diff options
author | ewt <devnull@localhost> | 1997-06-02 19:59:31 +0000 |
---|---|---|
committer | ewt <devnull@localhost> | 1997-06-02 19:59:31 +0000 |
commit | 7ba07d0e70ba58d0d79d9a48169a5b479b3bea95 (patch) | |
tree | 4751620ab549fb9cf5a56f1424e325dba6b5eb1d | |
parent | 9b9de6ce15f26c7214423fdcaa8c9d8a9e598044 (diff) | |
download | librpm-tizen-7ba07d0e70ba58d0d79d9a48169a5b479b3bea95.tar.gz librpm-tizen-7ba07d0e70ba58d0d79d9a48169a5b479b3bea95.tar.bz2 librpm-tizen-7ba07d0e70ba58d0d79d9a48169a5b479b3bea95.zip |
*** empty log message ***
CVS patchset: 1680
CVS date: 1997/06/02 19:59:31
-rw-r--r-- | misc/getmntent.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/misc/getmntent.c b/misc/getmntent.c new file mode 100644 index 000000000..69eb1887b --- /dev/null +++ b/misc/getmntent.c @@ -0,0 +1,58 @@ +#include "miscfn.h" + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifdef __aix__ +#define COMMENTCHAR '*' +#else +#define COMMENTCHAR '#' +#endif + +struct mntent *getmntent(FILE *filep) { + static struct mntent item = { NULL }; + char buf[1024], * start; + char * chptr; + + if (item.mnt_dir) { + free(item.mnt_dir); + } + + while (fgets(buf, sizeof(buf) - 1, filep)) { + /* chop off \n */ + buf[strlen(buf) - 1] = '\0'; + + chptr = buf; + while (isspace(*chptr)) chptr++; + + if (*chptr == COMMENTCHAR) continue; + + #if __aix__ + /* aix uses a screwed up file format */ + if (*chptr == '/') { + start = chptr; + while (*chptr != ':') chptr++; + *chptr = '\0'; + item.mnt_dir = strdup(start); + return &item; + } + #else + while (!isspace(*chptr) && (*chptr)) chptr++; + if (!*chptr) return NULL; + + while (isspace(*chptr) && (*chptr)) chptr++; + if (!*chptr) return NULL; + start = chptr; + + while (!isspace(*chptr) && (*chptr)) chptr++; + *chptr = '\0'; + + item.mnt_dir = strdup(start); + return &item; + #endif + } + + return NULL; +} |