6 #include "lib/global.h" /* <glib.h> */
10 #ifdef SEARCH_TYPE_PCRE
14 /*** typedefs(not structures) and defined constants **********************************************/
16 typedef int (*mc_search_fn
) (const void *user_data
, gsize char_offset
);
18 #define MC_SEARCH__NUM_REPLACE_ARGS 64
20 #ifdef SEARCH_TYPE_GLIB
21 # define mc_search_matchinfo_t GMatchInfo
23 # define mc_search_matchinfo_t pcre_extra
26 /*** enums ***************************************************************************************/
31 MC_SEARCH_E_REGEX_COMPILE
,
33 MC_SEARCH_E_REGEX_REPLACE
,
46 MC_SEARCH_CB_INVALID
= -1,
47 MC_SEARCH_CB_ABORT
= -2,
48 MC_SEARCH_CB_SKIP
= -3
52 /*** structures declarations (and typedefs of structures)*****************************************/
54 typedef struct mc_search_struct
{
56 /* public input data */
58 /* search in all charsets */
59 gboolean is_all_charsets
;
61 /* case sentitive search */
62 gboolean is_case_sentitive
;
64 /* search only once. Is this for replace? */
65 gboolean is_once_only
;
67 /* search only whole words (from begin to end). Used only with NORMAL search type */
70 /* search entire string (from begin to end). Used only with GLOB search type */
71 gboolean is_entire_line
;
73 /* function, used for getting data. NULL if not used */
74 mc_search_fn search_fn
;
76 /* function, used for updatin current search status. NULL if not used */
77 mc_search_fn update_fn
;
80 mc_search_type_t search_type
;
83 /* public output data */
85 /* some data for normal */
89 /* some data for regexp */
91 mc_search_matchinfo_t
*regex_match_info
;
92 GString
*regex_buffer
;
93 #ifdef SEARCH_TYPE_PCRE
94 int iovector
[MC_SEARCH__NUM_REPLACE_ARGS
* 2];
95 #endif /* SEARCH_TYPE_PCRE */
99 /* prepared conditions */
100 GPtrArray
*conditions
;
102 /* original search string */
106 /* error code after search */
107 mc_search_error_t error
;
112 typedef struct mc_search_type_str_struct
{
114 mc_search_type_t type
;
115 } mc_search_type_str_t
;
117 /*** global variables defined in .c file *********************************************************/
119 /*** declarations of public functions ************************************************************/
121 mc_search_t
*mc_search_new (const gchar
* original
, gsize original_len
);
123 void mc_search_free (mc_search_t
* mc_search
);
125 gboolean
mc_search_prepare (mc_search_t
* mc_search
);
127 gboolean
mc_search_run (mc_search_t
* mc_search
, const void *user_data
, gsize start_search
,
128 gsize end_search
, gsize
* found_len
);
130 gboolean
mc_search_is_type_avail (mc_search_type_t
);
132 const mc_search_type_str_t
*mc_search_types_list_get (size_t *num
);
134 GString
*mc_search_prepare_replace_str (mc_search_t
* mc_search
, GString
* replace_str
);
135 char *mc_search_prepare_replace_str2 (mc_search_t
*, char *);
137 gboolean
mc_search_is_fixed_search_str (mc_search_t
*);
139 gchar
**mc_search_get_types_strings_array (size_t *num
);
141 gboolean
mc_search (const gchar
*, const gchar
*, mc_search_type_t
);
143 int mc_search_getstart_rezult_by_num (mc_search_t
*, int);
144 int mc_search_getend_rezult_by_num (mc_search_t
*, int);