version 1.4, 1997/02/03 01:02:42 |
version 1.5, 1997/02/03 01:05:44 |
|
|
|
/* $OpenBSD$ */ |
/* $NetBSD: ruserpass.c,v 1.11 1997/01/19 14:19:16 lukem Exp $ */ |
/* $NetBSD: ruserpass.c,v 1.11 1997/01/19 14:19:16 lukem Exp $ */ |
|
|
/* |
/* |
|
|
#if 0 |
#if 0 |
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95"; |
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95"; |
#else |
#else |
static char rcsid[] = "$NetBSD: ruserpass.c,v 1.11 1997/01/19 14:19:16 lukem Exp $"; |
static char rcsid[] = "$OpenBSD$"; |
#endif |
#endif |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
|
|
if (hdir == NULL) |
if (hdir == NULL) |
hdir = "."; |
hdir = "."; |
if (strlen(hdir) + sizeof(".netrc") < sizeof(buf)) { |
if (strlen(hdir) + sizeof(".netrc") < sizeof(buf)) { |
(void) sprintf(buf, "%s/.netrc", hdir); |
(void)sprintf(buf, "%s/.netrc", hdir); |
} else { |
} else { |
warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG)); |
warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG)); |
return (0); |
return (0); |
|
|
if (*aname == 0) { |
if (*aname == 0) { |
*aname = malloc((unsigned) |
*aname = malloc((unsigned) |
strlen(tokval) + 1); |
strlen(tokval) + 1); |
(void) strcpy(*aname, tokval); |
(void)strcpy(*aname, tokval); |
} else { |
} else { |
if (strcmp(*aname, tokval)) |
if (strcmp(*aname, tokval)) |
goto next; |
goto next; |
|
|
} |
} |
if (token() && *apass == 0) { |
if (token() && *apass == 0) { |
*apass = malloc((unsigned) strlen(tokval) + 1); |
*apass = malloc((unsigned) strlen(tokval) + 1); |
(void) strcpy(*apass, tokval); |
(void)strcpy(*apass, tokval); |
} |
} |
break; |
break; |
case ACCOUNT: |
case ACCOUNT: |
|
|
} |
} |
if (token() && *aacct == 0) { |
if (token() && *aacct == 0) { |
*aacct = malloc((unsigned) strlen(tokval) + 1); |
*aacct = malloc((unsigned) strlen(tokval) + 1); |
(void) strcpy(*aacct, tokval); |
(void)strcpy(*aacct, tokval); |
} |
} |
break; |
break; |
case MACDEF: |
case MACDEF: |
if (proxy) { |
if (proxy) { |
(void) fclose(cfile); |
(void)fclose(cfile); |
return (0); |
return (0); |
} |
} |
while ((c=getc(cfile)) != EOF) |
while ((c=getc(cfile)) != EOF) |
if (c != ' ' && c != '\t') |
if (c != ' ' && c != '\t') |
break; |
break; |
if (c == EOF || c == '\n') { |
if (c == EOF || c == '\n') { |
printf("Missing macdef name argument.\n"); |
puts("Missing macdef name argument."); |
goto bad; |
goto bad; |
} |
} |
if (macnum == 16) { |
if (macnum == 16) { |
printf( |
puts( |
"Limit of 16 macros have already been defined\n"); |
"Limit of 16 macros have already been defined"); |
goto bad; |
goto bad; |
} |
} |
tmp = macros[macnum].mac_name; |
tmp = macros[macnum].mac_name; |
|
|
*tmp++ = c; |
*tmp++ = c; |
} |
} |
if (c == EOF) { |
if (c == EOF) { |
printf( |
puts( |
"Macro definition missing null line terminator.\n"); |
"Macro definition missing null line terminator."); |
goto bad; |
goto bad; |
} |
} |
*tmp = '\0'; |
*tmp = '\0'; |
|
|
while ((c=getc(cfile)) != EOF && c != '\n'); |
while ((c=getc(cfile)) != EOF && c != '\n'); |
} |
} |
if (c == EOF) { |
if (c == EOF) { |
printf( |
puts( |
"Macro definition missing null line terminator.\n"); |
"Macro definition missing null line terminator."); |
goto bad; |
goto bad; |
} |
} |
if (macnum == 0) { |
if (macnum == 0) { |
|
|
tmp = macros[macnum].mac_start; |
tmp = macros[macnum].mac_start; |
while (tmp != macbuf + 4096) { |
while (tmp != macbuf + 4096) { |
if ((c=getc(cfile)) == EOF) { |
if ((c=getc(cfile)) == EOF) { |
printf( |
puts( |
"Macro definition missing null line terminator.\n"); |
"Macro definition missing null line terminator."); |
goto bad; |
goto bad; |
} |
} |
*tmp = c; |
*tmp = c; |
|
|
tmp++; |
tmp++; |
} |
} |
if (tmp == macbuf + 4096) { |
if (tmp == macbuf + 4096) { |
printf("4K macro buffer exceeded\n"); |
puts("4K macro buffer exceeded"); |
goto bad; |
goto bad; |
} |
} |
break; |
break; |
|
|
goto done; |
goto done; |
} |
} |
done: |
done: |
(void) fclose(cfile); |
(void)fclose(cfile); |
return (0); |
return (0); |
bad: |
bad: |
(void) fclose(cfile); |
(void)fclose(cfile); |
return (-1); |
return (-1); |
} |
} |
|
|