diff options
Diffstat (limited to 'common')
| -rw-r--r-- | common/os_calls.c | 18 | ||||
| -rw-r--r-- | common/os_calls.h | 6 |
2 files changed, 14 insertions, 10 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index dbef8da6..2c8e37cd 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -207,14 +207,17 @@ g_sprintf(char *dest, const char *format, ...) } /*****************************************************************************/ -void DEFAULT_CC +int DEFAULT_CC g_snprintf(char *dest, int len, const char *format, ...) { + int err; va_list ap; va_start(ap, format); - vsnprintf(dest, len, format, ap); + err = vsnprintf(dest, len, format, ap); va_end(ap); + + return err; } /*****************************************************************************/ @@ -2995,10 +2998,11 @@ g_sigterm(int pid) /*****************************************************************************/ /* returns 0 if ok */ +/* the caller is responsible to free the buffs */ /* does not work in win32 */ int APP_CC -g_getuser_info(const char *username, int *gid, int *uid, char *shell, - char *dir, char *gecos) +g_getuser_info(const char *username, int *gid, int *uid, char **shell, + char **dir, char **gecos) { #if defined(_WIN32) return 1; @@ -3021,17 +3025,17 @@ g_getuser_info(const char *username, int *gid, int *uid, char *shell, if (dir != 0) { - g_strcpy(dir, pwd_1->pw_dir); + *dir = g_strdup(pwd_1->pw_dir); } if (shell != 0) { - g_strcpy(shell, pwd_1->pw_shell); + *shell = g_strdup(pwd_1->pw_shell); } if (gecos != 0) { - g_strcpy(gecos, pwd_1->pw_gecos); + *gecos = g_strdup(pwd_1->pw_gecos); } return 0; diff --git a/common/os_calls.h b/common/os_calls.h index 2ed2cb81..9f0e61fb 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -61,7 +61,7 @@ void APP_CC g_free(void* ptr); void DEFAULT_CC g_printf(const char *format, ...) printflike(1, 2); void DEFAULT_CC g_sprintf(char* dest, const char* format, ...) \ printflike(2, 3); -void DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...) \ +int DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...) \ printflike(3, 4); void DEFAULT_CC g_writeln(const char* format, ...) printflike(1, 2); void DEFAULT_CC g_write(const char* format, ...) printflike(1, 2); @@ -179,8 +179,8 @@ char* APP_CC g_getenv(const char* name); int APP_CC g_exit(int exit_code); int APP_CC g_getpid(void); int APP_CC g_sigterm(int pid); -int APP_CC g_getuser_info(const char* username, int* gid, int* uid, char* shell, - char* dir, char* gecos); +int APP_CC g_getuser_info(const char* username, int* gid, int* uid, char** shell, + char** dir, char** gecos); int APP_CC g_getgroup_info(const char* groupname, int* gid); int APP_CC g_check_user_in_group(const char* username, int gid, int* ok); int APP_CC g_time1(void); |
