X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=rmt%2Frmt.c;fp=rmt%2Frmt.c;h=fc6eb827f4788c0c60b878f918c1eb0fc0e394b8;hp=fc8ebce49eec2c95bb89cb7f978ae0f87ac4a077;hb=ba3af39e8b08027d3338b5533bddc86a9c803a74;hpb=4095abc031a4b91bd6d056ff2b6cf9e7cd568afc diff --git a/rmt/rmt.c b/rmt/rmt.c index fc8ebce..fc6eb82 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: rmt.c,v 1.20 2002/05/21 15:48:46 stelian Exp $"; + "$Id: rmt.c,v 1.21 2002/07/29 12:00:34 stelian Exp $"; #endif /* not linux */ /* @@ -49,6 +49,7 @@ static const char rcsid[] = */ #include #include +#include #include #include #include @@ -117,7 +118,6 @@ static int rmt_version = 0; char *checkbuf __P((char *, int)); void error __P((int)); void getstring __P((char *)); -int getopenflags __P((char *)); int main(int argc, char *argv[]) @@ -150,7 +150,7 @@ top: /* * Translate extended GNU syntax into its numeric platform equivalent */ - oflags = getopenflags(filemode); + oflags = rmtflags_toint(filemode); #ifdef O_TEXT /* * Default to O_BINARY the client may not know that we need it. @@ -458,96 +458,3 @@ error(int num) (void)snprintf(resp, sizeof(resp), "E%d\n%s\n", num, strerror(num)); (void)write(1, resp, strlen(resp)); } - -struct openflags { - char *name; - int value; -} openflags[] = { - { "O_RDONLY", O_RDONLY }, - { "O_WRONLY", O_WRONLY }, - { "O_RDWR", O_RDWR }, -#ifdef O_CREAT - { "O_CREAT", O_CREAT }, -#endif -#ifdef O_EXCL - { "O_EXCL", O_EXCL }, -#endif -#ifdef O_NOCTTY - { "O_NOCTTY", O_NOCTTY }, -#endif -#ifdef O_TRUNC - { "O_TRUNC", O_TRUNC }, -#endif -#ifdef O_APPEND - { "O_APPEND", O_APPEND }, -#endif -#ifdef O_NONBLOCK - { "O_NONBLOCK", O_NONBLOCK }, -#endif -#ifdef O_NDELAY - { "O_NDELAY", O_NDELAY }, -#endif -#ifdef O_SYNC - { "O_SYNC", O_SYNC }, -#endif -#ifdef O_FSYNC - { "O_FSYNC", O_FSYNC }, -#endif -#ifdef O_ASYNC - { "O_ASYNC", O_ASYNC }, -#endif -#ifdef O_TEXT - { "O_TEXT", O_TEXT }, -#endif -#ifdef O_DSYNC - { "O_DSYNC", O_DSYNC }, -#endif -#ifdef O_RSYNC - { "O_RSYNC", O_RSYNC }, -#endif -#ifdef O_PRIV - { "O_PRIV", O_PRIV }, -#endif -#ifdef O_LARGEFILE - { "O_LARGEFILE",O_LARGEFILE }, -#endif - { NULL, 0 } -}; - -/* Parts of this stolen again from Jörg Schilling's star package... */ -int -getopenflags(char *filemode) -{ - char *p = filemode; - struct openflags *op; - int result = 0; - - do { - /* skip space */ - while (*p != '\0' && *p == ' ') - p++; - /* get O_XXXX constant */ - if (p[0] != 'O' || p[1] != '_') { - /* numeric syntax detected */ - result = atoi(filemode); - result &= O_RDONLY | O_WRONLY | O_RDWR; - return result; - } - - /* translate O_XXXX constant */ - for (op = openflags; op->name; op++) { - int slen = strlen(op->name); - if ((strncmp(op->name, p, slen) == 0) && - (p[slen] == '|' || p[slen] == ' ' || - p[slen] == '\0')) { - result |= op->value; - break; - } - } - - /* goto next constant */ - p = strchr(p, '|'); - } while (p && *p++ == '|'); - - return result; -}