(patched) gocr-0.44
[swftools.git] / lib / gocr / job.c
1 /*
2 This is a Optical-Character-Recognition program
3 Copyright (C) 2000-2006  Joerg Schulenburg
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19  see README for email address */
20
21 #include "pgm2asc.h"
22 #include "gocr.h"
23
24 /* initialize job structure */
25 void job_init(job_t *job) {
26   /* init source */
27   job->src.fname = "-";
28   /* FIXME jb: init pix */  
29   job->src.p.p = NULL;
30
31   /* init results */
32   list_init( &job->res.boxlist );
33   list_init( &job->res.linelist ); 
34   job->res.avX = 5;
35   job->res.avY = 8; 
36   job->res.sumX = 0;
37   job->res.sumY = 0;
38   job->res.numC = 0;
39   job->res.lines.dy=0; 
40   job->res.lines.num=0;
41   
42   /* init temporaries */
43   list_init( &job->tmp.dblist ); 
44   job->tmp.n_run = 0;
45   /* FIXME jb: init ppo */
46   job->tmp.ppo.p = NULL; 
47   job->tmp.ppo.x = 0;
48   job->tmp.ppo.y = 0;
49
50   /* init cfg */
51   job->cfg.cs = 0;
52   job->cfg.spc = 0; 
53   job->cfg.mode = 0;
54   job->cfg.dust_size = -1; /* auto detect */
55   job->cfg.only_numbers = 0;
56   job->cfg.verbose = 0;
57   job->cfg.out_format = UTF8; /* old: ISO8859_1; */
58   job->cfg.lc = "_";
59   job->cfg.db_path = (char*)NULL;
60   job->cfg.cfilter = (char*)NULL;
61   job->cfg.certainty = 95;
62 }
63
64 /* free job structure */
65 void job_free(job_t *job) {
66
67   /* if tmp is just a copy of the pointer to the original image */
68   if (job->tmp.ppo.p==job->src.p.p) job->tmp.ppo.p=NULL;
69
70   /* FIMXE jb: free lists
71    * list_free( &job->res.linelist );
72    * list_free( &job->tmp.dblist );
73    */
74  
75   list_and_data_free(&(job->res.boxlist), (void (*)(void *))free_box);
76
77   /* FIXME jb: free pix */
78   if (job->src.p.p) { free(job->src.p.p); job->src.p.p=NULL; }
79
80   /* FIXME jb: free pix */
81   if (job->tmp.ppo.p) { free(job->tmp.ppo.p); job->tmp.ppo.p=NULL; }
82
83 }