Changeset 988 for vendor/current/source3/printing/pcap.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/printing/pcap.c
r740 r988 84 84 } 85 85 86 bool pcap_cache_add(const char *name, const char *comment, const char *location) 87 { 86 bool pcap_cache_loaded(time_t *_last_change) 87 { 88 NTSTATUS status; 89 time_t last; 90 91 status = printer_list_get_last_refresh(&last); 92 if (!NT_STATUS_IS_OK(status)) { 93 return false; 94 } 95 if (_last_change != NULL) { 96 *_last_change = last; 97 } 98 return true; 99 } 100 101 bool pcap_cache_replace(const struct pcap_cache *pcache) 102 { 103 const struct pcap_cache *p; 88 104 NTSTATUS status; 89 105 time_t t = time_mono(NULL); 90 106 91 status = printer_list_set_printer(talloc_tos(), name, comment, location, t);92 return NT_STATUS_IS_OK(status);93 }94 95 bool pcap_cache_loaded(void)96 {97 NTSTATUS status;98 time_t last;99 100 status = printer_list_get_last_refresh(&last);101 return NT_STATUS_IS_OK(status);102 }103 104 bool pcap_cache_replace(const struct pcap_cache *pcache)105 {106 const struct pcap_cache *p;107 NTSTATUS status;108 109 107 status = printer_list_mark_reload(); 110 108 if (!NT_STATUS_IS_OK(status)) { … … 114 112 115 113 for (p = pcache; p; p = p->next) { 116 pcap_cache_add(p->name, p->comment, p->location); 114 status = printer_list_set_printer(talloc_tos(), p->name, 115 p->comment, p->location, t); 116 if (!NT_STATUS_IS_OK(status)) { 117 return false; 118 } 117 119 } 118 120 … … 133 135 const char *pcap_name = lp_printcapname(); 134 136 bool pcap_reloaded = False; 135 NTSTATUS status;136 137 bool post_cache_fill_fn_handled = false; 138 struct pcap_cache *pcache = NULL; 137 139 138 140 DEBUG(3, ("reloading printcap cache\n")); … … 141 143 if (pcap_name == NULL || *pcap_name == 0) { 142 144 DEBUG(0, ("No printcap file name configured!\n")); 143 return;144 }145 146 status = printer_list_mark_reload();147 if (!NT_STATUS_IS_OK(status)) {148 DEBUG(0, ("Failed to mark printer list for reload!\n"));149 145 return; 150 146 } … … 165 161 #ifdef HAVE_IPRINT 166 162 if (strequal(pcap_name, "iprint")) { 167 pcap_reloaded = iprint_cache_reload( );163 pcap_reloaded = iprint_cache_reload(&pcache); 168 164 goto done; 169 165 } … … 172 168 #if defined(SYSV) || defined(HPUX) 173 169 if (strequal(pcap_name, "lpstat")) { 174 pcap_reloaded = sysv_cache_reload( );170 pcap_reloaded = sysv_cache_reload(&pcache); 175 171 goto done; 176 172 } … … 179 175 #ifdef AIX 180 176 if (strstr_m(pcap_name, "/qconfig") != NULL) { 181 pcap_reloaded = aix_cache_reload(); 182 goto done; 183 } 184 #endif 185 186 pcap_reloaded = std_pcap_cache_reload(pcap_name); 187 177 pcap_reloaded = aix_cache_reload(&pcache); 178 goto done; 179 } 180 #endif 181 182 pcap_reloaded = std_pcap_cache_reload(pcap_name, &pcache); 183 184 /* Fix silly compiler warning about done not being used if none of the above 185 * ifdefs are used */ 186 #if defined(HAVE_CUPS) || defined(HAVE_IPRINT) || defined(SYSV) || defined(HPUX) || defined(AIX) 188 187 done: 188 #endif 189 189 DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error")); 190 190 … … 192 192 /* cleanup old entries only if the operation was successful, 193 193 * otherwise keep around the old entries until we can 194 * successful y reaload */195 status = printer_list_clean_old(); 196 if (! NT_STATUS_IS_OK(status)) {197 DEBUG(0, ("Failed to cleanupprinter list!\n"));194 * successfully reload */ 195 196 if (!pcap_cache_replace(pcache)) { 197 DEBUG(0, ("Failed to replace printer list!\n")); 198 198 } 199 199 200 if (post_cache_fill_fn != NULL) { 200 201 post_cache_fill_fn(ev, msg_ctx); 201 202 } 202 203 } 204 pcap_cache_destroy_specific(&pcache); 203 205 204 206 return; … … 230 232 } 231 233 232 void pcap_printer_ fn(void (*fn)(const char *, const char *, const char *, void *), void *pdata)233 { 234 NTSTATUS status; 235 236 status = printer_list_r un_fn(fn, pdata);234 void pcap_printer_read_fn(void (*fn)(const char *, const char *, const char *, void *), void *pdata) 235 { 236 NTSTATUS status; 237 238 status = printer_list_read_run_fn(fn, pdata); 237 239 if (!NT_STATUS_IS_OK(status)) { 238 240 DEBUG(3, ("Failed to run fn for all printers!\n"));
Note:
See TracChangeset
for help on using the changeset viewer.