# HG changeset patch # User Michiel Broek # Date 1398177987 -7200 # Node ID 91065eba8e1b5efaa80e6231cfd85a28d195d0be # Parent ac8e19023b12e20a21b7dd3341947b903840d0e5 Added two sources diff -r ac8e19023b12 -r 91065eba8e1b thermometers/main.c --- /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 + * + * 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 +#include +#include + + +#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; +} + diff -r ac8e19023b12 -r 91065eba8e1b thermometers/main.h --- /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