home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / FTSER10.ZIP / ADTDV2.ZIP / cal.c next >
C/C++ Source or Header  |  1997-01-26  |  2KB  |  60 lines

  1. /*------------------------------------------------------------------------*
  2.  *  File: cal.c                                  *
  3.  *  Author: Brady Tippit  1-26-97                      *
  4.  *                                      *
  5.  *  A Unix-like calendar utility built using td.lib and Borland keywords. *                                       
  6.  *                                                                        *
  7.  *  To compile, if your turboc.cfg file has -ms in it use:          *
  8.  *  bcc cal.c td.lib   otherwise use: bcc -ms cal.c td.lib          *
  9.  *                                      *
  10.  *------------------------------------------------------------------------*/
  11.  
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include "datelib.h"
  17.  
  18.  
  19. int main(int argc, char *argv[])
  20. {
  21.    int theYear, theMonth;
  22.    tdtype *date;           /* Declare a pointer to a tdtype. */
  23.    
  24.  
  25.    if(argc == 2 && !strcmp(argv[1], "-?"))
  26.    {
  27.      fprintf(stdout, "\nSyntax: cal [month] [year]\n");
  28.      fprintf(stdout, "Usage: prints out the calendar month for\n");
  29.      fprintf(stdout, "any year from Jan 1, 1 A.D. to Dec 31 32766\n");
  30.      fprintf(stdout, "Example: cal 7 1776, or cal 1 1\n");
  31.      fprintf(stdout, "Remember to give the exact year that\n");
  32.      fprintf(stdout, "you want. Don't abbreviate!\n");
  33.      fprintf(stdout, "For the current month, just type cal.\n");
  34.      return(1);
  35.    }
  36.    else
  37.     if(argc != 1 && argc != 3)
  38.     {
  39.       fprintf(stderr, "\nCal requires 0 or 2 arguments\n");
  40.       fprintf(stdout, "For help type  cal -?\n");
  41.       return(1);
  42.     }
  43.     if(argc == 1)
  44.     {
  45.       date = TimeDate();     /* Initialize and fill all fields.   */
  46.       theMonth = date->td_mon;     /* Access the month and year fields. */
  47.       theYear = date->td_year;
  48.     }
  49.     else
  50.      if(argc == 3)
  51.      {
  52.        theMonth = atoi(argv[1]);
  53.        theYear  = atoi(argv[2]);
  54.      }
  55.  
  56.      PrintCalendar(theMonth, theYear);
  57.   
  58.    return(0);
  59. }
  60.