NetSim Source Code Help
Loading...
Searching...
No Matches
Linux.h
Go to the documentation of this file.
1/************************************************************************************
2 * Copyright (C) 2015 *
3 * TETCOS, Bangalore. India *
4 * *
5 * Tetcos owns the intellectual property rights in the Product and its content. *
6 * The copying, redistribution, reselling or publication of any or all of the *
7 * Product or its content without express prior written consent of Tetcos is *
8 * prohibited. Ownership and / or any other right relating to the software and all *
9 * intellectual property rights therein shall remain at all times with Tetcos. *
10 * *
11 * Author: Shashi kant suman *
12 * *
13 * ---------------------------------------------------------------------------------*/
14
15#ifndef LINUX_HEADER
16#define LINUX_HEADER
17
18#include <string.h>
19#include <errno.h>
20#include <math.h>
21#include <ctype.h>
22#include <dlfcn.h>
23#include <pthread.h>
24#include <time.h>
25#include <malloc.h>// _msize
26#include <unistd.h> //for close()
27#include <sys/time.h> //gettimeofday
28#include <sys/types.h>
29
30#define INT8 int8_t
31#define UINT8 uint8_t
32#define INT16 int16_t
33#define UINT16 uint16_t
34#define INT32 int32_t
35#define UINT32 uint32_t
36#define INT64 int64_t
37#define UINT64 uint64_t
38#define UINT unsigned int
39
40#define _declspec(dllexport) extern
41#define _declspec(dllimport) extern
42#define GetLastError() errno
43//#define _putenv putenv
44#define _getch();
45#define getch();
46#define PVOID void*
47# define HINSTANCE void*
48# define LoadLibraryA(x) dlopen(x,RTLD_NOW)
49# define LoadLibrary(x) dlopen(x,RTLD_NOW)
50# define GetProcAddress(x,y) dlsym(x,y)
51# define FreeLibrary dlclose
52# define MessageBoxA(a,b,c,d) printf("%s\t%s\n",b,c);
53# define MessageBox(a,b,c,d) printf("%s\t%s\n",b,c);
54# define fnDlError(x){printf("Error: %s\n",dlerror());}
55# define fnSystemError(x,...){printf("Error No:%d in %s line no %d: %s\n",errno,__FILE__,__LINE__,x);}
56# define fnNetSimError(x,...){printf("In %s line no %d: %s",__FILE__,__LINE__,x);}
57# define GetCurrentThreadId() pthread_self()
58# define WriteFile(file,str,size,a,b) write(file,str,size)
59#define BOOLEAN BOOL
60
61typedef enum
62{
65}BOOL;
66
67
68typedef struct _LARGE_INTEGER {
69 long long QuadPart;
71static const char pathSeperator[5] = "/";
72// static const char libext[10] = ".so";
73#define HANDLE void *
74#define HMODULE void*
75#define pthread_mutex_destroy(a) ReleaseMutex(a)
76#define FALSE 0
77#define TRUE 1
78#define WORD unsigned short
79#define DWORD unsigned int
80#define WINAPI
81#define LPVOID void *
82#define INFINITE INFINITY
83#define WaitForSingleObject(mutexObject,b) pthread_mutex_lock( mutexObject )
84#define ReleaseMutex(mutexObject) pthread_mutex_unlock(mutexObject)
85typedef struct _SYSTEMTIME {
95#define _popen(a,b) popen(a,b)
96#define _pclose(a) pclose(a)
97#define CRITICAL_SECTION pthread_mutex_t;
98#define FARPROC void *
99#define EnterCriticalSection(a) pthread_mutex_lock (a);
100#define LeaveCriticalSection(a) pthread_mutex_unlock (a);
101#define DeleteCriticalSection(a) pthread_mutex_destroy (a);
102#define CreateMutexA CreateMutex
103#define CloseHandle(mutex) pthread_mutex_destroy(mutex);
104#define Sleep(x) usleep(1000*x) //usleep takes in microscecond
105#define _fcloseall() fcloseall()
106#define min(a,b) !(b<a)?a:b
107#define max(a,b) !(b>a)?a:b
108#define __debugbreak()
109typedef unsigned char u_char;
110typedef unsigned short u_short;
111typedef unsigned int u_int;
112typedef unsigned long u_long;
113#define __in
114#define __out
115
116//Thread function
117void* CreateMutex(void* att,int a,char* name);
118void WaitForMultipleObjects(DWORD nCount,const pthread_mutex_t *lpHandles,int bWaitAll, DWORD dwMilliseconds);
119
120
121//String macros
122#define _strrev strrev
123#ifdef _strdup
124#undef _strdup
125#endif
126#define _strdup(x) x==NULL?NULL:strdup(x)
127#define _stricmp strcasecmp
128#define stricmp strcasecmp
129
130//String function
131char *_strrev(char *str);
132char* _strupr( char* s );
133
134
135
136
137//Time function
138void GetSystemTime(struct _SYSTEMTIME *lp);
140
141
142//Memory function
143int _msize(void* p);
144
145//error function
146#define SetLastError(x) errno=x
147
148//environment function
149void _putenv(char* s);
150#endif //LINUX_HEADER
DWORD GetTickCount()
struct _LARGE_INTEGER LARGE_INTEGER
char * _strupr(char *s)
BOOL
Definition: Linux.h:62
void WaitForMultipleObjects(DWORD nCount, const pthread_mutex_t *lpHandles, int bWaitAll, DWORD dwMilliseconds)
#define WORD
Definition: Linux.h:78
struct _SYSTEMTIME SYSTEMTIME
#define _strrev
Definition: Linux.h:122
unsigned long u_long
Definition: Linux.h:112
void * CreateMutex(void *att, int a, char *name)
static const char pathSeperator[5]
Definition: Linux.h:71
unsigned short u_short
Definition: Linux.h:110
#define DWORD
Definition: Linux.h:79
#define TRUE
Definition: Linux.h:77
#define FALSE
Definition: Linux.h:76
void _putenv(char *s)
unsigned int u_int
Definition: Linux.h:111
void GetSystemTime(struct _SYSTEMTIME *lp)
unsigned char u_char
Definition: Linux.h:109
#define _msize(memory)
Definition: Memory.h:33
static struct stru_802_11_Phy_Parameters_HT a
long long QuadPart
Definition: Linux.h:69
WORD wYear
Definition: Linux.h:86
WORD wMilliseconds
Definition: Linux.h:93
WORD wMonth
Definition: Linux.h:87
WORD wHour
Definition: Linux.h:90
WORD wSecond
Definition: Linux.h:92
WORD wMinute
Definition: Linux.h:91
WORD wDay
Definition: Linux.h:89
WORD wDayOfWeek
Definition: Linux.h:88