PageRenderTime 57ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/src/google/protobuf-c/protobuf-c-parser.h

http://protobuf-c.googlecode.com/
C Header | 95 lines | 44 code | 12 blank | 39 comment | 0 complexity | 4d2250ce3caed5a55845f69813f1bdcf MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /*
  2. * Copyright (c) 2008-2011, Dave Benson.
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with
  7. * or without modification, are permitted provided that the
  8. * following conditions are met:
  9. *
  10. * Redistributions of source code must retain the above
  11. * copyright notice, this list of conditions and the following
  12. * disclaimer.
  13. * Redistributions in binary form must reproduce
  14. * the above copyright notice, this list of conditions and
  15. * the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * Neither the name
  19. * of "protobuf-c" nor the names of its contributors
  20. * may be used to endorse or promote products derived from
  21. * this software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  24. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  25. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  26. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
  28. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  29. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  30. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  31. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  32. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  33. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. typedef struct _ProtobufC_ParseResult ProtobufC_ParseResult;
  39. struct _ProtobufC_ParseResult
  40. {
  41. const char *message;
  42. const char *filename;
  43. unsigned line_no;
  44. };
  45. struct _ProtobufC_ParserPackage
  46. {
  47. char *name;
  48. unsigned n_messages;
  49. ProtobufCMessageDescriptor *message_descriptors;
  50. unsigned n_enums;
  51. ProtobufCEnumDescriptor *enum_descriptors;
  52. };
  53. ProtobufC_Parser *protobuf_c_parser_new (void);
  54. /* If non-NULL, return-value should be freed with default allocator */
  55. typedef char *(*ProtobufC_ImportHandlerFunc) (const char *package_name,
  56. void *func_data);
  57. void protobuf_c_parser_set_import_handler (ProtobufC_Parser *parser,
  58. ProtobufC_ImportHandlerFunc func,
  59. void *func_data);
  60. ProtobufC_ParserPackage *
  61. protobuf_c_parser_parse_file(ProtobufC_Parser *parser,
  62. const char *filename,
  63. ProtobufC_ParseResult *error);
  64. ProtobufC_ParserPackage *
  65. protobuf_c_parser_import (ProtobufC_Parser *parser,
  66. const char *package_name,
  67. ProtobufC_ParseResult *error);
  68. void protobuf_c_parser_free (ProtobufC_Parser *parser);
  69. typedef enum
  70. {
  71. PROTOBUF_C_CODEGEN_MODE_H,
  72. PROTOBUF_C_CODEGEN_MODE_C
  73. } ProtobufC_CodegenMode;
  74. struct _ProtobufC_CodegenInfo
  75. {
  76. const char *package_name;
  77. ProtobufC_CodegenMode mode;
  78. const char *output_filename;
  79. };
  80. #define PROTOBUF_C_CODEGEN_INFO_INIT { NULL, PROTOBUF_C_CODEGEN_MODE_H, NULL }
  81. protobuf_c_boolean protobuf_c_parser_codegen(ProtobufC_Parser *parser,
  82. ProtobufC_CodegenInfo *codegen);