diff options
| author | xHire <xhire@tuxportal.cz> | 2008-10-25 14:11:06 +0200 |
|---|---|---|
| committer | xHire <xhire@tuxportal.cz> | 2008-10-25 14:11:06 +0200 |
| commit | c8a9209d77a896bf49227e5aeccd54e91ccf29cc (patch) | |
| tree | 6b7367406ebbc6ce3ea5e0c8668c75f6fb3f6ae9 /src/base/director.c | |
| parent | cb9deba915dd7b114eeb76601eb1c8b07c1ba90f (diff) | |
Changed style of the code to the K&R standard
Diffstat (limited to 'src/base/director.c')
| -rw-r--r-- | src/base/director.c | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/src/base/director.c b/src/base/director.c index eea7ea4..dfcc9cb 100644 --- a/src/base/director.c +++ b/src/base/director.c @@ -10,54 +10,51 @@ #include "main.h" #include "list.h" -typedef struct director_struct -{ - char *path; - list_t *list; +typedef struct director_struct { + char *path; + list_t *list; } director_t; -director_t * -loadDirector(char *s) +director_t *loadDirector(char *s) { - director_t *new; - DIR *dir; - struct dirent *item; - char path[STR_PATH_SIZE]; - assert(s != 0); - new = malloc(sizeof(director_t)); - memset(new, 0, sizeof(director_t)); - new->list = newList(); + director_t *new; + DIR *dir; + struct dirent *item; + char path[STR_PATH_SIZE]; + assert(s != 0); + new = malloc(sizeof(director_t)); + memset(new, 0, sizeof(director_t)); + new->list = newList(); #ifndef __WIN32__ - if (s[0] == '/') + if (s[0] == '/') #else - if (s[1] == ':') + if (s[1] == ':') #endif - strcpy(path, s); - else { - // this is really correct aproach - getcwd(path, STR_PATH_SIZE); - strcat(path, "/"); - strcat(path, s); - } - new->path = strdup(path); - dir = opendir(new->path); - if (dir == NULL) { - free(new->path); - free(new); - return NULL; - } + strcpy(path, s); + else { + // this is really correct aproach + getcwd(path, STR_PATH_SIZE); + strcat(path, "/"); + strcat(path, s); + } + new->path = strdup(path); + dir = opendir(new->path); + if (dir == NULL) { + free(new->path); + free(new); + return NULL; + } - while ((item = readdir(dir)) != NULL) - addList(new->list, strdup(item->d_name)); - closedir(dir); - return new; + while ((item = readdir(dir)) != NULL) + addList(new->list, strdup(item->d_name)); + closedir(dir); + return new; } -void -destroyDirector(director_t * p) +void destroyDirector(director_t * p) { - assert(p != NULL); - destroyListItem(p->list, free); - free(p->path); - free(p); + assert(p != NULL); + destroyListItem(p->list, free); + free(p->path); + free(p); } |