winfuncs.c

00001 /*
00002  * iaxclient: a cross-platform IAX softphone library
00003  *
00004  * Copyrights:
00005  * Copyright (C) 2003-2006, Horizon Wimba, Inc.
00006  * Copyright (C) 2007, Wimba, Inc.
00007  *
00008  * Contributors:
00009  * Steve Kann <stevek@stevek.com>
00010  *
00011  * This program is free software, distributed under the terms of
00012  * the GNU Lesser (Library) General Public License.
00013  */
00014 
00015 #include "iaxclient_lib.h"
00016 
00017 #include <windows.h>
00018 #include <winbase.h>
00019 
00020 #include <stdio.h>
00021 
00022 #if !defined(_WIN32_WCE)
00023 #include <sys/timeb.h>
00024 
00025 /* Win-doze doesnt have gettimeofday(). This sux. So, what we did is
00026 provide some gettimeofday-like functionality that works for our purposes. */
00027 
00028 /*
00029         changed 'struct timezone*' to 'void*' since
00030         timezone is defined as a long in MINGW and caused compile-time warnings.
00031         this should be okay since we don't use the passed value.
00032 */
00033 
00034 
00035 /*
00036  * functions implementations
00037  */
00038 
00039 void gettimeofday( struct timeval* tv, void* tz )
00040 {
00041         struct _timeb curSysTime;
00042 
00043         _ftime(&curSysTime);
00044         tv->tv_sec = (long)curSysTime.time;
00045         tv->tv_usec = curSysTime.millitm * 1000;
00046 }
00047 #endif
00048 
00049 void os_init(void)
00050 {
00051         WSADATA wsd;
00052 
00053         if(WSAStartup(0x0101,&wsd))
00054         {   // Error message?
00055             exit(1);
00056         }
00057 }
00058 
00059 /* yes, it could have just been a #define, but that makes linking trickier */
00060 EXPORT void iaxc_millisleep(long ms)
00061 {
00062         Sleep(ms);
00063 }
00064 
00065 int iaxci_post_event_callback(iaxc_event ev) {
00066         iaxc_event *e;
00067         e = (iaxc_event *)malloc(sizeof(ev));
00068         *e = ev;
00069 
00070         if (!PostMessage((HWND)post_event_handle,post_event_id,(WPARAM) NULL, (LPARAM) e))
00071                 free(e);
00072         return 0;
00073 }
00074 
00075 /* Increasing the Thread Priority.  See
00076  * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/scheduling_priorities.asp
00077  * for discussion on Win32 scheduling priorities.
00078  */
00079 
00080 int iaxci_prioboostbegin() {
00081     if ( !SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL)  ) {
00082         fprintf(stderr, "SetThreadPriority failed: %ld.\n", GetLastError());
00083     }
00084     return 0;
00085 }
00086 
00087 int iaxci_prioboostend() {
00088     /* TODO */
00089     return 0;
00090 }
00091 

Generated on Mon Sep 24 15:43:29 2007 for IAXClient by  doxygen 1.5.3