| 1 |
/* |
| 2 |
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 3 |
* Copyright (C) 2003-2008 Benny Prijono <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 |
*/ |
| 19 |
#include "TargetConditionals.h" |
| 20 |
|
| 21 |
#if !defined TARGET_IPHONE_SIMULATOR || TARGET_IPHONE_SIMULATOR == 0 |
| 22 |
|
| 23 |
#include <pj/os.h> |
| 24 |
#include <pj/string.h> |
| 25 |
|
| 26 |
#include <UIKit/UIDevice.h> |
| 27 |
|
| 28 |
void pj_iphone_os_get_sys_info(pj_sys_info *si, pj_str_t *si_buffer) |
| 29 |
{ |
| 30 |
unsigned buf_len = si_buffer->slen, left = si_buffer->slen, len; |
| 31 |
UIDevice *device = [UIDevice currentDevice]; |
| 32 |
|
| 33 |
if ([device respondsToSelector:@selector(isMultitaskingSupported)]) |
| 34 |
si->flags |= PJ_SYS_HAS_IOS_BG; |
| 35 |
|
| 36 |
#define ALLOC_CP_STR(str,field) \ |
| 37 |
do { \ |
| 38 |
len = [str length]; \ |
| 39 |
if (len && left >= len+1) { \ |
| 40 |
si->field.ptr = si_buffer->ptr + buf_len - left; \ |
| 41 |
si->field.slen = len; \ |
| 42 |
[str getCString:si->field.ptr maxLength:len+1 \ |
| 43 |
encoding:NSASCIIStringEncoding]; \ |
| 44 |
left -= (len+1); \ |
| 45 |
} \ |
| 46 |
} while (0) |
| 47 |
|
| 48 |
ALLOC_CP_STR([device systemName], os_name); |
| 49 |
ALLOC_CP_STR([device systemVersion], machine); |
| 50 |
} |
| 51 |
|
| 52 |
#endif |