~ubuntu-branches/ubuntu/precise/cuneiform/precise

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/ctb/src/ctb_tool.c

  • 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:
2
2
Copyright (c) 1993-2008, Cognitive Technologies
3
3
All rights reserved.
4
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
 
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
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
32
 
33
33
Redistribution and use in source and binary forms, with or without modification,
34
34
are permitted provided that the following conditions are met:
75
75
//********************************************************************
76
76
//*************** static data : **************************************
77
77
//********************************************************************
78
 
static Word8 save_pack[256*128+3+CTB_DATA_SIZE]; // global bit map buffer
79
 
static Word8 zero_data[CTB_DATA_SIZE]={0};  // zero attributes              //
 
78
static uchar save_pack[256*128+3+CTB_DATA_SIZE]; // global bit map buffer
 
79
static uchar zero_data[CTB_DATA_SIZE]={0};  // zero attributes              //
80
80
static char *error_strings[]={
81
81
"Error free!",
82
82
"Can't open .CTB-file",
95
95
"Align Error",
96
96
"Can't saved to CTB with different version"
97
97
};
98
 
static Word32 mask_r[]={  255,    128,  192,  224,  240,  248,  252,  254, 255};
 
98
static uint32_t mask_r[]={  255,    128,  192,  224,  240,  248,  252,  254, 255};
99
99
//                        0      1      2    3      4    5     6     7     8
100
100
//********************************************************************
101
101
//********************* static function : ****************************
102
102
//********************************************************************
103
 
static Int32  CTB_volume_true(char *file_name );
104
 
static Bool32   CTB_type(Int16 wid, Int16 hei, Int16 dpb);
105
 
static void     xor_lines(Word8 *bin,Int32 wb,Int32 len);
106
 
static void     xor_lines_rest(Word8 *bin,Int32 wb,Int32 len,Word8 mask);
107
 
static void     xor_one_line(Word8 *bin,Word8 *bin1,Int32 wb);
 
103
static int32_t  CTB_volume_true(char *file_name );
 
104
static Bool32   CTB_type(int16_t wid, int16_t hei, int16_t dpb);
 
105
static void     xor_lines(uchar *bin,int32_t wb,int32_t len);
 
106
static void     xor_lines_rest(uchar *bin,int32_t wb,int32_t len,uchar mask);
 
107
static void     xor_one_line(uchar *bin,uchar *bin1,int32_t wb);
108
108
//********************************************************************
109
109
//************ global functions : ************************************
110
110
//********************************************************************
111
111
char *  ctb_last_punct(char *word);
112
 
Bool32  CTB_files_init(char *file_name,Word8 *data,Int16 maxX,Int16 maxY,
113
 
                    Int16 dpb,Word8 signums, Word8 attr_size);
 
112
Bool32  CTB_files_init(char *file_name,uchar *data,int16_t maxX,int16_t maxY,
 
113
                    int16_t dpb,uchar signums, uchar attr_size);
114
114
//********************************************************************
115
115
//************ global data : *****************************************
116
116
//********************************************************************
117
 
Int32   ctb_err_code = CTB_ERR_NONE;   // error code
 
117
int32_t   ctb_err_code = CTB_ERR_NONE;   // error code
118
118
char * ctb_tmp_dir=NULL;
119
119
CTB_FUNC(char) local_grey_ctb[256] = "page6666";
120
120
CTB_FUNC(char) local_ctb_name[256] = "ct666666";
121
121
//********************************************************************
122
122
//***********  EXPORT functions from CTB_pack ************************
123
123
//********************************************************************
124
 
Int16 decLine(Word8 *inB, Int16 inLen, Word8 *outBuffer);
125
 
Int16 encLine(Word8 *inBuff, Int16 inLen,Word8 *save_p, Int16 outLen);
126
 
Int16 encput( Word8 byt, Word8 cnt,Word8 *save);
 
124
int16_t decLine(uchar *inB, int16_t inLen, uchar *outBuffer);
 
125
int16_t encLine(uchar *inBuff, int16_t inLen,uchar *save_p, int16_t outLen);
 
126
int16_t encput( uchar byt, uchar cnt,uchar *save);
127
127
//********************************************************************
128
128
//***********  EXPORT functions from CTB_cnvm ************************
129
129
//********************************************************************
130
 
Bool32  conv_bytes_to_bits( Int16 colors, Word8 *text,Word8 *bin, Int16 len);
131
 
Bool32  conv_bits_to_bytes( Int16 colors, Word8 *text,Word8 *bin, Int16 len);
 
130
Bool32  conv_bytes_to_bits( int16_t colors, uchar *text,uchar *bin, int16_t len);
 
131
Bool32  conv_bits_to_bytes( int16_t colors, uchar *text,uchar *bin, int16_t len);
132
132
 
133
133
//********************************************************************
134
134
//**************** open/close CTB-files ******************************
173
173
}
174
174
#endif
175
175
 
176
 
CTB_FUNC(Int32) CTB_gettmpdirname(void) {
 
176
CTB_FUNC(int32_t) CTB_gettmpdirname(void) {
177
177
    char* tmp = get_tmp_pattern();
178
178
    ctb_tmp_dir = malloc(strlen(tmp) + 1);
179
179
    strncpy(ctb_tmp_dir, tmp, strlen(tmp) + 1);
180
 
    ctb_tmp_dir = mkdtemp(ctb_tmp_dir);
 
180
    ctb_tmp_dir = (char*)mkdtemp(ctb_tmp_dir);
181
181
    free_tmp_pattern(tmp);
182
182
    if(!ctb_tmp_dir)
183
183
        return 1;
185
185
        return 0;
186
186
}
187
187
 
188
 
CTB_FUNC(Int32) CTB_get_error(void)
 
188
CTB_FUNC(int32_t) CTB_get_error(void)
189
189
{
190
190
return ctb_err_code ;
191
191
}
237
237
        ctb_err_code = CTB_ERR_VERS;
238
238
        return 0;
239
239
        }
240
 
hnd->len=(Int32)(((long)HCTB.size_x*HCTB.size_y)/HCTB.dot_per_byte);
 
240
hnd->len=(int32_t)(((long)HCTB.size_x*HCTB.size_y)/HCTB.dot_per_byte);
241
241
                      // store attributes    //
242
242
hnd->num     = HCTB.volume>0 ? HCTB.volume : CTB_volume_true(file_name);
243
 
hnd->type           = (Int16)CTB_type(HCTB.size_x,HCTB.size_y,HCTB.dot_per_byte);
 
243
hnd->type           = (int16_t)CTB_type(HCTB.size_x,HCTB.size_y,HCTB.dot_per_byte);
244
244
hnd->width          = HCTB.size_x;
245
245
hnd->height         = HCTB.size_y;
246
246
hnd->colors         = 1<<(8/HCTB.dot_per_byte);
299
299
  else
300
300
    HCTB.need_compress &=(0xFF^0x02) ;
301
301
  if( HCTB.dot_per_byte<=0 )
302
 
    HCTB.dot_per_byte = (Word8)((long)hnd->len/((long)HCTB.size_x*HCTB.size_y)) ;
 
302
    HCTB.dot_per_byte = (uchar)((long)hnd->len/((long)HCTB.size_x*HCTB.size_y)) ;
303
303
  if( fseek(hnd->bas,0,SEEK_SET) )
304
304
    return ;
305
305
  if( hnd->attr=='w' )                         // if enable change CTB  //
319
319
return;
320
320
}
321
321
 
322
 
CTB_FUNC(Bool32)  CTB_files_test(char *filename,Int16 maxX, Int16 maxY, Int16 dpb)
 
322
CTB_FUNC(Bool32)  CTB_files_test(char *filename,int16_t maxX, int16_t maxY, int16_t dpb)
323
323
{
324
324
H_CTB_file H_CTB={{'C','T'},0,128,96,0,0,0,0,0,{0}},HCTB;
325
325
char s[MAXPATH],file_name[MAXPATH],*p;
365
365
}
366
366
 
367
367
// for LEM PRO 256x128x2 ONLY
368
 
CTB_FUNC(Bool32)  CTB_create(char *file_name,Word8 *data)
 
368
CTB_FUNC(Bool32)  CTB_create(char *file_name,uchar *data)
369
369
{
370
 
Word8   attr_size=32+2; // version 7
 
370
uchar   attr_size=32+2; // version 7
371
371
 
372
372
if(!ctb_tmp_dir) {
373
373
    if(CTB_gettmpdirname()){
381
381
return  CTB_files_init(file_name,data,256,128,8,CTB_NON_SIGNUMS,attr_size);
382
382
}
383
383
 
384
 
CTB_FUNC(Bool32)  CTB_create_gray(char *file_name,Word8 *data)
 
384
CTB_FUNC(Bool32)  CTB_create_gray(char *file_name,uchar *data)
385
385
{
386
 
Word8   attr_size=32+2; // version 7
 
386
uchar   attr_size=32+2; // version 7
387
387
if( data && data[0] )
388
388
    attr_size=data[0];
389
389
return  CTB_files_init(file_name,data,256,128,1,CTB_GRAY_SCALE,attr_size);
393
393
//********************************************************************
394
394
//**************** subroutines to read data from *********************
395
395
//********************************************************************
396
 
CTB_FUNC(Int32)  CTB_read( CTB_handle *hnd,Int32 num , Word8 *save_bin, Word8 *data)
 
396
CTB_FUNC(int32_t)  CTB_read( CTB_handle *hnd,int32_t num , uchar *save_bin, uchar *data)
397
397
{
398
398
FFILE   fp;
399
 
Int32   l_seek,f_seek,l, len, w,h, sign, wb, datalen;
 
399
int32_t   l_seek,f_seek,l, len, w,h, sign, wb, datalen;
400
400
Bool32  gray=(hnd->signums&CTB_GRAY_SCALE),
401
401
        plane=(hnd->signums&CTB_PLANE);
402
402
 
500
500
        return 0;
501
501
        }
502
502
 
503
 
wb =  gray ? (((Int32)w+7)/8)*8 : (((Int32)w+7)/8);
504
 
len = wb*(Int32)h;
 
503
wb =  gray ? (((int32_t)w+7)/8)*8 : (((int32_t)w+7)/8);
 
504
len = wb*(int32_t)h;
505
505
if( hnd->type==CTB_256_128_2 && (w>255 || h>127 || len>REC_MAX_RASTER_SIZE) )
506
506
    {
507
507
        ctb_err_code = CTB_ERR_READ;
515
515
                    memcpy(save_bin,&save_pack[datalen+1],len);
516
516
                    break;
517
517
            case        CTB_COMP_PCX:   // decode picture by PCX-compressing
518
 
                    decLine(&save_pack[datalen+1],(Int16)l_seek,save_bin);
 
518
                    decLine(&save_pack[datalen+1],(int16_t)l_seek,save_bin);
519
519
                    break;
520
520
            default:
521
521
                    ctb_err_code = CTB_ERR_UNKNOWN_PACK;
530
530
                    memcpy(save_bin,&save_pack[datalen],len);
531
531
                    break;
532
532
            case        CTB_COMP_PCX:   // decode picture by PCX-compressing
533
 
                    decLine(&save_pack[datalen],(Int16)l_seek,save_bin);
 
533
                    decLine(&save_pack[datalen],(int16_t)l_seek,save_bin);
534
534
                    break;
535
535
            default:
536
536
                    ctb_err_code = CTB_ERR_UNKNOWN_PACK;
538
538
            }
539
539
    }
540
540
{
541
 
Word8 mask=0;
 
541
uchar mask=0;
542
542
if( hnd->type==CTB_256_128_2   )
543
543
    {
544
 
    mask = (Word8)mask_r[w&7];
 
544
    mask = (uchar)mask_r[w&7];
545
545
    }
546
546
xor_lines_rest(save_bin,!plane?wb:wb/8,len,mask);
547
547
}
548
548
return sign;
549
549
}
550
550
 
551
 
CTB_FUNC(Int32)  CTB_volume(CTB_handle *hnd )
 
551
CTB_FUNC(int32_t)  CTB_volume(CTB_handle *hnd )
552
552
{
553
553
return hnd->num;
554
554
}
555
555
 
556
 
CTB_FUNC(Int32)  CTB_volume_all(char *filename )
 
556
CTB_FUNC(int32_t)  CTB_volume_all(char *filename )
557
557
{
558
558
struct stat sts;
559
559
char lin[MAXPATH],file_name[MAXPATH],*p;
566
566
if( STAT(lin,&sts)==-1 )
567
567
        return 0;
568
568
 
569
 
return (Int32)(sts.st_size/8);
 
569
return (int32_t)(sts.st_size/8);
570
570
}
571
571
 
572
572
 
573
573
 
574
 
CTB_FUNC(Bool32)  CTB_read_global_data(CTB_handle *hnd, Word8 *data)
 
574
CTB_FUNC(Bool32)  CTB_read_global_data(CTB_handle *hnd, uchar *data)
575
575
{
576
 
Int32   gdatalen;
 
576
int32_t   gdatalen;
577
577
ctb_err_code = CTB_ERR_NONE;
578
578
if( data==NULL )
579
579
        {
624
624
}
625
625
 
626
626
 
627
 
CTB_FUNC(Bool32)  CTB_read_data(CTB_handle *hnd, Int32 num, Word8 *data)
 
627
CTB_FUNC(Bool32)  CTB_read_data(CTB_handle *hnd, int32_t num, uchar *data)
628
628
{
629
 
Int32 f_seek, datalen;
 
629
int32_t f_seek, datalen;
630
630
FFILE fp;
631
631
 
632
632
ctb_err_code = CTB_ERR_NONE;
696
696
//********************************************************************
697
697
// ************** subroutines to write data to a file ***************** //
698
698
//********************************************************************
699
 
CTB_FUNC(Bool32)  CTB_write_mark( CTB_handle *hnd, Int32 num,Word8 *bin, Word8 *data , Bool32  mark)
 
699
CTB_FUNC(Bool32)  CTB_write_mark( CTB_handle *hnd, int32_t num,uchar *bin, uchar *data , Bool32  mark)
700
700
{
701
 
Int16   sp,n=(Int16)hnd->len;
 
701
int16_t   sp,n=(int16_t)hnd->len;
702
702
FFILE   fp;
703
 
Int32   pos, datalen, wb;
704
 
Int16   len;
705
 
Word8   w,h;
 
703
int32_t   pos, datalen, wb;
 
704
int16_t   len;
 
705
uchar   w,h;
706
706
Bool32  gray=(hnd->signums&CTB_GRAY_SCALE),
707
707
        plane=(hnd->signums&CTB_PLANE);
708
708
 
726
726
        return FALSE;
727
727
        }
728
728
 
729
 
wb =  gray ? (((Int32)w+7)/8)*8 : (((Int32)w+7)/8);
 
729
wb =  gray ? (((int32_t)w+7)/8)*8 : (((int32_t)w+7)/8);
730
730
 
731
 
n = len = (Int16)(wb*(Int32)h);
732
 
if( hnd->type==CTB_256_128_2 && (w>255 || h>127 || len>REC_MAX_RASTER_SIZE) )
 
731
n = len = (int16_t)(wb*(int32_t)h);
 
732
if( hnd->type==CTB_256_128_2 && (/*w>255 ||*/ h>127 || len>REC_MAX_RASTER_SIZE) )
733
733
    {
734
734
        ctb_err_code = CTB_ERR_WRITE;
735
735
        return FALSE;
838
838
return TRUE;
839
839
}
840
840
 
841
 
CTB_FUNC(Bool32)  CTB_write( CTB_handle *hnd, Int32 num,Word8 *bin, Word8 *data )
 
841
CTB_FUNC(Bool32)  CTB_write( CTB_handle *hnd, int32_t num,uchar *bin, uchar *data )
842
842
{
843
843
Bool32 ret = CTB_write_mark(hnd,num,bin,data,FALSE);
844
844
if( ret )
846
846
return ret;
847
847
}
848
848
 
849
 
CTB_FUNC(Bool32)  CTB_kill(CTB_handle *hnd, Int32 num)
 
849
CTB_FUNC(Bool32)  CTB_kill(CTB_handle *hnd, int32_t num)
850
850
{
851
851
long f_seek;
852
852
FFILE fp;
892
892
 
893
893
 
894
894
CTB_FUNC(Bool32)  CTB_swap(CTB_handle *hnd,
895
 
                                                   Int32 num1,Int32 num2)
 
895
                                                   int32_t num1,int32_t num2)
896
896
{
897
897
long f_seek1, l_seek1;
898
898
long f_seek2, l_seek2;
991
991
return TRUE;
992
992
}
993
993
 
994
 
CTB_FUNC(Bool32)  CTB_mark(CTB_handle *hnd, Int32 num)
 
994
CTB_FUNC(Bool32)  CTB_mark(CTB_handle *hnd, int32_t num)
995
995
{
996
996
long f_seek, l_seek;
997
997
FFILE fp;
1050
1050
}
1051
1051
 
1052
1052
// delete image num //
1053
 
CTB_FUNC(Bool32)  CTB_delete( CTB_handle *hnd,Int32 num )
 
1053
CTB_FUNC(Bool32)  CTB_delete( CTB_handle *hnd,int32_t num )
1054
1054
{
1055
 
Word8 buffer[8];
1056
 
Int16 i,n=hnd->num - 1;
 
1055
uchar buffer[8];
 
1056
int16_t i,n=hnd->num - 1;
1057
1057
 
1058
1058
ctb_err_code = CTB_ERR_NONE;
1059
1059
if( hnd==NULL )
1067
1067
        return FALSE;
1068
1068
    }
1069
1069
 
1070
 
for(i=(Int16)num;i<n;i++)
 
1070
for(i=(int16_t)num;i<n;i++)
1071
1071
        {
1072
1072
        if( fseek(hnd->ndx,(i+1)*8,SEEK_SET) )
1073
1073
        {
1096
1096
}
1097
1097
 
1098
1098
// insert kadr (bin,data) after (num-1) image, before num image //
1099
 
CTB_FUNC(Bool32)  CTB_insert( CTB_handle *hnd,Int32 num,Word8 *bin,     Word8 *data )
 
1099
CTB_FUNC(Bool32)  CTB_insert( CTB_handle *hnd,int32_t num,uchar *bin,     uchar *data )
1100
1100
{
1101
 
Word8 buffer[8];
1102
 
Int32 i,n=hnd->num - 1;
 
1101
uchar buffer[8];
 
1102
int32_t i,n=hnd->num - 1;
1103
1103
 
1104
1104
ctb_err_code = CTB_ERR_NONE;
1105
1105
if( hnd==NULL )
1143
1143
return TRUE;
1144
1144
}
1145
1145
 
1146
 
CTB_FUNC(Bool32)  CTB_write_data(CTB_handle *hnd, Int32 num, Word8 *data)
 
1146
CTB_FUNC(Bool32)  CTB_write_data(CTB_handle *hnd, int32_t num, uchar *data)
1147
1147
{
1148
 
Int32 f_seek, datalen;
 
1148
int32_t f_seek, datalen;
1149
1149
FFILE fp;
1150
1150
 
1151
1151
if( hnd->version<CTB_VERSION )
1213
1213
return TRUE;
1214
1214
}
1215
1215
 
1216
 
CTB_FUNC(Bool32)  CTB_write_global_data(CTB_handle *hnd,Word8 *data)
 
1216
CTB_FUNC(Bool32)  CTB_write_global_data(CTB_handle *hnd,uchar *data)
1217
1217
{
1218
1218
FFILE fp;
1219
 
Int32 gdatalen;
 
1219
int32_t gdatalen;
1220
1220
 
1221
1221
ctb_err_code = CTB_ERR_NONE;
1222
1222
if( data==NULL )
1263
1263
//********************************************************************
1264
1264
//***************** static functions : *******************************
1265
1265
//********************************************************************
1266
 
static void xor_lines(Word8 *bin,Int32 wb,Int32 len)
 
1266
static void xor_lines(uchar *bin,int32_t wb,int32_t len)
1267
1267
{
1268
1268
int i,ii,h=len/wb;
1269
1269
for(ii=(h-1)*wb,i=1;i<h;i++,ii-=wb)
1271
1271
return;
1272
1272
}
1273
1273
 
1274
 
static void xor_lines_rest(Word8 *bin,Int32 wb,Int32 len,Word8 mask)
 
1274
static void xor_lines_rest(uchar *bin,int32_t wb,int32_t len,uchar mask)
1275
1275
{
1276
1276
int i,ii,h=len/wb;
1277
1277
if( mask )
1293
1293
return;
1294
1294
}
1295
1295
 
1296
 
static Bool32  CTB_type(Int16 wid, Int16 hei, Int16 dpb)
 
1296
static Bool32  CTB_type(int16_t wid, int16_t hei, int16_t dpb)
1297
1297
{
1298
1298
if( wid==128 && hei==96 && dpb==8 )
1299
1299
  return CTB_128_96_2;
1331
1331
return CTB_UNKNOWN;
1332
1332
}
1333
1333
 
1334
 
static Int32 CTB_volume_true(char *filename )
 
1334
static int32_t CTB_volume_true(char *filename )
1335
1335
{
1336
1336
struct stat sts;
1337
1337
char lin[MAXPATH],file_name[MAXPATH],*p;
1338
 
Int32 i,n,k;
1339
 
Int32 fs,fl;
 
1338
int32_t i,n,k;
 
1339
int32_t fs,fl;
1340
1340
FFILE fp;
1341
1341
 
1342
1342
strcpy(file_name,filename);
1346
1346
if( STAT(lin,&sts)==-1 )
1347
1347
        return 0;
1348
1348
 
1349
 
n = (Int32)(sts.st_size/8);
 
1349
n = (int32_t)(sts.st_size/8);
1350
1350
 
1351
1351
fp=fopen(lin,R_B);
1352
1352
if( fp==BAD_FOPEN )
1361
1361
 
1362
1362
return k;
1363
1363
}
1364
 
static void xor_one_line(Word8 *bin,Word8 *bin1,Int32 wb)
 
1364
static void xor_one_line(uchar *bin,uchar *bin1,int32_t wb)
1365
1365
{
1366
1366
int i;
1367
1367
for(i=0;i<wb;i++)
1375
1375
char * ctb_last_punct(char *word)
1376
1376
{
1377
1377
char *p = word + STRLEN(word) - 1;
1378
 
Int16 i=0;
 
1378
int16_t i=0;
1379
1379
 
1380
1380
do{
1381
1381
  if( *p==':' || *p=='\\' )
1387
1387
return NULL;     // i==4                         //
1388
1388
}
1389
1389
 
1390
 
Bool32  CTB_files_init(char *filename,Word8 *data,Int16 maxX, Int16 maxY,
1391
 
      Int16 dpb, Word8 signums, Word8 attr_size)
 
1390
Bool32  CTB_files_init(char *filename,uchar *data,int16_t maxX, int16_t maxY,
 
1391
      int16_t dpb, uchar signums, uchar attr_size)
1392
1392
{
1393
1393
H_CTB_file H_CTB={{'C','T'},0,0,0,0,0,0,0,0,{0}}; // signatura only //
1394
1394
char s[MAXPATH],file_name[MAXPATH],*p;
1395
1395
FFILE fp;
1396
 
Int16 l;
 
1396
int16_t l;
1397
1397
 
1398
1398
strcpy(file_name,filename);
1399
1399
p=ctb_last_punct(file_name);
1410
1410
H_CTB.version      = CTB_VERSION; // version number
1411
1411
H_CTB.size_x       = maxX;        // frame width
1412
1412
H_CTB.size_y       = maxY;        // frame height
1413
 
H_CTB.dot_per_byte = (Word8)dpb;  // point inbyte
 
1413
H_CTB.dot_per_byte = (uchar)dpb;  // point inbyte
1414
1414
H_CTB.signums      = signums;     // characteristics
1415
1415
H_CTB.attr_size    = attr_size;   // number of attributes
1416
1416
l = sizeof(H_CTB)-CTB_DATA_SIZE;
1440
1440
return TRUE;
1441
1441
}
1442
1442
 
1443
 
CTB_FUNC(Int32)   CTB_GetVersion(void )
 
1443
CTB_FUNC(int32_t)   CTB_GetVersion(void )
1444
1444
{
1445
1445
return CTB_VERSION;
1446
1446
}