summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-04-13 23:57:50 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-04-13 23:57:50 +0000
commit80b5b9901c305254d64ef97baef59eaa1bd1e792 (patch)
treea81be1dd0449e5eb98cadaf0c11865235d8d9ddc /usr.sbin
parentd4e911c1cc791c196fcb9c9d13ec28a25e63053f (diff)
time_t and kill a few dumb defines
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/dhcpd/conflex.c4
-rw-r--r--usr.sbin/dhcpd/confpars.c8
-rw-r--r--usr.sbin/dhcpd/db.c8
-rw-r--r--usr.sbin/dhcpd/dhcp.c10
-rw-r--r--usr.sbin/dhcpd/dhcpd.c4
-rw-r--r--usr.sbin/dhcpd/dhcpd.h69
-rw-r--r--usr.sbin/dhcpd/dispatch.c6
-rw-r--r--usr.sbin/dhcpd/memory.c2
-rw-r--r--usr.sbin/dhcpd/parse.c28
-rw-r--r--usr.sbin/dhcpd/tree.c10
-rw-r--r--usr.sbin/dhcpd/tree.h4
11 files changed, 69 insertions, 84 deletions
diff --git a/usr.sbin/dhcpd/conflex.c b/usr.sbin/dhcpd/conflex.c
index 58136a2bc1a..cc7dde96aa3 100644
--- a/usr.sbin/dhcpd/conflex.c
+++ b/usr.sbin/dhcpd/conflex.c
@@ -94,7 +94,7 @@ static int get_char (cfile)
{
int c = getc (cfile);
if (!ugflag) {
- if (c == EOL) {
+ if (c == '\n') {
if (cur_line == line1) {
cur_line = line2;
prev_line = line1;
@@ -223,7 +223,7 @@ static void skip_to_eol (cfile)
c = get_char (cfile);
if (c == EOF)
return;
- if (c == EOL)
+ if (c == '\n')
return;
} while (1);
}
diff --git a/usr.sbin/dhcpd/confpars.c b/usr.sbin/dhcpd/confpars.c
index fec0c61d274..31bb48b9dda 100644
--- a/usr.sbin/dhcpd/confpars.c
+++ b/usr.sbin/dhcpd/confpars.c
@@ -43,7 +43,7 @@
#include "dhcpd.h"
#include "dhctoken.h"
-static TIME parsed_time;
+static time_t parsed_time;
/* conf-file :== parameters declarations EOF
parameters :== <nil> | parameter | parameters parameter
@@ -1122,10 +1122,10 @@ void parse_option_param (cfile, group)
but rather in the database file and the journal file. (Okay, actually
they're not even used there yet). */
-TIME parse_timestamp (cfile)
+time_t parse_timestamp (cfile)
FILE *cfile;
{
- TIME rv;
+ time_t rv;
rv = parse_date (cfile);
return rv;
@@ -1183,7 +1183,7 @@ struct lease *parse_lease_declaration (cfile)
/* Parse any of the times associated with the lease. */
if (token == STARTS || token == ENDS || token == TIMESTAMP) {
- TIME t;
+ time_t t;
t = parse_date (cfile);
switch (token) {
case STARTS:
diff --git a/usr.sbin/dhcpd/db.c b/usr.sbin/dhcpd/db.c
index ae39a2ec24e..dca8fb8ea9d 100644
--- a/usr.sbin/dhcpd/db.c
+++ b/usr.sbin/dhcpd/db.c
@@ -46,7 +46,7 @@ FILE *db_file;
static int counting = 0;
static int count = 0;
-TIME write_time;
+time_t write_time;
/* Write the specified lease to the current lease database file. */
@@ -199,7 +199,7 @@ void db_startup ()
/* Read in the existing lease file... */
read_leases ();
- GET_TIME (&write_time);
+ time(&write_time);
new_lease_file ();
}
@@ -207,7 +207,7 @@ void new_lease_file ()
{
char newfname [MAXPATHLEN];
char backfname [MAXPATHLEN];
- TIME t;
+ time_t t;
int db_fd;
/* If we already have an open database, close it. */
@@ -216,7 +216,7 @@ void new_lease_file ()
}
/* Make a temporary lease file... */
- GET_TIME (&t);
+ time(&t);
snprintf (newfname, sizeof newfname,"%s.%d", path_dhcpd_db, (int)t);
db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
if (db_fd == -1) {
diff --git a/usr.sbin/dhcpd/dhcp.c b/usr.sbin/dhcpd/dhcp.c
index eca34e64d60..56a3c112373 100644
--- a/usr.sbin/dhcpd/dhcp.c
+++ b/usr.sbin/dhcpd/dhcp.c
@@ -618,14 +618,14 @@ void ack_lease (packet, lease, offer, when)
struct packet *packet;
struct lease *lease;
unsigned int offer;
- TIME when;
+ time_t when;
{
struct lease lt;
struct lease_state *state;
- TIME lease_time;
- TIME offered_lease_time;
- TIME max_lease_time;
- TIME default_lease_time;
+ time_t lease_time;
+ time_t offered_lease_time;
+ time_t max_lease_time;
+ time_t default_lease_time;
int ulafdr;
struct class *vendor_class, *user_class;
diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c
index eff62fd6047..c03c12480e5 100644
--- a/usr.sbin/dhcpd/dhcpd.c
+++ b/usr.sbin/dhcpd/dhcpd.c
@@ -53,7 +53,7 @@ static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.htm
static void usage PROTO ((char *));
-TIME cur_time;
+time_t cur_time;
struct group root_group;
struct iaddr server_identifier;
@@ -189,7 +189,7 @@ int main (argc, argv)
remote_port = htons (ntohs (local_port) + 1);
/* Get the current time... */
- GET_TIME (&cur_time);
+ time(&cur_time);
/* Read the dhcpd.conf file... */
if (!readconf ())
diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h
index d97848fb82f..d87b0daad32 100644
--- a/usr.sbin/dhcpd/dhcpd.h
+++ b/usr.sbin/dhcpd/dhcpd.h
@@ -77,11 +77,7 @@ extern int h_errno;
#define ifr_netmask ifr_addr
-/* Varargs stuff... */
#include <stdarg.h>
-#define VA_DOTDOTDOT ...
-#define va_dcl
-#define VA_start(list, last) va_start (list, last)
#ifndef _PATH_DHCPD_PID
#define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
@@ -89,20 +85,9 @@ extern int h_errno;
#ifndef _PATH_DHCPD_DB
#define _PATH_DHCPD_DB "/var/db/dhcpd.leases"
#endif
-#ifndef _PATH_DHCLIENT_PID
-#define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
-#endif
-#ifndef _PATH_DHCLIENT_DB
-#define _PATH_DHCLIENT_DB "/var/db/dhclient.leases"
-#endif
-
-#define EOL '\n'
-#define VOIDPTR void *
/* Time stuff... */
#include <sys/time.h>
-#define TIME time_t
-#define GET_TIME(x) time ((x))
#define HAVE_SA_LEN
#define HAVE_MKSTEMP
@@ -139,14 +124,14 @@ struct string_list {
struct name_server {
struct name_server *next;
struct sockaddr_in addr;
- TIME rcdate;
+ time_t rcdate;
};
/* A domain search list element. */
struct domain_search_list {
struct domain_search_list *next;
char *domain;
- TIME rcdate;
+ time_t rcdate;
};
/* A dhcp packet and the pointers to its option values. */
@@ -181,7 +166,7 @@ struct lease {
struct lease *waitq_next;
struct iaddr ip_addr;
- TIME starts, ends, timestamp;
+ time_t starts, ends, timestamp;
unsigned char *uid;
int uid_len;
int uid_max;
@@ -211,7 +196,7 @@ struct lease_state {
struct interface_info *ip;
- TIME offered_expiry;
+ time_t offered_expiry;
struct tree_cache *options [256];
u_int32_t expiry, renewal, rebind;
@@ -261,10 +246,10 @@ struct group {
struct subnet *subnet;
struct shared_network *shared_network;
- TIME default_lease_time;
- TIME max_lease_time;
- TIME bootp_lease_cutoff;
- TIME bootp_lease_length;
+ time_t default_lease_time;
+ time_t max_lease_time;
+ time_t bootp_lease_cutoff;
+ time_t bootp_lease_length;
char *filename;
char *server_name;
@@ -326,7 +311,7 @@ struct class {
/* DHCP client lease structure... */
struct client_lease {
struct client_lease *next; /* Next lease in list. */
- TIME expiry, renewal, rebind; /* Lease timeouts. */
+ time_t expiry, renewal, rebind; /* Lease timeouts. */
struct iaddr address; /* Address being leased. */
char *server_name; /* Name of boot server. */
char *filename; /* Name of file we're supposed to boot. */
@@ -364,22 +349,22 @@ struct client_config {
u_int8_t required_options [256]; /* Options server must supply. */
u_int8_t requested_options [256]; /* Options to request from server. */
int requested_option_count; /* Number of requested options. */
- TIME timeout; /* Start to panic if we don't get a
+ time_t timeout; /* Start to panic if we don't get a
lease in this time period when
SELECTING. */
- TIME initial_interval; /* All exponential backoff intervals
+ time_t initial_interval; /* All exponential backoff intervals
start here. */
- TIME retry_interval; /* If the protocol failed to produce
+ time_t retry_interval; /* If the protocol failed to produce
an address before the timeout,
try the protocol again after this
many seconds. */
- TIME select_interval; /* Wait this many seconds from the
+ time_t select_interval; /* Wait this many seconds from the
first DHCPDISCOVER before
picking an offered lease. */
- TIME reboot_timeout; /* When in INIT-REBOOT, wait this
+ time_t reboot_timeout; /* When in INIT-REBOOT, wait this
long before giving up and going
to INIT. */
- TIME backoff_cutoff; /* When doing exponential backoff,
+ time_t backoff_cutoff; /* When doing exponential backoff,
never back off to an interval
longer than this amount. */
struct string_list *media; /* Possible network media values. */
@@ -404,8 +389,8 @@ struct client_state {
struct iaddr destination; /* Where to send packet. */
u_int32_t xid; /* Transaction ID. */
u_int16_t secs; /* secs value from DHCPDISCOVER. */
- TIME first_sending; /* When was first copy sent? */
- TIME interval; /* What's the current resend interval? */
+ time_t first_sending; /* When was first copy sent? */
+ time_t interval; /* What's the current resend interval? */
struct string_list *medium; /* Last media type tried. */
struct dhcp_packet packet; /* Outgoing DHCP packet. */
@@ -460,7 +445,7 @@ struct hardware_link {
struct timeout {
struct timeout *next;
- TIME when;
+ time_t when;
void (*func) PROTO ((void *));
void *what;
};
@@ -559,7 +544,7 @@ int debug (char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
int parse_warn (char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
/* dhcpd.c */
-extern TIME cur_time;
+extern time_t cur_time;
extern struct group root_group;
extern u_int16_t local_port;
@@ -599,7 +584,7 @@ int parse_lbrace PROTO ((FILE *));
void parse_host_declaration PROTO ((FILE *, struct group *));
char *parse_host_name PROTO ((FILE *));
void parse_class_declaration PROTO ((FILE *, struct group *, int));
-void parse_lease_time PROTO ((FILE *, TIME *));
+void parse_lease_time PROTO ((FILE *, time_t *));
void parse_shared_net_declaration PROTO ((FILE *, struct group *));
void parse_subnet_declaration PROTO ((FILE *, struct shared_network *));
void parse_group_declaration PROTO ((FILE *, struct group *));
@@ -608,10 +593,10 @@ char *parse_string PROTO ((FILE *));
struct tree *parse_ip_addr_or_hostname PROTO ((FILE *, int));
struct tree_cache *parse_fixed_addr_param PROTO ((FILE *));
void parse_option_param PROTO ((FILE *, struct group *));
-TIME parse_timestamp PROTO ((FILE *));
+time_t parse_timestamp PROTO ((FILE *));
struct lease *parse_lease_declaration PROTO ((FILE *));
void parse_address_range PROTO ((FILE *, struct subnet *));
-TIME parse_date PROTO ((FILE *));
+time_t parse_date PROTO ((FILE *));
unsigned char *parse_numeric_aggregate PROTO ((FILE *,
unsigned char *, int *,
int, int, int));
@@ -637,7 +622,7 @@ void dhcprelease PROTO ((struct packet *));
void dhcpdecline PROTO ((struct packet *));
void dhcpinform PROTO ((struct packet *));
void nak_lease PROTO ((struct packet *, struct iaddr *cip));
-void ack_lease PROTO ((struct packet *, struct lease *, unsigned int, TIME));
+void ack_lease PROTO ((struct packet *, struct lease *, unsigned int, time_t));
void dhcp_reply PROTO ((struct lease *));
struct lease *find_lease PROTO ((struct packet *,
struct shared_network *, int *));
@@ -681,8 +666,8 @@ void write_leases PROTO ((void));
void dump_subnets PROTO ((void));
/* alloc.c */
-VOIDPTR dmalloc PROTO ((int, char *));
-void dfree PROTO ((VOIDPTR, char *));
+void * dmalloc PROTO ((int, char *));
+void dfree PROTO ((void *, char *));
struct packet *new_packet PROTO ((char *));
struct dhcp_packet *new_dhcp_packet PROTO ((char *));
struct tree *new_tree PROTO ((char *));
@@ -889,7 +874,7 @@ void reinitialize_interfaces PROTO ((void));
void dispatch PROTO ((void));
int locate_network PROTO ((struct packet *));
void got_one PROTO ((struct protocol *));
-void add_timeout PROTO ((TIME, void (*) PROTO ((void *)), void *));
+void add_timeout PROTO ((time_t, void (*) PROTO ((void *)), void *));
void cancel_timeout PROTO ((void (*) PROTO ((void *)), void *));
void add_protocol PROTO ((char *, int,
void (*) PROTO ((struct protocol *)), void *));
@@ -1096,7 +1081,7 @@ extern char path_resolv_conf [];
struct name_server *name_servers;
struct domain_search_list *domains;
-void read_resolv_conf PROTO ((TIME));
+void read_resolv_conf PROTO ((time_t));
struct sockaddr_in *pick_name_server PROTO ((void));
/* inet_addr.c */
diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c
index 89a2f626ecd..4d1dd65a6b2 100644
--- a/usr.sbin/dhcpd/dispatch.c
+++ b/usr.sbin/dhcpd/dispatch.c
@@ -382,7 +382,7 @@ void dispatch ()
/* Not likely to be transitory... */
if (count == -1) {
if (errno == EAGAIN || errno == EINTR) {
- GET_TIME (&cur_time);
+ time(&cur_time);
continue;
}
else
@@ -390,7 +390,7 @@ void dispatch ()
}
/* Get the current time... */
- GET_TIME (&cur_time);
+ time(&cur_time);
i = 0;
for (l = protocols; l; l = l -> next) {
@@ -541,7 +541,7 @@ int locate_network (packet)
}
void add_timeout (when, where, what)
- TIME when;
+ time_t when;
void (*where) PROTO ((void *));
void *what;
{
diff --git a/usr.sbin/dhcpd/memory.c b/usr.sbin/dhcpd/memory.c
index d383320bf8a..9b36410ae4a 100644
--- a/usr.sbin/dhcpd/memory.c
+++ b/usr.sbin/dhcpd/memory.c
@@ -662,7 +662,7 @@ void abandon_lease (lease, message)
char *message;
{
struct lease lt;
- TIME abtime;
+ time_t abtime;
abtime = lease -> subnet -> group -> default_lease_time;
lease -> flags |= ABANDONED_LEASE;
diff --git a/usr.sbin/dhcpd/parse.c b/usr.sbin/dhcpd/parse.c
index 90949a9ef16..05bce05ba72 100644
--- a/usr.sbin/dhcpd/parse.c
+++ b/usr.sbin/dhcpd/parse.c
@@ -78,7 +78,7 @@ void skip_to_semi (cfile)
} else if (token == SEMI && !brace_count) {
token = next_token (&val, cfile);
return;
- } else if (token == EOL) {
+ } else if (token == '\n') {
/* EOL only happens when parsing /etc/resolv.conf,
and we treat it like a semicolon because the
resolv.conf file is line-oriented. */
@@ -260,7 +260,7 @@ void parse_hardware_param (cfile, hardware)
void parse_lease_time (cfile, timep)
FILE *cfile;
- TIME *timep;
+ time_t *timep;
{
char *val;
int token;
@@ -487,7 +487,7 @@ void convert_num (buf, str, base, size)
year/month/day; next is hours:minutes:seconds on a 24-hour
clock. */
-TIME parse_date (cfile)
+time_t parse_date (cfile)
FILE *cfile;
{
struct tm tm;
@@ -503,7 +503,7 @@ TIME parse_date (cfile)
parse_warn ("numeric day of week expected.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
tm.tm_wday = atoi (val);
@@ -513,7 +513,7 @@ TIME parse_date (cfile)
parse_warn ("numeric year expected.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
tm.tm_year = atoi (val);
if (tm.tm_year > 1900)
@@ -525,7 +525,7 @@ TIME parse_date (cfile)
parse_warn ("expected slash separating year from month.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
/* Month... */
@@ -534,7 +534,7 @@ TIME parse_date (cfile)
parse_warn ("numeric month expected.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
tm.tm_mon = atoi (val) - 1;
@@ -544,7 +544,7 @@ TIME parse_date (cfile)
parse_warn ("expected slash separating month from day.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
/* Month... */
@@ -553,7 +553,7 @@ TIME parse_date (cfile)
parse_warn ("numeric day of month expected.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
tm.tm_mday = atoi (val);
@@ -563,7 +563,7 @@ TIME parse_date (cfile)
parse_warn ("numeric hour expected.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
tm.tm_hour = atoi (val);
@@ -573,7 +573,7 @@ TIME parse_date (cfile)
parse_warn ("expected colon separating hour from minute.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
/* Minute... */
@@ -582,7 +582,7 @@ TIME parse_date (cfile)
parse_warn ("numeric minute expected.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
tm.tm_min = atoi (val);
@@ -592,7 +592,7 @@ TIME parse_date (cfile)
parse_warn ("expected colon separating hour from minute.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
/* Minute... */
@@ -601,7 +601,7 @@ TIME parse_date (cfile)
parse_warn ("numeric minute expected.");
if (token != SEMI)
skip_to_semi (cfile);
- return (TIME)0;
+ return (NULL);
}
tm.tm_sec = atoi (val);
tm.tm_isdst = 0;
diff --git a/usr.sbin/dhcpd/tree.c b/usr.sbin/dhcpd/tree.c
index e8912ae63fe..cd69abd366f 100644
--- a/usr.sbin/dhcpd/tree.c
+++ b/usr.sbin/dhcpd/tree.c
@@ -42,9 +42,9 @@
#include "dhcpd.h"
-static TIME tree_evaluate_recurse PROTO ((int *, unsigned char **, int *,
+static time_t tree_evaluate_recurse PROTO ((int *, unsigned char **, int *,
struct tree *));
-static TIME do_host_lookup PROTO ((int *, unsigned char **, int *,
+static time_t do_host_lookup PROTO ((int *, unsigned char **, int *,
struct dns_host_entry *));
static void do_data_copy PROTO ((int *, unsigned char **, int *,
unsigned char *, int));
@@ -232,14 +232,14 @@ int tree_evaluate (tree_cache)
return 1;
}
-static TIME tree_evaluate_recurse (bufix, bufp, bufcount, tree)
+static time_t tree_evaluate_recurse (bufix, bufp, bufcount, tree)
int *bufix;
unsigned char **bufp;
int *bufcount;
struct tree *tree;
{
int limit;
- TIME t1, t2;
+ time_t t1, t2;
switch (tree -> op) {
case TREE_CONCAT:
@@ -276,7 +276,7 @@ static TIME tree_evaluate_recurse (bufix, bufp, bufcount, tree)
}
}
-static TIME do_host_lookup (bufix, bufp, bufcount, dns)
+static time_t do_host_lookup (bufix, bufp, bufcount, dns)
int *bufix;
unsigned char **bufp;
int *bufcount;
diff --git a/usr.sbin/dhcpd/tree.h b/usr.sbin/dhcpd/tree.h
index c2df41f52b1..73956be528c 100644
--- a/usr.sbin/dhcpd/tree.h
+++ b/usr.sbin/dhcpd/tree.h
@@ -79,14 +79,14 @@ struct dns_host_entry {
unsigned char *data;
int data_len;
int buf_len;
- TIME timeout;
+ time_t timeout;
};
struct tree_cache {
unsigned char *value;
int len;
int buf_size;
- TIME timeout;
+ time_t timeout;
struct tree *tree;
int flags;
#define TC_AWAITING_RESOLUTION 1