~ubuntu-branches/ubuntu/trusty/cuneiform/trusty

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/ced/sources/main/ced.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, c-assert.diff, slovenian-slv.diff
  • Date: 2011-01-26 21:53:07 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110126215307-62x61mcesr607qb7
Tags: 1.0.0+dfsg-2
* Upload to unstable.
* Explicitly build-depend on pkg-config. Thanks to Stefano Rivera for the
  bug report.
* Add Vcs-* fields.
* Use the standard C assert() macro, rather than custom Cuneiform one.
  [c-assert.diff]
* Pass CFLAGS, CXXFLAGS and LDFLAGS (get from dpkg-buildflags) to cmake
  (closes: #608345). Thanks to Sami Liedes for the bug report.
  + Build depend on dpkg-dev (>= 1.15.7).
* Pass --parallel to dh.
  + Bump debhelper minimum version to 7.4.10.
* Update debian/copyright to the latest DEP-5 version.
* Bump year in debian/copyright.
* Explicitly link to GraphicsMagick (rather than via the ImageMagick
  compatibility layer).
* Don't ship /usr/lib/cuneiform/*.so symlinks. These libraries are
  considered private, at least until #598616 is fixed.
* Rename some private variables in debian/rules to make them lowercase.
* Update patch headers.
* Provide proper ‘build-arch’ and ‘build-indep’ targets in debian/rules.
* Document input format in the manual page (closes: #572061). Thanks to
  Janusz S. Bień for the bug report.
* Use ‘slv’ (rather than ‘slo’) as language code for Slovenian.
  [slovenian-slv.diff]
* Fix package description: Slovenian is supported, Slovak is not.
* Improve documentation of the language (-l) option (closes: #602512).
  Thanks to Jari Aalto for the bug report.
* Install reasons file for vrms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
Copyright (c) 1993-2008, Cognitive Technologies
3
 
All rights reserved.
4
 
 
5
 
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
 
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
7
 
 
8
 
      * ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
 
        ���� ����������� �� ��������� �����, ���� ������ ������� � �����������
10
 
        ����� �� ��������.
11
 
      * ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
 
        ������ ����������, ������������ ��� ���������������, ������ �����������
13
 
        ��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
 
        ����������� ����� �� ��������.
15
 
      * �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
 
        ���� ������������ � �������� �������� ��������� �/��� �����������
17
 
        ���������, ���������� �� ���� ��, ��� ���������������� �����������
18
 
        ����������.
19
 
 
20
 
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
 
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
 
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
 
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
 
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
 
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
 
������������� ������, ��������� � �������������� ��� ���������� ����������
27
 
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
 
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
 
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
 
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
 
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
32
 
 
33
 
Redistribution and use in source and binary forms, with or without modification,
34
 
are permitted provided that the following conditions are met:
35
 
 
36
 
    * Redistributions of source code must retain the above copyright notice,
37
 
      this list of conditions and the following disclaimer.
38
 
    * Redistributions in binary form must reproduce the above copyright notice,
39
 
      this list of conditions and the following disclaimer in the documentation
40
 
      and/or other materials provided with the distribution.
41
 
    * Neither the name of the Cognitive Technologies nor the names of its
42
 
      contributors may be used to endorse or promote products derived from this
43
 
      software without specific prior written permission.
44
 
 
45
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49
 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55
 
*/
 
2
 Copyright (c) 1993-2008, Cognitive Technologies
 
3
 All rights reserved.
 
4
 
 
5
 Разрешается повторное распространение и использование как в виде исходного кода,
 
6
 так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
 
7
 
 
8
 * При повторном распространении исходного кода должны оставаться указанное
 
9
 выше уведомление об авторском праве, этот список условий и последующий
 
10
 отказ от гарантий.
 
11
 * При повторном распространении двоичного кода в документации и/или в
 
12
 других материалах, поставляемых при распространении, должны сохраняться
 
13
 указанная выше информация об авторском праве, этот список условий и
 
14
 последующий отказ от гарантий.
 
15
 * Ни название Cognitive Technologies, ни имена ее сотрудников не могут
 
16
 быть использованы в качестве средства поддержки и/или продвижения
 
17
 продуктов, основанных на этом ПО, без предварительного письменного
 
18
 разрешения.
 
19
 
 
20
 ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
 
21
 ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
 
22
 ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
 
23
 ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
 
24
 МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
 
25
 НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
 
26
 ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
 
27
 НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
 
28
 СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
 
29
 ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
 
30
 НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
 
31
 ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
 
32
 
 
33
 Redistribution and use in source and binary forms, with or without modification,
 
34
 are permitted provided that the following conditions are met:
 
35
 
 
36
 * Redistributions of source code must retain the above copyright notice,
 
37
 this list of conditions and the following disclaimer.
 
38
 * Redistributions in binary form must reproduce the above copyright notice,
 
39
 this list of conditions and the following disclaimer in the documentation
 
40
 and/or other materials provided with the distribution.
 
41
 * Neither the name of the Cognitive Technologies nor the names of its
 
42
 contributors may be used to endorse or promote products derived from this
 
43
 software without specific prior written permission.
 
44
 
 
45
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
46
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
47
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
48
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 
49
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
50
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
51
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
52
 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
53
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
54
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
55
 */
56
56
 
57
57
#include "stdafx.h"
58
58
 
63
63
//#include "edfile.h"
64
64
//#include "edext.h"
65
65
 
66
 
Bool32 func_char(PWord8 p, Word32 lth);
67
 
Bool32 func_spec(PWord8 p, Word32 lth);
 
66
Bool32 func_char(puchar p, uint32_t lth);
 
67
Bool32 func_spec(puchar p, uint32_t lth);
68
68
 
69
 
FNCFIOReadMemoryFromFile    MemFromFile;
70
 
FNCFIOLockMemory                                        Lock;
71
 
FNCFIOUnlockMemory                              Unlock;
72
 
FNCFIOFreeMemory                                        Free;
 
69
FNCFIOReadMemoryFromFile MemFromFile;
 
70
FNCFIOLockMemory Lock;
 
71
FNCFIOUnlockMemory Unlock;
 
72
FNCFIOFreeMemory Free;
73
73
//FNCFIOAllocMemory                                     Alloc;
74
 
FNCFIOOpenFreeFile                                      Open;
75
 
FNCFIOCloseFreeFile                                     Close;
76
 
FNCFIOWriteToFile                                       Write;
77
 
 
78
 
 
79
 
static unsigned char ed_table[]=
80
 
    {
81
 
    sizeof (struct bit_map_ref),        /* 0  SS_BITMAP_REF         */
82
 
    sizeof (struct text_ref),           /* 1  SS_TEXT_REF           */
83
 
    sizeof (struct font_kegl),          /* 2  SS_FONT_KEGL          */
84
 
    sizeof (struct kegl),               /* 3  SS_KEGL               */
85
 
    sizeof (struct shift),              /* 4  SS_SHIFT              */
86
 
    sizeof (struct retrieve_level),     /* 5  SS_RETR_LEVEL         */
87
 
    sizeof (struct underline),          /* 6  SS_UNDERLINE          */
88
 
    sizeof (struct dens_print),         /* 7  SS_DENS_PRINT         */
89
 
    sizeof (struct tabul),              /* 8  SS_TABUL              */
90
 
    0x41,                               /* 9  SS_TABL_TABUL         */
91
 
    0x84,                               /* 0A SS_SHEET_DESCR        */
92
 
    sizeof (struct fragm_disk),         /* 0B SS_FRAGMENT           */
93
 
    sizeof (struct step_back),          /* 0C SS_STEP_BACK          */
94
 
    sizeof (struct line_beg),           /* 0D SS_LINE_BEG           */
95
 
    sizeof (struct position),           /* 0E SS_POSITION           */
96
 
    sizeof(struct EdTagLanguage),       /* 0F SS_LANGUAGE           */
97
 
    sizeof (struct table_conform_sizes),/* 10 SS_TABL_CONFORM_SIZES */
98
 
    sizeof (struct group_words),        /* 11 SS_GROUP_WORDS        */
99
 
    sizeof (struct group_symbols),      /* 12 SS_GROUP_SYMBOLS      */
100
 
    0,                                  /* 13 Unused code           */
101
 
    0,                                  /* 14 Unused code           */
102
 
    2,                                  /* 15 ASCII symbol 'Start Paragraph'      */
103
 
    sizeof (struct border),             /* 16 SS_BORDER             */
104
 
    0x82,                               /* 17 SS_TABLE_HEADER       */
105
 
    0x82,                               /* 18 SS_LIST_OF FRAGMENTS  */
106
 
    0,                                  /* 19 Unused code           */
107
 
    0,                                  /* 1A Unused code           */
108
 
    0,                                  /* 1B Unused code           */
109
 
    0x83,                               /* 1C Special code of Extention ED */
110
 
    sizeof (struct aksant),             /* 1D SS_AKSANT             */
111
 
    sizeof (struct neg_half_space),     /* 1E SS_NEG_HALF_SPACE     */
112
 
    sizeof (struct pos_half_space)      /* 1F SS_POS_HALF_SPACE     */
113
 
    };
 
74
FNCFIOOpenFreeFile Open;
 
75
FNCFIOCloseFreeFile Close;
 
76
FNCFIOWriteToFile Write;
 
77
 
 
78
static unsigned char ed_table[] = { sizeof(struct bit_map_ref), /* 0  SS_BITMAP_REF         */
 
79
sizeof(struct text_ref), /* 1  SS_TEXT_REF           */
 
80
sizeof(struct font_kegl), /* 2  SS_FONT_KEGL          */
 
81
sizeof(struct kegl), /* 3  SS_KEGL               */
 
82
sizeof(struct shift), /* 4  SS_SHIFT              */
 
83
sizeof(struct retrieve_level), /* 5  SS_RETR_LEVEL         */
 
84
sizeof(struct underline), /* 6  SS_UNDERLINE          */
 
85
sizeof(struct dens_print), /* 7  SS_DENS_PRINT         */
 
86
sizeof(struct tabul), /* 8  SS_TABUL              */
 
87
0x41, /* 9  SS_TABL_TABUL         */
 
88
0x84, /* 0A SS_SHEET_DESCR        */
 
89
sizeof(struct fragm_disk), /* 0B SS_FRAGMENT           */
 
90
sizeof(struct step_back), /* 0C SS_STEP_BACK          */
 
91
sizeof(struct line_beg), /* 0D SS_LINE_BEG           */
 
92
sizeof(struct position), /* 0E SS_POSITION           */
 
93
sizeof(struct EdTagLanguage), /* 0F SS_LANGUAGE           */
 
94
sizeof(struct table_conform_sizes),/* 10 SS_TABL_CONFORM_SIZES */
 
95
sizeof(struct group_words), /* 11 SS_GROUP_WORDS        */
 
96
sizeof(struct group_symbols), /* 12 SS_GROUP_SYMBOLS      */
 
97
0, /* 13 Unused code           */
 
98
0, /* 14 Unused code           */
 
99
2, /* 15 ASCII symbol 'Start Paragraph'      */
 
100
sizeof(struct border), /* 16 SS_BORDER             */
 
101
0x82, /* 17 SS_TABLE_HEADER       */
 
102
0x82, /* 18 SS_LIST_OF FRAGMENTS  */
 
103
0, /* 19 Unused code           */
 
104
0, /* 1A Unused code           */
 
105
0, /* 1B Unused code           */
 
106
0x83, /* 1C Special code of Extention ED */
 
107
sizeof(struct aksant), /* 1D SS_AKSANT             */
 
108
sizeof(struct neg_half_space), /* 1E SS_NEG_HALF_SPACE     */
 
109
sizeof(struct pos_half_space) /* 1F SS_POS_HALF_SPACE     */
 
110
};
114
111
 
115
112
//###########################################
116
 
void CED_SetRawDataProc(FNRDProc proc)
117
 
{
 
113
void CED_SetRawDataProc(FNRDProc proc) {
118
114
#define DEC_FUN(a,b,c)  b=MyRawData##b
119
115
 
120
 
DEC_FUN(void, CED_BitmapRef,(const bit_map_ref* pt));
121
 
DEC_FUN(void, CED_TextRef,(const text_ref* pt));
122
 
DEC_FUN(void, CED_FontKegl,(const font_kegl *pt));
123
 
DEC_FUN(void, CED_Kegl,(const kegl* pt));
124
 
DEC_FUN(void, CED_Shift,(const shift* pt));
125
 
DEC_FUN(void, CED_RetrieveLevel,(const retrieve_level* pt));
126
 
DEC_FUN(void, CED_Underline,(const underline* pt));
127
 
DEC_FUN(void, CED_DensPrint,(const dens_print* pt));
128
 
DEC_FUN(void, CED_Tabul,(const tabul* pt));
129
 
DEC_FUN(void, CED_TablTabul,(const tabl_tabul* pt));
130
 
DEC_FUN(void, CED_SheetDiskDescr,(const sheet_disk_descr* pt));
131
 
DEC_FUN(void, CED_FragmDiskDescr,(const fragm_disk_descr* pt));
132
 
DEC_FUN(void, CED_FragmDisk,(const fragm_disk* pt));
133
 
DEC_FUN(void, CED_StepBack,(const step_back* pt));
134
 
DEC_FUN(void, CED_LineBeg,(const line_beg* pt));
135
 
DEC_FUN(void, CED_Position,(const position* pt));
136
 
DEC_FUN(void, CED_EdTagLanguage,(const EdTagLanguage* pt));
137
 
DEC_FUN(void, CED_TableConformSizes,(const table_conform_sizes* pt));
138
 
DEC_FUN(void, CED_GroupWords,(const group_words* pt));
139
 
DEC_FUN(void, CED_GroupSymbols,(const group_symbols* pt));
140
 
DEC_FUN(void, CED_Border,(const border* pt));
141
 
DEC_FUN(void, CED_TableHeader,(const table_header* pt));
142
 
DEC_FUN(void, CED_ListOfFragments,(const list_of_fragments* pt));
143
 
DEC_FUN(void, CED_Extention,(const edExtention* pt,const void* ptExt));
144
 
DEC_FUN(void, CED_ExtentionNew,(const edExtentionNew* pt,const void* ptExt));
145
 
DEC_FUN(void, CED_Aksant,(const aksant* pt));
146
 
DEC_FUN(void, CED_Letter,(const letter* pt,const Word32 alternatives));
 
116
        DEC_FUN(void, CED_BitmapRef,(const bit_map_ref* pt));
 
117
        DEC_FUN(void, CED_TextRef,(const text_ref* pt));
 
118
        DEC_FUN(void, CED_FontKegl,(const font_kegl *pt));
 
119
        DEC_FUN(void, CED_Kegl,(const kegl* pt));
 
120
        DEC_FUN(void, CED_Shift,(const shift* pt));
 
121
        DEC_FUN(void, CED_RetrieveLevel,(const retrieve_level* pt));
 
122
        DEC_FUN(void, CED_Underline,(const underline* pt));
 
123
        DEC_FUN(void, CED_DensPrint,(const dens_print* pt));
 
124
        DEC_FUN(void, CED_Tabul,(const tabul* pt));
 
125
        DEC_FUN(void, CED_TablTabul,(const tabl_tabul* pt));
 
126
        DEC_FUN(void, CED_SheetDiskDescr,(const sheet_disk_descr* pt));
 
127
        DEC_FUN(void, CED_FragmDiskDescr,(const fragm_disk_descr* pt));
 
128
        DEC_FUN(void, CED_FragmDisk,(const fragm_disk* pt));
 
129
        DEC_FUN(void, CED_StepBack,(const step_back* pt));
 
130
        DEC_FUN(void, CED_LineBeg,(const line_beg* pt));
 
131
        DEC_FUN(void, CED_Position,(const position* pt));
 
132
        DEC_FUN(void, CED_EdTagLanguage,(const EdTagLanguage* pt));
 
133
        DEC_FUN(void, CED_TableConformSizes,(const table_conform_sizes* pt));
 
134
        DEC_FUN(void, CED_GroupWords,(const group_words* pt));
 
135
        DEC_FUN(void, CED_GroupSymbols,(const group_symbols* pt));
 
136
        DEC_FUN(void, CED_Border,(const border* pt));
 
137
        DEC_FUN(void, CED_TableHeader,(const table_header* pt));
 
138
        DEC_FUN(void, CED_ListOfFragments,(const list_of_fragments* pt));
 
139
        DEC_FUN(void, CED_Extention,(const edExtention* pt,const void* ptExt));
 
140
        DEC_FUN(void, CED_ExtentionNew,(const edExtentionNew* pt,const void* ptExt));
 
141
        DEC_FUN(void, CED_Aksant,(const aksant* pt));
 
142
        DEC_FUN(void, CED_Letter,(const letter* pt,const uint32_t alternatives));
147
143
 
148
144
#undef DEC_FUN
149
145
 
150
 
RDProced=proc;
 
146
        RDProced = proc;
151
147
}
152
148
 
153
 
/*CED_FUNC(*/Word32/*)*/ CED_ReadED(char * file,Bool32 readFromFile, Word32 bufLen)
154
 
{
155
 
        Word8 code;
 
149
/*CED_FUNC(*/uint32_t/*)*/CED_ReadED(char * file, Bool32 readFromFile,
 
150
                uint32_t bufLen) {
 
151
        uchar code;
156
152
        HANDLE PedHandle;
157
 
        Word32 lth,ret;
158
 
        PWord8 start,edscan_stop;
 
153
        uint32_t lth, ret;
 
154
        puchar start, edscan_stop;
159
155
 
160
 
        if (readFromFile)
161
 
        {
162
 
                ret=MemFromFile((PInt8)file,&PedHandle);
163
 
                if (ret==0)
 
156
        if (readFromFile) {
 
157
                ret = MemFromFile((pchar) file, &PedHandle);
 
158
                if (ret == 0)
164
159
                        return 0;
165
 
                start = (PWord8)Lock(PedHandle);
166
 
                if ( !start )
167
 
                {
 
160
                start = (puchar) Lock(PedHandle);
 
161
                if (!start) {
168
162
                        Unlock(PedHandle);
169
163
                        Free(PedHandle);
170
164
                        return 0;
171
165
                }
172
 
        }
173
 
        else
174
 
        {
175
 
                start =(Word8*)file;
176
 
                ret=bufLen;
177
 
        }
178
 
        PWord8 curr = edscan_stop=start;
179
 
        PWord8 end=start+ret;
 
166
        } else {
 
167
                start = (uchar*) file;
 
168
                ret = bufLen;
 
169
        }
 
170
        puchar curr = edscan_stop = start;
 
171
        puchar end = start + ret;
180
172
 
181
 
next_symb:
182
 
        if (curr>=end) goto quit;
183
 
        if (*curr >= ' ')
184
 
        {
 
173
        next_symb: if (curr >= end)
 
174
                goto quit;
 
175
        if (*curr >= ' ') {
185
176
                start = curr;
186
 
                while (end - curr >= 2)
187
 
                {
 
177
                while (end - curr >= 2) {
188
178
                        curr += 2;
189
 
                        if (!(*(curr-1) & 1))
 
179
                        if (!(*(curr - 1) & 1))
190
180
                                goto char_proc;
191
181
                }
192
 
                edscan_stop = start; goto quit;
 
182
                edscan_stop = start;
 
183
                goto quit;
193
184
 
194
 
char_proc:
195
 
                if (func_char(start, (WORD)(curr-start))) goto next_symb;
196
 
                edscan_stop = start; goto quit;
 
185
                char_proc: if (func_char(start, (uint16_t)(curr - start)))
 
186
                        goto next_symb;
 
187
                edscan_stop = start;
 
188
                goto quit;
197
189
        }
198
190
 
199
 
 /* Search code */
200
 
/*If the size exceeds 0x40, then actual size is stored in structure itself. Its offset is equal to (value in a table & 0xf). length of the size is 2 bytes if value in table >=0x80 and 1 byte otherwise.
201
 
 */
202
 
        code = ed_table [*curr];
 
191
        /* Search code */
 
192
        /*If the size exceeds 0x40, then actual size is stored in structure itself. Its offset is equal to (value in a table & 0xf). length of the size is 2 bytes if value in table >=0x80 and 1 byte otherwise.
 
193
         */
 
194
        code = ed_table[*curr];
203
195
 
204
 
        if ((code & 0xc0) == 0)
205
 
        {
206
 
                if (code == 0)
207
 
                {
 
196
        if ((code & 0xc0) == 0) {
 
197
                if (code == 0) {
208
198
                        curr += sizeof(*curr);
209
199
                        goto next_symb;
210
200
                }
211
 
    // { edscan_stop = curr;        return 32; }
212
 
                if (end - curr < code)
213
 
                {
 
201
                // { edscan_stop = curr;        return 32; }
 
202
                if (end - curr < code) {
214
203
                        edscan_stop = curr;
215
204
                        goto quit;
216
205
                }
217
 
                if ( func_spec(curr, code) )
218
 
                {
 
206
                if (func_spec(curr, code)) {
219
207
                        curr += code;
220
208
                        goto next_symb;
221
209
                }
222
 
                edscan_stop=curr;
 
210
                edscan_stop = curr;
223
211
                goto quit;
224
212
        }
225
213
 
226
 
        if (code & 0x80)
227
 
        {
228
 
//SS_EXTENTION can be either 16 or 32 bit.
229
 
                if (*(Word8*)curr!=SS_EXTENTION)
230
 
                        lth = *(PWord16) (curr + (code & 0xf));
231
 
                else
232
 
                {
233
 
                        if (!( (*(Word16*)(curr+1)) &0x8000))
234
 
                                lth=*(PWord16) (curr + (code & 0xf));
 
214
        if (code & 0x80) {
 
215
                //SS_EXTENTION can be either 16 or 32 bit.
 
216
                if (*(uchar*) curr != SS_EXTENTION)
 
217
                        lth = *(uint16_t*)(curr + (code & 0xf));
 
218
                else {
 
219
                        if (!((*(uint16_t*) (curr + 1)) & 0x8000))
 
220
                                lth = *(uint16_t*)(curr + (code & 0xf));
235
221
                        else
236
 
                                lth=*(PWord32) (curr + (code & 0xf));
 
222
                                lth = *(uint32_t*)(curr + (code & 0xf));
237
223
                }
238
 
        }
239
 
        else
240
 
                lth = *(PWord8) (curr + (code & 0xf));
 
224
        } else
 
225
                lth = *(puchar)(curr + (code & 0xf));
241
226
 
242
 
        if (lth == 0)
243
 
        {
 
227
        if (lth == 0) {
244
228
                curr += sizeof(*curr);
245
229
                goto next_symb;
246
230
        }
247
 
    //{ edscan_stop = curr; return 32; }
248
 
        if ((unsigned)(end - curr) < lth)
249
 
        {
 
231
        //{ edscan_stop = curr; return 32; }
 
232
        if ((unsigned) (end - curr) < lth) {
250
233
                edscan_stop = curr;
251
234
                goto quit;
252
235
        }
253
 
        if ( func_spec(curr, lth) )
254
 
    {
 
236
        if (func_spec(curr, lth)) {
255
237
                curr += lth;
256
238
                goto next_symb;
257
239
        }
258
 
        edscan_stop=curr;
 
240
        edscan_stop = curr;
259
241
        goto quit;
260
242
 
261
 
quit:
262
 
         ret=(int)(edscan_stop-start);
263
 
        if (readFromFile)
264
 
        {
 
243
        quit: ret = (int) (edscan_stop - start);
 
244
        if (readFromFile) {
265
245
                Unlock(PedHandle);
266
246
                Free(PedHandle);
267
247
        }
268
248
        return ret;
269
249
}
270
250
 
271
 
 
272
 
Bool32 func_char(PWord8 p, Word32 lth)
273
 
{
274
 
        const struct letter *pt= (struct letter*)p;
275
 
        CED_Letter(pt,lth/2);
 
251
Bool32 func_char(puchar p, uint32_t lth) {
 
252
        const struct letter *pt = (struct letter*) p;
 
253
        CED_Letter(pt, lth / 2);
276
254
        return TRUE;
277
255
}
278
256
 
279
 
Bool32 func_spec(PWord8 p, Word32 lth)
280
 
{
281
 
 
282
 
        switch (*p)
283
 
        {
284
 
            case SS_BITMAP_REF:
285
 
                {
286
 
                        const struct bit_map_ref *pt= (struct bit_map_ref*)p;
287
 
                        CED_BitmapRef(pt);
288
 
                        break;
289
 
                }
290
 
 
291
 
                case SS_TEXT_REF:
292
 
                {
293
 
                        const struct text_ref *pt = (text_ref *)p;
294
 
                        CED_TextRef(pt);
295
 
                        break;
296
 
                }
297
 
 
298
 
                case SS_FONT_KEGL:
299
 
                {
300
 
                        const struct font_kegl *pt = (struct font_kegl*)p;
301
 
                        CED_FontKegl(pt);
302
 
                        break;
303
 
                }
304
 
 
305
 
                case SS_KEGL:
306
 
                {
307
 
                        const struct kegl *pt = (struct kegl*)p;
308
 
                        CED_Kegl(pt);
309
 
                        break;
310
 
                }
311
 
 
312
 
                case SS_SHIFT:
313
 
                {
314
 
                        const shift *pt=(shift*)p;
315
 
                        CED_Shift(pt);
316
 
                        break;
317
 
                }
318
 
 
319
 
                case SS_RETR_LEVEL:
320
 
                {
321
 
                        const retrieve_level *pt=(retrieve_level *)p;
322
 
                        CED_RetrieveLevel(pt);
323
 
                        break;
324
 
                }
325
 
 
326
 
                case SS_UNDERLINE:
327
 
                {
328
 
                        const struct underline *pt = (struct underline*)p;
329
 
                        CED_Underline(pt);
330
 
                        break;
331
 
                }
332
 
 
333
 
                case SS_DENS_PRINT:
334
 
                {
335
 
                        const struct dens_print *pt = (struct dens_print*)p;
336
 
                        CED_DensPrint(pt);
337
 
                        break;
338
 
                }
339
 
 
340
 
                case SS_TABUL:
341
 
                {
342
 
                        const tabul *pt=(tabul*)p;
343
 
                        CED_Tabul(pt);
344
 
                        break;
345
 
                }
346
 
 
347
 
                case SS_TABL_TABUL:
348
 
                {
349
 
                        const tabl_tabul *pt=(tabl_tabul*)p;
350
 
                        CED_TablTabul(pt);
351
 
                        break;
352
 
                }
353
 
 
354
 
                case SS_SHEET_DESCR:
355
 
                {
356
 
                        const sheet_disk_descr* pt=(sheet_disk_descr*)p;
357
 
                        CED_SheetDiskDescr(pt);
358
 
                        for (int i=0;i<pt->quant_fragm;i++)
359
 
                        {
360
 
                                const fragm_disk_descr *pt1=(fragm_disk_descr*)(p+
361
 
                                                i*sizeof(fragm_disk_descr)+sizeof(sheet_disk_descr));
362
 
                                CED_FragmDiskDescr(pt1);
363
 
                        }
364
 
                        break;
365
 
                }
366
 
 
367
 
                case SS_FRAGMENT:
368
 
                {
369
 
                        const fragm_disk* pt=(fragm_disk*)p;
370
 
                        CED_FragmDisk(pt);
371
 
                        break;
372
 
                }
373
 
 
374
 
                case SS_STEP_BACK:
375
 
                {
376
 
                        const step_back* pt=(step_back*)p;
377
 
                        CED_StepBack(pt);
378
 
                        break;
379
 
                }
380
 
 
381
 
                case SS_LINE_BEG:
382
 
                {
383
 
                        const struct line_beg *pt= (struct line_beg*)p;
384
 
                        CED_LineBeg(pt);
385
 
                        break;
386
 
                }
387
 
 
388
 
                case SS_POSITION:
389
 
                {
390
 
                        const struct position *pt= (struct position*)p;
391
 
                        CED_Position(pt);
392
 
                        break;
393
 
                }
394
 
 
395
 
        case SS_LANGUAGE:
396
 
                {
397
 
                        const struct EdTagLanguage *pt= (struct EdTagLanguage*)p;
398
 
                        CED_EdTagLanguage(pt);
399
 
                        break;
400
 
                }
401
 
 
402
 
        case SS_TABL_CONFORM_SIZES:
403
 
                {
404
 
                        const struct table_conform_sizes *pt= (struct table_conform_sizes*)p;
405
 
                        CED_TableConformSizes(pt);
406
 
                        break;
407
 
                }
408
 
 
409
 
        case SS_GROUP_WORDS:
410
 
                {
411
 
                        const struct group_words *pt= (struct group_words*)p;
412
 
                        CED_GroupWords(pt);
413
 
                        break;
414
 
                }
415
 
 
416
 
        case SS_GROUP_SYMBOLS:
417
 
                {
418
 
                        const struct group_symbols *pt= (struct group_symbols*)p;
419
 
                        CED_GroupSymbols(pt);
420
 
                        break;
421
 
                }
422
 
 
423
 
        case 0x15:
424
 
                {
425
 
                        *(p+1)&=254;
426
 
                        func_char(p,2);
427
 
                        break;
428
 
                }
429
 
 
430
 
        case SS_BORDER:
431
 
                {
432
 
                        const struct border *pt= (struct border*)p;
433
 
                        CED_Border(pt);
434
 
                        break;
435
 
                }
436
 
 
437
 
        case SS_TABLE_HEADER:
438
 
                {
439
 
                        const struct table_header *pt= (struct table_header*)p;
440
 
                        CED_TableHeader(pt);
441
 
                        break;
442
 
                }
443
 
 
444
 
        case SS_LIST_OF_FRAGMENTS:
445
 
                {
446
 
                        const struct list_of_fragments *pt= (struct list_of_fragments*)p;
447
 
                        CED_ListOfFragments(pt);
448
 
                        break;
449
 
                }
450
 
 
451
 
        case SS_EXTENTION:
452
 
                {
453
 
                        const struct edExtention *pt= (struct edExtention*)p;
454
 
                        if (!(pt->Ecode&0x8000))
455
 
                                CED_Extention(pt,(const char*)(p+sizeof(edExtention)));
456
 
                        else
457
 
                        {
458
 
                                const struct edExtentionNew *pt1= (struct edExtentionNew*)p;
459
 
                                CED_ExtentionNew(pt1,(const char*)(p+sizeof(edExtentionNew)));
460
 
                        }
461
 
                        break;
462
 
                }
463
 
 
464
 
        case SS_AKSANT:
465
 
                {
466
 
                        const struct aksant *pt= (struct aksant*)p;
467
 
                        CED_Aksant(pt);
468
 
                        break;
469
 
                }
470
 
 
471
 
                case SS_NEG_HALF_SPACE:
472
 
                        {
473
 
                        *(p+1)&=254;
474
 
                        func_char(p,2);
475
 
                        break;
476
 
                        }
477
 
 
478
 
                case SS_POS_HALF_SPACE:
479
 
                        *(p+1)&=254;
480
 
                        func_char(p,2);
481
 
                        break;
482
 
 
483
 
                default:
484
 
                        {
485
 
                        return FALSE;
486
 
                        }
487
 
        }
488
 
return TRUE;
 
257
Bool32 func_spec(puchar p, uint32_t lth) {
 
258
 
 
259
        switch (*p) {
 
260
        case SS_BITMAP_REF: {
 
261
                const struct bit_map_ref *pt = (struct bit_map_ref*) p;
 
262
                CED_BitmapRef(pt);
 
263
                break;
 
264
        }
 
265
 
 
266
        case SS_TEXT_REF: {
 
267
                const struct text_ref *pt = (text_ref *) p;
 
268
                CED_TextRef(pt);
 
269
                break;
 
270
        }
 
271
 
 
272
        case SS_FONT_KEGL: {
 
273
                const struct font_kegl *pt = (struct font_kegl*) p;
 
274
                CED_FontKegl(pt);
 
275
                break;
 
276
        }
 
277
 
 
278
        case SS_KEGL: {
 
279
                const struct kegl *pt = (struct kegl*) p;
 
280
                CED_Kegl(pt);
 
281
                break;
 
282
        }
 
283
 
 
284
        case SS_SHIFT: {
 
285
                const shift *pt = (shift*) p;
 
286
                CED_Shift(pt);
 
287
                break;
 
288
        }
 
289
 
 
290
        case SS_RETR_LEVEL: {
 
291
                const retrieve_level *pt = (retrieve_level *) p;
 
292
                CED_RetrieveLevel(pt);
 
293
                break;
 
294
        }
 
295
 
 
296
        case SS_UNDERLINE: {
 
297
                const struct underline *pt = (struct underline*) p;
 
298
                CED_Underline(pt);
 
299
                break;
 
300
        }
 
301
 
 
302
        case SS_DENS_PRINT: {
 
303
                const struct dens_print *pt = (struct dens_print*) p;
 
304
                CED_DensPrint(pt);
 
305
                break;
 
306
        }
 
307
 
 
308
        case SS_TABUL: {
 
309
                const tabul *pt = (tabul*) p;
 
310
                CED_Tabul(pt);
 
311
                break;
 
312
        }
 
313
 
 
314
        case SS_TABL_TABUL: {
 
315
                const tabl_tabul *pt = (tabl_tabul*) p;
 
316
                CED_TablTabul(pt);
 
317
                break;
 
318
        }
 
319
 
 
320
        case SS_SHEET_DESCR: {
 
321
                const sheet_disk_descr* pt = (sheet_disk_descr*) p;
 
322
                CED_SheetDiskDescr(pt);
 
323
                for (int i = 0; i < pt->quant_fragm; i++) {
 
324
                        const fragm_disk_descr *pt1 = (fragm_disk_descr*) (p + i
 
325
                                        * sizeof(fragm_disk_descr) + sizeof(sheet_disk_descr));
 
326
                        CED_FragmDiskDescr(pt1);
 
327
                }
 
328
                break;
 
329
        }
 
330
 
 
331
        case SS_FRAGMENT: {
 
332
                const fragm_disk* pt = (fragm_disk*) p;
 
333
                CED_FragmDisk(pt);
 
334
                break;
 
335
        }
 
336
 
 
337
        case SS_STEP_BACK: {
 
338
                const step_back* pt = (step_back*) p;
 
339
                CED_StepBack(pt);
 
340
                break;
 
341
        }
 
342
 
 
343
        case SS_LINE_BEG: {
 
344
                const struct line_beg *pt = (struct line_beg*) p;
 
345
                CED_LineBeg(pt);
 
346
                break;
 
347
        }
 
348
 
 
349
        case SS_POSITION: {
 
350
                const struct position *pt = (struct position*) p;
 
351
                CED_Position(pt);
 
352
                break;
 
353
        }
 
354
 
 
355
        case SS_LANGUAGE: {
 
356
                const struct EdTagLanguage *pt = (struct EdTagLanguage*) p;
 
357
                CED_EdTagLanguage(pt);
 
358
                break;
 
359
        }
 
360
 
 
361
        case SS_TABL_CONFORM_SIZES: {
 
362
                const struct table_conform_sizes *pt = (struct table_conform_sizes*) p;
 
363
                CED_TableConformSizes(pt);
 
364
                break;
 
365
        }
 
366
 
 
367
        case SS_GROUP_WORDS: {
 
368
                const struct group_words *pt = (struct group_words*) p;
 
369
                CED_GroupWords(pt);
 
370
                break;
 
371
        }
 
372
 
 
373
        case SS_GROUP_SYMBOLS: {
 
374
                const struct group_symbols *pt = (struct group_symbols*) p;
 
375
                CED_GroupSymbols(pt);
 
376
                break;
 
377
        }
 
378
 
 
379
        case 0x15: {
 
380
                *(p + 1) &= 254;
 
381
                func_char(p, 2);
 
382
                break;
 
383
        }
 
384
 
 
385
        case SS_BORDER: {
 
386
                const struct border *pt = (struct border*) p;
 
387
                CED_Border(pt);
 
388
                break;
 
389
        }
 
390
 
 
391
        case SS_TABLE_HEADER: {
 
392
                const struct table_header *pt = (struct table_header*) p;
 
393
                CED_TableHeader(pt);
 
394
                break;
 
395
        }
 
396
 
 
397
        case SS_LIST_OF_FRAGMENTS: {
 
398
                const struct list_of_fragments *pt = (struct list_of_fragments*) p;
 
399
                CED_ListOfFragments(pt);
 
400
                break;
 
401
        }
 
402
 
 
403
        case SS_EXTENTION: {
 
404
                const struct edExtention *pt = (struct edExtention*) p;
 
405
                if (!(pt->Ecode & 0x8000))
 
406
                        CED_Extention(pt, (const char*) (p + sizeof(edExtention)));
 
407
                else {
 
408
                        const struct edExtentionNew *pt1 = (struct edExtentionNew*) p;
 
409
                        CED_ExtentionNew(pt1, (const char*) (p + sizeof(edExtentionNew)));
 
410
                }
 
411
                break;
 
412
        }
 
413
 
 
414
        case SS_AKSANT: {
 
415
                const struct aksant *pt = (struct aksant*) p;
 
416
                CED_Aksant(pt);
 
417
                break;
 
418
        }
 
419
 
 
420
        case SS_NEG_HALF_SPACE: {
 
421
                *(p + 1) &= 254;
 
422
                func_char(p, 2);
 
423
                break;
 
424
        }
 
425
 
 
426
        case SS_POS_HALF_SPACE:
 
427
                *(p + 1) &= 254;
 
428
                func_char(p, 2);
 
429
                break;
 
430
 
 
431
        default: {
 
432
                return FALSE;
 
433
        }
 
434
        }
 
435
        return TRUE;
489
436
}