Changeset 91 for pjproject/branches/pjproject-0.2/pjlib/src/pj/os_win32.c
- Timestamp:
- Dec 2, 2005 10:28:52 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/pjproject-0.2/pjlib/src/pj/os_win32.c
r88 r91 1 /* $Header: / pjproject/pjlib/src/pj/os_win32.c 7 6/21/05 12:37a Bennylp $ */1 /* $Header: /cvs/pjproject-0.2.9.3/pjlib/src/pj/os_win32.c,v 1.1 2005/12/02 20:02:30 nn Exp $ */ 2 2 /* 3 3 * PJLIB - PJ Foundation Library … … 27 27 #include <pj/guid.h> 28 28 #include <stddef.h> 29 #include <sys/timeb.h> 29 #ifndef PJ_WIN32_WINCE 30 # include <sys/timeb.h> 31 #else 32 33 # include <windows.h> 34 35 struct timeb { 36 time_t time; 37 unsigned short millitm; 38 }; 39 40 static void ftime( struct timeb *tb ) 41 { 42 SYSTEMTIME st; 43 int days, years, leapyears; 44 45 if(tb == NULL) 46 { 47 //nlSetError(NL_NULL_POINTER); 48 assert(tb); 49 return; 50 } 51 GetSystemTime(&st); 52 leapyears = (st.wYear - 1970 + 1) / 4; 53 years = st.wYear - 1970 - leapyears; 54 55 days = years * 365 + leapyears * 366; 56 57 switch (st.wMonth) { 58 case 1: 59 case 3: 60 case 5: 61 case 7: 62 case 8: 63 case 10: 64 case 12: 65 days += 31; 66 break; 67 case 4: 68 case 6: 69 case 9: 70 case 11: 71 days += 30; 72 break; 73 case 2: 74 days += (st.wYear%4 == 0) ? 29 : 28; 75 break; 76 default: 77 break; 78 } 79 days += st.wDay; 80 tb->time = days * 86400 + st.wHour * 3600 + st.wMinute * 60 + st.wSecond; 81 tb->millitm = st.wMilliseconds; 82 } 83 84 time_t time(time_t *t) 85 { 86 struct timeb tb; 87 88 ftime(&tb); 89 *t = tb.time; 90 91 return *t; 92 } 93 #endif 94 30 95 #include <time.h> 31 96 #include <stdlib.h> … … 321 386 #if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400 322 387 return InterlockedIncrement(&atomic_var->value); 388 #elif defined(PJ_WIN32_WINCE) 389 return InterlockedIncrement(&atomic_var->value); 323 390 #else 324 391 # error Fix Me … … 332 399 #if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400 333 400 return InterlockedDecrement(&atomic_var->value); 401 #elif defined(PJ_WIN32_WINCE) 402 return InterlockedIncrement(&atomic_var->value); 334 403 #else 335 404 # error Fix me … … 664 733 PJ_DEF(pj_status_t) pj_time_decode(const pj_time_val *tv, pj_parsed_time *pt) 665 734 { 735 #if defined(PJ_WIN32_WINCE) 736 SYSTEMTIME local_time; 737 GetLocalTime(&local_time); 738 739 pt->year = local_time.wYear; 740 pt->mon = local_time.wMonth; 741 pt->day = local_time.wDay; 742 pt->hour = local_time.wHour; 743 pt->min = local_time.wMinute; 744 pt->sec = local_time.wSecond; 745 pt->wday = local_time.wDayOfWeek; 746 pt->yday = 0; //note this 747 pt->msec = local_time.wMilliseconds; 748 #else 666 749 struct tm *local_time; 667 668 750 local_time = localtime((time_t*)&tv->sec); 669 751 … … 677 759 pt->yday = local_time->tm_yday; 678 760 pt->msec = tv->msec; 761 #endif 762 679 763 680 764 return PJ_OK; … … 701 785 * Terminal 702 786 */ 787 #if !defined(PJ_WIN32_WINCE) 703 788 704 789 static WORD pj_color_to_os_attr(pj_color_t color) … … 758 843 } 759 844 845 #else 846 847 static short pj_color_to_os_attr(pj_color_t color) 848 { 849 return 0; 850 } 851 852 static pj_color_t os_attr_to_pj_color(short attr) 853 { 854 return 0; 855 } 856 857 858 /** 859 * Set terminal color. 860 */ 861 PJ_DEF(pj_status_t) pj_term_set_color(pj_color_t color) 862 { 863 return PJ_OK; 864 } 865 866 /** 867 * Get current terminal foreground color. 868 */ 869 PJ_DEF(pj_color_t) pj_term_get_color(void) 870 { 871 return 0; 872 } 873 874 875 #endif 876
Note: See TracChangeset
for help on using the changeset viewer.