#include #include #include #include #include FILE *outfile; main(argc,argv) int argc; char *argv[]; { long int fileNumInt; int partit, openit; char theChar, fileNumStr[1000], bufStr[4]; if (argc<2 || argc>2) { printf( "For dividing PubChem SDF dumps.\n" ); printf( "Needs stdin and starting file number.\n" ); exit(1); } fileNumInt = atoi( argv[1] ); itoa ( fileNumInt , fileNumStr, 10); openit=1; while(1) { partit=0; while( partit==0 ) { theChar = getchar (); if ( feof(stdin) ) { printf ("All done\n"); exit(1); } if ( openit == 1 ) { outfile = fopen ( fileNumStr , "w" ); openit=0; } fputc ( theChar, outfile ); bufStr[3]=bufStr[2]; bufStr[2]=bufStr[1]; bufStr[1]=bufStr[0]; bufStr[0]=theChar; if (bufStr[0]=='$' && bufStr[1]=='$' && bufStr[2]=='$' && bufStr[3]=='$' ) { fputc ( '\n' , outfile ); fclose ( outfile ); printf ("%s done\n", fileNumStr ); partit=1; fileNumInt++; itoa ( fileNumInt , fileNumStr, 10); openit=1; } } } printf ("Never gets here\n"); } /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: lib/crtdll/stdlib/itoa.c * PURPOSE: converts a integer to ascii * PROGRAMER: * UPDATE HISTORY: * 1995: Created * 1998: Added ltoa Boudewijn Dekker */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ char * itoa(int value, char *string, int radix) { char tmp[33]; char *tp = tmp; int i; unsigned v; int sign; char *sp; if (radix > 36 || radix <= 1) { return 0; } sign = (radix == 10 && value < 0); if (sign) v = -value; else v = (unsigned)value; while (v || tp == tmp) { i = v % radix; v = v / radix; if (i < 10) *tp++ = i+'0'; else *tp++ = i + 'a' - 10; } if (string == 0) string = (char *)malloc((tp-tmp)+sign+1); sp = string; if (sign) *sp++ = '-'; while (tp > tmp) *sp++ = *--tp; *sp = 0; return string; } char * ltoa(long value, char *string, int radix) { char tmp[33]; char *tp = tmp; long i; unsigned long v; int sign; char *sp; if (radix > 36 || radix <= 1) { return 0; } sign = (radix == 10 && value < 0); if (sign) v = -value; else v = (unsigned long)value; while (v || tp == tmp) { i = v % radix; v = v / radix; if (i < 10) *tp++ = i+'0'; else *tp++ = i + 'a' - 10; } if (string == 0) string = (char *)malloc((tp-tmp)+sign+1); sp = string; if (sign) *sp++ = '-'; while (tp > tmp) *sp++ = *--tp; *sp = 0; return string; } char * _ultoa(unsigned long value, char *string, int radix) { char tmp[33]; char *tp = tmp; long i; unsigned long v = value; char *sp; if (radix > 36 || radix <= 1) { return 0; } while (v || tp == tmp) { i = v % radix; v = v / radix; if (i < 10) *tp++ = i+'0'; else *tp++ = i + 'a' - 10; } if (string == 0) string = (char *)malloc((tp-tmp)+1); sp = string; while (tp > tmp) *sp++ = *--tp; *sp = 0; return string; }