From 9d4730cf181e1e1c69ac119ab18ae3ae3ac0f0d6 Mon Sep 17 00:00:00 2001 From: imp Date: Tue, 5 Feb 2002 21:06:56 +0000 Subject: o Move externs to extern.h o Use new-style prototypes exclusively rather than the old foo() style. o Use new-style function definitions. o remove register o make functions passed to signal have the right signature. o do minor const poisoning. --- libexec/talkd/announce.c | 14 ++++---------- libexec/talkd/extern.h | 40 ++++++++++++++++++++++++++++++++++++++++ libexec/talkd/print.c | 10 ++++------ libexec/talkd/process.c | 24 +++++------------------- libexec/talkd/table.c | 38 +++++++++++++++----------------------- libexec/talkd/talkd.c | 11 ++++------- 6 files changed, 72 insertions(+), 65 deletions(-) create mode 100644 libexec/talkd/extern.h (limited to 'libexec/talkd') diff --git a/libexec/talkd/announce.c b/libexec/talkd/announce.c index 2761c41..6d33005 100644 --- a/libexec/talkd/announce.c +++ b/libexec/talkd/announce.c @@ -58,11 +58,10 @@ static const char rcsid[] = #include #include "ttymsg.h" +#include "extern.h" extern char hostname[]; -int print_mesg __P((char *, FILE *, CTL_MSG *, char *)); - /* * Announce an invitation to talk. */ @@ -72,9 +71,7 @@ int print_mesg __P((char *, FILE *, CTL_MSG *, char *)); * a talk is requested. */ int -announce(request, remote_machine) - CTL_MSG *request; - char *remote_machine; +announce(CTL_MSG *request, const char *remote_machine) { char full_tty[32]; FILE *tf; @@ -98,11 +95,8 @@ announce(request, remote_machine) * in in vi at the time */ int -print_mesg(tty, tf, request, remote_machine) - char *tty; - FILE *tf; - CTL_MSG *request; - char *remote_machine; +print_mesg(const char *tty, FILE *tf, CTL_MSG *request, + const char *remote_machine) { struct timeval clock; time_t clock_sec; diff --git a/libexec/talkd/extern.h b/libexec/talkd/extern.h new file mode 100644 index 0000000..56edbd1 --- /dev/null +++ b/libexec/talkd/extern.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2002 M. Warner Losh. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +int announce(CTL_MSG *, const char *); +int delete_invite(int); +void do_announce(CTL_MSG *, CTL_RESPONSE *); +CTL_MSG *find_request(CTL_MSG *request); +CTL_MSG *find_match(CTL_MSG *request); +int find_user(const char *name, char *tty); +void insert_table(CTL_MSG *, CTL_RESPONSE *); +int new_id(void); +int print_mesg(const char *, FILE *, CTL_MSG *, const char *); +void print_request(const char *, CTL_MSG *); +void print_response(const char *, CTL_RESPONSE *); +void process_request(CTL_MSG *mp, CTL_RESPONSE *rp); +void timeout(int sig); diff --git a/libexec/talkd/print.c b/libexec/talkd/print.c index 8c1ba9b..94b87b4 100644 --- a/libexec/talkd/print.c +++ b/libexec/talkd/print.c @@ -47,6 +47,8 @@ static const char rcsid[] = #include #include +#include "extern.h" + static char *types[] = { "leave_invite", "look_up", "delete", "announce" }; #define NTYPES (sizeof (types) / sizeof (types[0])) @@ -56,9 +58,7 @@ static char *answers[] = #define NANSWERS (sizeof (answers) / sizeof (answers[0])) void -print_request(cp, mp) - char *cp; - register CTL_MSG *mp; +print_request(const char *cp, CTL_MSG *mp) { char tbuf[80], *tp; @@ -72,9 +72,7 @@ print_request(cp, mp) } void -print_response(cp, rp) - char *cp; - register CTL_RESPONSE *rp; +print_response(const char *cp, CTL_RESPONSE *rp) { char tbuf[80], *tp, abuf[80], *ap; diff --git a/libexec/talkd/process.c b/libexec/talkd/process.c index b3659a5..fb09300 100644 --- a/libexec/talkd/process.c +++ b/libexec/talkd/process.c @@ -60,23 +60,12 @@ static const char rcsid[] = #include #include -int announce __P((CTL_MSG *, char *)); -int delete_invite __P((int)); -void do_announce __P((CTL_MSG *, CTL_RESPONSE *)); -CTL_MSG *find_request(); -CTL_MSG *find_match(); -int find_user __P((char *, char *)); -void insert_table __P((CTL_MSG *, CTL_RESPONSE *)); -int new_id __P((void)); -void print_request __P((char *, CTL_MSG *)); -void print_response __P((char *, CTL_RESPONSE *)); +#include "extern.h" void -process_request(mp, rp) - register CTL_MSG *mp; - register CTL_RESPONSE *rp; +process_request(CTL_MSG *mp, CTL_RESPONSE *rp) { - register CTL_MSG *ptr; + CTL_MSG *ptr; extern int debug; char *s; @@ -151,9 +140,7 @@ process_request(mp, rp) } void -do_announce(mp, rp) - register CTL_MSG *mp; - CTL_RESPONSE *rp; +do_announce(CTL_MSG *mp, CTL_RESPONSE *rp) { struct hostent *hp; CTL_MSG *ptr; @@ -199,8 +186,7 @@ do_announce(mp, rp) * Search utmp for the local user */ int -find_user(name, tty) - char *name, *tty; +find_user(const char *name, char *tty) { struct utmp ubuf; int status; diff --git a/libexec/talkd/table.c b/libexec/talkd/table.c index 5062c78..28e8d8e 100644 --- a/libexec/talkd/table.c +++ b/libexec/talkd/table.c @@ -57,6 +57,8 @@ static const char rcsid[] = #include #include +#include "extern.h" + #define MAX_ID 16000 /* << 2^15 so I don't have sign troubles */ #define NIL ((TABLE_ENTRY *)0) @@ -74,23 +76,18 @@ struct table_entry { TABLE_ENTRY *last; }; -TABLE_ENTRY *table = NIL; +static void delete(TABLE_ENTRY *); -void delete __P((TABLE_ENTRY *)); -CTL_MSG *find_request(); -CTL_MSG *find_match(); -int new_id __P((void)); -void print_request __P((char *, CTL_MSG *)); +TABLE_ENTRY *table = NIL; /* * Look in the table for an invitation that matches the current * request looking for an invitation */ CTL_MSG * -find_match(request) - register CTL_MSG *request; +find_match(CTL_MSG *request) { - register TABLE_ENTRY *ptr; + TABLE_ENTRY *ptr; time_t current_time; gettimeofday(&tp, &txp); @@ -121,10 +118,9 @@ find_match(request) * one as find_match does */ CTL_MSG * -find_request(request) - register CTL_MSG *request; +find_request(CTL_MSG *request) { - register TABLE_ENTRY *ptr; + TABLE_ENTRY *ptr; time_t current_time; gettimeofday(&tp, &txp); @@ -159,11 +155,9 @@ find_request(request) } void -insert_table(request, response) - CTL_MSG *request; - CTL_RESPONSE *response; +insert_table(CTL_MSG *request, CTL_RESPONSE *response) { - register TABLE_ENTRY *ptr; + TABLE_ENTRY *ptr; time_t current_time; gettimeofday(&tp, &txp); @@ -189,7 +183,7 @@ insert_table(request, response) * Generate a unique non-zero sequence number */ int -new_id() +new_id(void) { static int current_id = 0; @@ -204,10 +198,9 @@ new_id() * Delete the invitation with id 'id_num' */ int -delete_invite(id_num) - int id_num; +delete_invite(int id_num) { - register TABLE_ENTRY *ptr; + TABLE_ENTRY *ptr; ptr = table; if (debug) @@ -228,9 +221,8 @@ delete_invite(id_num) /* * Classic delete from a double-linked list */ -void -delete(ptr) - register TABLE_ENTRY *ptr; +static void +delete(TABLE_ENTRY *ptr) { if (debug) diff --git a/libexec/talkd/talkd.c b/libexec/talkd/talkd.c index 551fd5b..d35c0e3 100644 --- a/libexec/talkd/talkd.c +++ b/libexec/talkd/talkd.c @@ -66,6 +66,8 @@ static const char rcsid[] = #include #include +#include "extern.h" + CTL_MSG request; CTL_RESPONSE response; @@ -78,13 +80,8 @@ char hostname[MAXHOSTNAMELEN]; #define TIMEOUT 30 #define MAXIDLE 120 -void process_request __P((CTL_MSG *, CTL_RESPONSE *)); -void timeout(); - int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { register CTL_MSG *mp = &request; int cc; @@ -130,7 +127,7 @@ main(argc, argv) } void -timeout() +timeout(int sig __unused) { int save_errno = errno; -- cgit v1.1