データ構造 | |
struct | pcap_cache |
型定義 | |
typedef pcap_cache | pcap_cache_t |
関数 | |
BOOL | pcap_cache_add (const char *name, const char *comment) |
static void | pcap_cache_destroy (pcap_cache_t *cache) |
BOOL | pcap_cache_loaded (void) |
void | pcap_cache_reload (void) |
BOOL | pcap_printername_ok (const char *printername) |
void | pcap_printer_fn (void(*fn)(char *, char *)) |
変数 | |
static pcap_cache_t * | pcap_cache = NULL |
typedef struct pcap_cache pcap_cache_t |
BOOL pcap_cache_add | ( | const char * | name, | |
const char * | comment | |||
) |
参照先 pcap_cache::comment・pcap_cache::name・pcap_cache::next・pcap_cache.
参照元 aix_cache_reload()・cups_cache_reload()・iprint_cache_add_printer()・pcap_cache_reload()・sysv_cache_reload().
00076 { 00077 pcap_cache_t *p; 00078 00079 if (name == NULL || ((p = SMB_MALLOC_P(pcap_cache_t)) == NULL)) 00080 return False; 00081 00082 p->name = SMB_STRDUP(name); 00083 p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL; 00084 00085 p->next = pcap_cache; 00086 pcap_cache = p; 00087 00088 return True; 00089 }
static void pcap_cache_destroy | ( | pcap_cache_t * | cache | ) | [static] |
参照先 cache・pcap_cache::comment・pcap_cache::name・pcap_cache::next.
参照元 pcap_cache_reload().
00092 { 00093 pcap_cache_t *p, *next; 00094 00095 for (p = cache; p != NULL; p = next) { 00096 next = p->next; 00097 00098 SAFE_FREE(p->name); 00099 SAFE_FREE(p->comment); 00100 SAFE_FREE(p); 00101 } 00102 }
BOOL pcap_cache_loaded | ( | void | ) |
void pcap_cache_reload | ( | void | ) |
参照先 aix_cache_reload()・pcap_cache::comment・cups_cache_reload()・fgets_slash()・iprint_cache_reload()・name・pcap_cache・pcap_cache_add()・pcap_cache_destroy()・safe_free()・strchr_m()・strequal()・strstr_m()・sysv_cache_reload()・x_fclose()・x_fopen().
参照元 load_printers()・reload_printers().
00110 { 00111 const char *pcap_name = lp_printcapname(); 00112 BOOL pcap_reloaded = False; 00113 pcap_cache_t *tmp_cache = NULL; 00114 XFILE *pcap_file; 00115 char *pcap_line; 00116 00117 DEBUG(3, ("reloading printcap cache\n")); 00118 00119 /* only go looking if no printcap name supplied */ 00120 if (pcap_name == NULL || *pcap_name == 0) { 00121 DEBUG(0, ("No printcap file name configured!\n")); 00122 return; 00123 } 00124 00125 tmp_cache = pcap_cache; 00126 pcap_cache = NULL; 00127 00128 #ifdef HAVE_CUPS 00129 if (strequal(pcap_name, "cups")) { 00130 pcap_reloaded = cups_cache_reload(); 00131 goto done; 00132 } 00133 #endif 00134 00135 #ifdef HAVE_IPRINT 00136 if (strequal(pcap_name, "iprint")) { 00137 pcap_reloaded = iprint_cache_reload(); 00138 goto done; 00139 } 00140 #endif 00141 00142 #if defined(SYSV) || defined(HPUX) 00143 if (strequal(pcap_name, "lpstat")) { 00144 pcap_reloaded = sysv_cache_reload(); 00145 goto done; 00146 } 00147 #endif 00148 00149 #ifdef AIX 00150 if (strstr_m(pcap_name, "/qconfig") != NULL) { 00151 pcap_reloaded = aix_cache_reload(); 00152 goto done; 00153 } 00154 #endif 00155 00156 /* handle standard printcap - moved from pcap_printer_fn() */ 00157 00158 if ((pcap_file = x_fopen(pcap_name, O_RDONLY, 0)) == NULL) { 00159 DEBUG(0, ("Unable to open printcap file %s for read!\n", pcap_name)); 00160 goto done; 00161 } 00162 00163 for (; (pcap_line = fgets_slash(NULL, sizeof(pstring), pcap_file)) != NULL; safe_free(pcap_line)) { 00164 pstring name, comment; 00165 char *p, *q; 00166 00167 if (*pcap_line == '#' || *pcap_line == 0) 00168 continue; 00169 00170 /* now we have a real printer line - cut at the first : */ 00171 if ((p = strchr_m(pcap_line, ':')) != NULL) 00172 *p = 0; 00173 00174 /* 00175 * now find the most likely printer name and comment 00176 * this is pure guesswork, but it's better than nothing 00177 */ 00178 for (*name = *comment = 0, p = pcap_line; p != NULL; p = q) { 00179 BOOL has_punctuation; 00180 00181 if ((q = strchr_m(p, '|')) != NULL) 00182 *q++ = 0; 00183 00184 has_punctuation = (strchr_m(p, ' ') || 00185 strchr_m(p, '\t') || 00186 strchr_m(p, '(') || 00187 strchr_m(p, ')')); 00188 00189 if (strlen(p) > strlen(comment) && has_punctuation) { 00190 pstrcpy(comment, p); 00191 continue; 00192 } 00193 00194 if (strlen(p) <= MAXPRINTERLEN && 00195 strlen(p) > strlen(name) && !has_punctuation) { 00196 if (!*comment) 00197 pstrcpy(comment, name); 00198 00199 pstrcpy(name, p); 00200 continue; 00201 } 00202 00203 if (!strchr_m(comment, ' ') && 00204 strlen(p) > strlen(comment)) { 00205 pstrcpy(comment, p); 00206 continue; 00207 } 00208 } 00209 00210 comment[60] = 0; 00211 name[MAXPRINTERLEN] = 0; 00212 00213 if (*name && !pcap_cache_add(name, comment)) { 00214 x_fclose(pcap_file); 00215 goto done; 00216 } 00217 } 00218 00219 x_fclose(pcap_file); 00220 pcap_reloaded = True; 00221 00222 done: 00223 DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error")); 00224 00225 if (pcap_reloaded) 00226 pcap_cache_destroy(tmp_cache); 00227 else { 00228 pcap_cache_destroy(pcap_cache); 00229 pcap_cache = tmp_cache; 00230 } 00231 00232 return; 00233 }
BOOL pcap_printername_ok | ( | const char * | printername | ) |
参照先 pcap_cache::name・pcap_cache::next・pcap_cache・strequal().
参照元 add_auto_printers()・find_service()・print_job_start()・reload_printers().
00237 { 00238 pcap_cache_t *p; 00239 00240 for (p = pcap_cache; p != NULL; p = p->next) 00241 if (strequal(p->name, printername)) 00242 return True; 00243 00244 return False; 00245 }
void pcap_printer_fn | ( | void(*)(char *, char *) | fn | ) |
参照先 pcap_cache::comment・fn・pcap_cache::name・pcap_cache::next・pcap_cache.
参照元 load_printers().
00256 { 00257 pcap_cache_t *p; 00258 00259 for (p = pcap_cache; p != NULL; p = p->next) 00260 fn(p->name, p->comment); 00261 00262 return; 00263 }
pcap_cache_t* pcap_cache = NULL [static] |