No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / bind / dist / bin / tests / fsaccess_test.c
blob6647d1b1fd6e79d6d6f5340f2673f1f3973e2cac
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2000, 2001 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: fsaccess_test.c,v 1.13 2007/06/19 23:46:59 tbox Exp */
22 /*! \file */
24 #include <config.h>
26 #include <stdio.h>
28 #include <sys/types.h> /* Non-portable. */
29 #include <sys/stat.h> /* Non-portable. */
31 #include <isc/fsaccess.h>
32 #include <isc/result.h>
34 #define PATH "/tmp/fsaccess"
36 int
37 main(void) {
38 isc_fsaccess_t access;
39 isc_result_t result;
41 remove(PATH);
42 fopen(PATH, "w");
43 chmod(PATH, 0);
45 access = 0;
47 isc_fsaccess_add(ISC_FSACCESS_OWNER | ISC_FSACCESS_GROUP,
48 ISC_FSACCESS_READ | ISC_FSACCESS_WRITE,
49 &access);
51 printf("fsaccess=%d\n", access);
53 isc_fsaccess_add(ISC_FSACCESS_OTHER, ISC_FSACCESS_READ, &access);
55 printf("fsaccess=%d\n", access);
57 result = isc_fsaccess_set(PATH, access);
58 if (result != ISC_R_SUCCESS)
59 fprintf(stderr, "result = %s\n", isc_result_totext(result));
61 return (0);