Initialize the gmime for upstream
[platform/upstream/gmime.git] / util / url-scanner.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*  GMime
3  *  Copyright (C) 2000-2012 Jeffrey Stedfast
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public License
7  *  as published by the Free Software Foundation; either version 2.1
8  *  of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free
17  *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
18  *  02110-1301, USA.
19  */
20
21
22 #ifndef __URL_SCANNER_H__
23 #define __URL_SCANNER_H__
24
25 #include <glib.h>
26 #include <sys/types.h>
27
28 G_BEGIN_DECLS
29
30 typedef struct {
31         const char *pattern;
32         const char *prefix;
33         size_t um_so;
34         size_t um_eo;
35 } urlmatch_t;
36
37 typedef gboolean (*UrlScanFunc) (const char *in, const char *pos, const char *inend, urlmatch_t *match);
38
39 /* some default GUrlScanFunc's */
40 G_GNUC_INTERNAL gboolean url_file_start (const char *in, const char *pos, const char *inend, urlmatch_t *match);
41 G_GNUC_INTERNAL gboolean url_file_end (const char *in, const char *pos, const char *inend, urlmatch_t *match);
42 G_GNUC_INTERNAL gboolean url_web_start (const char *in, const char *pos, const char *inend, urlmatch_t *match);
43 G_GNUC_INTERNAL gboolean url_web_end (const char *in, const char *pos, const char *inend, urlmatch_t *match);
44 G_GNUC_INTERNAL gboolean url_addrspec_start (const char *in, const char *pos, const char *inend, urlmatch_t *match);
45 G_GNUC_INTERNAL gboolean url_addrspec_end (const char *in, const char *pos, const char *inend, urlmatch_t *match);
46
47 typedef struct {
48         char *pattern;
49         char *prefix;
50         UrlScanFunc start;
51         UrlScanFunc end;
52 } urlpattern_t;
53
54 typedef struct _UrlScanner UrlScanner;
55
56 G_GNUC_INTERNAL UrlScanner *url_scanner_new (void);
57 G_GNUC_INTERNAL void url_scanner_free (UrlScanner *scanner);
58
59 G_GNUC_INTERNAL void url_scanner_add (UrlScanner *scanner, urlpattern_t *pattern);
60
61 G_GNUC_INTERNAL gboolean url_scanner_scan (UrlScanner *scanner, const char *in, size_t inlen, urlmatch_t *match);
62
63 G_END_DECLS
64
65 #endif /* __URL_SCANNER_H__ */