/* * (c) SPDsoft 1994 */ static char __ident[] = "@(#)(c) SPDsoft, 15 de septiembre 1995"; #define VERS_STR ((char*)&__ident[4]) #include #include #define N_MG (sizeof(magic)) #define DoError(frm, str) fprintf(stderr,frm,app_name,str,'\n') FILE *newfile(int i); char *app_name; char magic[3]={0xff, 0xd8, 0xff}; int main( int argc, char *argv[] ) { int i=0; int c; char *bp=magic, *bell=&magic[N_MG-1]; FILE *f=NULL; app_name = argv[0]; f = newfile(i); while ( EOF != ( c = getchar() )) { if ( c == (int) *bp ) { if ( bp == bell ) { /* la flauta ! */ fclose(f); f = newfile(++i); bp = magic; } else bp++; } else { bp = magic; } fputc( c, f ); } if (f) fclose(f); } FILE *newfile(int i) { char s[256]; FILE *f; sprintf(s,"out.%03d.jpg", i); if ( !(f = fopen ( s, "wb" ))) { perror("fopen"); exit(errno); } fwrite( magic, N_MG - 1, 1, f); return( f ); }