Debian Codegraph @

vendor/onigmo-source/doc/API

raw
1 Onigmo (Oniguruma-mod) API Version 6.0.0 2016/12/03
2
3 #include <onigmo.h>
4
5
6 # int onig_initialize(OnigEncoding use_encodings[], int num_encodings)
7
8 Initialize library.
9 This is added for compatibility to Oniguruma 6.0.
10 Currently this is same as onig_init().
11
12 arguments
13 1 use_encodings: array of encodings used in application.
14 2 num_encodings: number of encodings.
15
16
17 # int onig_init(void)
18
19 Initialize library.
20
21 Single thread program:
22 You don't have to call it explicitly, because it is called in onig_new().
23 However calling it is preferred.
24
25 Multi thread program:
26 You have to call it explicitly from a specific thread (normally the main
27 thread) before you use onig_new(), because onig_init() is not thread safe.
28
29
30 # int onig_error_code_to_str(UChar* err_buf, OnigPosition err_code, ...)
31
32 Get error message string.
33 If this function is used for onig_new(),
34 don't call this after the pattern argument of onig_new() is freed.
35
36 normal return: error message string length
37
38 arguments
39 1 err_buf: error message string buffer.
40 (required size: ONIG_MAX_ERROR_MESSAGE_LEN)
41 2 err_code: error code returned by other API functions.
42 3 err_info (optional): error info returned by onig_new().
43
44
45 # void onig_set_warn_func(OnigWarnFunc func)
46
47 Set warning function.
48
49 WARNING:
50 '[', '-', ']' in character class without escape.
51 ']' in pattern without escape.
52
53 arguments
54 1 func: function pointer. void (*func)(char* warning_message)
55
56
57 # void onig_set_verb_warn_func(OnigWarnFunc func)
58
59 Set verbose warning function.
60
61 WARNING:
62 redundant nested repeat operator.
63
64 arguments
65 1 func: function pointer. void (*func)(char* warning_message)
66
67
68 # int onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
69 OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
70 OnigErrorInfo* err_info)
71
72 Create a regex object.
73
74 normal return: ONIG_NORMAL
75
76 arguments
77 1 reg: return regex object's address.
78 2 pattern: regex pattern string.
79 3 pattern_end: terminate address of pattern. (pattern + pattern length)
80 4 option: compile time options.
81
82 ONIG_OPTION_NONE no option
83 ONIG_OPTION_SINGLELINE '^' -> '\A', '$' -> '\Z'
84 ONIG_OPTION_DOTALL '.' match with newline
85 ONIG_OPTION_MULTILINE same as ONIG_OPTION_DOTALL
86 ONIG_OPTION_IGNORECASE ambiguity match on
87 ONIG_OPTION_EXTEND extended pattern form
88 ONIG_OPTION_FIND_LONGEST find longest match
89 ONIG_OPTION_FIND_NOT_EMPTY ignore empty match
90 ONIG_OPTION_NEGATE_SINGLELINE
91 clear ONIG_OPTION_SINGLELINE which is enabled on
92 ONIG_SYNTAX_POSIX_BASIC, ONIG_SYNTAX_POSIX_EXTENDED,
93 ONIG_SYNTAX_PERL, ONIG_SYNTAX_PERL58, ONIG_SYNTAX_PERL58_NG,
94 ONIG_SYNTAX_JAVA, ONIG_SYNTAX_PYTHON
95
96 ONIG_OPTION_DONT_CAPTURE_GROUP only named group captured.
97 ONIG_OPTION_CAPTURE_GROUP named and no-named group captured.
98
99 ONIG_OPTION_NEWLINE_CRLF
100 Treat CR+LF as a newline too. (default: LF only)
101 To use this option, you must enable the following line in regenc.h.
102
103 /* #define USE_CRNL_AS_LINE_TERMINATOR */
104
105 5 enc: character encoding.
106
107 ONIG_ENCODING_ASCII ASCII
108 ONIG_ENCODING_ISO_8859_1 ISO 8859-1
109 ONIG_ENCODING_ISO_8859_2 ISO 8859-2
110 ONIG_ENCODING_ISO_8859_3 ISO 8859-3
111 ONIG_ENCODING_ISO_8859_4 ISO 8859-4
112 ONIG_ENCODING_ISO_8859_5 ISO 8859-5
113 ONIG_ENCODING_ISO_8859_6 ISO 8859-6
114 ONIG_ENCODING_ISO_8859_7 ISO 8859-7
115 ONIG_ENCODING_ISO_8859_8 ISO 8859-8
116 ONIG_ENCODING_ISO_8859_9 ISO 8859-9
117 ONIG_ENCODING_ISO_8859_10 ISO 8859-10
118 ONIG_ENCODING_ISO_8859_11 ISO 8859-11
119 ONIG_ENCODING_ISO_8859_13 ISO 8859-13
120 ONIG_ENCODING_ISO_8859_14 ISO 8859-14
121 ONIG_ENCODING_ISO_8859_15 ISO 8859-15
122 ONIG_ENCODING_ISO_8859_16 ISO 8859-16
123 ONIG_ENCODING_UTF_8 UTF-8
124 ONIG_ENCODING_UTF_16BE UTF-16BE
125 ONIG_ENCODING_UTF_16LE UTF-16LE
126 ONIG_ENCODING_UTF_32BE UTF-32BE
127 ONIG_ENCODING_UTF_32LE UTF-32LE
128 ONIG_ENCODING_EUC_JP EUC-JP
129 ONIG_ENCODING_EUC_TW EUC-TW
130 ONIG_ENCODING_EUC_KR EUC-KR
131 ONIG_ENCODING_EUC_CN EUC-CN
132 ONIG_ENCODING_SHIFT_JIS Shift_JIS
133 ONIG_ENCODING_WINDOWS_31J Windows-31J (CP932)
134 ONIG_ENCODING_KOI8_R KOI8-R
135 ONIG_ENCODING_KOI8_U KOI8-U
136 ONIG_ENCODING_WINDOWS_1250 Windows-1250 (CP1250)
137 ONIG_ENCODING_WINDOWS_1251 Windows-1251 (CP1251)
138 ONIG_ENCODING_WINDOWS_1252 Windows-1252 (CP1252)
139 ONIG_ENCODING_WINDOWS_1253 Windows-1253 (CP1253)
140 ONIG_ENCODING_WINDOWS_1254 Windows-1254 (CP1254)
141 ONIG_ENCODING_WINDOWS_1257 Windows-1257 (CP1257)
142 ONIG_ENCODING_BIG5 Big5
143 ONIG_ENCODING_GB18030 GB18030
144
145 or any OnigEncodingType data address defined by user.
146
147 The following encoding names can be also used for backward compatibility:
148
149 ONIG_ENCODING_UTF8 UTF-8
150 ONIG_ENCODING_UTF16_BE UTF-16BE
151 ONIG_ENCODING_UTF16_LE UTF-16LE
152 ONIG_ENCODING_UTF32_BE UTF-32BE
153 ONIG_ENCODING_UTF32_LE UTF-32LE
154 ONIG_ENCODING_SJIS Shift_JIS
155 ONIG_ENCODING_CP932 Windows-31J (CP932)
156 ONIG_ENCODING_CP1250 Windows-1250 (CP1250)
157 ONIG_ENCODING_CP1251 Windows-1251 (CP1251)
158 ONIG_ENCODING_CP1252 Windows-1252 (CP1252)
159 ONIG_ENCODING_CP1253 Windows-1253 (CP1253)
160 ONIG_ENCODING_CP1254 Windows-1254 (CP1254)
161 ONIG_ENCODING_CP1257 Windows-1257 (CP1257)
162
163
164 6 syntax: address of pattern syntax definition.
165
166 ONIG_SYNTAX_ASIS plain text
167 ONIG_SYNTAX_POSIX_BASIC POSIX Basic RE
168 ONIG_SYNTAX_POSIX_EXTENDED POSIX Extended RE
169 ONIG_SYNTAX_EMACS Emacs
170 ONIG_SYNTAX_GREP grep
171 ONIG_SYNTAX_GNU_REGEX GNU regex
172 ONIG_SYNTAX_JAVA Java (Sun java.util.regex)
173 ONIG_SYNTAX_PERL58 Perl 5.8
174 ONIG_SYNTAX_PERL58_NG Perl 5.8 + named group
175 ONIG_SYNTAX_PERL Perl 5.10+
176 ONIG_SYNTAX_PYTHON Python
177 ONIG_SYNTAX_RUBY Ruby
178 ONIG_SYNTAX_DEFAULT default (== Ruby)
179 onig_set_default_syntax()
180
181 or any OnigSyntaxType data address defined by user.
182
183 7 err_info: address for return optional error info.
184 Use this value as 3rd argument of onig_error_code_to_str().
185
186
187
188 # int onig_new_without_alloc(regex_t* reg, const UChar* pattern,
189 const UChar* pattern_end,
190 OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
191 OnigErrorInfo* err_info)
192
193 Create a regex object.
194 reg object area is not allocated in this function.
195
196 normal return: ONIG_NORMAL
197
198
199
200 # int onig_new_deluxe(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
201 OnigCompileInfo* ci, OnigErrorInfo* einfo)
202
203 Create a regex object.
204 This function is deluxe version of onig_new().
205
206 normal return: ONIG_NORMAL
207
208 arguments
209 1 reg: return address of regex object.
210 2 pattern: regex pattern string.
211 3 pattern_end: terminate address of pattern. (pattern + pattern length)
212 4 ci: compile time info.
213
214 ci->num_of_elements: number of elements in ci. (current version: 5)
215 ci->pattern_enc: pattern string character encoding.
216 ci->target_enc: target string character encoding.
217 ci->syntax: address of pattern syntax definition.
218 ci->option: compile time option.
219 ci->case_fold_flag: character matching case fold bit flag for
220 ONIG_OPTION_IGNORECASE mode.
221
222 ONIGENC_CASE_FOLD_MIN: minimum
223 ONIGENC_CASE_FOLD_DEFAULT: minimum
224 onig_set_default_case_fold_flag()
225
226 5 err_info: address for return optional error info.
227 Use this value as 3rd argument of onig_error_code_to_str().
228
229
230 Different character encoding combination is allowed for
231 the following cases only.
232
233 pattern_enc: ASCII, ISO_8859_1
234 target_enc: UTF_16BE, UTF_16LE, UTF_32BE, UTF_32LE
235
236 pattern_enc: UTF_16BE/LE
237 target_enc: UTF_16LE/BE
238
239 pattern_enc: UTF_32BE/LE
240 target_enc: UTF_32LE/BE
241
242
243 # void onig_free(regex_t* reg)
244
245 Free memory used by regex object.
246
247 arguments
248 1 reg: regex object.
249
250
251 # void onig_free_body(regex_t* reg)
252
253 Free memory used by regex object. (Except reg oneself.)
254
255 arguments
256 1 reg: regex object.
257
258
259 # OnigPosition onig_search(regex_t* reg, const UChar* str, const UChar* end,
260 const UChar* start, const UChar* range, OnigRegion* region,
261 OnigOptionType option)
262 # OnigPosition onig_search_gpos(regex_t* reg, const UChar* str, const UChar* end,
263 const UChar* global_pos,
264 const UChar* start, const UChar* range, OnigRegion* region,
265 OnigOptionType option)
266
267 Search string and return search result and matching region.
268
269 normal return: match position offset (i.e. p - str >= 0)
270 not found: ONIG_MISMATCH (< 0)
271
272 arguments
273 1 reg: regex object
274 2 str: target string
275 3 end: terminate address of target string
276 4 global_pos: position of \G
277 if not need, set same value as str.
278 5 start: search start address of target string
279 6 range: search terminate address of target string
280 in forward search (start <= searched string < range)
281 in backward search (range <= searched string <= start)
282 7 region: address for return group match range info (NULL is allowed)
283 8 option: search time option
284
285 ONIG_OPTION_NOTBOL string head(str) isn't considered as begin of line
286 ONIG_OPTION_NOTEOL string end (end) isn't considered as end of line
287 ONIG_OPTION_NOTBOS string head(str) isn't considered as begin of string (\A)
288 ONIG_OPTION_NOTEOS string end (end) isn't considered as end of string (\z)
289
290
291 # OnigPosition onig_match(regex_t* reg, const UChar* str, const UChar* end,
292 const UChar* at, OnigRegion* region, OnigOptionType option)
293
294 Match string and return result and matching region.
295
296 normal return: match length (>= 0)
297 not match: ONIG_MISMATCH ( < 0)
298
299 arguments
300 1 reg: regex object
301 2 str: target string
302 3 end: terminate address of target string
303 4 at: match address of target string
304 5 region: address for return group match range info (NULL is allowed)
305 6 option: search time option
306
307 ONIG_OPTION_NOTBOL string head(str) isn't considered as begin of line
308 ONIG_OPTION_NOTEOL string end (end) isn't considered as end of line
309 ONIG_OPTION_NOTBOS string head(str) isn't considered as begin of string (\A)
310 ONIG_OPTION_NOTEOS string end (end) isn't considered as end of string (\z)
311
312
313 # OnigPosition onig_scan(regex_t* reg, const UChar* str, const UChar* end,
314 OnigRegion* region, OnigOptionType option,
315 int (*scan_callback)(OnigPosition, OnigPosition, OnigRegion*, void*),
316 void* callback_arg)
317
318 Scan string and callback with matching region.
319
320 normal return: number of matching times
321 error: error code
322 interruption: return value of callback function (!= 0)
323
324 arguments
325 1 reg: regex object
326 2 str: target string
327 3 end: terminate address of target string
328 4 region: address for return group match range info (NULL is allowed)
329 5 option: search time option
330 6 scan_callback: callback function (defined by user)
331 7 callback_arg: optional argument passed to callback
332
333
334 # OnigRegion* onig_region_new(void)
335
336 Create a region.
337
338
339 # void onig_region_free(OnigRegion* region, int free_self)
340
341 Free memory used by region.
342
343 arguments
344 1 region: target region
345 2 free_self: [1: free all, 0: free memory used in region but not self]
346
347
348 # void onig_region_copy(OnigRegion* to, const OnigRegion* from)
349
350 Copy contents of region.
351
352 arguments
353 1 to: target region
354 2 from: source region
355
356
357 # void onig_region_clear(OnigRegion* region)
358
359 Clear contents of region.
360
361 arguments
362 1 region: target region
363
364
365 # int onig_region_resize(OnigRegion* region, int n)
366
367 Resize group range area of region.
368
369 normal return: ONIG_NORMAL
370
371 arguments
372 1 region: target region
373 2 n: new size
374
375
376 # int onig_name_to_group_numbers(regex_t* reg, const UChar* name, const UChar* name_end,
377 int** num_list)
378
379 Return the group number list of the name.
380 Named subexp is defined by (?<name>....).
381
382 normal return: number of groups for the name.
383 (ex. /(?<x>..)(?<x>..)/ ==> 2)
384 name not found: -1
385
386 arguments
387 1 reg: regex object.
388 2 name: group name.
389 3 name_end: terminate address of group name.
390 4 num_list: return list of group number.
391
392
393 # int onig_name_to_backref_number(regex_t* reg, const UChar* name, const UChar* name_end,
394 const OnigRegion *region)
395
396 Return the group number corresponding to the named backref (\k<name>).
397 If two or more regions for the groups of the name are effective,
398 the greatest number in it is obtained.
399
400 normal return: group number.
401
402 arguments
403 1 reg: regex object.
404 2 name: group name.
405 3 name_end: terminate address of group name.
406 4 region: search/match result region.
407
408
409 # int onig_foreach_name(regex_t* reg,
410 int (*func)(const UChar*, const UChar*, int,int*,regex_t*,void*),
411 void* arg)
412
413 Iterate function call for all names.
414
415 normal return: 0
416 error: func's return value.
417
418 arguments
419 1 reg: regex object.
420 2 func: callback function.
421 func(name, name_end, <number of groups>, <group number's list>,
422 reg, arg);
423 if func does not return 0, then iteration is stopped.
424 3 arg: argument for func.
425
426
427 # int onig_number_of_names(const regex_t* reg)
428
429 Return the number of names defined in the pattern.
430 Multiple definitions of one name is counted as one.
431
432 arguments
433 1 reg: regex object.
434
435
436 # OnigEncoding onig_get_encoding(const regex_t* reg)
437 # OnigOptionType onig_get_options(const regex_t* reg)
438 # OnigCaseFoldType onig_get_case_fold_flag(const regex_t* reg)
439 # OnigSyntaxType* onig_get_syntax(const regex_t* reg)
440
441 Return a value of the regex object.
442
443 arguments
444 1 reg: regex object.
445
446
447 # int onig_number_of_captures(const regex_t* reg)
448
449 Return the number of capture group in the pattern.
450
451 arguments
452 1 reg: regex object.
453
454
455 # int onig_number_of_capture_histories(const regex_t* reg)
456
457 Return the number of capture history defined in the pattern.
458
459 You can't use capture history if ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY
460 is disabled in the pattern syntax.(disabled in the default syntax)
461
462 arguments
463 1 reg: regex object.
464
465
466
467 # OnigCaptureTreeNode* onig_get_capture_tree(OnigRegion* region)
468
469 Return the root node of capture history data tree.
470
471 This value is undefined if matching has faild.
472
473 arguments
474 1 region: matching result.
475
476
477 # int onig_capture_tree_traverse(OnigRegion* region, int at,
478 int(*func)(int,OnigPosition,OnigPosition,int,int,void*),
479 void* arg)
480
481 Traverse and callback in capture history data tree.
482
483 normal return: 0
484 error: callback func's return value.
485
486 arguments
487 1 region: match region data.
488 2 at: callback position.
489
490 ONIG_TRAVERSE_CALLBACK_AT_FIRST: callback first, then traverse children.
491 ONIG_TRAVERSE_CALLBACK_AT_LAST: traverse children first, then callback.
492 ONIG_TRAVERSE_CALLBACK_AT_BOTH: callback first, then traverse children,
493 and at last callback again.
494
495 3 func: callback function.
496 if func does not return 0, then traverse is stopped.
497
498 int func(int group, OnigPosition beg, OnigPosition end,
499 int level, int at, void* arg)
500
501 group: group number
502 beg: capture start position
503 end: capture end position
504 level: nest level (from 0)
505 at: callback position
506 ONIG_TRAVERSE_CALLBACK_AT_FIRST
507 ONIG_TRAVERSE_CALLBACK_AT_LAST
508 arg: optional callback argument
509
510 4 arg; optional callback argument.
511
512
513 # int onig_noname_group_capture_is_active(const regex_t* reg)
514
515 Return noname group capture activity.
516
517 active: 1
518 inactive: 0
519
520 arguments
521 1 reg: regex object.
522
523 if option ONIG_OPTION_DONT_CAPTURE_GROUP == ON
524 --> inactive
525
526 if the regex pattern have named group
527 and syntax ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP == ON
528 and option ONIG_OPTION_CAPTURE_GROUP == OFF
529 --> inactive
530
531 else --> active
532
533
534 # UChar* onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start,
535 const UChar* s, const UChar* end)
536
537 Return previous character head address.
538
539 arguments
540 1 enc: character encoding
541 2 start: string address
542 3 s: target address of string
543 4 end: end of string
544
545
546 # UChar* onigenc_get_left_adjust_char_head(OnigEncoding enc,
547 const UChar* start, const UChar* s, const UChar* end)
548
549 Return left-adjusted head address of a character.
550
551 arguments
552 1 enc: character encoding
553 2 start: string address
554 3 s: target address of string
555 4 end: end of string
556
557
558 # UChar* onigenc_get_right_adjust_char_head(OnigEncoding enc,
559 const UChar* start, const UChar* s, const UChar* end)
560
561 Return right-adjusted head address of a character.
562
563 arguments
564 1 enc: character encoding
565 2 start: string address
566 3 s: target address of string
567 4 end: end of string
568
569
570 # int onigenc_strlen(OnigEncoding enc, const UChar* s, const UChar* end)
571 # int onigenc_strlen_null(OnigEncoding enc, const UChar* s)
572
573 Return number of characters in the string.
574
575
576 # int onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
577
578 Return number of bytes in the string.
579
580
581 # int onig_set_default_syntax(const OnigSyntaxType* syntax)
582
583 Set default syntax.
584
585 arguments
586 1 syntax: address of pattern syntax definition.
587
588
589 # void onig_copy_syntax(OnigSyntaxType* to, const OnigSyntaxType* from)
590
591 Copy syntax.
592
593 arguments
594 1 to: destination address.
595 2 from: source address.
596
597
598 # unsigned int onig_get_syntax_op(const OnigSyntaxType* syntax)
599 # unsigned int onig_get_syntax_op2(const OnigSyntaxType* syntax)
600 # unsigned int onig_get_syntax_behavior(const OnigSyntaxType* syntax)
601 # OnigOptionType onig_get_syntax_options(const OnigSyntaxType* syntax)
602
603 # void onig_set_syntax_op(OnigSyntaxType* syntax, unsigned int op)
604 # void onig_set_syntax_op2(OnigSyntaxType* syntax, unsigned int op2)
605 # void onig_set_syntax_behavior(OnigSyntaxType* syntax, unsigned int behavior)
606 # void onig_set_syntax_options(OnigSyntaxType* syntax, OnigOptionType options)
607
608 Get/Set elements of the syntax.
609
610 arguments
611 1 syntax: syntax
612 2 op, op2, behavior, options: value of element.
613
614
615 # void onig_copy_encoding(OnigEncodingType *to, OnigEncoding from)
616
617 Copy encoding.
618
619 arguments
620 1 to: destination address.
621 2 from: source address.
622
623
624 # int onig_set_meta_char(OnigSyntaxType* syntax, unsigned int what,
625 OnigCodePoint code)
626
627 Set a variable meta character to the code point value.
628 Except for an escape character, this meta characters specification
629 is not work, if ONIG_SYN_OP_VARIABLE_META_CHARACTERS is not effective
630 by the syntax. (Build-in syntaxes are not effective.)
631
632 normal return: ONIG_NORMAL
633
634 arguments
635 1 syntax: target syntax
636 2 what: specifies which meta character it is.
637
638 ONIG_META_CHAR_ESCAPE
639 ONIG_META_CHAR_ANYCHAR
640 ONIG_META_CHAR_ANYTIME
641 ONIG_META_CHAR_ZERO_OR_ONE_TIME
642 ONIG_META_CHAR_ONE_OR_MORE_TIME
643 ONIG_META_CHAR_ANYCHAR_ANYTIME
644
645 3 code: meta character or ONIG_INEFFECTIVE_META_CHAR.
646
647
648 # OnigCaseFoldType onig_get_default_case_fold_flag(void)
649
650 Get default case fold flag.
651
652
653 # int onig_set_default_case_fold_flag(OnigCaseFoldType case_fold_flag)
654
655 Set default case fold flag.
656
657 1 case_fold_flag: case fold flag
658
659
660 # unsigned int onig_get_match_stack_limit_size(void)
661
662 Return the maximum number of stack size.
663 (default: 0 == unlimited)
664
665
666 # int onig_set_match_stack_limit_size(unsigned int size)
667
668 Set the maximum number of stack size.
669 (size = 0: unlimited)
670
671 normal return: ONIG_NORMAL
672
673
674 # unsigned int onig_get_parse_depth_limit(void)
675
676 Return the maximum depth of parser recursion.
677 (default: DEFAULT_PARSE_DEPTH_LIMIT defined in regint.h. Currently 4096.)
678
679
680 # int onig_set_parse_depth_limit(unsigned int depth)
681
682 Set the maximum depth of parser recursion.
683 (depth = 0: Set to the default value defined in regint.h.)
684
685 normal return: ONIG_NORMAL
686
687
688 # int onig_end(void)
689
690 The use of this library is finished.
691
692 normal return: ONIG_NORMAL
693
694 It is not allowed to use regex objects which created
695 before onig_end() call.
696
697
698 # const char* onig_version(void)
699
700 Return version string. (ex. "5.0.3")
701
702 // END