home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
back2roots/padua
/
padua.7z
/
padua
/
ftp.vapor.com
/
microdot-1
/
md1_src_02.lzx
/
rnews.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-24
|
30KB
|
984 lines
#include "uuconv.h"
#ifndef UUXQT_MD
extern char linebuffer[];
extern APTR tx[6];
#endif
extern LONG lastoffset;
/* */
char tempfile[á128 ];
static char *sourcebatchname;
#ifndef UUXQT_MD
char *ng2board( char *ngname )
{
static char boardname[á256 ];
char *p;
struct Brett *brett = CLB_FindNewsgroup( ngname );
if( brett )
{
char *bn;
CLB_Get( brett, CLBA_NAME, &bn, TAG_DONE );
return( bn );
}
boardname[á255 ]á= 0;
strncpy( boardname, ngname, 255 );
strupr( boardname );
while( ( p = strchr( boardname, '.' ) ) )
*p = '/';
return( boardname );
}
#else
#define ng2board(s) s
#endif
/* Get a (possibly folded) line; returns (real) number of bytes read */
int readheaderline( struct AsyncFile *file, int maxlen )
{
int c, ch;
int rb = 0;
int gotlf = 0;
/*Printf("enter readhl\n" );*/
if( !maxlen || maxlen > LBLEN )
maxlen = LBLEN;
linebuffer[á0 ]á= 0;
for( c = 0; c < maxlen - 1; )
{
ch = CLU_ReadCharAsync( file );
/* Printf( "read: %ld (%lc), c = %ld, gotlf = %ld\n", ch, ch, c, gotlf );*/
if( ch < 0 )
break;
rb++;
/* CRs fressen */
if( ch == 13 )
{
continue;
}
else if( ch == 10 )
{
if( !c )
return( 1 );
if( gotlf )
{
/* Ende, Zeichen zurⁿck */
CLU_UnGetCAsync( file );
rb--;
break;
}
gotlf = TRUE;
continue;
}
/* Gefaltet? */
if( gotlf )
{
/*Printf( "gotlf TRUE, ch = %ld, c = %ld\n", ch, c );*/
if( !isspace( ch ) )
{
/* NΣchste Zeile, Zeichen zurⁿck */
CLU_UnGetCAsync( file );
rb--;
break;
}
/* Gefaltet! */
while( ( ch == 9 ) || ( ch == 32 ) || ( ch == 13 ) )
{
linebuffer[ác++ ]á= ' ';
ch = CLU_ReadCharAsync( file );
rb++;
}
/* Zeile nur mit Leerzeichen */
if( ch == 10 )
{
break;
}
gotlf = FALSE;
}
linebuffer[ác++ ]á= ch;
}
linebuffer[ác ]á= 0;
/* Printf( "exit c %ld rb %ld lenlb %ld lb = %s\n",
c, rb, strlen( linebuffer ), linebuffer
);*/
return( rb );
}
char *breakmid( char *ptr )
{
static char midbuffer[á512 ];
char *p;
ptr = stpblk( ptr );
strncpy( midbuffer, ( *ptrá== '<' )á? &ptr[á1 ]á: ptr, 511 );
p = strchr( midbuffer, '>'á);
if( p )
*p = 0;
return( midbuffer );
}
struct tzone
{
char name[á4 ];
short offset;
short dst;
};
static struct tzone tzones[] = {
{ "EST", -5 * 60, FALSE },
{ "EDT", -4 * 60, TRUE },
{ "CST", -6 * 60, FALSE },
{ "CDT", -5 * 60, TRUE },
{ "MST", -7 * 60, FALSE },
{ "MDT", -6 * 60, TRUE },
{ "PST", -8 * 60, FALSE },
{ "PDT", -7 * 60, TRUE },
{á0 }
};
char *convertuudate( char *uudate )
{
char *p;
char x[6];
long y;
int tzoffs = 0, dst = 0;
static char zcdate[á32 ];
struct tzone *tzone = tzones;
utunpk( time( NULL ), x );
p = strchr( uudate, ',' );
if( !p )
p = uudate;
else
p++;
/* *p -> date time */
p = stpblk( p );
/* Tag */
x[ 2 ] = atoi(p);
while( isdigit( *p ) || *p==' ' || *p=='\t' )
p++;
/* Monat */
if(!strnicmp(p,"Jan",3)) x[1]=1;
else if(!strnicmp(p,"Feb",3)) x[1]=2;
else if(!strnicmp(p,"Mar",3)) x[1]=3;
else if(!strnicmp(p,"Apr",3)) x[1]=4;
else if(!strnicmp(p,"May",3)) x[1]=5;
else if(!strnicmp(p,"Jun",3)) x[1]=6;
else if(!strnicmp(p,"Jul",3)) x[1]=7;
else if(!strnicmp(p,"Aug",3)) x[1]=8;
else if(!strnicmp(p,"Sep",3)) x[1]=9;
else if(!strnicmp(p,"Oct",3)) x[1]=10;
else if(!strnicmp(p,"Nov",3)) x[1]=11;
else if(!strnicmp(p,"Dec",3)) x[1]=12;
else
goto doex;
p = stpblk( &p[á4 ]á);
y = atoi( p );
if( y < 40 )
y += 30;
else if( y>1900 )
y -= 1970;
else
y -= 70;
x[ 0 ] = y;
/* Stunde */
while( isdigit( *p) )
p++;
p = stpblk( p );
x[3] = atoi( p );
p = strchr( p, ':' );
if( !p )
goto doex;
x[ 4 ] = atoi( ++p );
while( *p && *p!=':' && !isspace( *p ) )
p++;
if( *p == ':'á)
{
x[ 5 ] = atoi( ++p );
while( *p && !isspace( *p ) )
p++;
}
else
x[ 5 ] = 0;
/* Zeitzone... */
p = stpblk( p );
if( *p )
{
if( *p == '+'á|| *p == '-' )
{
zcdate[á0 ]á= p[ 1 ];
zcdate[á1 ]á= p[ 2 ];
zcdate[á2 ]á= 0;
zcdate[á3 ]á= p[ 3 ];
zcdate[á4 ]á= p[ 4 ];
zcdate[á5 ]á= 0;
tzoffs = ( atoi( zcdate ) * 60 ) + atoi( &zcdate[á3 ] );
if( *p == '-'á)
tzoffs = -tzoffs;
}
else
{
while( tzone->name[á0 ]á)
{
if( !strnicmp( tzone->name, p, strlen( tzone->name ) ) )
break;
tzone++;
}
tzoffs = tzone->offset;
dst = tzone->dst;
}
}
doex:
sprintf( zcdate, "%04ld%02ld%02ld%02ld%02ld%02ld%lc%lc%ld",
x[á0 ]á+ 1970,
x[á1 ],
x[á2 ],
x[á3 ],
x[á4 ],
x[á5 ],
dst ? 'S' : 'W',
tzoffs >= 0 ? '+' : '-',
abs( tzoffs / 60 )
);
return( zcdate );
}
/* konvertiert rfc-adresse;
entweder "User name" <domainadd>
oder User name <domainadd>
oder domainadd (user name)
0 = ok
1 = form1
-1 = error
*/
int convertadr( char *adr, char *to )
{
char *p, *p2;
char rnb[á512 ];
char dpb[á256 ];
// Printf( "convertadr %s\n", adr );
rnb[á255 ]á= dpb[á255 ]á= 0;
adr = stpblk( adr );
if( *adr == '"' )
{
strncpy( rnb, ++adr, 255 );
p = strchr( rnb, '"' );
if( !p )
return( -1 );
*p++ = 0;
p = strchr( p, '<' );
if( !p )
return( -1 );
strncpy( dpb, ++p, 255 );
p = strchr( dpb, '>' );
/*if( !p )
return( -1 );*/
if( p )
*p = 0;
sprintf( to, "%s (%s)", dpb, rnb );
//Printf( "ca: rc1, %s\n", to );
return( 1 );
}
else if( strchr( adr, '<'á) )
{
strcpy( rnb, adr );
p = strchr( rnb, '<'á);
*p++ = 0;
p2 = strchr( p, '>'á);
/*if( !p2 )
return( -1 );*/
if( p2 )
*p2 = 0;
p2 = &p[-2];
while( p2 > rnb && isspace( *p2 ) )
*p2-- = 0;
if(*rnb)
sprintf( to, "%s (%s)", p, rnb );
else
sprintf( to, "%s", p );
//Printf( "ca: rc1, %s\n", to );
return( 1 );
}
// Entweder Domainadresse oder Bang-Pfad; Bang-Pfad mu▀ aufgel÷st werden
if( strchr( adr, '@'á) )
{
strcpy( to, adr );
//Printf( "ca: rc0, %s\n", to );
return( 0 );
}
strncpy( rnb, adr, 255 );
p = strchr( rnb, ' 'á);
if( p )
*p = 0;
if( !( p = strrchr( rnb, '!'á) ) )
{
//Printf( "ca: rc-1, %s\n", rnb );
strcpy( to, rnb );
return( 0 );
}
*p++ = 0;
p2 = strrchr( rnb, '!'á);
if( !p2 )
p2 = rnb;
else
p2++;
// p = Zeiger auf letzte Node
// p2 = Zeiger auf vorletzte Node
sprintf( to, "%s@%s", p, p2 );
//Printf( "ca: rc1, %s\n", to );
return( 1 );
}
static char *slheader;
static APTR slpool;
static struct MinList sllist;
struct sl {
struct MinNode n;
char *string;
};
static void initstringlist( char *header )
{
slheader = header;
NewList( ( struct List * ) &sllist );
slpool = CLU_CreatePool( MEMF_CLEAR, 2048, 1024 );
}
static void addstringlist( char *string )
{
struct sl * new;
new = CLU_AllocPooled( slpool, sizeof( *new ) );
if( new )
{
new->string = CLU_StrDupPooled( slpool, string );
AddTail( ( struct List * ) &sllist, ( struct Node * ) new );
}
}
static void dumpstringlist( struct AsyncFile *outfile )
{
struct sl *sl;
while( ( sl = ( struct sl * ) RemHead( ( struct List * ) &sllist ) ) )
CLU_FPrintfAsync( outfile, "%s:%s\n", slheader, sl->string );
CLU_DeletePool( slpool );
}
/* Process article, len bytes */
/* Errors
-1 defekte adresse
-2 defektes datum
*/
#define allocbuffmem(x) AllocVec(x,MEMF_ANY)
#define freebuffmem(x) FreeVec(x)
/*static APTR currentbuffmem;
static LONG currentbuffmemlen;
static APTR allocbuffmem( int len )
{
}*/
static int doarticle( struct AsyncFile *fromfile, struct AsyncFile * tofile, int len )
{
int ch;
int cr = 0, lf = 0;
int c;
int offs;
int gotfollowuptoposter;
char *p, *token, *p2;
char buffer[á512 ];
char secbuf[á512 ];
char abs[á512 ], dummy[16];
BOOL isiso = FALSE;
BOOL bin = FALSE;
BOOL ismime = FALSE;
while( len )
{
domui();
abs[á0 ]á= 0;
gotfollowuptoposter = 0;
//isiso = bin = FALSE;
ch = readheaderline( fromfile, len );
len -= ch;
// Printf( "rnews: readheaderline ret %ld, %s\n", ch, linebuffer );
/* Artikelende? */
if( !linebuffer[á0 ]á)
break;
p = strchr( linebuffer, ':'á);
if( !p )
break;
*p++ = 0;
p = stpblk( p );
strncpy( secbuf, linebuffer, 255 );
secbuf[ 255 ]á= 0;
strlwr( linebuffer );
if( !strcmp( linebuffer, "organization" ) )
CLU_FPrintfAsync( tofile, "ORG:%s\n", p );
else if( !strcmp( linebuffer, "path" ) )
{
p2 = strrchr( p, '!'á);
if( p2 )
*p2 = 0;
CLU_FPrintfAsync( tofile, "ROT:%s\n", p );
}
else if( !strcmp( linebuffer, "xref" ) )
continue;
else if( !strcmp( linebuffer, "subject" ) )
{
CLU_FPrintfAsync( tofile, "BET:%s\n", p );
#ifndef UUXQT_MD
set(tx[4], MUIA_Text_Contents, p);
#endif
}
else if( !strcmp( linebuffer, "from" ) )
{
c = convertadr( p, buffer );
if( c < 0 )
return( -1 );
CLU_FPrintfAsync( tofile, "ABS:%s\n", buffer );
#ifndef UUXQT_MD
set(tx[2], MUIA_Text_Contents, buffer);
#endif
if( !abs[á0 ]á)
strcpy( abs, buffer );
if( c )
CLU_FPrintfAsync( tofile, "U-From:%s\n", p );
}
else if( !strcmp( linebuffer, "supersedes" ) )
{
CLU_FPrintfAsync( tofile, "ERSETZT:%s\n", breakmid( p ) );
}
else if( !strcmp( linebuffer, "date" ) )
{
token = convertuudate( p );
if( !token )
return( -2 );
CLU_FPrintfAsync( tofile, "EDA:%s\n", token );
CLU_FPrintfAsync( tofile, "U-Date:%s\n", p );
}
else if( !strcmp( linebuffer, "reply-to" ) )
{
c = convertadr( p, buffer );
if( c < 0 )
return( -1 );
CLU_FPrintfAsync( tofile, "ANTWORT-AN:%s\n", buffer );
strcpy( abs, buffer );
if( c )
CLU_FPrintfAsync( tofile, "U-Reply-To:%s\n", p );
}
else if( !strcmp( linebuffer, "newsgroups" ) )
{
#ifndef UUXQT_MD
set(tx[3], MUIA_Text_Contents, p);
#endif
while( token = strtok( p, "," ) )
{
token = stpblk( token );
CLU_FPrintfAsync( tofile, "EMP:/%s\n", ng2board( token ) );
p = NULL;
}
}
else if( !strcmp( linebuffer, "x-gateway" ) )
{
while( token = strtok( p, "," ) )
{
token = stpblk( token );
CLU_FPrintfAsync( tofile, "GATE:%s\n", token );
p = NULL;
}
}
else if( !strcmp( linebuffer, "followup-to" ) )
{
while( token = strtok( p, "," ) )
{
token = stpblk( token );
/* Poster-Syntax */
if( !stricmp( token, "poster" ) )
{
gotfollowuptoposter = 1;
}
else
{
CLU_FPrintfAsync( tofile, "DISKUSSION-IN:/%s\n", ng2board( token ) );
}
p = NULL;
}
}
else if( !strcmp( linebuffer, "references" ) )
{
initstringlist( "BEZ" );
while( token = strtok( p, ">" ) )
{
while( *token == ',' || isspace( *token ) )
token++;
addstringlist( breakmid( token ) );
p = NULL;
}
dumpstringlist( tofile );
}
else if( !strcmp( linebuffer, "message-id" ) )
{
CLU_FPrintfAsync( tofile, "MID:%s\n", breakmid( p ) );
}
else if( !strcmp( linebuffer, "x-charset" ) )
{
if( !stricmp( p, "ISO-8859-1" ) )
isiso = TRUE;
}
else if( !strcmp( linebuffer, "content-type" ) )
{
if( strstr( p, "ISO" ) || strstr( p, "Iso" ) || strstr( p, "iso" ) )
isiso = TRUE;
}
#ifndef UUXQT_MD
else if( !strcmp( linebuffer, "lines" ) )
set(tx[5], MUIA_Text_Contents, p);
#endif
else if( !strcmp( linebuffer, "mime-version" ) )
ismime = TRUE;
else if( !strcmp( linebuffer, "content-transfer") )
{
if( stricmp( p, "8bit" ) )
isiso = TRUE;
}
else if( !strcmp( linebuffer, "x-newsreader" ) )
CLU_FPrintfAsync( tofile, "MAILER:%s\n", p );
else if( !strcmp( linebuffer, "x-mailer" ) )
CLU_FPrintfAsync( tofile, "MAILER:%s\n", p );
else if( !strcmp( linebuffer, "x-newssoftware" ) )
CLU_FPrintfAsync( tofile, "MAILER:%s\n", p );
else if( !strncmp( linebuffer, "x-z-", 4 ) )
CLU_FPrintfAsync( tofile, "%s:%s\n", &secbuf[ 4 ], p );
else if( !strncmp( linebuffer, "x-zc-", 5 ) )
CLU_FPrintfAsync( tofile, "%s:%s\n", &secbuf[ 5 ], p );
else
{
if ( !strnicmp( linebuffer, "X-", 2 ) )
CLU_FPrintfAsync( tofile, "%s:%s\n", secbuf, p );
else
CLU_FPrintfAsync( tofile, "U-%s:%s\n", secbuf, p );
}
}
if( gotfollowuptoposter && abs[á0 ] )
CLU_FPrintfAsync( tofile, "DISKUSSION-IN:%s", abs );
#ifndef UUXQT_MD
CLU_FPrintfAsync( tofile, "__SOURCEFMT:RFC1036/822\n" );
#endif
// Printf( "rnews: after header\n" );
if( (isiso ) || ( !isiso && !ismime ) )
CLU_WriteAsync( tofile, "CHARSET:ISO1\n", 13 );
if( len < LBLEN )
{
char *buffmem = allocbuffmem( len * 2 ), *buffptr = buffmem;
CLU_ReadAsync( fromfile, linebuffer, len );
for( c = 0; c < len; c++ )
{
if( linebuffer[ác ]á== 10 )
*buffptr++ = 13;
else if( linebuffer[ác ]á== 13 )
continue;
*buffptr++ = linebuffer[ác ];
}
CLU_FPrintfAsync( tofile, "LEN:%ld\n\n", buffptr - buffmem );
// #ifndef UUXQT_MD
// sprintf(dummy,"%ld Byte",buffptr - buffmem);
// set(tx[5], MUIA_Text_Contents, dummy);
// #endif
CLU_WriteAsync( tofile, buffmem, buffptr - buffmem );
freebuffmem( buffmem );
}
else // Langsame, aber Speicherplatzsparende Methode
{
/* Zeilen zΣhlen */
if( !bin )
{
offs = CLU_FtellAsync( fromfile );
c = len;
while( c-- )
{
ch = CLU_ReadCharAsync( fromfile );
if( ch < 0 )
break;
if( ch == 10 )
lf++;
else if( ch == 13 )
cr++;
}
CLU_SeekAsync( fromfile, offs, ASMODE_START );
CLU_FPrintfAsync( tofile, "LEN:%ld\n\n",
len + lf - cr
);
}
else
{
CLU_FPrintfAsync( tofile, "LEN:%ld\n\n",
len );
}
domui();
/* Artikelinhalt kopieren */
while( len-- )
{
ch = CLU_ReadCharAsync( fromfile );
if( ch == 13 )
continue;
else if( ch == 10 )
{
CLU_WriteCharAsync( tofile, 13 );
CLU_WriteCharAsync( tofile, 10 );
}
else CLU_WriteCharAsync( tofile, ch );
}
}
// Printf( "rnews: after copy\n" );
domui();
return( 0 );
}
#ifndef UUXQT_MD
static void trasharticle( int errorc, char *fromname, struct AsyncFile *fromfile, ULONG lastoffs, ULONG len )
{
char tempname[á128 ];
char tempcommentname[á128 ];
BPTR tfh;
static struct sortinprefs sortinprefs;
STRPTR destarray[á2 ];
addlog( 8, "trashed article %s/%s@%ld, len %ld, rc %ld", sourcebatchname, fromname, lastoffs, len, errorc );
CLP_GetPrefs( PREFSID_SORTIN, SUBID_SORTIN_PREFS, &sortinprefs, sizeof( sortinprefs ), NULL );
CLP_MakeTempFileName( tempname, len );
CLP_MakeTempFileName( tempcommentname, 4096 );
CLU_SeekAsync( fromfile, lastoffs, OFFSET_BEGINNING );
CLU_Copy( fromfile, tempname, len, CLUCOPY_SOURCE_ASYNC | CLUCOPY_DEST_NAME );
CLU_SeekAsync( fromfile, lastoffs + len, OFFSET_BEGINNING );
tfh = Open( tempcommentname, MODE_NEWFILE );
FPrintf( tfh,
"Defekte RFC-Nachricht gefunden:\n"
"Quelldatei: %s (%s, Offset @%ld)\n"
"Fehlercode: %ld (%s)\n"
"LΣnge.....: %ld Bytes\n\n",
sourcebatchname, fromname, lastoffs,
errorc, geterror( errorc ),
len
);
Close( tfh );
destarray[á0 ]á= sortinprefs.trashname;
destarray[á1 ]á= NULL;
CLMM_SendFileTags( "CLUUXQT", destarray,
CLMMT_SourceFile, tempname,
CLMMT_SourceCharset, CLMM_CS_ISO,
CLMMT_CommentFile, tempcommentname,
CLMMT_CommentCharset, CLMM_CS_ISO,
CLMMT_Subject, "Defekte RFC-Nachricht",
//CLMMT_ContentsType, isbin ? CLMM_CTF_BIN : CLMM_CTF_TEXT,
TAG_DONE
);
DeleteFile( tempname );
DeleteFile( tempcommentname );
}
#endif
/* RNEWS-Batch parsen und in einzelne Artikel zerlegen */
static int donews( char *fromname, struct AsyncFile * fromfile, char *toname )
{
int rc = 0;
struct AsyncFile * tofile;
int len;
int articlecount = 0;
int lastoffs, rnewslen, tofileoffs;
tofile = CLU_OpenAsync( toname, ASMODE_WRITE, ASYNCBUFF );
if( !tofile )
return( 3 );
for( ;; )
{
redo:
domui();
tofileoffs = CLU_FtellAsync( tofile );
lastoffs = CLU_FtellAsync( fromfile );
if( !CLU_FGetsAsync( fromfile, linebuffer, 2047 ) )
break;
if( strnicmp( linebuffer, "#! rnews", 8 ) )
{
addlog( 8, "Warning: %ld@%s/%s: #! rnews not found, out of sync", lastoffs, sourcebatchname, fromname );
while( CLU_FGetsAsync( fromfile, linebuffer, 2047 ) )
{
if( !strnicmp( linebuffer, "#! rnews", 8 ) )
{
int coffs;
CLU_SeekAsync( fromfile, -strlen( linebuffer ), OFFSET_CURRENT );
coffs = CLU_FtellAsync( fromfile );
addlog( 8, "Warning: resynched at offset %ld, skipped %ld bytes!", coffs, coffs - lastoffs );
goto redo;
}
}
rc = 4;
break;
}
rnewslen = CLU_FtellAsync( fromfile ) - lastoffs;
len = atoi( &linebuffer[ 8 ] );
// Printf( "rnews: msglen %ld\n", len );
/* Nun gut... */
rc = doarticle( fromfile, tofile, len );
#ifndef UUXQT_MD
// Fehler bei Artikelbearbeitung
if( rc )
{
BPTR tfh;
CLU_CloseAsync( tofile );
tfh = Open( toname, MODE_OLDFILE );
if( tfh )
{
SetFileSize( tfh, tofileoffs, OFFSET_BEGINNING );
Close( tfh );
}
tofile = CLU_OpenAsync( toname, ASMODE_APPEND, ASYNCBUFF );
if( !tofile )
{
rc = 3;
break;
}
trasharticle( rc, fromname, fromfile, lastoffs, len + rnewslen );
rc = 0;
}
#endif
articlecount++;
set_fg( CLU_FtellAsync( fromfile ) );
}
CLU_CloseAsync( tofile );
addlog( 6, "finished processing; %ld articles, error %ld ", articlecount, rc );
return( rc );
}
/*void __asm __saveds doexitsig( register __a0 struct Task *t )
{
Signal( t, SIGBREAKF_CTRL_D );
}
*/
extern APTR app;
extern char gzipfullpath[];
int rnews( char *from, char *to )
{
struct AsyncFile * newsfile;
struct AsyncFile * tmpfile;
BPTR dostmpfile, dosnewsfile;
int rc;
sourcebatchname = from;
dosnewsfile = Open( from, MODE_OLDFILE );
if( !dosnewsfile )
return( 1 );
SetVBuf( dosnewsfile, NULL, BUF_FULL, ASYNCBUFF );
FGets( dosnewsfile, linebuffer, 2047 );
Flush( dosnewsfile );
/* Ungebatcht? */
if( !strnicmp( linebuffer, "#! rnews", 8 ) )
{
set_status( GS( MSG_TXT_CONVERTNEWS ) );
Close( dosnewsfile );
newsfile = CLU_OpenAsync( from, ASMODE_READ, ASYNCBUFF );
rc = donews( from, newsfile, to );
lastoffset = CLU_FtellAsync( newsfile );
CLU_CloseAsync( newsfile );
return( rc );
}
sprintf( tempfile, "uuconv.%lxtmp", CLU_GetSeqNum() );
// Printf( "rnews: tempfile name %s\n", tempfile );
/* Ohne Header? */
if( strnicmp( linebuffer, "#! cunbatch", 11 ) &&
strnicmp( linebuffer, "#! gunbatch", 11 ) )
{
Seek( dosnewsfile, 0, OFFSET_BEGINNING );
}
dostmpfile = Open( tempfile, MODE_READWRITE );
if( !dostmpfile )
{
Close( dosnewsfile );
return( 2 );
}
SetVBuf( dostmpfile, NULL, BUF_FULL, ASYNCBUFF );
/* Entpacken */
addlog( 5, "uncompressing %s to %s", from, tempfile );
domui();
set_status( GS( MSG_TXT_UNBATCH ) );
// set_sleep( TRUE );
#ifndef UUXQT_MD
CLP_PK_AllocSem();
rc = CLU_MUI_RunCommand( app, "UUCP:C/GZip -d",
NP_Input, dosnewsfile,
NP_Output, dostmpfile,
NP_StackSize, 20480,
NP_Priority, -1,
TAG_DONE
);
CLP_PK_FreeSem();
#else
{
char exec[ 256 ];
strcpy( exec, gzipfullpath );
strcat( exec, " -d" );
rc = SystemTags( exec,
SYS_Input, dosnewsfile,
SYS_Output, dostmpfile,
NP_StackSize, 20480,
NP_Priority, -1,
TAG_DONE
);
Close( dosnewsfile );
Close( dostmpfile );
}
#endif
// set_sleep( FALSE );
if( rc > 5 )
{
addlog( 9, "gzip error return %ld!", rc );
}
rc = CLU_GetFileLen( tempfile );
addlog( 5, "unbatched size %ld", rc );
set_file( tempfile, rc );
domui();
tmpfile = CLU_OpenAsync( tempfile, ASMODE_READ, ASYNCBUFF );
// Printf( "rnews: tmpfile ptr %lx\n", tmpfile );
set_status( GS( MSG_TXT_CONVERTNEWS ) );
rc = donews( tempfile, tmpfile, to );
lastoffset = CLU_FtellAsync( tmpfile );
CLU_CloseAsync( tmpfile );
if( !rc )
DeleteFile( from );
DeleteFile( tempfile );
return( rc );
}