home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
misc
/
b104_1
/
c
/
smtpqueue
< prev
Wrap
Text File
|
1993-10-04
|
1KB
|
72 lines
#include <stdlib.h>
#include <stdio.h>
void usage()
{
printf( "usage: smtpqueue address origin\n" );
exit( 1 );
}
void get_seq( char *name )
{
FILE *seq;
int num;
seq = fopen( "<Mail$Dir>.spool.mqueue.sequence", "r+" );
if( ! seq ) {
fprintf( stderr, "unable to open sequence file - is MailDir seen?\n" );
exit( 1 );
}
fscanf( seq, "%d", &num );
num++;
fseek( seq, 0, SEEK_SET );
fprintf( seq, "%d", num );
sprintf( name, "%d", num );
}
#define BLEN 1024
FILE *in;
FILE *out;
char fname[30];
char buff[BLEN+1];
int main( int argc, char **argv )
{
char *node;
if( argc!=3 ) usage();
in = stdin;
if( ! (node = strchr( argv[1], '@' )) ) {
fprintf( stderr, "%s is no valid address\n", argv[1] );
exit( 1 );
}
node++;
get_seq( fname );
sprintf( buff, "<Mail$dir>.spool.mqueue.work.%s", fname );
out = fopen( buff, "w" );
if( ! out ) {
fprintf( stderr, "unable to create SMTP control file\n" );
exit( 1 );
}
fprintf( out, "%s\n%s\n%s", node, argv[2], argv[1] );
fclose( out );
sprintf( buff, "<Mail$dir>.spool.mqueue.text.%s", fname );
out = fopen( buff, "w" );
if( ! out ) {
fprintf( stderr, "unable to create SMTP data file\n" );
sprintf( buff, "<Mail$dir>.spool.mqueue.work.%s", fname );
remove( buff );
exit( 1 );
}
while( node=fgets( buff, BLEN, in ) ) fputs( buff, out );
fclose( out );
fclose( in );
return 0;
}