Fix libcares.pc generation for static MingW* cross builds
[platform/upstream/c-ares.git] / ares_library_init.3
1 .\"
2 .\" Copyright 1998 by the Massachusetts Institute of Technology.
3 .\" Copyright (C) 2004-2009 by Daniel Stenberg
4 .\"
5 .\" Permission to use, copy, modify, and distribute this
6 .\" software and its documentation for any purpose and without
7 .\" fee is hereby granted, provided that the above copyright
8 .\" notice appear in all copies and that both that copyright
9 .\" notice and this permission notice appear in supporting
10 .\" documentation, and that the name of M.I.T. not be used in
11 .\" advertising or publicity pertaining to distribution of the
12 .\" software without specific, written prior permission.
13 .\" M.I.T. makes no representations about the suitability of
14 .\" this software for any purpose.  It is provided "as is"
15 .\" without express or implied warranty.
16 .\"
17 .TH ARES_LIBRARY_INIT 3 "19 May 2009"
18 .SH NAME
19 ares_library_init \- c-ares library initialization
20 .SH SYNOPSIS
21 .nf
22 .B #include <ares.h>
23 .PP
24 .B int ares_library_init(int \fIflags\fP)
25 .PP
26 .B cc file.c -lcares
27 .fi
28 .SH DESCRIPTION
29 .PP
30 The
31 .B ares_library_init
32 function performs initializations internally required by the c-ares
33 library that must take place before any other function provided by
34 c-ares can be used in a program.
35 .PP
36 This function must be called one time within the life of a program,
37 before the program actually executes any other c-ares library function.
38 Initializations done by this function remain effective until a
39 call to \fIares_library_cleanup(3)\fP is performed.
40 .PP
41 Successive calls to this function do nothing, only the first call done
42 when c-ares is in an uninitialized state is actually effective.
43 .PP
44 The
45 .I flags
46 parameter is a bit pattern that tells c-ares exactly which features
47 should be initialized, as described below. Set the desired bits by
48 ORing the values together. In normal operation you should specify
49 \fIARES_LIB_INIT_ALL\fP. Don't use any other value unless you are
50 familiar with it and trying to control some internal c-ares feature.
51 .PP
52 .B This function is not thread safe.
53 You have to call it once the program has started, but this call must be done
54 before the program starts any other thread. This is required to avoid
55 potential race conditions in library initialization, and also due to the fact
56 that \fIares_library_init(3)\fP might call functions from other libraries that
57 are thread unsafe, and could conflict with any other thread that is already
58 using these other libraries.
59 .PP
60 Win32/64 application DLLs shall not call \fIares_library_init(3)\fP from the
61 DllMain function. Doing so will produce deadlocks and other problems.
62 .SH FLAGS
63 .TP 5
64 .B ARES_LIB_INIT_ALL
65 Initialize everything possible. This sets all known bits.
66 .TP
67 .B ARES_LIB_INIT_WIN32
68 Initialize Win32/64 specific libraries.
69 .TP
70 .B ARES_LIB_INIT_NONE
71 Initialize nothing extra. This sets no bit.
72 .SH RETURN VALUE
73 Upon successful completion, ares_library_init() will return 0.  Otherwise, a
74 non-zero error number will be returned to indicate the error. Except for
75 \fIares_strerror(3)\fP, you shall not call any other c-ares function upon
76 \fIares_library_init(3)\fP failure.
77 .SH AVAILABILITY
78 This function was first introduced in c-ares version 1.7.0 along with the
79 definition of preprocessor symbol \fICARES_HAVE_ARES_LIBRARY_INIT\fP as an
80 indication of the availability of this function.
81 .PP
82 Since the introduction of this function it is absolutely mandatory to
83 call it for any Win32/64 program using c-ares.
84 .PP
85 Non-Win32/64 systems can still use c-ares version 1.7.0 without calling
86 \fIares_library_init(3)\fP due to the fact that \fIcurrently\fP it is nearly
87 a do-nothing function on non-Win32/64 platforms at this point.
88 .SH SEE ALSO
89 .BR ares_library_cleanup(3),
90 .BR ares_strerror(3)
91 .SH AUTHOR
92 Yang Tse
93 .PP
94 Copyright 1998 by the Massachusetts Institute of Technology.
95 .br
96 Copyright (C) 2004-2009 by Daniel Stenberg.