~ubuntu-branches/debian/experimental/cuneiform/experimental

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rling/sources/c/udictini.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-10 17:58:10 UTC
  • Revision ID: james.westby@ubuntu.com-20090710175810-rqc89d2i3tki9m89
Tags: upstream-0.7.0+dfsg
Import upstream version 0.7.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
*/
 
56
 
 
57
/*
 
58
 
 
59
�����������������������������������������������������������������������������ͻ
 
60
�        This module is a set  user dictionary initialisation utilities       �
 
61
�����������������������������������������������������������������������������ͼ
 
62
*/
 
63
 #include "spelmode.h"
 
64
/////// #include <dos.h>
 
65
#if defined (WATCOM)
 
66
  #include "spelwatc.h"
 
67
#elif defined (BC_FOR_WIN)
 
68
  #include "bcwtypes.h"
 
69
  typedef long signed int LONG;
 
70
#elif defined(TURBO_C)
 
71
 #include "tc_types.h"
 
72
#else
 
73
 #error No tool specified
 
74
#endif
 
75
 
 
76
 #include "speldefs.h"
 
77
 #include "spelfunc.h"
 
78
 #include "udicfunc.h"
 
79
 
 
80
 #include "tigeremulate.h"
 
81
 
 
82
#include "compat_defs.h"
 
83
 
 
84
DWORD        LoadUserDict( CHAR      *DictName,
 
85
                           CHAR      *pool,
 
86
                                       DWORD     pool_size,
 
87
                                       voc_state *user_dict)
 
88
 {
 
89
   LONG      size;
 
90
   pool_size = pool_size;
 
91
   if (_IsUserDict(DictName)!= UD_PERMITTED)     return 0;
 
92
 
 
93
#ifdef TURBO_C
 
94
 if(TEST_PRPH(pool))
 
95
    pool=ALI_PR(pool);
 
96
#endif
 
97
 
 
98
  user_dict -> vocseg = (BYTE *)SET_VOC_ROOT(pool);
 
99
 
 
100
  {
 
101
    INT Fh;
 
102
    CHAR nm[128];
 
103
    strcpy (nm, DictName);
 
104
    Fh = TGOPEN (VC_STREAM, nm, (INT)(O_RDONLY | O_BINARY), S_IREAD);
 
105
    if (Fh == -1)
 
106
        return 0;
 
107
    if (TGFILELTH(Fh) > MAX_VOC_SIZE)
 
108
    {
 
109
      TGCLOSE(Fh);
 
110
      return   0;
 
111
    }
 
112
    size = TGREAD(Fh, V_POINT(user_dict -> vocseg,0), TGFILELTH(Fh));
 
113
    TGCLOSE (Fh);
 
114
   }
 
115
  if ( size <=0)                      return 0;
 
116
   else
 
117
      { voc_open(user_dict);
 
118
        user_dict -> vocfree = (WORD)size;
 
119
      }
 
120
  return MAX_VOC_SIZE;
 
121
  }
 
122
 
 
123
DWORD InitializeNewUserDict ( CHAR *pool, DWORD pool_size, voc_state *user_dict)
 
124
{
 
125
#ifdef TURBO_C
 
126
 if(TEST_PRPH(pool))
 
127
    pool=ALI_PR(pool);
 
128
#endif
 
129
 
 
130
  if ( pool_size < MAX_VOC_SIZE)                   return 0;
 
131
 
 
132
  user_dict -> vocseg = SET_VOC_ROOT(pool);
 
133
  voc_init(user_dict);
 
134
 
 
135
  return MAX_VOC_SIZE;
 
136
}
 
137
 
 
138
 void ResetUserDict(voc_state * user_dict)
 
139
 {
 
140
  user_dict ->lev = -1;
 
141
 }
 
142
//////////////////////////////////////////////////////////////////////////////////////////////////////
 
143
//
 
144
 BOOL CloseUserDictionary (BYTE * DictName, voc_state *user_dict)
 
145
{
 
146
        if ( user_dict -> state & VOC_CHANGED)
 
147
        {
 
148
                char w[80];
 
149
                LONG size;
 
150
                INT h;
 
151
 
 
152
                strcpy (w,DictName);
 
153
                h = TGOPEN (VC_STREAM,w,O_CREAT, S_IREAD);
 
154
 
 
155
                if ( h == -1)
 
156
                {
 
157
                        /* MsgBox("failed to open"); */
 
158
                        return FALSE;
 
159
                }
 
160
 
 
161
                size = TGWRITE (h,V_POINT(user_dict ->vocseg,0), user_dict ->vocfree  );
 
162
                TGCLOSE(h);
 
163
 
 
164
                if ( size != (LONG)user_dict->vocfree )
 
165
                {
 
166
                        /* MsgBox("wrong size"); */
 
167
                        return  FALSE;
 
168
                }
 
169
 
 
170
                user_dict -> state &= (~VOC_CHANGED);
 
171
        }
 
172
        return     TRUE;
 
173
}