/* * lease-time :== NUMBER SEMI */ void parse_lease_time(FILE *cfile, time_t *timep) { char *val; int token; token = next_token(&val, cfile); if (token != NUMBER) { parse_warn("Expecting numeric lease time"); skip_to_semi(cfile); return; } convert_num((unsigned char *)timep, val, 10, 32); /* Unswap the number - convert_num returns stuff in NBO. */ *timep = ntohl(*timep); /* XXX */ parse_semi(cfile); }
/* * string-parameter :== STRING SEMI */ char * parse_string(FILE *cfile) { char *val, *s; int token; token = next_token(&val, cfile); if (token != TOK_STRING) { parse_warn("filename must be a string"); skip_to_semi(cfile); return (NULL); } s = strdup(val); if (!s) error("no memory for string %s.", val); if (!parse_semi(cfile)) { free(s); return (NULL); } return (s); }
/* * string-parameter :== STRING SEMI */ char * parse_string(FILE *cfile) { char *val, *s; size_t valsize; int token; token = next_token(&val, cfile); if (token != STRING) { parse_warn("filename must be a string"); skip_to_semi(cfile); return (NULL); } valsize = strlen(val) + 1; s = malloc(valsize); if (!s) error("no memory for string %s.", val); memcpy(s, val, valsize); if (!parse_semi(cfile)) return (NULL); return (s); }