projects
/
gapil.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
varie su read/pread/dup/dup2 ecc.
[gapil.git]
/
sources
/
BarCode.c
diff --git
a/sources/BarCode.c
b/sources/BarCode.c
index 138e23ab5d3908538afeccfaea03d2018d13211b..7852dae397a3bd165cab915e290b7743516f121e 100644
(file)
--- a/
sources/BarCode.c
+++ b/
sources/BarCode.c
@@
-29,7
+29,7
@@
* http://localhost/cgi-bin/barcode?string
* where string is the code to be converted
*
* http://localhost/cgi-bin/barcode?string
* where string is the code to be converted
*
- * $Id: BarCode.c,v 1.
1 2002/06/18 22:11:06
piccardi Exp $
+ * $Id: BarCode.c,v 1.
2 2002/06/21 22:24:10
piccardi Exp $
*
****************************************************************/
/*
*
****************************************************************/
/*
@@
-57,15
+57,12
@@
int main(int argc, char *argv[], char *envp[])
/*
* Variables definition
*/
/*
* Variables definition
*/
- char buffer[8192];
pid_t pid;
pid_t pid;
- size_t n;
int retval;
int pipein[2];
int pipeout[2];
int retval;
int pipein[2];
int pipeout[2];
- char size[]="-pA9";
- char psize[]="-sPAPERSIZE=a9";
char content[]="Content-type: image/jpeg\n\n";
char content[]="Content-type: image/jpeg\n\n";
+ char size[]="-pA9";
/*
* Begin
*/
/*
* Begin
*/
@@
-88,7
+85,7
@@
int main(int argc, char *argv[], char *envp[])
if (pid == 0) {
/*
* Child exec barcode program, that take input (string to encode)
if (pid == 0) {
/*
* Child exec barcode program, that take input (string to encode)
- * from pipein, remapped to stdin, and write the output (a
ppm
+ * from pipein, remapped to stdin, and write the output (a
PS
* image) to stdout, remapped to pipeout
*/
close(pipein[1]); /* close output side of input pipe */
* image) to stdout, remapped to pipeout
*/
close(pipein[1]); /* close output side of input pipe */
@@
-100,14
+97,14
@@
int main(int argc, char *argv[], char *envp[])
/*
* Parent write string to pipe input and close it,
* then wait child execution and results form pipeout,
/*
* Parent write string to pipe input and close it,
* then wait child execution and results form pipeout,
- * then fork to convert
ppm to gif using ppmtogif
+ * then fork to convert
PS to JPEG using gs
*/
close(pipein[0]); /* close input side of input pipe */
*/
close(pipein[0]); /* close input side of input pipe */
-
n=
write(pipein[1], argv[1], strlen(argv[1]));
+ write(pipein[1], argv[1], strlen(argv[1]));
close(pipein[1]);
waitpid(pid, NULL, 0);
/*
close(pipein[1]);
waitpid(pid, NULL, 0);
/*
- * refork to use
ppmtogif
+ * refork to use
gs
*/
pid = fork();
if (pid == -1) {
*/
pid = fork();
if (pid == -1) {
@@
-115,16
+112,13
@@
int main(int argc, char *argv[], char *envp[])
exit(0);
}
/*
exit(0);
}
/*
- * second child, convert
ppm to gif
+ * second child, convert
PS to JPEG
*/
if (pid == 0) {
/* send mime type */
close(pipeout[1]);
dup2(pipeout[0], STDIN_FILENO);
write(STDOUT_FILENO, content, strlen(content));
*/
if (pid == 0) {
/* send mime type */
close(pipeout[1]);
dup2(pipeout[0], STDIN_FILENO);
write(STDOUT_FILENO, content, strlen(content));
- n=read(pipeout[0], buffer, sizeof(buffer));
- printf("Letti %n di %n, %s\n", n, sizeof(buffer), buffer);
- exit(0);
execlp("gs", "gs", "-q", "-sDEVICE=jpeg", "-sOutputFile=-", "-", NULL);
}
/*
execlp("gs", "gs", "-q", "-sDEVICE=jpeg", "-sOutputFile=-", "-", NULL);
}
/*