| 711 | */ |
| 712 | |
| 713 | void |
| 714 | cupsdLoadAllSubscriptions(void) |
| 715 | { |
| 716 | int i; /* Looping var */ |
| 717 | cups_file_t *fp; /* subscriptions.conf file */ |
| 718 | int linenum; /* Current line number */ |
| 719 | char line[1024], /* Line from file */ |
| 720 | *value, /* Pointer to value */ |
| 721 | *valueptr; /* Pointer into value */ |
| 722 | cupsd_subscription_t *sub; /* Current subscription */ |
| 723 | int hex; /* Non-zero if reading hex data */ |
| 724 | int delete_sub; /* Delete subscription? */ |
| 725 | |
| 726 | |
| 727 | /* |
| 728 | * Open the subscriptions.conf file... |
| 729 | */ |
| 730 | |
| 731 | snprintf(line, sizeof(line), "%s/subscriptions.conf", ServerRoot); |
| 732 | if ((fp = cupsdOpenConfFile(line)) == NULL) |
| 733 | return; |
| 734 | |
| 735 | /* |
| 736 | * Read all of the lines from the file... |
| 737 | */ |
| 738 | |
| 739 | linenum = 0; |
| 740 | sub = NULL; |
| 741 | delete_sub = 0; |
| 742 | |
| 743 | while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum)) |
| 744 | { |
| 745 | if (!_cups_strcasecmp(line, "NextSubscriptionId") && value) |
| 746 | { |
| 747 | /* |
| 748 | * NextSubscriptionId NNN |
| 749 | */ |
| 750 | |
| 751 | i = atoi(value); |
| 752 | if (i >= NextSubscriptionId && i > 0) |
| 753 | NextSubscriptionId = i; |
| 754 | } |
| 755 | else if (!_cups_strcasecmp(line, "<Subscription")) |
| 756 | { |
| 757 | /* |
| 758 | * <Subscription #> |
| 759 | */ |
| 760 | |
| 761 | if (!sub && value && isdigit(value[0] & 255)) |
| 762 | { |
| 763 | sub = cupsdAddSubscription(CUPSD_EVENT_NONE, NULL, NULL, NULL, |
| 764 | atoi(value)); |
| 765 | } |
| 766 | else |
| 767 | { |
| 768 | cupsdLogMessage(CUPSD_LOG_ERROR, |
| 769 | "Syntax error on line %d of subscriptions.conf.", |
| 770 | linenum); |
no test coverage detected