Changeset 3428 for pjproject/trunk/pjlib/src/pj/os_info.c
- Timestamp:
- Mar 1, 2011 5:25:27 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pj/os_info.c
r3426 r3428 48 48 #endif 49 49 50 #if defined(PJ_DARWINOS) && PJ_DARWINOS != 0 51 # include "TargetConditionals.h" 52 #endif 50 53 51 54 #ifndef PJ_SYS_INFO_BUFFER_SIZE 52 55 # define PJ_SYS_INFO_BUFFER_SIZE 64 56 #endif 57 58 59 #if defined(PJ_DARWINOS) && PJ_DARWINOS != 0 && TARGET_OS_IPHONE 60 void pj_iphone_os_get_sys_info(pj_sys_info *si, pj_str_t *si_buffer); 53 61 #endif 54 62 … … 77 85 78 86 return buf; 87 } 88 89 static pj_uint32_t parse_version(char *str) 90 { 91 char *tok; 92 int i, maxtok; 93 pj_uint32_t version = 0; 94 95 while (*str && !pj_isdigit(*str)) 96 str++; 97 98 maxtok = 4; 99 for (tok = strtok(str, ".-"), i=0; tok && i<maxtok; 100 ++i, tok=strtok(NULL, ".-")) 101 { 102 int n; 103 104 if (!pj_isdigit(*tok)) 105 break; 106 107 n = atoi(tok); 108 version |= (n << ((3-i)*8)); 109 } 110 111 return version; 79 112 } 80 113 … … 106 139 */ 107 140 #if defined(PJ_HAS_UNAME) && PJ_HAS_UNAME 141 #if defined(PJ_DARWINOS) && PJ_DARWINOS != 0 && TARGET_OS_IPHONE 142 { 143 pj_str_t buf = {si_buffer + PJ_SYS_INFO_BUFFER_SIZE - left, left}; 144 pj_str_t machine = {"arm", 3}; 145 pj_str_t sdk_name = {"iOS-SDK", 7}; 146 char tmp[PJ_SYS_INFO_BUFFER_SIZE]; 147 148 pj_iphone_os_get_sys_info(&si, &buf); 149 left -= si.os_name.slen + 1; 150 151 si.os_ver = parse_version(si.machine.ptr); 152 153 si.machine = machine; 154 si.sdk_name = sdk_name; 155 156 #ifdef PJ_SDK_NAME 157 pj_memcpy(tmp, PJ_SDK_NAME, pj_ansi_strlen(PJ_SDK_NAME) + 1); 158 si.sdk_ver = parse_version(tmp); 159 #endif 160 } 161 #else 108 162 { 109 163 struct utsname u; 110 char *tok;111 int i, maxtok;112 164 113 165 /* Successful uname() returns zero on Linux and positive value … … 119 171 ALLOC_CP_STR(u.machine, machine); 120 172 ALLOC_CP_STR(u.sysname, os_name); 121 122 maxtok = 4; 123 for (tok = strtok(u.release, ".-"), i=0; 124 tok && i<maxtok; 125 ++i, tok=strtok(NULL, ".-")) 126 { 127 int n; 128 129 if (!pj_isdigit(*tok)) 130 break; 131 132 n = atoi(tok); 133 si.os_ver |= (n << ((3-i)*8)); 134 } 135 } 173 174 si.os_ver = parse_version(u.release); 175 } 176 #endif 136 177 #elif defined(_MSC_VER) 137 178 {
Note: See TracChangeset
for help on using the changeset viewer.