X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FBarCodePage.c;h=6895a87896b2fc188b4680493176bd1219c02b4a;hp=ef48ce77bcd4d2d6c2fb43e7e9673d47b935fc08;hb=fa15a3f1ecd64efd8440e46d398fd9976abc3d25;hpb=f554a11afa7c50c2b0267e890fb7581b6605384d diff --git a/sources/BarCodePage.c b/sources/BarCodePage.c index ef48ce7..6895a87 100644 --- a/sources/BarCodePage.c +++ b/sources/BarCodePage.c @@ -1,4 +1,4 @@ -/* BarCodeOld.c +/* BarCodePage.c * * Copyright (C) 2002 Simone Piccardi * @@ -29,28 +29,25 @@ * http://localhost/cgi-bin/barcode?string * where string is the code to be converted * - * $Id: BarCodePage.c,v 1.1 2002/06/30 13:26:17 piccardi Exp $ - * ****************************************************************/ /* * Include needed headers */ -#include /* predefined types */ -#include /* stat deinitiions */ -#include /* include unix standard library */ -/* */ -#include /* include standard I/O library */ -#include /* include standard library */ -#include /* include string library */ -#include /* include wait call */ -#include -#include -#include +#include /* primitive system data types */ +#include /* file characteristics constants and functions */ +#include /* unix standard library */ +#include /* standard I/O library */ +#include /* C standard library */ +#include /* C strings library */ +#include /* process termination constants and functions */ +#include /* file control functions */ +#include /* C assertion functions */ +#include /* date and time constants, types and functions */ + #include"macros.h" void WriteMess(char *mess); - /* Program begin */ int main(int argc, char *argv[], char *envp[]) { @@ -66,7 +63,7 @@ int main(int argc, char *argv[], char *envp[]) /* * Begin */ - /* create two pipes to handle process communication */ + /* create two pipes, pipein and pipeout, to handle communication */ if ( (retval = pipe(pipein)) ) { WriteMess("input pipe creation error"); exit(0); @@ -75,11 +72,10 @@ int main(int argc, char *argv[], char *envp[]) WriteMess("output pipe creation error"); exit(0); } - /* fork child to run barcode program */ - pid = fork(); - if (pid == -1) { + /* First fork: use child to run barcode program */ + if ( (pid = fork()) == -1 ) { WriteMess("child creation error"); - exit(0); + exit(0); } /* if child */ if (pid == 0) { @@ -92,7 +88,7 @@ int main(int argc, char *argv[], char *envp[]) dup2(pipein[0], STDIN_FILENO); /* remap stdin in pipe input */ close(pipeout[0]); dup2(pipeout[1], STDOUT_FILENO); /* remap stdout in pipe output */ - execlp("barcode", "barcode", size, NULL); //"-o", "-", NULL); + execlp("barcode", "barcode", size, NULL); } /* * Parent write string to pipe input and close it, @@ -103,9 +99,8 @@ int main(int argc, char *argv[], char *envp[]) write(pipein[1], argv[1], strlen(argv[1])); close(pipein[1]); waitpid(pid, NULL, 0); - /* Second fork use child to run ghostscript*/ - pid = fork(); - if (pid == -1) { + /* Second fork: use child to run ghostscript*/ + if ( (pid = fork()) == -1) { WriteMess("child creation error"); exit(0); }