Changeset 228 for branches/samba-3.2.x/source/printing/pcap.c
- Timestamp:
- May 26, 2009, 9:44:50 AM (17 years ago)
- File:
-
- 1 edited
-
branches/samba-3.2.x/source/printing/pcap.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/printing/pcap.c
r133 r228 64 64 65 65 66 typedefstruct pcap_cache {66 struct pcap_cache { 67 67 char *name; 68 68 char *comment; 69 69 struct pcap_cache *next; 70 } pcap_cache_t; 71 72 static pcap_cache_t *pcap_cache = NULL; 73 74 bool pcap_cache_add(const char *name, const char *comment) 75 { 76 pcap_cache_t *p; 77 78 if (name == NULL || ((p = SMB_MALLOC_P(pcap_cache_t)) == NULL)) 79 return False; 70 }; 71 72 /* The systemwide printcap cache. */ 73 static struct pcap_cache *pcap_cache = NULL; 74 75 bool pcap_cache_add_specific(struct pcap_cache **ppcache, const char *name, const char *comment) 76 { 77 struct pcap_cache *p; 78 79 if (name == NULL || ((p = SMB_MALLOC_P(struct pcap_cache)) == NULL)) 80 return false; 80 81 81 82 p->name = SMB_STRDUP(name); 82 83 p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL; 83 84 84 p->next = pcap_cache; 85 pcap_cache = p; 86 87 return True; 88 } 89 90 static void pcap_cache_destroy(pcap_cache_t *cache) 91 { 92 pcap_cache_t *p, *next; 93 94 for (p = cache; p != NULL; p = next) { 85 DEBUG(11,("pcap_cache_add_specific: Adding name %s info %s\n", 86 p->name, p->comment ? p->comment : "")); 87 88 p->next = *ppcache; 89 *ppcache = p; 90 91 return true; 92 } 93 94 void pcap_cache_destroy_specific(struct pcap_cache **pp_cache) 95 { 96 struct pcap_cache *p, *next; 97 98 for (p = *pp_cache; p != NULL; p = next) { 95 99 next = p->next; 96 100 … … 99 103 SAFE_FREE(p); 100 104 } 105 106 107 108 109 110 101 111 } 102 112 … … 104 114 { 105 115 return (pcap_cache != NULL); 116 117 118 119 120 121 122 123 124 125 106 126 } 107 127 … … 110 130 const char *pcap_name = lp_printcapname(); 111 131 bool pcap_reloaded = False; 112 pcap_cache_t*tmp_cache = NULL;132 *tmp_cache = NULL; 113 133 XFILE *pcap_file; 114 134 char *pcap_line; … … 224 244 225 245 if (pcap_reloaded) 226 pcap_cache_destroy (tmp_cache);246 pcap_cache_destroytmp_cache); 227 247 else { 228 pcap_cache_destroy (pcap_cache);248 pcap_cache_destroypcap_cache); 229 249 pcap_cache = tmp_cache; 230 250 } … … 236 256 bool pcap_printername_ok(const char *printername) 237 257 { 238 pcap_cache_t*p;258 *p; 239 259 240 260 for (p = pcap_cache; p != NULL; p = p->next) … … 246 266 247 267 /*************************************************************************** 248 run a function on each printer name in the printcap file. The function is 249 passed the primary name and the comment (if possible). Note the fn() takes 250 strings in DOS codepage. This means the xxx_printer_fn() calls must be fixed 251 to return DOS codepage. FIXME !! JRA. 252 253 XXX: I'm not sure if this comment still applies.. Anyone? -Rob 268 run a function on each printer name in the printcap file. 254 269 ***************************************************************************/ 255 void pcap_printer_fn(void (*fn)(char *, char *)) 256 { 257 pcap_cache_t *p; 258 259 for (p = pcap_cache; p != NULL; p = p->next) 260 fn(p->name, p->comment); 270 271 void pcap_printer_fn_specific(const struct pcap_cache *pc, 272 void (*fn)(const char *, const char *, void *), 273 void *pdata) 274 { 275 const struct pcap_cache *p; 276 277 for (p = pc; p != NULL; p = p->next) 278 fn(p->name, p->comment, pdata); 261 279 262 280 return; 263 281 } 282 283 284 285 286
Note:
See TracChangeset
for help on using the changeset viewer.
