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
26 main (int argc
, char *argv
[])
33 if (strcmp (argv
[argc
- 1], "-v") == 0 ||
34 strcmp (argv
[argc
- 1], "--verbose") == 0)
36 else if (strcmp (argv
[argc
- 1], "-d") == 0 ||
37 strcmp (argv
[argc
- 1], "--debug") == 0)
39 else if (strcmp (argv
[argc
- 1], "-b") == 0 ||
40 strcmp (argv
[argc
- 1], "--break-on-error") == 0)
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]);
55 fail ("Could not initialize shishi\n");
60 shishi_cfg (handle
, strdup ("verbose"));
62 escapeprint (NULL
, 0);
66 /* shishi_authenticator_ctime_set() */
67 p
= shishi_generalize_time (handle
, (time_t) 4711);
70 if (p
&& memcmp (p
, "19700101011831Z", 15) == 0)
71 success ("shishi_generalize_time() OK\n");
73 fail ("shishi_generalize_time() failed\n");
75 /* shishi_generalize_ctime() */
76 n
= (int) shishi_generalize_ctime (handle
, p
);
78 printf ("shishi_generalize_ctime () => `%d'.\n", n
);
80 success ("shishi_generalize_ctime() OK\n");
82 fail ("shishi_generalize_ctime() failed\n");
87 printf ("Generalized time self tests done with %d errors\n", error_count
);
89 return error_count
? 1 : 0;