aboutsummaryrefslogtreecommitdiffstats
path: root/transfug_oe.c
diff options
context:
space:
mode:
Diffstat (limited to 'transfug_oe.c')
-rw-r--r--transfug_oe.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/transfug_oe.c b/transfug_oe.c
index c30aa96..143558b 100644
--- a/transfug_oe.c
+++ b/transfug_oe.c
@@ -346,6 +346,9 @@ oe_data* oe_readbox(char* filename,void (*oput)(char*)) {
/* SIGNATURE */
fread(&signature,16,1,data->oe);
+#ifdef DEBUG
+ printf("signature: %.8x\n",signature[0]);
+#endif
if ((signature[0]!=0xFE12ADCF) || /* OE 5 & OE 5 BETA SIGNATURE */
(signature[1]!=0x6F74FDC5) ||
(signature[2]!=0x11D1E366) ||
@@ -404,14 +407,6 @@ oe_data* oe_readmbox(char* filename,void (*oput)(char*)) {
FILE *mbox = NULL;
char *filename = NULL, *fn;
-void msgandquit(int h) {
- if (h==0)
- printf("transfug_oe\nSyntax: transfug_oe [oe_mbox]*\n"
- "based on OE2MBX 1.21 (c) 2000 Stephan B. Nedregaard - stephan@micropop.com\n");
- else if (h==1)
- printf("OE2MBX cannot run on this platform. Please consult the Web site at http://www.micropop.com/code/\n");
- exit(h);
-}
void fatal(char *s) {
printf("Fatal error: %s\n\n",s);
@@ -419,34 +414,33 @@ void fatal(char *s) {
}
void writeit(char *s) {
- if (mbox==NULL) {
- mbox=fopen(fn,"w");
- if(mbox==NULL) fatal("Cannot create output file");
- }
- fprintf(mbox,"%s",s);
+ if (mbox==NULL) {
+ mbox=fopen(fn,"w");
+ if(mbox==NULL) {
+ fprintf (stderr, "TransfugDrake ERROR: cannot create file %s\n",fn);
+ exit (1);
+ }
+ fprintf(mbox,"%s",s);
+ }
}
int main(int argc, char*argv[]) {
int i;
-
+ oe_data *j;
+
/* Handle errors, help and syntax */
- if (argc<2) msgandquit(0);
- for (i=1;i<argc;i++)
- if ( !strcmp(argv[i],"-h") || !strcmp(argv[i],"--help") )
- msgandquit(0);
-
- /* Process mailboxes */
- for (i=1;i<argc;i++) {
- oe_data *j;
- printf("Converting %s...\n",argv[i]);
- filename = malloc(strlen(argv[i])+5);
- strcpy(filename,argv[i]);
- strcpy(filename+strlen(filename),".mbx");
- fn = filename+strlen(filename);
- while ((*fn!=SLASH) && (fn!=filename)) fn--;
- if (*fn==SLASH) fn++;
+ if (argc<3) {
+ printf("transfug_oe\nSyntax: transfug_oe oe_dbx output_mbox \n");
+ return (0);
+ }
+
+ /* Process mailbox */
+
+ printf("Converting %s...\n",argv[1]);
+ fn = argv[2];
printf(" => %s\n",fn);
- j = (oe_data*) oe_readbox(argv[i],writeit);
+ j = (oe_data*) oe_readbox(argv[1],writeit);
+ printf("yy\n");
if (j!=NULL) {
if (!j->success) printf(" No messages converted"); else
printf(" %d messages converted",j->success);
@@ -456,7 +450,5 @@ int main(int argc, char*argv[]) {
} else printf(" Empty mailbox\n");
if (mbox!=NULL) fclose(mbox);
mbox=NULL;
- free(filename);
- }
return 0;
}