home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / aix-rs6000 / elm2.3.11.AIX3.1.5.Z / elm2.3.11.AIX3.1.5 / src / conn_to.c < prev    next >
C/C++ Source or Header  |  1991-11-26  |  3KB  |  117 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: conn_to.c,v 4.1 90/04/28 22:42:37 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 4.1 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1986, 1987 Dave Taylor
  8.  *             Copyright (c) 1988, 1989, 1990 USENET Community Trust
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log:    conn_to.c,v $
  17.  * Revision 4.1  90/04/28  22:42:37  syd
  18.  * checkin of Elm 2.3 as of Release PL0
  19.  * 
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /** This contains the routine(s) needed to have the Elm mailer figure
  24.     out what machines the current machine can talk to.
  25.     It will invoke uuname to a file, then read the file in!
  26. **/
  27.  
  28. #include "headers.h"
  29.  
  30. /* char *strcpy(); */
  31.  
  32. #ifndef DONT_TOUCH_ADDRESSES
  33. get_connections()
  34. {
  35.  
  36.     /** get the direct connections that this machine has
  37.         using the uuname routine to get the names.
  38.     **/
  39.  
  40.     FILE *fd;
  41.     char  buffer[SLEN], filename[SLEN];
  42.     struct lsys_rec *system_record, *previous_record;
  43.     int   loc_on_line;
  44.  
  45.  
  46.     if (! warnings) {        /* skip this - they don't care! */
  47.       talk_to_sys = NULL;
  48.       return;
  49.     }
  50.  
  51.     if (strlen(uuname) == 0) {    /* skip this - no way to get connections */
  52.       warnings = NO;
  53.       talk_to_sys = NULL;
  54.       dprint(1, (debugfile, "No uuname - clearing warnings\n"));
  55.       error("Warning: no uuname command, clearing option warnings");
  56.       return;
  57.     }
  58.  
  59.     sprintf(filename, "%s%s%d", temp_dir, temp_uuname, getpid());
  60.     sprintf(buffer,"%s > %s", uuname, filename);
  61.  
  62.     if (system_call(buffer, SH, FALSE, FALSE) != 0) {
  63.       dprint(1, (debugfile, "Can't get uuname info - system() failed!\n"));
  64.       goto unable_to_get;
  65.     }
  66.     
  67.     if ((fd = fopen(filename, "r")) == NULL) {
  68.       dprint(1, (debugfile,
  69.         "Can't get uuname info - can't open file %s for reading\n",
  70.          filename));
  71.       goto unable_to_get;
  72.     }
  73.     
  74.     previous_record = NULL;
  75.  
  76.     while (fgets(buffer, SLEN, fd) != NULL) {
  77.       no_ret(buffer);
  78.       if (previous_record == NULL) {
  79.         dprint(2, (debugfile, "uuname\tdirect connection to %s, ", buffer));
  80.         loc_on_line = 30 + strlen(buffer);
  81.         previous_record = (struct lsys_rec *) pmalloc(sizeof *talk_to_sys);
  82.  
  83.         strcpy(previous_record->name, buffer);
  84.         previous_record->next = NULL;
  85.         talk_to_sys = previous_record;
  86.       }
  87.       else {    /* don't have to check uniqueness - uuname does that! */
  88.         if (loc_on_line + strlen(buffer) > 80) {
  89.           dprint(2, (debugfile, "\n\t"));
  90.           loc_on_line = 8;
  91.         }
  92.         dprint(2, (debugfile, "%s, ", buffer));
  93.         loc_on_line += (strlen(buffer) + 2);
  94.         system_record = (struct lsys_rec *) pmalloc(sizeof *talk_to_sys);
  95.       
  96.         strcpy(system_record->name, buffer);
  97.         system_record->next = NULL;
  98.         previous_record->next = system_record;
  99.         previous_record = system_record;
  100.       }
  101.     }
  102.  
  103.     fclose(fd);
  104.  
  105.     (void) unlink(filename);        /* kill da temp file!! */
  106.  
  107.     dprint(2, (debugfile, "\n"));        /* for a nice format! Yeah! */
  108.  
  109.     return;                    /* it all went okay... */
  110.  
  111. unable_to_get:
  112.     unlink(filename);    /* insurance */
  113.     error("Warning: couldn't figure out system connections...");
  114.     talk_to_sys = NULL;
  115. }
  116. #endif
  117.