util.c (1591) | util.c (2537) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 37 unchanged lines hidden (view full) --- 46#include <utmp.h> 47#include <errno.h> 48#include <unistd.h> 49#include <stdio.h> 50#include <ctype.h> 51#include <stdlib.h> 52#include <string.h> 53#include <paths.h> | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 37 unchanged lines hidden (view full) --- 46#include <utmp.h> 47#include <errno.h> 48#include <unistd.h> 49#include <stdio.h> 50#include <ctype.h> 51#include <stdlib.h> 52#include <string.h> 53#include <paths.h> |
54#include <errno.h> |
|
54#include "finger.h" 55 56static void find_idle_and_ttywrite __P((WHERE *)); 57static void userinfo __P((PERSON *, struct passwd *)); 58static WHERE *walloc __P((PERSON *)); 59 60int 61match(pw, user) --- 209 unchanged lines hidden (view full) --- 271 *p++ = '-'; 272 /* FALLTHROUGH */ 273 case 7: /* 012-3456 */ 274 *p++ = *num++; 275 *p++ = *num++; 276 *p++ = *num++; 277 break; 278 case 5: /* x0-1234 */ | 55#include "finger.h" 56 57static void find_idle_and_ttywrite __P((WHERE *)); 58static void userinfo __P((PERSON *, struct passwd *)); 59static WHERE *walloc __P((PERSON *)); 60 61int 62match(pw, user) --- 209 unchanged lines hidden (view full) --- 272 *p++ = '-'; 273 /* FALLTHROUGH */ 274 case 7: /* 012-3456 */ 275 *p++ = *num++; 276 *p++ = *num++; 277 *p++ = *num++; 278 break; 279 case 5: /* x0-1234 */ |
280 case 4: /* x1234 */ |
|
279 *p++ = 'x'; 280 *p++ = *num++; 281 break; 282 default: 283 return(num); 284 } | 281 *p++ = 'x'; 282 *p++ = *num++; 283 break; 284 default: 285 return(num); 286 } |
285 *p++ = '-'; | 287 if (len != 4) { 288 *p++ = '-'; 289 *p++ = *num++; 290 } |
286 *p++ = *num++; 287 *p++ = *num++; 288 *p++ = *num++; | 291 *p++ = *num++; 292 *p++ = *num++; 293 *p++ = *num++; |
289 *p++ = *num++; | |
290 *p = '\0'; 291 return(pbuf); 292} 293 294static void 295find_idle_and_ttywrite(w) 296 register WHERE *w; 297{ --- 14 unchanged lines hidden (view full) --- 312 313static void 314userinfo(pn, pw) 315 register PERSON *pn; 316 register struct passwd *pw; 317{ 318 register char *p, *t; 319 char *bp, name[1024]; | 294 *p = '\0'; 295 return(pbuf); 296} 297 298static void 299find_idle_and_ttywrite(w) 300 register WHERE *w; 301{ --- 14 unchanged lines hidden (view full) --- 316 317static void 318userinfo(pn, pw) 319 register PERSON *pn; 320 register struct passwd *pw; 321{ 322 register char *p, *t; 323 char *bp, name[1024]; |
324 struct stat sb; |
|
320 321 pn->realname = pn->office = pn->officephone = pn->homephone = NULL; 322 323 pn->uid = pw->pw_uid; 324 pn->name = strdup(pw->pw_name); 325 pn->dir = strdup(pw->pw_dir); 326 pn->shell = strdup(pw->pw_shell); 327 --- 16 unchanged lines hidden (view full) --- 344 ++t; 345 pn->realname = strdup(name); 346 pn->office = ((p = strsep(&bp, ",")) && *p) ? 347 strdup(p) : NULL; 348 pn->officephone = ((p = strsep(&bp, ",")) && *p) ? 349 strdup(p) : NULL; 350 pn->homephone = ((p = strsep(&bp, ",")) && *p) ? 351 strdup(p) : NULL; | 325 326 pn->realname = pn->office = pn->officephone = pn->homephone = NULL; 327 328 pn->uid = pw->pw_uid; 329 pn->name = strdup(pw->pw_name); 330 pn->dir = strdup(pw->pw_dir); 331 pn->shell = strdup(pw->pw_shell); 332 --- 16 unchanged lines hidden (view full) --- 349 ++t; 350 pn->realname = strdup(name); 351 pn->office = ((p = strsep(&bp, ",")) && *p) ? 352 strdup(p) : NULL; 353 pn->officephone = ((p = strsep(&bp, ",")) && *p) ? 354 strdup(p) : NULL; 355 pn->homephone = ((p = strsep(&bp, ",")) && *p) ? 356 strdup(p) : NULL; |
357 (void)sprintf(tbuf,"%s/%s", _PATH_MAILDIR, pw->pw_name); 358 pn->mailrecv = -1; /* -1 == not_valid */ 359 if (stat(tbuf, &sb) < 0) { 360 if (errno != ENOENT) { 361 (void)fprintf(stderr, 362 "finger: %s: %s\n", tbuf, strerror(errno)); 363 return; 364 } 365 } else if (sb.st_size != 0) { 366 pn->mailrecv = sb.st_mtime; 367 pn->mailread = sb.st_atime; 368 } |
|
352} 353 354#if __STDC__ 355#include <stdarg.h> 356#else 357#include <varargs.h> 358#endif 359 --- 22 unchanged lines hidden --- | 369} 370 371#if __STDC__ 372#include <stdarg.h> 373#else 374#include <varargs.h> 375#endif 376 --- 22 unchanged lines hidden --- |