source: trunk/athena/bin/gms/view_message_by_zephyr.c @ 1482

Revision 1482, 1.5 KB checked in by eichin, 36 years ago (diff)
Initial revision
Line 
1/* This file is part of the Project Athena Global Message System.
2 * Created by: Mark W. Eichin <eichin@athena.mit.edu>
3 * $Source: /afs/dev.mit.edu/source/repository/athena/bin/gms/view_message_by_zephyr.c,v $
4 * $Author: eichin $
5 *
6 *      Copyright (c) 1988 by the Massachusetts Institute of Technology.
7 *      For copying and distribution information, see the file
8 *      "mit-copyright.h".
9 */
10#include <mit-copyright.h>
11#ifndef lint
12static char rcsid_view_message_by_zephyr_c[] = "$Header: /afs/dev.mit.edu/source/repository/athena/bin/gms/view_message_by_zephyr.c,v 1.1 1988-09-26 15:22:09 eichin Exp $";
13#endif lint
14
15#include "globalmessage.h"
16#include <pwd.h>
17#include <stdio.h>
18#include <strings.h>
19#include <syslog.h>
20
21void view_message_by_zephyr(message)
22     char *message;
23{
24  char *whoami, *getlogin();
25  char *ptr;
26 
27  whoami = getlogin();
28
29  if(!whoami) {
30    struct passwd *pw;
31    pw = getpwuid(getuid());
32    if(pw) {
33      whoami = pw->pw_name;
34    } else {
35      fprintf(stderr,
36              "get_message: couldn't find username to send zephyr notice\n");
37      exit(2);
38    }
39  }
40  /* skip magic headers */
41  ptr = index(message, '\n')+1;
42 
43  /* check that there is *something* after the headers */
44  if(*ptr) {
45    /* don't even fork... this just exits anyway... */
46    execl("/usr/athena/zwrite",
47          "zwrite", "-d", "-q", "-n",  whoami, "-m", ptr, 0);
48    /* put logging here in case the exec fails. */
49    syslog(LOG_INFO, "GMS client execl of zwrite failed [%s]",
50           error_message(errno));
51  }
52}
Note: See TracBrowser for help on using the repository browser.