diff options
Diffstat (limited to 'source4/lib/util')
-rw-r--r-- | source4/lib/util/capability.c | 2 | ||||
-rw-r--r-- | source4/lib/util/data_blob.c | 26 | ||||
-rw-r--r-- | source4/lib/util/debug.c | 23 | ||||
-rw-r--r-- | source4/lib/util/fault.c | 8 | ||||
-rw-r--r-- | source4/lib/util/fsusage.c | 2 | ||||
-rw-r--r-- | source4/lib/util/genrand.c | 14 | ||||
-rw-r--r-- | source4/lib/util/idtree.c | 24 | ||||
-rw-r--r-- | source4/lib/util/module.c | 13 | ||||
-rw-r--r-- | source4/lib/util/mutex.c | 2 | ||||
-rw-r--r-- | source4/lib/util/pidfile.c | 2 | ||||
-rw-r--r-- | source4/lib/util/time.c | 68 | ||||
-rw-r--r-- | source4/lib/util/util.c | 62 | ||||
-rw-r--r-- | source4/lib/util/util_file.c | 21 | ||||
-rw-r--r-- | source4/lib/util/util_sock.c | 2 | ||||
-rw-r--r-- | source4/lib/util/util_str.c | 86 | ||||
-rw-r--r-- | source4/lib/util/util_strlist.c | 22 |
16 files changed, 192 insertions, 185 deletions
diff --git a/source4/lib/util/capability.c b/source4/lib/util/capability.c index ae08fab533..0062bb5cd6 100644 --- a/source4/lib/util/capability.c +++ b/source4/lib/util/capability.c @@ -107,7 +107,7 @@ static BOOL set_inherited_process_capability( uint32_t cap_flag, BOOL enable ) Gain the oplock capability from the kernel if possible. ****************************************************************************/ -void oplock_set_capability(BOOL this_process, BOOL inherit) +_PUBLIC_ void oplock_set_capability(BOOL this_process, BOOL inherit) { #if HAVE_KERNEL_OPLOCKS_IRIX set_process_capability(KERNEL_OPLOCK_CAPABILITY,this_process); diff --git a/source4/lib/util/data_blob.c b/source4/lib/util/data_blob.c index dfcfaa41ea..c1513a1d78 100644 --- a/source4/lib/util/data_blob.c +++ b/source4/lib/util/data_blob.c @@ -30,7 +30,7 @@ construct a data blob, must be freed with data_blob_free() you can pass NULL for p and get a blank data blob **/ -DATA_BLOB data_blob_named(const void *p, size_t length, const char *name) +_PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *name) { DATA_BLOB ret; @@ -56,7 +56,7 @@ DATA_BLOB data_blob_named(const void *p, size_t length, const char *name) /** construct a data blob, using supplied TALLOC_CTX **/ -DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name) +_PUBLIC_ DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name) { DATA_BLOB ret = data_blob_named(p, length, name); @@ -71,7 +71,7 @@ DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t leng reference a data blob, to the supplied TALLOC_CTX. Returns a NULL DATA_BLOB on failure **/ -DATA_BLOB data_blob_talloc_reference(TALLOC_CTX *mem_ctx, DATA_BLOB *blob) +_PUBLIC_ DATA_BLOB data_blob_talloc_reference(TALLOC_CTX *mem_ctx, DATA_BLOB *blob) { DATA_BLOB ret = *blob; @@ -88,7 +88,7 @@ DATA_BLOB data_blob_talloc_reference(TALLOC_CTX *mem_ctx, DATA_BLOB *blob) use this sparingly as it initialises data - better to initialise yourself if you want specific data in the blob **/ -DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length) +_PUBLIC_ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length) { DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, length); data_blob_clear(&blob); @@ -98,7 +98,7 @@ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length) /** free a data blob **/ -void data_blob_free(DATA_BLOB *d) +_PUBLIC_ void data_blob_free(DATA_BLOB *d) { if (d) { talloc_free(d->data); @@ -110,7 +110,7 @@ void data_blob_free(DATA_BLOB *d) /** clear a DATA_BLOB's contents **/ -void data_blob_clear(DATA_BLOB *d) +_PUBLIC_ void data_blob_clear(DATA_BLOB *d) { if (d->data) { memset(d->data, 0, d->length); @@ -120,7 +120,7 @@ void data_blob_clear(DATA_BLOB *d) /** free a data blob and clear its contents **/ -void data_blob_clear_free(DATA_BLOB *d) +_PUBLIC_ void data_blob_clear_free(DATA_BLOB *d) { data_blob_clear(d); data_blob_free(d); @@ -130,7 +130,7 @@ void data_blob_clear_free(DATA_BLOB *d) /** check if two data blobs are equal **/ -BOOL data_blob_equal(const DATA_BLOB *d1, const DATA_BLOB *d2) +_PUBLIC_ BOOL data_blob_equal(const DATA_BLOB *d1, const DATA_BLOB *d2) { if (d1->length != d2->length) { return False; @@ -150,7 +150,7 @@ BOOL data_blob_equal(const DATA_BLOB *d1, const DATA_BLOB *d2) /** print the data_blob as hex string **/ -char *data_blob_hex_string(TALLOC_CTX *mem_ctx, DATA_BLOB *blob) +_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, DATA_BLOB *blob) { int i; char *hex_string; @@ -170,7 +170,7 @@ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, DATA_BLOB *blob) useful for constructing data blobs in test suites, while avoiding const warnings **/ -DATA_BLOB data_blob_string_const(const char *str) +_PUBLIC_ DATA_BLOB data_blob_string_const(const char *str) { DATA_BLOB blob; blob.data = discard_const(str); @@ -178,7 +178,7 @@ DATA_BLOB data_blob_string_const(const char *str) return blob; } -DATA_BLOB data_blob_const(const void *p, size_t length) +_PUBLIC_ DATA_BLOB data_blob_const(const void *p, size_t length) { DATA_BLOB blob; blob.data = discard_const(p); @@ -190,7 +190,7 @@ DATA_BLOB data_blob_const(const void *p, size_t length) /** realloc a data_blob **/ -NTSTATUS data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length) +_PUBLIC_ NTSTATUS data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length) { blob->data = talloc_realloc_size(mem_ctx, blob->data, length); NT_STATUS_HAVE_NO_MEMORY(blob->data); @@ -201,7 +201,7 @@ NTSTATUS data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length) /** append some data to a data blob **/ -NTSTATUS data_blob_append(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, +_PUBLIC_ NTSTATUS data_blob_append(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const void *p, size_t length) { blob->data = talloc_realloc_size(mem_ctx, blob->data, diff --git a/source4/lib/util/debug.c b/source4/lib/util/debug.c index 4cf7c21641..1c5bb25753 100644 --- a/source4/lib/util/debug.c +++ b/source4/lib/util/debug.c @@ -30,7 +30,7 @@ **/ /* this global variable determines what messages are printed */ -int DEBUGLEVEL; +_PUBLIC_ int DEBUGLEVEL; /* the registered mutex handlers */ @@ -68,7 +68,7 @@ static void log_timestring(int level, const char *location, const char *func) the backend for debug messages. Note that the DEBUG() macro has already ensured that the log level has been met before this is called */ -void do_debug_header(int level, const char *location, const char *func) +_PUBLIC_ void do_debug_header(int level, const char *location, const char *func) { log_timestring(level, location, func); log_task_id(); @@ -78,7 +78,7 @@ void do_debug_header(int level, const char *location, const char *func) the backend for debug messages. Note that the DEBUG() macro has already ensured that the log level has been met before this is called */ -void do_debug(const char *format, ...) _PRINTF_ATTRIBUTE(1,2) +_PUBLIC_ void do_debug(const char *format, ...) _PRINTF_ATTRIBUTE(1,2) { va_list ap; char *s = NULL; @@ -101,7 +101,7 @@ void do_debug(const char *format, ...) _PRINTF_ATTRIBUTE(1,2) /** reopen the log file (usually called because the log file name might have changed) */ -void reopen_logs(void) +_PUBLIC_ void reopen_logs(void) { const char *logfile = lp_logfile(); char *fname = NULL; @@ -147,7 +147,7 @@ void reopen_logs(void) control the name of the logfile and whether logging will be to stdout, stderr or a file */ -void setup_logging(const char *prog_name, enum debug_logtype new_logtype) +_PUBLIC_ void setup_logging(const char *prog_name, enum debug_logtype new_logtype) { if (state.logtype < new_logtype) { state.logtype = new_logtype; @@ -162,7 +162,7 @@ void setup_logging(const char *prog_name, enum debug_logtype new_logtype) return a string constant containing n tabs no more than 10 tabs are returned */ -const char *do_debug_tab(uint_t n) +_PUBLIC_ const char *do_debug_tab(uint_t n) { const char *tabs[] = {"", "\t", "\t\t", "\t\t\t", "\t\t\t\t", "\t\t\t\t\t", "\t\t\t\t\t\t", "\t\t\t\t\t\t\t", "\t\t\t\t\t\t\t\t", @@ -174,7 +174,7 @@ const char *do_debug_tab(uint_t n) /** log suspicious usage - print comments and backtrace */ -void log_suspicious_usage(const char *from, const char *info) +_PUBLIC_ void log_suspicious_usage(const char *from, const char *info) { if (debug_handlers.ops.log_suspicious_usage) { debug_handlers.ops.log_suspicious_usage(from, info); @@ -185,15 +185,14 @@ void log_suspicious_usage(const char *from, const char *info) /** print suspicious usage - print comments and backtrace */ - -void print_suspicious_usage(const char* from, const char* info) +_PUBLIC_ void print_suspicious_usage(const char* from, const char* info) { if (debug_handlers.ops.print_suspicious_usage) { debug_handlers.ops.print_suspicious_usage(from, info); } } -uint32_t get_task_id(void) +_PUBLIC_ uint32_t get_task_id(void) { if (debug_handlers.ops.get_task_id) { return debug_handlers.ops.get_task_id(); @@ -201,7 +200,7 @@ uint32_t get_task_id(void) return getpid(); } -void log_task_id(void) +_PUBLIC_ void log_task_id(void) { if (debug_handlers.ops.log_task_id) { debug_handlers.ops.log_task_id(state.fd); @@ -211,7 +210,7 @@ void log_task_id(void) /** register a set of debug handlers. */ -void register_debug_handlers(const char *name, struct debug_ops *ops) +_PUBLIC_ void register_debug_handlers(const char *name, struct debug_ops *ops) { debug_handlers.name = name; debug_handlers.ops = *ops; diff --git a/source4/lib/util/fault.c b/source4/lib/util/fault.c index abe3f141ce..ff44b8a292 100644 --- a/source4/lib/util/fault.c +++ b/source4/lib/util/fault.c @@ -46,7 +46,7 @@ static const char *progname; /** * Write backtrace to debug log */ -void call_backtrace(void) +_PUBLIC_ void call_backtrace(void) { #ifdef HAVE_BACKTRACE #define BACKTRACE_STACK_SIZE 64 @@ -112,7 +112,7 @@ void call_backtrace(void) /** Something really nasty happened - panic ! **/ -void smb_panic(const char *why) +_PUBLIC_ void smb_panic(const char *why) { const char *cmd = lp_panic_action(); int result; @@ -181,7 +181,7 @@ static void sig_fault(int sig) /** setup our fault handlers **/ -void fault_setup(const char *pname) +_PUBLIC_ void fault_setup(const char *pname) { if (progname == NULL) { progname = pname; @@ -204,7 +204,7 @@ void fault_setup(const char *pname) register a fault handler. Should only be called once in the execution of smbd. */ -BOOL register_fault_handler(const char *name, void (*fault_handler)(int sig)) +_PUBLIC_ BOOL register_fault_handler(const char *name, void (*fault_handler)(int sig)) { if (fault_handlers.name != NULL) { /* it's already registered! */ diff --git a/source4/lib/util/fsusage.c b/source4/lib/util/fsusage.c index dde9c61eb3..96b5ee4f59 100644 --- a/source4/lib/util/fsusage.c +++ b/source4/lib/util/fsusage.c @@ -47,7 +47,7 @@ static uint64_t adjust_blocks(uint64_t blocks, uint64_t fromsize, uint64_t tosiz * * results are returned in *dfree and *dsize, in 512 byte units */ -int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize) +_PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize) { #ifdef STAT_STATFS3_OSF1 #define CONVERT_BLOCKS(B) adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_fsize, (uint64_t)512) diff --git a/source4/lib/util/genrand.c b/source4/lib/util/genrand.c index a264ac4e31..f2b038f161 100644 --- a/source4/lib/util/genrand.c +++ b/source4/lib/util/genrand.c @@ -40,13 +40,13 @@ static void (*reseed_callback)(int *newseed); Copy any user given reseed data. **/ -void set_rand_reseed_callback(void (*fn)(int *)) +_PUBLIC_ void set_rand_reseed_callback(void (*fn)(int *)) { reseed_callback = fn; set_need_random_reseed(); } -void set_need_random_reseed(void) +_PUBLIC_ void set_need_random_reseed(void) { done_reseed = False; } @@ -204,7 +204,7 @@ static int do_reseed(BOOL use_fd, int fd) /** Interface to the (hopefully) good crypto random number generator. **/ -void generate_random_buffer(uint8_t *out, int len) +_PUBLIC_ void generate_random_buffer(uint8_t *out, int len) { static int urand_fd = -1; unsigned char md4_buf[64]; @@ -250,7 +250,7 @@ void generate_random_buffer(uint8_t *out, int len) /** generate a single random uint32_t **/ -uint32_t generate_random(void) +_PUBLIC_ uint32_t generate_random(void) { uint8_t v[4]; generate_random_buffer(v, 4); @@ -261,7 +261,7 @@ uint32_t generate_random(void) /** very basic password quality checker **/ -BOOL check_password_quality(const char *s) +_PUBLIC_ BOOL check_password_quality(const char *s) { int has_digit=0, has_capital=0, has_lower=0; while (*s) { @@ -282,7 +282,7 @@ BOOL check_password_quality(const char *s) Use the random number generator to generate a random string. **/ -char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list) +_PUBLIC_ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list) { size_t i; size_t list_len = strlen(list); @@ -299,7 +299,7 @@ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list return retstr; } -char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len) +_PUBLIC_ char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len) { char *retstr; const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,"; diff --git a/source4/lib/util/idtree.c b/source4/lib/util/idtree.c index 1ccf6d5e81..d29c3b8fbd 100644 --- a/source4/lib/util/idtree.c +++ b/source4/lib/util/idtree.c @@ -310,21 +310,21 @@ static int _idr_remove(struct idr_context *idp, int id) this is the public interface **************************************************************************/ -/* +/** initialise a idr tree. The context return value must be passed to all subsequent idr calls. To destroy the idr tree use talloc_free() on this context */ -struct idr_context *idr_init(TALLOC_CTX *mem_ctx) +_PUBLIC_ struct idr_context *idr_init(TALLOC_CTX *mem_ctx) { return talloc_zero(mem_ctx, struct idr_context); } -/* +/** allocate the next available id, and assign 'ptr' into its slot. you can retrieve later this pointer using idr_find() */ -int idr_get_new(struct idr_context *idp, void *ptr, int limit) +_PUBLIC_ int idr_get_new(struct idr_context *idp, void *ptr, int limit) { int ret = idr_get_new_above_int(idp, ptr, 0); if (ret > limit) { @@ -334,11 +334,11 @@ int idr_get_new(struct idr_context *idp, void *ptr, int limit) return ret; } -/* +/** allocate a new id, giving the first available value greater than or equal to the given starting id */ -int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int limit) +_PUBLIC_ int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int limit) { int ret = idr_get_new_above_int(idp, ptr, starting_id); if (ret > limit) { @@ -348,10 +348,10 @@ int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int l return ret; } -/* +/** allocate a new id randomly in the given range */ -int idr_get_new_random(struct idr_context *idp, void *ptr, int limit) +_PUBLIC_ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit) { int id; @@ -366,18 +366,18 @@ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit) return id; } -/* +/** find a pointer value previously set with idr_get_new given an id */ -void *idr_find(struct idr_context *idp, int id) +_PUBLIC_ void *idr_find(struct idr_context *idp, int id) { return _idr_find(idp, id); } -/* +/** remove an id from the idr tree */ -int idr_remove(struct idr_context *idp, int id) +_PUBLIC_ int idr_remove(struct idr_context *idp, int id) { int ret; ret = _idr_remove((struct idr_context *)idp, id); diff --git a/source4/lib/util/module.c b/source4/lib/util/module.c index ad8afe2b16..ef72551570 100644 --- a/source4/lib/util/module.c +++ b/source4/lib/util/module.c @@ -56,7 +56,11 @@ static void *load_module(TALLOC_CTX *mem_ctx, const char *dir, const char *name) return init_fn; } -init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) +/** + * Obtain list of init functions from the modules in the specified + * directory + */ +_PUBLIC_ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) { DIR *dir; struct dirent *entry; @@ -88,7 +92,12 @@ init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path) return ret; } -BOOL run_init_functions(NTSTATUS (**fns) (void)) +/** + * Run the specified init functions. + * + * @return True if all functions ran successfully, False otherwise + */ +_PUBLIC_ BOOL run_init_functions(NTSTATUS (**fns) (void)) { int i; BOOL ret; diff --git a/source4/lib/util/mutex.c b/source4/lib/util/mutex.c index 79c281ff0c..3b64f4929b 100644 --- a/source4/lib/util/mutex.c +++ b/source4/lib/util/mutex.c @@ -39,7 +39,7 @@ static struct { register a set of mutex/rwlock handlers. Should only be called once in the execution of smbd. */ -BOOL register_mutex_handlers(const char *name, struct mutex_ops *ops) +_PUBLIC_ BOOL register_mutex_handlers(const char *name, struct mutex_ops *ops) { if (mutex_handlers.name != NULL) { /* it's already registered! */ diff --git a/source4/lib/util/pidfile.c b/source4/lib/util/pidfile.c index 7f56fa5641..1a46e6e70c 100644 --- a/source4/lib/util/pidfile.c +++ b/source4/lib/util/pidfile.c @@ -36,7 +36,7 @@ * return the pid in a pidfile. return 0 if the process (or pidfile) * does not exist */ -pid_t pidfile_pid(const char *name) +_PUBLIC_ pid_t pidfile_pid(const char *name) { int fd; char pidstr[20]; diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c index a56175cda9..4897d2fa95 100644 --- a/source4/lib/util/time.c +++ b/source4/lib/util/time.c @@ -45,7 +45,7 @@ /** External access to time_t_min and time_t_max. **/ -time_t get_time_t_max(void) +_PUBLIC_ time_t get_time_t_max(void) { return TIME_T_MAX; } @@ -53,7 +53,7 @@ time_t get_time_t_max(void) /** a gettimeofday wrapper **/ -void GetTimeOfDay(struct timeval *tval) +_PUBLIC_ void GetTimeOfDay(struct timeval *tval) { #ifdef HAVE_GETTIMEOFDAY_TZ gettimeofday(tval,NULL); @@ -69,7 +69,7 @@ void GetTimeOfDay(struct timeval *tval) interpret an 8 byte "filetime" structure to a time_t It's originally in "100ns units since jan 1st 1601" **/ -time_t nt_time_to_unix(NTTIME nt) +_PUBLIC_ time_t nt_time_to_unix(NTTIME nt) { if (nt == 0) { return 0; @@ -93,7 +93,7 @@ time_t nt_time_to_unix(NTTIME nt) put a 8 byte filetime from a time_t This takes GMT as input **/ -void unix_to_nt_time(NTTIME *nt, time_t t) +_PUBLIC_ void unix_to_nt_time(NTTIME *nt, time_t t) { uint64_t t2; @@ -117,7 +117,7 @@ void unix_to_nt_time(NTTIME *nt, time_t t) /** check if it's a null unix time **/ -BOOL null_time(time_t t) +_PUBLIC_ BOOL null_time(time_t t) { return t == 0 || t == (time_t)0xFFFFFFFF || @@ -128,7 +128,7 @@ BOOL null_time(time_t t) /** check if it's a null NTTIME **/ -BOOL null_nttime(NTTIME t) +_PUBLIC_ BOOL null_nttime(NTTIME t) { return t == 0 || t == (NTTIME)-1; } @@ -185,7 +185,7 @@ static uint32_t make_dos_date(time_t unixdate, int zone_offset) put a dos date into a buffer (time/date format) This takes GMT time and puts local time in the buffer **/ -void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset) +_PUBLIC_ void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset) { uint32_t x = make_dos_date(unixdate, zone_offset); SIVAL(buf,offset,x); @@ -195,7 +195,7 @@ void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset) put a dos date into a buffer (date/time format) This takes GMT time and puts local time in the buffer **/ -void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset) +_PUBLIC_ void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset) { uint32_t x; x = make_dos_date(unixdate, zone_offset); @@ -208,7 +208,7 @@ put a dos 32 bit "unix like" date into a buffer. This routine takes GMT and converts it to LOCAL time before putting it (most SMBs assume localtime for this sort of date) **/ -void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset) +_PUBLIC_ void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset) { if (!null_time(unixdate)) { unixdate -= zone_offset; @@ -238,7 +238,7 @@ static void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int * create a unix date (int GMT) from a dos date (which is actually in localtime) **/ -time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset) +_PUBLIC_ time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset) { uint32_t dos_date=0; struct tm t; @@ -262,7 +262,7 @@ time_t pull_dos_date(const uint8_t *date_ptr, int zone_offset) /** like make_unix_date() but the words are reversed **/ -time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset) +_PUBLIC_ time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset) { uint32_t x,x2; @@ -277,7 +277,7 @@ time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset) create a unix GMT date from a dos date in 32 bit "unix like" format these generally arrive as localtimes, with corresponding DST **/ -time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset) +_PUBLIC_ time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset) { time_t t = (time_t)IVAL(date_ptr,0); if (!null_time(t)) { @@ -290,7 +290,7 @@ time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset) /** return a HTTP/1.0 time string **/ -char *http_timestring(TALLOC_CTX *mem_ctx, time_t t) +_PUBLIC_ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t) { char *buf; char tempTime[60]; @@ -316,7 +316,7 @@ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t) /** Return the date and time as a string **/ -char *timestring(TALLOC_CTX *mem_ctx, time_t t) +_PUBLIC_ char *timestring(TALLOC_CTX *mem_ctx, time_t t) { char *TimeBuf; char tempTime[80]; @@ -346,7 +346,7 @@ char *timestring(TALLOC_CTX *mem_ctx, time_t t) /** return a talloced string representing a NTTIME for human consumption */ -const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt) +_PUBLIC_ const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt) { time_t t; if (nt == 0) { @@ -360,7 +360,7 @@ const char *nt_time_string(TALLOC_CTX *mem_ctx, NTTIME nt) /** put a NTTIME into a packet */ -void push_nttime(uint8_t *base, uint16_t offset, NTTIME t) +_PUBLIC_ void push_nttime(uint8_t *base, uint16_t offset, NTTIME t) { SBVAL(base, offset, t); } @@ -368,7 +368,7 @@ void push_nttime(uint8_t *base, uint16_t offset, NTTIME t) /** pull a NTTIME from a packet */ -NTTIME pull_nttime(uint8_t *base, uint16_t offset) +_PUBLIC_ NTTIME pull_nttime(uint8_t *base, uint16_t offset) { NTTIME ret = BVAL(base, offset); return ret; @@ -377,7 +377,7 @@ NTTIME pull_nttime(uint8_t *base, uint16_t offset) /** parse a nttime as a large integer in a string and return a NTTIME */ -NTTIME nttime_from_string(const char *s) +_PUBLIC_ NTTIME nttime_from_string(const char *s) { return strtoull(s, NULL, 0); } @@ -385,7 +385,7 @@ NTTIME nttime_from_string(const char *s) /** return (tv1 - tv2) in microseconds */ -int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2) +_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2) { int64_t sec_diff = tv1->tv_sec - tv2->tv_sec; return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec); @@ -395,7 +395,7 @@ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2) /** return a zero timeval */ -struct timeval timeval_zero(void) +_PUBLIC_ struct timeval timeval_zero(void) { struct timeval tv; tv.tv_sec = 0; @@ -406,7 +406,7 @@ struct timeval timeval_zero(void) /** return True if a timeval is zero */ -BOOL timeval_is_zero(const struct timeval *tv) +_PUBLIC_ BOOL timeval_is_zero(const struct timeval *tv) { return tv->tv_sec == 0 && tv->tv_usec == 0; } @@ -414,7 +414,7 @@ BOOL timeval_is_zero(const struct timeval *tv) /** return a timeval for the current time */ -struct timeval timeval_current(void) +_PUBLIC_ struct timeval timeval_current(void) { struct timeval tv; GetTimeOfDay(&tv); @@ -424,7 +424,7 @@ struct timeval timeval_current(void) /** return a timeval struct with the given elements */ -struct timeval timeval_set(uint32_t secs, uint32_t usecs) +_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs) { struct timeval tv; tv.tv_sec = secs; @@ -436,7 +436,7 @@ struct timeval timeval_set(uint32_t secs, uint32_t usecs) /** return a timeval ofs microseconds after tv */ -struct timeval timeval_add(const struct timeval *tv, +_PUBLIC_ struct timeval timeval_add(const struct timeval *tv, uint32_t secs, uint32_t usecs) { struct timeval tv2 = *tv; @@ -460,7 +460,7 @@ struct timeval timeval_sum(const struct timeval *tv1, /** return a timeval secs/usecs into the future */ -struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs) +_PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs) { struct timeval tv = timeval_current(); return timeval_add(&tv, secs, usecs); @@ -472,7 +472,7 @@ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs) Return 0 if tv1 == tv2 Return 1 if tv1 > tv2 */ -int timeval_compare(const struct timeval *tv1, const struct timeval *tv2) +_PUBLIC_ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2) { if (tv1->tv_sec > tv2->tv_sec) return 1; if (tv1->tv_sec < tv2->tv_sec) return -1; @@ -484,7 +484,7 @@ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2) /** return True if a timer is in the past */ -BOOL timeval_expired(const struct timeval *tv) +_PUBLIC_ BOOL timeval_expired(const struct timeval *tv) { struct timeval tv2 = timeval_current(); if (tv2.tv_sec > tv->tv_sec) return True; @@ -495,7 +495,7 @@ BOOL timeval_expired(const struct timeval *tv) /** return the number of seconds elapsed between two times */ -double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2) +_PUBLIC_ double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2) { return (tv2->tv_sec - tv1->tv_sec) + (tv2->tv_usec - tv1->tv_usec)*1.0e-6; @@ -504,7 +504,7 @@ double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2) /** return the number of seconds elapsed since a given time */ -double timeval_elapsed(const struct timeval *tv) +_PUBLIC_ double timeval_elapsed(const struct timeval *tv) { struct timeval tv2 = timeval_current(); return timeval_elapsed2(tv, &tv2); @@ -513,7 +513,7 @@ double timeval_elapsed(const struct timeval *tv) /** return the lesser of two timevals */ -struct timeval timeval_min(const struct timeval *tv1, +_PUBLIC_ struct timeval timeval_min(const struct timeval *tv1, const struct timeval *tv2) { if (tv1->tv_sec < tv2->tv_sec) return *tv1; @@ -525,7 +525,7 @@ struct timeval timeval_min(const struct timeval *tv1, /** return the greater of two timevals */ -struct timeval timeval_max(const struct timeval *tv1, +_PUBLIC_ struct timeval timeval_max(const struct timeval *tv1, const struct timeval *tv2) { if (tv1->tv_sec > tv2->tv_sec) return *tv1; @@ -539,7 +539,7 @@ struct timeval timeval_max(const struct timeval *tv1, if tv1 comes after tv2, then return a zero timeval (this is *tv2 - *tv1) */ -struct timeval timeval_until(const struct timeval *tv1, +_PUBLIC_ struct timeval timeval_until(const struct timeval *tv1, const struct timeval *tv2) { struct timeval t; @@ -560,7 +560,7 @@ struct timeval timeval_until(const struct timeval *tv1, /** convert a timeval to a NTTIME */ -NTTIME timeval_to_nttime(const struct timeval *tv) +_PUBLIC_ NTTIME timeval_to_nttime(const struct timeval *tv) { return 10*(tv->tv_usec + ((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000)); @@ -587,7 +587,7 @@ static int tm_diff(struct tm *a, struct tm *b) /** return the UTC offset in seconds west of UTC, or 0 if it cannot be determined */ -int get_time_zone(time_t t) +_PUBLIC_ int get_time_zone(time_t t) { struct tm *tm = gmtime(&t); struct tm tm_utc; diff --git a/source4/lib/util/util.c b/source4/lib/util/util.c index 074dc000fb..81084878b5 100644 --- a/source4/lib/util/util.c +++ b/source4/lib/util/util.c @@ -37,7 +37,7 @@ Find a suitable temporary directory. The result should be copied immediately as it may be overwritten by a subsequent call. **/ -const char *tmpdir(void) +_PUBLIC_ const char *tmpdir(void) { char *p; if ((p = getenv("TMPDIR"))) @@ -49,7 +49,7 @@ const char *tmpdir(void) /** Check if a file exists - call vfs_file_exist for samba files. **/ -BOOL file_exist(const char *fname) +_PUBLIC_ BOOL file_exist(const char *fname) { struct stat st; @@ -64,7 +64,7 @@ BOOL file_exist(const char *fname) Check a files mod time. **/ -time_t file_modtime(const char *fname) +_PUBLIC_ time_t file_modtime(const char *fname) { struct stat st; @@ -78,7 +78,7 @@ time_t file_modtime(const char *fname) Check if a directory exists. **/ -BOOL directory_exist(const char *dname) +_PUBLIC_ BOOL directory_exist(const char *dname) { struct stat st; BOOL ret; @@ -93,7 +93,7 @@ BOOL directory_exist(const char *dname) return ret; } -BOOL directory_create_or_exist(const char *dname, uid_t uid, +_PUBLIC_ BOOL directory_create_or_exist(const char *dname, uid_t uid, mode_t dir_perms) { mode_t old_umask; @@ -179,7 +179,7 @@ static void close_low_fds(BOOL stderr_too) if BSD use FNDELAY **/ -int set_blocking(int fd, BOOL set) +_PUBLIC_ int set_blocking(int fd, BOOL set) { int val; #ifdef O_NONBLOCK @@ -207,7 +207,7 @@ int set_blocking(int fd, BOOL set) Sleep for a specified number of milliseconds. **/ -void msleep(uint_t t) +_PUBLIC_ void msleep(uint_t t) { struct timeval tval; @@ -222,7 +222,7 @@ void msleep(uint_t t) Become a daemon, discarding the controlling terminal. **/ -void become_daemon(BOOL Fork) +_PUBLIC_ void become_daemon(BOOL Fork) { if (Fork) { if (fork()) { @@ -255,7 +255,7 @@ void become_daemon(BOOL Fork) Exists only because we need to pass a function pointer somewhere --SSS **/ -void safe_free(void *p) +_PUBLIC_ void safe_free(void *p) { SAFE_FREE(p); } @@ -265,7 +265,7 @@ void safe_free(void *p) see if a string matches either our primary or one of our secondary netbios aliases. do a case insensitive match */ -BOOL is_myname(const char *name) +_PUBLIC_ BOOL is_myname(const char *name) { const char **aliases; int i; @@ -289,7 +289,7 @@ BOOL is_myname(const char *name) Get my own name, return in malloc'ed storage. **/ -char* get_myname(void) +_PUBLIC_ char* get_myname(void) { char *hostname; const int host_name_max = 255; @@ -320,7 +320,7 @@ char* get_myname(void) Return true if a string could be a pure IP address. **/ -BOOL is_ipaddress(const char *str) +_PUBLIC_ BOOL is_ipaddress(const char *str) { BOOL pure_address = True; int i; @@ -338,7 +338,7 @@ BOOL is_ipaddress(const char *str) /** Interpret an internet address or name into an IP address in 4 byte form. **/ -uint32_t interpret_addr(const char *str) +_PUBLIC_ uint32_t interpret_addr(const char *str) { struct hostent *hp; uint32_t res; @@ -383,7 +383,7 @@ uint32_t interpret_addr(const char *str) /** A convenient addition to interpret_addr(). **/ -struct ipv4_addr interpret_addr2(const char *str) +_PUBLIC_ struct ipv4_addr interpret_addr2(const char *str) { struct ipv4_addr ret; uint32_t a = interpret_addr(str); @@ -395,7 +395,7 @@ struct ipv4_addr interpret_addr2(const char *str) Check if an IP is the 0.0.0.0. **/ -BOOL is_zero_ip(struct ipv4_addr ip) +_PUBLIC_ BOOL is_zero_ip(struct ipv4_addr ip) { return ip.addr == 0; } @@ -404,7 +404,7 @@ BOOL is_zero_ip(struct ipv4_addr ip) Are two IPs on the same subnet? **/ -BOOL same_net(struct ipv4_addr ip1,struct ipv4_addr ip2,struct ipv4_addr mask) +_PUBLIC_ BOOL same_net(struct ipv4_addr ip1,struct ipv4_addr ip2,struct ipv4_addr mask) { uint32_t net1,net2,nmask; @@ -420,7 +420,7 @@ BOOL same_net(struct ipv4_addr ip1,struct ipv4_addr ip2,struct ipv4_addr mask) Check if a process exists. Does this work on all unixes? **/ -BOOL process_exists(pid_t pid) +_PUBLIC_ BOOL process_exists(pid_t pid) { /* Doing kill with a non-positive pid causes messages to be * sent to places we don't want. */ @@ -433,7 +433,7 @@ BOOL process_exists(pid_t pid) is dealt with in posix.c **/ -BOOL fcntl_lock(int fd, int op, off_t offset, off_t count, int type) +_PUBLIC_ BOOL fcntl_lock(int fd, int op, off_t offset, off_t count, int type) { struct flock lock; int ret; @@ -486,7 +486,7 @@ static void print_asc(int level, const uint8_t *buf,int len) DEBUGADD(level,("%c", isprint(buf[i])?buf[i]:'.')); } -void dump_data(int level, const uint8_t *buf,int len) +_PUBLIC_ void dump_data(int level, const uint8_t *buf,int len) { int i=0; if (len<=0) return; @@ -522,7 +522,7 @@ void dump_data(int level, const uint8_t *buf,int len) malloc that aborts with smb_panic on fail or zero size. **/ -void *smb_xmalloc(size_t size) +_PUBLIC_ void *smb_xmalloc(size_t size) { void *p; if (size == 0) @@ -536,7 +536,7 @@ void *smb_xmalloc(size_t size) Memdup with smb_panic on fail. **/ -void *smb_xmemdup(const void *p, size_t size) +_PUBLIC_ void *smb_xmemdup(const void *p, size_t size) { void *p2; p2 = smb_xmalloc(size); @@ -548,7 +548,7 @@ void *smb_xmemdup(const void *p, size_t size) strdup that aborts on malloc fail. **/ -char *smb_xstrdup(const char *s) +_PUBLIC_ char *smb_xstrdup(const char *s) { char *s1 = strdup(s); if (!s1) @@ -561,7 +561,7 @@ char *smb_xstrdup(const char *s) Like strdup but for memory. **/ -void *memdup(const void *p, size_t size) +_PUBLIC_ void *memdup(const void *p, size_t size) { void *p2; if (size == 0) @@ -576,7 +576,7 @@ void *memdup(const void *p, size_t size) /** A useful function for returning a path in the Samba lock directory. **/ -char *lock_path(TALLOC_CTX* mem_ctx, const char *name) +_PUBLIC_ char *lock_path(TALLOC_CTX* mem_ctx, const char *name) { char *fname, *dname; if (name == NULL) { @@ -631,7 +631,7 @@ static char *pid_path(TALLOC_CTX* mem_ctx, const char *name) * @retval Pointer to a talloc'ed string containing the full path. **/ -char *lib_path(TALLOC_CTX* mem_ctx, const char *name) +_PUBLIC_ char *lib_path(TALLOC_CTX* mem_ctx, const char *name) { char *fname; fname = talloc_asprintf(mem_ctx, "%s/%s", dyn_LIBDIR, name); @@ -646,7 +646,7 @@ char *lib_path(TALLOC_CTX* mem_ctx, const char *name) * * @retval Pointer to a talloc'ed string containing the full path. **/ -char *private_path(TALLOC_CTX* mem_ctx, const char *name) +_PUBLIC_ char *private_path(TALLOC_CTX* mem_ctx, const char *name) { char *fname; if (name == NULL) { @@ -664,7 +664,7 @@ char *private_path(TALLOC_CTX* mem_ctx, const char *name) for smbd go. If NULL is passed for name then return the directory path itself */ -char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name) +_PUBLIC_ char *smbd_tmp_path(TALLOC_CTX *mem_ctx, const char *name) { char *fname, *dname; @@ -688,7 +688,7 @@ static char *modules_path(TALLOC_CTX* mem_ctx, const char *name) return talloc_asprintf(mem_ctx, "%s/%s", dyn_MODULESDIR, name); } -init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem) +_PUBLIC_ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem) { char *path = modules_path(mem_ctx, subsystem); init_module_fn *ret; @@ -700,7 +700,7 @@ init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, const char *subsystem) return ret; } -void dump_data_pw(const char *msg, const uint8_t * data, size_t len) +_PUBLIC_ void dump_data_pw(const char *msg, const uint8_t * data, size_t len) { #ifdef DEBUG_PASSWORD DEBUG(11, ("%s", msg)); @@ -716,7 +716,7 @@ void dump_data_pw(const char *msg, const uint8_t * data, size_t len) * see if a range of memory is all zero. A NULL pointer is considered * to be all zero */ -BOOL all_zero(const uint8_t *ptr, uint_t size) +_PUBLIC_ BOOL all_zero(const uint8_t *ptr, uint_t size) { int i; if (!ptr) return True; @@ -729,7 +729,7 @@ BOOL all_zero(const uint8_t *ptr, uint_t size) /** realloc an array, checking for integer overflow in the array size */ -void *realloc_array(void *ptr, size_t el_size, unsigned count) +_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count) { #define MAX_MALLOC_SIZE 0x7fffffff if (count == 0 || diff --git a/source4/lib/util/util_file.c b/source4/lib/util/util_file.c index 5e55b81873..430472f25a 100644 --- a/source4/lib/util/util_file.c +++ b/source4/lib/util/util_file.c @@ -34,7 +34,7 @@ read a line from a file with possible \ continuation chars. Blanks at the start or end of a line are stripped. The string will be allocated if s2 is NULL **/ -char *fgets_slash(char *s2,int maxlen,XFILE *f) +_PUBLIC_ char *fgets_slash(char *s2,int maxlen,XFILE *f) { char *s=s2; int len = 0; @@ -106,7 +106,7 @@ char *fgets_slash(char *s2,int maxlen,XFILE *f) /** * Read one line (data until next newline or eof) and allocate it */ -char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint) +_PUBLIC_ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint) { char *data = NULL; ssize_t alloc_size = 0, offset = 0, ret; @@ -156,8 +156,7 @@ char *afdgets(int fd, TALLOC_CTX *mem_ctx, size_t hint) /** load a file into memory from a fd. **/ - -char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx) +_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx) { struct stat sbuf; char *p; @@ -181,7 +180,7 @@ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx) /** load a file into memory **/ -char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx) +_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx) { int fd; char *p; @@ -202,7 +201,7 @@ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx) /** mmap (if possible) or read a file **/ -void *map_file(const char *fname, size_t size) +_PUBLIC_ void *map_file(const char *fname, size_t size) { size_t s2 = 0; void *p = NULL; @@ -278,7 +277,7 @@ static char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX * load a file into memory and return an array of pointers to lines in the file must be freed with talloc_free(). **/ -char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx) +_PUBLIC_ char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx) { char *p; char **lines; @@ -299,7 +298,7 @@ load a fd into memory and return an array of pointers to lines in the file must be freed with talloc_free(). If convert is true calls unix_to_dos on the list. **/ -char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx) +_PUBLIC_ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx) { char *p; char **lines; @@ -320,7 +319,7 @@ char **fd_lines_load(int fd, int *numlines, TALLOC_CTX *mem_ctx) take a list of lines and modify them to produce a list where \ continues a line **/ -void file_lines_slashcont(char **lines) +_PUBLIC_ void file_lines_slashcont(char **lines) { int i, j; @@ -342,7 +341,7 @@ void file_lines_slashcont(char **lines) /** save a lump of data into a file. Mostly used for debugging */ -BOOL file_save(const char *fname, const void *packet, size_t length) +_PUBLIC_ BOOL file_save(const char *fname, const void *packet, size_t length) { int fd; fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644); @@ -359,7 +358,7 @@ BOOL file_save(const char *fname, const void *packet, size_t length) /** see if a file exists */ -BOOL file_exists(const char *path) +_PUBLIC_ BOOL file_exists(const char *path) { struct stat st; return (stat(path, &st) == 0); diff --git a/source4/lib/util/util_sock.c b/source4/lib/util/util_sock.c index e3913f56a9..0a4380faf4 100644 --- a/source4/lib/util/util_sock.c +++ b/source4/lib/util/util_sock.c @@ -75,7 +75,7 @@ static const struct { /** Set user socket options. **/ -void set_socket_options(int fd, const char *options) +_PUBLIC_ void set_socket_options(int fd, const char *options) { const char **options_list = str_list_make(NULL, options, " \t,"); int j; diff --git a/source4/lib/util/util_str.c b/source4/lib/util/util_str.c index 11a95731de..ef6abd6e83 100644 --- a/source4/lib/util/util_str.c +++ b/source4/lib/util/util_str.c @@ -40,7 +40,7 @@ * Based on a routine by GJC@VILLAGE.COM. * Extensively modified by Andrew.Tridgell@anu.edu.au **/ -BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize) +_PUBLIC_ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize) { const char *s; BOOL quoted; @@ -82,7 +82,7 @@ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize) /** Case insensitive string compararison **/ -int strcasecmp_m(const char *s1, const char *s2) +_PUBLIC_ int strcasecmp_m(const char *s1, const char *s2) { codepoint_t c1=0, c2=0; size_t size1, size2; @@ -117,7 +117,7 @@ int strcasecmp_m(const char *s1, const char *s2) * * @note The comparison is case-insensitive. **/ -BOOL strequal(const char *s1, const char *s2) +_PUBLIC_ BOOL strequal(const char *s1, const char *s2) { if (s1 == s2) return(True); @@ -130,7 +130,7 @@ BOOL strequal(const char *s1, const char *s2) /** Compare 2 strings (case sensitive). **/ -BOOL strcsequal(const char *s1,const char *s2) +_PUBLIC_ BOOL strcsequal(const char *s1,const char *s2) { if (s1 == s2) return(True); @@ -144,7 +144,7 @@ BOOL strcsequal(const char *s1,const char *s2) /** Do a case-insensitive, whitespace-ignoring string compare. **/ -int strwicmp(const char *psz1, const char *psz2) +_PUBLIC_ int strwicmp(const char *psz1, const char *psz2) { /* if BOTH strings are NULL, return TRUE, if ONE is NULL return */ /* appropriate value. */ @@ -175,7 +175,7 @@ int strwicmp(const char *psz1, const char *psz2) String replace. NOTE: oldc and newc must be 7 bit characters **/ -void string_replace(char *s, char oldc, char newc) +_PUBLIC_ void string_replace(char *s, char oldc, char newc) { while (*s) { size_t size; @@ -190,7 +190,7 @@ void string_replace(char *s, char oldc, char newc) /** Trim the specified elements off the front and back of a string. **/ -BOOL trim_string(char *s,const char *front,const char *back) +_PUBLIC_ BOOL trim_string(char *s,const char *front,const char *back) { BOOL ret = False; size_t front_len; @@ -229,7 +229,7 @@ BOOL trim_string(char *s,const char *front,const char *back) /** Find the number of 'c' chars in a string **/ -size_t count_chars(const char *s, char c) +_PUBLIC_ size_t count_chars(const char *s, char c) { size_t count = 0; @@ -247,7 +247,7 @@ size_t count_chars(const char *s, char c) Safe string copy into a known length string. maxlength does not include the terminating zero. **/ -char *safe_strcpy(char *dest,const char *src, size_t maxlength) +_PUBLIC_ char *safe_strcpy(char *dest,const char *src, size_t maxlength) { size_t len; @@ -289,7 +289,7 @@ char *safe_strcpy(char *dest,const char *src, size_t maxlength) Safe string cat into a string. maxlength does not include the terminating zero. **/ -char *safe_strcat(char *dest, const char *src, size_t maxlength) +_PUBLIC_ char *safe_strcat(char *dest, const char *src, size_t maxlength) { size_t src_len, dest_len; @@ -331,7 +331,7 @@ char *safe_strcat(char *dest, const char *src, size_t maxlength) characters. Don't change it ! **/ -char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength) +_PUBLIC_ char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength) { size_t len, i; @@ -375,7 +375,7 @@ char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, si The variable n should always be one less than the available size. **/ -char *StrnCpy(char *dest,const char *src,size_t n) +_PUBLIC_ char *StrnCpy(char *dest,const char *src,size_t n) { char *d = dest; if (!dest) @@ -401,7 +401,7 @@ char *StrnCpy(char *dest,const char *src,size_t n) **/ -size_t strhex_to_str(char *p, size_t len, const char *strhex) +_PUBLIC_ size_t strhex_to_str(char *p, size_t len, const char *strhex) { size_t i; size_t num_chars = 0; @@ -436,7 +436,7 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex) return num_chars; } -DATA_BLOB strhex_to_data_blob(const char *strhex) +_PUBLIC_ DATA_BLOB strhex_to_data_blob(const char *strhex) { DATA_BLOB ret_blob = data_blob(NULL, strlen(strhex)/2+1); @@ -451,7 +451,7 @@ DATA_BLOB strhex_to_data_blob(const char *strhex) /** * Routine to print a buffer as HEX digits, into an allocated string. */ -void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) +_PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) { int i; char *hex_buffer; @@ -466,7 +466,7 @@ void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) /** Check if a string is part of a list. **/ -BOOL in_list(const char *s, const char *list, BOOL casesensitive) +_PUBLIC_ BOOL in_list(const char *s, const char *list, BOOL casesensitive) { pstring tok; const char *p=list; @@ -504,7 +504,7 @@ static BOOL string_init(char **dest,const char *src) /** Free a string value. **/ -void string_free(char **s) +_PUBLIC_ void string_free(char **s) { if (s) SAFE_FREE(*s); } @@ -513,7 +513,7 @@ void string_free(char **s) Set a string value, deallocating any existing space, and allocing the space for the string **/ -BOOL string_set(char **dest, const char *src) +_PUBLIC_ BOOL string_set(char **dest, const char *src) { string_free(dest); return string_init(dest,src); @@ -531,7 +531,7 @@ BOOL string_set(char **dest, const char *src) use of len==0 which was for no length checks to be done. **/ -void string_sub(char *s,const char *pattern, const char *insert, size_t len) +_PUBLIC_ void string_sub(char *s,const char *pattern, const char *insert, size_t len) { char *p; ssize_t ls,lp,li, i; @@ -585,7 +585,7 @@ void string_sub(char *s,const char *pattern, const char *insert, size_t len) use of len==0 which was for no length checks to be done. **/ -void all_string_sub(char *s,const char *pattern,const char *insert, size_t len) +_PUBLIC_ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len) { char *p; ssize_t ls,lp,li; @@ -623,7 +623,7 @@ void all_string_sub(char *s,const char *pattern,const char *insert, size_t len) /** Strchr and strrchr_m are a bit complex on general multi-byte strings. **/ -char *strchr_m(const char *s, char c) +_PUBLIC_ char *strchr_m(const char *s, char c) { /* characters below 0x3F are guaranteed to not appear in non-initial position in multi-byte charsets */ @@ -643,7 +643,7 @@ char *strchr_m(const char *s, char c) return NULL; } -char *strrchr_m(const char *s, char c) +_PUBLIC_ char *strrchr_m(const char *s, char c) { char *ret = NULL; @@ -668,7 +668,7 @@ char *strrchr_m(const char *s, char c) /* return True if any (multi-byte) character is lower case */ -BOOL strhaslower(const char *string) +_PUBLIC_ BOOL strhaslower(const char *string) { while (*string) { size_t c_size; @@ -691,7 +691,7 @@ BOOL strhaslower(const char *string) /* return True if any (multi-byte) character is upper case */ -BOOL strhasupper(const char *string) +_PUBLIC_ BOOL strhasupper(const char *string) { while (*string) { size_t c_size; @@ -714,7 +714,7 @@ BOOL strhasupper(const char *string) /** Convert a string to lower case, allocated with talloc **/ -char *strlower_talloc(TALLOC_CTX *ctx, const char *src) +_PUBLIC_ char *strlower_talloc(TALLOC_CTX *ctx, const char *src) { size_t size=0; char *dest; @@ -749,7 +749,7 @@ char *strlower_talloc(TALLOC_CTX *ctx, const char *src) /** Convert a string to UPPER case, allocated with talloc **/ -char *strupper_talloc(TALLOC_CTX *ctx, const char *src) +_PUBLIC_ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) { size_t size=0; char *dest; @@ -788,7 +788,7 @@ char *strupper_talloc(TALLOC_CTX *ctx, const char *src) /** Convert a string to lower case. **/ -void strlower_m(char *s) +_PUBLIC_ void strlower_m(char *s) { char *d; @@ -824,7 +824,7 @@ void strlower_m(char *s) /** Convert a string to UPPER case. **/ -void strupper_m(char *s) +_PUBLIC_ void strupper_m(char *s) { char *d; @@ -862,7 +862,7 @@ void strupper_m(char *s) be the same as the number of bytes in a string for single byte strings, but will be different for multibyte. **/ -size_t strlen_m(const char *s) +_PUBLIC_ size_t strlen_m(const char *s) { size_t count = 0; @@ -897,7 +897,7 @@ size_t strlen_m(const char *s) Work out the number of multibyte chars in a string, including the NULL terminator. **/ -size_t strlen_m_term(const char *s) +_PUBLIC_ size_t strlen_m_term(const char *s) { if (!s) { return 0; @@ -910,7 +910,7 @@ size_t strlen_m_term(const char *s) Unescape a URL encoded string, in place. **/ -void rfc1738_unescape(char *buf) +_PUBLIC_ void rfc1738_unescape(char *buf) { char *p=buf; @@ -949,7 +949,7 @@ void rfc1738_unescape(char *buf) /** * Decode a base64 string into a DATA_BLOB - simple and slow algorithm **/ -DATA_BLOB base64_decode_data_blob(TALLOC_CTX *mem_ctx, const char *s) +_PUBLIC_ DATA_BLOB base64_decode_data_blob(TALLOC_CTX *mem_ctx, const char *s) { DATA_BLOB ret = data_blob_talloc(mem_ctx, s, strlen(s)+1); ret.length = ldb_base64_decode((char *)ret.data); @@ -959,7 +959,7 @@ DATA_BLOB base64_decode_data_blob(TALLOC_CTX *mem_ctx, const char *s) /** * Decode a base64 string in-place - wrapper for the above **/ -void base64_decode_inplace(char *s) +_PUBLIC_ void base64_decode_inplace(char *s) { ldb_base64_decode(s); } @@ -967,7 +967,7 @@ void base64_decode_inplace(char *s) /** * Encode a base64 string into a talloc()ed string caller to free. **/ -char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data) +_PUBLIC_ char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data) { return ldb_base64_encode(mem_ctx, (const char *)data.data, data.length); } @@ -987,7 +987,7 @@ size_t valgrind_strlen(const char *s) format a string into length-prefixed dotted domain format, as used in NBT and in some ADS structures **/ -const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s) +_PUBLIC_ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s) { char *ret; int i; @@ -1016,7 +1016,7 @@ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s) return ret; } -BOOL add_string_to_array(TALLOC_CTX *mem_ctx, +_PUBLIC_ BOOL add_string_to_array(TALLOC_CTX *mem_ctx, const char *str, const char ***strings, int *num) { char *dup_str = talloc_strdup(mem_ctx, str); @@ -1039,7 +1039,7 @@ BOOL add_string_to_array(TALLOC_CTX *mem_ctx, /** varient of strcmp() that handles NULL ptrs **/ -int strcmp_safe(const char *s1, const char *s2) +_PUBLIC_ int strcmp_safe(const char *s1, const char *s2) { if (s1 == s2) { return 0; @@ -1056,7 +1056,7 @@ return the number of bytes occupied by a buffer in ASCII format the result includes the null termination limited by 'n' bytes **/ -size_t ascii_len_n(const char *src, size_t n) +_PUBLIC_ size_t ascii_len_n(const char *src, size_t n) { size_t len; @@ -1072,7 +1072,7 @@ size_t ascii_len_n(const char *src, size_t n) /** Return a string representing a CIFS attribute for a file. **/ -char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib) +_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib) { int i, len; const struct { @@ -1119,7 +1119,7 @@ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib) represent a boolean. **/ -BOOL set_boolean(const char *boolean_string, BOOL *boolean) +_PUBLIC_ BOOL set_boolean(const char *boolean_string, BOOL *boolean) { if (strwicmp(boolean_string, "yes") == 0 || strwicmp(boolean_string, "true") == 0 || @@ -1137,7 +1137,7 @@ BOOL set_boolean(const char *boolean_string, BOOL *boolean) return False; } -BOOL conv_str_bool(const char * str, BOOL * val) +_PUBLIC_ BOOL conv_str_bool(const char * str, BOOL * val) { char * end = NULL; long lval; @@ -1158,7 +1158,7 @@ BOOL conv_str_bool(const char * str, BOOL * val) /** * Convert a size specification like 16K into an integral number of bytes. **/ -BOOL conv_str_size(const char * str, uint64_t * val) +_PUBLIC_ BOOL conv_str_size(const char * str, uint64_t * val) { char * end = NULL; unsigned long long lval; @@ -1192,7 +1192,7 @@ BOOL conv_str_size(const char * str, uint64_t * val) return True; } -BOOL conv_str_u64(const char * str, uint64_t * val) +_PUBLIC_ BOOL conv_str_u64(const char * str, uint64_t * val) { char * end = NULL; unsigned long long lval; diff --git a/source4/lib/util/util_strlist.c b/source4/lib/util/util_strlist.c index e3d5126029..48ddbde9e1 100644 --- a/source4/lib/util/util_strlist.c +++ b/source4/lib/util/util_strlist.c @@ -31,7 +31,7 @@ separator list. The separator list must contain characters less than or equal to 0x2f for this to work correctly on multi-byte strings */ -const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) +_PUBLIC_ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep) { int num_elements = 0; const char **ret = NULL; @@ -81,7 +81,7 @@ const char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char * * Entries are seperated by spaces and can be enclosed by quotes. * Does NOT support escaping */ -const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep) +_PUBLIC_ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const char *sep) { int num_elements = 0; const char **ret = NULL; @@ -140,7 +140,7 @@ const char **str_list_make_shell(TALLOC_CTX *mem_ctx, const char *string, const /** * join a list back to one string */ -char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator) +_PUBLIC_ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator) { char *ret = NULL; int i; @@ -159,7 +159,7 @@ char *str_list_join(TALLOC_CTX *mem_ctx, const char **list, char seperator) /** join a list back to one (shell-like) string; entries * seperated by spaces, using quotes where necessary */ -char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep) +_PUBLIC_ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep) { char *ret = NULL; int i; @@ -185,7 +185,7 @@ char *str_list_join_shell(TALLOC_CTX *mem_ctx, const char **list, char sep) /** return the number of elements in a string list */ -size_t str_list_length(const char **list) +_PUBLIC_ size_t str_list_length(const char **list) { size_t ret; for (ret=0;list && list[ret];ret++) /* noop */ ; @@ -196,7 +196,7 @@ size_t str_list_length(const char **list) /** copy a string list */ -const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) +_PUBLIC_ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) { int i; const char **ret = talloc_array(mem_ctx, const char *, str_list_length(list)+1); @@ -216,7 +216,7 @@ const char **str_list_copy(TALLOC_CTX *mem_ctx, const char **list) /** Return true if all the elements of the list match exactly. */ -BOOL str_list_equal(const char **list1, const char **list2) +_PUBLIC_ BOOL str_list_equal(const char **list1, const char **list2) { int i; @@ -239,7 +239,7 @@ BOOL str_list_equal(const char **list1, const char **list2) /** add an entry to a string list */ -const char **str_list_add(const char **list, const char *s) +_PUBLIC_ const char **str_list_add(const char **list, const char *s) { size_t len = str_list_length(list); const char **ret; @@ -258,7 +258,7 @@ const char **str_list_add(const char **list, const char *s) /** remove an entry from a string list */ -void str_list_remove(const char **list, const char *s) +_PUBLIC_ void str_list_remove(const char **list, const char *s) { int i; @@ -276,7 +276,7 @@ void str_list_remove(const char **list, const char *s) /** return True if a string is in a list */ -BOOL str_list_check(const char **list, const char *s) +_PUBLIC_ BOOL str_list_check(const char **list, const char *s) { int i; @@ -289,7 +289,7 @@ BOOL str_list_check(const char **list, const char *s) /** return True if a string is in a list, case insensitively */ -BOOL str_list_check_ci(const char **list, const char *s) +_PUBLIC_ BOOL str_list_check_ci(const char **list, const char *s) { int i; |