6 #include "lib/global.h" /* <glib.h> */
10 #ifdef SEARCH_TYPE_PCRE
14 /*** typedefs(not structures) and defined constants **********************************************/
16 typedef enum mc_search_cbret_t mc_search_cbret_t
;
18 typedef mc_search_cbret_t (*mc_search_fn
) (const void *user_data
, gsize char_offset
,
20 typedef mc_search_cbret_t (*mc_update_fn
) (const void *user_data
, gsize char_offset
);
22 #define MC_SEARCH__NUM_REPLACE_ARGS 64
24 #ifdef SEARCH_TYPE_GLIB
25 #define mc_search_matchinfo_t GMatchInfo
27 #define mc_search_matchinfo_t pcre_extra
30 /*** enums ***************************************************************************************/
36 MC_SEARCH_E_REGEX_COMPILE
,
38 MC_SEARCH_E_REGEX_REPLACE
,
44 MC_SEARCH_T_INVALID
= -1,
51 enum mc_search_cbret_t
54 MC_SEARCH_CB_INVALID
= -1,
55 MC_SEARCH_CB_ABORT
= -2,
56 MC_SEARCH_CB_SKIP
= -3
59 /*** structures declarations (and typedefs of structures)*****************************************/
61 typedef struct mc_search_struct
63 /* public input data */
66 /* search in all charsets */
67 gboolean is_all_charsets
;
70 /* case sensitive search */
71 gboolean is_case_sensitive
;
73 /* search only once. Is this for replace? */
74 gboolean is_once_only
;
76 /* search only whole words (from begin to end). Used only with NORMAL search type */
79 /* search entire string (from begin to end). Used only with GLOB search type */
80 gboolean is_entire_line
;
82 /* function, used for getting data. NULL if not used */
83 mc_search_fn search_fn
;
85 /* function, used for updatin current search status. NULL if not used */
86 mc_update_fn update_fn
;
89 mc_search_type_t search_type
;
91 /* public output data */
93 /* some data for normal */
97 /* some data for regexp */
100 mc_search_matchinfo_t
*regex_match_info
;
101 GString
*regex_buffer
;
102 #ifdef SEARCH_TYPE_PCRE
103 int iovector
[MC_SEARCH__NUM_REPLACE_ARGS
* 2];
104 #endif /* SEARCH_TYPE_PCRE */
108 /* prepared conditions */
109 GPtrArray
*conditions
;
111 /* original search string */
115 gchar
*original_charset
;
118 /* error code after search */
119 mc_search_error_t error
;
123 typedef struct mc_search_type_str_struct
126 mc_search_type_t type
;
127 } mc_search_type_str_t
;
129 /*** global variables defined in .c file *********************************************************/
132 extern const char *STR_E_NOTFOUND
;
133 extern const char *STR_E_UNKNOWN_TYPE
;
134 extern const char *STR_E_RPL_NOT_EQ_TO_FOUND
;
135 extern const char *STR_E_RPL_INVALID_TOKEN
;
137 /*** declarations of public functions ************************************************************/
139 mc_search_t
*mc_search_new (const gchar
* original
, const gchar
* original_charset
);
141 mc_search_t
*mc_search_new_len (const gchar
* original
, gsize original_len
,
142 const gchar
* original_charset
);
144 void mc_search_free (mc_search_t
* lc_mc_search
);
146 gboolean
mc_search_prepare (mc_search_t
* mc_search
);
148 gboolean
mc_search_run (mc_search_t
* mc_search
, const void *user_data
, gsize start_search
,
149 gsize end_search
, gsize
* found_len
);
151 gboolean
mc_search_is_type_avail (mc_search_type_t
);
153 const mc_search_type_str_t
*mc_search_types_list_get (size_t * num
);
155 GString
*mc_search_prepare_replace_str (mc_search_t
* mc_search
, GString
* replace_str
);
156 char *mc_search_prepare_replace_str2 (mc_search_t
* lc_mc_search
, const char *replace_str
);
158 gboolean
mc_search_is_fixed_search_str (mc_search_t
*);
160 gchar
**mc_search_get_types_strings_array (size_t * num
);
162 gboolean
mc_search (const gchar
* pattern
, const gchar
* pattern_charset
, const gchar
* str
,
163 mc_search_type_t type
);
165 int mc_search_getstart_result_by_num (mc_search_t
*, int);
166 int mc_search_getend_result_by_num (mc_search_t
*, int);