Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / bind / dist / lib / isc / win32 / resource.c
blobe2c0d43e2f8fb518e1ee9cb7b1809b8375de14ee
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2004, 2007, 2008 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: resource.c,v 1.10 2008/07/11 23:47:09 tbox Exp */
22 #include <config.h>
24 #include <stdio.h>
26 #include <isc/platform.h>
27 #include <isc/resource.h>
28 #include <isc/result.h>
29 #include <isc/util.h>
31 #include "errno2result.h"
34 * Windows limits the maximum number of open files to 2048
37 #define WIN32_MAX_OPEN_FILES 2048
39 isc_result_t
40 isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
41 isc_resourcevalue_t rlim_value;
42 int wresult;
44 if (resource != isc_resource_openfiles)
45 return (ISC_R_NOTIMPLEMENTED);
48 if (value == ISC_RESOURCE_UNLIMITED)
49 rlim_value = WIN32_MAX_OPEN_FILES;
50 else
51 rlim_value = min(value, WIN32_MAX_OPEN_FILES);
53 wresult = _setmaxstdio((int) rlim_value);
55 if (wresult > 0)
56 return (ISC_R_SUCCESS);
57 else
58 return (isc__errno2result(errno));
61 isc_result_t
62 isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
64 if (resource != isc_resource_openfiles)
65 return (ISC_R_NOTIMPLEMENTED);
67 *value = WIN32_MAX_OPEN_FILES;
68 return (ISC_R_SUCCESS);
71 isc_result_t
72 isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
73 return (isc_resource_getlimit(resource, value));