Diffstat (limited to 'gammu/emb/common/misc/misc.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/misc/misc.c | 19 |
1 files changed, 14 insertions, 5 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 @@ -6,16 +6,19 @@ #include <time.h> #include <stdarg.h> #include <stdio.h> #include <locale.h> #include <sys/timeb.h> #ifdef WIN32 # include "windows.h" #endif +#if defined(linux) || defined(__linux) || defined(__linux__) +# include <sys/utsname.h> +#endif #include "../gsmstate.h" #include "misc.h" /* Based on article in Polish PC-Kurier 8/1998 page 104 * Archive on http://www.pckurier.pl */ char *DayOfWeek (int year, int month, int day) @@ -225,21 +228,23 @@ char *OSDate (GSM_DateTime dt) #ifdef WIN32 setlocale(LC_ALL, ".ACP"); #endif return retval2; } bool CheckDate(GSM_DateTime *date) -{ - /* FIXME: This could also check if day is correct for selected month */ +{ + const unsigned int days[]={31,29,31,30,31,30,31,31,30,31,30,31}; + + /* FIXME: This could also check for leap years */ return date->Year != 0 && - date->Month >= 1 && date->Month <= 12 && - date->Day >= 1 && date->Day <= 31; + date->Month >= 1 && date->Month <= 12 && + date->Day >= 1 && date->Day <= days[date->Month]; } bool CheckTime(GSM_DateTime *date) { return date->Hour <= 23 && date->Hour >= 0 && date->Minute <= 59 && date->Minute >= 0 && date->Second <= 59 && date->Second >= 0; } @@ -446,16 +451,19 @@ void DumpMessage(FILE *df, Debug_Level dl, const unsigned char *message, int mes } char *GetOS(void) { #ifdef WIN32 OSVERSIONINFOEX Ver; bool Extended = true; #endif +#if defined(linux) || defined(__linux) || defined(__linux__) + struct utsname Ver; +#endif static char Buffer[100] = {0x00}; #ifdef WIN32 memset(&Ver,sizeof(OSVERSIONINFOEX),0); Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if (!GetVersionEx((OSVERSIONINFO *)&Ver)) { Extended = false; @@ -515,17 +523,18 @@ char *GetOS(void) } else { sprintf(Buffer, "Windows %i.%i.%i",Ver.dwMajorVersion,Ver.dwMinorVersion,Ver.dwBuildNumber); } if (Extended && Ver.wServicePackMajor != 0) { sprintf(Buffer+strlen(Buffer)," SP%i",Ver.wServicePackMajor); } #elif defined(linux) || defined(__linux) || defined(__linux__) - sprintf(Buffer, "Linux"); + uname(&Ver); + sprintf(Buffer, "Linux, kernel %s",Ver.release); #elif defined(__FreeBSD__) sprintf(Buffer, "FreeBSD"); #elif defined(__NetBSD__) sprintf(Buffer, "NetBSD"); #elif defined(__OpenBSD__) sprintf(Buffer, "OpenBSD"); #elif defined(__GNU__) sprintf(Buffer, "GNU/Hurd"); |