Add LIBTASN1_CFLAGS.
[shishi.git] / tests / gztime.c
blobd036744e19c093da1db6ec148c19e7184a9a6362
1 /* gztime.c Shishi generalized time self tests.
2 * Copyright (C) 2002, 2003 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Shishi 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "utils.c"
23 #include <shishi.h>
25 int
26 main (int argc, char *argv[])
28 Shishi *handle;
29 const char *p;
30 int n;
33 if (strcmp (argv[argc - 1], "-v") == 0 ||
34 strcmp (argv[argc - 1], "--verbose") == 0)
35 verbose = 1;
36 else if (strcmp (argv[argc - 1], "-d") == 0 ||
37 strcmp (argv[argc - 1], "--debug") == 0)
38 debug = 1;
39 else if (strcmp (argv[argc - 1], "-b") == 0 ||
40 strcmp (argv[argc - 1], "--break-on-error") == 0)
41 break_on_error = 1;
42 else if (strcmp (argv[argc - 1], "-h") == 0 ||
43 strcmp (argv[argc - 1], "-?") == 0 ||
44 strcmp (argv[argc - 1], "--help") == 0)
46 printf ("Usage: %s [-vdbh?] [--verbose] [--debug] "
47 "[--break-on-error] [--help]\n", argv[0]);
48 return 1;
50 while (argc-- > 1);
52 handle = shishi ();
53 if (handle == NULL)
55 fail ("Could not initialize shishi\n");
56 return 1;
59 if (debug)
60 shishi_cfg (handle, strdup ("verbose"));
62 escapeprint (NULL, 0);
63 hexprint (NULL, 0);
64 binprint (NULL, 0);
66 /* shishi_authenticator_ctime_set() */
67 p = shishi_generalize_time (handle, (time_t) 4711);
68 if (debug)
69 escapeprint (p, 15);
70 if (p && memcmp (p, "19700101011831Z", 15) == 0)
71 success ("shishi_generalize_time() OK\n");
72 else
73 fail ("shishi_generalize_time() failed\n");
75 /* shishi_generalize_ctime() */
76 n = (int) shishi_generalize_ctime (handle, p);
77 if (debug)
78 printf ("shishi_generalize_ctime () => `%d'.\n", n);
79 if (n == 4711)
80 success ("shishi_generalize_ctime() OK\n");
81 else
82 fail ("shishi_generalize_ctime() failed\n");
84 shishi_done (handle);
86 if (verbose)
87 printf ("Generalized time self tests done with %d errors\n", error_count);
89 return error_count ? 1 : 0;