hdfs_ext.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef LIBHDFSPP_HDFS_HDFSEXT
  19. #define LIBHDFSPP_HDFS_HDFSEXT
  20. /* get typdefs and #defines from libhdfs' hdfs.h to stay consistent */
  21. #include <hdfs/hdfs.h>
  22. /**
  23. * Note: The #defines below are copied directly from libhdfs'
  24. * hdfs.h. LIBHDFS_EXTERNAL gets explicitly #undefed at the
  25. * end of the file so it must be redefined here.
  26. **/
  27. #ifdef WIN32
  28. #ifdef LIBHDFS_DLL_EXPORT
  29. #define LIBHDFS_EXTERNAL __declspec(dllexport)
  30. #elif LIBHDFS_DLL_IMPORT
  31. #define LIBHDFS_EXTERNAL __declspec(dllimport)
  32. #else
  33. #define LIBHDFS_EXTERNAL
  34. #endif
  35. #else
  36. #ifdef LIBHDFS_DLL_EXPORT
  37. #define LIBHDFS_EXTERNAL __attribute__((visibility("default")))
  38. #elif LIBHDFS_DLL_IMPORT
  39. #define LIBHDFS_EXTERNAL __attribute__((visibility("default")))
  40. #else
  41. #define LIBHDFS_EXTERNAL
  42. #endif
  43. #endif
  44. /**
  45. * Keep C bindings that are libhdfs++ specific in here.
  46. **/
  47. extern "C" {
  48. /**
  49. * Reads the last error, if any, that happened in this thread
  50. * into the user supplied buffer.
  51. * @param buf A chunk of memory with room for the error string.
  52. * @param len Size of the buffer, if the message is longer than
  53. * len len-1 bytes of the message will be copied.
  54. **/
  55. LIBHDFS_EXTERNAL
  56. void hdfsGetLastError(char *buf, int len);
  57. /**
  58. * Create an HDFS builder, using the configuration XML files from the indicated
  59. * directory. If the directory does not exist, or contains no configuration
  60. * XML files, a Builder using all default values will be returned.
  61. *
  62. * @return The HDFS builder, or NULL on error.
  63. */
  64. struct hdfsBuilder *hdfsNewBuilderFromDirectory(const char * configDirectory);
  65. /**
  66. * Get a configuration string from the settings currently read into the builder.
  67. *
  68. * @param key The key to find
  69. * @param val (out param) The value. This will be set to NULL if the
  70. * key isn't found. You must free this string with
  71. * hdfsConfStrFree.
  72. *
  73. * @return 0 on success; nonzero error code otherwise.
  74. * Failure to find the key is not an error.
  75. */
  76. int hdfsBuilderConfGetStr(struct hdfsBuilder *bld, const char *key,
  77. char **val);
  78. /**
  79. * Get a configuration integer from the settings currently read into the builder.
  80. *
  81. * @param key The key to find
  82. * @param val (out param) The value. This will NOT be changed if the
  83. * key isn't found.
  84. *
  85. * @return 0 on success; nonzero error code otherwise.
  86. * Failure to find the key is not an error.
  87. */
  88. int hdfsBuilderConfGetInt(struct hdfsBuilder *bld, const char *key, int32_t *val);
  89. } /* end extern "C" */
  90. #endif