1 /* -*- mode:C; c-file-style: "bsd" -*- */
2 /*
3 * Written by Richard Levitte <richard@levitte.org>
4 * Copyright (c) 2008-2012 Yubico AB
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include "ykcore_lcl.h"
33 #include "ykdef.h"
34 #include "ykstatus.h"
35
ykds_alloc(void)36 YK_STATUS *ykds_alloc(void)
37 {
38 YK_STATUS *st = malloc(sizeof(YK_STATUS));
39 if (!st) {
40 yk_errno = YK_ENOMEM;
41 }
42 return st;
43 }
44
ykds_free(YK_STATUS * st)45 void ykds_free(YK_STATUS *st)
46 {
47 free(st);
48 }
49
ykds_static(void)50 YK_STATUS *ykds_static(void)
51 {
52 static YK_STATUS st;
53 return &st;
54 }
55
ykds_version_major(const YK_STATUS * st)56 extern int ykds_version_major(const YK_STATUS *st)
57 {
58 if (st)
59 return st->versionMajor;
60 yk_errno = YK_ENOSTATUS;
61 return 0;
62 }
ykds_version_minor(const YK_STATUS * st)63 extern int ykds_version_minor(const YK_STATUS *st)
64 {
65 if (st)
66 return st->versionMinor;
67 yk_errno = YK_ENOSTATUS;
68 return 0;
69 }
ykds_version_build(const YK_STATUS * st)70 extern int ykds_version_build(const YK_STATUS *st)
71 {
72 if (st)
73 return st->versionBuild;
74 yk_errno = YK_ENOSTATUS;
75 return 0;
76 }
ykds_pgm_seq(const YK_STATUS * st)77 extern int ykds_pgm_seq(const YK_STATUS *st)
78 {
79 if (st)
80 return st->pgmSeq;
81 yk_errno = YK_ENOSTATUS;
82 return 0;
83 }
ykds_touch_level(const YK_STATUS * st)84 extern int ykds_touch_level(const YK_STATUS *st)
85 {
86 if (st)
87 return st->touchLevel;
88 yk_errno = YK_ENOSTATUS;
89 return 0;
90 }
91