[tuxdroid-svn] r719 - in daemon/trunk: . libs
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-11-21 16:00:11
|
Author: jaguarondi Date: 2007-11-21 17:00:01 +0100 (Wed, 21 Nov 2007) New Revision: 719 Modified: daemon/trunk/Makefile daemon/trunk/libs/USBDaemon_command_tux.c daemon/trunk/libs/USBDaemon_globals.h daemon/trunk/libs/USBDaemon_status_table.h daemon/trunk/main.c daemon/trunk/versioning.c daemon/trunk/versioning.h Log: * Updated versioning of the daemon. Modified: daemon/trunk/Makefile =================================================================== --- daemon/trunk/Makefile 2007-11-21 15:53:56 UTC (rev 718) +++ daemon/trunk/Makefile 2007-11-21 16:00:01 UTC (rev 719) @@ -57,11 +57,6 @@ @$(CC) $(CFLAGS) $(C_PREPROC) $(C_INCLUDE_DIRS) -c "$<" -o "$@" endef -## Generate doxygen documentation -.PHONY: doc -doc: - @./doc/builddoc.sh - .PHONY: print_header directories $(TARGET): print_header directories version.h $(SRC_OBJS) @@ -74,10 +69,12 @@ -@rm -rf "$(OBJ_DIR)" -@rm -rf "$(OUTPUT_DIR)/$(TARGET)" -@rmdir "$(OUTPUT_DIR)" + -@rm version.h clean: @echo Deleting intermediate files for 'USBDaemon - $(CFG)' -@rm -rf "$(OBJ_DIR)" + -@rm version.h print_header: @echo ----------Configuration: USBDaemon - Linux $(CFG)---------- @@ -87,7 +84,7 @@ -@if [ ! -d "$(OBJ_DIR)" ]; then mkdir "$(OBJ_DIR)"; fi version.h: version.txt - @echo "#define VERSION \"`cat version.txt`\"" > version.h + @echo "#define _TUXD_VERSION_ \"`cat version.txt`\"" > version.h $(OBJ_DIR)/main.o: main.c \ libs/USBDaemon_globals.h \ @@ -148,5 +145,8 @@ libs/USBDaemon_tcp_server.h $(compile_source) +## Generate doxygen documentation +.PHONY: doc +doc: + @./doc/builddoc.sh - Modified: daemon/trunk/libs/USBDaemon_command_tux.c =================================================================== --- daemon/trunk/libs/USBDaemon_command_tux.c 2007-11-21 15:53:56 UTC (rev 718) +++ daemon/trunk/libs/USBDaemon_command_tux.c 2007-11-21 16:00:01 UTC (rev 719) @@ -313,9 +313,10 @@ switch (data[0]) { case SUB_D_REQ_INFO_VERSION: - result[1] = version.major; - result[2] = version.minor; - result[3] = version.release; + result[1] = daemon_version.major; + result[2] = daemon_version.minor; + result[3] = daemon_version.update; + result[4] = daemon_version.release; break; case SUB_D_REQ_INFO_CLIENT_COUNT: result[1] = tcp_clients_count; Modified: daemon/trunk/libs/USBDaemon_globals.h =================================================================== --- daemon/trunk/libs/USBDaemon_globals.h 2007-11-21 15:53:56 UTC (rev 718) +++ daemon/trunk/libs/USBDaemon_globals.h 2007-11-21 16:00:01 UTC (rev 719) @@ -51,21 +51,4 @@ extern pid_t daemon_pid; extern bool show_invalid_raw; -#define MATURITY_LEN 9 -typedef char maturity_t[MATURITY_LEN + 1]; - -#define RELEASE_STATUS_LEN 19 -typedef char release_status_t[RELEASE_STATUS_LEN + 1]; - -struct version_s -{ - int major; - int minor; - int release; - maturity_t maturity; - release_status_t release_status; - int revision; -}; -extern struct version_s version; - #endif Modified: daemon/trunk/libs/USBDaemon_status_table.h =================================================================== --- daemon/trunk/libs/USBDaemon_status_table.h 2007-11-21 15:53:56 UTC (rev 718) +++ daemon/trunk/libs/USBDaemon_status_table.h 2007-11-21 16:00:01 UTC (rev 719) @@ -27,6 +27,7 @@ #include "../tuxdefs/api.h" #include "../tuxdefs/defines.h" #include <stdbool.h> +#include "../version.h" /*_____________________ D E F I N E S ______________________________________*/ @@ -274,6 +275,9 @@ extern unsigned char cmd_status_flag; extern unsigned char pong_received; +extern void update_raw_status_table(const unsigned char *new_status); +extern void update_system_status_table(const unsigned char *new_status); + /** Number of firmware information structures to store. * There's one for each firmware and one for the general release package. * Firmware will have the same index as defined in CPU_IDENTIFIERS, the last @@ -282,6 +286,8 @@ /** Index of the general release package information structure defined in * tux_status. */ #define RELEASE_INDEX (NUMBER_OF_FIRMWARE - 1) +/** Size of the version string. */ +#define VERSION_STRING_LENGTH 100 /** * Tux status table. @@ -297,20 +303,33 @@ int version_minor; int version_update; int revision; - int release; - int local_modification; - int mixed_revisions; + bool release; + bool local_modification; + bool mixed_revisions; int author; int variation; - char version_string[100]; + char version_string[VERSION_STRING_LENGTH]; } firmware_info[NUMBER_OF_FIRMWARE]; /** Sound flash properties. */ struct sound_flash_t { int number_of_sounds; + int filled_space; } sound_flash; }; +/** + * Daemon version information. + */ +struct daemon_version_t +{ + int major; /**< major version number */ + int minor; /**< minor version number */ + int update; /**< update version number */ + bool release; /**< has been tagged as a release */ + const char *version_string;/**< version string given in version.txt */ +}; + struct connection_status_t { /** USB request flag set when a USB command is issued and reset @@ -326,11 +345,10 @@ uint8_t wifi_channel; }; +/* Structures that define the variables that should be accessible by the API. + */ extern struct tux_status_t tux_status; - +extern struct daemon_version_t daemon_version; extern struct connection_status_t connection_status; -extern void update_raw_status_table(const unsigned char *new_status); -extern void update_system_status_table(const unsigned char *new_status); - #endif Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-11-21 15:53:56 UTC (rev 718) +++ daemon/trunk/main.c 2007-11-21 16:00:01 UTC (rev 719) @@ -41,19 +41,10 @@ #include "libs/USBDaemon_tcp_server.h" #include "libs/USBDaemon_status_table.h" #include "libs/USBDaemon_command_tux.h" -#include "version.h" +#include "versioning.h" /*_____________________ F U N C T I O N S __________________________________*/ -struct version_s version = { - .major = 0, - .minor = 0, - .release = 0, - .maturity = "", - .release_status = "", - .revision = 0 -}; - bool show_frames = false; /**< Show USB frames structure */ bool show_raw_status = false; /**< Show all raw statuses */ bool show_invalid_raw = false; /**< Show only invalid statuses */ @@ -65,42 +56,6 @@ static gid_t group = (gid_t)-1; /**< Initial group id */ /** - * Extract daemon info from version string. - */ -static void setup_daemon_info(void) -{ - const char delimiters[] = " .-"; - char cp[] = VERSION; - char *token; - - if ((token = strtok(cp, delimiters)) != NULL) - version.major = atoi(token); - - if ((token = strtok(NULL, delimiters)) != NULL) - version.minor = atoi(token); - - if ((token = strtok(NULL, delimiters)) != NULL) - version.release = atoi(token); - - if ((token = strtok(NULL, delimiters)) != NULL) - strncpy(version.maturity, token, sizeof(version.maturity)); - - if ((token = strtok(NULL, delimiters)) != NULL) - strncpy(version.release_status, token, sizeof(version.release_status)); -} - -/** - * Display daemon info on standard output. - */ -static void print_daemon_info(void) -{ - printf("-----------------------------------\n"); - printf("Tux USB Daemon version %s\n", VERSION); - printf("Kysoh 2007.\n"); - printf("-----------------------------------\n"); -} - -/** * Clean closing of stdin and stdout. */ static int fd_nullify(int desired_fd) @@ -318,6 +273,15 @@ exit(status); } +/** + * Display daemon info on standard output. + */ +static void print_version(char const *me) +{ + printf("%s %s\n", me, daemon_version.version_string); + printf("Copyright (C) 2007 KySoH S.A. <tux...@ky...>\n"); +} + int main(int argc, char *argv[]) { unsigned char i; @@ -360,6 +324,9 @@ exit(0); } + /* Initialization */ + init_daemon_info(); + if (daemonized) daemonize(log_target, log_level); else @@ -369,12 +336,9 @@ log_open(LOG_TARGET_SHELL); log_set_level(log_level); + print_version(argv[0]); } - /* Setup & print daemon information */ - setup_daemon_info(); - print_daemon_info(); - #ifdef USB_DEBUG /* Set libusb debug level */ usb_set_debug(LIBUSB_DEBUG_LEVEL); Modified: daemon/trunk/versioning.c =================================================================== --- daemon/trunk/versioning.c 2007-11-21 15:53:56 UTC (rev 718) +++ daemon/trunk/versioning.c 2007-11-21 16:00:01 UTC (rev 719) @@ -32,6 +32,33 @@ #include "tuxdefs/api.h" /** + * Daemon version information. + */ +struct daemon_version_t daemon_version = { .version_string = _TUXD_VERSION_}; + +/** + * Extract daemon version numbers from the version string and store them in the + * daemon version structure. + */ +void init_daemon_info(void) +{ + const char delimiters[] = " .-"; + char *token; + char cp[255]; + + strcpy(cp,daemon_version.version_string); + if ((token = strtok(cp, delimiters)) != NULL) + daemon_version.major = atoi(token); + if ((token = strtok(NULL, delimiters)) != NULL) + daemon_version.minor = atoi(token); + if ((token = strtok(NULL, delimiters)) != NULL) + daemon_version.update = atoi(token); + if ((token = strtok(NULL, "")) == NULL || + !(strstr(token, "SVN") || strstr(token, "svn"))) + daemon_version.release = true; +} + +/** * CPU names mapped from their identifiers. * Should be in sync with CPU_IDENTIFIERS so that cpu_name[some_cpu_id] * should return its CPU name. Modified: daemon/trunk/versioning.h =================================================================== --- daemon/trunk/versioning.h 2007-11-21 15:53:56 UTC (rev 718) +++ daemon/trunk/versioning.h 2007-11-21 16:00:01 UTC (rev 719) @@ -23,6 +23,7 @@ #ifndef _VERSIONING_H_ #define _VERSIONING_H_ +extern void init_daemon_info(void); extern void tux_information_cleaning(void); extern void get_versioning(void); extern void versioning_call(void); |