hwlocality_xmlexport.3 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. .TH "hwlocality_xmlexport" 3 "Thu Sep 7 2023" "Version 2.9.3" "Hardware Locality (hwloc)" \" -*- nroff -*-
  2. .ad l
  3. .nh
  4. .SH NAME
  5. hwlocality_xmlexport \- Exporting Topologies to XML
  6. .SH SYNOPSIS
  7. .br
  8. .PP
  9. .SS "Enumerations"
  10. .in +1c
  11. .ti -1c
  12. .RI "enum \fBhwloc_topology_export_xml_flags_e\fP { \fBHWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1\fP }"
  13. .br
  14. .in -1c
  15. .SS "Functions"
  16. .in +1c
  17. .ti -1c
  18. .RI "int \fBhwloc_topology_export_xml\fP (\fBhwloc_topology_t\fP topology, const char *xmlpath, unsigned long flags)"
  19. .br
  20. .ti -1c
  21. .RI "int \fBhwloc_topology_export_xmlbuffer\fP (\fBhwloc_topology_t\fP topology, char **xmlbuffer, int *buflen, unsigned long flags)"
  22. .br
  23. .ti -1c
  24. .RI "void \fBhwloc_free_xmlbuffer\fP (\fBhwloc_topology_t\fP topology, char *xmlbuffer)"
  25. .br
  26. .ti -1c
  27. .RI "void \fBhwloc_topology_set_userdata_export_callback\fP (\fBhwloc_topology_t\fP topology, void(*export_cb)(void *reserved, \fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj))"
  28. .br
  29. .ti -1c
  30. .RI "int \fBhwloc_export_obj_userdata\fP (void *reserved, \fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj, const char *name, const void *buffer, size_t length)"
  31. .br
  32. .ti -1c
  33. .RI "int \fBhwloc_export_obj_userdata_base64\fP (void *reserved, \fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj, const char *name, const void *buffer, size_t length)"
  34. .br
  35. .ti -1c
  36. .RI "void \fBhwloc_topology_set_userdata_import_callback\fP (\fBhwloc_topology_t\fP topology, void(*import_cb)(\fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj, const char *name, const void *buffer, size_t length))"
  37. .br
  38. .in -1c
  39. .SH "Detailed Description"
  40. .PP
  41. .SH "Enumeration Type Documentation"
  42. .PP
  43. .SS "enum \fBhwloc_topology_export_xml_flags_e\fP"
  44. .PP
  45. Flags for exporting XML topologies\&. Flags to be given as a OR'ed set to \fBhwloc_topology_export_xml()\fP\&.
  46. .PP
  47. \fBEnumerator\fP
  48. .in +1c
  49. .TP
  50. \fB\fIHWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1 \fP\fP
  51. Export XML that is loadable by hwloc v1\&.x\&. However, the export may miss some details about the topology\&.
  52. .SH "Function Documentation"
  53. .PP
  54. .SS "int hwloc_export_obj_userdata (void * reserved, \fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj, const char * name, const void * buffer, size_t length)"
  55. .PP
  56. Export some object userdata to XML\&. This function may only be called from within the export() callback passed to \fBhwloc_topology_set_userdata_export_callback()\fP\&. It may be invoked one of multiple times to export some userdata to XML\&. The \fCbuffer\fP content of length \fClength\fP is stored with optional name \fCname\fP\&.
  57. .PP
  58. When importing this XML file, the import() callback (if set) will be called exactly as many times as \fBhwloc_export_obj_userdata()\fP was called during export()\&. It will receive the corresponding \fCname\fP, \fCbuffer\fP and \fClength\fP arguments\&.
  59. .PP
  60. \fCreserved\fP, \fCtopology\fP and \fCobj\fP must be the first three parameters that were given to the export callback\&.
  61. .PP
  62. Only printable characters may be exported to XML string attributes\&.
  63. .PP
  64. If exporting binary data, the application should first encode into printable characters only (or use \fBhwloc_export_obj_userdata_base64()\fP)\&. It should also take care of portability issues if the export may be reimported on a different architecture\&.
  65. .PP
  66. \fBReturns\fP
  67. .RS 4
  68. 0 on success\&.
  69. .PP
  70. -1 with errno set to \fCEINVAL\fP if a non-printable character is passed in \fCname\fP or \fBbuffer\fP\&.
  71. .RE
  72. .PP
  73. .SS "int hwloc_export_obj_userdata_base64 (void * reserved, \fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj, const char * name, const void * buffer, size_t length)"
  74. .PP
  75. Encode and export some object userdata to XML\&. This function is similar to \fBhwloc_export_obj_userdata()\fP but it encodes the input buffer into printable characters before exporting\&. On import, decoding is automatically performed before the data is given to the import() callback if any\&.
  76. .PP
  77. This function may only be called from within the export() callback passed to \fBhwloc_topology_set_userdata_export_callback()\fP\&.
  78. .PP
  79. The name must be made of printable characters for export to XML string attributes\&.
  80. .PP
  81. The function does not take care of portability issues if the export may be reimported on a different architecture\&.
  82. .PP
  83. \fBReturns\fP
  84. .RS 4
  85. 0 on success\&.
  86. .PP
  87. -1 with errno set to \fCEINVAL\fP if a non-printable character is passed in \fCname\fP\&.
  88. .RE
  89. .PP
  90. .SS "void hwloc_free_xmlbuffer (\fBhwloc_topology_t\fP topology, char * xmlbuffer)"
  91. .PP
  92. Free a buffer allocated by \fBhwloc_topology_export_xmlbuffer()\fP
  93. .SS "int hwloc_topology_export_xml (\fBhwloc_topology_t\fP topology, const char * xmlpath, unsigned long flags)"
  94. .PP
  95. Export the topology into an XML file\&. This file may be loaded later through \fBhwloc_topology_set_xml()\fP\&.
  96. .PP
  97. By default, the latest export format is used, which means older hwloc releases (e\&.g\&. v1\&.x) will not be able to import it\&. Exporting to v1\&.x specific XML format is possible using flag \fBHWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1\fP but it may miss some details about the topology\&. If there is any chance that the exported file may ever be imported back by a process using hwloc 1\&.x, one should consider detecting it at runtime and using the corresponding export format\&.
  98. .PP
  99. \fCflags\fP is a OR'ed set of \fBhwloc_topology_export_xml_flags_e\fP\&.
  100. .PP
  101. \fBReturns\fP
  102. .RS 4
  103. 0 on success, or -1 on error\&.
  104. .RE
  105. .PP
  106. \fBNote\fP
  107. .RS 4
  108. See also \fBhwloc_topology_set_userdata_export_callback()\fP for exporting application-specific object userdata\&.
  109. .PP
  110. The topology-specific userdata pointer is ignored when exporting to XML\&.
  111. .PP
  112. Only printable characters may be exported to XML string attributes\&. Any other character, especially any non-ASCII character, will be silently dropped\&.
  113. .PP
  114. If \fCname\fP is '-', the XML output is sent to the standard output\&.
  115. .RE
  116. .PP
  117. .SS "int hwloc_topology_export_xmlbuffer (\fBhwloc_topology_t\fP topology, char ** xmlbuffer, int * buflen, unsigned long flags)"
  118. .PP
  119. Export the topology into a newly-allocated XML memory buffer\&. \fCxmlbuffer\fP is allocated by the callee and should be freed with \fBhwloc_free_xmlbuffer()\fP later in the caller\&.
  120. .PP
  121. This memory buffer may be loaded later through \fBhwloc_topology_set_xmlbuffer()\fP\&.
  122. .PP
  123. By default, the latest export format is used, which means older hwloc releases (e\&.g\&. v1\&.x) will not be able to import it\&. Exporting to v1\&.x specific XML format is possible using flag \fBHWLOC_TOPOLOGY_EXPORT_XML_FLAG_V1\fP but it may miss some details about the topology\&. If there is any chance that the exported buffer may ever be imported back by a process using hwloc 1\&.x, one should consider detecting it at runtime and using the corresponding export format\&.
  124. .PP
  125. The returned buffer ends with a \\0 that is included in the returned length\&.
  126. .PP
  127. \fCflags\fP is a OR'ed set of \fBhwloc_topology_export_xml_flags_e\fP\&.
  128. .PP
  129. \fBReturns\fP
  130. .RS 4
  131. 0 on success, or -1 on error\&.
  132. .RE
  133. .PP
  134. \fBNote\fP
  135. .RS 4
  136. See also \fBhwloc_topology_set_userdata_export_callback()\fP for exporting application-specific object userdata\&.
  137. .PP
  138. The topology-specific userdata pointer is ignored when exporting to XML\&.
  139. .PP
  140. Only printable characters may be exported to XML string attributes\&. Any other character, especially any non-ASCII character, will be silently dropped\&.
  141. .RE
  142. .PP
  143. .SS "void hwloc_topology_set_userdata_export_callback (\fBhwloc_topology_t\fP topology, void(*)(void *reserved, \fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj) export_cb)"
  144. .PP
  145. Set the application-specific callback for exporting object userdata\&. The object userdata pointer is not exported to XML by default because hwloc does not know what it contains\&.
  146. .PP
  147. This function lets applications set \fCexport_cb\fP to a callback function that converts this opaque userdata into an exportable string\&.
  148. .PP
  149. \fCexport_cb\fP is invoked during XML export for each object whose \fCuserdata\fP pointer is not \fCNULL\fP\&. The callback should use \fBhwloc_export_obj_userdata()\fP or \fBhwloc_export_obj_userdata_base64()\fP to actually export something to XML (possibly multiple times per object)\&.
  150. .PP
  151. \fCexport_cb\fP may be set to \fCNULL\fP if userdata should not be exported to XML\&.
  152. .PP
  153. \fBNote\fP
  154. .RS 4
  155. The topology-specific userdata pointer is ignored when exporting to XML\&.
  156. .RE
  157. .PP
  158. .SS "void hwloc_topology_set_userdata_import_callback (\fBhwloc_topology_t\fP topology, void(*)(\fBhwloc_topology_t\fP topology, \fBhwloc_obj_t\fP obj, const char *name, const void *buffer, size_t length) import_cb)"
  159. .PP
  160. Set the application-specific callback for importing userdata\&. On XML import, userdata is ignored by default because hwloc does not know how to store it in memory\&.
  161. .PP
  162. This function lets applications set \fCimport_cb\fP to a callback function that will get the XML-stored userdata and store it in the object as expected by the application\&.
  163. .PP
  164. \fCimport_cb\fP is called during \fBhwloc_topology_load()\fP as many times as \fBhwloc_export_obj_userdata()\fP was called during export\&. The topology is not entirely setup yet\&. Object attributes are ready to consult, but links between objects are not\&.
  165. .PP
  166. \fCimport_cb\fP may be \fCNULL\fP if userdata should be ignored during import\&.
  167. .PP
  168. \fBNote\fP
  169. .RS 4
  170. \fCbuffer\fP contains \fClength\fP characters followed by a null byte ('\\0')\&.
  171. .PP
  172. This function should be called before \fBhwloc_topology_load()\fP\&.
  173. .PP
  174. The topology-specific userdata pointer is ignored when importing from XML\&.
  175. .RE
  176. .PP
  177. .SH "Author"
  178. .PP
  179. Generated automatically by Doxygen for Hardware Locality (hwloc) from the source code\&.