ares_parse_txt_reply.3 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. .\"
  2. .\" Copyright 1998 by the Massachusetts Institute of Technology.
  3. .\"
  4. .\" Permission to use, copy, modify, and distribute this
  5. .\" software and its documentation for any purpose and without
  6. .\" fee is hereby granted, provided that the above copyright
  7. .\" notice appear in all copies and that both that copyright
  8. .\" notice and this permission notice appear in supporting
  9. .\" documentation, and that the name of M.I.T. not be used in
  10. .\" advertising or publicity pertaining to distribution of the
  11. .\" software without specific, written prior permission.
  12. .\" M.I.T. makes no representations about the suitability of
  13. .\" this software for any purpose. It is provided "as is"
  14. .\" without express or implied warranty.
  15. .\"
  16. .TH ARES_PARSE_TXT_REPLY 3 "27 October 2009"
  17. .SH NAME
  18. ares_parse_txt_reply \- Parse a reply to a DNS query of type TXT
  19. .SH SYNOPSIS
  20. .nf
  21. .B #include <ares.h>
  22. .PP
  23. .B int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
  24. .B struct ares_txt_reply **\fItxt_out\fP);
  25. .PP
  26. .B int ares_parse_txt_reply_ext(const unsigned char* \fIabuf\fP, int \fIalen\fP,
  27. .B struct ares_txt_ext **\fItxt_out\fP);
  28. .fi
  29. .SH DESCRIPTION
  30. The
  31. .BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
  32. function parses the response to a query of type TXT into a
  33. linked list (one element per sub-string) of
  34. .IR "struct ares_txt_reply" " (" "struct ares_txt_ext" ")"
  35. The parameters
  36. .I abuf
  37. and
  38. .I alen
  39. give the contents of the response. The result is stored in allocated
  40. memory and a pointer to it stored into the variable pointed to by
  41. .IR txt_out .
  42. It is the caller's responsibility to free the resulting
  43. .IR txt_out
  44. structure when it is no longer needed using the function
  45. .B ares_free_data
  46. .PP
  47. The structure
  48. .I ares_txt_reply
  49. contains the following fields:
  50. .sp
  51. .in +4n
  52. .nf
  53. struct ares_txt_reply {
  54. struct ares_txt_reply *next;
  55. unsigned int length;
  56. unsigned char *txt;
  57. };
  58. .fi
  59. .in
  60. .PP
  61. The structure
  62. .I ares_txt_ext
  63. contains the following fields:
  64. .sp
  65. .in +4n
  66. .nf
  67. struct ares_txt_ext {
  68. struct ares_txt_ext *next;
  69. unsigned int length;
  70. unsigned char *txt;
  71. unsigned char record_start;
  72. };
  73. .fi
  74. .in
  75. .PP
  76. The
  77. .I record_start
  78. field in
  79. .I struct ares_txt_ext
  80. is 1 if this structure is a start of a TXT record, and 0 if the structure is a
  81. continuation of a previous record. The linked list of the
  82. .I struct ares_txt_ext
  83. will have at least one item with
  84. .I record_start
  85. equal to 1, and may have some items with
  86. .I record_start
  87. equal to 0 between them.
  88. .PP
  89. These sequences of
  90. .I struct ares_txt_ext
  91. (starting from the item with
  92. .I record_start
  93. equal to 1, and ending right before the record start item) may be treated as
  94. either components of a single TXT record or as a multi-parted TXT record,
  95. depending on particular use case.
  96. .PP
  97. .SH RETURN VALUES
  98. .BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
  99. can return any of the following values:
  100. .TP 15
  101. .B ARES_SUCCESS
  102. The response was successfully parsed.
  103. .TP 15
  104. .B ARES_EBADRESP
  105. The response was malformatted.
  106. .TP 15
  107. .B ARES_ENODATA
  108. The response did not contain an answer to the query.
  109. .TP 15
  110. .B ARES_ENOMEM
  111. Memory was exhausted.
  112. .SH AVAILABILITY
  113. This function was first introduced in c-ares version 1.7.0.
  114. .SH SEE ALSO
  115. .BR ares_query (3)
  116. .BR ares_free_data (3)
  117. .SH AUTHOR
  118. Written by Jakub Hrozek <[email protected]>, on behalf of Red Hat, Inc http://www.redhat.com
  119. .PP
  120. Amended by Fedor Indutny <[email protected]>, on behalf of PayPal, Inc https://www.paypal.com