/* $Id: seti.c,v 1.8 2003/06/13 05:11:11 reinelt Exp $ * * seti@home specific functions * * Copyright 2001 by Axel Ehnert * * This program 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. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * $Log: seti.c,v $ * Revision 1.8 2003/06/13 05:11:11 reinelt * error message cosmetics * * Revision 1.7 2003/02/22 07:53:10 reinelt * cfg_get(key,defval) * * Revision 1.6 2001/09/12 05:37:22 reinelt * * fixed a bug in seti.c (file was never closed, lcd4linux run out of fd's * * improved socket debugging * * Revision 1.5 2001/08/05 17:13:29 reinelt * * cleaned up inlude of sys/time.h and time.h * * Revision 1.4 2001/03/08 09:02:04 reinelt * * seti client cleanup * * Revision 1.3 2001/02/19 00:15:46 reinelt * * integrated mail and seti client * major rewrite of parser and tokenizer to support double-byte tokens * * Revision 1.2 2001/02/18 21:16:06 reinelt * *** empty log message *** * * Revision 1.1 2001/02/18 21:15:15 reinelt * * added setiathome client * */ /* * exported functions: * * Seti (int *perc, int *cput) * returns 0 if ok, -1 if error * sets *perc to the percentage completed by seti@home client * sets *perc to the cpu time used * */ #define STATEFILE "state.sah" #include #include #include #include #include #include #include #include #include #include "cfg.h" #include "debug.h" #include "seti.h" int Seti (double *perc, double *cput) { static char fn[256]; static time_t now=0; static int fd=-2; static double v1=0; static double v2=0; char buffer[8192], *p; *perc=v1; *cput=v2; if (fd==-1) return -1; if (time(NULL)==now) return 0; time(&now); if (fd==-2) { char *dir=cfg_get("SetiDir",NULL); if (dir==NULL || *dir=='\0') { error ("no 'SetiDir' entry in %s!\n", cfg_file()); fd=-1; return -1; } if (strlen(dir)>sizeof(fn)-sizeof(STATEFILE)-2) { error ("entry 'SetiDir' too long in %s!\n", cfg_file()); fd=-1; return -1; } strcpy(fn, dir); strcat(fn, "/"); strcat(fn, STATEFILE); } fd = open(fn, O_RDONLY); if (fd==-1) { error ("open(%s) failed: %s", fn, strerror(errno)); return -1; } if (read (fd, &buffer, sizeof(buffer)-1)==-1) { error ("read(%s) failed: %s", fn, strerror(errno)); close (fd); fd=-1; return -1; } close (fd); p=strstr(buffer, "prog="); if (p==NULL) { error ("parse(%s) failed: no 'prog=' line", fn); fd=-1; return -1; } if (sscanf(p+5, "%lf", &v1)!=1) { error ("parse(%s) failed: unknown 'prog=' format", fn); fd=-1; return -1; } p=strstr(buffer, "cpu="); if (p==NULL) { error ("parse(%s) failed: no 'cpu=' line", fn); fd=-1; return -1; } if (sscanf(p+4, "%lf", &v2)!=1) { error ("parse(%s) failed: unknown 'cpu=' format", fn); fd=-1; return -1; } *perc=v1; *cput=v2; return 0; } 641cea4f304e68a29ec1335b7b4215035c0&follow=1'>plugin_huawei-fix-interval-check_V2.patch from Jarmichael1-35/+35 2010-02-12Improved config behavior.mjona1-9/+32 2010-02-12Fixed a segmentation fault bug in cfg_get().mjona1-1/+1 2010-02-11All static memory allocations were turned into dynamical ones.mjona1-128/+200 2010-02-07timer.c: two small optimizations (removed "flag"; tv_usec can't be negative)mzuther1-7/+4 2010-02-07added grouping of widgets by update interval (new file "timer_group.c")mzuther13-168/+441 2010-02-07BUG: handle negative delays in timer_process() (timer.c)mzuther1-0/+4 2010-02-06timer.c: I had forgotten how to initialize a "struct" :)mzuther1-3/+4 2010-02-06BUG: compensate timers for processing delay ("timer.c")mzuther1-1/+3 2010-02-06timer.c: exchanged "proprietary code" with timeradd() and timersub() functionsmzuther1-14/+10 2010-02-04timer.c: removed fruitless changes to variable "flag" from timer_process()mzuther1-2/+0 2010-02-04According to its man page, timercmp() is broken on some systems -- applied th...mzuther1-1/+1 2010-02-04small warning removedmichael1-1/+1 2010-02-04clear errno after creating the FIFO by Claas Hilbrechtmichael1-0/+2 t-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@901 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-11-22update fifo plugin - untestedmichux1-1/+1 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@900 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-10-07Replace write to external variable usb_debug by calling usb_set_debug().bwalle7-16/+7 This fixes build on openSUSE Factory. git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@899 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-10-06adding GPI to picoLCD for reading button events by Igor Mammedov ↵michael1-1/+22 <niallain@gmail.com> git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@898 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-10-06properties fixedmichael11-3290/+2675 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@897 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-10-05Rebuild auto-generated autoconf stuff due to last change in drivers.m4.bwalle3-2657/+3297 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@896 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-10-05Add 'ULA200' driver when --with-drivers=all is specifiedbwalle1-0/+1 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@895 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-09-14strftime_tz patch from Bernhard Wallemichael1-0/+11 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@894 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-09-08strftime_tz() plugin by Bernhard Wallemichael1-0/+25 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@893 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-09-03ULA200 driver by Bernhard Wallemichael7-2/+825 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@892 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-09-03indentmichael1-4/+4 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@891 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-08-31Increased the maximum bps to 230400, if defined in <termios.h>.sonic741-2/+7 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@890 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-08-27git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@889 ↵sonic741-18/+11 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-08-27D4D updates by Svenmichael1-38/+60 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@888 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-08-03driver for 4D Systems serial displays by Sven Killigmichael9-45/+846 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@887 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-08-03signed/unsigned mismatchmichael1-3/+3 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@886 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-07-26added command functionsmichux1-2/+130 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@885 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-07-15added IRLCD driver by Jean-Philippe Civademichael10-5/+467 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@884 3ae390bd-cb1e-0410-b409-cd5a39f66f1f 2008-07-15'autoreconf -f -i' run & config.rpath addedmichael8-370/+1617 git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@883 3ae390bd-cb1e-0410-b409-cd5a39f66f1f