|
From: Erik M. <er...@us...> - 2001-09-16 15:44:02
|
Update of /cvsroot/blob/blob/src
In directory usw-pr-cvs1:/tmp/cvs-serv6125/src
Modified Files:
clock.c command.c main.c util.c uucodec.c
Log Message:
Cleanup: s/MyStrNCmp/strncmp/
Also had to add -fno-builtin to the compiler flags cause strncmp seems to be
a builtin function in gcc-3.0.
Index: clock.c
===================================================================
RCS file: /cvsroot/blob/blob/src/clock.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- clock.c 2001/08/06 22:44:52 1.2
+++ clock.c 2001/09/16 15:44:00 1.3
@@ -83,7 +83,7 @@
}
*value=0x00;
- if (MyStrNCmp(commandline, " 0x", 3) == 0) {
+ if (strncmp(commandline, " 0x", 3) == 0) {
commandline += 3;
} else if(commandline[0] == ' ') {
commandline += 1;
Index: command.c
===================================================================
RCS file: /cvsroot/blob/blob/src/command.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- command.c 2001/09/15 20:35:52 1.4
+++ command.c 2001/09/16 15:44:00 1.5
@@ -46,62 +46,58 @@
extern u32 __commandlist_end;
-#if 0
-/* the last command in the list */
-static commandlist_t __command last_command = {
- callback: NULL,
-};
-#endif
-
/* the first command */
static commandlist_t *commands;
static commandlist_t *lastcommand;
+
void init_commands(void)
{
- SerialOutputString("Command list start: 0x");
- SerialOutputHex((unsigned int) &__commandlist_start);
- SerialOutputString("\nCommand list end: 0x");
- SerialOutputHex((unsigned int) &__commandlist_end);
- SerialOutputByte('\n');
+ commandlist_t *cmd, *next_cmd;
commands = (commandlist_t *) &__commandlist_start;
lastcommand = (commandlist_t *) &__commandlist_end;
+
+ /* make a list */
+ /* FIXME: should sort the list in alphabetical order over here */
+ cmd = next_cmd = commands;
+ next_cmd++;
+
+ while(next_cmd < lastcommand) {
+ cmd->next = next_cmd;
+ cmd++;
+ next_cmd++;
+ }
}
+
+
+static int parse_args(char *cmdline, int *argc, char **argv)
+{
+
+}
+
+
+
+
int parse_command(char *cmdline)
{
commandlist_t *cmd;
int len;
-
- SerialOutputString("*** " __FUNCTION__ " called\n");
- for(cmd = commands; cmd != lastcommand; cmd++) {
+ for(cmd = commands; cmd != NULL; cmd = cmd->next) {
if(cmd->magic != COMMAND_MAGIC) {
SerialOutputString("*** Invalid command list entry\n");
return -1;
}
- if(cmd->callback == NULL) {
- SerialOutputString("*** No callback\n");
- continue;
- }
-
- SerialOutputString("\n*** Trying to match command '");
- SerialOutputString(cmd->name);
- SerialOutputString("'... ");
-
len = strlen(cmd->name);
- if(MyStrNCmp(cmd->name, cmdline, len) == 0) {
- SerialOutputString("yes\n");
-
+ if(strncmp(cmd->name, cmdline, len) == 0) {
/* call function */
return cmd->callback(1, cmdline);
- } else {
- SerialOutputString("no\n");
}
}
@@ -122,9 +118,20 @@
static char foohelp[] = "foo help";
__commandlist(foo, fooname, foohelp);
+
+
+
+static int bar(int argc, char *argv[])
+{
+ SerialOutputString("*** bar() got called!\n");
+ return 0;
+}
+
+
+__commandlist(bar, "bar", "bar help");
+
+
-/* the last command in the list */
-__commandlist(NULL, NULL, NULL);
Index: main.c
===================================================================
RCS file: /cvsroot/blob/blob/src/main.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- main.c 2001/09/15 20:14:23 1.9
+++ main.c 2001/09/16 15:44:00 1.10
@@ -180,28 +180,28 @@
numRead = GetCommand(commandline, 128, 600);
if(numRead > 0) {
- if(MyStrNCmp(commandline, "boot", 4) == 0) {
+ if(strncmp(commandline, "boot", 4) == 0) {
boot_linux(commandline + 4);
- } else if(MyStrNCmp(commandline, "clock", 5) == 0) {
+ } else if(strncmp(commandline, "clock", 5) == 0) {
SetClock(commandline + 5);
- } else if(MyStrNCmp(commandline, "download ", 9) == 0) {
+ } else if(strncmp(commandline, "download ", 9) == 0) {
Download(commandline + 9);
- } else if(MyStrNCmp(commandline, "flash ", 6) == 0) {
+ } else if(strncmp(commandline, "flash ", 6) == 0) {
Flash(commandline + 6);
- } else if(MyStrNCmp(commandline, "help", 4) == 0) {
+ } else if(strncmp(commandline, "help", 4) == 0) {
PrintHelp();
- } else if(MyStrNCmp(commandline, "reblob", 6) == 0) {
+ } else if(strncmp(commandline, "reblob", 6) == 0) {
Reblob();
- } else if(MyStrNCmp(commandline, "reboot", 6) == 0) {
+ } else if(strncmp(commandline, "reboot", 6) == 0) {
Reboot();
- } else if(MyStrNCmp(commandline, "reload ", 7) == 0) {
+ } else if(strncmp(commandline, "reload ", 7) == 0) {
Reload(commandline + 7);
- } else if(MyStrNCmp(commandline, "reset", 5) == 0) {
+ } else if(strncmp(commandline, "reset", 5) == 0) {
ResetTerminal();
- } else if(MyStrNCmp(commandline, "speed ", 6) == 0) {
+ } else if(strncmp(commandline, "speed ", 6) == 0) {
SetDownloadSpeed(commandline + 6);
}
- else if(MyStrNCmp(commandline, "status", 6) == 0) {
+ else if(strncmp(commandline, "status", 6) == 0) {
PrintStatus();
} else if(parse_command(commandline) != 0 ) {
SerialOutputString("*** Unknown command: ");
@@ -223,27 +223,27 @@
int bufLen;
int *numRead = 0;
- if(MyStrNCmp(commandline, "blob", 4) == 0) {
+ if(strncmp(commandline, "blob", 4) == 0) {
/* download blob */
startAddress = BLOB_RAM_BASE;
bufLen = blob_status.blockSize - BLOB_BLOCK_OFFSET;
numRead = &blob_status.blobSize;
blob_status.blobType = fromDownload;
#ifdef PARAM_START
- } else if(MyStrNCmp(commandline, "param", 5) == 0) {
+ } else if(strncmp(commandline, "param", 5) == 0) {
/* download kernel */
startAddress = PARAM_RAM_BASE;
bufLen = PARAM_LEN;
numRead = &blob_status.paramSize;
blob_status.paramType = fromDownload;
#endif
- } else if(MyStrNCmp(commandline, "kernel", 6) == 0) {
+ } else if(strncmp(commandline, "kernel", 6) == 0) {
/* download kernel */
startAddress = KERNEL_RAM_BASE;
bufLen = blob_status.blockSize - KERNEL_BLOCK_OFFSET;
numRead = &blob_status.kernelSize;
blob_status.kernelType = fromDownload;
- } else if(MyStrNCmp(commandline, "ramdisk", 7) == 0) {
+ } else if(strncmp(commandline, "ramdisk", 7) == 0) {
/* download ramdisk */
startAddress = RAMDISK_RAM_BASE;
bufLen = blob_status.blockSize - RAMDISK_BLOCK_OFFSET;
@@ -304,7 +304,7 @@
int numBytes = 0;
int maxSize = 0;
- if(MyStrNCmp(commandline, "blob", 4) == 0) {
+ if(strncmp(commandline, "blob", 4) == 0) {
startAddress = BLOB_RAM_BASE;
block = blBlob;
numBytes = blob_status.blobSize;
@@ -317,7 +317,7 @@
SerialOutputString("Saving blob to flash ");
#ifdef PARAM_START
- } else if(MyStrNCmp(commandline, "param", 5) == 0) {
+ } else if(strncmp(commandline, "param", 5) == 0) {
startAddress = PARAM_RAM_BASE;
block = blParam;
numBytes = blob_status.paramSize;
@@ -330,7 +330,7 @@
SerialOutputString("Saving paramater block to flash ");
#endif
- } else if(MyStrNCmp(commandline, "kernel", 6) == 0) {
+ } else if(strncmp(commandline, "kernel", 6) == 0) {
startAddress = KERNEL_RAM_BASE;
block = blKernel;
numBytes = blob_status.kernelSize;
@@ -342,7 +342,7 @@
}
SerialOutputString("Saving kernel to flash ");
- } else if(MyStrNCmp(commandline, "ramdisk", 7) == 0) {
+ } else if(strncmp(commandline, "ramdisk", 7) == 0) {
startAddress = RAMDISK_RAM_BASE;
block = blRamdisk;
numBytes = blob_status.ramdiskSize;
@@ -405,33 +405,33 @@
void SetDownloadSpeed(char *commandline)
{
- if(MyStrNCmp(commandline, "1200", 4) == 0) {
+ if(strncmp(commandline, "1200", 4) == 0) {
blob_status.downloadSpeed = baud1k2;
- } else if(MyStrNCmp(commandline, "1k2", 3) == 0) {
+ } else if(strncmp(commandline, "1k2", 3) == 0) {
blob_status.downloadSpeed = baud1k2;
- } else if(MyStrNCmp(commandline, "9600", 4) == 0) {
+ } else if(strncmp(commandline, "9600", 4) == 0) {
blob_status.downloadSpeed = baud9k6;
- } else if(MyStrNCmp(commandline, "9k6", 3) == 0) {
+ } else if(strncmp(commandline, "9k6", 3) == 0) {
blob_status.downloadSpeed = baud9k6;
- } else if(MyStrNCmp(commandline, "19200", 5) == 0) {
+ } else if(strncmp(commandline, "19200", 5) == 0) {
blob_status.downloadSpeed = baud19k2;
- } else if(MyStrNCmp(commandline, "19k2", 4) == 0) {
+ } else if(strncmp(commandline, "19k2", 4) == 0) {
blob_status.downloadSpeed = baud19k2;
- } else if(MyStrNCmp(commandline, "38400", 5) == 0) {
+ } else if(strncmp(commandline, "38400", 5) == 0) {
blob_status.downloadSpeed = baud38k4;
- } else if(MyStrNCmp(commandline, "38k4", 4) == 0) {
+ } else if(strncmp(commandline, "38k4", 4) == 0) {
blob_status.downloadSpeed = baud38k4;
- } else if(MyStrNCmp(commandline, "57600", 5) == 0) {
+ } else if(strncmp(commandline, "57600", 5) == 0) {
blob_status.downloadSpeed = baud57k6;
- } else if(MyStrNCmp(commandline, "57k6", 4) == 0) {
+ } else if(strncmp(commandline, "57k6", 4) == 0) {
blob_status.downloadSpeed = baud57k6;
- } else if(MyStrNCmp(commandline, "115200", 6) == 0) {
+ } else if(strncmp(commandline, "115200", 6) == 0) {
blob_status.downloadSpeed = baud115k2;
- } else if(MyStrNCmp(commandline, "115k2", 5) == 0) {
+ } else if(strncmp(commandline, "115k2", 5) == 0) {
blob_status.downloadSpeed = baud115k2;
- } else if(MyStrNCmp(commandline, "230400", 6) == 0) {
+ } else if(strncmp(commandline, "230400", 6) == 0) {
blob_status.downloadSpeed = baud230k4;
- } else if(MyStrNCmp(commandline, "230k4", 5) == 0) {
+ } else if(strncmp(commandline, "230k4", 5) == 0) {
blob_status.downloadSpeed = baud230k4;
} else {
SerialOutputString("*** Invalid download speed value \"");
@@ -536,7 +536,7 @@
u32 *dst = 0;
int numWords;
- if(MyStrNCmp(commandline, "blob", 4) == 0) {
+ if(strncmp(commandline, "blob", 4) == 0) {
src = (u32 *)BLOB_RAM_BASE;
dst = (u32 *)BLOB_START;
numWords = BLOB_LEN / 4;
@@ -544,7 +544,7 @@
blob_status.blobType = fromFlash;
SerialOutputString("Loading blob from flash ");
#ifdef PARAM_START
- } else if(MyStrNCmp(commandline, "param", 6) == 0) {
+ } else if(strncmp(commandline, "param", 6) == 0) {
src = (u32 *)PARAM_RAM_BASE;
dst = (u32 *)PARAM_START;
numWords = PARAM_LEN / 4;
@@ -552,14 +552,14 @@
blob_status.paramType = fromFlash;
SerialOutputString("Loading paramater block from flash ");
#endif
- } else if(MyStrNCmp(commandline, "kernel", 6) == 0) {
+ } else if(strncmp(commandline, "kernel", 6) == 0) {
src = (u32 *)KERNEL_RAM_BASE;
dst = (u32 *)KERNEL_START;
numWords = KERNEL_LEN / 4;
blob_status.kernelSize = 0;
blob_status.kernelType = fromFlash;
SerialOutputString("Loading kernel from flash ");
- } else if(MyStrNCmp(commandline, "ramdisk", 7) == 0) {
+ } else if(strncmp(commandline, "ramdisk", 7) == 0) {
src = (u32 *)RAMDISK_RAM_BASE;
dst = (u32 *)INITRD_START;
numWords = INITRD_LEN / 4;
Index: util.c
===================================================================
RCS file: /cvsroot/blob/blob/src/util.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- util.c 2001/08/07 17:36:48 1.3
+++ util.c 2001/09/16 15:44:00 1.4
@@ -91,7 +91,7 @@
-int MyStrNCmp(const char *s1, const char *s2, int maxlen)
+int strncmp(const char *s1, const char *s2, int maxlen)
{
int i;
@@ -103,29 +103,9 @@
}
return 0;
-} /* MyStrNCmp */
-
-
-
-
-int MyToUpper(int c)
-{
- if((c >= 'a') && (c <= 'z'))
- c += 'A' - 'a';
-
- return(c);
}
-
-
-int MyToLower(int c)
-{
- if((c >= 'A') && (c <= 'Z'))
- c += 'a' - 'A';
-
- return(c);
-}
int strlen(const char *s)
Index: uucodec.c
===================================================================
RCS file: /cvsroot/blob/blob/src/uucodec.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- uucodec.c 2001/08/06 22:44:52 1.2
+++ uucodec.c 2001/09/16 15:44:00 1.3
@@ -86,7 +86,7 @@
do {
SerialInputString(buf, sizeof(buf), 6);
TEST_MAX_RETRIES;
- } while (MyStrNCmp(buf, "begin ", 6) != 0);
+ } while (strncmp(buf, "begin ", 6) != 0);
/*
SerialOutputString("Bytes received : 0x00000000");
@@ -146,7 +146,7 @@
}
}
SerialOutputByte('\n');
- if (SerialInputString(p = buf, sizeof(buf), 2) == 0 || (MyStrNCmp(buf, "end", 3))) {
+ if (SerialInputString(p = buf, sizeof(buf), 2) == 0 || (strncmp(buf, "end", 3))) {
SerialOutputString("*** No \"end\" line. Aborting.\n");
return(-1);
}
|