include/df/osapi.hpp

00001 
00002 // OS Core API
00003 
00005 class OSAPI {  //can NOT inherit SystemCode!!!
00006   public:
00007     static void SetLastError(uint32 ErrCode, Thread *thread);
00008     static uint32 GetLastError(Thread *);
00009     static char **GetEnvironmentStrings();
00010     static BOOL GetEnvironmentVariable(char *vname, String &);
00011     static BOOL SetEnvironmentVariable(char *vname, char *vdata);
00012 
00013     static BOOL GetExecutableFilename(String &s);
00014 
00015     static uint32 CreateThread(Thread *, uint32 stacksize);
00016     static void CloseThread(Thread *);
00017     static void ExitThread(uint32 ExitCode);
00018     static uint32 GetCurrentProcessId();
00019     static uint32 GetCurrentThreadHandle();    //handle
00020     static uint32 GetCurrentThreadId();        //must uniquely id thread
00021     static BOOL IsThreadActive(Thread *);
00022     static BOOL TerminateThread(Thread *);
00023     static BOOL ResumeThread(Thread *);
00024     static BOOL SuspendThread(Thread *);
00025 
00026     static void ExitProcess(uint32 ExitCode);  //abrupt hault.
00027 
00028     static void WaitMessage();
00029     static BOOL IsQueueEmpty();
00030     static void ProcessQueue(BOOL);
00031 
00032     static BOOL PostWindowMessage(uint32 window, uint32 msg, iPTR wParam, iPTR lParam);
00033     static BOOL PostMessage(Thread *, uint32 msg, iPTR wParam, iPTR lParam, int = 0, int = 0, int = 0);  //last 3 int's for Linux only
00034 
00035     static BOOL GetComputerName(String &name);
00036     static BOOL ExpandEnvironmentStrings(String &);
00037 
00038     static PTR Alloc(uint32 siz, uint32 flgs = MEM_LOCKED);  //returns mem (MEM_LOCKED) or handle (MEM_UNLOCKED)
00039     static PTR ReAlloc(PTR oldptr, uint32 newsiz);  //only for MEM_LOCKED memory
00040     static BOOL Free(PTR);
00041     static PTR Lock(PTR handle); //returns ptr
00042     static BOOL Unlock(PTR mem);  //will not work on mem that was alloced with MEM_LOCKED
00043 
00044     static uint32 AvailPhysMem();
00045     static uint32 AvailVirMem();
00046 
00047     static BOOL SetTime(Time *t);
00048     static void GetTime(Time *t);
00049     static void Sleep(uint32 x);
00050 
00051     static BOOL Message(char *, char *, BOOL);
00052 
00053     static void RaiseException(char *);  //display message and force exit
00054 
00055     //File IO
00056     static int32 Open(char *fname, int action, int attr, int share);
00057     static BOOL Close(uint32 handle);
00058     static uint32 Seek(uint32 handle, int32 offset, int8 fromwhere);
00059     static uint64 Seek64(uint32 handle, int64 offset, int8 fromwhere);
00060     static int32 Read(uint32 handle, void *buf, int32 siz);
00061     static int32 Write(uint32 handle, void *buf, int32 siz);
00062     static uint32 GetSize(uint32 handle);
00063     static uint64 GetSize64(uint32 handle);
00064     static BOOL SetEof(uint32 handle);
00065     static BOOL GetAttr(char *fname, int32 &attr);
00066     static BOOL SetAttr(char *fname, int32 attr);
00067     static BOOL Delete(char *fname);
00068     static BOOL CreatePath(char *dname);
00069     static BOOL SetCurrentPath(char *dname);
00070     static BOOL GetCurrentPath(String &dname);
00071     static BOOL Sync(uint32 handle);
00072     static BOOL GetShort(String &s, char *l);
00073     static BOOL FindFirst(FileFind *ff, const char *fname);
00074     static BOOL FindNext(FileFind *ff);
00075     static BOOL FindClose(FileFind *ff);
00076     static BOOL Rename(char *oldname, char *newname);
00077     static void GetTempPath(String &s);
00078     static void GetTempFileName(String &s, char *ext = NULL);  //DF/1.5.5
00079     static void GetOSPath(String &s);
00080     static BOOL CopyFile(char *src, char *dest, BOOL overwrite);
00081     static BOOL MoveFile(char *src, char *dest, BOOL overwrite);
00082     static BOOL DeletePath(char *path);
00083     static BOOL GetStartMenuPath(String &path, BOOL AllUsers);
00084     static BOOL GetDesktopPath(String &path);
00085     static BOOL FileGetTime(char *, Time *creation, Time *lastaccess, Time *lastwrite);
00086     static BOOL FileSetTime(char *, Time *creation, Time *lastaccess, Time *lastwrite);
00087     static BOOL Exist(char *);
00088     //DF/1.5.5 - new File members
00089     static BOOL GetDeviceFreeSpace(char *, uint64 &free);
00090     static BOOL IsDeviceRemovable(char *);
00091 
00092     //service stuff
00093     static BOOL SetServiceStatus(BOOL state);
00094 
00095     //Networking API
00096     static BOOL IsWinSock2();
00097     static BOOL SocketFree(uint32 handle);
00098     static BOOL SocketListen(uint32 handle);
00099     static uint32 SocketAlloc(int _sock_type, int _proto_type);
00100     static uint32 SocketAccept(uint32 handle, IPAddr *remote, uint16 *remoteport);
00101     static BOOL SetSocketOption(uint32 handle, int type, int32 state);
00102     static BOOL GetSocketOption(uint32 handle, int type, int32 &state);
00103     static BOOL SocketBind(uint32 handle, uint16 &port, IPAddr &ip);
00104     static BOOL DNSLookup(char *host, IPAddr &ip);
00105     static BOOL DNSReverseLookup(IPAddr &ip, String &host);
00106     static BOOL SocketConnect(uint32 handle, IPAddr &addr, uint16 port, uint32 timeout);
00107     static BOOL SocketDisconnect(uint32 handle);
00108     static BOOL SocketGetLocalIP(uint32 handle, IPAddr &ip);
00109     static BOOL SocketAsyncStartListen(uint32 handle);
00110     static BOOL SocketAsyncStart(uint32 handle);
00111     static BOOL SocketAsyncStop(uint32 handle);
00112     static void SocketUninit();
00113     static BOOL SocketInit();
00114     static uint32 SocketGetLastError();
00115     static int32 SocketStatus(uint32 handle, int flgs);
00116     static int32 SocketWrite(uint32 handle, void *buf, int32 len);
00117     static int32 SocketWrite(uint32 handle, IPAddr &ip, uint16 port, void *buf, int32 len);
00118     static int32 SocketRead(uint32 handle, void *buf, int32 len);
00119     static int32 SocketRead(uint32 handle, IPAddr &ip, uint16 &port, void *buf, int32 len);
00120     static void SocketEvent(uint32 handle, int type);
00121     static void SocketAttach(Network *);
00122     static BOOL SocketDetach(Network *);
00123     static Network *SocketFind(uint32);
00124     static BOOL GetDNS(IPAddr &);  //get DNS Server
00125 
00126     //mutex API
00127     static PTR CreateMutex(char *name = (char*)NULL);
00128     static BOOL LockMutex(PTR handle, BOOL waitforever);
00129     static void ReleaseMutex(PTR handle);
00130     static void DestroyMutex(PTR handle);
00131 
00132     static void ConvertPathStyle(char *);
00133 
00134     //event log
00135     static uint32 OpenLog();
00136     static BOOL CloseLog(uint32 handle);
00137     static BOOL WriteLog(uint32 handle, char *msg, int type);
00138 
00139     //timer
00140     static BOOL TimerCreate(Timer *);
00141     static BOOL TimerDelete(Timer *);
00142 
00143     //DLLs
00144     static PTR DLLOpen(char *);
00145     static BOOL DLLClose(PTR);
00146     static PTR DLLGetProcPtr(PTR, char *);
00147 
00148     //Clipboard
00149     static BOOL ClipBoardPaste(PTR data, uint32 datasize);
00150     static PTR ClipBoardCopy();
00151 
00152     //user
00153     static BOOL GetCurrentUser(String &user);
00154     static BOOL LoginAsUser(char *, char *);  //DF/1.7.1
00155 
00156     //misc
00157     static void ConsoleStdout(char *);
00158     static void DirectPrint(PTR, uint32);
00159 
00160     //df
00161     static void initTables();
00162     static DF_TABLESSTRUCT *getTables();
00163     static void initProcess();
00164 };
00165 
00166 //Windows specific stuff
00168 class OSAPI_W32 {
00169   public:
00170     static char CmdLine[1024];   //copy of command line (spaces -> NULLs)
00171     static char OrgCmdLine[1024];   //copy of command line (spaces intack)
00172 
00173     static PTR Get_hInstance();
00174     static PTR Get_hPrevInstance();
00175     static int Get_nCmdShow();
00176     static char *Get_lpszCmdLine();
00177     static PTR Get_StartupInfo();  //returns pointer to it
00178 
00179     static void Set_hInstance(PTR);
00180     static void Set_hPrevInstance(PTR);
00181     static void Set_nCmdShow(int);
00182     static void Set_lpszCmdLine(char *);
00183 
00184     static void build_argv();
00185     static BOOL COM_Init();
00186     static BOOL COM_UnInit();
00187 };
00188 

Generated on Mon Mar 5 09:49:14 2007 for DigiForce by  doxygen 1.4.7