Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

nsutil.c

Go to the documentation of this file.
00001 /*
00002 NeuroServer
00003  
00004 A collection of programs to translate between EEG data and TCP network
00005 messages. This is a part of the OpenEEG project, see http://openeeg.sf.net
00006 for details.
00007     
00008 Copyright (C) 2003, 2004 Rudi Cilibrasi (cilibrar@ofb.net)
00009      
00010 This library is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU Lesser General Public
00012 License as published by the Free Software Foundation; either
00013 version 2.1 of the License, or (at your option) any later version.
00014          
00015 This library is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 Lesser General Public License for more details.
00019              
00020 You should have received a copy of the GNU Lesser General Public
00021 License along with this library; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00023 */
00024                 
00025 #include <stdio.h>
00026 #include <stdarg.h>
00027 #include <assert.h>
00028 #include "nsutil.h"
00029 
00030 #ifdef __MINGW32__
00031 #include <windows.h>
00032 #else
00033 #include <unistd.h>
00034 #endif
00035 
00036 int max_fd = 0;
00037 
00038 void rtime(time_t *t)
00039 {
00040         time(t);
00041 }
00042 
00043 void updateMaxFd(int fd)
00044 {
00045         if (max_fd < fd + 1)
00046                 max_fd = fd + 1;
00047 }
00048 
00049 int rprintf(const char *fmt, ...)
00050 {
00051         int retval;
00052         char buf[4096];
00053         va_list va;
00054         buf[4095] = '\0';
00055         va_start(va, fmt);
00056         vsnprintf(buf, 4095, fmt, va);
00057         va_end(va);
00058         retval = fprintf(stdout, "%s", buf);
00059         fflush(stdout);
00060         return retval;
00061 }
00062 
00063 int rexit(int errcode) {
00064         printf("Exitting with error code %d\n", errcode);
00065         fflush(stdout);
00066         *((char *) 0) = 0;
00067         assert(0);
00068         return 0;
00069 }
00070 void rsleep(int ms)
00071 {
00072 #ifdef __MINGW32__
00073         Sleep(ms);
00074 #else
00075         usleep(ms*10000);
00076 #endif
00077 }

Generated on Tue Feb 8 00:05:16 2005 for Neuroserver by doxygen 1.3.3