1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

tdb: Fix blank line endings

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Volker Lendecke 2013-03-18 14:39:04 +01:00 committed by Stefan Metzmacher
parent a92c08e18b
commit c8c0bf7480
5 changed files with 45 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* /*
Unix SMB/CIFS implementation. Unix SMB/CIFS implementation.
low level tdb backup and restore utility low level tdb backup and restore utility
Copyright (C) Andrew Tridgell 2002 Copyright (C) Andrew Tridgell 2002
@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -61,7 +61,7 @@ static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const c
static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...) static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const char *format, ...)
{ {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vfprintf(stdout, format, ap); vfprintf(stdout, format, ap);
va_end(ap); va_end(ap);
@ -122,7 +122,7 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
} }
/* open the old tdb */ /* open the old tdb */
tdb = tdb_open_ex(old_name, 0, 0, tdb = tdb_open_ex(old_name, 0, 0,
O_RDWR, 0, &log_ctx, NULL); O_RDWR, 0, &log_ctx, NULL);
if (!tdb) { if (!tdb) {
printf("Failed to open %s\n", old_name); printf("Failed to open %s\n", old_name);
@ -132,10 +132,10 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
/* create the new tdb */ /* create the new tdb */
unlink(tmp_name); unlink(tmp_name);
tdb_new = tdb_open_ex(tmp_name, tdb_new = tdb_open_ex(tmp_name,
hash_size ? hash_size : tdb_hash_size(tdb), hash_size ? hash_size : tdb_hash_size(tdb),
TDB_DEFAULT, TDB_DEFAULT,
O_RDWR|O_CREAT|O_EXCL, st.st_mode & 0777, O_RDWR|O_CREAT|O_EXCL, st.st_mode & 0777,
&log_ctx, NULL); &log_ctx, NULL);
if (!tdb_new) { if (!tdb_new) {
perror(tmp_name); perror(tmp_name);
@ -192,9 +192,9 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
/* close the new tdb and re-open read-only */ /* close the new tdb and re-open read-only */
tdb_close(tdb_new); tdb_close(tdb_new);
tdb_new = tdb_open_ex(tmp_name, tdb_new = tdb_open_ex(tmp_name,
0, 0,
TDB_DEFAULT, TDB_DEFAULT,
O_RDONLY, 0, O_RDONLY, 0,
&log_ctx, NULL); &log_ctx, NULL);
if (!tdb_new) { if (!tdb_new) {
@ -204,7 +204,7 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
free(tmp_name); free(tmp_name);
return 1; return 1;
} }
/* traverse the new tdb to confirm */ /* traverse the new tdb to confirm */
count2 = tdb_traverse(tdb_new, test_fn, NULL); count2 = tdb_traverse(tdb_new, test_fn, NULL);
if (count2 != count1) { if (count2 != count1) {
@ -237,7 +237,7 @@ static int verify_tdb(const char *fname, const char *bak_name)
int count = -1; int count = -1;
/* open the tdb */ /* open the tdb */
tdb = tdb_open_ex(fname, 0, 0, tdb = tdb_open_ex(fname, 0, 0,
O_RDONLY, 0, &log_ctx, NULL); O_RDONLY, 0, &log_ctx, NULL);
/* traverse the tdb, then close it */ /* traverse the tdb, then close it */
@ -280,7 +280,6 @@ static void usage(void)
printf(" -v verify mode (restore if corrupt)\n"); printf(" -v verify mode (restore if corrupt)\n");
printf(" -n hashsize set the new hash size for the backup\n"); printf(" -n hashsize set the new hash size for the backup\n");
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {

View File

@ -1,4 +1,4 @@
/* /*
Unix SMB/CIFS implementation. Unix SMB/CIFS implementation.
simple tdb dump util simple tdb dump util
Copyright (C) Andrew Tridgell 2001 Copyright (C) Andrew Tridgell 2001
@ -7,12 +7,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -99,7 +99,7 @@ static int dump_tdb(const char *fname, const char *keyname, bool emergency)
TDB_CONTEXT *tdb; TDB_CONTEXT *tdb;
TDB_DATA key, value; TDB_DATA key, value;
struct tdb_logging_context logfn = { log_stderr }; struct tdb_logging_context logfn = { log_stderr };
tdb = tdb_open_ex(fname, 0, 0, O_RDONLY, 0, &logfn, NULL); tdb = tdb_open_ex(fname, 0, 0, O_RDONLY, 0, &logfn, NULL);
if (!tdb) { if (!tdb) {
printf("Failed to open %s\n", fname); printf("Failed to open %s\n", fname);

View File

@ -24,7 +24,7 @@ static void _start_timer(void)
static double _end_timer(void) static double _end_timer(void)
{ {
gettimeofday(&tp2,NULL); gettimeofday(&tp2,NULL);
return((tp2.tv_sec - tp1.tv_sec) + return((tp2.tv_sec - tp1.tv_sec) +
(tp2.tv_usec - tp1.tv_usec)*1.0e-6); (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
} }
@ -40,7 +40,7 @@ static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...)
static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...) static void tdb_log(struct tdb_context *tdb, int level, const char *format, ...)
{ {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vfprintf(stdout, format, ap); vfprintf(stdout, format, ap);
va_end(ap); va_end(ap);
@ -189,15 +189,15 @@ static void merge_test(void)
char keys[5][2]; char keys[5][2];
char tdata[] = "test"; char tdata[] = "test";
TDB_DATA key, data; TDB_DATA key, data;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
snprintf(keys[i],2, "%d", i); snprintf(keys[i],2, "%d", i);
key.dptr = keys[i]; key.dptr = keys[i];
key.dsize = 2; key.dsize = 2;
data.dptr = tdata; data.dptr = tdata;
data.dsize = 4; data.dsize = 4;
if (tdb_store(db, key, data, TDB_REPLACE) != 0) { if (tdb_store(db, key, data, TDB_REPLACE) != 0) {
fatal("tdb_store failed"); fatal("tdb_store failed");
} }
@ -248,7 +248,7 @@ static char *test_path(const char *filename)
db = tdb_open(test_tdb, 0, TDB_CLEAR_IF_FIRST, db = tdb_open(test_tdb, 0, TDB_CLEAR_IF_FIRST,
O_RDWR | O_CREAT | O_TRUNC, 0600); O_RDWR | O_CREAT | O_TRUNC, 0600);
gdbm = gdbm_open(test_gdbm, 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST, gdbm = gdbm_open(test_gdbm, 512, GDBM_WRITER|GDBM_NEWDB|GDBM_FAST,
0600, NULL); 0600, NULL);
if (!db || !gdbm) { if (!db || !gdbm) {

View File

@ -1,4 +1,4 @@
/* /*
Unix SMB/CIFS implementation. Unix SMB/CIFS implementation.
Samba database functions Samba database functions
Copyright (C) Andrew Tridgell 1999-2000 Copyright (C) Andrew Tridgell 1999-2000
@ -10,12 +10,12 @@
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
@ -113,7 +113,7 @@ static void _start_timer(void)
static double _end_timer(void) static double _end_timer(void)
{ {
gettimeofday(&tp2,NULL); gettimeofday(&tp2,NULL);
return((tp2.tv_sec - tp1.tv_sec) + return((tp2.tv_sec - tp1.tv_sec) +
(tp2.tv_usec - tp1.tv_usec)*1.0e-6); (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
} }
@ -160,7 +160,7 @@ static void print_data(const char *buf,int len)
printf("%02X ",(int)((unsigned char)buf[i])); printf("%02X ",(int)((unsigned char)buf[i]));
i++; i++;
if (i%8 == 0) printf(" "); if (i%8 == 0) printf(" ");
if (i%16 == 0) { if (i%16 == 0) {
print_asc(&buf[i-16],8); printf(" "); print_asc(&buf[i-16],8); printf(" ");
print_asc(&buf[i-8],8); printf("\n"); print_asc(&buf[i-8],8); printf("\n");
if (i<len) printf("[%03X] ",i); if (i<len) printf("[%03X] ",i);
@ -168,18 +168,18 @@ static void print_data(const char *buf,int len)
} }
if (i%16) { if (i%16) {
int n; int n;
n = 16 - (i%16); n = 16 - (i%16);
printf(" "); printf(" ");
if (n>8) printf(" "); if (n>8) printf(" ");
while (n--) printf(" "); while (n--) printf(" ");
n = i%16; n = i%16;
if (n > 8) n = 8; if (n > 8) n = 8;
print_asc(&buf[i-(i%16)],n); printf(" "); print_asc(&buf[i-(i%16)],n); printf(" ");
n = (i%16) - n; n = (i%16) - n;
if (n>0) print_asc(&buf[i-n],n); if (n>0) print_asc(&buf[i-n],n);
printf("\n"); printf("\n");
} }
} }
@ -309,11 +309,11 @@ static void show_tdb(char *keyname, size_t keylen)
terror("fetch failed"); terror("fetch failed");
return; return;
} }
print_rec(tdb, key, dbuf, NULL); print_rec(tdb, key, dbuf, NULL);
free( dbuf.dptr ); free( dbuf.dptr );
return; return;
} }
@ -357,23 +357,23 @@ static void move_rec(char *keyname, size_t keylen, char* tdbname)
terror("fetch failed"); terror("fetch failed");
return; return;
} }
print_rec(tdb, key, dbuf, NULL); print_rec(tdb, key, dbuf, NULL);
dst_tdb = tdb_open(tdbname, 0, 0, O_RDWR, 0600); dst_tdb = tdb_open(tdbname, 0, 0, O_RDWR, 0600);
if ( !dst_tdb ) { if ( !dst_tdb ) {
terror("unable to open destination tdb"); terror("unable to open destination tdb");
return; return;
} }
if (tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) != 0) { if (tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) != 0) {
terror("failed to move record"); terror("failed to move record");
} }
else else
printf("record moved\n"); printf("record moved\n");
tdb_close( dst_tdb ); tdb_close( dst_tdb );
return; return;
} }
@ -520,7 +520,7 @@ static void first_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey)
{ {
TDB_DATA dbuf; TDB_DATA dbuf;
*pkey = tdb_firstkey(the_tdb); *pkey = tdb_firstkey(the_tdb);
dbuf = tdb_fetch(the_tdb, *pkey); dbuf = tdb_fetch(the_tdb, *pkey);
if (!dbuf.dptr) terror("fetch failed"); if (!dbuf.dptr) terror("fetch failed");
else { else {
@ -532,9 +532,9 @@ static void next_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey)
{ {
TDB_DATA dbuf; TDB_DATA dbuf;
*pkey = tdb_nextkey(the_tdb, *pkey); *pkey = tdb_nextkey(the_tdb, *pkey);
dbuf = tdb_fetch(the_tdb, *pkey); dbuf = tdb_fetch(the_tdb, *pkey);
if (!dbuf.dptr) if (!dbuf.dptr)
terror("fetch failed"); terror("fetch failed");
else else
print_rec(the_tdb, *pkey, dbuf, NULL); print_rec(the_tdb, *pkey, dbuf, NULL);

View File

@ -1,5 +1,5 @@
/* this tests tdb by doing lots of ops from several simultaneous /* this tests tdb by doing lots of ops from several simultaneous
writers - that stresses the locking code. writers - that stresses the locking code.
*/ */
#include "replace.h" #include "replace.h"
@ -59,7 +59,7 @@ static void tdb_log(struct tdb_context *tdb, enum tdb_debug_level level, const c
system(ptr); system(ptr);
free(ptr); free(ptr);
} }
#endif #endif
} }
static void fatal(const char *why) static void fatal(const char *why)