From bc1e6488eec32b12074ed7d82c85bf422d2381ab Mon Sep 17 00:00:00 2001 From: Christopher Hall Date: Thu, 1 Oct 2009 11:16:09 +0800 Subject: [PATCH] [tidy-up] Change OpenMoko to Openmoko Signed-off-by: Christopher Hall --- Makefile | 2 +- .../det-wikird.windows/Makefile | 2 +- .../det-wikird.windows/det-wikird.cpp | 208 +++++++++--------- .../detect-wikireader/src/check-wikireader.c | 4 +- .../detect-wikireader/src/check-wikireader.h | 2 +- host-tools/detect-wikireader/src/daemon.c | 82 +++---- host-tools/detect-wikireader/src/daemon.h | 2 +- .../detect-wikireader/src/log-message.c | 12 +- .../detect-wikireader/src/log-message.h | 2 +- host-tools/detect-wikireader/src/main.c | 40 ++-- .../detect-wikireader/src/wiki-inotify.c | 14 +- .../detect-wikireader/src/wiki-inotify.h | 2 +- host-tools/wiki-xml/main.c | 65 +++--- samo-lib/mbr/memory-test.c | 2 +- 14 files changed, 219 insertions(+), 220 deletions(-) diff --git a/Makefile b/Makefile index 2a8c4a44d..7618baa05 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile - a Makefile for setting up Wiki Reader # -# (C) Copyright 2008, 2009 OpenMoko, Inc. +# (C) Copyright 2008, 2009 Openmoko, Inc. # Authors: xiangfu liu # Sean Moss-Pultz # Christopher Hall diff --git a/host-tools/detect-wikireader/det-wikird.windows/Makefile b/host-tools/detect-wikireader/det-wikird.windows/Makefile index 77c853986..3838adb3b 100755 --- a/host-tools/detect-wikireader/det-wikird.windows/Makefile +++ b/host-tools/detect-wikireader/det-wikird.windows/Makefile @@ -1,5 +1,5 @@ # -# (C) Copyright 2008 OpenMoko, Inc. +# (C) Copyright 2008 Openmoko, Inc. # Author: xiangfu liu # # This program is free software: you can redistribute it and/or modify diff --git a/host-tools/detect-wikireader/det-wikird.windows/det-wikird.cpp b/host-tools/detect-wikireader/det-wikird.windows/det-wikird.cpp index 0d28075da..bf95232e2 100755 --- a/host-tools/detect-wikireader/det-wikird.windows/det-wikird.cpp +++ b/host-tools/detect-wikireader/det-wikird.windows/det-wikird.cpp @@ -1,5 +1,5 @@ -/* - * (C) Copyright 2008 OpenMoko, Inc. +sr/* + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #define APPTITLE "det-wikird Openmoko" @@ -53,25 +53,25 @@ int WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int nCmdShow) wc.lpszClassName=APPTITLE; if (!RegisterClass(&wc)) - return 0; + return 0; hwnd = CreateWindow(APPTITLE, APPTITLE, - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT,CW_USEDEFAULT,300,100, - NULL,NULL,hInst,NULL); + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT,CW_USEDEFAULT,300,100, + NULL,NULL,hInst,NULL); if (!hwnd) - return 0; + return 0; g_hwnd = hwnd; MinimizeToSysTray(); UpdateWindow(hwnd); while (GetMessage(&msg,NULL,0,0) > 0) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } return 0; } @@ -91,14 +91,14 @@ int PaintMessage(HWND hwnd) int Message(char *msg) { if (msg != NULL) { - if (strlen(g_Msg) + strlen(msg) < MSG_BUFFER_LENGTH) { - strcat(g_Msg, "\n"); - strcat(g_Msg, msg); - } - else - strcpy(g_Msg, msg); + if (strlen(g_Msg) + strlen(msg) < MSG_BUFFER_LENGTH) { + strcat(g_Msg, "\n"); + strcat(g_Msg, msg); + } + else + strcpy(g_Msg, msg); } - PaintMessage(g_hwnd); + PaintMessage(g_hwnd); InvalidateRect(g_hwnd, NULL, TRUE); UpdateWindow(g_hwnd); return 0; @@ -116,34 +116,34 @@ void openWeb() // open register root key if(RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkRoot)==ERROR_SUCCESS) - { - // open subkey - if(RegOpenKeyEx(hkRoot, - "htmlfile\\shell\\open\\command", - 0, - KEY_ALL_ACCESS, - &hSubKey)==ERROR_SUCCESS) - { - // get the browers - RegEnumValue(hSubKey, - 0, - ValueName, - &cbValueName, - NULL, - &dwType, - DataValue, - &cbDataValue); - // set main page value - strcpy(ShellChar,(char *)DataValue); - strcat(ShellChar, WEBSITE); - // run the browers - WinExec(ShellChar,SW_SHOW); - } - else - Message("WEB browers open error."); - } + { + // open subkey + if(RegOpenKeyEx(hkRoot, + "htmlfile\\shell\\open\\command", + 0, + KEY_ALL_ACCESS, + &hSubKey)==ERROR_SUCCESS) + { + // get the browers + RegEnumValue(hSubKey, + 0, + ValueName, + &cbValueName, + NULL, + &dwType, + DataValue, + &cbDataValue); + // set main page value + strcpy(ShellChar,(char *)DataValue); + strcat(ShellChar, WEBSITE); + // run the browers + WinExec(ShellChar,SW_SHOW); + } + else + Message("WEB browers open error."); + } else - Message("WEB browers open error."); + Message("WEB browers open error."); RegCloseKey(hSubKey); RegCloseKey(hkRoot); @@ -155,61 +155,61 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) switch (msg) { case WM_PAINT: - PaintMessage(hwnd); - break; + PaintMessage(hwnd); + break; case WM_DESTROY: - PostQuitMessage(0); - break; + PostQuitMessage(0); + break; case WM_DEVICECHANGE: - switch (wparam) { - case DBT_DEVICEARRIVAL: - Message("Debug: A device has been inserted."); - if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) { - PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; + switch (wparam) { + case DBT_DEVICEARRIVAL: + Message("Debug: A device has been inserted."); + if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) { + PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; - UINT IsRAMDISK; - char Driver[4] = {'A', ':', '\\', '\0'}; - Driver[0] = FirstDriveFromMask(lpdbv->dbcv_unitmask); - IsRAMDISK=GetDriveType(Driver); - if (IsRAMDISK == DRIVE_RAMDISK || - IsRAMDISK == DRIVE_FIXED || /* DRIVE_FIXED means harddisk */ - IsRAMDISK == DRIVE_REMOVABLE) { - wsprintf(g_Msg, "Drive %s Media has arrived.", Driver); - Message(NULL); - if (check_wikireader(Driver) == 0) { - openWeb(); - Message("openning http://wiki.openmoko.org"); - } - else - Message("this is not Openmoko Wiki Reader."); - } - } - break; - - case DBT_DEVICEREMOVECOMPLETE: - Message("Debug: A device has been removed"); - break; - } - break; + UINT IsRAMDISK; + char Driver[4] = {'A', ':', '\\', '\0'}; + Driver[0] = FirstDriveFromMask(lpdbv->dbcv_unitmask); + IsRAMDISK=GetDriveType(Driver); + if (IsRAMDISK == DRIVE_RAMDISK || + IsRAMDISK == DRIVE_FIXED || /* DRIVE_FIXED means harddisk */ + IsRAMDISK == DRIVE_REMOVABLE) { + wsprintf(g_Msg, "Drive %s Media has arrived.", Driver); + Message(NULL); + if (check_wikireader(Driver) == 0) { + openWeb(); + Message("openning http://wiki.openmoko.org"); + } + else + Message("this is not Openmoko Wiki Reader."); + } + } + break; + + case DBT_DEVICEREMOVECOMPLETE: + Message("Debug: A device has been removed"); + break; + } + break; case WM_USER: - switch(lparam) - { - case WM_LBUTTONDBLCLK: - if (g_bInSysTray) - ShowWindow(g_hwnd,SW_SHOW); - else - MinimizeToSysTray(); - g_bInSysTray = !g_bInSysTray; - break; - case WM_LBUTTONUP: - break; - } - break; + switch(lparam) + { + case WM_LBUTTONDBLCLK: + if (g_bInSysTray) + ShowWindow(g_hwnd,SW_SHOW); + else + MinimizeToSysTray(); + g_bInSysTray = !g_bInSysTray; + break; + case WM_LBUTTONUP: + break; + } + break; default: - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProc(hwnd, msg, wparam, lparam); } return DefWindowProc(hwnd, msg, wparam, lparam); @@ -225,17 +225,17 @@ is set to 1. Returns the first drive letter that was found. --------------------------------------------------------------------*/ -char FirstDriveFromMask(ULONG unitmask) -{ - char i; - for (i = 0; i < 26; ++i) - { - if (unitmask & 0x1) - break; - unitmask = unitmask >> 1; - } - return (i + 'A'); -} +char FirstDriveFromMask(ULONG unitmask) +{ + char i; + for (i = 0; i < 26; ++i) + { + if (unitmask & 0x1) + break; + unitmask = unitmask >> 1; + } + return (i + 'A'); +} void MinimizeToSysTray() { // Hide the window diff --git a/host-tools/detect-wikireader/src/check-wikireader.c b/host-tools/detect-wikireader/src/check-wikireader.c index 4d6470a6d..461aa6999 100644 --- a/host-tools/detect-wikireader/src/check-wikireader.c +++ b/host-tools/detect-wikireader/src/check-wikireader.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify @@ -95,7 +95,7 @@ int check_wikireader(char *path) int r; int file; - if ( (file = open(path, O_RDWR, + if ( (file = open(path, O_RDWR, S_IRUSR | S_IWUSR) ) < 0) { #ifdef WINDOWS #else diff --git a/host-tools/detect-wikireader/src/check-wikireader.h b/host-tools/detect-wikireader/src/check-wikireader.h index 5afc3aabe..aae5070bf 100644 --- a/host-tools/detect-wikireader/src/check-wikireader.h +++ b/host-tools/detect-wikireader/src/check-wikireader.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify diff --git a/host-tools/detect-wikireader/src/daemon.c b/host-tools/detect-wikireader/src/daemon.c index 9e30a50ad..a9f90dc0a 100644 --- a/host-tools/detect-wikireader/src/daemon.c +++ b/host-tools/detect-wikireader/src/daemon.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify @@ -38,7 +38,7 @@ static char *pid_file = RUNNING_DIR PID_FILE_NAME; int open_pid_file() { int fd = -1; - fd = open(pid_file, O_RDWR|O_CREAT, + fd = open(pid_file, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); @@ -90,7 +90,7 @@ int atou(const char *s, unsigned int *ret_u) { /* if (!x || *x || errno) { if (!errno) - errno = EINVAL; + errno = EINVAL; return -1; } */ @@ -139,12 +139,12 @@ int check_lock_file() lfp = open_pid_file(); if (lfp < 0) { - syslog(LOG_INFO, "can not open lock file."); + syslog(LOG_INFO, "can not open lock file."); return -1; } if (lockf(lfp, F_TLOCK, 0) < 0) { - syslog(LOG_INFO, "can not lock."); + syslog(LOG_INFO, "can not lock."); return -1; } @@ -155,43 +155,43 @@ int check_lock_file() return 0; } -int daemon_init(void) +int daemon_init(void) { - if (getppid() == 1) + if (getppid() == 1) return -1; /* already a daemon */ - /* Our process ID and Session ID */ - pid_t pid, sid; - - /* Fork off the parent process */ - pid = fork(); - if (pid < 0) { - exit(EXIT_FAILURE); - } - /* If we got a good PID, then - we can exit the parent process. */ - if (pid > 0) { - exit(EXIT_SUCCESS); - } - - /* Change the file mode mask */ - umask(0); - - /* Open any logs here */ - - /* Create a new SID for the child process */ - sid = setsid(); - if (sid < 0) { - /* Log the failure */ - exit(EXIT_FAILURE); - } - - /* Change the current working directory */ - if ((chdir(RUNNING_DIR)) < 0) { - /* Log the failure */ - exit(EXIT_FAILURE); - } - + /* Our process ID and Session ID */ + pid_t pid, sid; + + /* Fork off the parent process */ + pid = fork(); + if (pid < 0) { + exit(EXIT_FAILURE); + } + /* If we got a good PID, then + we can exit the parent process. */ + if (pid > 0) { + exit(EXIT_SUCCESS); + } + + /* Change the file mode mask */ + umask(0); + + /* Open any logs here */ + + /* Create a new SID for the child process */ + sid = setsid(); + if (sid < 0) { + /* Log the failure */ + exit(EXIT_FAILURE); + } + + /* Change the current working directory */ + if ((chdir(RUNNING_DIR)) < 0) { + /* Log the failure */ + exit(EXIT_FAILURE); + } + if ((check_lock_file()) < 0) { /* lock file file failure */ exit(EXIT_FAILURE); @@ -199,11 +199,11 @@ int daemon_init(void) /* close all descriptors */ int desc; - for (desc = getdtablesize(); desc >= 0; --desc) + for (desc = getdtablesize(); desc >= 0; --desc) close(desc); return 0; -} +} /* Kill a current running daemon. Return non-zero on success, -1 * otherwise. If successful *pid contains the PID of the daemon diff --git a/host-tools/detect-wikireader/src/daemon.h b/host-tools/detect-wikireader/src/daemon.h index dcb4b5cc3..f23eabd9f 100644 --- a/host-tools/detect-wikireader/src/daemon.h +++ b/host-tools/detect-wikireader/src/daemon.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify diff --git a/host-tools/detect-wikireader/src/log-message.c b/host-tools/detect-wikireader/src/log-message.c index 1305a159e..107bb3c9c 100644 --- a/host-tools/detect-wikireader/src/log-message.c +++ b/host-tools/detect-wikireader/src/log-message.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Op * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ #include -#define LOG_FILE_NAME ".det-wikird.log" +#define LOG_FILE_NAME ".det-wikird.log" static char* log_file; static int log_fp; @@ -36,21 +36,21 @@ int init_log_message(void) strcpy(log_file, home); strcat(log_file, LOG_FILE_NAME); - log_fp = open(log_file,O_CREAT, + log_fp = open(log_file,O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (log_fp < 0) { - syslog(LOG_INFO, "can not open log file."); + syslog(LOG_INFO, "can not open log file."); return -1; } return 0; -} +} int log_message(char *message) { - if (log_fp < 0) + if (log_fp < 0) return -1; fprintf(log_fp,"%s\n",message); diff --git a/host-tools/detect-wikireader/src/log-message.h b/host-tools/detect-wikireader/src/log-message.h index 3c147eba9..aaf867320 100644 --- a/host-tools/detect-wikireader/src/log-message.h +++ b/host-tools/detect-wikireader/src/log-message.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify diff --git a/host-tools/detect-wikireader/src/main.c b/host-tools/detect-wikireader/src/main.c index 8bb346d48..333847dd9 100644 --- a/host-tools/detect-wikireader/src/main.c +++ b/host-tools/detect-wikireader/src/main.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify @@ -33,7 +33,7 @@ #include "detect-wikireader-version.h" - + static int intervals = 1; /* default intervals is 1 second */ static char *monitor_dir = "/media"; /* check whick dirtory */ @@ -45,11 +45,11 @@ void signal_handler(int signo) syslog(LOG_INFO,"hangup signal catched"); break; case SIGTERM: - /* catched signal sent by kill(1) command */ + /* catched signal sent by kill(1) command */ syslog(LOG_INFO, "terminate signal catched"); - closelog(); + closelog(); close_monitor(); - exit(EXIT_SUCCESS); + exit(EXIT_SUCCESS); break; default: break; @@ -86,7 +86,7 @@ int main(int argc, char **argv) { int daemon = 0; - printf("det-wikird - (C) 2007-2008 by OpenMoko Inc.\n" + printf("det-wikird - (C) 2007-2008 by Openmoko Inc.\n" "This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n"); while (1) { @@ -127,37 +127,37 @@ int main(int argc, char **argv) } if (daemon) { - if (daemon_init() != 0) { - printf("can't fork self\n"); - exit(EXIT_FAILURE); - } + if (daemon_init() != 0) { + printf("can't fork self\n"); + exit(EXIT_FAILURE); + } } - openlog("openmoko-detect-wikireader", LOG_PID, LOG_USER); - syslog(LOG_INFO, "program started."); + openlog("openmoko-detect-wikireader", LOG_PID, LOG_USER); + syslog(LOG_INFO, "program started."); - /* arrange to catch the signal */ + /* arrange to catch the signal */ signal(SIGCHLD,SIG_IGN); /* ignore child */ signal(SIGTSTP,SIG_IGN); /* ignore tty signals */ signal(SIGTTOU,SIG_IGN); signal(SIGTTIN,SIG_IGN); signal(SIGHUP,signal_handler); /* catch hangup signal */ signal(SIGTERM,signal_handler); /* catch kill signal */ - - /* Daemon-specific initialization goes here */ + + /* Daemon-specific initialization goes here */ int rt; if ((rt = init_monitor(monitor_dir)) != 0) { - syslog(LOG_INFO, "init_monitor error: %d", rt); + syslog(LOG_INFO, "init_monitor error: %d", rt); exit(EXIT_SUCCESS); } - /* The Big Loop */ - while (1) { + /* The Big Loop */ + while (1) { /* Do some task here ... */ - run_monitor(); + run_monitor(); sleep(intervals); - } + } exit(EXIT_SUCCESS); } diff --git a/host-tools/detect-wikireader/src/wiki-inotify.c b/host-tools/detect-wikireader/src/wiki-inotify.c index 9643bbc31..6065e4096 100644 --- a/host-tools/detect-wikireader/src/wiki-inotify.c +++ b/host-tools/detect-wikireader/src/wiki-inotify.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify @@ -67,25 +67,25 @@ int run_monitor(void) if ( return_value < 0 ) { /* Error */ syslog(LOG_INFO, "select erro."); - } + } else if ( ! return_value ) { /* Timeout */ - } + } else if ( FD_ISSET ( fd, &descriptors ) ) { /* Process the inotify events */ syslog(LOG_INFO, "data."); - int length = read( fd, buffer, BUF_LEN ); + int length = read( fd, buffer, BUF_LEN ); if ( length < 0 ) { syslog(LOG_INFO, "read error."); return -1; - } + } struct inotify_event *event = ( struct inotify_event * ) &buffer[ 0 ]; if ( event->len ) { if ( event->mask & IN_CREATE ) { if ( event->mask & IN_ISDIR ) { - syslog(LOG_INFO, "The directory %s was created.\n", event->name ); + syslog(LOG_INFO, "The directory %s was created.\n", event->name ); strcpy(path, monitor_dir); strcat(path, "/"); strcat(path, event->name); @@ -97,7 +97,7 @@ int run_monitor(void) } else if ( event->mask & IN_DELETE ) { if ( event->mask & IN_ISDIR ) { - syslog(LOG_INFO, "The directory %s was deleted.\n", event->name ); + syslog(LOG_INFO, "The directory %s was deleted.\n", event->name ); } else { syslog(LOG_INFO, "The file %s was deleted.\n", event->name ); } diff --git a/host-tools/detect-wikireader/src/wiki-inotify.h b/host-tools/detect-wikireader/src/wiki-inotify.h index a682010ad..d97ae433c 100644 --- a/host-tools/detect-wikireader/src/wiki-inotify.h +++ b/host-tools/detect-wikireader/src/wiki-inotify.h @@ -1,5 +1,5 @@ /* - * (C) Copyright 2008 OpenMoko, Inc. + * (C) Copyright 2008 Openmoko, Inc. * Author: xiangfu liu * * This program is free software: you can redistribute it and/or modify diff --git a/host-tools/wiki-xml/main.c b/host-tools/wiki-xml/main.c index 0a6019b9e..85e6893c7 100644 --- a/host-tools/wiki-xml/main.c +++ b/host-tools/wiki-xml/main.c @@ -1,6 +1,5 @@ /* - * (C) Copyright 2009 OpenMoko, Inc. - * Author: Christopher Hall + * (C) Copyright 2009 Openmoko, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,9 +17,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -30,7 +29,7 @@ #include "wiki_render.h" char *framebuffer; -unsigned char *article_buf_pointer; +unsigned char *article_buf_pointer; void fb_refresh(void) {} @@ -96,7 +95,7 @@ void showMsg(int currentLevel, char *format, ...) return; //printf("[%ld]", clock()); - va_start(ap, format); + va_start(ap, format); vprintf(format, ap); va_end(ap); } @@ -106,7 +105,7 @@ void init_bigram_table(MYSQL *conn) char sSQL[MAX_SQL_STR]; int rc; char c1, c2; - + mysql_query(conn, "delete from bigram"); mysql_query(conn, "alter table bigram AUTO_INCREMENT=1"); mysql_commit(conn); @@ -182,7 +181,7 @@ void add_idx_to_range(long idx, long *idx_range_count, long idx_range[MAX_IDX_RA { int nMatch = -1; int i; - + for (i = 0; i < *idx_range_count && nMatch < 0; i++) { if (idx < idx_range[i][0]) @@ -219,7 +218,7 @@ void add_idx_to_range(long idx, long *idx_range_count, long idx_range[MAX_IDX_RA idx_range[*idx_range_count][1] = idx; *idx_range_count = *idx_range_count + 1; } - } + } } #define MAX_FILE_PER_FOLDER 100 @@ -227,7 +226,7 @@ void add_file_name(long name, char type, long file_names[MAX_FILE_PER_FOLDER], c { int i; int nMatch = -1; - + for (i = 0; i < *file_count && nMatch < 0; i++) if (name < file_names[i]) nMatch = i; @@ -248,35 +247,35 @@ void add_file_name(long name, char type, long file_names[MAX_FILE_PER_FOLDER], c file_types[*file_count] = type; *file_count = *file_count + 1; } - } -} + } +} void count_files(char *dir, long *idx_range_count, long idx_range[MAX_IDX_RANGE][2], long *max_file_size) { - struct dirent *de = NULL; + struct dirent *de = NULL; DIR *d = NULL; char path[256]; long file_names[MAX_FILE_PER_FOLDER]; char file_types[MAX_FILE_PER_FOLDER]; int file_count = 0; - int i; + int i; struct stat file_stat; - - d = opendir(dir); - if(d == NULL) + + d = opendir(dir); + if(d == NULL) return; - - // Loop while not NULL + + // Loop while not NULL while ((de = readdir(d)) != NULL) - { + { if (de->d_name[0] != '.') { add_file_name(atol(de->d_name), de->d_type, file_names, file_types, &file_count); } } - + for (i = 0; i < file_count; i++) - { + { if (file_types[i] == DT_DIR) { sprintf(path, "%s/%ld", dir, file_names[i]); @@ -292,7 +291,7 @@ void count_files(char *dir, long *idx_range_count, long idx_range[MAX_IDX_RANGE] } } - closedir(d); + closedir(d); } MYSQL *g_conn; @@ -325,7 +324,7 @@ int main(int argc, char **argv) time_t t; nMsgLevel = 0; - printf("wiki-xml-parser - (C) 2009 by OpenMoko Inc.\n" + printf("wiki-xml-parser - (C) 2009 by Openmoko Inc.\n" "This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n"); if (argc <2) @@ -447,7 +446,7 @@ int main(int argc, char **argv) showMsg(0, "Error connecting DB %s/%s using %s/%s\n", sServer, sDB, sId, sPassword); exit(1); } - + if (pass==0) { if (sTitle[0]) @@ -463,7 +462,7 @@ int main(int argc, char **argv) showMsg(0, "query entries error - %d (%s)\n", rc, mysql_error(conn)); exit(1); } - + res = mysql_use_result(conn); if ((row = mysql_fetch_row(res)) != NULL) { @@ -472,7 +471,7 @@ int main(int argc, char **argv) long nTextLen; char buf[1025]; int len; - + if (!row[1]) { if (row[4]) @@ -510,7 +509,7 @@ int main(int argc, char **argv) long count = 0; int i; long max_file_size = 0; - + count_files("./dat", &idx_range_count, idx_range, &max_file_size); for (i = 0; i < idx_range_count; i++) { @@ -520,7 +519,7 @@ int main(int argc, char **argv) showMsg(0, "Total file count: %ld, Max file size: %ld\n", count, max_file_size); exit(0); } - + rc = mysql_query(conn, "select idx from entries order by idx desc limit 1"); res = mysql_use_result(conn); if ((row = mysql_fetch_row(res)) != NULL && row[0]) @@ -587,8 +586,8 @@ int main(int argc, char **argv) init_bigram_table(conn); } } - - time(&t); + + time(&t); showMsg(0, "start pass %d - %s\n", pass, ctime(&t)); if (pass == 1) { @@ -629,7 +628,7 @@ int main(int argc, char **argv) /* close connection */ mysql_close(conn); mysql_close(g_conn); - + exit(0); } diff --git a/samo-lib/mbr/memory-test.c b/samo-lib/mbr/memory-test.c index b152b0e22..a1afb1248 100644 --- a/samo-lib/mbr/memory-test.c +++ b/samo-lib/mbr/memory-test.c @@ -1,7 +1,7 @@ // taken from Qi boot loader /* - * (C) Copyright 2007 OpenMoko, Inc. + * (C) Copyright 2007 Openmoko, Inc. * Author: Andy Green * * Memory test routines