|
|
|
@@ -29,67 +29,61 @@ |
|
|
|
#include <process.h> |
|
|
|
#endif |
|
|
|
|
|
|
|
#define DEFAULT_TMP_DIR "/tmp" |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
namespace Jack { |
|
|
|
|
|
|
|
void JackTools::KillServer() |
|
|
|
{ |
|
|
|
#ifdef WIN32 |
|
|
|
exit(1); |
|
|
|
#else |
|
|
|
kill(GetPID(), SIGINT); |
|
|
|
#endif |
|
|
|
} |
|
|
|
char* jack_tmpdir = (char*)DEFAULT_TMP_DIR; |
|
|
|
|
|
|
|
void JackTools::ThrowJackNetException() |
|
|
|
{ |
|
|
|
throw JackNetException(); |
|
|
|
} |
|
|
|
|
|
|
|
int JackTools::MkDir(const char* path) |
|
|
|
{ |
|
|
|
void JackTools::RewriteName(const char* name, char* new_name) |
|
|
|
{ |
|
|
|
size_t i; |
|
|
|
for (i = 0; i < strlen(name); i++) { |
|
|
|
if ((name[i] == '/') || (name[i] == '\\')) |
|
|
|
new_name[i] = '_'; |
|
|
|
else |
|
|
|
new_name[i] = name[i]; |
|
|
|
} |
|
|
|
new_name[i] = '\0'; |
|
|
|
} |
|
|
|
|
|
|
|
const char* JackTools::DefaultServerName() |
|
|
|
{ |
|
|
|
const char* server_name; |
|
|
|
if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL) |
|
|
|
server_name = JACK_DEFAULT_SERVER_NAME; |
|
|
|
return server_name; |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
|
return CreateDirectory(path, NULL) == 0; |
|
|
|
#else |
|
|
|
return mkdir(path, 0777) != 0; |
|
|
|
#endif |
|
|
|
void JackTools::KillServer() |
|
|
|
{ |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
#define DEFAULT_TMP_DIR "/tmp" |
|
|
|
char* jack_tmpdir = (char*)DEFAULT_TMP_DIR; |
|
|
|
int JackTools::MkDir(const char* path) |
|
|
|
{ |
|
|
|
return CreateDirectory(path, NULL) == 0; |
|
|
|
} |
|
|
|
|
|
|
|
int JackTools::GetPID() |
|
|
|
{ |
|
|
|
#ifdef WIN32 |
|
|
|
return _getpid(); |
|
|
|
#else |
|
|
|
return getpid(); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
int JackTools::GetUID() |
|
|
|
{ |
|
|
|
#ifdef WIN32 |
|
|
|
return _getpid(); |
|
|
|
//#error "No getuid function available" |
|
|
|
#else |
|
|
|
return getuid(); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
const char* JackTools::DefaultServerName() |
|
|
|
{ |
|
|
|
const char* server_name; |
|
|
|
if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL) |
|
|
|
server_name = JACK_DEFAULT_SERVER_NAME; |
|
|
|
return server_name; |
|
|
|
} |
|
|
|
|
|
|
|
/* returns the name of the per-user subdirectory of jack_tmpdir */ |
|
|
|
#ifdef WIN32 |
|
|
|
|
|
|
|
char* JackTools::UserDir() |
|
|
|
{ |
|
|
|
return ""; |
|
|
|
@@ -107,7 +101,62 @@ namespace Jack { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
void BuildClientPath(char* path_to_so, int path_len, const char* so_name) |
|
|
|
{ |
|
|
|
snprintf(path_to_so, path_len, ADDON_DIR "/%s.dll", so_name); |
|
|
|
} |
|
|
|
|
|
|
|
void PrintLoadError(const char* so_name) |
|
|
|
{ |
|
|
|
// Retrieve the system error message for the last-error code |
|
|
|
LPVOID lpMsgBuf; |
|
|
|
LPVOID lpDisplayBuf; |
|
|
|
DWORD dw = GetLastError(); |
|
|
|
|
|
|
|
FormatMessage( |
|
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | |
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM | |
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS, |
|
|
|
NULL, |
|
|
|
dw, |
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
|
|
(LPTSTR) &lpMsgBuf, |
|
|
|
0, NULL ); |
|
|
|
|
|
|
|
// Display the error message and exit the process |
|
|
|
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, |
|
|
|
(lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)so_name) + 40) * sizeof(TCHAR)); |
|
|
|
_snprintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), |
|
|
|
TEXT("error loading %s err = %s"), so_name, lpMsgBuf); |
|
|
|
|
|
|
|
jack_error((LPCTSTR)lpDisplayBuf); |
|
|
|
|
|
|
|
LocalFree(lpMsgBuf); |
|
|
|
LocalFree(lpDisplayBuf); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#else |
|
|
|
void JackTools::KillServer() |
|
|
|
{ |
|
|
|
kill(GetPID(), SIGINT); |
|
|
|
} |
|
|
|
|
|
|
|
int JackTools::MkDir(const char* path) |
|
|
|
{ |
|
|
|
return mkdir(path, 0777) != 0; |
|
|
|
} |
|
|
|
|
|
|
|
int JackTools::GetPID() |
|
|
|
{ |
|
|
|
return getpid(); |
|
|
|
} |
|
|
|
|
|
|
|
int JackTools::GetUID() |
|
|
|
{ |
|
|
|
return getuid(); |
|
|
|
} |
|
|
|
|
|
|
|
char* JackTools::UserDir() |
|
|
|
{ |
|
|
|
static char user_dir[JACK_PATH_MAX + 1] = ""; |
|
|
|
@@ -124,7 +173,6 @@ namespace Jack { |
|
|
|
return user_dir; |
|
|
|
} |
|
|
|
|
|
|
|
/* returns the name of the per-server subdirectory of jack_user_dir() */ |
|
|
|
char* JackTools::ServerDir(const char* server_name, char* server_dir) |
|
|
|
{ |
|
|
|
/* format the path name into the suppled server_dir char array, |
|
|
|
@@ -223,75 +271,23 @@ namespace Jack { |
|
|
|
pclose(in); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
void JackTools::RewriteName(const char* name, char* new_name) |
|
|
|
void BuildClientPath(char* path_to_so, int path_len, const char* so_name) |
|
|
|
{ |
|
|
|
size_t i; |
|
|
|
for (i = 0; i < strlen(name); i++) { |
|
|
|
if ((name[i] == '/') || (name[i] == '\\')) |
|
|
|
new_name[i] = '_'; |
|
|
|
else |
|
|
|
new_name[i] = name[i]; |
|
|
|
const char* internal_dir; |
|
|
|
if ((internal_dir = getenv("JACK_INTERNAL_DIR")) == 0) { |
|
|
|
if ((internal_dir = getenv("JACK_DRIVER_DIR")) == 0) { |
|
|
|
internal_dir = ADDON_DIR; |
|
|
|
} |
|
|
|
} |
|
|
|
new_name[i] = '\0'; |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
|
|
|
|
|
void BuildClientPath(char* path_to_so, int path_len, const char* so_name) |
|
|
|
{ |
|
|
|
snprintf(path_to_so, path_len, ADDON_DIR "/%s.dll", so_name); |
|
|
|
} |
|
|
|
|
|
|
|
void PrintLoadError(const char* so_name) |
|
|
|
{ |
|
|
|
// Retrieve the system error message for the last-error code |
|
|
|
LPVOID lpMsgBuf; |
|
|
|
LPVOID lpDisplayBuf; |
|
|
|
DWORD dw = GetLastError(); |
|
|
|
|
|
|
|
FormatMessage( |
|
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | |
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM | |
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS, |
|
|
|
NULL, |
|
|
|
dw, |
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
|
|
(LPTSTR) &lpMsgBuf, |
|
|
|
0, NULL ); |
|
|
|
|
|
|
|
// Display the error message and exit the process |
|
|
|
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, |
|
|
|
(lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)so_name) + 40) * sizeof(TCHAR)); |
|
|
|
_snprintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), |
|
|
|
TEXT("error loading %s err = %s"), so_name, lpMsgBuf); |
|
|
|
|
|
|
|
jack_error((LPCTSTR)lpDisplayBuf); |
|
|
|
|
|
|
|
LocalFree(lpMsgBuf); |
|
|
|
LocalFree(lpDisplayBuf); |
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
void PrintLoadError(const char* so_name) |
|
|
|
{ |
|
|
|
jack_log("error loading %s err = %s", so_name, dlerror()); |
|
|
|
} |
|
|
|
|
|
|
|
void BuildClientPath(char* path_to_so, int path_len, const char* so_name) |
|
|
|
{ |
|
|
|
const char* internal_dir; |
|
|
|
if ((internal_dir = getenv("JACK_INTERNAL_DIR")) == 0) { |
|
|
|
if ((internal_dir = getenv("JACK_DRIVER_DIR")) == 0) { |
|
|
|
internal_dir = ADDON_DIR; |
|
|
|
} |
|
|
|
snprintf(path_to_so, path_len, "%s/%s.so", internal_dir, so_name); |
|
|
|
} |
|
|
|
|
|
|
|
snprintf(path_to_so, path_len, "%s/%s.so", internal_dir, so_name); |
|
|
|
} |
|
|
|
|
|
|
|
void PrintLoadError(const char* so_name) |
|
|
|
{ |
|
|
|
jack_log("error loading %s err = %s", so_name, dlerror()); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
template <class T> |
|
|
|
|