/*cole-AfreeCOLElibrary.cole_extract-Extractafilefromafilesystem.Copyright1998,1999RobertoArturoTenaSanchezThisprogramisfreesoftware;youcanredistributeitand/ormodifyitunderthetermsoftheGNUGeneralPublicLicenseaspublishedbytheFreeSoftwareFoundation;eitherversion2oftheLicense,or(atyouroption)anylaterversion.Thisprogramisdistributedinthehopethatitwillbeuseful,butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyofMERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.SeetheGNUGeneralPublicLicenseformoredetails.YoushouldhavereceivedacopyoftheGNUGeneralPublicLicensealongwiththisprogram;ifnot,writetotheFreeSoftwareFoundation,Inc.,59TemplePlace,Suite330,Boston,MA02111-1307USA*//*ArturoTena*/#include/*Tocompilethisfileoutsidecolesourcetree,youmustincludehereinstead*/#include"cole.h"#definePRGNAME"iOLE"#defineBUFFER_SIZE128intmain(intargc,char**argv){ COLEFS*cfs; COLEFILE*cf; COLERRNOcolerrno; charbuffer[BUFFER_SIZE]; size_tchar_read; if(argc!=3){ fprintf(stderr,"cole_extract.Extractafilefroma" "filesystemtothestandardoutput.\n" "Usage:"PRGNAME"\n" "FILE-Filewiththefilesystem.\n" "INFILE-Filenameofthefiletoextract.\n"); exit(1); } printf("%s",argv[1]); cfs=cole_mount(argv[1],&colerrno); if(cfs==NULL){ cole_perror(PRGNAME,colerrno); exit(1); } cf=cole_fopen(cfs,argv[2],&colerrno); if(cf==NULL){ cole_perror(PRGNAME,colerrno); cole_umount(cfs,NULL); exit(1); } while((char_read=cole_fread(cf,buffer,BUFFER_SIZE,&colerrno))){ if(fwrite(buffer,1,char_read,stdout)!=char_read){ break; } } if(!cole_feof(cf)){ cole_perror(PRGNAME,colerrno); cole_umount(cfs,NULL); exit(1); } if(cole_fclose(
1