From 008c97e3652233186d83a5010f69741368ef98db Mon Sep 17 00:00:00 2001 From: Vladimir Chtchetkine Date: Fri, 8 Oct 2010 08:22:06 -0700 Subject: Cleanup warnings in the standalone UI build Change-Id: I2dc79f9d0b3916749366aa4155431420e05888c1 --- Makefile.android | 8 +- console-ui.c | 751 ------------------------------------------------------- vl-android-ui.c | 99 -------- 3 files changed, 3 insertions(+), 855 deletions(-) diff --git a/Makefile.android b/Makefile.android index 3020429..c057585 100644 --- a/Makefile.android +++ b/Makefile.android @@ -635,7 +635,7 @@ endif # misc. sources # -CORE_MISC_SOURCES = \ +CORE_MISC_SOURCES = vl-android.c \ console.c \ loader.c \ monitor.c \ @@ -851,7 +851,6 @@ VL_SOURCES := framebuffer.c \ android/cmdline-option.c \ android/config.c \ android/main.c \ - vl-android.c # Add common system libraries # @@ -1026,7 +1025,6 @@ LOCAL_LDLIBS += $(AUDIO_LDLIBS) # VL_SOURCES := framebuffer.c \ user-events-qemu.c \ - vl-android.c # Add common system libraries # @@ -1176,9 +1174,9 @@ VL_SOURCES := framebuffer.c \ android/config.c \ android/display.c \ android/main.c \ - console-ui.c \ qemu-timer-ui.c \ - vl-android-ui.c + vl-android-ui.c \ + console-ui.c \ # Add common system libraries # diff --git a/console-ui.c b/console-ui.c index 1afcaca..8fd7e7d 100644 --- a/console-ui.c +++ b/console-ui.c @@ -61,51 +61,6 @@ typedef struct QEMUFIFO { int count, wptr, rptr; } QEMUFIFO; -static int qemu_fifo_write(QEMUFIFO *f, const uint8_t *buf, int len1) -{ - int l, len; - - l = f->buf_size - f->count; - if (len1 > l) - len1 = l; - len = len1; - while (len > 0) { - l = f->buf_size - f->wptr; - if (l > len) - l = len; - memcpy(f->buf + f->wptr, buf, l); - f->wptr += l; - if (f->wptr >= f->buf_size) - f->wptr = 0; - buf += l; - len -= l; - } - f->count += len1; - return len1; -} - -static int qemu_fifo_read(QEMUFIFO *f, uint8_t *buf, int len1) -{ - int l, len; - - if (len1 > f->count) - len1 = f->count; - len = len1; - while (len > 0) { - l = f->buf_size - f->rptr; - if (l > len) - l = len; - memcpy(buf, f->buf + f->rptr, l); - f->rptr += l; - if (f->rptr >= f->buf_size) - f->rptr = 0; - buf += l; - len -= l; - } - f->count -= len1; - return len1; -} - typedef enum { GRAPHIC_CONSOLE, TEXT_CONSOLE, @@ -234,73 +189,6 @@ static unsigned int vga_get_color(DisplayState *ds, unsigned int rgba) return color; } -static void vga_fill_rect (DisplayState *ds, - int posx, int posy, int width, int height, uint32_t color) -{ - uint8_t *d, *d1; - int x, y, bpp; - - bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; - d1 = ds_get_data(ds) + - ds_get_linesize(ds) * posy + bpp * posx; - for (y = 0; y < height; y++) { - d = d1; - switch(bpp) { - case 1: - for (x = 0; x < width; x++) { - *((uint8_t *)d) = color; - d++; - } - break; - case 2: - for (x = 0; x < width; x++) { - *((uint16_t *)d) = color; - d += 2; - } - break; - case 4: - for (x = 0; x < width; x++) { - *((uint32_t *)d) = color; - d += 4; - } - break; - } - d1 += ds_get_linesize(ds); - } -} - -/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */ -static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w, int h) -{ - const uint8_t *s; - uint8_t *d; - int wb, y, bpp; - - bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; - wb = w * bpp; - if (yd <= ys) { - s = ds_get_data(ds) + - ds_get_linesize(ds) * ys + bpp * xs; - d = ds_get_data(ds) + - ds_get_linesize(ds) * yd + bpp * xd; - for (y = 0; y < h; y++) { - memmove(d, s, wb); - d += ds_get_linesize(ds); - s += ds_get_linesize(ds); - } - } else { - s = ds_get_data(ds) + - ds_get_linesize(ds) * (ys + h - 1) + bpp * xs; - d = ds_get_data(ds) + - ds_get_linesize(ds) * (yd + h - 1) + bpp * xd; - for (y = 0; y < h; y++) { - memmove(d, s, wb); - d -= ds_get_linesize(ds); - s -= ds_get_linesize(ds); - } - } -} - /***********************************************************/ /* basic char display */ @@ -434,634 +322,6 @@ static void console_print_text_attributes(TextAttributes *t_attrib, char ch) } #endif -static void vga_putcharxy(DisplayState *ds, int x, int y, int ch, - TextAttributes *t_attrib) -{ - uint8_t *d; - const uint8_t *font_ptr; - unsigned int font_data, linesize, xorcol, bpp; - int i; - unsigned int fgcol, bgcol; - -#ifdef DEBUG_CONSOLE - printf("x: %2i y: %2i", x, y); - console_print_text_attributes(t_attrib, ch); -#endif - - if (t_attrib->invers) { - bgcol = color_table[t_attrib->bold][t_attrib->fgcol]; - fgcol = color_table[t_attrib->bold][t_attrib->bgcol]; - } else { - fgcol = color_table[t_attrib->bold][t_attrib->fgcol]; - bgcol = color_table[t_attrib->bold][t_attrib->bgcol]; - } - - bpp = (ds_get_bits_per_pixel(ds) + 7) >> 3; - d = ds_get_data(ds) + - ds_get_linesize(ds) * y * FONT_HEIGHT + bpp * x * FONT_WIDTH; - linesize = ds_get_linesize(ds); - font_ptr = vgafont16 + FONT_HEIGHT * ch; - xorcol = bgcol ^ fgcol; - switch(ds_get_bits_per_pixel(ds)) { - case 8: - for(i = 0; i < FONT_HEIGHT; i++) { - font_data = *font_ptr++; - if (t_attrib->uline - && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; - } - ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; - ((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; - d += linesize; - } - break; - case 16: - case 15: - for(i = 0; i < FONT_HEIGHT; i++) { - font_data = *font_ptr++; - if (t_attrib->uline - && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; - } - ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol; - ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol; - ((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol; - ((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol; - d += linesize; - } - break; - case 32: - for(i = 0; i < FONT_HEIGHT; i++) { - font_data = *font_ptr++; - if (t_attrib->uline && ((i == FONT_HEIGHT - 2) || (i == FONT_HEIGHT - 3))) { - font_data = 0xFFFF; - } - ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol; - ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol; - ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol; - ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol; - ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol; - ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol; - ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol; - ((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol; - d += linesize; - } - break; - } -} - -static void text_console_resize(TextConsole *s) -{ - TextCell *cells, *c, *c1; - int w1, x, y, last_width; - - last_width = s->width; - s->width = s->g_width / FONT_WIDTH; - s->height = s->g_height / FONT_HEIGHT; - - w1 = last_width; - if (s->width < w1) - w1 = s->width; - - cells = qemu_malloc(s->width * s->total_height * sizeof(TextCell)); - for(y = 0; y < s->total_height; y++) { - c = &cells[y * s->width]; - if (w1 > 0) { - c1 = &s->cells[y * last_width]; - for(x = 0; x < w1; x++) { - *c++ = *c1++; - } - } - for(x = w1; x < s->width; x++) { - c->ch = ' '; - c->t_attrib = s->t_attrib_default; - c++; - } - } - qemu_free(s->cells); - s->cells = cells; -} - -static inline void text_update_xy(TextConsole *s, int x, int y) -{ - s->text_x[0] = MIN(s->text_x[0], x); - s->text_x[1] = MAX(s->text_x[1], x); - s->text_y[0] = MIN(s->text_y[0], y); - s->text_y[1] = MAX(s->text_y[1], y); -} - -static void invalidate_xy(TextConsole *s, int x, int y) -{ - if (s->update_x0 > x * FONT_WIDTH) - s->update_x0 = x * FONT_WIDTH; - if (s->update_y0 > y * FONT_HEIGHT) - s->update_y0 = y * FONT_HEIGHT; - if (s->update_x1 < (x + 1) * FONT_WIDTH) - s->update_x1 = (x + 1) * FONT_WIDTH; - if (s->update_y1 < (y + 1) * FONT_HEIGHT) - s->update_y1 = (y + 1) * FONT_HEIGHT; -} - -static void update_xy(TextConsole *s, int x, int y) -{ - TextCell *c; - int y1, y2; - - if (s == active_console) { - if (!ds_get_bits_per_pixel(s->ds)) { - text_update_xy(s, x, y); - return; - } - - y1 = (s->y_base + y) % s->total_height; - y2 = y1 - s->y_displayed; - if (y2 < 0) - y2 += s->total_height; - if (y2 < s->height) { - c = &s->cells[y1 * s->width + x]; - vga_putcharxy(s->ds, x, y2, c->ch, - &(c->t_attrib)); - invalidate_xy(s, x, y2); - } - } -} - -static void console_show_cursor(TextConsole *s, int show) -{ - TextCell *c; - int y, y1; - - if (s == active_console) { - int x = s->x; - - if (!ds_get_bits_per_pixel(s->ds)) { - s->cursor_invalidate = 1; - return; - } - - if (x >= s->width) { - x = s->width - 1; - } - y1 = (s->y_base + s->y) % s->total_height; - y = y1 - s->y_displayed; - if (y < 0) - y += s->total_height; - if (y < s->height) { - c = &s->cells[y1 * s->width + x]; - if (show) { - TextAttributes t_attrib = s->t_attrib_default; - t_attrib.invers = !(t_attrib.invers); /* invert fg and bg */ - vga_putcharxy(s->ds, x, y, c->ch, &t_attrib); - } else { - vga_putcharxy(s->ds, x, y, c->ch, &(c->t_attrib)); - } - invalidate_xy(s, x, y); - } - } -} - -static void console_refresh(TextConsole *s) -{ - TextCell *c; - int x, y, y1; - - if (s != active_console) - return; - if (!ds_get_bits_per_pixel(s->ds)) { - s->text_x[0] = 0; - s->text_y[0] = 0; - s->text_x[1] = s->width - 1; - s->text_y[1] = s->height - 1; - s->cursor_invalidate = 1; - return; - } - - vga_fill_rect(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds), - color_table[0][COLOR_BLACK]); - y1 = s->y_displayed; - for(y = 0; y < s->height; y++) { - c = s->cells + y1 * s->width; - for(x = 0; x < s->width; x++) { - vga_putcharxy(s->ds, x, y, c->ch, - &(c->t_attrib)); - c++; - } - if (++y1 == s->total_height) - y1 = 0; - } - console_show_cursor(s, 1); - dpy_update(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds)); -} - -static void console_scroll(int ydelta) -{ - TextConsole *s; - int i, y1; - - s = active_console; - if (!s || (s->console_type == GRAPHIC_CONSOLE)) - return; - - if (ydelta > 0) { - for(i = 0; i < ydelta; i++) { - if (s->y_displayed == s->y_base) - break; - if (++s->y_displayed == s->total_height) - s->y_displayed = 0; - } - } else { - ydelta = -ydelta; - i = s->backscroll_height; - if (i > s->total_height - s->height) - i = s->total_height - s->height; - y1 = s->y_base - i; - if (y1 < 0) - y1 += s->total_height; - for(i = 0; i < ydelta; i++) { - if (s->y_displayed == y1) - break; - if (--s->y_displayed < 0) - s->y_displayed = s->total_height - 1; - } - } - console_refresh(s); -} - -static void console_put_lf(TextConsole *s) -{ - TextCell *c; - int x, y1; - - s->y++; - if (s->y >= s->height) { - s->y = s->height - 1; - - if (s->y_displayed == s->y_base) { - if (++s->y_displayed == s->total_height) - s->y_displayed = 0; - } - if (++s->y_base == s->total_height) - s->y_base = 0; - if (s->backscroll_height < s->total_height) - s->backscroll_height++; - y1 = (s->y_base + s->height - 1) % s->total_height; - c = &s->cells[y1 * s->width]; - for(x = 0; x < s->width; x++) { - c->ch = ' '; - c->t_attrib = s->t_attrib_default; - c++; - } - if (s == active_console && s->y_displayed == s->y_base) { - if (!ds_get_bits_per_pixel(s->ds)) { - s->text_x[0] = 0; - s->text_y[0] = 0; - s->text_x[1] = s->width - 1; - s->text_y[1] = s->height - 1; - return; - } - - vga_bitblt(s->ds, 0, FONT_HEIGHT, 0, 0, - s->width * FONT_WIDTH, - (s->height - 1) * FONT_HEIGHT); - vga_fill_rect(s->ds, 0, (s->height - 1) * FONT_HEIGHT, - s->width * FONT_WIDTH, FONT_HEIGHT, - color_table[0][s->t_attrib_default.bgcol]); - s->update_x0 = 0; - s->update_y0 = 0; - s->update_x1 = s->width * FONT_WIDTH; - s->update_y1 = s->height * FONT_HEIGHT; - } - } -} - -/* Set console attributes depending on the current escape codes. - * NOTE: I know this code is not very efficient (checking every color for it - * self) but it is more readable and better maintainable. - */ -static void console_handle_escape(TextConsole *s) -{ - int i; - - for (i=0; inb_esc_params; i++) { - switch (s->esc_params[i]) { - case 0: /* reset all console attributes to default */ - s->t_attrib = s->t_attrib_default; - break; - case 1: - s->t_attrib.bold = 1; - break; - case 4: - s->t_attrib.uline = 1; - break; - case 5: - s->t_attrib.blink = 1; - break; - case 7: - s->t_attrib.invers = 1; - break; - case 8: - s->t_attrib.unvisible = 1; - break; - case 22: - s->t_attrib.bold = 0; - break; - case 24: - s->t_attrib.uline = 0; - break; - case 25: - s->t_attrib.blink = 0; - break; - case 27: - s->t_attrib.invers = 0; - break; - case 28: - s->t_attrib.unvisible = 0; - break; - /* set foreground color */ - case 30: - s->t_attrib.fgcol=COLOR_BLACK; - break; - case 31: - s->t_attrib.fgcol=COLOR_RED; - break; - case 32: - s->t_attrib.fgcol=COLOR_GREEN; - break; - case 33: - s->t_attrib.fgcol=COLOR_YELLOW; - break; - case 34: - s->t_attrib.fgcol=COLOR_BLUE; - break; - case 35: - s->t_attrib.fgcol=COLOR_MAGENTA; - break; - case 36: - s->t_attrib.fgcol=COLOR_CYAN; - break; - case 37: - s->t_attrib.fgcol=COLOR_WHITE; - break; - /* set background color */ - case 40: - s->t_attrib.bgcol=COLOR_BLACK; - break; - case 41: - s->t_attrib.bgcol=COLOR_RED; - break; - case 42: - s->t_attrib.bgcol=COLOR_GREEN; - break; - case 43: - s->t_attrib.bgcol=COLOR_YELLOW; - break; - case 44: - s->t_attrib.bgcol=COLOR_BLUE; - break; - case 45: - s->t_attrib.bgcol=COLOR_MAGENTA; - break; - case 46: - s->t_attrib.bgcol=COLOR_CYAN; - break; - case 47: - s->t_attrib.bgcol=COLOR_WHITE; - break; - } - } -} - -static void console_clear_xy(TextConsole *s, int x, int y) -{ - int y1 = (s->y_base + y) % s->total_height; - TextCell *c = &s->cells[y1 * s->width + x]; - c->ch = ' '; - c->t_attrib = s->t_attrib_default; - update_xy(s, x, y); -} - -static void console_putchar(TextConsole *s, int ch) -{ - TextCell *c; - int y1, i; - int x, y; - - switch(s->state) { - case TTY_STATE_NORM: - switch(ch) { - case '\r': /* carriage return */ - s->x = 0; - break; - case '\n': /* newline */ - console_put_lf(s); - break; - case '\b': /* backspace */ - if (s->x > 0) - s->x--; - break; - case '\t': /* tabspace */ - if (s->x + (8 - (s->x % 8)) > s->width) { - s->x = 0; - console_put_lf(s); - } else { - s->x = s->x + (8 - (s->x % 8)); - } - break; - case '\a': /* alert aka. bell */ - /* TODO: has to be implemented */ - break; - case 14: - /* SI (shift in), character set 0 (ignored) */ - break; - case 15: - /* SO (shift out), character set 1 (ignored) */ - break; - case 27: /* esc (introducing an escape sequence) */ - s->state = TTY_STATE_ESC; - break; - default: - if (s->x >= s->width) { - /* line wrap */ - s->x = 0; - console_put_lf(s); - } - y1 = (s->y_base + s->y) % s->total_height; - c = &s->cells[y1 * s->width + s->x]; - c->ch = ch; - c->t_attrib = s->t_attrib; - update_xy(s, s->x, s->y); - s->x++; - break; - } - break; - case TTY_STATE_ESC: /* check if it is a terminal escape sequence */ - if (ch == '[') { - for(i=0;iesc_params[i] = 0; - s->nb_esc_params = 0; - s->state = TTY_STATE_CSI; - } else { - s->state = TTY_STATE_NORM; - } - break; - case TTY_STATE_CSI: /* handle escape sequence parameters */ - if (ch >= '0' && ch <= '9') { - if (s->nb_esc_params < MAX_ESC_PARAMS) { - s->esc_params[s->nb_esc_params] = - s->esc_params[s->nb_esc_params] * 10 + ch - '0'; - } - } else { - s->nb_esc_params++; - if (ch == ';') - break; -#ifdef DEBUG_CONSOLE - fprintf(stderr, "escape sequence CSI%d;%d%c, %d parameters\n", - s->esc_params[0], s->esc_params[1], ch, s->nb_esc_params); -#endif - s->state = TTY_STATE_NORM; - switch(ch) { - case 'A': - /* move cursor up */ - if (s->esc_params[0] == 0) { - s->esc_params[0] = 1; - } - s->y -= s->esc_params[0]; - if (s->y < 0) { - s->y = 0; - } - break; - case 'B': - /* move cursor down */ - if (s->esc_params[0] == 0) { - s->esc_params[0] = 1; - } - s->y += s->esc_params[0]; - if (s->y >= s->height) { - s->y = s->height - 1; - } - break; - case 'C': - /* move cursor right */ - if (s->esc_params[0] == 0) { - s->esc_params[0] = 1; - } - s->x += s->esc_params[0]; - if (s->x >= s->width) { - s->x = s->width - 1; - } - break; - case 'D': - /* move cursor left */ - if (s->esc_params[0] == 0) { - s->esc_params[0] = 1; - } - s->x -= s->esc_params[0]; - if (s->x < 0) { - s->x = 0; - } - break; - case 'G': - /* move cursor to column */ - s->x = s->esc_params[0] - 1; - if (s->x < 0) { - s->x = 0; - } - break; - case 'f': - case 'H': - /* move cursor to row, column */ - s->x = s->esc_params[1] - 1; - if (s->x < 0) { - s->x = 0; - } - s->y = s->esc_params[0] - 1; - if (s->y < 0) { - s->y = 0; - } - break; - case 'J': - switch (s->esc_params[0]) { - case 0: - /* clear to end of screen */ - for (y = s->y; y < s->height; y++) { - for (x = 0; x < s->width; x++) { - if (y == s->y && x < s->x) { - continue; - } - console_clear_xy(s, x, y); - } - } - break; - case 1: - /* clear from beginning of screen */ - for (y = 0; y <= s->y; y++) { - for (x = 0; x < s->width; x++) { - if (y == s->y && x > s->x) { - break; - } - console_clear_xy(s, x, y); - } - } - break; - case 2: - /* clear entire screen */ - for (y = 0; y <= s->height; y++) { - for (x = 0; x < s->width; x++) { - console_clear_xy(s, x, y); - } - } - break; - } - case 'K': - switch (s->esc_params[0]) { - case 0: - /* clear to eol */ - for(x = s->x; x < s->width; x++) { - console_clear_xy(s, x, s->y); - } - break; - case 1: - /* clear from beginning of line */ - for (x = 0; x <= s->x; x++) { - console_clear_xy(s, x, s->y); - } - break; - case 2: - /* clear entire line */ - for(x = 0; x < s->width; x++) { - console_clear_xy(s, x, s->y); - } - break; - } - break; - case 'm': - console_handle_escape(s); - break; - case 'n': - /* report cursor position */ - /* TODO: send ESC[row;colR */ - break; - case 's': - /* save cursor position */ - s->x_saved = s->x; - s->y_saved = s->y; - break; - case 'u': - /* restore cursor position */ - s->x = s->x_saved; - s->y = s->y_saved; - break; - default: -#ifdef DEBUG_CONSOLE - fprintf(stderr, "unhandled escape character '%c'\n", ch); -#endif - break; - } - break; - } - } -} - void console_select(unsigned int index) { TextConsole *s; @@ -1085,17 +345,6 @@ void console_select(unsigned int index) } } -static void text_console_invalidate(void *opaque) -{ - TextConsole *s = (TextConsole *) opaque; - if (!ds_get_bits_per_pixel(s->ds) && s->console_type == TEXT_CONSOLE) { - s->g_width = ds_get_width(s->ds); - s->g_height = ds_get_height(s->ds); - text_console_resize(s); - } - console_refresh(s); -} - static TextConsole *get_graphic_console(DisplayState *ds) { int i; diff --git a/vl-android-ui.c b/vl-android-ui.c index 3c9fc22..60df320 100644 --- a/vl-android-ui.c +++ b/vl-android-ui.c @@ -192,7 +192,6 @@ int old_param = 0; const char *qemu_name; int alt_grab = 0; -static int timer_alarm_pending = 1; static QEMUTimer *nographic_timer; uint8_t qemu_uuid[16]; @@ -832,8 +831,6 @@ void main_loop_wait(int timeout) static void main_loop(void) { - int r; - #ifdef CONFIG_IOTHREAD qemu_system_ready = 1; qemu_cond_broadcast(&qemu_system_cond); @@ -873,99 +870,6 @@ static void sighandler_setup(void) #endif -#ifdef _WIN32 -/* Look for support files in the same directory as the executable. */ -static char *find_datadir(const char *argv0) -{ - char *p; - char buf[MAX_PATH]; - DWORD len; - - len = GetModuleFileName(NULL, buf, sizeof(buf) - 1); - if (len == 0) { - return NULL; - } - - buf[len] = 0; - p = buf + len - 1; - while (p != buf && *p != '\\') - p--; - *p = 0; - if (access(buf, R_OK) == 0) { - return qemu_strdup(buf); - } - return NULL; -} -#else /* !_WIN32 */ - -/* Find a likely location for support files using the location of the binary. - For installed binaries this will be "$bindir/../share/qemu". When - running from the build tree this will be "$bindir/../pc-bios". */ -#define SHARE_SUFFIX "/share/qemu" -#define BUILD_SUFFIX "/pc-bios" -static char *find_datadir(const char *argv0) -{ - char *dir; - char *p = NULL; - char *res; -#ifdef PATH_MAX - char buf[PATH_MAX]; -#endif - size_t max_len; - -#if defined(__linux__) - { - int len; - len = readlink("/proc/self/exe", buf, sizeof(buf) - 1); - if (len > 0) { - buf[len] = 0; - p = buf; - } - } -#elif defined(__FreeBSD__) - { - int len; - len = readlink("/proc/curproc/file", buf, sizeof(buf) - 1); - if (len > 0) { - buf[len] = 0; - p = buf; - } - } -#endif - /* If we don't have any way of figuring out the actual executable - location then try argv[0]. */ - if (!p) { -#ifdef PATH_MAX - p = buf; -#endif - p = realpath(argv0, p); - if (!p) { - return NULL; - } - } - dir = dirname(p); - dir = dirname(dir); - - max_len = strlen(dir) + - MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1; - res = qemu_mallocz(max_len); - snprintf(res, max_len, "%s%s", dir, SHARE_SUFFIX); - if (access(res, R_OK)) { - snprintf(res, max_len, "%s%s", dir, BUILD_SUFFIX); - if (access(res, R_OK)) { - qemu_free(res); - res = NULL; - } - } -#ifndef PATH_MAX - free(p); -#endif - return res; -} -#undef SHARE_SUFFIX -#undef BUILD_SUFFIX -#endif - #define QEMU_FILE_TYPE_BIOS 0 #define QEMU_FILE_TYPE_KEYMAP 1 @@ -1002,11 +906,8 @@ char *qemu_find_file(int type, const char *name) int main(int argc, char **argv, char **envp) { - int i; DisplayState *ds; DisplayChangeListener *dcl; - const char *r, *optarg; - char tmp_str[1024]; init_clocks(); -- cgit v1.1