source: trunk/athena/bin/discuss/libds/announce.c @ 12459

Revision 12459, 2.4 KB checked in by danw, 25 years ago (diff)
comment out text after #else and #endif
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 *      $Id: announce.c,v 1.10 1999-02-08 14:47:07 danw Exp $
10 *
11 */
12
13#ifndef lint
14static char rcsid_announce_c[] =
15    "$Id: announce.c,v 1.10 1999-02-08 14:47:07 danw Exp $";
16#endif /* lint */
17
18#include <stdio.h>
19#include <sys/file.h>
20#if HAVE_FCNTL_H
21#include <fcntl.h>
22#endif
23#include <discuss/tfile.h>
24#include <discuss/interface.h>
25#include <discuss/dsname.h>
26#include <discuss/dsc_et.h>
27
28#define min(x,y) ((x)<(y)?(x):(y))
29
30extern tfile unix_tfile();
31
32dsc_announce_mtg (nbpsrc, nbpdest, public, tf, txn_no, code_ptr)
33name_blk *nbpsrc, *nbpdest;
34int public;
35tfile tf;
36int *txn_no;
37int *code_ptr;
38{
39        char temp_file[64];
40        char buffer[512],subject[100];
41        int fd,tfs,tocopy,mycode;
42        FILE *fp;
43        tfile tf2;
44        mtg_info my_minfo;
45
46        *code_ptr = 0;
47        fp = NULL;
48        tf2 = NULL;
49
50        dsc_get_mtg_info(nbpsrc,
51                         &my_minfo, code_ptr);
52        if (*code_ptr != 0)
53             return;
54
55        (void) sprintf(temp_file,"/tmp/mtgz%d.%d",getuid(),getpid());
56        (void) unlink(temp_file);
57
58        fp = fopen(temp_file,"w");
59        if (!fp) {
60                *code_ptr = CANT_WRITE_TEMP;
61                goto punt;
62        }
63        fprintf(fp,"  Meeting Name:  %s\n", my_minfo.long_name);
64        fprintf(fp,"  Host:          %s\n", nbpsrc->hostname);
65        fprintf(fp,"  Pathname:      %s\n", nbpsrc->pathname);
66        fprintf(fp,"  Participation: %s\n", public?"Public":"Private");
67        fprintf(fp,"\n");
68        fclose(fp);
69        fp = NULL;
70
71        fd = open(temp_file,O_APPEND|O_RDWR,0);
72        if (fd < 0) {
73                *code_ptr = CANT_WRITE_TEMP;
74                goto punt;
75        }
76        tf2 = unix_tfile(fd);
77        tfs = tfsize(tf);
78        while (tfs > 0) {
79                tocopy = min (512, tfs);
80                tocopy = tread (tf, buffer, tocopy, code_ptr);
81                if (*code_ptr)
82                        goto punt;
83                twrite (tf2, buffer, tocopy, code_ptr);
84                if (*code_ptr)
85                        goto punt;
86                tfs -= tocopy;
87        }
88        (void) tclose(tf2, code_ptr);
89        tf2 = NULL;
90        *code_ptr = 0;
91
92        fd = open(temp_file,O_RDONLY,0);
93        if (fd < 0) {
94                *code_ptr = CANT_WRITE_TEMP;
95                goto punt;
96        }
97        tf2 = unix_tfile(fd);
98
99        (void) sprintf(subject,"%s meeting",my_minfo.long_name);
100        dsc_add_trn(nbpdest, tf2, subject, 0, txn_no, code_ptr);
101
102punt:
103        if (tf2 != NULL)
104             tclose(tf2, &mycode);
105        if (fp != NULL)
106             fclose(fp);
107        if (my_minfo.chairman != NULL)
108             free(my_minfo.chairman);
109        if (my_minfo.location != NULL)
110             free(my_minfo.location);
111        if (my_minfo.long_name != NULL)
112             free(my_minfo.long_name);
113}
Note: See TracBrowser for help on using the repository browser.