Annotation of embedtools/src/updimg.c, revision 1.1.2.1
1.1.2.1 ! misho 1: #include "global.h"
! 2:
! 3:
! 4: sl_config cfg;
! 5: int Verbose, Mode;
! 6: char szImg[MAXPATHLEN], szDir[MAXPATHLEN];
! 7: extern char compiled[], compiledby[], compilehost[];
! 8:
! 9:
! 10: static void Usage()
! 11: {
! 12: printf( " Update Image tool for embedded systems on CompactFlash\n"
! 13: "=== %s === %s@%s ===\n\n"
! 14: " Syntax: updimg [-v] <modes> <image_name> [operate_dir]\n\n"
! 15: "\t-v\t\tVerbose ...\n\n"
! 16: "\t-a\t\tMake image active for next boot\n"
! 17: "\t-i\t\tInstall new image\n"
! 18: "\t-r\t\tRollback old backuped image\n"
! 19: "\t-b\t\tBackup image\n"
! 20: "\t-d\t\tClean backuped image\n"
! 21: "\n", compiled, compiledby, compilehost);
! 22: }
! 23:
! 24: // -----------------------------------
! 25:
! 26: int main(int argc, char **argv)
! 27: {
! 28: char ch;
! 29: int mode;
! 30:
! 31: while ((ch = getopt(argc, argv, "hvdbtair")) != -1)
! 32: switch (ch) {
! 33: case 'a':
! 34: Mode |= 0x1;
! 35: break;
! 36: case 't':
! 37: Mode |= 0x8;
! 38: break;
! 39: case 'r':
! 40: if (Mode & 0x2) {
! 41: printf("Error:: can`t set rollback mode because find set install ...\n");
! 42: return 1;
! 43: } else
! 44: Mode |= 0x4;
! 45: break;
! 46: case 'i':
! 47: if (Mode & 0x4) {
! 48: printf("Error:: can`t set install mode because find set rollback ...\n");
! 49: return 1;
! 50: } else
! 51: Mode |= 0x2;
! 52: break;
! 53: case 'b':
! 54: if (Mode & 0x20) {
! 55: printf("Error:: can`t set backup mode because find set clean ...\n");
! 56: return 1;
! 57: } else
! 58: Mode |= 0x10;
! 59: break;
! 60: case 'd':
! 61: if (Mode & 0x10) {
! 62: printf("Error:: can`t set clean mode because find set backup ...\n");
! 63: return 1;
! 64: } else
! 65: Mode |= 0x20;
! 66: break;
! 67: case 'v':
! 68: Verbose++;
! 69: break;
! 70: case 'h':
! 71: default:
! 72: Usage();
! 73: return 1;
! 74: }
! 75: argc -= optind;
! 76: argv += optind;
! 77: if (!Mode) {
! 78: printf("Error:: Mode not specified !!!\n\n");
! 79: Usage();
! 80: return 1;
! 81: }
! 82: if (!argc) {
! 83: printf("Error:: Image filename not specified !!!\n\n");
! 84: Usage();
! 85: return 1;
! 86: } else
! 87: strlcpy(szImg, *argv, MAXPATHLEN);
! 88: if (argc > 1) {
! 89: strlcpy(szDir, argv[1], MAXPATHLEN);
! 90: chdir(szDir);
! 91: VERB(5) printf("Info(5):: Change to dir %s\n", szDir);
! 92: }
! 93:
! 94: openlog("updimg", LOG_CONS, 0);
! 95: for (mode = 0x20; mode; mode >>= 1)
! 96: switch (Mode & mode) {
! 97: case 0x1:
! 98: Activate();
! 99: break;
! 100: case 0x2:
! 101: Install();
! 102: break;
! 103: case 0x4:
! 104: Rollback();
! 105: break;
! 106: case 0x8:
! 107: tFTP();
! 108: break;
! 109: case 0x10:
! 110: Backup();
! 111: break;
! 112: case 0x20:
! 113: Clean();
! 114: break;
! 115: }
! 116:
! 117: closelog();
! 118: return 0;
! 119: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>