13 { "help", false, NULL, 'h' }, |
13 { "help", false, NULL, 'h' }, |
14 { "quiet", false, NULL, 'q' }, |
14 { "quiet", false, NULL, 'q' }, |
15 { "verbose", false, NULL, 'v' }, |
15 { "verbose", false, NULL, 'v' }, |
16 { "debug", false, NULL, 'D' }, |
16 { "debug", false, NULL, 'D' }, |
17 { "force-update", false, NULL, 'U' }, |
17 { "force-update", false, NULL, 'U' }, |
|
18 { "background", true, NULL, 'B' }, |
18 { "width", true, NULL, 'W' }, |
19 { "width", true, NULL, 'W' }, |
19 { "height", true, NULL, 'H' }, |
20 { "height", true, NULL, 'H' }, |
20 { "x", true, NULL, 'x' }, |
21 { "x", true, NULL, 'x' }, |
21 { "y", true, NULL, 'y' }, |
22 { "y", true, NULL, 'y' }, |
22 { "zoom", true, NULL, 'z' }, |
23 { "zoom", true, NULL, 'z' }, |
36 "\t-h, --help show this help and exit\n" |
37 "\t-h, --help show this help and exit\n" |
37 "\t-q, --quiet supress informational output\n" |
38 "\t-q, --quiet supress informational output\n" |
38 "\t-v, --verbose display more informational output\n" |
39 "\t-v, --verbose display more informational output\n" |
39 "\t-D, --debug equivalent to -v\n" |
40 "\t-D, --debug equivalent to -v\n" |
40 "\t-U, --force-update unconditionally update image caches\n" |
41 "\t-U, --force-update unconditionally update image caches\n" |
|
42 "\t-B, --background set background pattern for cache update\n" |
41 "\t-W, --width set tile width\n" |
43 "\t-W, --width set tile width\n" |
42 "\t-H, --height set tile height\n" |
44 "\t-H, --height set tile height\n" |
43 "\t-x, --x set tile x offset\n" |
45 "\t-x, --x set tile x offset\n" |
44 "\t-y, --y set tile z offset\n" |
46 "\t-y, --y set tile z offset\n" |
45 "\t-z, --zoom set zoom factor (<0)\n" |
47 "\t-z, --zoom set zoom factor (<0)\n" |
50 int main (int argc, char **argv) |
52 int main (int argc, char **argv) |
51 { |
53 { |
52 int opt; |
54 int opt; |
53 bool force_update = false; |
55 bool force_update = false; |
54 struct pt_tile_info ti = {0, 0, 0, 0, 0}; |
56 struct pt_tile_info ti = {0, 0, 0, 0, 0}; |
|
57 struct pt_image_params update_params = { }; |
55 int threads = 2; |
58 int threads = 2; |
56 int tmp, err; |
59 int tmp, err; |
57 |
60 |
58 // parse arguments |
61 // parse arguments |
59 while ((opt = getopt_long(argc, argv, "hqvDUW:H:x:y:z:j:", options, NULL)) != -1) { |
62 while ((opt = getopt_long(argc, argv, "hqvDUB:W:H:x:y:z:j:", options, NULL)) != -1) { |
60 switch (opt) { |
63 switch (opt) { |
61 case 'h': |
64 case 'h': |
62 // display help |
65 // display help |
63 help(argv[0]); |
66 help(argv[0]); |
64 |
67 |
81 // force update of image caches |
84 // force update of image caches |
82 force_update = true; |
85 force_update = true; |
83 |
86 |
84 break; |
87 break; |
85 |
88 |
|
89 case 'B': |
|
90 // background pattern |
|
91 { |
|
92 unsigned int b1, b2, b3, b4; |
|
93 |
|
94 // parse 0xXXXXXXXX |
|
95 if (sscanf(optarg, "0x%02x%02x%02x%02x", &b1, &b2, &b3, &b4) != 4) |
|
96 FATAL("Invalid hex value for -B/--background: %s", optarg); |
|
97 |
|
98 // store |
|
99 update_params.background_color[0] = b1; |
|
100 update_params.background_color[1] = b2; |
|
101 update_params.background_color[2] = b3; |
|
102 update_params.background_color[3] = b4; |
|
103 |
|
104 } break; |
|
105 |
86 case 'W': |
106 case 'W': |
87 ti.width = strtol(optarg, NULL, 0); break; |
107 ti.width = strtol(optarg, NULL, 0); break; |
88 |
108 |
89 case 'H': |
109 case 'H': |
90 ti.height = strtol(optarg, NULL, 0); break; |
110 ti.height = strtol(optarg, NULL, 0); break; |
166 else if (status == PT_CACHE_FRESH) |
186 else if (status == PT_CACHE_FRESH) |
167 log_debug("\tImage cache is fresh"); |
187 log_debug("\tImage cache is fresh"); |
168 |
188 |
169 log_debug("\tUpdating image cache..."); |
189 log_debug("\tUpdating image cache..."); |
170 |
190 |
171 if ((err = pt_image_update(image))) { |
191 if ((err = pt_image_update(image, &update_params))) { |
172 log_warn_errno("pt_image_update: %s: %s", img_path, pt_strerror(err)); |
192 log_warn_errno("pt_image_update: %s: %s", img_path, pt_strerror(err)); |
173 } |
193 } |
174 |
194 |
175 log_info("\tUpdated image cache"); |
195 log_info("\tUpdated image cache"); |
176 |
196 |