summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/printing/printing.c45
1 files changed, 17 insertions, 28 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 5483005e1b..b45a31a1c7 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -907,7 +907,7 @@ static int printjob_comp(print_queue_struct *j1, print_queue_struct *j2)
static void store_queue_struct(struct tdb_print_db *pdb, struct traverse_struct *pts)
{
- TDB_DATA data, key;
+ TDB_DATA data;
int max_reported_jobs = lp_max_reported_jobs(pts->snum);
print_queue_struct *queue = pts->queue;
size_t len;
@@ -951,22 +951,19 @@ static void store_queue_struct(struct tdb_print_db *pdb, struct traverse_struct
queue[i].fs_file);
}
- key.dptr = "INFO/linear_queue_array";
- key.dsize = strlen(key.dptr);
- tdb_store(pdb->tdb, key, data, TDB_REPLACE);
+ tdb_store(pdb->tdb, string_tdb_data("INFO/linear_queue_array"), data,
+ TDB_REPLACE);
SAFE_FREE(data.dptr);
return;
}
static TDB_DATA get_jobs_changed_data(struct tdb_print_db *pdb)
{
- TDB_DATA data, key;
+ TDB_DATA data;
- key.dptr = "INFO/jobs_changed";
- key.dsize = strlen(key.dptr);
ZERO_STRUCT(data);
- data = tdb_fetch(pdb->tdb, key);
+ data = tdb_fetch(pdb->tdb, string_tdb_data("INFO/jobs_changed"));
if (data.dptr == NULL || data.dsize == 0 || (data.dsize % 4 != 0)) {
SAFE_FREE(data.dptr);
ZERO_STRUCT(data);
@@ -1736,11 +1733,11 @@ static BOOL remove_from_jobs_changed(const char* sharename, uint32 jobid)
BOOL ret = False;
BOOL gotlock = False;
- key.dptr = "INFO/jobs_changed";
- key.dsize = strlen(key.dptr);
ZERO_STRUCT(data);
- if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) == -1)
+ if (tdb_chainlock_with_timeout(pdb->tdb,
+ string_tdb_data("INFO/jobs_changed"),
+ 5) == -1)
goto out;
gotlock = True;
@@ -2057,7 +2054,7 @@ int print_job_write(int snum, uint32 jobid, const char *buf, int size)
static int get_queue_status(const char* sharename, print_status_struct *status)
{
fstring keystr;
- TDB_DATA data, key;
+ TDB_DATA data;
struct tdb_print_db *pdb = get_print_db_byname(sharename);
int len;
@@ -2066,10 +2063,8 @@ static int get_queue_status(const char* sharename, print_status_struct *status)
if (status) {
ZERO_STRUCTP(status);
- slprintf(keystr, sizeof(keystr)-1, "STATUS/%s", sharename);
- key.dptr = keystr;
- key.dsize = strlen(keystr);
- data = tdb_fetch(pdb->tdb, key);
+ fstr_sprintf(keystr, "STATUS/%s", sharename);
+ data = tdb_fetch(pdb->tdb, string_tdb_data(keystr));
if (data.dptr) {
if (data.dsize == sizeof(print_status_struct))
/* this memcpy is ok since the status struct was
@@ -2179,18 +2174,17 @@ static BOOL allocate_print_jobid(struct tdb_print_db *pdb, int snum, const char
static BOOL add_to_jobs_changed(struct tdb_print_db *pdb, uint32 jobid)
{
- TDB_DATA data, key;
+ TDB_DATA data;
uint32 store_jobid;
- key.dptr = "INFO/jobs_changed";
- key.dsize = strlen(key.dptr);
SIVAL(&store_jobid, 0, jobid);
data.dptr = (char *)&store_jobid;
data.dsize = 4;
DEBUG(10,("add_to_jobs_changed: Added jobid %u\n", (unsigned int)jobid ));
- return (tdb_append(pdb->tdb, key, data) == 0);
+ return (tdb_append(pdb->tdb, string_tdb_data("INFO/jobs_changed"),
+ data) == 0);
}
/***************************************************************************
@@ -2429,7 +2423,7 @@ fail:
static BOOL get_stored_queue_info(struct tdb_print_db *pdb, int snum, int *pcount, print_queue_struct **ppqueue)
{
- TDB_DATA data, key, cgdata;
+ TDB_DATA data, cgdata;
print_queue_struct *queue = NULL;
uint32 qcount = 0;
uint32 extra_count = 0;
@@ -2449,20 +2443,15 @@ static BOOL get_stored_queue_info(struct tdb_print_db *pdb, int snum, int *pcoun
ZERO_STRUCT(data);
ZERO_STRUCT(cgdata);
- key.dptr = "INFO/linear_queue_array";
- key.dsize = strlen(key.dptr);
/* Get the stored queue data. */
- data = tdb_fetch(pdb->tdb, key);
+ data = tdb_fetch(pdb->tdb, string_tdb_data("INFO/linear_queue_array"));
if (data.dptr && data.dsize >= sizeof(qcount))
len += tdb_unpack(data.dptr + len, data.dsize - len, "d", &qcount);
/* Get the changed jobs list. */
- key.dptr = "INFO/jobs_changed";
- key.dsize = strlen(key.dptr);
-
- cgdata = tdb_fetch(pdb->tdb, key);
+ cgdata = tdb_fetch(pdb->tdb, string_tdb_data("INFO/jobs_changed"));
if (cgdata.dptr != NULL && (cgdata.dsize % 4 == 0))
extra_count = cgdata.dsize/4;