Changeset 1012
- Timestamp:
- Feb 22, 2017, 1:08:56 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rpm/trunk/build/rpmfc.c
r636 r1012 1 1 #include "system.h" 2 3 #ifdef __EMX__4 #include <process.h>5 #include <stdlib.h>6 #endif7 2 8 3 #include <errno.h> … … 21 16 #include <rpm/rpmfi.h> 22 17 #include <rpm/rpmstrpool.h> 18 19 #ifdef __EMX__ 20 #include <sys/socket.h> 21 /* Use socketpair instead of pipe because of select */ 22 #define pipe(p) socketpair(AF_UNIX, SOCK_STREAM, 0, p) 23 #endif 23 24 24 25 #include "lib/rpmfi_internal.h" /* rpmfiles stuff for now */ … … 206 207 int myerrno = 0; 207 208 int ret = 1; /* assume failure */ 208 #ifdef __EMX__ 209 int i, fd, nbw, nbr; 210 FILE* in; 211 char tmpfile[_MAX_PATH]; 212 char buffer[32*1024]; 213 #endif 214 215 #ifndef __EMX__ 209 216 210 if (pipe(toProg) < 0 || pipe(fromProg) < 0) { 217 211 rpmlog(RPMLOG_ERR, _("Couldn't create pipe for %s: %m\n"), argv[0]); … … 253 247 close(fromProg[1]); 254 248 255 #else256 257 #if 0258 if (dir && chdir(dir)) {259 rpmlog(RPMLOG_ERR, _("Couldn't chdir to %s: %s\n"),260 dir, strerror(errno));261 _exit(EXIT_FAILURE);262 }263 #endif264 265 // write data to file266 strcpy( tmpfile, "check-files-XXXXXX");267 if (mktemp( tmpfile) == NULL) {268 rpmlog(RPMLOG_ERR, _("Couldn't get temp file: %s\n"),269 strerror(errno));270 return NULL;271 }272 fd = open( tmpfile, O_CREAT|O_TRUNC|O_BINARY|O_WRONLY);273 if (fd == -1) {274 unlink(tmpfile);275 rpmlog(RPMLOG_ERR, _("Couldn't open temp file: %s\n"),276 strerror(errno));277 return NULL;278 }279 nbw = write( fd, writePtr,writeBytesLeft);280 if (nbw != writeBytesLeft) {281 close(fd);282 unlink(tmpfile);283 rpmlog(RPMLOG_ERR, _("Couldn't write temp file: %s\n"),284 strerror(errno));285 return NULL;286 }287 close(fd);288 289 // create command line, popen does290 // not directly execute shell scripts :-(291 // TODO rewrite check-files.sh in rexx292 strcpy( buffer, "sh -c \"");293 strcat( buffer, argv[0]);294 // popen requires backslash!295 //for( i=0; i<strlen(buffer); i++)296 // if (buffer[i] == '/')297 // buffer[i] = '\\';298 299 i = 1;300 while( argv[i] != NULL) {301 strcat( buffer, " ");302 strcat( buffer, argv[i++]);303 }304 // add temp file305 strcat( buffer, " ");306 strcat( buffer, tmpfile);307 strcat( buffer, "\"");308 if (0)309 fprintf( stderr,"command line: '%s'\n", buffer);310 311 // execute child and read input pipe312 in = popen( buffer, "r");313 if (in == NULL) {314 unlink(tmpfile);315 rpmlog(RPMLOG_ERR, _("Couldn't popen: %s\n"),316 strerror(errno));317 return NULL;318 }319 320 249 readBuff = newStringBuf(); 321 322 /* Read any data from prog */323 { char buf[BUFSIZ+1];324 while (!feof(in)) {325 nbr = fread(buf, 1, sizeof(buf)-1, in);326 buf[nbr] = '\0';327 if (0)328 fprintf( stderr,"read '%s'\n",buf);329 appendStringBuf(readBuff, buf);330 }331 }332 fclose(in);333 334 // delete temporary335 unlink(tmpfile);336 337 #endif // __EMX__338 339 #ifndef __EMX__340 readBuff = newStringBuf();341 250 342 251 while (1) { … … 421 330 goto exit; 422 331 } 423 #endif // __EMX__424 332 425 333 ret = 0;
Note:
See TracChangeset
for help on using the changeset viewer.