# SOME DESCRIPTIVE TITLE # Copyright (C) YEAR Free Software Foundation, Inc. # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2024-06-01 05:51+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "getaddrinfo_a" msgstr "" #. type: TH #: archlinux debian-unstable opensuse-tumbleweed #, no-wrap msgid "2024-05-02" msgstr "" #. type: TH #: archlinux debian-unstable #, no-wrap msgid "Linux man-pages 6.8" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "getaddrinfo_a, gai_suspend, gai_error, gai_cancel - asynchronous network " "address and service translation" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "LIBRARY" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "Asynchronous name lookup library (I, I<-lanl>)" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n" "B<#include Enetdb.hE>\n" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "BIB<, struct gaicb *>IB<[restrict],>\n" "B< int >IB<, struct sigevent *restrict >IB<);>\n" "BIB<[], int >IB<,>\n" "B< const struct timespec *>IB<);>\n" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "BIB<);>\n" "BIB<);>\n" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function performs the same task as " "B(3), but allows multiple name look-ups to be performed " "asynchronously, with optional notification on completion of look-up " "operations." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The I argument has one of the following values:" msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "Perform the look-ups synchronously. The call blocks until the look-ups have " "completed." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "Perform the look-ups asynchronously. The call returns immediately, and the " "requests are resolved in the background. See the discussion of the I " "argument below." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The array I specifies the look-up requests to process. The I " "argument specifies the number of elements in I. The requested look-up " "operations are started in parallel. NULL elements in I are ignored. " "Each request is described by a I structure, defined as follows:" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "struct gaicb {\n" " const char *ar_name;\n" " const char *ar_service;\n" " const struct addrinfo *ar_request;\n" " struct addrinfo *ar_result;\n" "};\n" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The elements of this structure correspond to the arguments of " "B(3). Thus, I corresponds to the I argument and " "I to the I argument, identifying an Internet host and a " "service. The I element corresponds to the I argument, " "specifying the criteria for selecting the returned socket address " "structures. Finally, I corresponds to the I argument; you " "do not need to initialize this element, it will be automatically set when " "the request is resolved. The I structure referenced by the last " "two elements is described in B(3)." msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed msgid "" "When I is specified as B, notifications about resolved " "requests can be obtained by employing the I structure pointed to " "by the I argument. For the definition and general details of this " "structure, see B(3type). The Isigev_notify> field can " "have the following values:" msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "Don't provide any notification." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. si_pid and si_uid are also set, to the values of the calling process, #. which doesn't provide useful information, so we'll skip mentioning it. #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed msgid "" "When a look-up completes, generate the signal I for the " "process. See B(3type) for general details. The I field " "of the I structure will be set to B." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed msgid "" "When a look-up completes, invoke I as if it were the " "start function of a new thread. See B(3type) for details." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "For B and B, it may be useful to point Isigev_value.sival_ptr> to I." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function suspends execution of the calling thread, " "waiting for the completion of one or more requests in the array I. " "The I argument specifies the size of the array I. The call " "blocks until one of the following occurs:" msgstr "" #. type: IP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "\\[bu]" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "One or more of the operations in I completes." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The call is interrupted by a signal that is caught." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The time interval specified in I elapses. This argument specifies " "a timeout in seconds plus nanoseconds (see B(2) for details of " "the I structure). If I is NULL, then the call blocks " "indefinitely (until one of the events above occurs)." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "No explicit indication of which request was completed is given; you must " "determine which request(s) have completed by iterating with B() " "over the list of requests." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function returns the status of the request I: " "either B if the request was not completed yet, 0 if it was " "handled successfully, or an error code if the request could not be resolved." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function cancels the request I. If the request " "has been canceled successfully, the error status of the request will be set " "to B and normal asynchronous notification will be performed. " "The request cannot be canceled if it is currently being processed; in that " "case, it will be handled as if B() has never been called. If " "I is NULL, an attempt is made to cancel all outstanding requests that " "the process has made." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "RETURN VALUE" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function returns 0 if all of the requests have been " "enqueued successfully, or one of the following nonzero error codes:" msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The resources necessary to enqueue the look-up requests were not available. " "The application may check the error status of each request to determine " "which ones failed." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "Out of memory." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "I is invalid." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function returns 0 if at least one of the listed " "requests has been completed. Otherwise, it returns one of the following " "nonzero error codes:" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The given timeout expired before any of the requests could be completed." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "There were no actual requests given to the function." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "A signal has interrupted the function. Note that this interruption might " "have been caused by signal notification of some completed look-up request." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B() function can return B for an unfinished " "look-up request, 0 for a successfully completed look-up (as described " "above), one of the error codes that could be returned by B(3), " "or the error code B if the request has been canceled " "explicitly before it could be finished." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The B() function can return one of these values:" msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The request has been canceled successfully." msgstr "" #. type: TP #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The request has not been canceled." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The request has already completed." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The B(3) function translates these error codes to a human " "readable string, suitable for error reporting." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "ATTRIBUTES" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "For an explanation of the terms used in this section, see B(7)." msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Interface" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Attribute" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Value" msgstr "" #. type: tbl table #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed #, no-wrap msgid ".na\n" msgstr "" #. type: tbl table #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed #, no-wrap msgid ".nh\n" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "B(),\n" "B(),\n" "B(),\n" "B()" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Thread safety" msgstr "" #. type: tbl table #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "MT-Safe" msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "STANDARDS" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-leap-15-6 opensuse-tumbleweed msgid "GNU." msgstr "" #. type: SH #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "HISTORY" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-leap-15-6 opensuse-tumbleweed msgid "glibc 2.2.3." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The interface of B() was modeled after the B(3) " "interface." msgstr "" #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "EXAMPLES" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "Two examples are provided: a simple example that resolves several requests " "in parallel synchronously, and a complex example showing some of the " "asynchronous capabilities." msgstr "" #. type: SS #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Synchronous example" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "The program below simply resolves several hostnames in parallel, giving a " "speed-up compared to resolving the hostnames sequentially using " "B(3). The program might be used like this:" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "$ B<./a.out mirrors.kernel.org enoent.linuxfoundation.org gnu.org>\n" "mirrors.kernel.org: 139.178.88.99\n" "enoent.linuxfoundation.org: Name or service not known\n" "gnu.org: 209.51.188.116\n" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "Here is the program source code" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed #, no-wrap msgid "" "#define _GNU_SOURCE\n" "#include Eerr.hE\n" "#include Enetdb.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "\\&\n" "#define MALLOC(n, type) ((type *) reallocarray(NULL, n, sizeof(type)))\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int ret;\n" " struct gaicb *reqs[argc - 1];\n" " char host[NI_MAXHOST];\n" " struct addrinfo *res;\n" "\\&\n" " if (argc E 2) {\n" " fprintf(stderr, \"Usage: %s HOST...\\en\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " for (size_t i = 0; i E argc - 1; i++) {\n" " reqs[i] = MALLOC(1, struct gaicb);\n" " if (reqs[i] == NULL)\n" " err(EXIT_FAILURE, \"malloc\");\n" "\\&\n" " memset(reqs[i], 0, sizeof(*reqs[0]));\n" " reqs[i]-Ear_name = argv[i + 1];\n" " }\n" "\\&\n" " ret = getaddrinfo_a(GAI_WAIT, reqs, argc - 1, NULL);\n" " if (ret != 0) {\n" " fprintf(stderr, \"getaddrinfo_a() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" "\\&\n" " for (size_t i = 0; i E argc - 1; i++) {\n" " printf(\"%s: \", reqs[i]-Ear_name);\n" " ret = gai_error(reqs[i]);\n" " if (ret == 0) {\n" " res = reqs[i]-Ear_result;\n" "\\&\n" " ret = getnameinfo(res-Eai_addr, res-Eai_addrlen,\n" " host, sizeof(host),\n" " NULL, 0, NI_NUMERICHOST);\n" " if (ret != 0) {\n" " fprintf(stderr, \"getnameinfo() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" " puts(host);\n" "\\&\n" " } else {\n" " puts(gai_strerror(ret));\n" " }\n" " }\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. SRC END #. type: SS #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "Asynchronous example" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "" "This example shows a simple interactive B() front-end. The " "notification facility is not demonstrated." msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "An example session might look like this:" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "" "$ B<./a.out>\n" "E a mirrors.kernel.org enoent.linuxfoundation.org gnu.org\n" "E c 2\n" "[2] gnu.org: Request not canceled\n" "E w 0 1\n" "[00] mirrors.kernel.org: Finished\n" "E l\n" "[00] mirrors.kernel.org: 139.178.88.99\n" "[01] enoent.linuxfoundation.org: Processing request in progress\n" "[02] gnu.org: 209.51.188.116\n" "E l\n" "[00] mirrors.kernel.org: 139.178.88.99\n" "[01] enoent.linuxfoundation.org: Name or service not known\n" "[02] gnu.org: 209.51.188.116\n" msgstr "" #. type: Plain text #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed msgid "The program source is as follows:" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed #, no-wrap msgid "" "#define _GNU_SOURCE\n" "#include Eassert.hE\n" "#include Eerr.hE\n" "#include Enetdb.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" "\\&\n" "#define CALLOC(n, type) ((type *) calloc(n, sizeof(type)))\n" "\\&\n" "#define REALLOCF(ptr, n, type) \\e\n" "({ \\e\n" " static_assert(__builtin_types_compatible_p(typeof(ptr), type *)); \\e\n" " \\e\n" " (type *) reallocarrayf(ptr, n, sizeof(type)); \\e\n" "})\n" "\\&\n" "static struct gaicb **reqs = NULL;\n" "static size_t nreqs = 0;\n" "\\&\n" "static inline void *\n" "reallocarrayf(void *p, size_t nmemb, size_t size)\n" "{\n" " void *q;\n" "\\&\n" " q = reallocarray(p, nmemb, size);\n" " if (q == NULL && nmemb != 0 && size != 0)\n" " free(p);\n" " return q;\n" "}\n" "\\&\n" "static char *\n" "getcmd(void)\n" "{\n" " static char buf[256];\n" "\\&\n" " fputs(\"E \", stdout); fflush(stdout);\n" " if (fgets(buf, sizeof(buf), stdin) == NULL)\n" " return NULL;\n" "\\&\n" " if (buf[strlen(buf) - 1] == \\[aq]\\en\\[aq])\n" " buf[strlen(buf) - 1] = 0;\n" "\\&\n" " return buf;\n" "}\n" "\\&\n" "/* Add requests for specified hostnames. */\n" "static void\n" "add_requests(void)\n" "{\n" " size_t nreqs_base = nreqs;\n" " char *host;\n" " int ret;\n" "\\&\n" " while ((host = strtok(NULL, \" \"))) {\n" " nreqs++;\n" " reqs = REALLOCF(reqs, nreqs, struct gaicb *);\n" " if (reqs == NULL)\n" " err(EXIT_FAILURE, \"reallocf\");\n" "\\&\n" " reqs[nreqs - 1] = CALLOC(1, struct gaicb);\n" " if (reqs[nreqs - 1] == NULL)\n" " err(EXIT_FAILURE, \"calloc\");\n" "\\&\n" " reqs[nreqs - 1]-Ear_name = strdup(host);\n" " }\n" "\\&\n" " /* Queue nreqs_base..nreqs requests. */\n" "\\&\n" " ret = getaddrinfo_a(GAI_NOWAIT, &reqs[nreqs_base],\n" " nreqs - nreqs_base, NULL);\n" " if (ret) {\n" " fprintf(stderr, \"getaddrinfo_a() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" "}\n" "\\&\n" "/* Wait until at least one of specified requests completes. */\n" "static void\n" "wait_requests(void)\n" "{\n" " char *id;\n" " int ret;\n" " size_t n;\n" " struct gaicb const **wait_reqs;\n" "\\&\n" " wait_reqs = CALLOC(nreqs, const struct gaicb *);\n" " if (wait_reqs == NULL)\n" " err(EXIT_FAILURE, \"calloc\");\n" "\\&\n" " /* NULL elements are ignored by gai_suspend(). */\n" "\\&\n" " while ((id = strtok(NULL, \" \")) != NULL) {\n" " n = atoi(id);\n" "\\&\n" " if (n E= nreqs) {\n" " printf(\"Bad request number: %s\\en\", id);\n" " return;\n" " }\n" "\\&\n" " wait_reqs[n] = reqs[n];\n" " }\n" "\\&\n" " ret = gai_suspend(wait_reqs, nreqs, NULL);\n" " if (ret) {\n" " printf(\"gai_suspend(): %s\\en\", gai_strerror(ret));\n" " return;\n" " }\n" "\\&\n" " for (size_t i = 0; i E nreqs; i++) {\n" " if (wait_reqs[i] == NULL)\n" " continue;\n" "\\&\n" " ret = gai_error(reqs[i]);\n" " if (ret == EAI_INPROGRESS)\n" " continue;\n" "\\&\n" " printf(\"[%02zu] %s: %s\\en\", i, reqs[i]-Ear_name,\n" " ret == 0 ? \"Finished\" : gai_strerror(ret));\n" " }\n" "}\n" "\\&\n" "/* Cancel specified requests. */\n" "static void\n" "cancel_requests(void)\n" "{\n" " char *id;\n" " int ret;\n" " size_t n;\n" "\\&\n" " while ((id = strtok(NULL, \" \")) != NULL) {\n" " n = atoi(id);\n" "\\&\n" " if (n E= nreqs) {\n" " printf(\"Bad request number: %s\\en\", id);\n" " return;\n" " }\n" "\\&\n" " ret = gai_cancel(reqs[n]);\n" " printf(\"[%s] %s: %s\\en\", id, reqs[atoi(id)]-Ear_name,\n" " gai_strerror(ret));\n" " }\n" "}\n" "\\&\n" "/* List all requests. */\n" "static void\n" "list_requests(void)\n" "{\n" " int ret;\n" " char host[NI_MAXHOST];\n" " struct addrinfo *res;\n" "\\&\n" " for (size_t i = 0; i E nreqs; i++) {\n" " printf(\"[%02zu] %s: \", i, reqs[i]-Ear_name);\n" " ret = gai_error(reqs[i]);\n" "\\&\n" " if (!ret) {\n" " res = reqs[i]-Ear_result;\n" "\\&\n" " ret = getnameinfo(res-Eai_addr, res-Eai_addrlen,\n" " host, sizeof(host),\n" " NULL, 0, NI_NUMERICHOST);\n" " if (ret) {\n" " fprintf(stderr, \"getnameinfo() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" " puts(host);\n" " } else {\n" " puts(gai_strerror(ret));\n" " }\n" " }\n" "}\n" "\\&\n" "int\n" "main(void)\n" "{\n" " char *cmdline;\n" " char *cmd;\n" "\\&\n" " while ((cmdline = getcmd()) != NULL) {\n" " cmd = strtok(cmdline, \" \");\n" "\\&\n" " if (cmd == NULL) {\n" " list_requests();\n" " } else {\n" " switch (cmd[0]) {\n" " case \\[aq]a\\[aq]:\n" " add_requests();\n" " break;\n" " case \\[aq]w\\[aq]:\n" " wait_requests();\n" " break;\n" " case \\[aq]c\\[aq]:\n" " cancel_requests();\n" " break;\n" " case \\[aq]l\\[aq]:\n" " list_requests();\n" " break;\n" " default:\n" " fprintf(stderr, \"Bad command: %c\\en\", cmd[0]);\n" " break;\n" " }\n" " }\n" " }\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. SRC END #. type: SH #: archlinux debian-bookworm debian-unstable fedora-40 fedora-rawhide #: mageia-cauldron opensuse-leap-15-6 opensuse-tumbleweed #, no-wrap msgid "SEE ALSO" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-40 fedora-rawhide mageia-cauldron #: opensuse-tumbleweed msgid "" "B(3), B(3), B(3), B(7), B(7), " "B(3type)" msgstr "" #. type: TH #: debian-bookworm #, no-wrap msgid "2023-02-05" msgstr "" #. type: TH #: debian-bookworm #, no-wrap msgid "Linux man-pages 6.03" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 msgid "" "When I is specified as B, notifications about resolved " "requests can be obtained by employing the I structure pointed to " "by the I argument. For the definition and general details of this " "structure, see B(7). The Isigev_notify> field can have " "the following values:" msgstr "" #. si_pid and si_uid are also set, to the values of the calling process, #. which doesn't provide useful information, so we'll skip mentioning it. #. type: Plain text #: debian-bookworm opensuse-leap-15-6 msgid "" "When a look-up completes, generate the signal I for the " "process. See B(7) for general details. The I field of " "the I structure will be set to B." msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 msgid "" "When a look-up completes, invoke I as if it were the " "start function of a new thread. See B(7) for details." msgstr "" #. type: Plain text #: debian-bookworm msgid "These functions are GNU extensions; they first appeared in glibc 2.2.3." msgstr "" #. type: SH #: debian-bookworm #, no-wrap msgid "NOTES" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "#define _GNU_SOURCE\n" "#include Enetdb.hE\n" "#include Estdio.hE\n" "#include Estdlib.hE\n" "#include Estring.hE\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "int\n" "main(int argc, char *argv[])\n" "{\n" " int ret;\n" " struct gaicb *reqs[argc - 1];\n" " char host[NI_MAXHOST];\n" " struct addrinfo *res;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " if (argc E 2) {\n" " fprintf(stderr, \"Usage: %s HOST...\\en\", argv[0]);\n" " exit(EXIT_FAILURE);\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " for (size_t i = 0; i E argc - 1; i++) {\n" " reqs[i] = malloc(sizeof(*reqs[0]));\n" " if (reqs[i] == NULL) {\n" " perror(\"malloc\");\n" " exit(EXIT_FAILURE);\n" " }\n" " memset(reqs[i], 0, sizeof(*reqs[0]));\n" " reqs[i]-Ear_name = argv[i + 1];\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " ret = getaddrinfo_a(GAI_WAIT, reqs, argc - 1, NULL);\n" " if (ret != 0) {\n" " fprintf(stderr, \"getaddrinfo_a() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " for (size_t i = 0; i E argc - 1; i++) {\n" " printf(\"%s: \", reqs[i]-Ear_name);\n" " ret = gai_error(reqs[i]);\n" " if (ret == 0) {\n" " res = reqs[i]-Ear_result;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " ret = getnameinfo(res-Eai_addr, res-Eai_addrlen,\n" " host, sizeof(host),\n" " NULL, 0, NI_NUMERICHOST);\n" " if (ret != 0) {\n" " fprintf(stderr, \"getnameinfo() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" " puts(host);\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " } else {\n" " puts(gai_strerror(ret));\n" " }\n" " }\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "static struct gaicb **reqs = NULL;\n" "static size_t nreqs = 0;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "static char *\n" "getcmd(void)\n" "{\n" " static char buf[256];\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " fputs(\"E \", stdout); fflush(stdout);\n" " if (fgets(buf, sizeof(buf), stdin) == NULL)\n" " return NULL;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " if (buf[strlen(buf) - 1] == \\[aq]\\en\\[aq])\n" " buf[strlen(buf) - 1] = 0;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " return buf;\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "/* Add requests for specified hostnames. */\n" "static void\n" "add_requests(void)\n" "{\n" " size_t nreqs_base = nreqs;\n" " char *host;\n" " int ret;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " while ((host = strtok(NULL, \" \"))) {\n" " nreqs++;\n" " reqs = realloc(reqs, sizeof(reqs[0]) * nreqs);\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " reqs[nreqs - 1] = calloc(1, sizeof(*reqs[0]));\n" " reqs[nreqs - 1]-Ear_name = strdup(host);\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid " /* Queue nreqs_base..nreqs requests. */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " ret = getaddrinfo_a(GAI_NOWAIT, &reqs[nreqs_base],\n" " nreqs - nreqs_base, NULL);\n" " if (ret) {\n" " fprintf(stderr, \"getaddrinfo_a() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "/* Wait until at least one of specified requests completes. */\n" "static void\n" "wait_requests(void)\n" "{\n" " char *id;\n" " int ret;\n" " size_t n;\n" " struct gaicb const **wait_reqs = calloc(nreqs, sizeof(*wait_reqs));\n" " /* NULL elements are ignored by gai_suspend(). */\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " while ((id = strtok(NULL, \" \")) != NULL) {\n" " n = atoi(id);\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " if (n E= nreqs) {\n" " printf(\"Bad request number: %s\\en\", id);\n" " return;\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " wait_reqs[n] = reqs[n];\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " ret = gai_suspend(wait_reqs, nreqs, NULL);\n" " if (ret) {\n" " printf(\"gai_suspend(): %s\\en\", gai_strerror(ret));\n" " return;\n" " }\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " for (size_t i = 0; i E nreqs; i++) {\n" " if (wait_reqs[i] == NULL)\n" " continue;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " ret = gai_error(reqs[i]);\n" " if (ret == EAI_INPROGRESS)\n" " continue;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " printf(\"[%02zu] %s: %s\\en\", i, reqs[i]-Ear_name,\n" " ret == 0 ? \"Finished\" : gai_strerror(ret));\n" " }\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "/* Cancel specified requests. */\n" "static void\n" "cancel_requests(void)\n" "{\n" " char *id;\n" " int ret;\n" " size_t n;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " ret = gai_cancel(reqs[n]);\n" " printf(\"[%s] %s: %s\\en\", id, reqs[atoi(id)]-Ear_name,\n" " gai_strerror(ret));\n" " }\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "/* List all requests. */\n" "static void\n" "list_requests(void)\n" "{\n" " int ret;\n" " char host[NI_MAXHOST];\n" " struct addrinfo *res;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " for (size_t i = 0; i E nreqs; i++) {\n" " printf(\"[%02zu] %s: \", i, reqs[i]-Ear_name);\n" " ret = gai_error(reqs[i]);\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " if (!ret) {\n" " res = reqs[i]-Ear_result;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " ret = getnameinfo(res-Eai_addr, res-Eai_addrlen,\n" " host, sizeof(host),\n" " NULL, 0, NI_NUMERICHOST);\n" " if (ret) {\n" " fprintf(stderr, \"getnameinfo() failed: %s\\en\",\n" " gai_strerror(ret));\n" " exit(EXIT_FAILURE);\n" " }\n" " puts(host);\n" " } else {\n" " puts(gai_strerror(ret));\n" " }\n" " }\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" "int\n" "main(void)\n" "{\n" " char *cmdline;\n" " char *cmd;\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " while ((cmdline = getcmd()) != NULL) {\n" " cmd = strtok(cmdline, \" \");\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 #, no-wrap msgid "" " if (cmd == NULL) {\n" " list_requests();\n" " } else {\n" " switch (cmd[0]) {\n" " case \\[aq]a\\[aq]:\n" " add_requests();\n" " break;\n" " case \\[aq]w\\[aq]:\n" " wait_requests();\n" " break;\n" " case \\[aq]c\\[aq]:\n" " cancel_requests();\n" " break;\n" " case \\[aq]l\\[aq]:\n" " list_requests();\n" " break;\n" " default:\n" " fprintf(stderr, \"Bad command: %c\\en\", cmd[0]);\n" " break;\n" " }\n" " }\n" " }\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: Plain text #: debian-bookworm opensuse-leap-15-6 msgid "" "B(3), B(3), B(3), B(7), B(7), " "B(7)" msgstr "" #. type: TH #: fedora-40 fedora-rawhide mageia-cauldron #, no-wrap msgid "2023-10-31" msgstr "" #. type: TH #: fedora-40 mageia-cauldron #, no-wrap msgid "Linux man-pages 6.06" msgstr "" #. type: TH #: fedora-rawhide #, no-wrap msgid "Linux man-pages 6.7" msgstr "" #. type: TH #: opensuse-leap-15-6 #, no-wrap msgid "2023-03-30" msgstr "" #. type: TH #: opensuse-leap-15-6 #, no-wrap msgid "Linux man-pages 6.04" msgstr "" #. type: TH #: opensuse-tumbleweed #, no-wrap msgid "Linux man-pages (unreleased)" msgstr ""