| 446 | */ |
| 447 | |
| 448 | void |
| 449 | WriteTextComment(const char *name, /* I - Comment name ("Title", etc.) */ |
| 450 | const char *value) /* I - Comment value */ |
| 451 | { |
| 452 | int len; /* Current line length */ |
| 453 | |
| 454 | |
| 455 | /* |
| 456 | * DSC comments are of the form: |
| 457 | * |
| 458 | * %%name: value |
| 459 | * |
| 460 | * The name and value must be limited to 7-bit ASCII for most printers, |
| 461 | * so we escape all non-ASCII and ASCII control characters as described |
| 462 | * in the Adobe Document Structuring Conventions specification. |
| 463 | */ |
| 464 | |
| 465 | printf("%%%%%s: (", name); |
| 466 | len = 5 + (int)strlen(name); |
| 467 | |
| 468 | while (*value) |
| 469 | { |
| 470 | if (*value < ' ' || *value >= 127) |
| 471 | { |
| 472 | /* |
| 473 | * Escape this character value... |
| 474 | */ |
| 475 | |
| 476 | if (len >= 251) /* Keep line < 254 chars */ |
| 477 | break; |
| 478 | |
| 479 | printf("\\%03o", *value & 255); |
| 480 | len += 4; |
| 481 | } |
| 482 | else if (*value == '\\') |
| 483 | { |
| 484 | /* |
| 485 | * Escape the backslash... |
| 486 | */ |
| 487 | |
| 488 | if (len >= 253) /* Keep line < 254 chars */ |
| 489 | break; |
| 490 | |
| 491 | putchar('\\'); |
| 492 | putchar('\\'); |
| 493 | len += 2; |
| 494 | } |
| 495 | else |
| 496 | { |
| 497 | /* |
| 498 | * Put this character literally... |
| 499 | */ |
| 500 | |
| 501 | if (len >= 254) /* Keep line < 254 chars */ |
| 502 | break; |
| 503 | |
| 504 | putchar(*value); |
| 505 | len ++; |
no outgoing calls
no test coverage detected