Touches..

This commit is contained in:
David Anderson 2004-02-07 21:23:24 +00:00
parent b773a2784c
commit 8f68eb9457
2 changed files with 99 additions and 1 deletions

View File

@ -1,4 +1,11 @@
#define VERSION "0.73" #ifdef __linux__
#include <malloc.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <sched.h>
#endif
#define VERSION "0.74"
plugin_info_t Plugin_info = { plugin_info_t Plugin_info = {
@ -85,6 +92,10 @@ void (*function)(void*);
void (*endfunction)(void*); void (*endfunction)(void*);
#ifdef __linux__
int thread_fork(void *arg);
#endif
#define AMS_OFFSET 0.01 #define AMS_OFFSET 0.01
#define SPEAK_NORMAL 0 #define SPEAK_NORMAL 0
@ -886,3 +897,13 @@ struct MsgSets
MessageInfo *msg; MessageInfo *msg;
AmxCallList msgCalls; AmxCallList msgCalls;
}; };
#ifdef __linux__
int thread_fork(void *arg)
{
char *szCmd;
szCmd = (char*)arg;
system(szCmd);
return 0;
}
#endif

View File

@ -47,6 +47,8 @@ MsgSets Msg[MAX_MESSAGES];
int LastMessage; int LastMessage;
cvar_t amxxe_version = {"amxxe_version", VERSION, FCVAR_SERVER, 0}; cvar_t amxxe_version = {"amxxe_version", VERSION, FCVAR_SERVER, 0};
/******************************************************** /********************************************************
vexd's utility funcs vexd's utility funcs
@ -475,6 +477,78 @@ static cell AMX_NATIVE_CALL get_offset_float(AMX *amx, cell *params)
return 1; return 1;
} }
//(BAILOPAN)
//return operating system
static cell AMX_NATIVE_CALL get_system_os(AMX *amx, cell *params)
{
int iLen = params[2];
#ifndef __linux__
char *szOS = "win32";
#else
char *szOS = "linux";
#endif
return SET_AMXSTRING(amx, params[1], szOS, iLen);
}
//(BAILOPAN)
//Allows you to issue a command to the operating system.
static cell AMX_NATIVE_CALL system_cmd(AMX *amx, cell *params)
{
int i_apptype = params[1];
int iLen, retVal, iLen2;
char *szCommand = AMX_GET_STRING(amx, params[2], iLen);
char *szDirectory = AMX_GET_STRING(amx, params[3], iLen2);
#ifndef __linux__
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
if (!i_apptype) {
if (!CreateProcess(NULL, (LPTSTR)szCommand, NULL, NULL, FALSE, 0, NULL, (LPCTSTR)szDirectory, &si, &pi)) {
return 0;
} else {
retVal = 1;
}
} else if (i_apptype == 1) {
if (!CreateProcess((LPCTSTR)szCommand, NULL, NULL, NULL, FALSE, 0, NULL, (LPCTSTR)szDirectory, &si, &pi)) {
return 0;
} else {
retVal = 1;
}
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
#else
void *stack;
pid_t pid;
if (!app_type) {
app_type = 64;
}
stack = malloc(app_type * 64);
if (stack == 0) {
return -1;
}
pid = clone(&thread_fork, (char *)stack + app_type*64, 0, szCommand);
if (pid == -1) {
return -1;
}
pid = waitpid(pid, 0, 0);
if (pid == -1) {
return -1;
}
free(stack);
retval = 1;
#endif
return retVal;
}
// Get an integer from an entities entvars. // Get an integer from an entities entvars.
// (vexd) // (vexd)
@ -3135,6 +3209,9 @@ AMX_NATIVE_INFO Engine_Natives[] = {
{"get_msg_args", get_msg_args}, {"get_msg_args", get_msg_args},
{"get_msg_argtype", get_msg_argtype}, {"get_msg_argtype", get_msg_argtype},
{"get_system_os", get_system_os},
{"system_cmd", system_cmd},
{ NULL, NULL } { NULL, NULL }
}; };