h_errno.c revision 156956
1214571Sdim/*- 2214571Sdim * Copyright (c) 2006 The FreeBSD Project. All rights reserved. 3214571Sdim * 4214571Sdim * Redistribution and use in source and binary forms, with or without 5214571Sdim * modification, are permitted provided that the following conditions 6214571Sdim * are met: 7214571Sdim * 1. Redistributions of source code must retain the above copyright 8214571Sdim * notice, this list of conditions and the following disclaimer. 9214571Sdim * 2. Redistributions in binary form must reproduce the above copyright 10214571Sdim * notice, this list of conditions and the following disclaimer in the 11214571Sdim * documentation and/or other materials provided with the distribution. 12214571Sdim * 13214571Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14214571Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15214571Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16214571Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17214571Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18214571Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19214571Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20214571Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21214571Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22214571Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23214571Sdim * SUCH DAMAGE. 24214571Sdim * 25214571Sdim * $FreeBSD: head/lib/libc/resolv/h_errno.c 156956 2006-03-21 15:37:16Z ume $ 26214571Sdim */ 27214571Sdim 28214571Sdim#include <sys/types.h> 29214571Sdim#include <netinet/in.h> 30214571Sdim#include <arpa/nameser.h> 31214571Sdim#include <resolv.h> 32214571Sdim 33214571Sdim#undef h_errno 34214571Sdimextern int h_errno; 35214571Sdim 36214571Sdimint * 37214571Sdim__h_errno(void) 38214571Sdim{ 39214571Sdim return (&__res_state()->res_h_errno); 40214571Sdim} 41214571Sdim 42214571Sdimvoid 43214571Sdim__h_errno_set(res_state res, int err) 44214571Sdim{ 45214571Sdim h_errno = res->res_h_errno = err; 46214571Sdim} 47214571Sdim 48214571Sdim/* binary backward compatibility for FreeBSD 5.x and 6.x */ 49214571Sdim__weak_reference(__h_errno, __h_error); 50214571Sdim