From 48228cae2eaa0847b07f899811dd7f0ab8a7365e Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 28 Jan 2014 10:38:36 -0800 Subject: common: added shm to os_calls --- common/os_calls.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'common/os_calls.c') diff --git a/common/os_calls.c b/common/os_calls.c index 2d5b4280..bb26d246 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include #include @@ -3118,3 +3120,17 @@ g_text2bool(const char *s) } return 0; } + +/*****************************************************************************/ +void * APP_CC +g_shmat(int shmid) +{ + return shmat(shmid, 0, 0); +} + +/*****************************************************************************/ +int APP_CC +g_shmdt(const void *shmaddr) +{ + return shmdt(shmaddr); +} -- cgit v1.2.1 From 4e6d57dbe5cf231648425c686265ecc9bb8c5b7b Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 8 Feb 2014 18:05:52 -0800 Subject: common: some notes and compile fixes --- common/os_calls.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'common/os_calls.c') diff --git a/common/os_calls.c b/common/os_calls.c index bb26d246..ee9792b1 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1,7 +1,7 @@ /** * xrdp: A Remote Desktop Protocol server. * - * Copyright (C) Jay Sorg 2004-2013 + * Copyright (C) Jay Sorg 2004-2014 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,11 @@ * put all the os / arch define in here you want */ +/* To test for Windows (64 bit or 32 bit) use _WIN32 and _WIN64 in addition + for 64 bit windows. _WIN32 is defined for both. + To test for Linux use __linux__. + To test for BSD use BSD */ + #if defined(HAVE_CONFIG_H) #include "config_ac.h" #endif @@ -60,6 +65,13 @@ #include #include +/* this is so we can use #ifdef BSD later */ +/* This is the recommended way of detecting BSD in the + FreeBSD Porter's Handbook. */ +#if (defined(__unix__) || defined(unix)) && !defined(USG) +#include +#endif + #include "os_calls.h" #include "arch.h" #include "log.h" @@ -596,9 +608,11 @@ g_tcp_local_socket(void) } /*****************************************************************************/ +/* returns error */ int APP_CC g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) { +#if defined(SO_PEERCRED) int ucred_length; struct myucred { @@ -625,6 +639,9 @@ g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) *gid = credentials.gid; } return 0; +#else + return 1; +#endif } /*****************************************************************************/ @@ -3122,15 +3139,25 @@ g_text2bool(const char *s) } /*****************************************************************************/ +/* returns pointer or nil on error */ void * APP_CC g_shmat(int shmid) { - return shmat(shmid, 0, 0); +#if defined(_WIN32) + return 0; +#else + return shmat(shmid, 0, 0); +#endif } /*****************************************************************************/ +/* returns -1 on error */ int APP_CC g_shmdt(const void *shmaddr) { +#if defined(_WIN32) + return -1; +#else return shmdt(shmaddr); +#endif } -- cgit v1.2.1 From 43e388b7e5e6bea5c79a462afc24edbf91de91fd Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 8 Feb 2014 21:48:44 -0800 Subject: remove some warning, move gethostname to os_calls --- common/os_calls.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'common/os_calls.c') diff --git a/common/os_calls.c b/common/os_calls.c index ee9792b1..80b2d235 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -613,7 +613,11 @@ int APP_CC g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid) { #if defined(SO_PEERCRED) +#if defined(_WIN32) int ucred_length; +#else + unsigned int ucred_length; +#endif struct myucred { pid_t pid; @@ -3151,7 +3155,7 @@ g_shmat(int shmid) } /*****************************************************************************/ -/* returns -1 on error */ +/* returns -1 on error 0 on success */ int APP_CC g_shmdt(const void *shmaddr) { @@ -3161,3 +3165,11 @@ g_shmdt(const void *shmaddr) return shmdt(shmaddr); #endif } + +/*****************************************************************************/ +/* returns -1 on error 0 on success */ +int APP_CC +g_gethostname(char *name, int len) +{ + return gethostname(name, len); +} -- cgit v1.2.1