diff options
-rw-r--r-- | include/hardware_legacy/gps.h | 12 | ||||
-rw-r--r-- | include/hardware_legacy/led.h | 44 | ||||
-rw-r--r-- | include/hardware_legacy/power.h | 13 | ||||
-rw-r--r-- | led/Android.mk | 15 | ||||
-rw-r--r-- | led/led_qemu.c | 23 | ||||
-rw-r--r-- | led/led_sardine.c | 78 | ||||
-rw-r--r-- | led/led_stub.c | 51 | ||||
-rw-r--r-- | led/led_trout.c | 115 | ||||
-rw-r--r-- | power/power.c | 52 | ||||
-rw-r--r-- | power/power_qemu.c | 23 | ||||
-rw-r--r-- | power/power_qemu.h | 3 | ||||
-rw-r--r-- | qemu.h | 8 | ||||
-rw-r--r-- | qemu/qemu.c | 201 |
13 files changed, 151 insertions, 487 deletions
diff --git a/include/hardware_legacy/gps.h b/include/hardware_legacy/gps.h index 5f8740f..eb70119 100644 --- a/include/hardware_legacy/gps.h +++ b/include/hardware_legacy/gps.h @@ -241,6 +241,18 @@ typedef struct { int (*inject_xtra_data)( char* data, int length ); } GpsXtraInterface; +/** Extended interface for SUPL support. */ +typedef struct { + /** + * Sets the name of the APN to be used for SUPL. + */ + int (*set_apn)( const char* apn ); + /** + * Sets the IP address and port for the SUPL server. + */ + int (*set_server)( uint32_t addr, int port ); +} GpsSuplInterface; + /** Returns the hardware GPS interface. */ const GpsInterface* gps_get_hardware_interface(); diff --git a/include/hardware_legacy/led.h b/include/hardware_legacy/led.h deleted file mode 100644 index b5acb73..0000000 --- a/include/hardware_legacy/led.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _HARDWARE_LED_H -#define _HARDWARE_LED_H - -#if __cplusplus -extern "C" { -#endif - -/** - * Changes the state of the LED. - * - * -# Turn on LED: Alpha != 0 and RBG != 0, onMS == 0 && offMS == 0. - * -# Blink LED: Alpha != 0 and RBG != 0, onMS != 0 && offMS != 0. - * -# Turn off LED: Alpha == 0 or RGB == 0. - * - * @param colorARGB represents the LED's color: Alpha=31:24, Red=23:16 - * Green=15:8 Blue=7:0 - * @param onMS represents the time the LED is on in milliseconds - * @param offMS represents the time the LED is off in milliseconds - * - * @return 0 if successful - */ -int set_led_state(unsigned colorARGB, int onMS, int offMS); - -#if __cplusplus -} // extern "C" -#endif - -#endif // _HARDWARE_LED_H diff --git a/include/hardware_legacy/power.h b/include/hardware_legacy/power.h index 993bca5..b7cee43 100644 --- a/include/hardware_legacy/power.h +++ b/include/hardware_legacy/power.h @@ -33,19 +33,6 @@ enum { int acquire_wake_lock(int lock, const char* id); int release_wake_lock(const char* id); - -enum { - KEYBOARD_LIGHT = 0x00000001, - SCREEN_LIGHT = 0x00000002, - BUTTON_LIGHT = 0x00000004, -}; - -// set the lights identified in mask to the brightness specified -// in value. for example -// set_light_brightness(SCREEN_LIGHT | KEYBOARD_LIGHT, 200); -// sets the screen and keyboard lights to brightness 200 -int set_light_brightness(unsigned int mask, unsigned int brightness); - // true if you want the screen on, false if you want it off int set_screen_state(int on); diff --git a/led/Android.mk b/led/Android.mk deleted file mode 100644 index a0326b9..0000000 --- a/led/Android.mk +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2006 The Android Open Source Project - -ifeq ($(TARGET_DEVICE),sooner) -LOCAL_SRC_FILES += led/led_sardine.c -LOCAL_CFLAGS += -DCONFIG_LED_SARDINE -endif -ifneq (,$(filter $(TARGET_DEVICE),dream sapphire)) -LOCAL_SRC_FILES += led/led_trout.c -LOCAL_CFLAGS += -DCONFIG_LED_TROUT -endif -ifeq ($(QEMU_HARDWARE),true) -LOCAL_CFLAGS += -DCONFIG_LED_QEMU -endif -LOCAL_SRC_FILES += led/led_stub.c - diff --git a/led/led_qemu.c b/led/led_qemu.c deleted file mode 100644 index c98402b..0000000 --- a/led/led_qemu.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "qemu.h" - -int -qemu_set_led_state(unsigned color, int on, int off) -{ - qemu_control_command( "set_led_state:%08x:%d:%d", color, on, off ); - return 0; -} diff --git a/led/led_sardine.c b/led/led_sardine.c deleted file mode 100644 index b6a508a..0000000 --- a/led/led_sardine.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include <hardware_legacy/led.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <stdio.h> - -const char* const CADENCE_FILE = "/sys/class/leds/left/cadence"; -const char* const COLOR_FILE = "/sys/class/leds/left/color"; -const char* const BT_WIFI_FILE = "/sys/class/leds/right/brightness"; - -static int -write_string(const char* file, const char* string, int len) -{ - int fd; - ssize_t amt; - - fd = open(file, O_RDWR); - if (fd < 0) { - return errno; - } - - amt = write(fd, string, len+1); - - close(fd); - return amt >= 0 ? 0 : errno; -} - -int sardine_set_led_state(unsigned colorARGB, int onMS, int offMS) -{ - int len; - char buf[30]; - int red, green, color; - - // alpha of 0 or color of 0 (ignoring blue) means off - if ((colorARGB & 0xff000000) == 0 || (colorARGB & 0x00ffff00) == 0) { - onMS = 0; - offMS = 0; - } - - // blue means green - if ((colorARGB & 0x00ffff00) == 0 && (colorARGB & 0x000000ff) != 0) { - colorARGB |= (colorARGB & 0x000000ff) << 8; - } - - // ===== color ===== - // this color conversion isn't really correct, but it's better to - // have the light come bright on when asked for low intensity than to - // not come on at all. we have no blue - red = (colorARGB & 0x00ff0000) ? 1 : 0; - green = (colorARGB & 0x0000ff00) ? 2 : 0; - color = (red | green) - 1; - - len = sprintf(buf, "%d", color); - write_string(COLOR_FILE, buf, len); - - // ===== color ===== - len = sprintf(buf, "%d,%d", onMS, offMS); - write_string(CADENCE_FILE, buf, len); - - return 0; -} diff --git a/led/led_stub.c b/led/led_stub.c deleted file mode 100644 index 6b3b3da..0000000 --- a/led/led_stub.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include <hardware_legacy/led.h> - -typedef int (*LedFunc)(unsigned, int, int); - -#ifdef CONFIG_LED_SARDINE -extern int sardine_set_led_state(unsigned, int, int); -# define HW_LED_FUNC sardine_set_led_state -#endif - -#ifdef CONFIG_LED_TROUT -extern int trout_set_led_state(unsigned, int, int); -# define HW_LED_FUNC trout_set_led_state -#endif - -#ifdef CONFIG_LED_QEMU -#include "qemu.h" -static int -qemu_set_led_state(unsigned color, int on, int off) -{ - qemu_control_command( "set_led_state:%08x:%d:%d", color, on, off ); - return 0; -} -#endif - -int -set_led_state(unsigned color, int on, int off) -{ -#ifdef CONFIG_LED_QEMU - QEMU_FALLBACK(set_led_state(color,on,off)); -#endif -#ifdef HW_LED_FUNC - return HW_LED_FUNC(color, on, off); -#else - return 0; -#endif -} diff --git a/led/led_trout.c b/led/led_trout.c deleted file mode 100644 index b129ec9..0000000 --- a/led/led_trout.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include <hardware_legacy/led.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <stdio.h> - -#define LOG_TAG "LED" -#include <utils/Log.h> - -const char* const AMBER_BRIGHTNESS_FILE = "/sys/class/leds/amber/brightness"; -const char* const RED_BRIGHTNESS_FILE = "/sys/class/leds/red/brightness"; -const char* const GREEN_BRIGHTNESS_FILE = "/sys/class/leds/green/brightness"; -const char* const BLUE_BRIGHTNESS_FILE = "/sys/class/leds/blue/brightness"; -const char* const BLINK_ENABLE_FILE = "/sys/class/leds/red/device/blink"; -const char* const BLINK_FREQ_FILE = "/sys/class/leds/red/device/grpfreq"; -const char* const BLINK_PWM_FILE = "/sys/class/leds/red/device/grppwm"; - -static int -write_string(const char* file, const char* string, int len) -{ - int fd; - ssize_t amt; - - fd = open(file, O_RDWR); - if (fd < 0) { - LOGE("open failed errno: %d\n", errno); - return errno; - } - - amt = write(fd, string, len); - if (amt < 0) { - LOGE("write failed errno: %d\n", errno); - } - - close(fd); - return amt >= 0 ? 0 : errno; -} - -int trout_set_led_state(unsigned colorARGB, int onMS, int offMS) -{ - int len; - char buf[30]; - int alpha, red, green, blue; - int blink, freq, pwm; - - LOGV("set_led_state colorARGB=%08X, onMS=%d, offMS=%d\n", colorARGB, onMS, offMS); - - // alpha of 0 or color of 0 means off - if ((colorARGB & 0xff000000) == 0 || (colorARGB & 0x00ffffff) == 0) { - onMS = 0; - offMS = 0; - } - - red = (colorARGB >> 16) & 0xFF; - green = (colorARGB >> 8) & 0xFF; - blue = colorARGB & 0xFF; - - len = sprintf(buf, "%d", red); - write_string(RED_BRIGHTNESS_FILE, buf, len); - len = sprintf(buf, "%d", green); - write_string(GREEN_BRIGHTNESS_FILE, buf, len); - len = sprintf(buf, "%d", blue); - write_string(BLUE_BRIGHTNESS_FILE, buf, len); - - if (onMS > 0 && offMS > 0) { - int totalMS = onMS + offMS; - - // the LED appears to blink about once per second if freq is 20 - // 1000ms / 20 = 50 - freq = totalMS / 50; - // pwm specifies the ratio of ON versus OFF - // pwm = 0 -> always off - // pwm = 255 => always on - pwm = (onMS * 255) / totalMS; - - // the low 4 bits are ignored, so round up if necessary - if (pwm > 0 && pwm < 16) - pwm = 16; - - blink = 1; - } else { - blink = 0; - freq = 0; - pwm = 0; - } - - if (blink) { - len = sprintf(buf, "%d", freq); - write_string(BLINK_FREQ_FILE, buf, len); - len = sprintf(buf, "%d", pwm); - write_string(BLINK_PWM_FILE, buf, len); - } - - len = sprintf(buf, "%d", blink); - write_string(BLINK_ENABLE_FILE, buf, len); - - return 0; -} diff --git a/power/power.c b/power/power.c index 1130dfa..0309db7 100644 --- a/power/power.c +++ b/power/power.c @@ -56,10 +56,6 @@ const char * const NEW_PATHS[] = { const char * const AUTO_OFF_TIMEOUT_DEV = "/sys/android_power/auto_off_timeout"; -const char * const LCD_BACKLIGHT = "/sys/class/leds/lcd-backlight/brightness"; -const char * const BUTTON_BACKLIGHT = "/sys/class/leds/button-backlight/brightness"; -const char * const KEYBOARD_BACKLIGHT = "/sys/class/leds/keyboard-backlight/brightness"; - //XXX static pthread_once_t g_initialized = THREAD_ONCE_INIT; static int g_initialized = 0; static int g_fds[OUR_FD_COUNT]; @@ -162,54 +158,6 @@ set_last_user_activity_timeout(int64_t delay) } } -static void -set_a_light(const char* path, int value) -{ - int fd; - static int already_warned = 0; - - // LOGI("set_a_light(%s, %d)\n", path, value); - - fd = open(path, O_RDWR); - if (fd >= 0) { - char buffer[20]; - int bytes = sprintf(buffer, "%d\n", value); - write(fd, buffer, bytes); - close(fd); - } else { - if (already_warned == 0) { - LOGE("set_a_light failed to open %s\n", path); - already_warned = 1; - } - } -} - -int -set_light_brightness(unsigned int mask, unsigned int brightness) -{ - QEMU_FALLBACK(set_light_brightness(mask,brightness)); - - initialize_fds(); - -// LOGI("set_light_brightness mask=0x%08x brightness=%d now=%lld g_error=%s\n", -// mask, brightness, systemTime(), strerror(g_error)); - - if (mask & KEYBOARD_LIGHT) { - set_a_light(KEYBOARD_BACKLIGHT, brightness); - } - - if (mask & SCREEN_LIGHT) { - set_a_light(LCD_BACKLIGHT, brightness); - } - - if (mask & BUTTON_LIGHT) { - set_a_light(BUTTON_BACKLIGHT, brightness); - } - - return 0; -} - - int set_screen_state(int on) { diff --git a/power/power_qemu.c b/power/power_qemu.c index d400082..742276f 100644 --- a/power/power_qemu.c +++ b/power/power_qemu.c @@ -19,29 +19,6 @@ #include <errno.h> #include <hardware_legacy/power.h> -static void -set_a_light(const char* name, unsigned brightness) -{ - qemu_control_command( "power:light:brightness:%s:%d", - name, brightness ); -} - -int -qemu_set_light_brightness(unsigned int mask, unsigned int brightness) -{ - if (mask & KEYBOARD_LIGHT) { - set_a_light("keyboard_backlight", brightness); - } - if (mask & SCREEN_LIGHT) { - set_a_light("lcd_backlight", brightness); - } - if (mask & BUTTON_LIGHT) { - set_a_light("button_backlight", brightness); - } - return 0; -} - - int qemu_set_screen_state(int on) { diff --git a/power/power_qemu.h b/power/power_qemu.h index 3004950..c689da3 100644 --- a/power/power_qemu.h +++ b/power/power_qemu.h @@ -19,9 +19,6 @@ #include <stdint.h> extern int -qemu_set_light_brightness(unsigned int mask, unsigned int brightness); - -extern int qemu_set_screen_state(int on); #endif /* _power_qemu_h */ @@ -35,7 +35,9 @@ typedef struct { char is_inited; char is_available; char is_qemud; + char is_qemud_old; char is_tty; + int fd; char device[32]; } QemuChannel; @@ -65,15 +67,15 @@ extern int qemu_command_format( char* buffer, const char* format, ... ); -/* directly sends a command through the 'control' channel. +/* directly sends a command through the 'hw-control' channel. * this will open the channel, send the formatted command, then * close the channel automatically. * returns 0 on success, or -1 on error. */ extern int qemu_control_command( const char* fmt, ... ); -/* sends a question to the control channel, then receive an answer in - * a user-allocated buffer. returns the lenght of the answer, or -1 +/* sends a question to the hw-control channel, then receive an answer in + * a user-allocated buffer. returns the length of the answer, or -1 * in case of error. * * 'question' *must* have been formatted through qemu_command_format diff --git a/qemu/qemu.c b/qemu/qemu.c index 2631c58..de029be 100644 --- a/qemu/qemu.c +++ b/qemu/qemu.c @@ -50,6 +50,116 @@ qemu_check(void) return in_qemu; } +static int +qemu_fd_write( int fd, const char* cmd, int len ) +{ + int len2; + do { + len2 = write(fd, cmd, len); + } while (len2 < 0 && errno == EINTR); + return len2; +} + +static int +qemu_fd_read( int fd, char* buff, int len ) +{ + int len2; + do { + len2 = read(fd, buff, len); + } while (len2 < 0 && errno == EINTR); + return len2; +} + + +static int +qemu_channel_open_qemud( QemuChannel* channel, + const char* name ) +{ + int fd, ret, namelen = strlen(name); + char answer[2]; + + fd = socket_local_client( "qemud", + ANDROID_SOCKET_NAMESPACE_RESERVED, + SOCK_STREAM ); + if (fd < 0) { + D("no qemud control socket: %s", strerror(errno)); + return -1; + } + + /* send service name to connect */ + if (qemu_fd_write(fd, name, namelen) != namelen) { + D("can't send service name to qemud: %s", + strerror(errno)); + close(fd); + return -1; + } + + /* read answer from daemon */ + if (qemu_fd_read(fd, answer, 2) != 2 || + answer[0] != 'O' || answer[1] != 'K') { + D("cant' connect to %s service through qemud", name); + close(fd); + return -1; + } + + channel->is_qemud = 1; + channel->fd = fd; + return 0; +} + + +static int +qemu_channel_open_qemud_old( QemuChannel* channel, + const char* name ) +{ + int fd; + + snprintf(channel->device, sizeof channel->device, + "qemud_%s", name); + + fd = socket_local_client( channel->device, + ANDROID_SOCKET_NAMESPACE_RESERVED, + SOCK_STREAM ); + if (fd < 0) { + D("no '%s' control socket available: %s", + channel->device, strerror(errno)); + return -1; + } + + close(fd); + channel->is_qemud_old = 1; + return 0; +} + + +static int +qemu_channel_open_tty( QemuChannel* channel, + const char* name, + int mode ) +{ + char key[PROPERTY_KEY_MAX]; + char prop[PROPERTY_VALUE_MAX]; + int ret; + + ret = snprintf(key, sizeof key, "ro.kernel.android.%s", name); + if (ret >= (int)sizeof key) + return -1; + + if (property_get(key, prop, "") == 0) { + D("no kernel-provided %s device name", name); + return -1; + } + + ret = snprintf(channel->device, sizeof channel->device, + "/dev/%s", prop); + if (ret >= (int)sizeof channel->device) { + D("%s device name too long: '%s'", name, prop); + return -1; + } + + channel->is_tty = !memcmp("/dev/tty", channel->device, 8); + return 0; +} int qemu_channel_open( QemuChannel* channel, @@ -61,67 +171,44 @@ qemu_channel_open( QemuChannel* channel, /* initialize the channel is needed */ if (!channel->is_inited) { - int done = 0; + channel->is_inited = 1; - // try to connect to qemud socket first do { - snprintf(channel->device, sizeof channel->device, - "qemud_%s", name); - - fd = socket_local_client( channel->device, - ANDROID_SOCKET_NAMESPACE_RESERVED, - SOCK_STREAM ); - if (fd < 0) { - D("no '%s' control socket available: %s", - channel->device, strerror(errno)); - break; - } - close(fd); - channel->is_qemud = 1; - done = 1; - } while (0); - - // otherwise, look for a kernel-provided device name - if (!done) do { - char key[PROPERTY_KEY_MAX]; - char prop[PROPERTY_VALUE_MAX]; - int ret; - - ret = snprintf(key, sizeof key, "ro.kernel.android.%s", name); - if (ret >= (int)sizeof key) + if (qemu_channel_open_qemud(channel, name) == 0) break; - if (property_get(key, prop, "") == 0) { - D("no kernel-provided %s device name", name); + if (qemu_channel_open_qemud_old(channel, name) == 0) break; - } - ret = snprintf(channel->device, sizeof channel->device, - "/dev/%s", prop); - if (ret >= (int)sizeof channel->device) { - D("%s device name too long: '%s'", name, prop); + if (qemu_channel_open_tty(channel, name, mode) == 0) break; - } - channel->is_tty = !memcmp("/dev/tty", channel->device, 8); - done = 1; + channel->is_available = 0; + return -1; } while (0); - channel->is_available = done; - channel->is_inited = 1; + channel->is_available = 1; } /* try to open the file */ if (!channel->is_available) { - fd = -1; errno = ENOENT; - } else if (channel->is_qemud) { + return -1; + } + + if (channel->is_qemud) { + return dup(channel->fd); + } + + if (channel->is_qemud_old) { do { fd = socket_local_client( channel->device, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM ); } while (fd < 0 && errno == EINTR); - } else { + } + else /* /dev/ttySn ? */ + { do { fd = open(channel->device, mode); } while (fd < 0 && errno == EINTR); @@ -181,7 +268,7 @@ qemu_control_fd(void) static QemuChannel channel[1]; int fd; - fd = qemu_channel_open( channel, "control", O_RDWR ); + fd = qemu_channel_open( channel, "hw-control", O_RDWR ); if (fd < 0) { D("%s: could not open control channel: %s", __FUNCTION__, strerror(errno)); @@ -190,26 +277,6 @@ qemu_control_fd(void) } static int -qemu_control_write( int fd, const char* cmd, int len ) -{ - int len2; - do { - len2 = write(fd, cmd, len); - } while (len2 < 0 && errno == EINTR); - return len2; -} - -static int -qemu_control_read( int fd, char* buff, int len ) -{ - int len2; - do { - len2 = read(fd, buff, len); - } while (len2 < 0 && errno == EINTR); - return len2; -} - -static int qemu_control_send(const char* cmd, int len) { int fd, len2; @@ -223,7 +290,7 @@ qemu_control_send(const char* cmd, int len) if (fd < 0) return -1; - len2 = qemu_control_write(fd, cmd, len); + len2 = qemu_fd_write(fd, cmd, len); close(fd); if (len2 != len) { D("%s: could not send everything %d < %d", @@ -273,7 +340,7 @@ extern int qemu_control_query( const char* question, int questionlen, if (fd < 0) return -1; - ret = qemu_control_write( fd, question, questionlen ); + ret = qemu_fd_write( fd, question, questionlen ); if (ret != questionlen) { D("%s: could not write all: %d < %d", __FUNCTION__, ret, questionlen); @@ -281,14 +348,14 @@ extern int qemu_control_query( const char* question, int questionlen, } /* read a 4-byte header giving the length of the following content */ - ret = qemu_control_read( fd, header, 4 ); + ret = qemu_fd_read( fd, header, 4 ); if (ret != 4) { D("%s: could not read header (%d != 4)", __FUNCTION__, ret); goto Exit; } - header[5] = 0; + header[4] = 0; len = strtol( header, &end, 16 ); if ( len < 0 || end == NULL || end != header+4 || len > answersize ) { D("%s: could not parse header: '%s'", @@ -297,7 +364,7 @@ extern int qemu_control_query( const char* question, int questionlen, } /* read the answer */ - ret = qemu_control_read( fd, answer, len ); + ret = qemu_fd_read( fd, answer, len ); if (ret != len) { D("%s: could not read all of answer %d < %d", __FUNCTION__, ret, len); |