static void finished_p(void) { if(THIS->done) return; if(THIS->fd != -1) { if(THIS->living_outputs > 1) return; if(THIS->firstinput) return; }else{ if(THIS->living_outputs) return; } pipe_done(); }
/*! @decl void finish() *! *! Terminate and reinitialize the pipe. */ static void pipe_finish(INT32 args) { pop_n_elems(args); push_int(0); pipe_done(); }
static int adbTARScan(const char *path) { uint32_t arcref; struct arcentry a; int extfd; char buffer[BUFFER_SIZE]; size_t bufferfill=0; int retval; size_t skip=0; size_t requiredata=0; /* fprintf(stderr, "adbTARScan, %s\n", path);*/ if (!setupformat(path)) return 0; switch (format) { /* case 0:*/ default: /* avoids warning -ss040902 */ extfd=open(path, O_RDONLY); break; case 1: { char *argv[5]; argv[0]="gunzip"; argv[1]="-c"; argv[2]="-d"; argv[3]="-f"; argv[4]=NULL; extfd=pipe_uncompress("gunzip", argv, path); break; } case 2: { char *argv[4]; argv[0]="bzcat"; argv[1]="-d"; argv[2]="-c"; argv[3]=NULL; extfd=pipe_uncompress("bzcat", argv, path); break; } case 3: { char *argv[2]; argv[0]="zcat"; argv[1]=NULL; extfd=pipe_uncompress("zcat", argv, path); break; } } if (extfd<0) return 0; if ((retval=read(extfd, buffer, BUFFER_SIZE))<=0) { pipe_done(); return 0; } bufferfill=retval; memset(a.name, 0, sizeof(a.name)); strncpy(a.name, arcname, sizeof(a.name)-1); a.size=_filelength(path); a.flags=ADB_ARC; if (!adbAdd(&a)) { pipe_done(); return 0; } arcref=adbFind(arcname); while (1) { while ((bufferfill>(sizeof(struct posix_header)+requiredata))&&(!skip)) { struct posix_header *entry=(struct posix_header *)buffer; /* do we need this entry? */ size_t size; if (strncmp(entry->magic, "ustar", 5)) { if (memcmp(entry->magic, "\0\0\0\0\0\0", 6)) { fprintf(stderr, "arctar: Error in TAR-stream: %s\n", path); pipe_done(); return 0; } } if (!*entry->name) { pipe_done(); return 1; } /* fprintf(stderr, "arctar: Entry: %s\n", entry->name);*/ size=char12tosize_t(entry->size); _splitpath(entry->name, 0, 0, name, ext); if(fsIsModule(ext)) { if ( ((strlen(entry->name)+1)<ARC_PATH_MAX) && ( (entry->typeflag==REGTYPE) || (entry->typeflag==AREGTYPE) ) ) { /* TODO if ((!strcasecmp(ext, MIF_EXT))&&size<65536) requiredata=size; else*/ { requiredata=1084; if (size<requiredata) requiredata=size; } if (bufferfill<(sizeof(struct posix_header)+requiredata)) break; /* we need more data */ strcpy(a.name, entry->name); a.size=size; a.flags=0; a.parent=arcref; if(!adbAdd(&a)) { pipe_done(); return 0; } strcpy(a.name, name); strcat(a.name, ext); if (fsScanInArc) { char shortname[12]; uint32_t fileref; struct moduleinfostruct mi; fs12name(shortname, a.name); fileref=mdbGetModuleReference(shortname, a.size); if (fileref==0xffffffff) { pipe_done(); return 0; } if (!mdbInfoRead(fileref)) { if (mdbGetModuleInfo(&mi, fileref)) { mdbReadMemInfo(&mi, buffer+sizeof(struct posix_header), 1084); mdbWriteModuleInfo(fileref, &mi); } } /* TODO MIF_EXT a.name.... if ((!stricmp(ext, MIF_EXT)) && (size<65536)) mifMemRead(a.name, size, buffer+sizeof(struct posix_header)); */ } requiredata=0; } } skip=(sizeof(struct posix_header)+size+BLOCKSIZE-1)&~(BLOCKSIZE-1); } if (skip) { if (skip>bufferfill) { skip-=bufferfill; bufferfill=0; } else { memmove(buffer, buffer+skip, bufferfill-skip); bufferfill-=skip; skip=0; } } retval=read(extfd, buffer+bufferfill, BUFFER_SIZE-bufferfill); if (retval<=0) break; bufferfill+=retval; } pipe_done(); return 1; }