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

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