home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / nntp1.5 / part01 / server / post.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-18  |  1.0 KB  |  54 lines

  1. #ifndef lint
  2. static char    *sccsid = "@(#)post.c    1.12    (Berkeley) 1/11/88";
  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;
  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.     retcode = spawn(inews, "inews", "-h", CONT_POST, ERR_POSTFAIL, errbuf);
  43.     if (retcode <= 0)
  44.         printf("%d %s\r\n", ERR_POSTFAIL, errbuf);
  45.     else if (retcode > 0)
  46.         printf("%d Article posted successfully.\r\n", OK_POSTED);
  47.     (void) fflush(stdout);
  48.  
  49. #ifdef LOG
  50.     syslog(LOG_INFO, "%s post %s", hostname,
  51.             retcode == 1 ? "succeeded" : "failed");
  52. #endif
  53. }
  54.