Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

test_load_ttref.c

This file shows how to use test_tz_conf().

#include <stdio.h>
#include "date.h"

extern int                ttref_line_num;
extern struct ttref_tab   ttrefs;


int main (int argc, char* argv[])
{
  int   cr;
  int   i;
  char  *conf;

  if (argc != 3)
  {
    fprintf (stderr, "\nUsage: load_ttref.test <ttref config file> <tz config file>\n\n");
    return 1;
  }

  /***************************************************/
  /* Load Time Zones Configuration file              */
  /***************************************************/

  cr = load_timezones(argv[2]);
  if (cr != TIME_ZONES_LOAD_OK)
  {
    fprintf (stderr, "\nload_timezones() failed - Error code is: %d\n", cr);
    return 1;
  }

  /***************************************************/
  /* Set local time zone to UTC                      */
  /***************************************************/

   if (set_local_TZ_to_GMT())
   {
     fprintf (stderr, "\nCan not set local time zone to UTC!!!\n");
     return 1;
   }

  /***************************************************/
  /* Compute timestamps references                   */
  /***************************************************/

  cr = test_tz_conf(argv[1], TZ_AUTOCONF_OFF);

  if (cr != TTREF_OK)
  {
    fprintf (stderr, "\nError code is: %d\n", cr);

    if (cr != TTREF_KO) { return 1; }

    fprintf (stdout, "\n\nSwitching into auto configuration mode ...\n");

    cr = test_tz_conf(argv[1], TZ_AUTOCONF_ON);
    if (cr != TTREF_OK)
    {
       fprintf (stderr, "\nError code is: %d\n", cr);
       return 1;
    }
  }


  conf = print_tz_conf();
  if (conf != NULL)
  {
    fprintf (stdout, "\nNew time zone configuration is: \n%s\n\n", conf);
    free (conf);
  }


  /***************************************************/
  /* Print references                                */
  /***************************************************/

  fprintf (stdout, "\n\nTTREF configuration (%d):\n\n", ttrefs.entry_number);
  for (i=0; i<ttrefs.entry_number; i++)
  {
    fprintf (stdout, "\n -> %s", ((ttrefs.ttref)[i]).date);
    fprintf (stdout, "\n    %s", ((ttrefs.ttref)[i]).timestamp);
  }
  fprintf (stdout, "\n\n");



  fprintf (stdout, "\n\nTimeStamps check is OK\n\n");

  return 0;
}

Generated on Thu Apr 3 16:23:41 2003 for Common_C_libraries by doxygen1.3-rc1