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

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