1178825Sdfr/* 2233294Sstas * Copyright (c) 2006 Kungliga Tekniska H��gskolan 3233294Sstas * (Royal Institute of Technology, Stockholm, Sweden). 4233294Sstas * All rights reserved. 5178825Sdfr * 6233294Sstas * Redistribution and use in source and binary forms, with or without 7233294Sstas * modification, are permitted provided that the following conditions 8233294Sstas * are met: 9178825Sdfr * 10233294Sstas * 1. Redistributions of source code must retain the above copyright 11233294Sstas * notice, this list of conditions and the following disclaimer. 12178825Sdfr * 13233294Sstas * 2. Redistributions in binary form must reproduce the above copyright 14233294Sstas * notice, this list of conditions and the following disclaimer in the 15233294Sstas * documentation and/or other materials provided with the distribution. 16178825Sdfr * 17178825Sdfr * 3. Neither the name of KTH nor the names of its contributors may be 18178825Sdfr * used to endorse or promote products derived from this software without 19178825Sdfr * specific prior written permission. 20178825Sdfr * 21178825Sdfr * THIS SOFTWARE IS PROVIDED BY KTH AND ITS CONTRIBUTORS ``AS IS'' AND ANY 22178825Sdfr * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24178825Sdfr * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KTH OR ITS CONTRIBUTORS BE 25178825Sdfr * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26178825Sdfr * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27178825Sdfr * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 28178825Sdfr * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29178825Sdfr * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30178825Sdfr * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31178825Sdfr * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 32178825Sdfr 33178825Sdfr#include "kadmin_locl.h" 34178825Sdfr 35178825Sdfrkrb5_context context; 36178825Sdfrvoid *kadm_handle; 37178825Sdfr 38178825Sdfrstruct { 39178825Sdfr const char *str; 40178825Sdfr int ret; 41178825Sdfr time_t t; 42178825Sdfr} ts[] = { 43178825Sdfr { "2006-12-22 18:09:00", 0, 1166810940 }, 44178825Sdfr { "2006-12-22", 0, 1166831999 }, 45178825Sdfr { "2006-12-22 23:59:59", 0, 1166831999 } 46178825Sdfr}; 47178825Sdfr 48178825Sdfrstatic int 49178825Sdfrtest_time(void) 50178825Sdfr{ 51178825Sdfr int i, errors = 0; 52178825Sdfr 53178825Sdfr for (i = 0; i < sizeof(ts)/sizeof(ts[0]); i++) { 54178825Sdfr time_t t; 55178825Sdfr int ret; 56178825Sdfr 57178825Sdfr ret = str2time_t (ts[i].str, &t); 58178825Sdfr if (ret != ts[i].ret) { 59178825Sdfr printf("%d: %d is wrong ret\n", i, ret); 60178825Sdfr errors++; 61233294Sstas } 62178825Sdfr else if (t != ts[i].t) { 63178825Sdfr printf("%d: %d is wrong time\n", i, (int)t); 64178825Sdfr errors++; 65178825Sdfr } 66178825Sdfr } 67233294Sstas 68178825Sdfr return errors; 69178825Sdfr} 70178825Sdfr 71178825Sdfr 72178825Sdfrint 73178825Sdfrmain(int argc, char **argv) 74178825Sdfr{ 75178825Sdfr krb5_error_code ret; 76178825Sdfr 77178825Sdfr setprogname(argv[0]); 78178825Sdfr 79178825Sdfr ret = krb5_init_context(&context); 80178825Sdfr if (ret) 81178825Sdfr errx (1, "krb5_init_context failed: %d", ret); 82178825Sdfr 83178825Sdfr ret = 0; 84178825Sdfr ret += test_time(); 85178825Sdfr 86178825Sdfr krb5_free_context(context); 87178825Sdfr 88178825Sdfr return ret; 89178825Sdfr} 90233294Sstas 91