Changeset 132 for trunk/include


Ignore:
Timestamp:
Oct 23, 2007, 11:44:41 PM (17 years ago)
Author:
rainer
Message:

Make utility functions thread-safe.

Location:
trunk/include
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/samhain.h

    r131 r132  
    4545#define SH_GRBUF_SIZE  4096
    4646#define SH_PWBUF_SIZE  4096
     47#define SH_ERRBUF_SIZE   64
    4748
    4849/* Sizes for arrays (user, group, timestamp).
  • trunk/include/sh_error.h

    r86 r132  
    176176/* error messages
    177177 */
    178 /*@owned@*/char * sh_error_message (int tellme);
     178/*@owned@*/char * sh_error_message (int tellme, char * str, size_t len);
    179179
    180180/* switch on/off log to file temporarily
  • trunk/include/sh_pthread.h

    r130 r132  
    2323        } while (0)
    2424
     25#define SH_MUTEX_LOCK_UNSAFE(M) pthread_mutex_lock(&(M))
     26#define SH_MUTEX_UNLOCK_UNSAFE(M) pthread_mutex_unlock(&(M))
    2527
    2628#else
     
    3234#define SH_MUTEX_LOCK(M)                        ((void)0)
    3335#define SH_MUTEX_UNLOCK(M)                      ((void)0)
     36#define SH_MUTEX_LOCK_UNSAFE(M)                 ((void)0)
     37#define SH_MUTEX_UNLOCK_UNSAFE(M)               ((void)0)
    3438
    3539/* #ifdef HAVE_PTHREAD */
  • trunk/include/sh_tools.h

    r27 r132  
    1616
    1717#ifdef SH_ENCRYPT
    18 char * errorExplain (int err_num);
     18/* returns pointer to errbuf
     19 */
     20char * errorExplain (int err_num, char * errbuf, size_t len);
    1921#endif
    2022
     23/* returns allocated buffer
     24 */
    2125char * sh_tools_safe_name(const char * str, int flag);
    2226int is_numeric (const char * address);
     
    2630                    char * ecall, int * errnum, char * errmsg, int errsiz);
    2731void delete_cache(void);
    28 char * sh_tools_errmessage (int tellme);
     32
     33/* returns pointer to errbuf
     34 */
     35char * sh_tools_errmessage (int tellme, char * errbuf, size_t len);
    2936
    3037
     
    4148int check_request_nerr (char * have, char * need);
    4249
     50/* returns allocated buffer
     51 */
    4352char * hash_me (char * key, char * buf,   int buflen);
    4453int sh_tools_hash_vfy(char * key, char * buf, int buflen);
    4554
     55/* returns allocated buffer
     56 */
    4657char * get_client_conf_file (char * peer, unsigned long * length);
     58
     59/* returns allocated buffer
     60 */
    4761char * get_client_data_file (char * peer, unsigned long * length);
    4862
  • trunk/include/sh_unix.h

    r114 r132  
    291291int  sh_unix_init(int goDaemon);
    292292
    293 /* for local time use thetime = 0
    294  */
    295 /*@owned@*/ char * sh_unix_time (time_t thetime);
    296 
    297 /* convert to GMT time
    298  */
    299 char * sh_unix_gmttime (time_t thetime);
     293/* for local time use thetime = 0, returns pointer to buffer
     294 */
     295char * sh_unix_time (time_t thetime, char * buffer, size_t len);
     296
     297/* convert to GMT time, returns pointer to buffer
     298 */
     299char * sh_unix_gmttime (time_t thetime, char * buffer, size_t len);
    300300
    301301/* effective user info
     
    303303int  sh_unix_getUser (void);
    304304
    305 /* get home directory
    306  */
    307 char *  sh_unix_getUIDdir (int level, uid_t uid);
     305/* get home directory, , returns pointer to out
     306 */
     307char *  sh_unix_getUIDdir (int level, uid_t uid, char * out, size_t len);
    308308
    309309
  • trunk/include/sh_utils.h

    r93 r132  
    4343} st_format;
    4444
     45/* returns allocated string
     46 */
    4547char * sh_util_formatted (const char * fmt, st_format * ftab);
    4648
     
    6062int    taus_seed           (void);
    6163
     64/* returns allocated memory
     65 */
    6266char * sh_util_strdup (const char * str);
     67
     68/* returns allocated memory
     69 */
    6370char * sh_util_strdup_l (const char * str, size_t len);
     71
     72/* returns pointer within str
     73 */
    6474char * sh_util_strsep (char **str, const char *delim);
    6575
    66 /* compactify verbose acl text
     76/* compactify verbose acl text, returns allocated memory
    6777 */
    6878char * sh_util_acl_compact (char * buf, ssize_t len);
     
    146156
    147157/* returns freshly allocated memory, return value should be free'd.
    148  * Arhument list must be NULL terminated.
     158 * Argument list must be NULL terminated.
    149159 */
    150160char * sh_util_strconcat (const char * arg1, ...) SH_GNUC_NULL_TERMINATED;
Note: See TracChangeset for help on using the changeset viewer.