関数 | |
tdb_print_db * | get_print_db_byname (const char *printername) |
void | release_print_db (struct tdb_print_db *pdb) |
void | close_all_print_db (void) |
TDB_DATA | get_printer_notify_pid_list (TDB_CONTEXT *tdb, const char *printer_name, BOOL cleanlist) |
変数 | |
static struct tdb_print_db * | print_db_head |
struct tdb_print_db* get_print_db_byname | ( | const char * | printername | ) |
printing_db.c の 33 行で定義されています。
参照先 tdb_print_db::next・num_open・print_db_head・tdb_print_db::printer_name・tdb_print_db::ref_count・strequal()・tdb_print_db::tdb.
参照元 get_queue_status()・get_updating_pid()・pjob_delete()・pjob_store()・print_backend_init()・print_cache_expired()・print_cache_flush()・print_job_delete1()・print_job_exists()・print_job_find()・print_job_start()・print_notify_deregister_pid()・print_notify_pid_list()・print_notify_register_pid()・print_queue_status()・print_queue_update()・print_queue_update_internal()・print_queue_update_with_lock()・remove_from_jobs_changed()・set_updating_pid()・sysjob_to_jobid().
00034 { 00035 struct tdb_print_db *p = NULL, *last_entry = NULL; 00036 int num_open = 0; 00037 pstring printdb_path; 00038 BOOL done_become_root = False; 00039 00040 SMB_ASSERT(printername != NULL); 00041 00042 for (p = print_db_head, last_entry = print_db_head; p; p = p->next) { 00043 /* Ensure the list terminates... JRA. */ 00044 SMB_ASSERT(p->next != print_db_head); 00045 00046 if (p->tdb && strequal(p->printer_name, printername)) { 00047 DLIST_PROMOTE(print_db_head, p); 00048 p->ref_count++; 00049 return p; 00050 } 00051 num_open++; 00052 last_entry = p; 00053 } 00054 00055 /* Not found. */ 00056 if (num_open >= MAX_PRINT_DBS_OPEN) { 00057 /* Try and recycle the last entry. */ 00058 if (print_db_head && last_entry) { 00059 DLIST_PROMOTE(print_db_head, last_entry); 00060 } 00061 00062 for (p = print_db_head; p; p = p->next) { 00063 if (p->ref_count) 00064 continue; 00065 if (p->tdb) { 00066 if (tdb_close(print_db_head->tdb)) { 00067 DEBUG(0,("get_print_db: Failed to close tdb for printer %s\n", 00068 print_db_head->printer_name )); 00069 return NULL; 00070 } 00071 } 00072 p->tdb = NULL; 00073 p->ref_count = 0; 00074 memset(p->printer_name, '\0', sizeof(p->printer_name)); 00075 break; 00076 } 00077 if (p && print_db_head) { 00078 DLIST_PROMOTE(print_db_head, p); 00079 p = print_db_head; 00080 } 00081 } 00082 00083 if (!p) { 00084 /* Create one. */ 00085 p = SMB_MALLOC_P(struct tdb_print_db); 00086 if (!p) { 00087 DEBUG(0,("get_print_db: malloc fail !\n")); 00088 return NULL; 00089 } 00090 ZERO_STRUCTP(p); 00091 DLIST_ADD(print_db_head, p); 00092 } 00093 00094 pstrcpy(printdb_path, lock_path("printing/")); 00095 pstrcat(printdb_path, printername); 00096 pstrcat(printdb_path, ".tdb"); 00097 00098 if (geteuid() != 0) { 00099 become_root(); 00100 done_become_root = True; 00101 } 00102 00103 p->tdb = tdb_open_log(printdb_path, 5000, TDB_DEFAULT, O_RDWR|O_CREAT, 00104 0600); 00105 00106 if (done_become_root) 00107 unbecome_root(); 00108 00109 if (!p->tdb) { 00110 DEBUG(0,("get_print_db: Failed to open printer backend database %s.\n", 00111 printdb_path )); 00112 DLIST_REMOVE(print_db_head, p); 00113 SAFE_FREE(p); 00114 return NULL; 00115 } 00116 fstrcpy(p->printer_name, printername); 00117 p->ref_count++; 00118 return p; 00119 }
void release_print_db | ( | struct tdb_print_db * | pdb | ) |
printing_db.c の 125 行で定義されています。
参照元 get_queue_status()・get_updating_pid()・pjob_delete()・pjob_store()・print_backend_init()・print_cache_expired()・print_cache_flush()・print_job_delete1()・print_job_exists()・print_job_find()・print_job_start()・print_notify_deregister_pid()・print_notify_pid_list()・print_notify_register_pid()・print_queue_status()・print_queue_update()・print_queue_update_internal()・print_queue_update_with_lock()・remove_from_jobs_changed()・set_updating_pid()・sysjob_to_jobid().
void close_all_print_db | ( | void | ) |
printing_db.c の 135 行で定義されています。
参照先 tdb_print_db::next・print_db_head・tdb_print_db::tdb・tdb_close().
参照元 del_a_printer()・print_backend_init()・printing_end().
00136 { 00137 struct tdb_print_db *p = NULL, *next_p = NULL; 00138 00139 for (p = print_db_head; p; p = next_p) { 00140 next_p = p->next; 00141 00142 if (p->tdb) 00143 tdb_close(p->tdb); 00144 DLIST_REMOVE(print_db_head, p); 00145 ZERO_STRUCTP(p); 00146 SAFE_FREE(p); 00147 } 00148 }
TDB_DATA get_printer_notify_pid_list | ( | TDB_CONTEXT * | tdb, | |
const char * | printer_name, | |||
BOOL | cleanlist | |||
) |
printing_db.c の 156 行で定義されています。
参照先 TDB_DATA::dptr・TDB_DATA::dsize・process_exists_by_pid()・sys_getpid()・tdb・tdb_delete_bystring()・tdb_fetch_bystring().
参照元 print_notify_deregister_pid()・print_notify_pid_list()・print_notify_register_pid().
00157 { 00158 TDB_DATA data; 00159 size_t i; 00160 00161 ZERO_STRUCT(data); 00162 00163 data = tdb_fetch_bystring( tdb, NOTIFY_PID_LIST_KEY ); 00164 00165 if (!data.dptr) { 00166 ZERO_STRUCT(data); 00167 return data; 00168 } 00169 00170 if (data.dsize % 8) { 00171 DEBUG(0,("get_printer_notify_pid_list: Size of record for printer %s not a multiple of 8 !\n", printer_name )); 00172 tdb_delete_bystring(tdb, NOTIFY_PID_LIST_KEY ); 00173 SAFE_FREE(data.dptr); 00174 ZERO_STRUCT(data); 00175 return data; 00176 } 00177 00178 if (!cleanlist) 00179 return data; 00180 00181 /* 00182 * Weed out all dead entries. 00183 */ 00184 00185 for( i = 0; i < data.dsize; i += 8) { 00186 pid_t pid = (pid_t)IVAL(data.dptr, i); 00187 00188 if (pid == sys_getpid()) 00189 continue; 00190 00191 /* Entry is dead if process doesn't exist or refcount is zero. */ 00192 00193 while ((i < data.dsize) && ((IVAL(data.dptr, i + 4) == 0) || !process_exists_by_pid(pid))) { 00194 00195 /* Refcount == zero is a logic error and should never happen. */ 00196 if (IVAL(data.dptr, i + 4) == 0) { 00197 DEBUG(0,("get_printer_notify_pid_list: Refcount == 0 for pid = %u printer %s !\n", 00198 (unsigned int)pid, printer_name )); 00199 } 00200 00201 if (data.dsize - i > 8) 00202 memmove( &data.dptr[i], &data.dptr[i+8], data.dsize - i - 8); 00203 data.dsize -= 8; 00204 } 00205 } 00206 00207 return data; 00208 }
struct tdb_print_db* print_db_head [static] |