| 485 | */ |
| 486 | |
| 487 | cups_file_t * /* O - CUPS file */ |
| 488 | pipe_sendmail(const char *to) /* I - To: address */ |
| 489 | { |
| 490 | cups_file_t *fp; /* CUPS file */ |
| 491 | int pid; /* Process ID */ |
| 492 | int pipefds[2]; /* Pipe file descriptors */ |
| 493 | int argc; /* Number of arguments */ |
| 494 | char *argv[100], /* Argument array */ |
| 495 | line[1024], /* Sendmail command + args */ |
| 496 | *lineptr; /* Pointer into line */ |
| 497 | |
| 498 | |
| 499 | /* |
| 500 | * First break the mailtoSendmail string into arguments... |
| 501 | */ |
| 502 | |
| 503 | strlcpy(line, mailtoSendmail, sizeof(line)); |
| 504 | argv[0] = line; |
| 505 | argc = 1; |
| 506 | |
| 507 | for (lineptr = strchr(line, ' '); lineptr; lineptr = strchr(lineptr, ' ')) |
| 508 | { |
| 509 | while (*lineptr == ' ') |
| 510 | *lineptr++ = '\0'; |
| 511 | |
| 512 | if (*lineptr) |
| 513 | { |
| 514 | /* |
| 515 | * Point to the next argument... |
| 516 | */ |
| 517 | |
| 518 | argv[argc ++] = lineptr; |
| 519 | |
| 520 | /* |
| 521 | * Stop if we have too many... |
| 522 | */ |
| 523 | |
| 524 | if (argc >= (int)(sizeof(argv) / sizeof(argv[0]) - 2)) |
| 525 | break; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | argv[argc ++] = (char *)to; |
| 530 | argv[argc] = NULL; |
| 531 | |
| 532 | /* |
| 533 | * Create the pipe... |
| 534 | */ |
| 535 | |
| 536 | if (pipe(pipefds)) |
| 537 | { |
| 538 | perror("ERROR: Unable to create pipe"); |
| 539 | return (NULL); |
| 540 | } |
| 541 | |
| 542 | /* |
| 543 | * Then run the command... |
| 544 | */ |
no test coverage detected