6 #include "../src/global.h" /* <glib.h> */
8 #if ! GLIB_CHECK_VERSION (2, 14, 0)
14 # include <sys/types.h>
19 /*** typedefs(not structures) and defined constants **********************************************/
21 typedef int (*mc_search_fn
) (const void *user_data
, gsize char_offset
);
23 #define MC_SEARCH__NUM_REPL_ARGS 64
25 #if GLIB_CHECK_VERSION (2, 14, 0)
26 #define mc_search_matchinfo_t GMatchInfo
29 # define mc_search_matchinfo_t pcre_extra
31 # define mc_search_matchinfo_t regmatch_t
35 #define MC_SEARCH__PCRE_MAX_MATCHES 64
37 /*** enums ***************************************************************************************/
42 MC_SEARCH_E_REGEX_COMPILE
,
44 MC_SEARCH_E_REGEX_REPLACE
,
56 /*** structures declarations (and typedefs of structures)*****************************************/
58 typedef struct mc_search_struct
{
60 /* public input data */
62 /* search in all charsets */
63 gboolean is_all_charsets
;
65 /* case sentitive search */
66 gboolean is_case_sentitive
;
68 /* search only once. Is this for replace? */
69 gboolean is_once_only
;
71 /* function, used for getting data. NULL if not used */
72 mc_search_fn search_fn
;
75 mc_search_type_t search_type
;
78 /* public output data */
80 /* some data for normal */
83 /* some data for regexp */
84 mc_search_matchinfo_t
*regex_match_info
;
85 GString
*regex_buffer
;
86 #if ! GLIB_CHECK_VERSION (2, 14, 0)
89 int iovector
[MC_SEARCH__PCRE_MAX_MATCHES
* 2];
90 #else /* HAVE_LIBPCRE */
91 #endif /* HAVE_LIBPCRE */
92 #endif /* ! GLIB_CHECK_VERSION (2, 14, 0) */
96 /* prepared conditions */
97 GPtrArray
*conditions
;
99 /* original search string */
103 /* error code after search */
104 mc_search_error_t error
;
109 typedef struct mc_search_type_str_struct
{
111 mc_search_type_t type
;
112 } mc_search_type_str_t
;
114 /*** global variables defined in .c file *********************************************************/
116 /*** declarations of public functions ************************************************************/
118 mc_search_t
*mc_search_new (const gchar
* original
, gsize original_len
);
120 void mc_search_free (mc_search_t
* mc_search
);
122 gboolean
mc_search_run (mc_search_t
* mc_search
, const void *user_data
, gsize start_search
,
123 gsize end_search
, gsize
* founded_len
);
125 gboolean
mc_search_is_type_avail (mc_search_type_t
);
127 const mc_search_type_str_t
*mc_search_types_list_get (void);
129 GString
*mc_search_prepare_replace_str (mc_search_t
* mc_search
, GString
* replace_str
);
131 gboolean
mc_search_is_fixed_search_str (mc_search_t
*);
133 gchar
**mc_search_get_types_strings_array (void);
135 gboolean
mc_search (const gchar
*, const gchar
*, mc_search_type_t
);
137 int mc_search_getstart_rezult_by_num(mc_search_t
*, int);
138 int mc_search_getend_rezult_by_num(mc_search_t
*, int);