| 1 | /* |
| 2 | Copyright (C) 2009-2016 Brazil |
| 3 | Copyright (C) 2022-2023 Sutou Kouhei <[email protected]> |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include "grn.h" |
| 23 | #include <groonga/nfkc.h> |
| 24 | |
| 25 | #ifdef __cplusplus |
| 26 | extern "C" { |
| 27 | #endif |
| 28 | |
| 29 | typedef enum { |
| 30 | GETOPT_OP_NONE = 0, |
| 31 | GETOPT_OP_ON, |
| 32 | GETOPT_OP_OFF, |
| 33 | GETOPT_OP_UPDATE |
| 34 | } grn_str_getopt_op; |
| 35 | |
| 36 | typedef struct { |
| 37 | const char opt; /* ends opt == 0 && longopt == NULL */ |
| 38 | const char *longopt; |
| 39 | const char **arg; /* if NULL, no arg are required */ |
| 40 | int flag; |
| 41 | grn_str_getopt_op op; |
| 42 | } grn_str_getopt_opt; |
| 43 | |
| 44 | GRN_API size_t |
| 45 | grn_str_len(grn_ctx *ctx, |
| 46 | const char *str, |
| 47 | const char *end, |
| 48 | grn_encoding encoding, |
| 49 | const char **last); |
| 50 | |
| 51 | #define GRN_STR_BLANK 0x80 |
| 52 | #define GRN_STR_ISBLANK(c) (c & 0x80) |
| 53 | #define GRN_STR_CTYPE(c) (c & 0x7f) |
| 54 | |
| 55 | GRN_API int |
| 56 | grn_isspace(const char *s, grn_encoding encoding); |
| 57 | int8_t |
| 58 | grn_atoi8(const char *nptr, const char *end, const char **rest); |
| 59 | uint8_t |
| 60 | grn_atoui8(const char *nptr, const char *end, const char **rest); |
| 61 | int16_t |
| 62 | grn_atoi16(const char *nptr, const char *end, const char **rest); |
| 63 | uint16_t |
| 64 | grn_atoui16(const char *nptr, const char *end, const char **rest); |
| 65 | GRN_API int |
| 66 | grn_atoi(const char *nptr, const char *end, const char **rest); |
| 67 | GRN_API unsigned int |
| 68 | grn_atoui(const char *nptr, const char *end, const char **rest); |
| 69 | GRN_API unsigned int |
| 70 | grn_htoui(const char *nptr, const char *end, const char **rest); |
| 71 | GRN_API int64_t |
| 72 | grn_atoll(const char *nptr, const char *end, const char **rest); |
| 73 | GRN_API uint64_t |
| 74 | grn_atoull(const char *nptr, const char *end, const char **rest); |
| 75 | grn_rc |
| 76 | grn_itoa(int i, char *p, char *end, char **rest); |
| 77 | grn_rc |
| 78 | grn_lltoa(int64_t i, char *p, char *end, char **rest); |
| 79 | grn_rc |
| 80 | grn_ulltoa(uint64_t i, char *p, char *end, char **rest); |
| 81 | GRN_API grn_rc |
| 82 | grn_aton(grn_ctx *ctx, |
| 83 | const char *p, |
| 84 | const char *end, |
| 85 | const char **rest, |
| 86 | grn_obj *res); |
| 87 | |
| 88 | GRN_API void |
| 89 | grn_itoh(unsigned int i, char *p, unsigned int len); |
| 90 | int |
| 91 | grn_str_tok(const char *str, |
| 92 | size_t str_len, |
| 93 | char delim, |
| 94 | const char **tokbuf, |
| 95 | int buf_size, |
| 96 | const char **rest); |
| 97 | GRN_API int |
| 98 | grn_str_getopt(int argc, |
| 99 | char *const argv[], |
| 100 | const grn_str_getopt_opt *opts, |
| 101 | int *flags); |
| 102 | |
| 103 | extern int grn_str_margin_size; |
| 104 | |
| 105 | char * |
| 106 | grn_itob(grn_id id, char *p); |
| 107 | grn_id |
| 108 | grn_btoi(char *b); |
| 109 | |
| 110 | grn_rc |
| 111 | grn_substring(grn_ctx *ctx, |
| 112 | char **str, |
| 113 | char **str_end, |
| 114 | int start, |
| 115 | int end, |
| 116 | grn_encoding encoding); |
| 117 | |
| 118 | GRN_API int |
| 119 | grn_charlen_(grn_ctx *ctx, |
| 120 | const char *str, |
| 121 | const char *end, |
| 122 | grn_encoding encoding); |
| 123 | GRN_API grn_str * |
| 124 | grn_str_open_(grn_ctx *ctx, |
| 125 | const char *str, |
| 126 | unsigned int str_len, |
| 127 | int flags, |
| 128 | grn_encoding encoding); |
| 129 | |
| 130 | grn_rc |
| 131 | grn_text_ulltoa(grn_ctx *ctx, grn_obj *buf, unsigned long long int i); |
| 132 | |
| 133 | GRN_API const char * |
| 134 | grn_text_cgidec(grn_ctx *ctx, |
| 135 | grn_obj *buf, |
| 136 | const char *p, |
| 137 | const char *e, |
| 138 | const char *delimiters); |
| 139 | |
| 140 | #define GRN_TOK_VOID (0x00) |
| 141 | #define GRN_TOK_SYMBOL (0x01) |
| 142 | #define GRN_TOK_STRING (0x02) |
| 143 | #define GRN_TOK_QUOTE (0x03) |
| 144 | |
| 145 | GRN_API const char * |
| 146 | grn_text_unesc_tok( |
| 147 | grn_ctx *ctx, grn_obj *buf, const char *p, const char *e, uint8_t *tok_type); |
| 148 | |
| 149 | GRN_API void |
| 150 | grn_str_url_path_normalize( |
| 151 | grn_ctx *ctx, const char *path, size_t path_len, char *buf, size_t buf_len); |
| 152 | |
| 153 | #define GRN_OBJ_FORMAT_XML_ELEMENT_MASK (0x01 << 1) |
| 154 | #define GRN_OBJ_FORMAT_XML_ELEMENT_RESULTSET (0x00 << 1) |
| 155 | #define GRN_OBJ_FORMAT_XML_ELEMENT_NAVIGATIONENTRY (0x01 << 1) |
| 156 | |
| 157 | #include <stdio.h> |
| 158 | GRN_API grn_rc |
| 159 | grn_text_fgets(grn_ctx *ctx, grn_obj *buf, FILE *fp); |
| 160 | |
| 161 | bool |
| 162 | grn_bulk_is_zero(grn_ctx *ctx, grn_obj *obj); |
| 163 | |
| 164 | #ifdef __cplusplus |
| 165 | } |
| 166 | #endif |