blob: 1509923437a6542056febaa1520264765c93d1cf [file] [log] [blame]
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +00001/* vi: set sw=4 ts=4: */
2/*
Bernhard Reutner-Fischerdd76b792009-01-27 12:56:33 +00003 * Copyright (C) 2008 Michele Sanges <michele.sanges@gmail.com>
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +00004 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02005 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +00006 *
7 * Usage:
8 * - use kernel option 'vga=xxx' or otherwise enable framebuffer device.
Denis Vlasenko25a9c172008-03-26 15:12:11 +00009 * - put somewhere fbsplash.cfg file and an image in .ppm format.
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000010 * - run applet: $ setsid fbsplash [params] &
Denis Vlasenko1f228982008-04-22 00:16:29 +000011 * -c: hide cursor
12 * -d /dev/fbN: framebuffer device (if not /dev/fb0)
13 * -s path_to_image_file (can be "-" for stdin)
14 * -i path_to_cfg_file
15 * -f path_to_fifo (can be "-" for stdin)
Denis Vlasenko25a9c172008-03-26 15:12:11 +000016 * - if you want to run it only in presence of a kernel parameter
17 * (for example fbsplash=on), use:
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000018 * grep -q "fbsplash=on" </proc/cmdline && setsid fbsplash [params]
19 * - commands for fifo:
20 * "NN" (ASCII decimal number) - percentage to show on progress bar.
21 * "exit" (or just close fifo) - well you guessed it.
22 */
23
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000024#include "libbb.h"
25#include <linux/fb.h>
26
Denis Vlasenko25a9c172008-03-26 15:12:11 +000027/* If you want logging messages on /tmp/fbsplash.log... */
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000028#define DEBUG 0
29
30#define BYTES_PER_PIXEL 2
31
32typedef unsigned short DATA;
33
34struct globals {
35#if DEBUG
36 bool bdebug_messages; // enable/disable logging
37 FILE *logfile_fd; // log file
38#endif
39 unsigned char *addr; // pointer to framebuffer memory
Denis Vlasenko0f99d492008-07-24 23:38:04 +000040 unsigned ns[7]; // n-parameters
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000041 const char *image_filename;
42 struct fb_var_screeninfo scr_var;
43 struct fb_fix_screeninfo scr_fix;
44};
45#define G (*ptr_to_globals)
Denis Vlasenko7049ff82008-06-25 09:53:17 +000046#define INIT_G() do { \
47 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
48} while (0)
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000049
Denis Vlasenko0f99d492008-07-24 23:38:04 +000050#define nbar_width ns[0] // progress bar width
51#define nbar_height ns[1] // progress bar height
52#define nbar_posx ns[2] // progress bar horizontal position
53#define nbar_posy ns[3] // progress bar vertical position
54#define nbar_colr ns[4] // progress bar color red component
55#define nbar_colg ns[5] // progress bar color green component
56#define nbar_colb ns[6] // progress bar color blue component
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000057
58#if DEBUG
59#define DEBUG_MESSAGE(strMessage, args...) \
60 if (G.bdebug_messages) { \
61 fprintf(G.logfile_fd, "[%s][%s] - %s\n", \
62 __FILE__, __FUNCTION__, strMessage); \
63 }
64#else
65#define DEBUG_MESSAGE(...) ((void)0)
66#endif
67
68
69/**
70 * Open and initialize the framebuffer device
71 * \param *strfb_device pointer to framebuffer device
72 */
73static void fb_open(const char *strfb_device)
74{
75 int fbfd = xopen(strfb_device, O_RDWR);
76
77 // framebuffer properties
78 xioctl(fbfd, FBIOGET_VSCREENINFO, &G.scr_var);
79 xioctl(fbfd, FBIOGET_FSCREENINFO, &G.scr_fix);
80
81 if (G.scr_var.bits_per_pixel != 16)
82 bb_error_msg_and_die("only 16 bpp is supported");
83
84 // map the device in memory
85 G.addr = mmap(NULL,
Dan Fandrich07078c22011-01-26 11:30:34 -080086 G.scr_var.xres * G.scr_var.yres_virtual
Denys Vlasenko814da222010-03-14 23:59:54 +010087 * BYTES_PER_PIXEL /*(G.scr_var.bits_per_pixel / 8)*/,
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000088 PROT_WRITE, MAP_SHARED, fbfd, 0);
89 if (G.addr == MAP_FAILED)
Bernhard Reutner-Fischer4efcec92009-02-14 12:36:16 +000090 bb_perror_msg_and_die("mmap");
Dan Fandrich07078c22011-01-26 11:30:34 -080091
92 // point to the start of the visible screen
93 G.addr += G.scr_var.yoffset * G.scr_fix.line_length + G.scr_var.xoffset * BYTES_PER_PIXEL;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +000094 close(fbfd);
95}
96
97
98/**
99 * Draw hollow rectangle on framebuffer
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000100 */
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000101static void fb_drawrectangle(void)
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000102{
103 int cnt;
104 DATA thispix;
105 DATA *ptr1, *ptr2;
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000106 unsigned char nred = G.nbar_colr/2;
107 unsigned char ngreen = G.nbar_colg/2;
108 unsigned char nblue = G.nbar_colb/2;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000109
110 nred >>= 3; // 5-bit red
111 ngreen >>= 2; // 6-bit green
112 nblue >>= 3; // 5-bit blue
113 thispix = nblue + (ngreen << 5) + (nred << (5+6));
114
115 // horizontal lines
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000116 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
117 ptr2 = (DATA*)(G.addr + ((G.nbar_posy + G.nbar_height - 1) * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
118 cnt = G.nbar_width - 1;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000119 do {
120 *ptr1++ = thispix;
121 *ptr2++ = thispix;
122 } while (--cnt >= 0);
123
124 // vertical lines
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000125 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
126 ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL);
Denys Vlasenko814da222010-03-14 23:59:54 +0100127 cnt = G.nbar_height - 1;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000128 do {
129 *ptr1 = thispix; ptr1 += G.scr_var.xres;
130 *ptr2 = thispix; ptr2 += G.scr_var.xres;
131 } while (--cnt >= 0);
132}
133
134
135/**
136 * Draw filled rectangle on framebuffer
137 * \param nx1pos,ny1pos upper left position
138 * \param nx2pos,ny2pos down right position
Denis Vlasenko11b9f262008-03-26 20:06:24 +0000139 * \param nred,ngreen,nblue rgb color
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000140 */
141static void fb_drawfullrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos,
142 unsigned char nred, unsigned char ngreen, unsigned char nblue)
143{
144 int cnt1, cnt2, nypos;
145 DATA thispix;
146 DATA *ptr;
147
148 nred >>= 3; // 5-bit red
149 ngreen >>= 2; // 6-bit green
150 nblue >>= 3; // 5-bit blue
151 thispix = nblue + (ngreen << 5) + (nred << (5+6));
Denis Vlasenko1f228982008-04-22 00:16:29 +0000152
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000153 cnt1 = ny2pos - ny1pos;
154 nypos = ny1pos;
155 do {
156 ptr = (DATA*)(G.addr + (nypos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL);
157 cnt2 = nx2pos - nx1pos;
158 do {
159 *ptr++ = thispix;
160 } while (--cnt2 >= 0);
Denis Vlasenko1f228982008-04-22 00:16:29 +0000161
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000162 nypos++;
163 } while (--cnt1 >= 0);
164}
165
166
167/**
168 * Draw a progress bar on framebuffer
Denis Vlasenko11b9f262008-03-26 20:06:24 +0000169 * \param percent percentage of loading
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000170 */
Denis Vlasenko11b9f262008-03-26 20:06:24 +0000171static void fb_drawprogressbar(unsigned percent)
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000172{
173 int i, left_x, top_y, width, height;
Denis Vlasenko11b9f262008-03-26 20:06:24 +0000174
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000175 // outer box
176 left_x = G.nbar_posx;
177 top_y = G.nbar_posy;
178 width = G.nbar_width - 1;
179 height = G.nbar_height - 1;
180 if ((height | width) < 0)
181 return;
182 // NB: "width" of 1 actually makes rect with width of 2!
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000183 fb_drawrectangle();
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000184
185 // inner "empty" rectangle
186 left_x++;
187 top_y++;
188 width -= 2;
189 height -= 2;
190 if ((height | width) < 0)
191 return;
192 fb_drawfullrectangle(
193 left_x, top_y,
194 left_x + width, top_y + height,
195 G.nbar_colr, G.nbar_colg, G.nbar_colb);
196
Denis Vlasenko11b9f262008-03-26 20:06:24 +0000197 if (percent > 0) {
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000198 // actual progress bar
Denis Vlasenko11b9f262008-03-26 20:06:24 +0000199 width = width * percent / 100;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000200 i = height;
201 if (height == 0)
202 height++; // divide by 0 is bad
203 while (i >= 0) {
204 // draw one-line thick "rectangle"
205 // top line will have gray lvl 200, bottom one 100
206 unsigned gray_level = 100 + i*100/height;
207 fb_drawfullrectangle(
208 left_x, top_y, left_x + width, top_y,
209 gray_level, gray_level, gray_level);
210 top_y++;
211 i--;
212 }
213 }
214}
215
216
217/**
218 * Draw image from PPM file
219 */
220static void fb_drawimage(void)
221{
Bernhard Reutner-Fischer051fdb92009-02-16 12:36:50 +0000222 FILE *theme_file;
Denys Vlasenko814da222010-03-14 23:59:54 +0100223 char *read_ptr;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000224 unsigned char *pixline;
225 unsigned i, j, width, height, line_size;
226
Denys Vlasenko814da222010-03-14 23:59:54 +0100227 if (LONE_DASH(G.image_filename)) {
Vladimir Dronnikov6eaac022009-11-07 04:14:50 +0100228 theme_file = stdin;
Denys Vlasenko814da222010-03-14 23:59:54 +0100229 } else {
Vladimir Dronnikov6eaac022009-11-07 04:14:50 +0100230 int fd = open_zipped(G.image_filename);
231 if (fd < 0)
232 bb_simple_perror_msg_and_die(G.image_filename);
Denys Vlasenkoa7ccdee2009-11-15 23:28:11 +0100233 theme_file = xfdopen_for_read(fd);
Vladimir Dronnikov6eaac022009-11-07 04:14:50 +0100234 }
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000235
Denys Vlasenko814da222010-03-14 23:59:54 +0100236 /* Parse ppm header:
237 * - Magic: two characters "P6".
Bernhard Reutner-Fischer8dcb33c2009-02-18 15:13:05 +0000238 * - Whitespace (blanks, TABs, CRs, LFs).
239 * - A width, formatted as ASCII characters in decimal.
240 * - Whitespace.
Denys Vlasenko814da222010-03-14 23:59:54 +0100241 * - A height, ASCII decimal.
Bernhard Reutner-Fischer8dcb33c2009-02-18 15:13:05 +0000242 * - Whitespace.
Denys Vlasenko814da222010-03-14 23:59:54 +0100243 * - The maximum color value, ASCII decimal, in 0..65535
Bernhard Reutner-Fischer8dcb33c2009-02-18 15:13:05 +0000244 * - Newline or other single whitespace character.
Denys Vlasenko814da222010-03-14 23:59:54 +0100245 * (we support newline only)
Bernhard Reutner-Fischer8dcb33c2009-02-18 15:13:05 +0000246 * - A raster of Width * Height pixels in triplets of rgb
Denys Vlasenko814da222010-03-14 23:59:54 +0100247 * in pure binary by 1 or 2 bytes. (we support only 1 byte)
Bernhard Reutner-Fischer8dcb33c2009-02-18 15:13:05 +0000248 */
Denys Vlasenko814da222010-03-14 23:59:54 +0100249#define concat_buf bb_common_bufsiz1
250 read_ptr = concat_buf;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000251 while (1) {
Denys Vlasenko814da222010-03-14 23:59:54 +0100252 int w, h, max_color_val;
253 int rem = concat_buf + sizeof(concat_buf) - read_ptr;
254 if (rem < 2
255 || fgets(read_ptr, rem, theme_file) == NULL
256 ) {
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000257 bb_error_msg_and_die("bad PPM file '%s'", G.image_filename);
Denys Vlasenko814da222010-03-14 23:59:54 +0100258 }
259 read_ptr = strchrnul(read_ptr, '#');
260 *read_ptr = '\0'; /* ignore #comments */
261 if (sscanf(concat_buf, "P6 %u %u %u", &w, &h, &max_color_val) == 3
262 && max_color_val <= 255
263 ) {
264 width = w; /* w is on stack, width may be in register */
265 height = h;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000266 break;
Denys Vlasenko814da222010-03-14 23:59:54 +0100267 }
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000268 }
269
270 line_size = width*3;
Denys Vlasenko814da222010-03-14 23:59:54 +0100271 pixline = xmalloc(line_size);
272
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000273 if (width > G.scr_var.xres)
274 width = G.scr_var.xres;
275 if (height > G.scr_var.yres)
276 height = G.scr_var.yres;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000277 for (j = 0; j < height; j++) {
Denys Vlasenko814da222010-03-14 23:59:54 +0100278 unsigned char *pixel;
279 DATA *src;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000280
Bernhard Reutner-Fischer051fdb92009-02-16 12:36:50 +0000281 if (fread(pixline, 1, line_size, theme_file) != line_size)
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000282 bb_error_msg_and_die("bad PPM file '%s'", G.image_filename);
Denys Vlasenko814da222010-03-14 23:59:54 +0100283 pixel = pixline;
284 src = (DATA *)(G.addr + j * G.scr_fix.line_length);
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000285 for (i = 0; i < width; i++) {
286 unsigned thispix;
287 thispix = (((unsigned)pixel[0] << 8) & 0xf800)
288 | (((unsigned)pixel[1] << 3) & 0x07e0)
289 | (((unsigned)pixel[2] >> 3));
290 *src++ = thispix;
291 pixel += 3;
292 }
293 }
Denys Vlasenko814da222010-03-14 23:59:54 +0100294 free(pixline);
Bernhard Reutner-Fischer051fdb92009-02-16 12:36:50 +0000295 fclose(theme_file);
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000296}
297
298
299/**
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000300 * Parse configuration file
301 * \param *cfg_filename name of the configuration file
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000302 */
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000303static void init(const char *cfg_filename)
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000304{
Denys Vlasenko10544a82010-02-09 00:26:10 +0100305 static const char param_names[] ALIGN1 =
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000306 "BAR_WIDTH\0" "BAR_HEIGHT\0"
Denis Vlasenko0f99d492008-07-24 23:38:04 +0000307 "BAR_LEFT\0" "BAR_TOP\0"
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000308 "BAR_R\0" "BAR_G\0" "BAR_B\0"
309#if DEBUG
310 "DEBUG\0"
311#endif
312 ;
Denis Vlasenko0f99d492008-07-24 23:38:04 +0000313 char *token[2];
314 parser_t *parser = config_open2(cfg_filename, xfopen_stdin);
Denis Vlasenko084266e2008-07-26 23:08:31 +0000315 while (config_read(parser, token, 2, 2, "#=",
Denys Vlasenko814da222010-03-14 23:59:54 +0100316 (PARSE_NORMAL | PARSE_MIN_DIE) & ~(PARSE_TRIM | PARSE_COLLAPSE))) {
Denys Vlasenko77832482010-08-12 14:14:45 +0200317 unsigned val = xatoi_positive(token[1]);
Denis Vlasenko0f99d492008-07-24 23:38:04 +0000318 int i = index_in_strings(param_names, token[0]);
319 if (i < 0)
Bernhard Reutner-Fischer4efcec92009-02-14 12:36:16 +0000320 bb_error_msg_and_die("syntax error: %s", token[0]);
Denis Vlasenko0f99d492008-07-24 23:38:04 +0000321 if (i >= 0 && i < 7)
322 G.ns[i] = val;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000323#if DEBUG
Denis Vlasenko0f99d492008-07-24 23:38:04 +0000324 if (i == 7) {
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000325 G.bdebug_messages = val;
326 if (G.bdebug_messages)
Denis Vlasenko5415c852008-07-21 23:05:26 +0000327 G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log");
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000328 }
Denis Vlasenko0f99d492008-07-24 23:38:04 +0000329#endif
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000330 }
Denis Vlasenko0f99d492008-07-24 23:38:04 +0000331 config_close(parser);
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000332}
333
334
335int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000336int fbsplash_main(int argc UNUSED_PARAM, char **argv)
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000337{
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000338 const char *fb_device, *cfg_filename, *fifo_filename;
Denis Vlasenko11b9f262008-03-26 20:06:24 +0000339 FILE *fp = fp; // for compiler
Denis Vlasenko7f8f0fa2008-04-04 20:38:49 +0000340 char *num_buf;
341 unsigned num;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000342 bool bCursorOff;
343
344 INIT_G();
345
346 // parse command line options
347 fb_device = "/dev/fb0";
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000348 cfg_filename = NULL;
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000349 fifo_filename = NULL;
350 bCursorOff = 1 & getopt32(argv, "cs:d:i:f:",
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000351 &G.image_filename, &fb_device, &cfg_filename, &fifo_filename);
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000352
353 // parse configuration file
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000354 if (cfg_filename)
355 init(cfg_filename);
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000356
357 // We must have -s IMG
358 if (!G.image_filename)
359 bb_show_usage();
360
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000361 fb_open(fb_device);
362
363 if (fifo_filename && bCursorOff) {
364 // hide cursor (BEFORE any fb ops)
Denys Vlasenkod9a3e892010-05-16 23:42:13 +0200365 full_write(STDOUT_FILENO, "\033[?25l", 6);
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000366 }
367
368 fb_drawimage();
369
Denis Vlasenkoa38ba592008-03-28 11:17:35 +0000370 if (!fifo_filename)
371 return EXIT_SUCCESS;
372
373 fp = xfopen_stdin(fifo_filename);
Denis Vlasenko7f8f0fa2008-04-04 20:38:49 +0000374 if (fp != stdin) {
Denis Vlasenko72b34422008-03-27 13:14:29 +0000375 // For named pipes, we want to support this:
376 // mkfifo cmd_pipe
377 // fbsplash -f cmd_pipe .... &
378 // ...
379 // echo 33 >cmd_pipe
380 // ...
381 // echo 66 >cmd_pipe
Denis Vlasenko7f8f0fa2008-04-04 20:38:49 +0000382 // This means that we don't want fbsplash to get EOF
383 // when last writer closes input end.
384 // The simplest way is to open fifo for writing too
385 // and become an additional writer :)
386 open(fifo_filename, O_WRONLY); // errors are ignored
387 }
388
389 fb_drawprogressbar(0);
390 // Block on read, waiting for some input.
391 // Use of <stdio.h> style I/O allows to correctly
392 // handle a case when we have many buffered lines
393 // already in the pipe
394 while ((num_buf = xmalloc_fgetline(fp)) != NULL) {
395 if (strncmp(num_buf, "exit", 4) == 0) {
396 DEBUG_MESSAGE("exit");
397 break;
398 }
399 num = atoi(num_buf);
400 if (isdigit(num_buf[0]) && (num <= 100)) {
401#if DEBUG
Denys Vlasenko7bb346f2009-10-06 22:09:50 +0200402 DEBUG_MESSAGE(itoa(num));
Denis Vlasenko7f8f0fa2008-04-04 20:38:49 +0000403#endif
404 fb_drawprogressbar(num);
405 }
406 free(num_buf);
407 }
408
409 if (bCursorOff) // restore cursor
Denys Vlasenkod9a3e892010-05-16 23:42:13 +0200410 full_write(STDOUT_FILENO, "\033[?25h", 6);
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000411
Denis Vlasenkoc6dbb852008-03-26 14:57:49 +0000412 return EXIT_SUCCESS;
413}