home *** CD-ROM | disk | FTP | other *** search
- /*
- ** sendbatch.c - written by Ingo Feulner, Copyright (C) 1990.
- **
- ** 12-Jul-90 first version
- ** 1-Oct-90 corrected some known bugs
- **
- */
-
-
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
-
- #include "unix.h"
- #include "config.h"
-
- #define VERDATE " 1.02 (1 Oct 90) "
-
- static char *version20 = "$VER: sendbatch" VERDATE "\n\r";
-
- #ifndef TRUE
- #define TRUE 1
- #define FALSE 0
- #endif
-
- void main(int argc, char *argv[])
- {
- /* Werte fⁿr 'getopt()' */
- extern char *optarg;
- extern int optind;
- signed char c;
-
- FILE *tmp;
-
- char *tempfile = "T:sendbatch.tmpXXXXXXXX";
- char *ftempfile = "T:sendbatch.finalXXXXXXXX";
- char command[256];
- char batch[256];
- char acctest[256];
- char node[20];
-
- char compress = FALSE;
-
- long maxlength = 0;
-
-
-
- while((c = getopt(argc, argv, "acl:")) > 0)
- {
- switch(c)
- {
- case 'c':
- compress = TRUE;
- break;
- case 'l':
- maxlength = atol(optarg);
- break;
- case '?':
- (void)fprintf(stderr, "AmigaUUCP Plus: sendbatch" VERDATE "\n");
- (void)fprintf(stderr, "Copyright (C) 1990 Ingo Feulner\n\n");
- (void)fprintf(stderr, "Usage: %s [-c] [-l<maxlength>] system\n", argv[0]);
- exit(1);
- break;
- default:
- (void)fprintf(stderr, "Unknown option '%c'\n", c);
- exit(1);
- break;
- }
- }
-
- mktemp(tempfile);
- mktemp(ftempfile);
-
- (void)strcpy(node, argv[optind]);
-
- (void)strcpy(batch, node);
- (void)strcat(batch, ".nbatch");
-
- (void)strcpy(acctest, GetConfigDir(UUNEWS));
- (void)strcat(acctest, batch);
-
- if((tmp = fopen(acctest, "r")) == NULL)
- {
- (void)strcat(acctest, ".work");
- if((tmp = fopen(acctest, "r")) == NULL)
- {
- /* No news to batch, so exit quietly */
- (void)remove(tempfile);
- (void)remove(ftempfile);
- exit(0);
- }
- else
- fclose(tmp);
- }
- else
- fclose(tmp);
-
-
- if((tmp = fopen(ftempfile, "w")) == NULL)
- {
- (void)fprintf(stderr, "Can't open tempfile\n");
- exit(1);
- }
-
-
- if(compress == TRUE)
- {
- (void)fprintf(tmp, "#! cunbatch\n");
- fclose(tmp); /* wichtig! */
-
- (void)sprintf(command, "batch >%s %s %ld",
- tempfile, batch, (maxlength > 0) ? maxlength : 1000000);
-
- if(system(command))
- {
- (void)fprintf(stderr, "batch failed.\n");
- exit(1);
- }
-
-
- (void)sprintf(command, "compress <%s >>%s", tempfile, ftempfile);
-
- if(system(command))
- {
- (void)fprintf(stderr, "compress failed.\n");
- exit(1);
- }
-
-
- (void)sprintf(command, "uux %s \"%s!rnews\"", ftempfile, node);
-
- if(system(command))
- {
- (void)fprintf(stderr, "uux failed.\n");
- exit(1);
- }
- }
- else
- {
- fclose(tmp);
-
- (void)sprintf(command, "batch >%s %s %ld", ftempfile, batch,
- (maxlength > 0) ? maxlength : 1000000);
-
- if(system(command))
- {
- (void)fprintf(stderr, "batch failed.\n");
- exit(1);
- }
-
- (void)sprintf(command, "uux %s \"%s!rnews\"", ftempfile, node);
- if(system(command))
- {
- (void)fprintf(stderr, "uux failed.\n");
- exit(1);
- }
- }
- (void)remove(tempfile);
- (void)remove(ftempfile);
- }
-