announce.c (0b67b493a9e20a8b409768d7fee894ecfe720c1b) | announce.c (02a0965ef64123ce8c752d08176f2ec702d4aee6) |
---|---|
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 --- 60 unchanged lines hidden (view full) --- 69/* 70 * See if the user is accepting messages. If so, announce that 71 * a talk is requested. 72 */ 73int 74announce(CTL_MSG *request, const char *remote_machine) 75{ 76 char full_tty[32]; | 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 --- 60 unchanged lines hidden (view full) --- 69/* 70 * See if the user is accepting messages. If so, announce that 71 * a talk is requested. 72 */ 73int 74announce(CTL_MSG *request, const char *remote_machine) 75{ 76 char full_tty[32]; |
77 FILE *tf; | |
78 struct stat stbuf; 79 80 (void)snprintf(full_tty, sizeof(full_tty), 81 "%s%s", _PATH_DEV, request->r_tty); 82 if (stat(full_tty, &stbuf) < 0 || (stbuf.st_mode&020) == 0) 83 return (PERMISSION_DENIED); | 77 struct stat stbuf; 78 79 (void)snprintf(full_tty, sizeof(full_tty), 80 "%s%s", _PATH_DEV, request->r_tty); 81 if (stat(full_tty, &stbuf) < 0 || (stbuf.st_mode&020) == 0) 82 return (PERMISSION_DENIED); |
84 return (print_mesg(request->r_tty, tf, request, remote_machine)); | 83 return (print_mesg(request->r_tty, request, remote_machine)); |
85} 86 87#define max(a,b) ( (a) > (b) ? (a) : (b) ) 88#define N_LINES 5 89#define N_CHARS 256 90 91/* 92 * Build a block of characters containing the message. 93 * It is sent blank filled and in a single block to 94 * try to keep the message in one piece if the recipient 95 * in in vi at the time 96 */ 97int | 84} 85 86#define max(a,b) ( (a) > (b) ? (a) : (b) ) 87#define N_LINES 5 88#define N_CHARS 256 89 90/* 91 * Build a block of characters containing the message. 92 * It is sent blank filled and in a single block to 93 * try to keep the message in one piece if the recipient 94 * in in vi at the time 95 */ 96int |
98print_mesg(const char *tty, FILE *tf, CTL_MSG *request, | 97print_mesg(const char *tty, CTL_MSG *request, |
99 const char *remote_machine) 100{ | 98 const char *remote_machine) 99{ |
101 struct timeval clock; | 100 struct timeval now; |
102 time_t clock_sec; 103 struct timezone zone; | 101 time_t clock_sec; 102 struct timezone zone; |
104 struct tm *localtime(); | |
105 struct tm *localclock; 106 struct iovec iovec; 107 char line_buf[N_LINES][N_CHARS]; 108 int sizes[N_LINES]; 109 char big_buf[N_LINES*N_CHARS]; 110 char *bptr, *lptr, *vis_user; 111 int i, j, max_size; 112 113 i = 0; 114 max_size = 0; | 103 struct tm *localclock; 104 struct iovec iovec; 105 char line_buf[N_LINES][N_CHARS]; 106 int sizes[N_LINES]; 107 char big_buf[N_LINES*N_CHARS]; 108 char *bptr, *lptr, *vis_user; 109 int i, j, max_size; 110 111 i = 0; 112 max_size = 0; |
115 gettimeofday(&clock, &zone); 116 clock_sec = clock.tv_sec; | 113 gettimeofday(&now, &zone); 114 clock_sec = now.tv_sec; |
117 localclock = localtime(&clock_sec); 118 (void)snprintf(line_buf[i], N_CHARS, " "); 119 sizes[i] = strlen(line_buf[i]); 120 max_size = max(max_size, sizes[i]); 121 i++; 122 (void)snprintf(line_buf[i], N_CHARS, 123 "Message from Talk_Daemon@%s at %d:%02d on %d/%.2d/%.2d ...", 124 hostname, localclock->tm_hour , localclock->tm_min, --- 50 unchanged lines hidden --- | 115 localclock = localtime(&clock_sec); 116 (void)snprintf(line_buf[i], N_CHARS, " "); 117 sizes[i] = strlen(line_buf[i]); 118 max_size = max(max_size, sizes[i]); 119 i++; 120 (void)snprintf(line_buf[i], N_CHARS, 121 "Message from Talk_Daemon@%s at %d:%02d on %d/%.2d/%.2d ...", 122 hostname, localclock->tm_hour , localclock->tm_min, --- 50 unchanged lines hidden --- |