--- embedtools/src/Attic/updimg.c 2009/11/13 13:55:28 1.1 +++ embedtools/src/Attic/updimg.c 2009/11/13 13:55:28 1.1.2.1 @@ -0,0 +1,119 @@ +#include "global.h" + + +sl_config cfg; +int Verbose, Mode; +char szImg[MAXPATHLEN], szDir[MAXPATHLEN]; +extern char compiled[], compiledby[], compilehost[]; + + +static void Usage() +{ + printf( " Update Image tool for embedded systems on CompactFlash\n" + "=== %s === %s@%s ===\n\n" + " Syntax: updimg [-v] [operate_dir]\n\n" + "\t-v\t\tVerbose ...\n\n" + "\t-a\t\tMake image active for next boot\n" + "\t-i\t\tInstall new image\n" + "\t-r\t\tRollback old backuped image\n" + "\t-b\t\tBackup image\n" + "\t-d\t\tClean backuped image\n" + "\n", compiled, compiledby, compilehost); +} + +// ----------------------------------- + +int main(int argc, char **argv) +{ + char ch; + int mode; + + while ((ch = getopt(argc, argv, "hvdbtair")) != -1) + switch (ch) { + case 'a': + Mode |= 0x1; + break; + case 't': + Mode |= 0x8; + break; + case 'r': + if (Mode & 0x2) { + printf("Error:: can`t set rollback mode because find set install ...\n"); + return 1; + } else + Mode |= 0x4; + break; + case 'i': + if (Mode & 0x4) { + printf("Error:: can`t set install mode because find set rollback ...\n"); + return 1; + } else + Mode |= 0x2; + break; + case 'b': + if (Mode & 0x20) { + printf("Error:: can`t set backup mode because find set clean ...\n"); + return 1; + } else + Mode |= 0x10; + break; + case 'd': + if (Mode & 0x10) { + printf("Error:: can`t set clean mode because find set backup ...\n"); + return 1; + } else + Mode |= 0x20; + break; + case 'v': + Verbose++; + break; + case 'h': + default: + Usage(); + return 1; + } + argc -= optind; + argv += optind; + if (!Mode) { + printf("Error:: Mode not specified !!!\n\n"); + Usage(); + return 1; + } + if (!argc) { + printf("Error:: Image filename not specified !!!\n\n"); + Usage(); + return 1; + } else + strlcpy(szImg, *argv, MAXPATHLEN); + if (argc > 1) { + strlcpy(szDir, argv[1], MAXPATHLEN); + chdir(szDir); + VERB(5) printf("Info(5):: Change to dir %s\n", szDir); + } + + openlog("updimg", LOG_CONS, 0); + for (mode = 0x20; mode; mode >>= 1) + switch (Mode & mode) { + case 0x1: + Activate(); + break; + case 0x2: + Install(); + break; + case 0x4: + Rollback(); + break; + case 0x8: + tFTP(); + break; + case 0x10: + Backup(); + break; + case 0x20: + Clean(); + break; + } + + closelog(); + return 0; +}