1160814Ssimon/* crypto/o_dir.h -*- mode:C; c-file-style: "eay" -*- */
2160814Ssimon/* Copied from Richard Levitte's (richard@levitte.org) LP library.  All
3160814Ssimon * symbol names have been changed, with permission from the author.
4160814Ssimon */
5160814Ssimon
6160814Ssimon/* $LP: LPlib/test/test_dir.c,v 1.1 2004/06/16 22:59:47 _cvs_levitte Exp $ */
7160814Ssimon/*
8160814Ssimon * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
9160814Ssimon * All rights reserved.
10160814Ssimon *
11160814Ssimon * Redistribution and use in source and binary forms, with or without
12160814Ssimon * modification, are permitted provided that the following conditions
13160814Ssimon * are met:
14160814Ssimon * 1. Redistributions of source code must retain the above copyright
15160814Ssimon *    notice, this list of conditions and the following disclaimer.
16160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright
17160814Ssimon *    notice, this list of conditions and the following disclaimer in the
18160814Ssimon *    documentation and/or other materials provided with the distribution.
19160814Ssimon *
20160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21160814Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23160814Ssimon * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24160814Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25160814Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26160814Ssimon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28160814Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29160814Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30160814Ssimon * SUCH DAMAGE.
31160814Ssimon */
32160814Ssimon
33160814Ssimon#include <stddef.h>
34160814Ssimon#include <stdlib.h>
35160814Ssimon#include <stdio.h>
36160814Ssimon#include <errno.h>
37160814Ssimon#include "e_os2.h"
38160814Ssimon#include "o_dir.h"
39160814Ssimon
40160814Ssimon#if defined OPENSSL_SYS_UNIX || defined OPENSSL_SYS_WIN32 || defined OPENSSL_SYS_WINCE
41160814Ssimon#define CURRDIR "."
42160814Ssimon#elif defined OPENSSL_SYS_VMS
43160814Ssimon#define CURRDIR "SYS$DISK:[]"
44160814Ssimon#else
45160814Ssimon#error "No supported platform defined!"
46160814Ssimon#endif
47160814Ssimon
48160814Ssimonint main()
49160814Ssimon{
50160814Ssimon  OPENSSL_DIR_CTX *ctx = NULL;
51160814Ssimon  const char *result;
52160814Ssimon
53160814Ssimon  while((result = OPENSSL_DIR_read(&ctx, CURRDIR)) != NULL)
54160814Ssimon    {
55160814Ssimon      printf("%s\n", result);
56160814Ssimon    }
57160814Ssimon
58160814Ssimon  if (errno)
59160814Ssimon    {
60160814Ssimon      perror("test_dir");
61160814Ssimon      exit(1);
62160814Ssimon    }
63160814Ssimon
64160814Ssimon  if (!OPENSSL_DIR_end(&ctx))
65160814Ssimon    {
66160814Ssimon      perror("test_dir");
67160814Ssimon      exit(2);
68160814Ssimon    }
69160814Ssimon  exit(0);
70160814Ssimon}
71