void r_prg(char *prog, int fd) { FILE *fp; fp=fdopen(fd,"w"); s_header(fp,NULL); fflush(fp); dup2(fd,1); dup2(fd,2); close(fd); execl(prog,prog,NULL); perror(prog); }
void s_dir(char *dir, int fd) { FILE *fp; fp=fdopen(fd,"w"); s_header(fp,TXT_C); fprintf(fp,"\r\n"); fflush(fp); dup2(fd,1); dup2(fd,2); close(fd); execlp("ls","ls","-l",dir,NULL); perror(dir); exit(1); }
/*--------------------------------------*/ virtual void writeText_sparse(const char *fn, const AzIntArr *ia, int digits) const { AzFile file(fn); file.open("wb"); AzBytArr s_header("sparse "); s_header.cn(rowNum()); s_header.nl(); s_header.writeText(&file); int num; const int *cxs = ia->point(&num); int ix; for (ix = 0; ix < num; ++ix) { int cx = cxs[ix]; AzBytArr s; col(cx)->to_sparse(&s, digits); s.nl(); s.writeText(&file); } file.close(true); }
void f_cat(char *arg, int fd) { char *extension=get_context(arg); char *context= TXT_C; FILE *fpsock, *fpfile; int c; fpsock=fdopen(fd,"w"); fpfile=fopen(arg,"r"); if(fpsock!=NULL&&fpfile!=NULL){ s_header(fpsock,context); fprintf(fpsock,"\r\n"); while((c=getc(fpfile))!=EOF){ putc(c,fpsock); } } fclose(fpfile); fclose(fpsock); exit(0); }