virtual_query.h

Windows消息处理与资源定义
本文介绍了Windows应用程序中消息处理函数WndProc及对话框过程函数About的声明方式,并展示了资源标识符的定义方法,包括退出命令IDM_EXIT、测试命令IDM_TEST及关于对话框命令IDM_ABOUT。

  name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5572165936844014&dt=1194442938015&lmt=1194190197&format=336x280_as&output=html&correlator=1194442937843&url=file%3A%2F%2F%2FC%3A%2FDocuments%2520and%2520Settings%2Flhh1%2F%E6%A1%8C%E9%9D%A2%2FCLanguage.htm&color_bg=FFFFFF&color_text=000000&color_link=000000&color_url=FFFFFF&color_border=FFFFFF&ad_type=text&ga_vid=583001034.1194442938&ga_sid=1194442938&ga_hid=1942779085&flash=9&u_h=768&u_w=1024&u_ah=740&u_aw=1024&u_cd=32&u_tz=480&u_java=true" frameborder="0" width="336" scrolling="no" height="280" allowtransparency="allowtransparency"> #define IDM_EXIT           100
#define IDM_TEST           200
#define IDM_ABOUT          301

LRESULT CALLBACK WndProc  (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About    (HWND, UINT, WPARAM, LPARAM);

char *cmlsh_filename_completion_function(const char *text, int state) { char current_dir[PATH_MAX]; char abs_path[PATH_MAX]; int is_prefix_of_existing = 0; int should_reset = 0; struct stat st; int flash_len = NOS_CMLSH_FLASH_DIR_LEN; int is_flash_mode = (strncmp(text, NOS_CMLSH_FLASH_DIR, flash_len) == 0); int is_flash_prefix = (strncmp(NOS_CMLSH_FLASH_DIR, text, strlen(text)) == 0) && (strlen(text) < flash_len); const char *compare_text = text; if (is_flash_mode && strncmp(text, NOS_CMLSH_FLASH_DIR, flash_len) == 0) { compare_text = text + flash_len; } const char *slash = strrchr(compare_text, '/'); const char *base = slash ? (slash + 1) : compare_text; int base_len = strlen(base); if (comp_state.matches && comp_state.count > 0 && base_len > 0) { int all_match = 1; for (int i = 0; i < comp_state.count; i++) { if (comp_state.matches[i] == NULL) continue; if (strncmp(comp_state.matches[i], base, base_len) != 0) { all_match = 0; break; } } is_prefix_of_existing = all_match; } else { is_prefix_of_existing = 0; } getcwd(current_dir, sizeof(current_dir)); if (is_flash_mode) { char flash_path[PATH_MAX]; snprintf(flash_path, sizeof(flash_path), "%s%s", NOS_CMLSH_HOME_DIR, text + flash_len); snprintf(abs_path, sizeof(abs_path), "%s", flash_path); } else { snprintf(abs_path, sizeof(abs_path), "%s/%s", current_dir, text); } should_reset = !comp_state.initialized || comp_state.matches == NULL || (!is_prefix_of_existing && access(abs_path, F_OK) != 0) || (comp_state.count == 1 && stat(abs_path, &st) == 0 && S_ISDIR(st.st_mode)) || (comp_state.count == 0 && stat(abs_path, &st) == 0 && S_ISDIR(st.st_mode)) || (comp_state.current_text && strlen(text) < strlen(comp_state.current_text)); if (comp_state.matches && comp_state.count == 1 && stat(abs_path, &st) == 0 && !S_ISDIR(st.st_mode)) { comp_state.initialized = 0; return NULL; } if (should_reset) { char *saved_last_prefix = NULL; char *saved_base_dir = NULL; int saved_flash_mode = comp_state.flash_mode; if (comp_state.last_prefix) { saved_last_prefix = XSTRDUP(MTYPE_TMP, comp_state.last_prefix); } if (comp_state.base_dir) { saved_base_dir = XSTRDUP(MTYPE_TMP, comp_state.base_dir); } cmlsh_reset_completion_state(); char *current_base = NULL; char *current_prefix = NULL; int current_level = 0; cmlsh_parse_input_text(text, &current_base, &current_prefix, &current_level); if (saved_last_prefix) { comp_state.last_prefix = saved_last_prefix; } else { comp_state.last_prefix = NULL; } if (saved_base_dir) { comp_state.base_dir = saved_base_dir; } else { comp_state.base_dir = NULL; } const char *use_prefix = current_prefix; if ((current_prefix == NULL || *current_prefix == '\0') && comp_state.last_prefix && comp_state.last_prefix[0] != '\0' && comp_state.base_dir && current_base && strcmp(comp_state.base_dir, current_base) == 0) { use_prefix = comp_state.last_prefix; } if (comp_state.base_dir == NULL || strcmp(comp_state.base_dir, current_base) != 0) { if (comp_state.base_dir) { XFREE(MTYPE_TMP, comp_state.base_dir); } comp_state.base_dir = XSTRDUP(MTYPE_TMP, current_base); } comp_state.flash_mode = saved_flash_mode; comp_state.current_level = current_level; comp_state.current_text = XSTRDUP(MTYPE_TMP, text); if (is_flash_mode) { const char *rel_path = comp_state.base_dir + flash_len; int needed = NOS_CMLSH_HOME_DIR_LEN + strlen(rel_path) + 2; char *actual_path = XCALLOC(MTYPE_TMP, needed); snprintf(actual_path, needed, "%s%s", NOS_CMLSH_HOME_DIR, rel_path); if (actual_path[strlen(actual_path) - 1] != '/') { actual_path = XREALLOC(MTYPE_TMP, actual_path, strlen(actual_path) + 2); strcat(actual_path, "/"); } comp_state.matches = cmlsh_generate_current_dir_paths(actual_path, use_prefix, current_level == 0); XFREE(MTYPE_TMP, actual_path); } else if (is_flash_prefix) { comp_state.matches = cmlsh_generate_current_dir_paths(current_base, use_prefix, 1); int count = 0; if (comp_state.matches) { while (comp_state.matches[count]) count++; } else { comp_state.matches = XCALLOC(MTYPE_TMP, 2 * sizeof(char*)); } int found = 0; for (int i = 0; i < count; i++) { if (strcmp(comp_state.matches[i], NOS_CMLSH_FLASH_DIR) == 0) { found = 1; break; } } if (!found) { comp_state.matches = XREALLOC(MTYPE_TMP, comp_state.matches, (count + 2) * sizeof(char*)); comp_state.matches[count] = XSTRDUP(MTYPE_TMP, NOS_CMLSH_FLASH_DIR); comp_state.matches[count + 1] = NULL; } comp_state.count = count + (found ? 0 : 1); } else { comp_state.matches = cmlsh_generate_current_dir_paths(current_base, use_prefix, current_level == 0); } if (current_prefix && *current_prefix) { if (comp_state.last_prefix) { XFREE(MTYPE_TMP, comp_state.last_prefix); } comp_state.last_prefix = XSTRDUP(MTYPE_TMP, current_prefix); } comp_state.count = 0; if (comp_state.matches) { while (comp_state.matches[comp_state.count]) { comp_state.count++; } } comp_state.last_state = -1; comp_state.initialized = 1; } if (!comp_state.matches || comp_state.count == 0) { comp_state.initialized = 0; return NULL; } int next_index = (comp_state.last_state + 1) % comp_state.count; comp_state.last_state = next_index; if (comp_state.count == 1) { next_index = 0; } char *match = comp_state.matches[next_index]; char *full_path = NULL; if (strcmp(match, NOS_CMLSH_FLASH_DIR) == 0) { full_path = XSTRDUP(MTYPE_TMP, NOS_CMLSH_FLASH_DIR); } else if (comp_state.flash_mode) { char *virtual_base = comp_state.base_dir; char *virtual_path = NULL; if (virtual_base && strlen(virtual_base) > 0) { int base_len = strlen(virtual_base); int needs_slash = (base_len > 0 && virtual_base[base_len - 1] != '/'); virtual_path = XCALLOC(MTYPE_TMP, base_len + strlen(match) + 2); if (needs_slash) { snprintf(virtual_path, base_len + strlen(match) + 2, "%s/%s", virtual_base, match); } else { snprintf(virtual_path, base_len + strlen(match) + 1, "%s%s", virtual_base, match); } } else { virtual_path = XSTRDUP(MTYPE_TMP, match); } full_path = virtual_path; } else { if (comp_state.base_dir && strlen(comp_state.base_dir) > 0) { int base_len = strlen(comp_state.base_dir); int needs_slash = (base_len > 0 && comp_state.base_dir[base_len - 1] != '/'); full_path = XCALLOC(MTYPE_TMP, base_len + strlen(match) + 2); if (needs_slash) { snprintf(full_path, base_len + strlen(match) + 2, "%s/%s", comp_state.base_dir, match); } else { snprintf(full_path, base_len + strlen(match) + 1, "%s%s", comp_state.base_dir, match); } } else { full_path = XSTRDUP(MTYPE_TMP, match); } } return full_path; } char **cmlsh_filename_completion_matches(const char text, CPFunction genfunc) { if (text == NULL || *text == ‘\0’) { comp_state.initialized = 0; return NULL; } char *match = (*genfunc)(text, 0); if (!match) { return NULL; } char **matches = (char **)XCALLOC(MTYPE_TMP, 2 * sizeof(char *)); matches[0] = match; matches[1] = NULL; return matches; } char** cmlsh_completion(char* text, int start, int end) { char** matches; char** filename_matches = NULL; int is_fs_command = 0; int fs_cmd_len = 0; int i; const LineInfo* li; li = el_line(e); rl_line_buffer = (char*)li->buffer; rl_end = li->lastchar - li->buffer; rl_line_buffer[rl_end] = '\0'; matches = completion_matches(text, cmlsh_completion_matches); for (i = 0; cmlsh_fs_commands[i]; i++) { int len = strlen(cmlsh_fs_commands[i]); if (strncmp(rl_line_buffer, cmlsh_fs_commands[i], len) == 0 && (rl_line_buffer[len] == ' ' || rl_line_buffer[len] == '\0')) { is_fs_command = 1; fs_cmd_len = len; break; } } if (!matches || !matches[0]) { if (matches) { for (i = 0; matches[i]; i++) { XFREE(MTYPE_TMP,matches[i]); } XFREE(MTYPE_TMP,matches); matches = NULL; } if (is_fs_command && start > fs_cmd_len) { filename_matches = cmlsh_filename_completion_matches(text, cmlsh_filename_completion_function); } if (!filename_matches || !filename_matches[0]) { return NULL; } #if 1 int matches_num, maxlen, match_len, match_display = 1; for (i = 0, maxlen = 0; comp_state.matches[i]; i++) { match_len = strlen(comp_state.matches[i]); if (match_len > maxlen) maxlen = match_len; } matches_num = i; printf("\n"); if (match_display) rl_display_match_list_tmp(comp_state.matches, matches_num, maxlen); #endif return NULL; } return matches; } 在这个基础上优化成linux原生的补全效果,不要另写钩子函数
最新发布
08-27
qwe123@qwe123-virtual-machine:~/CLionProjects/C_code/BDZ_hash$ gcc -O3 bdz_hash.c -lcmph -o bdz_hash bdz_hash.c:8:5: error: unknown type name ‘uint32_t’ 8 | uint32_t dist1; | ^~~~~~~~ bdz_hash.c:9:5: error: unknown type name ‘uint32_t’ 9 | uint32_t dist2; | ^~~~~~~~ bdz_hash.c:10:5: error: unknown type name ‘uint32_t’ 10 | uint32_t dist3; | ^~~~~~~~ bdz_hash.c:14:5: error: unknown type name ‘uint32_t’ 14 | uint32_t star_id1; | ^~~~~~~~ bdz_hash.c:15:5: error: unknown type name ‘uint32_t’ 15 | uint32_t star_id2; | ^~~~~~~~ bdz_hash.c:16:5: error: unknown type name ‘uint32_t’ 16 | uint32_t star_id3; | ^~~~~~~~ bdz_hash.c:17:5: error: unknown type name ‘uint32_t’ 17 | uint32_t dist1; | ^~~~~~~~ bdz_hash.c:18:5: error: unknown type name ‘uint32_t’ 18 | uint32_t dist2; | ^~~~~~~~ bdz_hash.c:19:5: error: unknown type name ‘uint32_t’ 19 | uint32_t dist3; | ^~~~~~~~ bdz_hash.c: In function ‘read_features’: bdz_hash.c:37:9: error: unknown type name ‘uint32_t’ 37 | uint32_t s1, s2, s3, d1, d2, d3; | ^~~~~~~~ bdz_hash.c:5:1: note: ‘uint32_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’? 4 | #include <cmph.h> +++ |+#include <stdint.h> 5 | bdz_hash.c: In function ‘build_bdz_mphf’: bdz_hash.c:59:56: warning: passing argument 1 of ‘cmph_io_vector_adapter’ from incompatible pointer type [-Wincompatible-pointer-types] 59 | cmph_io_adapter_t* source = cmph_io_vector_adapter((char*)keys, sizeof(FeatureKey), n); | ^~~~~~~~~~~ | | | char * In file included from bdz_hash.c:4: /usr/local/include/cmph.h:34:51: note: expected ‘char **’ but argument is of type ‘char *’ 34 | cmph_io_adapter_t *cmph_io_vector_adapter(char ** vector, cmph_uint32 nkeys); | ~~~~~~~~^~~~~~ bdz_hash.c:59:33: error: too many arguments to function ‘cmph_io_vector_adapter’ 59 | cmph_io_adapter_t* source = cmph_io_vector_adapter((char*)keys, sizeof(FeatureKey), n); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from bdz_hash.c:4: /usr/local/include/cmph.h:34:20: note: declared here 34 | cmph_io_adapter_t *cmph_io_vector_adapter(char ** vector, cmph_uint32 nkeys); | ^~~~~~~~~~~~~~~~~~~~~~ bdz_hash.c: At top level: bdz_hash.c:83:18: error: unknown type name ‘uint32_t’ 83 | uint32_t d1, uint32_t d2, uint32_t d3) { | ^~~~~~~~ bdz_hash.c:83:18: note: ‘uint32_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’? bdz_hash.c:83:31: error: unknown type name ‘uint32_t’ 83 | uint32_t d1, uint32_t d2, uint32_t d3) { | ^~~~~~~~ bdz_hash.c:83:31: note: ‘uint32_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’? bdz_hash.c:83:44: error: unknown type name ‘uint32_t’ 83 | uint32_t d1, uint32_t d2, uint32_t d3) { | ^~~~~~~~ bdz_hash.c:83:44: note: ‘uint32_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’? bdz_hash.c: In function ‘main’: bdz_hash.c:126:10: warning: implicit declaration of function ‘query_feature’ [-Wimplicit-function-declaration] 126 | if (!query_feature(mphf, hash_table, test_key.dist1, test_key.dist2, test_key.dist3)) { |
08-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值