-rw-r--r-- | gammu/emb/common/misc/misc.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gammu/emb/common/misc/misc.c b/gammu/emb/common/misc/misc.c index c2f09e4..7227e7b 100644 --- a/gammu/emb/common/misc/misc.c +++ b/gammu/emb/common/misc/misc.c | |||
@@ -1,61 +1,64 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ | 1 | /* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ |
2 | /* Checking used compiler (c) 2002 by Michal Cihar */ | 2 | /* Checking used compiler (c) 2002 by Michal Cihar */ |
3 | 3 | ||
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <ctype.h> | 5 | #include <ctype.h> |
6 | #include <time.h> | 6 | #include <time.h> |
7 | #include <stdarg.h> | 7 | #include <stdarg.h> |
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <locale.h> | 9 | #include <locale.h> |
10 | #include <sys/timeb.h> | 10 | #include <sys/timeb.h> |
11 | #ifdef WIN32 | 11 | #ifdef WIN32 |
12 | # include "windows.h" | 12 | # include "windows.h" |
13 | #endif | 13 | #endif |
14 | #if defined(linux) || defined(__linux) || defined(__linux__) | ||
15 | # include <sys/utsname.h> | ||
16 | #endif | ||
14 | 17 | ||
15 | #include "../gsmstate.h" | 18 | #include "../gsmstate.h" |
16 | #include "misc.h" | 19 | #include "misc.h" |
17 | 20 | ||
18 | /* Based on article in Polish PC-Kurier 8/1998 page 104 | 21 | /* Based on article in Polish PC-Kurier 8/1998 page 104 |
19 | * Archive on http://www.pckurier.pl | 22 | * Archive on http://www.pckurier.pl |
20 | */ | 23 | */ |
21 | char *DayOfWeek (int year, int month, int day) | 24 | char *DayOfWeek (int year, int month, int day) |
22 | { | 25 | { |
23 | int p,q,r,w; | 26 | int p,q,r,w; |
24 | static char DayOfWeekChar[10]; | 27 | static char DayOfWeekChar[10]; |
25 | 28 | ||
26 | p=(14-month) / 12; | 29 | p=(14-month) / 12; |
27 | q=month+12*p-2; | 30 | q=month+12*p-2; |
28 | r=year-p; | 31 | r=year-p; |
29 | w=(day+(31*q) / 12 + r + r / 4 - r / 100 + r / 400) % 7; | 32 | w=(day+(31*q) / 12 + r + r / 4 - r / 100 + r / 400) % 7; |
30 | strcpy(DayOfWeekChar,""); | 33 | strcpy(DayOfWeekChar,""); |
31 | switch (w) { | 34 | switch (w) { |
32 | case 0: strcpy(DayOfWeekChar,"Sun"); break; | 35 | case 0: strcpy(DayOfWeekChar,"Sun"); break; |
33 | case 1: strcpy(DayOfWeekChar,"Mon"); break; | 36 | case 1: strcpy(DayOfWeekChar,"Mon"); break; |
34 | case 2: strcpy(DayOfWeekChar,"Tue"); break; | 37 | case 2: strcpy(DayOfWeekChar,"Tue"); break; |
35 | case 3: strcpy(DayOfWeekChar,"Wed"); break; | 38 | case 3: strcpy(DayOfWeekChar,"Wed"); break; |
36 | case 4: strcpy(DayOfWeekChar,"Thu"); break; | 39 | case 4: strcpy(DayOfWeekChar,"Thu"); break; |
37 | case 5: strcpy(DayOfWeekChar,"Fri"); break; | 40 | case 5: strcpy(DayOfWeekChar,"Fri"); break; |
38 | case 6: strcpy(DayOfWeekChar,"Sat"); break; | 41 | case 6: strcpy(DayOfWeekChar,"Sat"); break; |
39 | } | 42 | } |
40 | return DayOfWeekChar; | 43 | return DayOfWeekChar; |
41 | } | 44 | } |
42 | 45 | ||
43 | void Fill_GSM_DateTime(GSM_DateTime *Date, time_t timet) | 46 | void Fill_GSM_DateTime(GSM_DateTime *Date, time_t timet) |
44 | { | 47 | { |
45 | struct tm *now; | 48 | struct tm *now; |
46 | 49 | ||
47 | now = localtime(&timet); | 50 | now = localtime(&timet); |
48 | Date->Year= now->tm_year; | 51 | Date->Year= now->tm_year; |
49 | Date->Month= now->tm_mon+1; | 52 | Date->Month= now->tm_mon+1; |
50 | Date->Day= now->tm_mday; | 53 | Date->Day= now->tm_mday; |
51 | Date->Hour= now->tm_hour; | 54 | Date->Hour= now->tm_hour; |
52 | Date->Minute= now->tm_min; | 55 | Date->Minute= now->tm_min; |
53 | Date->Second = now->tm_sec; | 56 | Date->Second = now->tm_sec; |
54 | } | 57 | } |
55 | 58 | ||
56 | void GSM_GetCurrentDateTime (GSM_DateTime *Date) | 59 | void GSM_GetCurrentDateTime (GSM_DateTime *Date) |
57 | { | 60 | { |
58 | Fill_GSM_DateTime(Date, time(NULL)); | 61 | Fill_GSM_DateTime(Date, time(NULL)); |
59 | if (Date->Year<1900) { | 62 | if (Date->Year<1900) { |
60 | if (Date->Year>90) Date->Year = Date->Year+1900; | 63 | if (Date->Year>90) Date->Year = Date->Year+1900; |
61 | else Date->Year = Date->Year+2000; | 64 | else Date->Year = Date->Year+2000; |
@@ -186,100 +189,102 @@ char *OSDate (GSM_DateTime dt) | |||
186 | 189 | ||
187 | /* Based on article in Polish PC-Kurier 8/1998 page 104 | 190 | /* Based on article in Polish PC-Kurier 8/1998 page 104 |
188 | * Archive on http://www.pckurier.pl | 191 | * Archive on http://www.pckurier.pl |
189 | */ | 192 | */ |
190 | p=(14-dt.Month) / 12; | 193 | p=(14-dt.Month) / 12; |
191 | q=dt.Month+12*p-2; | 194 | q=dt.Month+12*p-2; |
192 | r=dt.Year-p; | 195 | r=dt.Year-p; |
193 | w=(dt.Day+(31*q) / 12 + r + r / 4 - r / 100 + r / 400) % 7; | 196 | w=(dt.Day+(31*q) / 12 + r + r / 4 - r / 100 + r / 400) % 7; |
194 | 197 | ||
195 | timeptr.tm_yday = 0; /* FIXME */ | 198 | timeptr.tm_yday = 0; /* FIXME */ |
196 | timeptr.tm_isdst = -1; /* FIXME */ | 199 | timeptr.tm_isdst = -1; /* FIXME */ |
197 | timeptr.tm_year = dt.Year - 1900; | 200 | timeptr.tm_year = dt.Year - 1900; |
198 | timeptr.tm_mon = dt.Month - 1; | 201 | timeptr.tm_mon = dt.Month - 1; |
199 | timeptr.tm_mday = dt.Day; | 202 | timeptr.tm_mday = dt.Day; |
200 | timeptr.tm_hour = dt.Hour; | 203 | timeptr.tm_hour = dt.Hour; |
201 | timeptr.tm_min = dt.Minute; | 204 | timeptr.tm_min = dt.Minute; |
202 | timeptr.tm_sec = dt.Second; | 205 | timeptr.tm_sec = dt.Second; |
203 | timeptr.tm_wday = w; | 206 | timeptr.tm_wday = w; |
204 | #ifdef _BSD_SOURCE | 207 | #ifdef _BSD_SOURCE |
205 | timeptr.tm_zone = NULL; | 208 | timeptr.tm_zone = NULL; |
206 | #endif | 209 | #endif |
207 | 210 | ||
208 | #ifdef WIN32 | 211 | #ifdef WIN32 |
209 | strftime(retval2, 200, "%#x", &timeptr); | 212 | strftime(retval2, 200, "%#x", &timeptr); |
210 | #else | 213 | #else |
211 | strftime(retval2, 200, "%x", &timeptr); | 214 | strftime(retval2, 200, "%x", &timeptr); |
212 | #endif | 215 | #endif |
213 | /* If don't have weekday name, include it */ | 216 | /* If don't have weekday name, include it */ |
214 | strftime(retval, 200, "%A", &timeptr); | 217 | strftime(retval, 200, "%A", &timeptr); |
215 | if (strstr(retval2,retval)==NULL) { | 218 | if (strstr(retval2,retval)==NULL) { |
216 | /* Check also for short name */ | 219 | /* Check also for short name */ |
217 | strftime(retval, 200, "%a", &timeptr); | 220 | strftime(retval, 200, "%a", &timeptr); |
218 | if (strstr(retval2,retval)==NULL) { | 221 | if (strstr(retval2,retval)==NULL) { |
219 | strcat(retval2," ("); | 222 | strcat(retval2," ("); |
220 | strcat(retval2,retval); | 223 | strcat(retval2,retval); |
221 | strcat(retval2,")"); | 224 | strcat(retval2,")"); |
222 | } | 225 | } |
223 | } | 226 | } |
224 | 227 | ||
225 | #ifdef WIN32 | 228 | #ifdef WIN32 |
226 | setlocale(LC_ALL, ".ACP"); | 229 | setlocale(LC_ALL, ".ACP"); |
227 | #endif | 230 | #endif |
228 | 231 | ||
229 | return retval2; | 232 | return retval2; |
230 | } | 233 | } |
231 | 234 | ||
232 | bool CheckDate(GSM_DateTime *date) | 235 | bool CheckDate(GSM_DateTime *date) |
233 | { | 236 | { |
234 | /* FIXME: This could also check if day is correct for selected month */ | 237 | const unsigned int days[]={31,29,31,30,31,30,31,31,30,31,30,31}; |
238 | |||
239 | /* FIXME: This could also check for leap years */ | ||
235 | return date->Year != 0 && | 240 | return date->Year != 0 && |
236 | date->Month >= 1 && date->Month <= 12 && | 241 | date->Month >= 1 && date->Month <= 12 && |
237 | date->Day >= 1 && date->Day <= 31; | 242 | date->Day >= 1 && date->Day <= days[date->Month]; |
238 | } | 243 | } |
239 | 244 | ||
240 | bool CheckTime(GSM_DateTime *date) | 245 | bool CheckTime(GSM_DateTime *date) |
241 | { | 246 | { |
242 | return date->Hour <= 23 && date->Hour >= 0 && | 247 | return date->Hour <= 23 && date->Hour >= 0 && |
243 | date->Minute <= 59 && date->Minute >= 0 && | 248 | date->Minute <= 59 && date->Minute >= 0 && |
244 | date->Second <= 59 && date->Second >= 0; | 249 | date->Second <= 59 && date->Second >= 0; |
245 | } | 250 | } |
246 | 251 | ||
247 | int GetLine(FILE *File, char *Line, int count) | 252 | int GetLine(FILE *File, char *Line, int count) |
248 | { | 253 | { |
249 | int num; | 254 | int num; |
250 | 255 | ||
251 | if (fgets(Line, count, File) != NULL) { | 256 | if (fgets(Line, count, File) != NULL) { |
252 | num = strlen(Line) - 1; | 257 | num = strlen(Line) - 1; |
253 | while(1) { | 258 | while(1) { |
254 | if (Line[num] != '\n' && Line[num] != '\r') break; | 259 | if (Line[num] != '\n' && Line[num] != '\r') break; |
255 | if (num == 0) break; | 260 | if (num == 0) break; |
256 | Line[num--] = 0; | 261 | Line[num--] = 0; |
257 | } | 262 | } |
258 | return strlen(Line); | 263 | return strlen(Line); |
259 | } | 264 | } |
260 | return -1; | 265 | return -1; |
261 | } | 266 | } |
262 | 267 | ||
263 | void SplitLines(unsigned char *message, int messagesize, GSM_Lines *lines, unsigned char *whitespaces, int spaceslen, bool eot) | 268 | void SplitLines(unsigned char *message, int messagesize, GSM_Lines *lines, unsigned char *whitespaces, int spaceslen, bool eot) |
264 | { | 269 | { |
265 | int i,number=0,j; | 270 | int i,number=0,j; |
266 | bool whitespace=true, nowwhite; | 271 | bool whitespace=true, nowwhite; |
267 | 272 | ||
268 | for (i=0;i<MAX_LINES*2;i++) lines->numbers[i]=0; | 273 | for (i=0;i<MAX_LINES*2;i++) lines->numbers[i]=0; |
269 | 274 | ||
270 | for (i=0;i<messagesize;i++) { | 275 | for (i=0;i<messagesize;i++) { |
271 | nowwhite = false; | 276 | nowwhite = false; |
272 | for (j=0;j<spaceslen;j++) { | 277 | for (j=0;j<spaceslen;j++) { |
273 | if (whitespaces[j] == message[i]) { | 278 | if (whitespaces[j] == message[i]) { |
274 | nowwhite = true; | 279 | nowwhite = true; |
275 | break; | 280 | break; |
276 | } | 281 | } |
277 | } | 282 | } |
278 | if (whitespace) { | 283 | if (whitespace) { |
279 | if (!nowwhite) { | 284 | if (!nowwhite) { |
280 | lines->numbers[number]=i; | 285 | lines->numbers[number]=i; |
281 | number++; | 286 | number++; |
282 | whitespace=false; | 287 | whitespace=false; |
283 | } | 288 | } |
284 | } else { | 289 | } else { |
285 | if (nowwhite) { | 290 | if (nowwhite) { |
@@ -406,166 +411,170 @@ bool GSM_SetDebugLevel(char *info, Debug_Info *di) | |||
406 | if (!strcmp(info,"errors")) {di->dl = DL_TEXTERROR; return true;} | 411 | if (!strcmp(info,"errors")) {di->dl = DL_TEXTERROR; return true;} |
407 | if (!strcmp(info,"textdate")) {di->dl = DL_TEXTDATE; return true;} | 412 | if (!strcmp(info,"textdate")) {di->dl = DL_TEXTDATE; return true;} |
408 | if (!strcmp(info,"textalldate")) {di->dl = DL_TEXTALLDATE; return true;} | 413 | if (!strcmp(info,"textalldate")) {di->dl = DL_TEXTALLDATE; return true;} |
409 | if (!strcmp(info,"errorsdate")) {di->dl = DL_TEXTERRORDATE; return true;} | 414 | if (!strcmp(info,"errorsdate")) {di->dl = DL_TEXTERRORDATE; return true;} |
410 | return false; | 415 | return false; |
411 | } | 416 | } |
412 | 417 | ||
413 | /* Dumps a message */ | 418 | /* Dumps a message */ |
414 | void DumpMessage(FILE *df, Debug_Level dl, const unsigned char *message, int messagesize) | 419 | void DumpMessage(FILE *df, Debug_Level dl, const unsigned char *message, int messagesize) |
415 | { | 420 | { |
416 | int i,j=0,len=16; | 421 | int i,j=0,len=16; |
417 | unsigned charbuffer[200]; | 422 | unsigned charbuffer[200]; |
418 | 423 | ||
419 | if (df==NULL || messagesize == 0) return; | 424 | if (df==NULL || messagesize == 0) return; |
420 | 425 | ||
421 | smfprintf(df, dl, "\n"); | 426 | smfprintf(df, dl, "\n"); |
422 | 427 | ||
423 | memset(buffer,0x20,sizeof(buffer)); | 428 | memset(buffer,0x20,sizeof(buffer)); |
424 | buffer[len*5-1]=0; | 429 | buffer[len*5-1]=0; |
425 | 430 | ||
426 | for (i = 0; i < messagesize; i++) { | 431 | for (i = 0; i < messagesize; i++) { |
427 | sprintf(buffer+j*4,"%02X",message[i]); | 432 | sprintf(buffer+j*4,"%02X",message[i]); |
428 | buffer[j*4+2] = 0x20; | 433 | buffer[j*4+2] = 0x20; |
429 | if (isprint(message[i]) && message[i]!=0x09) { | 434 | if (isprint(message[i]) && message[i]!=0x09) { |
430 | if (j != len-1) buffer[j*4+2] = message[i]; | 435 | if (j != len-1) buffer[j*4+2] = message[i]; |
431 | buffer[(len-1)*4+j+3] = message[i]; | 436 | buffer[(len-1)*4+j+3] = message[i]; |
432 | } else { | 437 | } else { |
433 | buffer[(len-1)*4+j+3] = '.'; | 438 | buffer[(len-1)*4+j+3] = '.'; |
434 | } | 439 | } |
435 | if (j != len-1 && i != messagesize-1) buffer[j*4+3] = '|'; | 440 | if (j != len-1 && i != messagesize-1) buffer[j*4+3] = '|'; |
436 | if (j == len-1) { | 441 | if (j == len-1) { |
437 | smfprintf(df, dl, "%s\n", buffer); | 442 | smfprintf(df, dl, "%s\n", buffer); |
438 | memset(buffer,0x20,sizeof(buffer)); | 443 | memset(buffer,0x20,sizeof(buffer)); |
439 | buffer[len*5-1]=0; | 444 | buffer[len*5-1]=0; |
440 | j = 0; | 445 | j = 0; |
441 | } else { | 446 | } else { |
442 | j++; | 447 | j++; |
443 | } | 448 | } |
444 | } | 449 | } |
445 | if (j != 0) smfprintf(df, dl, "%s\n", buffer); | 450 | if (j != 0) smfprintf(df, dl, "%s\n", buffer); |
446 | } | 451 | } |
447 | 452 | ||
448 | char *GetOS(void) | 453 | char *GetOS(void) |
449 | { | 454 | { |
450 | #ifdef WIN32 | 455 | #ifdef WIN32 |
451 | OSVERSIONINFOEX Ver; | 456 | OSVERSIONINFOEX Ver; |
452 | bool Extended = true; | 457 | bool Extended = true; |
453 | #endif | 458 | #endif |
459 | #if defined(linux) || defined(__linux) || defined(__linux__) | ||
460 | struct utsnameVer; | ||
461 | #endif | ||
454 | static char Buffer[100] = {0x00}; | 462 | static char Buffer[100] = {0x00}; |
455 | 463 | ||
456 | #ifdef WIN32 | 464 | #ifdef WIN32 |
457 | memset(&Ver,sizeof(OSVERSIONINFOEX),0); | 465 | memset(&Ver,sizeof(OSVERSIONINFOEX),0); |
458 | Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); | 466 | Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
459 | 467 | ||
460 | if (!GetVersionEx((OSVERSIONINFO *)&Ver)) { | 468 | if (!GetVersionEx((OSVERSIONINFO *)&Ver)) { |
461 | Extended = false; | 469 | Extended = false; |
462 | Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | 470 | Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
463 | if (!GetVersionEx((OSVERSIONINFO *)&Ver)) { | 471 | if (!GetVersionEx((OSVERSIONINFO *)&Ver)) { |
464 | //#ifdef _MSC_VER | 472 | //#ifdef _MSC_VER |
465 | // Ver.dwMajorVersion = _winmajor; | 473 | // Ver.dwMajorVersion = _winmajor; |
466 | // Ver.dwMinorVersion = _winminor; | 474 | // Ver.dwMinorVersion = _winminor; |
467 | // Ver.dwBuildNumber = _osver; | 475 | // Ver.dwBuildNumber = _osver; |
468 | //#else | 476 | //#else |
469 | sprintf(Buffer, "Windows"); | 477 | sprintf(Buffer, "Windows"); |
470 | return Buffer; | 478 | return Buffer; |
471 | //#endif | 479 | //#endif |
472 | } | 480 | } |
473 | } | 481 | } |
474 | 482 | ||
475 | /* ----------------- 9x family ------------------ */ | 483 | /* ----------------- 9x family ------------------ */ |
476 | 484 | ||
477 | /* no info about Win95 SP1, Win95 OSR2.1, Win95 OSR2.5.... */ | 485 | /* no info about Win95 SP1, Win95 OSR2.1, Win95 OSR2.5.... */ |
478 | if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 950) { | 486 | if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 950) { |
479 | sprintf(Buffer,"Win 95"); | 487 | sprintf(Buffer,"Win 95"); |
480 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 1111) { | 488 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 1111) { |
481 | sprintf(Buffer,"Win 95 OSR2.x"); | 489 | sprintf(Buffer,"Win 95 OSR2.x"); |
482 | 490 | ||
483 | /* no info about Win98 SP1.... */ | 491 | /* no info about Win98 SP1.... */ |
484 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 10 && Ver.dwBuildNumber == 1998) { | 492 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 10 && Ver.dwBuildNumber == 1998) { |
485 | sprintf(Buffer,"Win 98"); | 493 | sprintf(Buffer,"Win 98"); |
486 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 10 && Ver.dwBuildNumber == 2222) { | 494 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 10 && Ver.dwBuildNumber == 2222) { |
487 | sprintf(Buffer,"Win 98 SE"); | 495 | sprintf(Buffer,"Win 98 SE"); |
488 | 496 | ||
489 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 90 && Ver.dwBuildNumber == 3000) { | 497 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 90 && Ver.dwBuildNumber == 3000) { |
490 | sprintf(Buffer,"Win ME"); | 498 | sprintf(Buffer,"Win ME"); |
491 | 499 | ||
492 | /* ---------------- NT family ------------------- */ | 500 | /* ---------------- NT family ------------------- */ |
493 | 501 | ||
494 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 1381) { | 502 | } else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 1381) { |
495 | sprintf(Buffer,"Win NT 4.0"); | 503 | sprintf(Buffer,"Win NT 4.0"); |
496 | 504 | ||
497 | } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 2195) { | 505 | } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 0 && Ver.dwBuildNumber == 2195) { |
498 | sprintf(Buffer,"Win 2000"); | 506 | sprintf(Buffer,"Win 2000"); |
499 | 507 | ||
500 | } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 1 && Ver.dwBuildNumber == 2600) { | 508 | } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 1 && Ver.dwBuildNumber == 2600) { |
501 | sprintf(Buffer,"Win XP"); | 509 | sprintf(Buffer,"Win XP"); |
502 | #if _MSC_VER > 1200 //6.0 has it undeclared | 510 | #if _MSC_VER > 1200 //6.0 has it undeclared |
503 | if (Extended) { | 511 | if (Extended) { |
504 | if (Ver.wSuiteMask & VER_SUITE_PERSONAL) { | 512 | if (Ver.wSuiteMask & VER_SUITE_PERSONAL) { |
505 | sprintf(Buffer+strlen(Buffer)," Home"); | 513 | sprintf(Buffer+strlen(Buffer)," Home"); |
506 | } else { | 514 | } else { |
507 | sprintf(Buffer+strlen(Buffer)," Pro"); | 515 | sprintf(Buffer+strlen(Buffer)," Pro"); |
508 | } | 516 | } |
509 | } | 517 | } |
510 | #endif | 518 | #endif |
511 | 519 | ||
512 | } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 2) { | 520 | } else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 2) { |
513 | sprintf(Buffer,"Win 2003"); | 521 | sprintf(Buffer,"Win 2003"); |
514 | 522 | ||
515 | } else { | 523 | } else { |
516 | sprintf(Buffer, "Windows %i.%i.%i",Ver.dwMajorVersion,Ver.dwMinorVersion,Ver.dwBuildNumber); | 524 | sprintf(Buffer, "Windows %i.%i.%i",Ver.dwMajorVersion,Ver.dwMinorVersion,Ver.dwBuildNumber); |
517 | } | 525 | } |
518 | 526 | ||
519 | if (Extended && Ver.wServicePackMajor != 0) { | 527 | if (Extended && Ver.wServicePackMajor != 0) { |
520 | sprintf(Buffer+strlen(Buffer)," SP%i",Ver.wServicePackMajor); | 528 | sprintf(Buffer+strlen(Buffer)," SP%i",Ver.wServicePackMajor); |
521 | } | 529 | } |
522 | #elif defined(linux) || defined(__linux) || defined(__linux__) | 530 | #elif defined(linux) || defined(__linux) || defined(__linux__) |
523 | sprintf(Buffer, "Linux"); | 531 | uname(&Ver); |
532 | sprintf(Buffer, "Linux, kernel %s",Ver.release); | ||
524 | #elif defined(__FreeBSD__) | 533 | #elif defined(__FreeBSD__) |
525 | sprintf(Buffer, "FreeBSD"); | 534 | sprintf(Buffer, "FreeBSD"); |
526 | #elif defined(__NetBSD__) | 535 | #elif defined(__NetBSD__) |
527 | sprintf(Buffer, "NetBSD"); | 536 | sprintf(Buffer, "NetBSD"); |
528 | #elif defined(__OpenBSD__) | 537 | #elif defined(__OpenBSD__) |
529 | sprintf(Buffer, "OpenBSD"); | 538 | sprintf(Buffer, "OpenBSD"); |
530 | #elif defined(__GNU__) | 539 | #elif defined(__GNU__) |
531 | sprintf(Buffer, "GNU/Hurd"); | 540 | sprintf(Buffer, "GNU/Hurd"); |
532 | #elif defined(sun) || defined(__sun) || defined(__sun__) | 541 | #elif defined(sun) || defined(__sun) || defined(__sun__) |
533 | # ifdef __SVR4 | 542 | # ifdef __SVR4 |
534 | sprintf(Buffer, "Sun Solaris"); | 543 | sprintf(Buffer, "Sun Solaris"); |
535 | # else | 544 | # else |
536 | sprintf(Buffer, "SunOS"); | 545 | sprintf(Buffer, "SunOS"); |
537 | # endif | 546 | # endif |
538 | #elif defined(hpux) || defined(__hpux) || defined(__hpux__) | 547 | #elif defined(hpux) || defined(__hpux) || defined(__hpux__) |
539 | sprintf(Buffer, "HP-UX"); | 548 | sprintf(Buffer, "HP-UX"); |
540 | #elif defined(ultrix) || defined(__ultrix) || defined(__ultrix__) | 549 | #elif defined(ultrix) || defined(__ultrix) || defined(__ultrix__) |
541 | sprintf(Buffer, "DEC Ultrix"); | 550 | sprintf(Buffer, "DEC Ultrix"); |
542 | #elif defined(sgi) || defined(__sgi) | 551 | #elif defined(sgi) || defined(__sgi) |
543 | sprintf(Buffer, "SGI Irix"); | 552 | sprintf(Buffer, "SGI Irix"); |
544 | #elif defined(__osf__) | 553 | #elif defined(__osf__) |
545 | sprintf(Buffer, "OSF Unix"); | 554 | sprintf(Buffer, "OSF Unix"); |
546 | #elif defined(bsdi) || defined(__bsdi__) | 555 | #elif defined(bsdi) || defined(__bsdi__) |
547 | sprintf(Buffer, "BSDI Unix"); | 556 | sprintf(Buffer, "BSDI Unix"); |
548 | #elif defined(_AIX) | 557 | #elif defined(_AIX) |
549 | sprintf(Buffer, "AIX Unix"); | 558 | sprintf(Buffer, "AIX Unix"); |
550 | #elif defined(_UNIXWARE) | 559 | #elif defined(_UNIXWARE) |
551 | sprintf(Buffer, "SCO Unixware"); | 560 | sprintf(Buffer, "SCO Unixware"); |
552 | #elif defined(DGUX) | 561 | #elif defined(DGUX) |
553 | sprintf(Buffer, "DG Unix"); | 562 | sprintf(Buffer, "DG Unix"); |
554 | #elif defined(__QNX__) | 563 | #elif defined(__QNX__) |
555 | sprintf(Buffer, "QNX"); | 564 | sprintf(Buffer, "QNX"); |
556 | #endif | 565 | #endif |
557 | return Buffer; | 566 | return Buffer; |
558 | } | 567 | } |
559 | 568 | ||
560 | char *GetCompiler(void) | 569 | char *GetCompiler(void) |
561 | { | 570 | { |
562 | static char Buffer[100] = {0x00}; | 571 | static char Buffer[100] = {0x00}; |
563 | 572 | ||
564 | #ifdef WIN32 | 573 | #ifdef WIN32 |
565 | # ifdef _MSC_VER | 574 | # ifdef _MSC_VER |
566 | if (_MSC_VER == 1200) { //? | 575 | if (_MSC_VER == 1200) { //? |
567 | sprintf(Buffer, "MS VC 6.0"); | 576 | sprintf(Buffer, "MS VC 6.0"); |
568 | } else if (_MSC_VER == 1300) { | 577 | } else if (_MSC_VER == 1300) { |
569 | sprintf(Buffer, "MS VC .NET 2002"); | 578 | sprintf(Buffer, "MS VC .NET 2002"); |
570 | } else if (_MSC_VER == 1310) { | 579 | } else if (_MSC_VER == 1310) { |
571 | sprintf(Buffer, "MS VC .NET 2003"); | 580 | sprintf(Buffer, "MS VC .NET 2003"); |