plugins/time/scrTime.c

00001 /*
00002  * Copyright Ian Burnett 2005, 2006.
00003  *
00004  * This file is part of Ian's Interactive LCD controller (IILC).
00005  * 
00006  * IILC is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU General Public License as published by the Free
00008  * Software Foundation; either version 2 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * IILC is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00014  * for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with IILC; if not, write to the Free Software Foundation, Inc.,
00018  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
00019  */
00020 
00021 #if !defined(_WIN32)
00022 #   include <strings.h>
00023 #endif
00024 
00025 #include <time.h>
00026 
00027 #include "scrTime.h"
00028 
00029 
00030 typedef struct _tag_screen_time
00031 {
00032     int dummy;
00033 
00034 
00035 
00036 } SCREEN_TIME, * LPSCREEN_TIME;
00037 
00038 
00039 int ModuleCreate(int handle, void ** context, LPMODULE_FN_ARRAY pFnArray)
00040 {
00041     /* We can use fn array version 1 */
00042     pFnArray->version = 1;
00043 
00044     /* Setup our various functions */
00045     pFnArray->pfnTextData = GetDisplayData;
00046 
00047     return 0;
00048 }
00049 
00050 
00051 int ModuleDestroy(void * context)
00052 {
00053     printf("In ModuleDestroy\n");
00054 
00055     return 0;
00056 }
00057 
00058 
00059 int GetDisplayData(void * context, int row, int nWidth, char * buf)
00060 {
00061     char * lfChar = NULL;
00062     char localBuf[1024];
00063     time_t now;
00064 
00065     /* Grab the current time */
00066     time(&now);
00067 
00068     /* Drop into the buffer (watch for thread-safety) */
00069     ctime_r(&now, localBuf);
00070 
00071     /* Remove the '\n' character */
00072     lfChar = index(localBuf, '\n');
00073     if (lfChar != NULL) {
00074         *lfChar = '\0';
00075     }
00076 
00077     sprintf(buf, "%s", localBuf);
00078 
00079     return 0;
00080 }

Generated on Mon Jul 17 01:36:11 2006 for IILC by  doxygen 1.4.6