API 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. Oniguruma API Version 5.9.2 2008/02/19
  2. #include <oniguruma.h>
  3. # int onig_init(void)
  4. Initialize library.
  5. You don't have to call it explicitly, because it is called in onig_new().
  6. # int onig_error_code_to_str(UChar* err_buf, int err_code, ...)
  7. Get error message string.
  8. If this function is used for onig_new(),
  9. don't call this after the pattern argument of onig_new() is freed.
  10. normal return: error message string length
  11. arguments
  12. 1 err_buf: error message string buffer.
  13. (required size: ONIG_MAX_ERROR_MESSAGE_LEN)
  14. 2 err_code: error code returned by other API functions.
  15. 3 err_info (optional): error info returned by onig_new().
  16. # void onig_set_warn_func(OnigWarnFunc func)
  17. Set warning function.
  18. WARNING:
  19. '[', '-', ']' in character class without escape.
  20. ']' in pattern without escape.
  21. arguments
  22. 1 func: function pointer. void (*func)(char* warning_message)
  23. # void onig_set_verb_warn_func(OnigWarnFunc func)
  24. Set verbose warning function.
  25. WARNING:
  26. redundant nested repeat operator.
  27. arguments
  28. 1 func: function pointer. void (*func)(char* warning_message)
  29. # int onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
  30. OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
  31. OnigErrorInfo* err_info)
  32. Create a regex object.
  33. normal return: ONIG_NORMAL
  34. arguments
  35. 1 reg: return regex object's address.
  36. 2 pattern: regex pattern string.
  37. 3 pattern_end: terminate address of pattern. (pattern + pattern length)
  38. 4 option: compile time options.
  39. ONIG_OPTION_NONE no option
  40. ONIG_OPTION_SINGLELINE '^' -> '\A', '$' -> '\Z'
  41. ONIG_OPTION_MULTILINE '.' match with newline
  42. ONIG_OPTION_IGNORECASE ambiguity match on
  43. ONIG_OPTION_EXTEND extended pattern form
  44. ONIG_OPTION_FIND_LONGEST find longest match
  45. ONIG_OPTION_FIND_NOT_EMPTY ignore empty match
  46. ONIG_OPTION_NEGATE_SINGLELINE
  47. clear ONIG_OPTION_SINGLELINE which is enabled on
  48. ONIG_SYNTAX_POSIX_BASIC, ONIG_SYNTAX_POSIX_EXTENDED,
  49. ONIG_SYNTAX_PERL, ONIG_SYNTAX_PERL_NG, ONIG_SYNTAX_JAVA
  50. ONIG_OPTION_DONT_CAPTURE_GROUP only named group captured.
  51. ONIG_OPTION_CAPTURE_GROUP named and no-named group captured.
  52. 5 enc: character encoding.
  53. ONIG_ENCODING_ASCII ASCII
  54. ONIG_ENCODING_ISO_8859_1 ISO 8859-1
  55. ONIG_ENCODING_ISO_8859_2 ISO 8859-2
  56. ONIG_ENCODING_ISO_8859_3 ISO 8859-3
  57. ONIG_ENCODING_ISO_8859_4 ISO 8859-4
  58. ONIG_ENCODING_ISO_8859_5 ISO 8859-5
  59. ONIG_ENCODING_ISO_8859_6 ISO 8859-6
  60. ONIG_ENCODING_ISO_8859_7 ISO 8859-7
  61. ONIG_ENCODING_ISO_8859_8 ISO 8859-8
  62. ONIG_ENCODING_ISO_8859_9 ISO 8859-9
  63. ONIG_ENCODING_ISO_8859_10 ISO 8859-10
  64. ONIG_ENCODING_ISO_8859_11 ISO 8859-11
  65. ONIG_ENCODING_ISO_8859_13 ISO 8859-13
  66. ONIG_ENCODING_ISO_8859_14 ISO 8859-14
  67. ONIG_ENCODING_ISO_8859_15 ISO 8859-15
  68. ONIG_ENCODING_ISO_8859_16 ISO 8859-16
  69. ONIG_ENCODING_UTF8 UTF-8
  70. ONIG_ENCODING_UTF16_BE UTF-16BE
  71. ONIG_ENCODING_UTF16_LE UTF-16LE
  72. ONIG_ENCODING_UTF32_BE UTF-32BE
  73. ONIG_ENCODING_UTF32_LE UTF-32LE
  74. ONIG_ENCODING_EUC_JP EUC-JP
  75. ONIG_ENCODING_EUC_TW EUC-TW
  76. ONIG_ENCODING_EUC_KR EUC-KR
  77. ONIG_ENCODING_EUC_CN EUC-CN
  78. ONIG_ENCODING_SJIS Shift_JIS
  79. ONIG_ENCODING_KOI8_R KOI8-R
  80. ONIG_ENCODING_CP1251 CP1251
  81. ONIG_ENCODING_BIG5 Big5
  82. ONIG_ENCODING_GB18030 GB18030
  83. or any OnigEncodingType data address defined by user.
  84. 6 syntax: address of pattern syntax definition.
  85. ONIG_SYNTAX_ASIS plain text
  86. ONIG_SYNTAX_POSIX_BASIC POSIX Basic RE
  87. ONIG_SYNTAX_POSIX_EXTENDED POSIX Extended RE
  88. ONIG_SYNTAX_EMACS Emacs
  89. ONIG_SYNTAX_GREP grep
  90. ONIG_SYNTAX_GNU_REGEX GNU regex
  91. ONIG_SYNTAX_JAVA Java (Sun java.util.regex)
  92. ONIG_SYNTAX_PERL Perl
  93. ONIG_SYNTAX_PERL_NG Perl + named group
  94. ONIG_SYNTAX_RUBY Ruby
  95. ONIG_SYNTAX_DEFAULT default (== Ruby)
  96. onig_set_default_syntax()
  97. or any OnigSyntaxType data address defined by user.
  98. 7 err_info: address for return optional error info.
  99. Use this value as 3rd argument of onig_error_code_to_str().
  100. # int onig_new_without_alloc(regex_t* reg, const UChar* pattern,
  101. const UChar* pattern_end,
  102. OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
  103. OnigErrorInfo* err_info)
  104. Create a regex object.
  105. reg object area is not allocated in this function.
  106. normal return: ONIG_NORMAL
  107. # int onig_new_deluxe(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
  108. OnigCompileInfo* ci, OnigErrorInfo* einfo)
  109. Create a regex object.
  110. This function is deluxe version of onig_new().
  111. normal return: ONIG_NORMAL
  112. arguments
  113. 1 reg: return address of regex object.
  114. 2 pattern: regex pattern string.
  115. 3 pattern_end: terminate address of pattern. (pattern + pattern length)
  116. 4 ci: compile time info.
  117. ci->num_of_elements: number of elements in ci. (current version: 5)
  118. ci->pattern_enc: pattern string character encoding.
  119. ci->target_enc: target string character encoding.
  120. ci->syntax: address of pattern syntax definition.
  121. ci->option: compile time option.
  122. ci->case_fold_flag: character matching case fold bit flag for
  123. ONIG_OPTION_IGNORECASE mode.
  124. ONIGENC_CASE_FOLD_MIN: minimum
  125. ONIGENC_CASE_FOLD_DEFAULT: minimum
  126. onig_set_default_case_fold_flag()
  127. 5 err_info: address for return optional error info.
  128. Use this value as 3rd argument of onig_error_code_to_str().
  129. Different character encoding combination is allowed for
  130. the following cases only.
  131. pattern_enc: ASCII, ISO_8859_1
  132. target_enc: UTF16_BE, UTF16_LE, UTF32_BE, UTF32_LE
  133. pattern_enc: UTF16_BE/LE
  134. target_enc: UTF16_LE/BE
  135. pattern_enc: UTF32_BE/LE
  136. target_enc: UTF32_LE/BE
  137. # void onig_free(regex_t* reg)
  138. Free memory used by regex object.
  139. arguments
  140. 1 reg: regex object.
  141. # void onig_free_body(regex_t* reg)
  142. Free memory used by regex object. (Except reg oneself.)
  143. arguments
  144. 1 reg: regex object.
  145. # int onig_search(regex_t* reg, const UChar* str, const UChar* end, const UChar* start,
  146. const UChar* range, OnigRegion* region, OnigOptionType option)
  147. Search string and return search result and matching region.
  148. normal return: match position offset (i.e. p - str >= 0)
  149. not found: ONIG_MISMATCH (< 0)
  150. arguments
  151. 1 reg: regex object
  152. 2 str: target string
  153. 3 end: terminate address of target string
  154. 4 start: search start address of target string
  155. 5 range: search terminate address of target string
  156. in forward search (start <= searched string < range)
  157. in backward search (range <= searched string <= start)
  158. 6 region: address for return group match range info (NULL is allowed)
  159. 7 option: search time option
  160. ONIG_OPTION_NOTBOL string head(str) isn't considered as begin of line
  161. ONIG_OPTION_NOTEOL string end (end) isn't considered as end of line
  162. ONIG_OPTION_POSIX_REGION region argument is regmatch_t[] of POSIX API.
  163. # int onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at,
  164. OnigRegion* region, OnigOptionType option)
  165. Match string and return result and matching region.
  166. normal return: match length (>= 0)
  167. not match: ONIG_MISMATCH ( < 0)
  168. arguments
  169. 1 reg: regex object
  170. 2 str: target string
  171. 3 end: terminate address of target string
  172. 4 at: match address of target string
  173. 5 region: address for return group match range info (NULL is allowed)
  174. 6 option: search time option
  175. ONIG_OPTION_NOTBOL string head(str) isn't considered as begin of line
  176. ONIG_OPTION_NOTEOL string end (end) isn't considered as end of line
  177. ONIG_OPTION_POSIX_REGION region argument is regmatch_t[] type of POSIX API.
  178. # OnigRegion* onig_region_new(void)
  179. Create a region.
  180. # void onig_region_free(OnigRegion* region, int free_self)
  181. Free memory used by region.
  182. arguments
  183. 1 region: target region
  184. 2 free_self: [1: free all, 0: free memory used in region but not self]
  185. # void onig_region_copy(OnigRegion* to, OnigRegion* from)
  186. Copy contents of region.
  187. arguments
  188. 1 to: target region
  189. 2 from: source region
  190. # void onig_region_clear(OnigRegion* region)
  191. Clear contents of region.
  192. arguments
  193. 1 region: target region
  194. # int onig_region_resize(OnigRegion* region, int n)
  195. Resize group range area of region.
  196. normal return: ONIG_NORMAL
  197. arguments
  198. 1 region: target region
  199. 2 n: new size
  200. # int onig_name_to_group_numbers(regex_t* reg, const UChar* name, const UChar* name_end,
  201. int** num_list)
  202. Return the group number list of the name.
  203. Named subexp is defined by (?<name>....).
  204. normal return: number of groups for the name.
  205. (ex. /(?<x>..)(?<x>..)/ ==> 2)
  206. name not found: -1
  207. arguments
  208. 1 reg: regex object.
  209. 2 name: group name.
  210. 3 name_end: terminate address of group name.
  211. 4 num_list: return list of group number.
  212. # int onig_name_to_backref_number(regex_t* reg, const UChar* name, const UChar* name_end,
  213. OnigRegion *region)
  214. Return the group number corresponding to the named backref (\k<name>).
  215. If two or more regions for the groups of the name are effective,
  216. the greatest number in it is obtained.
  217. normal return: group number.
  218. arguments
  219. 1 reg: regex object.
  220. 2 name: group name.
  221. 3 name_end: terminate address of group name.
  222. 4 region: search/match result region.
  223. # int onig_foreach_name(regex_t* reg,
  224. int (*func)(const UChar*, const UChar*, int,int*,regex_t*,void*),
  225. void* arg)
  226. Iterate function call for all names.
  227. normal return: 0
  228. error: func's return value.
  229. arguments
  230. 1 reg: regex object.
  231. 2 func: callback function.
  232. func(name, name_end, <number of groups>, <group number's list>,
  233. reg, arg);
  234. if func does not return 0, then iteration is stopped.
  235. 3 arg: argument for func.
  236. # int onig_number_of_names(regex_t* reg)
  237. Return the number of names defined in the pattern.
  238. Multiple definitions of one name is counted as one.
  239. arguments
  240. 1 reg: regex object.
  241. # OnigEncoding onig_get_encoding(regex_t* reg)
  242. # OnigOptionType onig_get_options(regex_t* reg)
  243. # OnigCaseFoldType onig_get_case_fold_flag(regex_t* reg)
  244. # OnigSyntaxType* onig_get_syntax(regex_t* reg)
  245. Return a value of the regex object.
  246. arguments
  247. 1 reg: regex object.
  248. # int onig_number_of_captures(regex_t* reg)
  249. Return the number of capture group in the pattern.
  250. arguments
  251. 1 reg: regex object.
  252. # int onig_number_of_capture_histories(regex_t* reg)
  253. Return the number of capture history defined in the pattern.
  254. You can't use capture history if ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY
  255. is disabled in the pattern syntax.(disabled in the default syntax)
  256. arguments
  257. 1 reg: regex object.
  258. # OnigCaptureTreeNode* onig_get_capture_tree(OnigRegion* region)
  259. Return the root node of capture history data tree.
  260. This value is undefined if matching has faild.
  261. arguments
  262. 1 region: matching result.
  263. # int onig_capture_tree_traverse(OnigRegion* region, int at,
  264. int(*func)(int,int,int,int,int,void*), void* arg)
  265. Traverse and callback in capture history data tree.
  266. normal return: 0
  267. error: callback func's return value.
  268. arguments
  269. 1 region: match region data.
  270. 2 at: callback position.
  271. ONIG_TRAVERSE_CALLBACK_AT_FIRST: callback first, then traverse childs.
  272. ONIG_TRAVERSE_CALLBACK_AT_LAST: traverse childs first, then callback.
  273. ONIG_TRAVERSE_CALLBACK_AT_BOTH: callback first, then traverse childs,
  274. and at last callback again.
  275. 3 func: callback function.
  276. if func does not return 0, then traverse is stopped.
  277. int func(int group, int beg, int end, int level, int at,
  278. void* arg)
  279. group: group number
  280. beg: capture start position
  281. end: capture end position
  282. level: nest level (from 0)
  283. at: callback position
  284. ONIG_TRAVERSE_CALLBACK_AT_FIRST
  285. ONIG_TRAVERSE_CALLBACK_AT_LAST
  286. arg: optional callback argument
  287. 4 arg; optional callback argument.
  288. # int onig_noname_group_capture_is_active(regex_t* reg)
  289. Return noname group capture activity.
  290. active: 1
  291. inactive: 0
  292. arguments
  293. 1 reg: regex object.
  294. if option ONIG_OPTION_DONT_CAPTURE_GROUP == ON
  295. --> inactive
  296. if the regex pattern have named group
  297. and syntax ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP == ON
  298. and option ONIG_OPTION_CAPTURE_GROUP == OFF
  299. --> inactive
  300. else --> active
  301. # UChar* onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
  302. Return previous character head address.
  303. arguments
  304. 1 enc: character encoding
  305. 2 start: string address
  306. 3 s: target address of string
  307. # UChar* onigenc_get_left_adjust_char_head(OnigEncoding enc,
  308. const UChar* start, const UChar* s)
  309. Return left-adjusted head address of a character.
  310. arguments
  311. 1 enc: character encoding
  312. 2 start: string address
  313. 3 s: target address of string
  314. # UChar* onigenc_get_right_adjust_char_head(OnigEncoding enc,
  315. const UChar* start, const UChar* s)
  316. Return right-adjusted head address of a character.
  317. arguments
  318. 1 enc: character encoding
  319. 2 start: string address
  320. 3 s: target address of string
  321. # int onigenc_strlen(OnigEncoding enc, const UChar* s, const UChar* end)
  322. # int onigenc_strlen_null(OnigEncoding enc, const UChar* s)
  323. Return number of characters in the string.
  324. # int onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
  325. Return number of bytes in the string.
  326. # int onig_set_default_syntax(OnigSyntaxType* syntax)
  327. Set default syntax.
  328. arguments
  329. 1 syntax: address of pattern syntax definition.
  330. # void onig_copy_syntax(OnigSyntaxType* to, OnigSyntaxType* from)
  331. Copy syntax.
  332. arguments
  333. 1 to: destination address.
  334. 2 from: source address.
  335. # unsigned int onig_get_syntax_op(OnigSyntaxType* syntax)
  336. # unsigned int onig_get_syntax_op2(OnigSyntaxType* syntax)
  337. # unsigned int onig_get_syntax_behavior(OnigSyntaxType* syntax)
  338. # OnigOptionType onig_get_syntax_options(OnigSyntaxType* syntax)
  339. # void onig_set_syntax_op(OnigSyntaxType* syntax, unsigned int op)
  340. # void onig_set_syntax_op2(OnigSyntaxType* syntax, unsigned int op2)
  341. # void onig_set_syntax_behavior(OnigSyntaxType* syntax, unsigned int behavior)
  342. # void onig_set_syntax_options(OnigSyntaxType* syntax, OnigOptionType options)
  343. Get/Set elements of the syntax.
  344. arguments
  345. 1 syntax: syntax
  346. 2 op, op2, behavior, options: value of element.
  347. # void onig_copy_encoding(OnigEncoding to, OnigOnigEncoding from)
  348. Copy encoding.
  349. arguments
  350. 1 to: destination address.
  351. 2 from: source address.
  352. # int onig_set_meta_char(OnigSyntaxType* syntax, unsigned int what,
  353. OnigCodePoint code)
  354. Set a variable meta character to the code point value.
  355. Except for an escape character, this meta characters specification
  356. is not work, if ONIG_SYN_OP_VARIABLE_META_CHARACTERS is not effective
  357. by the syntax. (Build-in syntaxes are not effective.)
  358. normal return: ONIG_NORMAL
  359. arguments
  360. 1 syntax: target syntax
  361. 2 what: specifies which meta character it is.
  362. ONIG_META_CHAR_ESCAPE
  363. ONIG_META_CHAR_ANYCHAR
  364. ONIG_META_CHAR_ANYTIME
  365. ONIG_META_CHAR_ZERO_OR_ONE_TIME
  366. ONIG_META_CHAR_ONE_OR_MORE_TIME
  367. ONIG_META_CHAR_ANYCHAR_ANYTIME
  368. 3 code: meta character or ONIG_INEFFECTIVE_META_CHAR.
  369. # OnigCaseFoldType onig_get_default_case_fold_flag()
  370. Get default case fold flag.
  371. # int onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag)
  372. Set default case fold flag.
  373. 1 case_fold_flag: case fold flag
  374. # unsigned int onig_get_match_stack_limit_size(void)
  375. Return the maximum number of stack size.
  376. (default: 0 == unlimited)
  377. # int onig_set_match_stack_limit_size(unsigned int size)
  378. Set the maximum number of stack size.
  379. (size = 0: unlimited)
  380. normal return: ONIG_NORMAL
  381. # int onig_end(void)
  382. The use of this library is finished.
  383. normal return: ONIG_NORMAL
  384. It is not allowed to use regex objects which created
  385. before onig_end() call.
  386. # const char* onig_version(void)
  387. Return version string. (ex. "5.0.3")
  388. // END