replaced libart with new polygon code
[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 <stdlib.h>
22 #include <stdio.h>
23 #include <memory.h>
24 #include "pgm2asc.h"
25 #include "gocr.h"
26
27 /* initialize job structure */
28 void job_init(job_t *job) {
29   /* init source */
30   job->src.fname = "-";
31   /* FIXME jb: init pix */  
32   job->src.p.p = NULL;
33
34   /* init results */
35   list_init( &job->res.boxlist );
36   list_init( &job->res.linelist ); 
37   job->res.avX = 5;
38   job->res.avY = 8; 
39   job->res.sumX = 0;
40   job->res.sumY = 0;
41   job->res.numC = 0;
42   job->res.lines.dy=0; 
43   job->res.lines.num=0;
44   
45   /* init temporaries */
46   list_init( &job->tmp.dblist ); 
47   job->tmp.n_run = 0;
48   /* FIXME jb: init ppo */
49   job->tmp.ppo.p = NULL; 
50   job->tmp.ppo.x = 0;
51   job->tmp.ppo.y = 0;
52
53   /* init cfg */
54   job->cfg.cs = 0;
55   job->cfg.spc = 0; 
56   job->cfg.mode = 0;
57   job->cfg.dust_size = -1; /* auto detect */
58   job->cfg.only_numbers = 0;
59   job->cfg.verbose = 0;
60   job->cfg.out_format = UTF8; /* old: ISO8859_1; */
61   job->cfg.lc = "_";
62   job->cfg.db_path = (char*)NULL;
63   job->cfg.cfilter = (char*)NULL;
64   job->cfg.certainty = 95;
65 }
66
67 /* free job structure */
68 void job_free(job_t *job) {
69
70   /* if tmp is just a copy of the pointer to the original image */
71   if (job->tmp.ppo.p==job->src.p.p) job->tmp.ppo.p=NULL;
72
73   /* FIMXE jb: free lists
74    * list_free( &job->res.linelist );
75    * list_free( &job->tmp.dblist );
76    */
77  
78   list_and_data_free(&(job->res.boxlist), (void (*)(void *))free_box);
79
80   /* FIXME jb: free pix */
81   if (job->src.p.p) { free(job->src.p.p); job->src.p.p=NULL; }
82
83   /* FIXME jb: free pix */
84   if (job->tmp.ppo.p) { free(job->tmp.ppo.p); job->tmp.ppo.p=NULL; }
85
86 }