Added two sources

Tue, 22 Apr 2014 16:46:27 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 22 Apr 2014 16:46:27 +0200
changeset 1
91065eba8e1b
parent 0
ac8e19023b12
child 2
217c90acc389

Added two sources

thermometers/main.c file | annotate | diff | comparison | revisions
thermometers/main.h file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thermometers/main.c	Tue Apr 22 16:46:27 2014 +0200
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * Copyright (C) 2014
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of the mbsePi-apps
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * mbsePi-apps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with EC-65K; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+#include "main.h"
+
+
+void help(void)
+{
+    fprintf(stdout, "Usage: thermomeneters [-d] [-h]\n");
+    fprintf(stdout, "  -d --debug              Debug on\n");
+    fprintf(stdout, "  -h --help               Display this help\n");
+}
+
+
+
+void die(int onsig)
+{
+    switch (onsig) {
+	case SIGHUP:	Log_Msg("[main] Hangup detected");
+			break;
+	case SIGINT:	Log_Msg("[main] Interrupt from keyboard");
+			break;
+	case SIGTERM:	Log_Msg("[main] Termination signal received");
+			break;
+	default:	Log_Msg("[main] die on signal %d", onsig);
+    }
+
+    exit(onsig);
+}
+
+
+
+int main(int argc, char *argv[])
+{
+    int		i, c, rc;
+    int		bForceReset = FALSE;
+    SDL_Event	event;
+    char	*path, name[128], *Range, *p;
+    FILE	*fp;
+    unsigned int	tmp1, tmp2;
+
+    while (1) {
+	int option_index = 0;
+	static struct option long_options[] = {
+	    {"debug", 0, 0, 'c'},
+	    {"help", 0, 0, 'h'},
+	    {0, 0, 0, 0}
+	};
+
+	c = getopt_long(argc, argv, "dh", long_options, &option_index);
+	if (c == -1)
+	    break;
+
+	switch (c) {
+	    case 'd':	
+			break;
+	    case 'h':	help();
+			return 1;
+	}
+    }
+
+    /*
+     *  Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored
+     *  but that's live. This daemon should only be stopped by SIGTERM.
+     *  Don't catch SIGCHLD.
+     */
+    for (i = 0; i < NSIG; i++) {
+    	if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP))
+	    signal(i, (void (*))die);
+    }
+
+
+    return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thermometers/main.h	Tue Apr 22 16:46:27 2014 +0200
@@ -0,0 +1,9 @@
+#ifndef	_MAIN_H
+#define	_MAIN_H
+
+
+#define TRUE 1
+#define FALSE 0
+
+
+#endif

mercurial