1997-06-03 03:59:31 +08:00
|
|
|
#include "miscfn.h"
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef __aix__
|
|
|
|
#define COMMENTCHAR '*'
|
|
|
|
#else
|
|
|
|
#define COMMENTCHAR '#'
|
|
|
|
#endif
|
|
|
|
|
1997-06-04 00:08:23 +08:00
|
|
|
our_mntent *getmntent(FILE *filep) {
|
|
|
|
static our_mntent item = { NULL };
|
1997-06-03 03:59:31 +08:00
|
|
|
char buf[1024], * start;
|
|
|
|
char * chptr;
|
|
|
|
|
1997-06-04 00:08:23 +08:00
|
|
|
if (item.our_mntdir) {
|
|
|
|
free(item.our_mntdir);
|
1997-06-03 03:59:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
1997-06-04 00:08:23 +08:00
|
|
|
item.our_mntdir = strdup(start);
|
1997-06-03 03:59:31 +08:00
|
|
|
return &item;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|