OSDN Git Service

fix copyright year.
[bbk/bchan.git] / src / tadlib.h
1 /*
2  * tadlib.h
3  *
4  * Copyright (c) 2009-2010 project bchan
5  *
6  * This software is provided 'as-is', without any express or implied
7  * warranty. In no event will the authors be held liable for any damages
8  * arising from the use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not
15  *    claim that you wrote the original software. If you use this software
16  *    in a product, an acknowledgment in the product documentation would be
17  *    appreciated but is not required.
18  *
19  * 2. Altered source versions must be plainly marked as such, and must not be
20  *    misrepresented as being the original software.
21  *
22  * 3. This notice may not be removed or altered from any source
23  *    distribution.
24  *
25  */
26
27 #include    <basic.h>
28 #include        <btron/dp.h>
29 #include        <tad.h>
30
31 #ifndef __TADLIB_H__
32 #define __TADLIB_H__
33
34 typedef struct actionlist_t_ actionlist_t;
35
36 #define ACTIONLIST_ACTIONTYPE_ANCHOR 0
37 #define ACTIONLIST_ACTIONTYPE_URL    1
38 #define ACTIONLIST_ACTIONTYPE_NUMBER 2
39 #define ACTIONLIST_ACTIONTYPE_RESID  3
40 IMPORT actionlist_t* actionlist_new();
41 IMPORT VOID actionlist_delete(actionlist_t *alist);
42 IMPORT W actionlist_findboard(actionlist_t *alist, PNT pos, RECT *r, W *type, UB **start, W *len);
43
44 IMPORT W tadlib_calcdrawsize(TC *str, W len, GID gid, SIZE *sz, actionlist_t **alist);
45 IMPORT W tadlib_drawtext(TC *str, W len, GID gid, W dh, W dv);
46 IMPORT W tadlib_remove_TA_APPL_calcsize(TC *str, W len);
47 IMPORT W tadlib_remove_TA_APPL(TC *str, W len, TC *dest, W dest_len);
48 IMPORT W tadlib_UW_to_str(UW val, TC *dest, W dest_len);
49 IMPORT VOID tadlib_separete_datepart(TC *str, W len, TC **date, W *date_len, TC **id, W *id_len, TC **beid, W *beid_len);
50
51 struct taditerator_t_ {
52         TC *bin;
53         W len;
54         W index;
55 };
56 typedef struct taditerator_t_ taditerator_t;
57
58 enum TADITERATOR_RESULT_T_ {
59         TADITERATOR_RESULT_CHARCTOR,
60         TADITERATOR_RESULT_SEGMENT,
61         TADITERATOR_RESULT_END,
62 };
63 typedef enum TADITERATOR_RESULT_T_ TADITERATOR_RESULT_T;
64
65 IMPORT VOID taditerator_initialize(taditerator_t *iterator, TC *bin, W strlen);
66 IMPORT VOID taditerator_finalize(taditerator_t *iterator);
67 IMPORT W  taditerator_next(taditerator_t *iterator, TC **pos, TC *segment, LTADSEG **seg, W *segsize, UB **data);
68
69 typedef struct tctokenchecker_valuetuple_t_ tctokenchecker_valuetuple_t;
70 struct tctokenchecker_valuetuple_t_ {
71         TC *name;
72         W val;
73 };
74
75 typedef struct tctokenchecker_t_ tctokenchecker_t;
76 struct tctokenchecker_t_ {
77         tctokenchecker_valuetuple_t *namelist;
78         W namelistnum;
79         TC *endtokens;
80         W stringindex;
81         W listindex_start;
82         W listindex_end;
83         W flag;
84 };
85
86 enum {
87         TCTOKENCHECKER_CONTINUE,
88         TCTOKENCHECKER_CONTINUE_NOMATCH,
89         TCTOKENCHECKER_DETERMINE,
90         TCTOKENCHECKER_NOMATCH,
91         TCTOKENCHECKER_AFTER_END
92 };
93
94 IMPORT VOID tctokenchecker_initialize(tctokenchecker_t *checker, tctokenchecker_valuetuple_t *namelist, W namelistnum, TC *endchars);
95 IMPORT VOID tctokenchecker_finalize(tctokenchecker_t *checker);
96 IMPORT VOID tctokenchecker_clear(tctokenchecker_t *checker);
97 IMPORT W tctokenchecker_inputchar(tctokenchecker_t *checker, TC c, W *val);
98 IMPORT VOID tctokenchecker_getlastmatchedstring(tctokenchecker_t *checker, TC **str, W *len);
99
100 typedef struct {
101 #if BIGENDIAN
102         UB subid;
103         UB attr;
104 #else
105         UB attr;
106         UB subid;
107 #endif
108         UH appl[3];
109 } TT_BCHAN;
110
111 #define TT_BCHAN_SUBID_ANCHOR_START 1
112 #define TT_BCHAN_SUBID_ANCHOR_END   2
113 #define TT_BCHAN_SUBID_URL_START    3
114 #define TT_BCHAN_SUBID_URL_END      4
115
116 #endif