summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-01-09 04:13:30 +0000
committerJeremy Allison <jra@samba.org>2002-01-09 04:13:30 +0000
commit91536cc901088232074ad8dd7ae16e0f6026f25e (patch)
treef0d2539b3503ed58ea6830d2b85c424849b98bf5 /source3/printing
parent0a3f6b9b489fda547650083252906a881740af2b (diff)
downloadsamba-91536cc901088232074ad8dd7ae16e0f6026f25e.tar.gz
samba-91536cc901088232074ad8dd7ae16e0f6026f25e.tar.bz2
samba-91536cc901088232074ad8dd7ae16e0f6026f25e.zip
Fixed all uses of tdb_fetch/store/_int to use explicit int32 little endian
in tdb's. All except winbindd_idmap.... Hmmmmmm. Jeremy. (This used to be commit ec71f1732b6b27bd2d65b250a6f3720a235dc38d)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c28
-rw-r--r--source3/printing/printing.c25
2 files changed, 33 insertions, 20 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index b49767eac7..6c0e4c83e7 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -262,15 +262,27 @@ BOOL nt_printing_init(void)
/* handle a Samba upgrade */
tdb_lock_bystring(tdb_drivers, vstring);
- if (tdb_fetch_int(tdb_drivers, vstring) != NTDRIVERS_DATABASE_VERSION) {
-
- if (tdb_fetch_int(tdb_drivers, vstring) == NTDRIVERS_DATABASE_VERSION_1) {
- if (!upgrade_to_version_2())
- return False;
- } else
- tdb_traverse(tdb_drivers, tdb_traverse_delete_fn, NULL);
+ {
+ int32 vers_id;
+
+ /* Cope with byte-reversed older versions of the db. */
+ vers_id = tdb_fetch_int32(tdb_drivers, vstring);
+ if ((vers_id != NTDRIVERS_DATABASE_VERSION) && (IREV(vers_id) == NTDRIVERS_DATABASE_VERSION)) {
+ /* Written on a bigendian machine with old fetch_int code. Save as le. */
+ tdb_store_int32(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION);
+ vers_id = NTDRIVERS_DATABASE_VERSION;
+ }
+
+ if (vers_id != NTDRIVERS_DATABASE_VERSION) {
- tdb_store_int(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION);
+ if ((vers_id == NTDRIVERS_DATABASE_VERSION_1) || (IREV(vers_id) == NTDRIVERS_DATABASE_VERSION_1)) {
+ if (!upgrade_to_version_2())
+ return False;
+ } else
+ tdb_traverse(tdb_drivers, tdb_traverse_delete_fn, NULL);
+
+ tdb_store_int32(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION);
+ }
}
tdb_unlock_bystring(tdb_drivers, vstring);
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index ab966bd9f2..08115cdb79 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -45,9 +45,10 @@ static pid_t local_pid;
static int get_queue_status(int, print_status_struct *);
/****************************************************************************
-initialise the printing backend. Called once at startup.
-Does not survive a fork
+ Initialise the printing backend. Called once at startup.
+ Does not survive a fork
****************************************************************************/
+
BOOL print_backend_init(void)
{
char *sversion = "INFO/version";
@@ -63,9 +64,9 @@ BOOL print_backend_init(void)
/* handle a Samba upgrade */
tdb_lock_bystring(tdb, sversion);
- if (tdb_fetch_int(tdb, sversion) != PRINT_DATABASE_VERSION) {
+ if (tdb_fetch_int32(tdb, sversion) != PRINT_DATABASE_VERSION) {
tdb_traverse(tdb, tdb_traverse_delete_fn, NULL);
- tdb_store_int(tdb, sversion, PRINT_DATABASE_VERSION);
+ tdb_store_int32(tdb, sversion, PRINT_DATABASE_VERSION);
}
tdb_unlock_bystring(tdb, sversion);
@@ -263,7 +264,7 @@ static void print_cache_flush(int snum)
{
fstring key;
slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
- tdb_store_int(tdb, key, -1);
+ tdb_store_int32(tdb, key, -1);
}
/****************************************************************************
@@ -385,7 +386,7 @@ static void print_queue_update_background(int snum)
*/
slprintf(cachestr, sizeof(cachestr)-1, "CACHE/%s", printer_name);
- tdb_store_int(tdb, cachestr, (int)time(NULL));
+ tdb_store_int32(tdb, cachestr, (int)time(NULL));
/* get the current queue using the appropriate interface */
ZERO_STRUCT(status);
@@ -441,7 +442,7 @@ static void print_queue_update_background(int snum)
safe_free(tstruct.queue);
- tdb_store_int(tdb, "INFO/total_jobs", tstruct.total_jobs);
+ tdb_store_int32(tdb, "INFO/total_jobs", tstruct.total_jobs);
/*
* Get the old print status. We will use this to compare the
@@ -471,7 +472,7 @@ static void print_queue_update_background(int snum)
*/
slprintf(keystr, sizeof(keystr)-1, "CACHE/%s", printer_name);
- tdb_store_int(tdb, keystr, (int)time(NULL));
+ tdb_store_int32(tdb, keystr, (int)time(NULL));
/* Delete our pid from the db. */
set_updating_pid(printer_name, True);
@@ -812,7 +813,7 @@ static BOOL print_cache_expired(int snum)
time_t t2, t = time(NULL);
slprintf(key, sizeof(key)-1, "CACHE/%s", lp_servicename(snum));
- t2 = tdb_fetch_int(tdb, key);
+ t2 = tdb_fetch_int32(tdb, key);
if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
DEBUG(3, ("print cache expired for queue %s \
(last_cache = %d, time now = %d, qcachetime = %d)\n", lp_servicename(snum),
@@ -875,7 +876,7 @@ static int get_total_jobs(int snum)
/* make sure the database is up to date */
if (print_cache_expired(snum)) print_queue_update(snum);
- total_jobs = tdb_fetch_int(tdb, "INFO/total_jobs");
+ total_jobs = tdb_fetch_int32(tdb, "INFO/total_jobs");
if (total_jobs >0)
return total_jobs;
else
@@ -966,7 +967,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
/* lock the database */
tdb_lock_bystring(tdb, "INFO/nextjob");
- next_jobid = tdb_fetch_int(tdb, "INFO/nextjob");
+ next_jobid = tdb_fetch_int32(tdb, "INFO/nextjob");
if (next_jobid == -1)
next_jobid = 1;
@@ -981,7 +982,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
goto fail;
}
- tdb_store_int(tdb, "INFO/nextjob", jobid);
+ tdb_store_int32(tdb, "INFO/nextjob", jobid);
/* we have a job entry - now create the spool file */
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%.6d.XXXXXX",