home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NNTP-1.000 / NNTP-1 / nntp.1.5.11t / server / post.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-17  |  1.5 KB  |  71 lines

  1. #ifndef lint
  2. static char    *sccsid = "@(#)$Header: post.c,v 1.17 90/12/23 11:50:01 sob Exp $";
  3. #endif
  4.  
  5. #include "common.h"
  6.  
  7. /*
  8.  * POST
  9.  *
  10.  * Post an article to a set of newsgroups.
  11.  */
  12.  
  13. post(argc, argv)
  14.     int    argc;
  15.     char    *argv[];
  16. {
  17.     char    errbuf[2 * NNTP_STRLEN];
  18.     int    retcode, blocks;
  19.  
  20.     if (!canpost) {
  21.         printf("%d Sorry, you're not allowed to post.\r\n",
  22.             ERR_NOPOST);
  23. #ifdef LOG
  24.             syslog(LOG_INFO, "%s post rejected", hostname);
  25. #endif
  26.         (void) fflush(stdout);
  27.         return;
  28.     }
  29.  
  30. #ifdef POSTER
  31.     if (uid_poster == 0) {
  32.         printf("%d User %s does not exist!  Can't post.\r\n",
  33.             ERR_POSTFAIL, POSTER);
  34. #ifdef SYSLOG
  35.         syslog(LOG_ERR, "post: User %s does not exist.", POSTER);
  36. #endif
  37.         (void) fflush(stdout);
  38.         return;
  39.     }
  40. #endif
  41.  
  42.     if (!space(MINFREE - POSTBUFFER)) {
  43.         /* force error reporting code into sending */
  44.         /* an out-of-space error message           */
  45.         if (gethostname(errbuf, MAXHOSTNAMELEN) < 0)
  46.         (void) strcpy(errbuf, "Amnesiac");
  47.  
  48.         (void) strcat(errbuf, " NNTP server out of space. Try later.");
  49.  
  50.         retcode = 0;        /* indicates that an error occurred */
  51.     }
  52.     else retcode =
  53. #ifdef CNEWS
  54.         spawn(inews, "inews", "-W", CONT_POST, ERR_POSTFAIL, errbuf,
  55.         "<none>");
  56. #else
  57.         spawn(inews, "inews", "-h", CONT_POST, ERR_POSTFAIL, errbuf,
  58.         "<none>");
  59. #endif
  60.     if (retcode <= 0)
  61.         printf("%d %s\r\n", ERR_POSTFAIL, errbuf);
  62.     else if (retcode > 0)
  63.         printf("%d Article posted successfully.\r\n", OK_POSTED);
  64.     (void) fflush(stdout);
  65.  
  66. #ifdef LOG
  67.     syslog(LOG_INFO, "%s post %s", hostname,
  68.             retcode == 1 ? "succeeded" : "failed");
  69. #endif
  70. }
  71.