home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / niftp / ni_niftp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  4.2 KB  |  150 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3.  
  4. /*
  5.  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
  6.  *
  7.  *
  8.  *     Copyright (C) 1979,1980,1981  University of Delaware
  9.  *
  10.  *     Department of Electrical Engineering
  11.  *     University of Delaware
  12.  *     Newark, Delaware  19711
  13.  *
  14.  *     Phone:  (302) 738-1163
  15.  *
  16.  *
  17.  *     This program module was developed as part of the University
  18.  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
  19.  *
  20.  *     Acquisition, use, and distribution of this module and its listings
  21.  *     are subject restricted to the terms of a license agreement.
  22.  *     Documents describing systems using this module must cite its source.
  23.  *
  24.  *     The above statements must be retained with all copies of this
  25.  *     program and may not be removed without the consent of the
  26.  *     University of Delaware.
  27.  *
  28.  *
  29.  *     version  -1    David H. Crocker    March   1979
  30.  *     version   0    David H. Crocker    April   1980
  31.  *     version  v7    David H. Crocker    May     1981
  32.  *     version   1    David H. Crocker    October 1981
  33.  *
  34. /*
  35.  *      Modified by Steve Kille from ch_local  August 1982
  36.  *
  37.  */
  38. #include <signal.h>
  39. #include "ch.h"
  40.  
  41. extern LLog *logptr;
  42.  
  43. Chan    *curchan;               /* Loaction for validating channel      */
  44.  
  45. /*
  46.  *  CH_QNIFTP  --  Channel for reception of NIFTP/ JNT mail
  47.  *
  48.  *  This module is made to look like a channel although it is not really
  49.  *
  50.  *  The module is called by the NIFTP, but does not communicate
  51.  *  with it except for the final exit value.  The module interacts
  52.  *  with submit, and passes messages to it.
  53.  *
  54.  *  The major advantage of looking like a channel is that messages
  55.  *  can pretent to submit that they have come in over a channel.
  56.  *  The facilities of submit can then be used for management and
  57.  *  other things (e.g. stamping Via: fields).
  58.  *
  59.  *  It should be called by the NIFTP with an execl of the form
  60.  *  execl( path, name, niftp-queue, fname, TSname) where the parameters are
  61.  *  character strings.  fname is the file containing the JNT mail
  62.  *  format message, and TSname is the calling address of the host.
  63.  *  MMDF will try to identify this as a real host.
  64.  *  niftp-queue is the NIFTP queue name.  This is mapped into an
  65.  *  MMDF channel name
  66.  *
  67.  *
  68.  *
  69.  */
  70.  
  71. /*      MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN     */
  72.  
  73. main (argc, argv)
  74. int     argc;
  75. char   *argv[];
  76. {
  77.     extern char *dupfpath ();
  78.     short retval;
  79.  
  80.     umask(0);
  81.     mmdf_init (argv[0]);
  82.     siginit ();
  83.  
  84.     retval = ni_niftp (argc, argv);
  85.  
  86. #ifdef DEBUG
  87.     ll_log (logptr, LLOGFTR, "Exiting with value (%s)", rp_valstr (retval));
  88. #endif
  89.  
  90.     ll_close (logptr);              /* clean log end, if cycled  */
  91.     exit (retval);
  92. }
  93. /* **************  (ch_) NIFTP  MAIL DELIVERY  ************************ */
  94.  
  95. ni_niftp (argc, argv)             /* send to NIFTP channel               */
  96. int     argc;
  97. char   *argv[];
  98. {
  99.     short       result;
  100.     ll_log (logptr, LLOGFST, "ni_niftp (q='%s', f='%s', TS='%s')",
  101.         argv[1], argv[2], argv[3]);
  102.  
  103.     if (rp_isbad (result = qn_init (argv[1])))
  104.     return (result);           /* problem setting-up NIFTP reception */
  105.                    /* This checks channel validity       */
  106.                    /* based on NIFTP queue name          */
  107.     if (rp_isbad (result = mm_init ()))
  108.     return (result);         /* problem initialising submit          */
  109.  
  110.     if (rp_isbad (result = qn2mm_send (argv[2], argv[3])))
  111.     return (result);           /* transfer the mail to submit        */
  112.  
  113.     qn_end (OK);                  /* done with Deliver function         */
  114.     mm_end (OK);
  115.  
  116.     return (RP_OK);               /* NORMAL RETURN                      */
  117. }
  118.  
  119. /* */
  120.  
  121. /* VARARGS2 */
  122.  
  123. err_abrt (code, fmt, b, c, d)     /* terminate ourself                  */
  124. short     code;
  125. char    fmt[],
  126.     b[],
  127.     c[],
  128.     d[];
  129. {
  130.     char linebuf[LINESIZE];
  131.  
  132.     qn_end (NOTOK);
  133.     mm_end (NOTOK);
  134.     if (rp_isbad (code))
  135.     {
  136. #ifdef DEBUG
  137.     if (rp_gbval (code) == RP_BNO || logptr -> ll_level >= LLOGBTR)
  138.     {                         /* don't worry about minor stuff      */
  139.         sprintf (linebuf, "%s%s", "[ABEND:  %s]\t", fmt);
  140.         ll_log (logptr, LLOGFAT, linebuf, rp_valstr (code), b, c, d);
  141.         abort ();
  142.     }
  143. #endif
  144.     }
  145.     ll_close (logptr);           /* in case of cycling, close neatly   */
  146.     exit (code);
  147. }
  148.  
  149.  
  150.