Ignore:
Timestamp:
Dec 2, 2005 10:28:52 PM (18 years ago)
Author:
nanang
Message:

Updated with wince files

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 $ */ 
    22/*  
    33 * PJLIB - PJ Foundation Library 
     
    2727#include <pj/guid.h> 
    2828#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 
     35struct timeb { 
     36        time_t time; 
     37        unsigned short millitm; 
     38}; 
     39 
     40static 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 
     84time_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 
    3095#include <time.h> 
    3196#include <stdlib.h> 
     
    321386#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400 
    322387    return InterlockedIncrement(&atomic_var->value); 
     388#elif defined(PJ_WIN32_WINCE) 
     389    return InterlockedIncrement(&atomic_var->value); 
    323390#else 
    324391#   error Fix Me 
     
    332399#if defined(PJ_WIN32_WINNT) && PJ_WIN32_WINNT >= 0x0400 
    333400    return InterlockedDecrement(&atomic_var->value); 
     401#elif defined(PJ_WIN32_WINCE) 
     402    return InterlockedIncrement(&atomic_var->value); 
    334403#else 
    335404#   error Fix me 
     
    664733PJ_DEF(pj_status_t) pj_time_decode(const pj_time_val *tv, pj_parsed_time *pt) 
    665734{ 
     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 
    666749    struct tm *local_time; 
    667  
    668750    local_time = localtime((time_t*)&tv->sec); 
    669751 
     
    677759    pt->yday = local_time->tm_yday; 
    678760    pt->msec = tv->msec; 
     761#endif 
     762 
    679763 
    680764    return PJ_OK; 
     
    701785 * Terminal 
    702786 */ 
     787#if !defined(PJ_WIN32_WINCE) 
    703788 
    704789static WORD pj_color_to_os_attr(pj_color_t color) 
     
    758843} 
    759844 
     845#else 
     846 
     847static short pj_color_to_os_attr(pj_color_t color) 
     848{ 
     849     return 0; 
     850} 
     851 
     852static pj_color_t os_attr_to_pj_color(short attr) 
     853{ 
     854    return 0; 
     855} 
     856 
     857 
     858/** 
     859 * Set terminal color. 
     860 */ 
     861PJ_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 */ 
     869PJ_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.