| 1064 | */ |
| 1065 | |
| 1066 | void |
| 1067 | cupsdSaveAllSubscriptions(void) |
| 1068 | { |
| 1069 | int i, j, /* Looping vars */ |
| 1070 | scount; /* Number of subscriptions */ |
| 1071 | cups_file_t *fp; /* subscriptions.conf file */ |
| 1072 | char filename[1024]; /* subscriptions.conf filename */ |
| 1073 | cupsd_subscription_t *sub; /* Current subscription */ |
| 1074 | unsigned mask; /* Current event mask */ |
| 1075 | const char *name; /* Current event name */ |
| 1076 | int hex; /* Non-zero if we are writing hex data */ |
| 1077 | |
| 1078 | |
| 1079 | /* |
| 1080 | * Create the subscriptions.conf file... |
| 1081 | */ |
| 1082 | |
| 1083 | snprintf(filename, sizeof(filename), "%s/subscriptions.conf", ServerRoot); |
| 1084 | |
| 1085 | if ((fp = cupsdCreateConfFile(filename, ConfigFilePerm)) == NULL) |
| 1086 | return; |
| 1087 | |
| 1088 | cupsdLogMessage(CUPSD_LOG_INFO, "Saving subscriptions.conf..."); |
| 1089 | |
| 1090 | /* |
| 1091 | * Write a small header to the file... |
| 1092 | */ |
| 1093 | |
| 1094 | cupsFilePuts(fp, "# Subscription configuration file for " CUPS_SVERSION "\n"); |
| 1095 | cupsFilePrintf(fp, "# Written by cupsd\n"); |
| 1096 | |
| 1097 | cupsFilePrintf(fp, "NextSubscriptionId %d\n", NextSubscriptionId); |
| 1098 | |
| 1099 | /* |
| 1100 | * Write every subscription known to the system... |
| 1101 | */ |
| 1102 | |
| 1103 | _cupsRWLockRead(&SubscriptionsLock); |
| 1104 | |
| 1105 | for (i = 0, scount = cupsArrayCount(Subscriptions); i < scount; i ++) |
| 1106 | { |
| 1107 | sub = (cupsd_subscription_t *)cupsArrayIndex(Subscriptions, i); |
| 1108 | |
| 1109 | cupsFilePrintf(fp, "<Subscription %d>\n", sub->id); |
| 1110 | |
| 1111 | if ((name = cupsdEventName((cupsd_eventmask_t)sub->mask)) != NULL) |
| 1112 | { |
| 1113 | /* |
| 1114 | * Simple event list... |
| 1115 | */ |
| 1116 | |
| 1117 | cupsFilePrintf(fp, "Events %s\n", name); |
| 1118 | } |
| 1119 | else |
| 1120 | { |
| 1121 | /* |
| 1122 | * Complex event list... |
| 1123 | */ |
no test coverage detected