summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/misc/misc.c
Side-by-side diff
Diffstat (limited to 'gammu/emb/common/misc/misc.c') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/misc/misc.c15
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
@@ -8,12 +8,15 @@
#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
@@ -228,16 +231,18 @@ char *OSDate (GSM_DateTime dt)
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->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 &&
@@ -448,12 +453,15 @@ 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);
@@ -517,13 +525,14 @@ char *GetOS(void)
}
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");