File: tst_errors.c

package info (click to toggle)
oath-toolkit 2.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 20,192 kB
  • ctags: 9,804
  • sloc: ansic: 52,211; sh: 13,751; yacc: 1,252; xml: 756; makefile: 350
file content (53 lines) | stat: -rw-r--r-- 1,437 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * tst_errors.c - self-tests for libpskc strerror functions
 * Copyright (C) 2012-2013 Simon Josefsson
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#include <config.h>

#include <pskc/pskc.h>

#include <stdio.h>

int
main (void)
{
  signed i;

  for (i = 3; i >= PSKC_LAST_ERROR - 3; i--)
    {
      const char *name = pskc_strerror_name (i);
      const char *err = pskc_strerror (i);

      if ((i <= 0 && i >= PSKC_LAST_ERROR) && name == NULL)
	{
	  printf ("No error string for return code %d\n", i);
	  return 1;
	}
      if ((i > 0 || i < PSKC_LAST_ERROR) && name != NULL)
	{
	  printf ("Error string for unknown return code %d\n", i);
	  return 1;
	}

      printf ("%d: %s: %s\n", i, name, err);
    }

  return 0;
}