home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / tua / part01 / procdaily.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-23  |  1.9 KB  |  74 lines

  1. /* $Id: procdaily.c,v 3.3 1991/09/01 14:02:17 piggy Rel $
  2.  * Process the "day-by-day" report.
  3.  *
  4.  *   Copyright (C) 1991  Lele Gaifax (piggy@idea.sublink.org)
  5.  *
  6.  *   This program is free software; you can redistribute it and/or modify
  7.  *   it under the terms of the GNU General Public License as published by
  8.  *   the Free Software Foundation; either version 1, or (at your option)
  9.  *   any later version.
  10.  *
  11.  *   This program is distributed in the hope that it will be useful,
  12.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *   GNU General Public License for more details.
  15.  *
  16.  *   You should have received a copy of the GNU General Public License
  17.  *   along with this program; if not, write to the Free Software
  18.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  * SYNOPSIS:
  21.  * struct dailyrep * InsertDay(int month, int day)
  22.  *    Look for the day: if it is not there, insert it, otherwise return
  23.  *      its infos.
  24.  *
  25.  * void EnquiryDaily(void (*funct)(struct dailyrep))
  26.  *    Make the report, calling the function for each "worked" day.
  27.  *
  28.  */
  29.  
  30. #define    FALSE 0
  31. #define TRUE  1
  32.  
  33. #include    <stdio.h>        /* for NULL definition */
  34. #include    "hdbstat.h"
  35.  
  36. static dailyrep_t Calendar[13][32] =
  37. {0};
  38.  
  39. dailyrep_t *
  40. InsertDay (month, day)
  41.      short month, day;
  42. {
  43.   register dailyrep_t *dr = &Calendar[month > 12 ? 0 : month][day > 31 ? 0 : day];
  44.  
  45.   if (dr->Used)
  46.     return dr;
  47.   else
  48.     {
  49.       dr->Used = TRUE;
  50.       dr->Month = month;
  51.       dr->Day = day;
  52.       dr->FilesOut = dr->FilesIn = 0;
  53.       dr->BytesOut = dr->BytesIn = 0.0;
  54.       dr->TimeOut = dr->TimeIn = 0.0;
  55.       dr->Commands = (Tcommrep_t) NULL;
  56.       return dr;
  57.     }
  58. }
  59.  
  60. void 
  61. EnquiryDay (funct)
  62.      void (*funct) ();
  63.  
  64. {
  65.   register short month, day;    /* {2} */
  66.  
  67.   for (month = 1; month < 13; month++)
  68.     for (day = 1; day < 32; day++)
  69.       {
  70.     if (Calendar[month][day].Used)
  71.       (*funct) (Calendar[month][day]);
  72.       }
  73. }
  74.