source: trunk/athena/bin/discuss/mclient/pmtg.c @ 22864

Revision 22864, 3.7 KB checked in by andersk, 17 years ago (diff)
Fix obsolete names for Kerberos library functions, which no longer worked on Mac OS X. Patch from broder.
Line 
1/*
2 *
3 *      Copyright (C) 1988, 1989 by the Massachusetts Institute of Technology
4 *      Developed by the MIT Student Information Processing Board (SIPB).
5 *      For copying information, see the file mit-copyright.h in this release.
6 *
7 */
8/*
9 *
10 * pmtg.c  -- Program to print out a entire meeting.
11 *
12 */
13
14#include <discuss/discuss.h>
15#include <sys/types.h>
16#include <sys/file.h>
17#include <stdio.h>
18#include <string.h>
19
20tfile unix_tfile();
21mtg_info minfo;
22
23#ifndef lint
24static char rcsid_pmtg_c[] =
25    "$Id: pmtg.c,v 1.7 1999-02-02 20:40:33 kcr Exp $";
26#endif
27
28int main (argc,argv)
29        int argc;
30        char **argv;
31{
32        int result;
33        trn_nums trn;
34        trn_info tinfo;
35        tfile tfstdout;
36        char machine [50],mtg_name[100];
37
38        initialize_dsc_error_table();
39        argc--; argv++;
40        if (argc != 1)
41                goto lusage;
42
43        resolve_mtg(*argv, machine, mtg_name);
44
45        init_rpc();
46        if (open_rpc (machine, "discuss", &result) == 0) {
47             (void) fprintf (stderr, "%s\n", error_message(result));
48             exit(1);
49        }
50        if (result) {
51             (void) fprintf (stderr, "Warning: %s\n", error_message(result));
52        }
53
54        get_mtg_info (mtg_name, &minfo, &result);
55        if (result != 0) {
56                (void) fprintf (stderr, "%s\n", error_message (result));
57                exit(1);
58        }
59
60        /* set up stdout tfile */
61        tfstdout = unix_tfile (1);
62
63        trn = minfo.first;
64        while (trn != 0) {
65                get_trn_info (mtg_name, trn, &tinfo, &result);
66                if (result != 0) {
67                        if (result != DELETED_TRN) {
68                                (void) fprintf (stderr, "%s\n",
69                                                error_message (result));
70                                exit (1);
71                        }
72                } else {
73                        write_header (&tinfo, tfstdout);
74                        get_trn (mtg_name, trn, tfstdout, &result);
75                        if (result != 0) {
76                                (void) fprintf (stderr, "%s\n",
77                                                error_message(result));
78                                exit (1);
79                        }
80                        write_trailer (&tinfo, tfstdout);
81                }
82                trn = tinfo.next;
83                free (tinfo.author);
84                free (tinfo.subject);
85        }
86
87        tdestroy (tfstdout);
88        term_rpc ();
89        return 0;
90
91 lusage:
92        (void) fprintf (stderr, "Usage: pmtg {mtg_name}\n");
93        exit (1);
94}
95
96char *ctime();
97
98write_header(info, tf)
99        trn_info *info;
100        tfile tf;
101{
102        char line [255];
103        char newtime [26];
104        char *plural;
105        int dummy;
106
107        (void) strcpy (newtime, ctime ((time_t *)&(info -> date_entered)));
108        newtime [24] = '\0';    /* get rid of \n */
109
110        if (info -> num_lines != 1)
111                plural = "s";
112        else
113                plural = "";
114     
115        (void) sprintf (line, "[%04d] %s %s %s (%d line%s)\n",
116                        info -> current, info -> author, minfo.long_name,
117                        &newtime[4], info -> num_lines, plural);
118        twrite (tf, line, strlen (line),&dummy);
119        if (info -> subject [0] != '\0') {
120                twrite (tf, "Subject: ", 9, &dummy);
121                twrite (tf, info -> subject, strlen (info -> subject), &dummy);
122                twrite (tf, "\n", 1, &dummy);
123        }
124        return;
125}
126
127write_trailer (info, tf)
128trn_info *info;
129tfile tf;
130{
131     char line [255];
132     int dummy;
133
134     if (info -> pref == 0 && info -> nref == 0)
135          sprintf (line, "--[%04d]--\n\n", info -> current);
136     else if (info -> pref == 0)
137          sprintf (line, "--[%04d]-- (nref = [%04d])\n\n", info -> current,
138                   info -> nref);
139     else if (info -> nref == 0)
140          sprintf (line, "--[%04d]-- (pref = [%04d])\n\n", info -> current,
141                   info -> pref);
142     else
143          sprintf (line, "--[%04d]-- (pref = [%04d], nref = [%04d])\n\n",
144                   info -> current, info -> pref, info -> nref);
145     twrite (tf, line, strlen (line),&dummy);
146}
147/*
148 *
149 * resolve_mtg:  Procedure to resolve a user meeting name into its host
150 *               an pathname.
151 *
152 */
153resolve_mtg (usr_string, machine, mtg_name)
154char *usr_string,*machine,*mtg_name;
155{
156     char *colon;
157     int machine_len;
158
159     colon = strchr (usr_string, ':');
160
161     if (colon == 0) {
162          strcpy (mtg_name, usr_string);
163          gethostname (machine, 50);
164          return;
165     }
166
167     machine_len = colon - usr_string;
168     memcpy (machine, usr_string, machine_len);
169     machine [machine_len] = '\0';
170     strcpy (mtg_name, colon+1);
171     return;
172}
Note: See TracBrowser for help on using the repository browser.