void PrintHelp ( const InfoUI_t * iu, // valid pointer FILE * f, // valid output stream int indent, // indent of output ccp help_cmd, // NULL or name of help command ccp info // NULL or additional text ) { int cmd = 0; if (iu->n_cmd) { char buf[100]; ParamList_t * param; for ( param = first_param; param; param = param->next ) if ( param->arg && *param->arg ) { int cmd_stat; const CommandTab_t * ct = ScanCommand(&cmd_stat,param->arg,iu->cmd_tab); if (ct) cmd = ct->id; else { StringCat2S(buf,sizeof(buf),"+",param->arg); ct = ScanCommand(&cmd_stat,buf,iu->cmd_tab); if (ct) cmd = ct->id; } break; } } PrintHelpCmd(iu,f,indent,cmd,help_cmd,info); }
enumError cmd_info() { static const CommandTab_t cmdtab[] = { { INFO__ALL, "ALL", 0, 0 }, { INFO_IMAGE_FORMAT, "IMAGE-FORMATS", "IMAGEFORMATS", 0 }, { INFO_IMAGE_FORMAT, "FILE-FORMATS", "FORMATS", 0 }, { 0,0,0,0 } }; u32 keys = 0; ParamList_t * param; for ( param = first_param; param; param = param->next ) { ccp arg = param->arg; if ( !arg || !*arg ) continue; const CommandTab_t * cmd = ScanCommand(0,arg,cmdtab); if (!cmd) return ERROR0(ERR_SYNTAX,"Unknown keyword: %s\n",arg); keys |= cmd->id; } if (!keys) keys = INFO__ALL; if (print_sections) { printf("\n[INFO]\n"); ccp text = "infos-avail="; const CommandTab_t * cptr; for ( cptr = cmdtab + 1; cptr->name1; cptr++ ) { printf("%s%s",text,cptr->name1); text = " "; } putchar('\n'); text = "infos="; for ( cptr = cmdtab + 1; cptr->name1; cptr++ ) { if ( cptr->id & keys ) { printf("%s%s",text,cptr->name1); text = " "; } } putchar('\n'); } if ( keys & INFO_IMAGE_FORMAT ) info_image_formats(); putchar('\n'); return ERR_OK; }
enumError cmd_features() { uint n_supported = 0, n_total = 0; ParamList_t * param; for ( param = first_param; param; param = param->next ) { ccp arg = param->arg; if ( !arg || !*arg ) continue; int cmd_stat; const CommandTab_t * cmd = ScanCommand(&cmd_stat,arg,feature_tab); if ( !cmd || cmd_stat ) { n_total++; if ( verbose > 0 ) printf("? Unknown feature: %s.\n",arg); continue; } if ( cmd->id == FEAT__ALL ) check_all_features(&n_supported,&n_total); else { n_total++; if (check_feature(cmd->id)) n_supported++; } } if (!n_total) check_all_features(&n_supported,&n_total); if ( n_supported == n_total ) { if ( verbose >= -1 ) { if ( n_total == 1 ) printf("> Exit status 0: The requested features is supported.\n"); else printf("> Exit status 0: All %u requested features are supported.\n", n_total); } return 0; } if ( !n_supported ) { if ( verbose >= -1 ) { if ( n_total == 1 ) printf("> Exit status 2: The requested features is not supported.\n"); else printf("> Exit status 2: All %u requested features are not supported.\n", n_total); } return 2; } if ( verbose >= -1 ) printf("> Exit status 1: %u of %u requested features are supported.\n", n_supported, n_total ); return 1; }
int main ( int argc, char ** argv ) { printf("***** %s *****\n",TITLE); SetupLib(argc,argv,NAME,PROG_UNKNOWN); printf("term width = %d\n",GetTermWidth(80,0)); #ifdef HAVE_FIEMAP printf("* HAVE_FIEMAP defined!\n"); #endif #ifdef FS_IOC_FIEMAP printf("* FS_IOC_FIEMAP defined!\n"); #endif #if defined(TEST) && defined(DEBUG) if (0) { id6_t * id6 = (id6_t*)iobuf; PRINT("sizeof(id6_t)=%zd, %p,%p,%p -> %zu,%zu,%zu\n", sizeof(id6_t), id6, id6+1, id6+2, (ccp)id6-iobuf, (ccp)(id6+1)-iobuf, (ccp)(id6+2)-iobuf ); } #endif if ( argc < 2 ) help_exit(); int cmd_stat; const CommandTab_t * cmd_ct = ScanCommand(&cmd_stat,argv[1],CommandTab); if (!cmd_ct) { PrintCommandError(CommandTab,argv[1],cmd_stat,0); help_exit(); } argv[1] = argv[0]; argv++; argc--; switch(cmd_ct->id) { case CMD_TEST: return test(argc,argv); break; case CMD_FILENAME: test_filename(argc,argv); break; case CMD_MATCH_PATTERN: test_match_pattern(argc,argv); break; case CMD_OPEN_DISC: test_open_disc(argc,argv); break; case CMD_HEXDUMP: test_hexdump(argc,argv); break; #ifdef HAVE_OPENSSL case CMD_SHA1: test_sha1(); break; #endif #ifndef NO_BZIP2 case CMD_BZIP2: test_bzip2(argc,argv); break; #endif #ifdef HAVE_WORK_DIR case CMD_WIIMM: test_wiimm(argc,argv); break; #endif case CMD_DEVELOP: develop(argc,argv); break; //case CMD_HELP: default: help_exit(); } CloseAll(); if (SIGINT_level) ERROR0(ERR_INTERRUPT,"Program interrupted by user."); return max_error; }