コード例 #1
0
ファイル: hehe.C プロジェクト: cook-/Ve281
static Val* search_help(Node<Key,Val>* node,Key key)
{
	if (!node) return NULL;
	if (key==*(node->lkey)) return node->lval;
	if ((node->rkey!=NULL)&&(key==*(node->rkey))) return node->rval;
	if (IsThreeNode(node)) {
		if (key<*(node->lkey)) {
			return search_help(node->left,key);
		}else if (key>*(node->rkey)) {
			return search_help(node->right,key);
		}else {
			return search_help(node->center,key);
		}
	}else {
		if (key<*(node->lkey)) {
			return search_help(node->left,key);
		} else {
			return search_help(node->center,key);
		}
	}
}
コード例 #2
0
ファイル: search.c プロジェクト: apcwowo/rop-tool
void search_cmd(int argc, char **argv) {
    r_binfmt_s bin;

    search_options_parse(argc, argv);

    r_binfmt_load(&bin, search_options_filename, search_options_arch);

    switch(search_options_mode) {
    case SEARCH_MODE_STRING_ALL:
        search_print_all_string_in_bin(&bin);
        break;

    case SEARCH_MODE_STRING_SPLIT:
        search_print_split_string_in_bin(&bin, search_options_string);
        break;

    case SEARCH_MODE_STRING:
        search_print_string_in_bin(&bin, search_options_string);
        break;

    case SEARCH_MODE_BYTE:
        search_print_numeric_in_bin(&bin, search_options_numeric, 1);
        break;

    case SEARCH_MODE_WORD:
        search_print_numeric_in_bin(&bin, search_options_numeric, 2);
        break;

    case SEARCH_MODE_DWORD:
        search_print_numeric_in_bin(&bin, search_options_numeric, 4);
        break;

    case SEARCH_MODE_QWORD:
        search_print_numeric_in_bin(&bin, search_options_numeric, 8);
        break;

    default:
        search_help();
        R_UTILS_ERR("I don't know what do you want searching !");
    }
}
コード例 #3
0
ファイル: help.c プロジェクト: quixadhal/discworld
int do_help(string str) {
  string filen, s;

  if (!str) {
    printf("General concepts:\n%-#*s\n", (int)this_player()->query_cols(),
           implode(delete(get_dir("/doc/concepts/*"), 0, 2), "\n"));
    printf("\nCommands:\n%-#*s\n", (int)this_player()->query_cols(),
           implode(delete(get_dir("/doc/helpdir/*"), 0, 2),"\n"));
    write("\nUsage : help <topic>\n");
    return 1;
  }
  filen = search_help(str);
  if (!filen)
    filen = create_help(str);
  if (!filen) {
    object *objs;
    int flag, loop;

    flag = 0;
    objs = find_match(str, this_player());
    if(!sizeof(objs)) {
      s = (string)SOUL_OB->help_soul(str);
      if (!s) {
        notify_fail("There is no help on "+str+" sorry.\n");
        return 0;
      }
      s = sprintf("%-=*s", this_player()->query_cols(), s);
      this_player()->set_finish_func("end_of_help");
      this_player()->more_string(s);
      return 1;
    }
    for(loop = 0; loop < sizeof(objs); loop++) {
      string text;

      if(text = (string)objs[loop]->get_help()) {
        this_player()->more_string("Help on "+(string)objs[loop]->query_name()+" :\n"+
          text+"\n","Help");
        flag = 1;
      }
    }
    if(!flag) {
      if(sizeof(objs) > 1)
        write("No help on those objects.\n");
      else
        write("No help on that object.\n");
    }
    return 1;
  }
  filen = (string)NROFF_HAND->cat_file(filen, 1);
  if (!filen) {
    filen = create_help(str);
    filen = (string)NROFF_HAND->cat_file(filen);
  }
  if (!filen) {
    notify_fail("Help file broken.  Please tell a creator.\n");
    log_file("HELP_FILES", "Help file "+str+" broken.\n");
    return 0;
  }
  this_player()->more_string(filen);
  return 1;
} /* do_help() */
コード例 #4
0
ファイル: search.c プロジェクト: apcwowo/rop-tool
/* Parse command line options */
void search_options_parse(int argc, char **argv) {
    int opt;

    const struct option opts[] = {
        {"all-string",    optional_argument, NULL, 'a'},
        {"byte",          required_argument, NULL, 'b'},
        {"bad",           required_argument, NULL, 'B'},
        {"dword",         required_argument, NULL, 'd'},
        {"help",          no_argument,       NULL, 'h'},
        {"no-color",      no_argument,       NULL, 'n'},
        {"qword",         required_argument, NULL, 'q'},
        {"raw",           no_argument,       NULL, 'r'},
        {"split-string",  required_argument, NULL, 's'},
        {"string",        required_argument, NULL, 'S'},
        {"word",          required_argument, NULL, 'w'},
        {NULL,            0,                 NULL, 0  }
    };

    while((opt = getopt_long(argc, argv, "a::b:B:d:hnq:rs:S:w:", opts, NULL)) != -1) {
        switch(opt) {

        case 'a':
            search_options_mode = SEARCH_MODE_STRING_ALL;
            if(optarg) search_options_strlen = strtoull(optarg, NULL, 0);
            if(search_options_strlen <= 0) R_UTILS_ERR("Bad argument for \"-a\" option ! Must be an integer > 0, e.g : -a5");
            break;
        case 'b':
            search_options_mode = SEARCH_MODE_BYTE;
            search_options_numeric = strtoull(optarg, NULL, 0);
            break;
        case 'B':
            search_options_bad = r_utils_bytes_unhexlify(optarg);
            break;
        case 'd':
            search_options_mode = SEARCH_MODE_DWORD;
            search_options_numeric = strtoull(optarg, NULL, 0);
            break;
        case 'h':
            search_help();
            exit(EXIT_FAILURE);
            break;
        case 'n':
            search_options_color = 0;
            break;
        case 'q':
            search_options_mode = SEARCH_MODE_QWORD;
            search_options_numeric = strtoull(optarg, NULL, 0);
            break;
        case 'r':
            search_options_arch = R_BINFMT_ARCH_X86;
            break;
        case 's':
            search_options_mode = SEARCH_MODE_STRING_SPLIT;
            search_options_string = r_utils_bytes_unhexlify(optarg);
            break;
        case 'S':
            search_options_mode = SEARCH_MODE_STRING;
            search_options_string = r_utils_bytes_unhexlify(optarg);
            break;
        case 'w':
            search_options_mode = SEARCH_MODE_WORD;
            search_options_numeric = strtoull(optarg, NULL, 0);
            break;

        default:
            search_help();
            exit(EXIT_FAILURE);
        }
    }

    if(optind < argc) {
        search_options_filename = argv[optind];
    }
}
コード例 #5
0
ファイル: hehe.C プロジェクト: cook-/Ve281
Val* Tree<Key,Val>::search(Key key) const
{
	return search_help(root,key);
}