timedeb.c

Go to the documentation of this file.
00001 /* timedeb.c */
00002 
00003 /* Este archivo tiene como único fin realizar el debug de la
00004  * libreria time.c */
00005 
00006 #include "routix/time.h"
00007 #include "routix/timer.h"
00008 
00009 #ifndef __SYSTEM
00010 #include "routix/system.h"
00011 #endif
00012 
00013 
00014 #define cmd(comando)    ( ! strcmp(msg,comando) )
00015 
00016 // Funciones
00017 void dump_tm();
00018 void bisiestos();
00019 void local();
00020 
00021 
00022 void time_debug(void) {
00023 
00024  char msg[80];
00025  while(1) {
00026    kprintf("tmdebug > ");
00027    gets(msg);
00028 
00029    if ( cmd("exit") ) { return; }
00030    else if ( cmd("dump") ) { dump_tm(); }
00031    else if ( cmd("bis")  ) { bisiestos(); }
00032    else if ( cmd("tod")  ) { kprintf("tod: %d\n",mktime( localtime(NULL) )); }
00033    else if ( cmd("localtime") ) { local(); }
00034    else if ( cmd("asctime") ) { asctime( localtime(NULL) ); }
00035    else if ( cmd("jiffies") ) { kprintf("jiffies: %d\n",jiffies); }
00036    else if ( cmd("excepcion") ) { dword *prueba=(dword *) 0xfffffff; *prueba=2; }
00037 
00038  }
00039 
00040 }
00041 
00042 
00043 
00044 
00045 void dump_tm()
00046 {
00047  struct tm *tm;
00048 
00049  tm = localtime(NULL);
00050 
00051  kprintf(" tm_seg=%d\n tm_min=%d\n tm_hour=%d\n",tm->tm_sec,tm->tm_min,tm->tm_hour);
00052  kprintf(" tm_mday=%d\n tm_mon=%d\n tm_year=%d\n",tm->tm_mday,tm->tm_mon,tm->tm_year);
00053  kprintf(" tm_wday=%d\n tm_yday=%d",tm->tm_wday,tm->tm_yday);
00054 
00055 }
00056 
00057 void bisiestos()
00058 {
00059  int i,counter;
00060  char msg[80];
00061 
00062  gets(msg);
00063  i=atoi(msg);
00064 
00065  for ( counter=0; counter < 10; counter++,i++) {
00066   if ( es_bisiesto(i) ) { kprintf("%d es bisiesto\n",i); }
00067   else { kprintf("%d no es bisiesto\n",i); }
00068  }
00069  
00070 }
00071 
00072 
00073 void local()
00074 {
00075  struct tm *tm;
00076  time_t tod;
00077  
00078  tod = mktime( localtime(NULL) );
00079 
00080 
00081  tm = localtime(NULL);
00082 
00083  kprintf(" tm_seg=%d\n tm_min=%d\n tm_hour=%d\n",tm->tm_sec,tm->tm_min,tm->tm_hour);
00084  kprintf(" tm_mday=%d\n tm_mon=%d\n tm_year=%d\n",tm->tm_mday,tm->tm_mon,tm->tm_year);
00085  kprintf(" tm_wday=%d\n",tm->tm_wday);
00086 
00087  kprintf("\ntod: %d\n",tod);
00088 
00089  tm = localtime(&tod);
00090 
00091  kprintf(" tm_seg=%d\n tm_min=%d\n tm_hour=%d\n",tm->tm_sec,tm->tm_min,tm->tm_hour);
00092  kprintf(" tm_mday=%d\n tm_mon=%d\n tm_year=%d\n",tm->tm_mday,tm->tm_mon,tm->tm_year);
00093  kprintf(" tm_wday=%d\n",tm->tm_wday);
00094  
00095 }

Generated on Sun May 30 18:38:35 2004 for Routix OS by doxygen 1.3.6