/* (C) 2004 by Guaracy Monteiro http://www.txt2tags-win.sf.net */ #include #include #define ERRFILENAME "stderr.log" char cmd[2048]; void out(FILE *fp) { while (!feof(fp)) { cmd[0]=0; fgets(cmd,80,fp); printf("%s",cmd); } } int main(int argc, char* argv[]) { FILE *fp; int i; dup2(fileno(stdout),fileno(stderr)); strcpy(cmd,"txt2tags.exe "); for (i=1; i<(argc); i++) { if (strchr(argv[i], ' ')) { strcat(strcat(strcat(cmd,"\""),argv[i]),"\""); } else { strcat(cmd,argv[i]); } strcat(cmd," "); } strcat(strcat(cmd, "2> "),ERRFILENAME); remove(ERRFILENAME); /* deletar stderr.log */ if ((fp = popen(cmd, "rt")) == NULL) { perror("popen"); exit(1); } out(fp); pclose(fp); if ((fp = fopen(ERRFILENAME,"rt")) == NULL) { exit(0); } out(fp); fclose(fp); return(0); }