some solaris fixes and add some funcs for sesman

ulab-original
jsorg71 19 years ago
parent f9b3faac0e
commit 2990d6daa7

@ -26,6 +26,10 @@
#include <windows.h>
#include <winsock.h>
#else
/* fix for solaris 10 with gcc 3.3.2 problem */
#if defined(sun) || defined(__sun)
#define ctid_t id_t
#endif
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
@ -43,6 +47,7 @@
#include <fcntl.h>
#include <pwd.h>
#include <time.h>
#include <grp.h>
#endif
#include <stdlib.h>
@ -56,6 +61,14 @@
extern char** environ;
#endif
/* for solaris */
#if !defined(PF_LOCAL)
#define PF_LOCAL AF_UNIX
#endif
#if !defined(INADDR_NONE)
#define INADDR_NONE ((unsigned long)-1)
#endif
/*****************************************************************************/
void*
g_malloc(int size, int zero)
@ -733,6 +746,17 @@ g_strncmp(char* c1, char* c2, int len)
return strncmp(c1, c2, len);
}
/*****************************************************************************/
int
g_strcasecmp(char* c1, char* c2)
{
#if defined(_WIN32)
return stricmp(c1, c2);
#else
return strcasecmp(c1, c2);
#endif
}
/*****************************************************************************/
int
g_strncasecmp(char* c1, char* c2, int len)
@ -818,6 +842,17 @@ g_system(char* aexec)
#endif
}
/*****************************************************************************/
char*
g_get_strerror(void)
{
#if defined(_WIN32)
return 0;
#else
return strerror(errno);
#endif
}
/*****************************************************************************/
void
g_execvp(char* p1, char* args[])
@ -1004,11 +1039,13 @@ g_sigterm(int pid)
}
/*****************************************************************************/
/* returns 0 if ok */
int
g_getuser_info(char* username, int* gid, int* uid, char* shell, char* dir,
char* gecos)
{
#if defined(_WIN32)
return 1;
#else
struct passwd* pwd_1;
@ -1035,9 +1072,65 @@ g_getuser_info(char* username, int* gid, int* uid, char* shell, char* dir,
{
g_strcpy(gecos, pwd_1->pw_gecos);
}
return 0;
}
return 1;
#endif
}
/*****************************************************************************/
/* returns 0 if ok */
int
g_getgroup_info(char* groupname, int* gid)
{
#if defined(_WIN32)
return 1;
#else
struct group* g;
g = getgrnam(groupname);
if (g != 0)
{
if (gid != 0)
{
*gid = g->gr_gid;
}
return 0;
}
return 1;
#endif
}
/*****************************************************************************/
/* returns error */
/* if zero is returned, then ok is set */
int
g_check_user_in_group(char* username, int gid, int* ok)
{
#if defined(_WIN32)
return 1;
#else
struct group* groups;
int i;
groups = getgrgid(gid);
if (groups == 0)
{
return 1;
}
*ok = 0;
i = 0;
while (0 != groups->gr_mem[i])
{
if (0 == g_strcmp(groups->gr_mem[i], username))
{
*ok = 1;
break;
}
i++;
}
return 0;
#endif
}
/*****************************************************************************/

@ -122,6 +122,8 @@ g_strcmp(char* c1, char* c2);
int
g_strncmp(char* c1, char* c2, int len);
int
g_strcasecmp(char* c1, char* c2);
int
g_strncasecmp(char* c1, char* c2, int len);
int
g_atoi(char* str);
@ -135,6 +137,8 @@ void*
g_get_proc_address(long lib, char* name);
int
g_system(char* aexec);
char*
g_get_strerror(void);
void
g_execvp(char* p1, char* args[]);
int
@ -174,6 +178,10 @@ int
g_getuser_info(char* username, int* gid, int* uid, char* shell, char* dir,
char* gecos);
int
g_getgroup_info(char* groupname, int* gid);
int
g_check_user_in_group(char* username, int gid, int* ok);
int
g_time1(void);
#endif

Loading…
Cancel
Save