/
devprofile.c
120 lines (95 loc) · 3.3 KB
/
devprofile.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
** devprofile.c Handle device profiles.
**
** Copyright (C) 2013 http://willus.com
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**
*/
#include "k2pdfopt.h"
static DEVPROFILE devprof[7] =
{
{"Kindle 1-5","k2",560,735,167,0,1,{0,0,3,4}},
{"Kindle DX","dx",800,1180,167,0,1,{0,0,0,0}},
/* v2.02: Changed kpw to 658 x 889 based on e-mail feedback, 9-15-13 */
{"Kindle Paperwhite","kpw",658,889,212,0,1,{0,0,3,4}},
{"Nook Simple Touch","nookst",552,725,167,0,1,{0,0,0,0}},
{"Kobo Touch","kbt",600,730,167,0,1,{0,0,3,4}},
{"Kobo Glo","kbg",758,942,213,0,1,{0,0,3,4}},
{"","",0,0,167,0,1,{0,0,0,0}}
};
int devprofiles_count(void)
{
int i;
for (i=0;devprof[i].name[0]!='\0';i++);
return(i);
}
char *devprofile_alias(int index)
{
return(devprof[index].alias);
}
char *devprofile_name(int index)
{
return(devprof[index].name);
}
void devprofiles_echo(FILE *out)
{
int i;
fprintf(out,"\nAvailable devices:\n");
for (i=0;devprof[i].width>0;i++)
{
afprintf(out," %s%s%s",TTEXT_BOLD,devprof[i].name,TTEXT_NORMAL);
if (devprof[i].alias[0]!='\0')
afprintf(out," (alias %s%s%s)",TTEXT_BOLD,devprof[i].alias,TTEXT_NORMAL);
fprintf(out,": %d x %d, %d dpi\n",devprof[i].width,
devprof[i].height,devprof[i].dpi);
fprintf(out," Mark corners=%d, Padding (l,t,r,b)=%d,%d,%d,%d\n\n",
devprof[i].mark_corners,
devprof[i].padding[0],devprof[i].padding[1],
devprof[i].padding[2],devprof[i].padding[3]);
}
fprintf(out,"\n");
}
DEVPROFILE *devprofile_get(char *name)
{
int i,i0,c;
for (i0=i=c=0;devprof[i].width>0;i++)
if (in_string(devprof[i].name,name)>=0 || in_string(devprof[i].alias,name)>=0)
{
c++;
i0=i;
}
if (c==1)
return(&devprof[i0]);
return(NULL);
}
char *devprofile_select(void)
{
while (1)
{
int i,n,x;
static char *q="q";
k2printf("Select your e-reader type:\n");
for (i=0;devprof[i].name[0]!='\0';i++)
k2printf(" %s%2d%s. %s (%s)\n",TTEXT_BOLD,i+1,TTEXT_NORMAL,devprof[i].name,devprof[i].alias);
k2printf(" %s%2d%s. Other (specify width, height, etc.)\n\n",TTEXT_BOLD,i+1,TTEXT_NORMAL);
n=userinput_integer("Enter selection",1,&x,1,i+1);
if (n<0)
return(q);
if (x==i+1)
break;
return(devprof[x-1].alias);
}
return(NULL);
}