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) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/misc/misc.c19
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
@@ -11,6 +11,9 @@
#ifdef WIN32
# include "windows.h"
#endif
+#if defined(linux) || defined(__linux) || defined(__linux__)
+# include <sys/utsname.h>
+#endif
#include "../gsmstate.h"
#include "misc.h"
@@ -230,11 +233,13 @@ char *OSDate (GSM_DateTime dt)
}
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)
@@ -451,6 +456,9 @@ char *GetOS(void)
OSVERSIONINFOEX Ver;
bool Extended = true;
#endif
+#if defined(linux) || defined(__linux) || defined(__linux__)
+ struct utsname Ver;
+#endif
static char Buffer[100] = {0x00};
#ifdef WIN32
@@ -520,7 +528,8 @@ char *GetOS(void)
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__)