process.c (50476) | process.c (90261) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)process.c 8.2 (Berkeley) 11/16/93"; 37#endif 38static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)process.c 8.2 (Berkeley) 11/16/93"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/libexec/talkd/process.c 50476 1999-08-28 00:22:10Z peter $"; | 39 "$FreeBSD: head/libexec/talkd/process.c 90261 2002-02-05 21:06:56Z imp $"; |
40#endif /* not lint */ 41 42/* 43 * process.c handles the requests, which can be of three types: 44 * ANNOUNCE - announce to a user that a talk is wanted 45 * LEAVE_INVITE - insert the request into the table 46 * LOOK_UP - look up to see if a request is waiting in 47 * in the table for the local user --- 7 unchanged lines hidden (view full) --- 55#include <ctype.h> 56#include <err.h> 57#include <netdb.h> 58#include <paths.h> 59#include <stdio.h> 60#include <string.h> 61#include <syslog.h> 62 | 40#endif /* not lint */ 41 42/* 43 * process.c handles the requests, which can be of three types: 44 * ANNOUNCE - announce to a user that a talk is wanted 45 * LEAVE_INVITE - insert the request into the table 46 * LOOK_UP - look up to see if a request is waiting in 47 * in the table for the local user --- 7 unchanged lines hidden (view full) --- 55#include <ctype.h> 56#include <err.h> 57#include <netdb.h> 58#include <paths.h> 59#include <stdio.h> 60#include <string.h> 61#include <syslog.h> 62 |
63int announce __P((CTL_MSG *, char *)); 64int delete_invite __P((int)); 65void do_announce __P((CTL_MSG *, CTL_RESPONSE *)); 66CTL_MSG *find_request(); 67CTL_MSG *find_match(); 68int find_user __P((char *, char *)); 69void insert_table __P((CTL_MSG *, CTL_RESPONSE *)); 70int new_id __P((void)); 71void print_request __P((char *, CTL_MSG *)); 72void print_response __P((char *, CTL_RESPONSE *)); | 63#include "extern.h" |
73 74void | 64 65void |
75process_request(mp, rp) 76 register CTL_MSG *mp; 77 register CTL_RESPONSE *rp; | 66process_request(CTL_MSG *mp, CTL_RESPONSE *rp) |
78{ | 67{ |
79 register CTL_MSG *ptr; | 68 CTL_MSG *ptr; |
80 extern int debug; 81 char *s; 82 83 rp->vers = TALK_VERSION; 84 rp->type = mp->type; 85 rp->id_num = htonl(0); 86 if (mp->vers != TALK_VERSION) { 87 syslog(LOG_WARNING, "bad protocol version %d", mp->vers); --- 58 unchanged lines hidden (view full) --- 146 rp->answer = UNKNOWN_REQUEST; 147 break; 148 } 149 if (debug) 150 print_response("process_request", rp); 151} 152 153void | 69 extern int debug; 70 char *s; 71 72 rp->vers = TALK_VERSION; 73 rp->type = mp->type; 74 rp->id_num = htonl(0); 75 if (mp->vers != TALK_VERSION) { 76 syslog(LOG_WARNING, "bad protocol version %d", mp->vers); --- 58 unchanged lines hidden (view full) --- 135 rp->answer = UNKNOWN_REQUEST; 136 break; 137 } 138 if (debug) 139 print_response("process_request", rp); 140} 141 142void |
154do_announce(mp, rp) 155 register CTL_MSG *mp; 156 CTL_RESPONSE *rp; | 143do_announce(CTL_MSG *mp, CTL_RESPONSE *rp) |
157{ 158 struct hostent *hp; 159 CTL_MSG *ptr; 160 int result; 161 162 /* see if the user is logged */ 163 result = find_user(mp->r_name, mp->r_tty); 164 if (result != SUCCESS) { --- 29 unchanged lines hidden (view full) --- 194} 195 196#include <utmp.h> 197 198/* 199 * Search utmp for the local user 200 */ 201int | 144{ 145 struct hostent *hp; 146 CTL_MSG *ptr; 147 int result; 148 149 /* see if the user is logged */ 150 result = find_user(mp->r_name, mp->r_tty); 151 if (result != SUCCESS) { --- 29 unchanged lines hidden (view full) --- 181} 182 183#include <utmp.h> 184 185/* 186 * Search utmp for the local user 187 */ 188int |
202find_user(name, tty) 203 char *name, *tty; | 189find_user(const char *name, char *tty) |
204{ 205 struct utmp ubuf; 206 int status; 207 FILE *fd; 208 struct stat statb; 209 time_t best = 0; 210 char line[sizeof(ubuf.ut_line) + 1]; 211 char ftty[sizeof(_PATH_DEV) - 1 + sizeof(line)]; --- 37 unchanged lines hidden --- | 190{ 191 struct utmp ubuf; 192 int status; 193 FILE *fd; 194 struct stat statb; 195 time_t best = 0; 196 char line[sizeof(ubuf.ut_line) + 1]; 197 char ftty[sizeof(_PATH_DEV) - 1 + sizeof(line)]; --- 37 unchanged lines hidden --- |