/********************************************************************* * * SEGGER_RTT_WriteString * * Function description * Stores string in SEGGER RTT control block. * This data is read by the host. * * Parameters * BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). * s Pointer to string. * * Return value * Number of bytes which have been stored in the "Up"-buffer. * * Notes * (1) If there is not enough space in the "Up"-buffer, depending on configuration, * remaining characters may be dropped or RTT module waits until there is more space in the buffer. * (2) String passed to this function has to be \0 terminated * (3) \0 termination character is *not* stored in RTT buffer */ unsigned SEGGER_RTT_WriteString(unsigned BufferIndex, const char* s) { unsigned Len; Len = STRLEN(s); return SEGGER_RTT_Write(BufferIndex, s, Len); }
BOOL INSTAPI GetTranslator (HWND hwndParent, LPSTR lpszName, WORD cbNameMax, WORD * pcbNameOut, LPSTR lpszPath, WORD cbPathMax, WORD * pcbPathOut, DWORD * pvOption) { pConfigTranslatorFunc pConfigTranslator; pTrsChooseFunc pTrsChoose; BOOL retcode = FALSE, finish = FALSE; PCONFIG pCfg; UWORD configMode; RETCODE ret = SQL_NO_DATA; void *handle; char translator[1024]; #if defined (__APPLE__) && !defined (NO_FRAMEWORKS) CFBundleRef bundle = NULL; CFBundleRef bundle_dll = NULL; CFURLRef liburl; #endif do { /* Load the Admin dialbox function */ #if defined (__APPLE__) # if !defined(NO_FRAMEWORKS) bundle = CFBundleGetBundleWithIdentifier (CFSTR ("org.iodbc.core")); if (bundle) { /* Search for the iODBCadm library */ liburl = CFBundleCopyResourceURL (bundle, CFSTR ("iODBCadm.bundle"), NULL, NULL); if (liburl) { bundle_dll = CFBundleCreate (NULL, liburl); CFRelease (liburl); CALL_TRSCHOOSE_DIALBOX_BUNDLE (); } } # endif #else CALL_TRSCHOOSE_DIALBOX ("libiodbcadm.so.2"); #endif if (ret == SQL_NO_DATA) { if (pcbNameOut) *pcbNameOut = 0; if (pcbPathOut) *pcbPathOut = 0; finish = TRUE; } if (ret == SQL_SUCCESS) { STRNCPY (lpszName, translator + STRLEN ("TranslationName="), cbNameMax - 1); if (pcbNameOut) *pcbNameOut = STRLEN (lpszName); /* Get it from the user odbcinst file */ wSystemDSN = USERDSN_ONLY; if (!_iodbcdm_cfg_search_init (&pCfg, "odbcinst.ini", TRUE)) { if (!_iodbcdm_cfg_find (pCfg, (char *) lpszName, "Setup")) CALL_CONFIG_TRANSLATOR (pCfg->value); if (!_iodbcdm_cfg_find (pCfg, (char *) lpszName, "Translator")) CALL_CONFIG_TRANSLATOR (pCfg->value); if (!access (lpszName, X_OK)) CALL_CONFIG_TRANSLATOR (lpszName); if (!_iodbcdm_cfg_find (pCfg, "Default", "Setup")) CALL_CONFIG_TRANSLATOR (pCfg->value); if (!_iodbcdm_cfg_find (pCfg, "Default", "Translator")) CALL_CONFIG_TRANSLATOR (pCfg->value); } /* Get it from the system odbcinst file */ if (pCfg) { _iodbcdm_cfg_done (pCfg); pCfg = NULL; } wSystemDSN = SYSTEMDSN_ONLY; if (!_iodbcdm_cfg_search_init (&pCfg, "odbcinst.ini", TRUE)) { if (!_iodbcdm_cfg_find (pCfg, (char *) lpszName, "Setup")) CALL_CONFIG_TRANSLATOR (pCfg->value); if (!_iodbcdm_cfg_find (pCfg, (char *) lpszName, "Translator")) CALL_CONFIG_TRANSLATOR (pCfg->value); if (!access (lpszName, X_OK)) CALL_CONFIG_TRANSLATOR (lpszName); if (!_iodbcdm_cfg_find (pCfg, "Default", "Setup")) CALL_CONFIG_TRANSLATOR (pCfg->value); if (!_iodbcdm_cfg_find (pCfg, "Default", "Translator")) CALL_CONFIG_TRANSLATOR (pCfg->value); } /* The last ressort, a proxy driver */ CALL_CONFIG_TRANSLATOR ("libtranslator.so.2"); /* Error : ConfigDSN could no be found */ PUSH_ERROR (ODBC_ERROR_LOAD_LIB_FAILED); done: STRNCPY (lpszPath, pCfg->fileName, cbPathMax - 1); if (pcbPathOut) *pcbPathOut = STRLEN (lpszPath); _iodbcdm_cfg_done (pCfg); } } while (!finish); retcode = TRUE; wSystemDSN = USERDSN_ONLY; configMode = ODBC_BOTH_DSN; return retcode; }
VOID ACLStr::Append(IN LPCTSTR str) { _Concat(STRLEN(str), str); } // Append
void get_frame_place_mcode(int level, stack_mode_t mode, int cur_zlevel, mval *result) { int count; stack_frame *fp; unsigned char pos_str[MAX_ENTRYREF_LEN]; mval label; mval routine; int ips; int offset; int s1, s2; boolean_t indirect_frame; ihdtyp *irtnhdr; cache_entry *indce; INTPTR_T *vp; unsigned char *fpmpc; assert(DOLLAR_STACK_PLACE == mode || DOLLAR_STACK_MCODE == mode); assert(0 <= level); assert(level < cur_zlevel); count = cur_zlevel; for (fp = frame_pointer; ; fp = fp->old_frame_pointer) { if (NULL == fp->old_frame_pointer) { if (fp->type & SFT_TRIGR) /* Have a trigger baseframe, pick up stack continuation frame_pointer stored by base_frame() */ fp = *(stack_frame **)(fp + 1); else { /* Something wrong, just return null or assert if debug mode */ assert(FALSE); result->str.len = 0; return; } } assert(NULL != fp); if (!(fp->type & SFT_COUNT)) continue; count--; if (count == level) break; } fpmpc = fp->mpc; if (ADDR_IN_CODE(fpmpc, fp->rvector)) { result->str.addr = (char *)&pos_str[0]; result->str.len = INTCAST(symb_line(fpmpc, &pos_str[0], 0, fp->rvector) - &pos_str[0]); indirect_frame = FALSE; } else { indirect_frame = TRUE; pos_str[0] = '@'; result->str.addr = (char *)&pos_str[0]; result->str.len = 1; } if (DOLLAR_STACK_PLACE == mode) { if (result->str.len) { s2pool(&result->str); assert(((unsigned char *)result->str.addr + result->str.len) == stringpool.free); } } if (DOLLAR_STACK_MCODE == mode) { if (!indirect_frame) { if (IS_GTM_IMAGE || (0 < level)) { label.mvtype = MV_STR; routine.mvtype = MV_STR; result->mvtype = MV_STR; label.str.len = result->str.len; label.str.addr = (char *)&pos_str[0]; routine.str.len = 0; for (ips = 0, s1 = s2 = -1; ips < result->str.len; ips++) { if ('+' == pos_str[ips]) { assert((-1 == s1) && (-1 == s2)); s1 = ips; } if ('^' == pos_str[ips]) { s2 = ips; break; } } if (s2 >= 0) { routine.str.addr = (char *)&pos_str[s2 + 1]; routine.str.len = result->str.len - s2 - 1; label.str.len = s2; } offset = 0; if (s1 >= 0) { label.str.len = s1; if (s2 < 0) s2 = result->str.len; for (ips = s1 + 1; ips < s2; ips++) offset = offset * 10 + pos_str[ips] - '0'; } op_fntext(&label, offset, &routine, result); } else { /* Utility base frame does not have source code */ result->str.addr = UTIL_BASE_FRAME_CODE; result->str.len = STRLEN(UTIL_BASE_FRAME_CODE); } } else { /* code picked up from cache_cleanup(). any changes here might need to be reflected there */ vp = (INTPTR_T *)fp->ctxt; assert(NULL != vp); vp--; if ((GTM_OMAGIC << 16) + OBJ_LABEL != *vp) /* Validate backward linkage */ GTMASSERT; vp--; irtnhdr = (ihdtyp *)((char *)vp + *vp); indce = irtnhdr->indce; assert(NULL != indce); assert(0 < indce->refcnt); /* currently used in the M stack better have a non-zero refcnt */ result->str = indce->src.str; s2pool(&result->str); assert(((unsigned char *)result->str.addr + result->str.len) == stringpool.free); } } return; }
/* * Find a file in a search context. * The search context was created with vim_findfile_init() above. * Return a pointer to an allocated file name or NULL if nothing found. * To get all matching files call this function until you get NULL. * * If the passed search_context is NULL, NULL is returned. * * The search algorithm is depth first. To change this replace the * stack with a list (don't forget to leave partly searched directories on the * top of the list). */ char_u *vim_findfile(void *search_ctx_arg) { char_u *file_path; char_u *rest_of_wildcards; char_u *path_end = NULL; ff_stack_T *stackp; size_t len; char_u *p; char_u *suf; ff_search_ctx_T *search_ctx; if (search_ctx_arg == NULL) return NULL; search_ctx = (ff_search_ctx_T *)search_ctx_arg; /* * filepath is used as buffer for various actions and as the storage to * return a found filename. */ file_path = xmalloc(MAXPATHL); /* store the end of the start dir -- needed for upward search */ if (search_ctx->ffsc_start_dir != NULL) path_end = &search_ctx->ffsc_start_dir[ STRLEN(search_ctx->ffsc_start_dir)]; /* upward search loop */ for (;; ) { /* downward search loop */ for (;; ) { /* check if user user wants to stop the search*/ os_breakcheck(); if (got_int) break; /* get directory to work on from stack */ stackp = ff_pop(search_ctx); if (stackp == NULL) break; /* * TODO: decide if we leave this test in * * GOOD: don't search a directory(-tree) twice. * BAD: - check linked list for every new directory entered. * - check for double files also done below * * Here we check if we already searched this directory. * We already searched a directory if: * 1) The directory is the same. * 2) We would use the same wildcard string. * * Good if you have links on same directory via several ways * or you have selfreferences in directories (e.g. SuSE Linux 6.3: * /etc/rc.d/init.d is linked to /etc/rc.d -> endless loop) * * This check is only needed for directories we work on for the * first time (hence stackp->ff_filearray == NULL) */ if (stackp->ffs_filearray == NULL && ff_check_visited(&search_ctx->ffsc_dir_visited_list ->ffvl_visited_list, stackp->ffs_fix_path , stackp->ffs_wc_path ) == FAIL) { #ifdef FF_VERBOSE if (p_verbose >= 5) { verbose_enter_scroll(); smsg("Already Searched: %s (%s)", stackp->ffs_fix_path, stackp->ffs_wc_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } #endif ff_free_stack_element(stackp); continue; } #ifdef FF_VERBOSE else if (p_verbose >= 5) { verbose_enter_scroll(); smsg("Searching: %s (%s)", stackp->ffs_fix_path, stackp->ffs_wc_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } #endif /* check depth */ if (stackp->ffs_level <= 0) { ff_free_stack_element(stackp); continue; } file_path[0] = NUL; /* * If no filearray till now expand wildcards * The function expand_wildcards() can handle an array of paths * and all possible expands are returned in one array. We use this * to handle the expansion of '**' into an empty string. */ if (stackp->ffs_filearray == NULL) { char_u *dirptrs[2]; /* we use filepath to build the path expand_wildcards() should * expand. */ dirptrs[0] = file_path; dirptrs[1] = NULL; /* if we have a start dir copy it in */ if (!vim_isAbsName(stackp->ffs_fix_path) && search_ctx->ffsc_start_dir) { STRCPY(file_path, search_ctx->ffsc_start_dir); add_pathsep((char *)file_path); } /* append the fix part of the search path */ STRCAT(file_path, stackp->ffs_fix_path); add_pathsep((char *)file_path); rest_of_wildcards = stackp->ffs_wc_path; if (*rest_of_wildcards != NUL) { len = STRLEN(file_path); if (STRNCMP(rest_of_wildcards, "**", 2) == 0) { /* pointer to the restrict byte * The restrict byte is not a character! */ p = rest_of_wildcards + 2; if (*p > 0) { (*p)--; file_path[len++] = '*'; } if (*p == 0) { /* remove '**<numb> from wildcards */ STRMOVE(rest_of_wildcards, rest_of_wildcards + 3); } else rest_of_wildcards += 3; if (stackp->ffs_star_star_empty == 0) { /* if not done before, expand '**' to empty */ stackp->ffs_star_star_empty = 1; dirptrs[1] = stackp->ffs_fix_path; } } /* * Here we copy until the next path separator or the end of * the path. If we stop at a path separator, there is * still something else left. This is handled below by * pushing every directory returned from expand_wildcards() * on the stack again for further search. */ while (*rest_of_wildcards && !vim_ispathsep(*rest_of_wildcards)) file_path[len++] = *rest_of_wildcards++; file_path[len] = NUL; if (vim_ispathsep(*rest_of_wildcards)) rest_of_wildcards++; } /* * Expand wildcards like "*" and "$VAR". * If the path is a URL don't try this. */ if (path_with_url((char *)dirptrs[0])) { stackp->ffs_filearray = xmalloc(sizeof(char *)); stackp->ffs_filearray[0] = vim_strsave(dirptrs[0]); stackp->ffs_filearray_size = 1; } else /* Add EW_NOTWILD because the expanded path may contain * wildcard characters that are to be taken literally. * This is a bit of a hack. */ expand_wildcards((dirptrs[1] == NULL) ? 1 : 2, dirptrs, &stackp->ffs_filearray_size, &stackp->ffs_filearray, EW_DIR|EW_ADDSLASH|EW_SILENT|EW_NOTWILD); stackp->ffs_filearray_cur = 0; stackp->ffs_stage = 0; } else rest_of_wildcards = &stackp->ffs_wc_path[ STRLEN(stackp->ffs_wc_path)]; if (stackp->ffs_stage == 0) { /* this is the first time we work on this directory */ if (*rest_of_wildcards == NUL) { /* * We don't have further wildcards to expand, so we have to * check for the final file now. */ for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (!path_with_url((char *)stackp->ffs_filearray[i]) && !os_isdir(stackp->ffs_filearray[i])) continue; /* not a directory */ /* prepare the filename to be checked for existence * below */ STRCPY(file_path, stackp->ffs_filearray[i]); add_pathsep((char *)file_path); STRCAT(file_path, search_ctx->ffsc_file_to_search); /* * Try without extra suffix and then with suffixes * from 'suffixesadd'. */ len = STRLEN(file_path); if (search_ctx->ffsc_tagfile) suf = (char_u *)""; else suf = curbuf->b_p_sua; for (;; ) { /* if file exists and we didn't already find it */ if ((path_with_url((char *)file_path) || (os_path_exists(file_path) && (search_ctx->ffsc_find_what == FINDFILE_BOTH || ((search_ctx->ffsc_find_what == FINDFILE_DIR) == os_isdir(file_path))))) #ifndef FF_VERBOSE && (ff_check_visited( &search_ctx->ffsc_visited_list->ffvl_visited_list, file_path , (char_u *)"" ) == OK) #endif ) { #ifdef FF_VERBOSE if (ff_check_visited( &search_ctx->ffsc_visited_list->ffvl_visited_list, file_path , (char_u *)"" ) == FAIL) { if (p_verbose >= 5) { verbose_enter_scroll(); smsg("Already: %s", file_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } continue; } #endif /* push dir to examine rest of subdirs later */ assert(i < UCHAR_MAX - 1); stackp->ffs_filearray_cur = (char_u)(i + 1); ff_push(search_ctx, stackp); if (!path_with_url((char *)file_path)) simplify_filename(file_path); if (os_dirname(ff_expand_buffer, MAXPATHL) == OK) { p = path_shorten_fname(file_path, ff_expand_buffer); if (p != NULL) STRMOVE(file_path, p); } #ifdef FF_VERBOSE if (p_verbose >= 5) { verbose_enter_scroll(); smsg("HIT: %s", file_path); msg_puts("\n"); // don't overwrite this either verbose_leave_scroll(); } #endif return file_path; } /* Not found or found already, try next suffix. */ if (*suf == NUL) break; assert(MAXPATHL >= len); copy_option_part(&suf, file_path + len, MAXPATHL - len, ","); } } } else { /* * still wildcards left, push the directories for further * search */ for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (!os_isdir(stackp->ffs_filearray[i])) continue; /* not a directory */ ff_push(search_ctx, ff_create_stack_element( stackp->ffs_filearray[i], rest_of_wildcards, stackp->ffs_level - 1, 0)); } } stackp->ffs_filearray_cur = 0; stackp->ffs_stage = 1; } /* * if wildcards contains '**' we have to descent till we reach the * leaves of the directory tree. */ if (STRNCMP(stackp->ffs_wc_path, "**", 2) == 0) { for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (fnamecmp(stackp->ffs_filearray[i], stackp->ffs_fix_path) == 0) continue; /* don't repush same directory */ if (!os_isdir(stackp->ffs_filearray[i])) continue; /* not a directory */ ff_push(search_ctx, ff_create_stack_element(stackp->ffs_filearray[i], stackp->ffs_wc_path, stackp->ffs_level - 1, 1)); } } /* we are done with the current directory */ ff_free_stack_element(stackp); } /* If we reached this, we didn't find anything downwards. * Let's check if we should do an upward search. */ if (search_ctx->ffsc_start_dir && search_ctx->ffsc_stopdirs_v != NULL && !got_int) { ff_stack_T *sptr; /* is the last starting directory in the stop list? */ if (ff_path_in_stoplist(search_ctx->ffsc_start_dir, (int)(path_end - search_ctx->ffsc_start_dir), search_ctx->ffsc_stopdirs_v) == TRUE) break; /* cut of last dir */ while (path_end > search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) path_end--; while (path_end > search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) path_end--; *path_end = 0; path_end--; if (*search_ctx->ffsc_start_dir == 0) break; STRCPY(file_path, search_ctx->ffsc_start_dir); add_pathsep((char *)file_path); STRCAT(file_path, search_ctx->ffsc_fix_path); /* create a new stack entry */ sptr = ff_create_stack_element(file_path, search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0); ff_push(search_ctx, sptr); } else break; } xfree(file_path); return NULL; }
int log(const char *fmt, ...) { if (!Log.good()) Log.open("MyLog.txt"); if (!Log.good()) return -1; ZeroMemory(gpcDebug, sizeof(gpcDebug)); JulianType ttt; GETJULIANDATE(0, &ttt); //SPRINTF(gpcDebug, "%d:%d:%d:%d %s:%d", ttt.wHour, ttt.wMinute, ttt.wSecond, // currentTimeMillis(),__FILE__, __LINE__); SPRINTF(gpcDebug, "[%s:%s]", __DATE__, __TIME__); char* ptc = &gpcDebug[STRLEN(gpcDebug)]; va_list p; va_start(p, fmt); for (const char *s = fmt; *s; ++s) { if (*s != '%') { *(ptc++) = *s; } else { switch (*(++s)) { case '%': { *(ptc++) = '%'; } break; case 's': { const char* pc = va_arg(p, const char*); while (*pc) { *(ptc++) = *(pc++); } } break; case 'c': { *(ptc++) = va_arg(p, char); } break; case 'd': { int nNum = va_arg(p, int); char pc[32] = { 0 }; if (nNum < 0) { *(ptc++) = '-'; nNum = -nNum; } else if (nNum == 0) { *(ptc++) = '0'; } int nIndex = 32; while (nNum > 0) { nIndex--; pc[nIndex] = (int) (nNum % 10) + '0'; nNum /= 10; } for (; nIndex < 32;) { *(ptc++) = pc[nIndex++]; } } break; case 'u': { unsigned int nNum = va_arg(p, unsigned int); char pc[32] = { 0 }; if (nNum == 0) { *(ptc++) = '0'; } int nIndex = 32; while (nNum > 0) { nIndex--; pc[nIndex] = (int) (nNum % 10) + '0'; nNum /= 10; } for (; nIndex < 32;) { *(ptc++) = pc[nIndex++]; } } break; case 'p': { *(ptc++) = '0'; *(ptc++) = 'x'; unsigned int unNum = va_arg(p, unsigned int); char pc[32] = { 0 }; if (unNum == 0) { *(ptc++) = '0'; } int nIndex = 32; while (unNum > 0) { nIndex--; int n = (int) (unNum % 16); if (n < 10) pc[nIndex] = n + '0'; else pc[nIndex] = n - 10 + 'a'; unNum >>= 4; } for (; nIndex < 32;) { *(ptc++) = pc[nIndex++]; } } break; default: break; } } } va_end(p); *ptc = 0; return Log.write((void*) gpcDebug, STRLEN(gpcDebug)); }
BOOL INSTAPI SQLInstallTranslatorEx (LPCSTR lpszTranslator, LPCSTR lpszPathIn, LPSTR lpszPathOut, WORD cbPathOutMax, WORD * pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount) { PCONFIG pCfg = NULL, pOdbcCfg = NULL; BOOL retcode = FALSE; CLEAR_ERROR (); if (lpszPathIn && access (lpszPathIn, R_OK | W_OK | X_OK)) { PUSH_ERROR (ODBC_ERROR_INVALID_PATH); goto quit; } switch (fRequest) { case ODBC_INSTALL_INQUIRY: if (lpszPathIn) { if (pcbPathOut) *pcbPathOut = STRLEN (lpszPathIn); retcode = TRUE; } else retcode = InstallDriverPathLength (pcbPathOut, "ODBCTRANSLATORS"); goto quit; case ODBC_INSTALL_COMPLETE: break; default: PUSH_ERROR (ODBC_ERROR_INVALID_REQUEST_TYPE); goto quit; } /* Check input parameters */ if (!lpszTranslator || !STRLEN (lpszTranslator)) { PUSH_ERROR (ODBC_ERROR_INVALID_PARAM_SEQUENCE); goto quit; } if (!lpszPathOut || !cbPathOutMax) { PUSH_ERROR (ODBC_ERROR_INVALID_BUFF_LEN); goto quit; } /* Write the out path */ if (!InstallDriverPath (lpszPathOut, cbPathOutMax, pcbPathOut, "ODBCTRANSLATORS")) goto quit; /* Else go through user/system odbcinst.ini */ switch (configMode) { case ODBC_BOTH_DSN: case ODBC_USER_DSN: wSystemDSN = USERDSN_ONLY; break; case ODBC_SYSTEM_DSN: wSystemDSN = SYSTEMDSN_ONLY; break; } if (_iodbcdm_cfg_search_init (&pCfg, "odbcinst.ini", TRUE)) { PUSH_ERROR (ODBC_ERROR_GENERAL_ERR); goto quit; } if (_iodbcdm_cfg_search_init (&pOdbcCfg, "odbc.ini", TRUE)) { PUSH_ERROR (ODBC_ERROR_GENERAL_ERR); pOdbcCfg = NULL; goto done; } if (!install_from_string (pCfg, pOdbcCfg, (char *) lpszTranslator, FALSE)) { PUSH_ERROR (ODBC_ERROR_INVALID_KEYWORD_VALUE); goto done; } if (_iodbcdm_cfg_commit (pCfg) || _iodbcdm_cfg_commit (pOdbcCfg)) { PUSH_ERROR (ODBC_ERROR_GENERAL_ERR); goto done; } retcode = TRUE; done: _iodbcdm_cfg_done (pCfg); if (pOdbcCfg) _iodbcdm_cfg_done (pOdbcCfg); quit: wSystemDSN = USERDSN_ONLY; configMode = ODBC_BOTH_DSN; return retcode; }
/// Redraw the popup menu, using "pum_first" and "pum_selected". void pum_redraw(void) { int row = pum_row; int col; int attr_norm = highlight_attr[HLF_PNI]; int attr_select = highlight_attr[HLF_PSI]; int attr_scroll = highlight_attr[HLF_PSB]; int attr_thumb = highlight_attr[HLF_PST]; int attr; int i; int idx; char_u *s; char_u *p = NULL; int totwidth, width, w; int thumb_pos = 0; int thumb_heigth = 1; int round; int n; // Never display more than we have if (pum_first > pum_size - pum_height) { pum_first = pum_size - pum_height; } if (pum_scrollbar) { thumb_heigth = pum_height * pum_height / pum_size; if (thumb_heigth == 0) { thumb_heigth = 1; } thumb_pos = (pum_first * (pum_height - thumb_heigth) + (pum_size - pum_height) / 2) / (pum_size - pum_height); } for (i = 0; i < pum_height; ++i) { idx = i + pum_first; attr = (idx == pum_selected) ? attr_select : attr_norm; // prepend a space if there is room if (curwin->w_p_rl) { if (pum_col < curwin->w_wincol + curwin->w_width - 1) { screen_putchar(' ', row, pum_col + 1, attr); } } else if (pum_col > 0) { screen_putchar(' ', row, pum_col - 1, attr); } // Display each entry, use two spaces for a Tab. // Do this 3 times: For the main text, kind and extra info col = pum_col; totwidth = 0; for (round = 1; round <= 3; ++round) { width = 0; s = NULL; switch (round) { case 1: p = pum_array[idx].pum_text; break; case 2: p = pum_array[idx].pum_kind; break; case 3: p = pum_array[idx].pum_extra; break; } if (p != NULL) { for (;; mb_ptr_adv(p)) { if (s == NULL) { s = p; } w = ptr2cells(p); if ((*p == NUL) || (*p == TAB) || (totwidth + w > pum_width)) { // Display the text that fits or comes before a Tab. // First convert it to printable characters. char_u *st; int saved = *p; *p = NUL; st = transstr(s); *p = saved; if (curwin->w_p_rl) { char_u *rt = reverse_text(st); char_u *rt_start = rt; int size = vim_strsize(rt); if (size > pum_width) { do { size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1; mb_ptr_adv(rt); } while (size > pum_width); if (size < pum_width) { // Most left character requires 2-cells but only 1 cell // is available on screen. Put a '<' on the left of the // pum item *(--rt) = '<'; size++; } } screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1, attr); free(rt_start); free(st); col -= width; } else { if (st != NULL) { screen_puts_len(st, (int)STRLEN(st), row, col, attr); free(st); } col += width; } if (*p != TAB) { break; } // Display two spaces for a Tab. if (curwin->w_p_rl) { screen_puts_len((char_u *)" ", 2, row, col - 1, attr); col -= 2; } else { screen_puts_len((char_u *)" ", 2, row, col, attr); col += 2; } totwidth += 2; // start text at next char s = NULL; width = 0; } else { width += w; } } } if (round > 1) { n = pum_kind_width + 1; } else { n = 1; } // Stop when there is nothing more to display. if ((round == 3) || ((round == 2) && (pum_array[idx].pum_extra == NULL)) || ((round == 1) && (pum_array[idx].pum_kind == NULL) && (pum_array[idx].pum_extra == NULL)) || (pum_base_width + n >= pum_width)) { break; } if (curwin->w_p_rl) { screen_fill(row, row + 1, pum_col - pum_base_width - n + 1, col + 1, ' ', ' ', attr); col = pum_col - pum_base_width - n + 1; } else { screen_fill(row, row + 1, col, pum_col + pum_base_width + n, ' ', ' ', attr); col = pum_col + pum_base_width + n; } totwidth = pum_base_width + n; } if (curwin->w_p_rl) { screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ', ' ', attr); } else { screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', attr); } if (pum_scrollbar > 0) { if (curwin->w_p_rl) { screen_putchar(' ', row, pum_col - pum_width, i >= thumb_pos && i < thumb_pos + thumb_heigth ? attr_thumb : attr_scroll); } else { screen_putchar(' ', row, pum_col + pum_width, i >= thumb_pos && i < thumb_pos + thumb_heigth ? attr_thumb : attr_scroll); } } row++; } }
BOOL INSTAPI ConfigDSN ( HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes) { char *dsn = NULL, *connstr = NULL, *curr, *cour = NULL; char dsnread[4096] = { 0 }; char prov[4096] = { 0 }; int driver_type = -1, flags = 0; BOOL retcode = FALSE; UWORD confMode = ODBC_USER_DSN; /* Map the request User/System */ if (fRequest < ODBC_ADD_DSN || fRequest > ODBC_REMOVE_DSN) { SQLPostInstallerError (ODBC_ERROR_INVALID_REQUEST_TYPE, NULL); goto done; } if (!lpszDriver || !STRLEN (lpszDriver)) { SQLPostInstallerError (ODBC_ERROR_INVALID_NAME, NULL); goto done; } /* Retrieve the config mode */ SQLGetConfigMode (&confMode); /* Retrieve the DSN if one exist */ for (curr = (LPSTR) lpszAttributes; curr && *curr; curr += (STRLEN (curr) + 1)) { if (!strncmp (curr, "DSN=", STRLEN ("DSN="))) { dsn = curr + STRLEN ("DSN="); break; } } /* Retrieve the corresponding driver */ if (strstr (lpszDriver, "OpenLink") || strstr (lpszDriver, "Openlink") || strstr (lpszDriver, "oplodbc")) { driver_type = 0; for (curr = (LPSTR) lpszAttributes, cour = prov; curr && *curr; curr += (STRLEN (curr) + 1), cour += (STRLEN (cour) + 1)) { if (!strncasecmp (curr, "Host=", STRLEN ("Host=")) && STRLEN (curr + STRLEN ("Host="))) { STRCPY (cour, curr); flags |= 0x1; continue; } if (!strncasecmp (curr, "ServerType=", STRLEN ("ServerType=")) && STRLEN (curr + STRLEN ("ServerType="))) { STRCPY (cour, curr); flags |= 0x2; continue; } STRCPY (cour, curr); } if (cour && !(flags & 1)) { STRCPY (cour, "Host=localhost\0"); cour += (STRLEN (cour) + 1); } if (cour && !(flags & 2)) { STRCPY (cour, "ServerType=Proxy\0"); cour += (STRLEN (cour) + 1); } if (cour) *cour = 0; } else if ((strstr (lpszDriver, "Virtuoso") || strstr (lpszDriver, "virtodbc"))) driver_type = 1; /* For each request */ switch (fRequest) { case ODBC_ADD_DSN: /* Check if the DSN with this name already exists */ SQLSetConfigMode (confMode); #ifdef WIN32 if (hwndParent && dsn && SQLGetPrivateProfileString ("ODBC 32 bit Data Sources", dsn, "", dsnread, sizeof (dsnread), NULL) && !create_confirm (hwndParent, dsn, "Are you sure you want to overwrite this DSN ?")) #else if (hwndParent && dsn && SQLGetPrivateProfileString ("ODBC Data Sources", dsn, "", dsnread, sizeof (dsnread), NULL) && !create_confirm (hwndParent, dsn, "Are you sure you want to overwrite this DSN ?")) #endif goto done; /* Call the right setup function */ connstr = create_gensetup (hwndParent, dsn, STRLEN (prov) ? prov : lpszAttributes, TRUE); /* Check output parameters */ if (!connstr) { SQLPostInstallerError (ODBC_ERROR_OUT_OF_MEM, NULL); goto done; } if (connstr == (LPSTR) - 1L) goto done; /* Add the DSN to the ODBC Data Sources */ SQLSetConfigMode (confMode); if (!SQLWriteDSNToIni (dsn = connstr + STRLEN ("DSN="), lpszDriver)) goto done; /* Add each keyword and values */ for (curr = connstr; *curr; curr += (STRLEN (curr) + 1)) { if (strncmp (curr, "DSN=", STRLEN ("DSN="))) { STRCPY (dsnread, curr); cour = strchr (dsnread, '='); if (cour) *cour = 0; SQLSetConfigMode (confMode); if (!SQLWritePrivateProfileString (dsn, dsnread, (cour && STRLEN (cour + 1)) ? cour + 1 : NULL, NULL)) goto done; } } break; case ODBC_CONFIG_DSN: if (!dsn || !STRLEN (dsn)) { SQLPostInstallerError (ODBC_ERROR_INVALID_KEYWORD_VALUE, NULL); goto done; } /* Call the right setup function */ connstr = create_gensetup (hwndParent, dsn, STRLEN (prov) ? prov : lpszAttributes, FALSE); /* Check output parameters */ if (!connstr) { SQLPostInstallerError (ODBC_ERROR_OUT_OF_MEM, NULL); goto done; } if (connstr == (LPSTR) - 1L) goto done; /* Compare if the DSN changed */ if (strcmp (connstr + STRLEN ("DSN="), dsn)) { /* Remove the previous DSN */ SQLSetConfigMode (confMode); if (!SQLRemoveDSNFromIni (dsn)) goto done; /* Add the new DSN section */ SQLSetConfigMode (confMode); if (!SQLWriteDSNToIni (dsn = connstr + STRLEN ("DSN="), lpszDriver)) goto done; } /* Add each keyword and values */ for (curr = connstr; *curr; curr += (STRLEN (curr) + 1)) { if (strncmp (curr, "DSN=", STRLEN ("DSN="))) { STRCPY (dsnread, curr); cour = strchr (dsnread, '='); if (cour) *cour = 0; SQLSetConfigMode (confMode); if (!SQLWritePrivateProfileString (dsn, dsnread, (cour && STRLEN (cour + 1)) ? cour + 1 : NULL, NULL)) goto done; } } break; case ODBC_REMOVE_DSN: if (!dsn || !STRLEN (dsn)) { SQLPostInstallerError (ODBC_ERROR_INVALID_KEYWORD_VALUE, NULL); goto done; } /* Just remove the DSN */ SQLSetConfigMode (confMode); if (!SQLRemoveDSNFromIni (dsn)) goto done; break; }; quit: retcode = TRUE; done: if (connstr && connstr != (LPSTR) - 1L && connstr != lpszAttributes && connstr != prov) free (connstr); return retcode; }
/**************************************************************************** * * Name: packet_receive * Function: receive a packet * variable: pPacket -- packet information point * nTimeOut -- time out * ****************************************************************************/ UINT32 packet_receive(PPACKET pPacket, UINT32 nTimeOut) { //receive and compare packet head flag unsigned char c = 0; BOOL bPacketHead = FALSE; BOOL bComtest = FALSE; UINT32 i = 0; int n = 0; UINT32 nLength = 0; MEMSET(pPacket, 0, sizeof(PACKET)); for(i = 0; i < nTimeOut;) { if( c == 'H') { // judge if packet head for(n = 0; n < 3; n++) { if(SUCCESS != com_read_tm(&c, 1, 1)) { c = 0; break; } if(c != l_packet_head_flag[n + 1]) break; } if(n == 3) { bPacketHead = TRUE; break; } } else if(c == 'c') { pPacket->data_buffer[0] = 'c'; LIB_ASH_OC(c); //judge if comtest for(n = 0; n < 6; n++) { // c = LIB_ASH_IC(); if(SUCCESS != com_read_tm(&c, 1, 100)) { c = 0; SH_PRINTF("comtest not all : %d\n", n); break; } if(c != l_packet_comtest[n + 1]) break; LIB_ASH_OC(c); } if(n == 6) { SH_PRINTF("RECEIVE comtest\n"); bComtest = TRUE; break; } } else if(SUCCESS != com_read(&c, 1)) { Sleep(1); i++; } } if(bPacketHead) { //receive packet head unsigned char packet_head[PACKET_HEAD_LEN]; if(SUCCESS != com_read_tm(packet_head + PACKET_TYPE_OFFSET, PACKET_HEAD_LEN - 4, 1000)) { SH_PRINTF("ERROR:receive head error"); return ERROR_PACKET_RECEIVEHEAD; } //compare CRC about packet head UINT32 nCRC = MG_Table_Driven_CRC(0xFFFFFFFF, packet_head + PACKET_TYPE_OFFSET, PACKET_HEAD_LEN - 8); if(nCRC != fetch_long(packet_head + PACKET_HEAD_CRC_OFFSET)) return ERROR_PACKET_HEADCRC; MakePacketHead(packet_head, pPacket); //Receive data and CRC nLength = pPacket->packet_length; // if blank packet receive 4B packet number only if(0 != pPacket->blank_flag && PACKET_DATA == pPacket->packet_type) nLength = 4; if(SUCCESS != com_read_tm(pPacket->data_buffer, nLength + 4, 1000)) return ERROR_PACKET_RECEIVEDATA; nCRC = MG_Table_Driven_CRC(0xFFFFFFFF, pPacket->data_buffer, nLength); if(nCRC != fetch_long(pPacket->data_buffer + nLength)) return ERROR_PACKET_DATACRC; if(PACKET_DATA == pPacket->packet_type) { if(1 == pPacket->blank_flag) memset(pPacket->data_buffer + 4, 0xFF, pPacket->packet_length - 4); else if(2 == pPacket->blank_flag) memset(pPacket->data_buffer + 4, 0x00, pPacket->packet_length - 4); } } else if(bComtest) { pPacket->packet_type = PACKET_COMMAND; MEMCPY(pPacket->data_buffer, l_packet_comtest, 7); i = 7; while(i < 128) { pPacket->data_buffer[i] = LIB_ASH_IC(); c = pPacket->data_buffer[i]; LIB_ASH_OC(c); if (c == 0x0D || c == 0x0A) break; i++; } pPacket->packet_length = STRLEN(pPacket->data_buffer); // for(i = 0; i < pPacket->packet_length; i++) // LIB_ASH_OC(pPacket->data_buffer[i]); SH_PRINTF(pPacket->data_buffer); g_packet_index = 0; g_packet_repeat = 0; } else return ERROR_NOPACKETRECEIVE; return SUCCESS; }
/// Translate a string into allocated memory, replacing special chars with /// printable chars. Returns NULL when out of memory. /// /// @param s /// /// @return translated string or NULL if out of memory. char_u *transstr(char_u *s) { char_u *res; char_u *p; int l, len, c; char_u hexbuf[11]; if (has_mbyte) { // Compute the length of the result, taking account of unprintable // multi-byte characters. len = 0; p = s; while (*p != NUL) { if ((l = (*mb_ptr2len)(p)) > 1) { c = (*mb_ptr2char)(p); p += l; if (vim_isprintc(c)) { len += l; } else { transchar_hex(hexbuf, c); len += (int)STRLEN(hexbuf); } } else { l = byte2cells(*p++); if (l > 0) { len += l; } else { // illegal byte sequence len += 4; } } } res = alloc((unsigned)(len + 1)); } else { res = alloc((unsigned)(vim_strsize(s) + 1)); } if (res != NULL) { *res = NUL; p = s; while (*p != NUL) { if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) { c = (*mb_ptr2char)(p); if (vim_isprintc(c)) { // append printable multi-byte char STRNCAT(res, p, l); } else { transchar_hex(res + STRLEN(res), c); } p += l; } else { STRCAT(res, transchar_byte(*p++)); } } } return res; }
static int coladvance2( pos_T *pos, bool addspaces, /* change the text to achieve our goal? */ bool finetune, /* change char offset for the exact column */ colnr_T wcol /* column to move to */ ) { int idx; char_u *ptr; char_u *line; colnr_T col = 0; int csize = 0; int one_more; int head = 0; one_more = (State & INSERT) || restart_edit != NUL || (VIsual_active && *p_sel != 'o') || ((ve_flags & VE_ONEMORE) && wcol < MAXCOL); line = ml_get_buf(curbuf, pos->lnum, false); if (wcol >= MAXCOL) { idx = (int)STRLEN(line) - 1 + one_more; col = wcol; if ((addspaces || finetune) && !VIsual_active) { curwin->w_curswant = linetabsize(line) + one_more; if (curwin->w_curswant > 0) --curwin->w_curswant; } } else { int width = curwin->w_width - win_col_off(curwin); if (finetune && curwin->w_p_wrap && curwin->w_width != 0 && wcol >= (colnr_T)width) { csize = linetabsize(line); if (csize > 0) csize--; if (wcol / width > (colnr_T)csize / width && ((State & INSERT) == 0 || (int)wcol > csize + 1)) { /* In case of line wrapping don't move the cursor beyond the * right screen edge. In Insert mode allow going just beyond * the last character (like what happens when typing and * reaching the right window edge). */ wcol = (csize / width + 1) * width - 1; } } ptr = line; while (col <= wcol && *ptr != NUL) { /* Count a tab for what it's worth (if list mode not on) */ csize = win_lbr_chartabsize(curwin, line, ptr, col, &head); MB_PTR_ADV(ptr); col += csize; } idx = (int)(ptr - line); /* * Handle all the special cases. The virtual_active() check * is needed to ensure that a virtual position off the end of * a line has the correct indexing. The one_more comparison * replaces an explicit add of one_more later on. */ if (col > wcol || (!virtual_active() && one_more == 0)) { idx -= 1; /* Don't count the chars from 'showbreak'. */ csize -= head; col -= csize; } if (virtual_active() && addspaces && ((col != wcol && col != wcol + 1) || csize > 1)) { /* 'virtualedit' is set: The difference between wcol and col is * filled with spaces. */ if (line[idx] == NUL) { /* Append spaces */ int correct = wcol - col; char_u *newline = xmallocz((size_t)(idx + correct)); memcpy(newline, line, (size_t)idx); memset(newline + idx, ' ', (size_t)correct); ml_replace(pos->lnum, newline, false); changed_bytes(pos->lnum, (colnr_T)idx); idx += correct; col = wcol; } else { /* Break a tab */ int linelen = (int)STRLEN(line); int correct = wcol - col - csize + 1; /* negative!! */ char_u *newline; if (-correct > csize) return FAIL; newline = xmallocz((size_t)(linelen - 1 + csize)); // Copy first idx chars memcpy(newline, line, (size_t)idx); // Replace idx'th char with csize spaces memset(newline + idx, ' ', (size_t)csize); // Copy the rest of the line memcpy(newline + idx + csize, line + idx + 1, (size_t)(linelen - idx - 1)); ml_replace(pos->lnum, newline, false); changed_bytes(pos->lnum, idx); idx += (csize - 1 + correct); col += correct; } } } if (idx < 0) pos->col = 0; else pos->col = idx; pos->coladd = 0; if (finetune) { if (wcol == MAXCOL) { /* The width of the last character is used to set coladd. */ if (!one_more) { colnr_T scol, ecol; getvcol(curwin, pos, &scol, NULL, &ecol); pos->coladd = ecol - scol; } } else { int b = (int)wcol - (int)col; /* The difference between wcol and col is used to set coladd. */ if (b > 0 && b < (MAXCOL - 2 * curwin->w_width)) pos->coladd = b; col += b; } } // Prevent from moving onto a trail byte. if (has_mbyte) { mark_mb_adjustpos(curbuf, pos); } if (col < wcol) return FAIL; return OK; }
void addtranslators_to_list (GtkWidget *widget, GtkWidget *dlg) { char *curr, *buffer = (char *) malloc (sizeof (char) * 65536), *szDriver; char driver[1024], _date[1024], _size[1024]; char *data[4]; int len, i; BOOL careabout; UWORD confMode = ODBC_USER_DSN; struct stat _stat; if (!buffer || !GTK_IS_CLIST (widget)) return; gtk_clist_clear (GTK_CLIST (widget)); /* Get the current config mode */ while (confMode != ODBC_SYSTEM_DSN + 1) { /* Get the list of drivers in the user context */ SQLSetConfigMode (confMode); #ifdef WIN32 len = SQLGetPrivateProfileString ("ODBC 32 bit Translators", NULL, "", buffer, 65535, "odbcinst.ini"); #else len = SQLGetPrivateProfileString ("ODBC Translators", NULL, "", buffer, 65535, "odbcinst.ini"); #endif if (len) goto process; goto end; process: for (curr = buffer; *curr; curr += (STRLEN (curr) + 1)) { /* Shadowing system odbcinst.ini */ for (i = 0, careabout = TRUE; i < GTK_CLIST (widget)->rows; i++) { gtk_clist_get_text (GTK_CLIST (widget), i, 0, &szDriver); if (!strcmp (szDriver, curr)) { careabout = FALSE; break; } } if (!careabout) continue; SQLSetConfigMode (confMode); #ifdef WIN32 SQLGetPrivateProfileString ("ODBC 32 bit Translators", curr, "", driver, sizeof (driver), "odbcinst.ini"); #else SQLGetPrivateProfileString ("ODBC Translators", curr, "", driver, sizeof (driver), "odbcinst.ini"); #endif /* Check if the driver is installed */ if (strcasecmp (driver, "Installed")) goto end; /* Get the driver library name */ SQLSetConfigMode (confMode); if (!SQLGetPrivateProfileString (curr, "Translator", "", driver, sizeof (driver), "odbcinst.ini")) { SQLSetConfigMode (confMode); SQLGetPrivateProfileString ("Default", "Translator", "", driver, sizeof (driver), "odbcinst.ini"); } if (STRLEN (curr) && STRLEN (driver)) { data[0] = curr; data[1] = driver; /* Get some information about the driver */ if (!stat (driver, &_stat)) { sprintf (_size, "%lu Kb", (unsigned long) _stat.st_size / 1024L); sprintf (_date, "%s", ctime (&_stat.st_mtime)); data[2] = _date; data[3] = _size; gtk_clist_append (GTK_CLIST (widget), data); } } } end: if (confMode == ODBC_USER_DSN) confMode = ODBC_SYSTEM_DSN; else confMode = ODBC_SYSTEM_DSN + 1; } if (GTK_CLIST (widget)->rows > 0) { gtk_clist_columns_autosize (GTK_CLIST (widget)); gtk_clist_sort (GTK_CLIST (widget)); } /* Make the clean up */ free (buffer); }
BOOL InstallDriverPathLength (WORD * pcbPathOut, LPSTR envname) { #ifdef _MAC OSErr result; long fldrDid; short fldrRef; #endif BOOL retcode = FALSE; WORD len = 0; char path[1024]; char *ptr; #if !defined(UNIX_PWD) #ifdef _MAC result = FindFolder (kOnSystemDisk, kExtensionFolderType, kDontCreateFolder, &fldrRef, &fldrDid); if (result != noErr) { PUSH_ERROR (ODBC_ERROR_GENERAL_ERR); goto quit; } ptr = get_full_pathname (fldrDid, fldrRef); len = STRLEN (ptr); free (ptr); goto done; #else /* * On Windows, there is only one place to look */ len = GetWindowsDirectory (path, sizeof (path)); goto done; #endif #else /* * 1. Check $ODBCDRIVERS environment variable */ if ((ptr = getenv (envname)) && access (ptr, R_OK | W_OK | X_OK) == 0) { len = STRLEN (ptr); goto done; } /* * 2. Check /usr/local/lib and /usr/lib */ #ifdef _BE if (access ("/boot/beos/system/lib", R_OK | W_OK | X_OK) == 0) { len = STRLEN ("/boot/beos/system/lib"); goto done; } #else if (access ("/usr/local/lib", R_OK | W_OK | X_OK) == 0) { len = STRLEN ("/usr/local/lib"); goto done; } #endif #ifdef _BE if (access ("/boot/home/config/lib", R_OK | W_OK | X_OK) == 0) { len = STRLEN ("/boot/home/config/lib"); goto done; } #else if (access ("/usr/lib", R_OK | W_OK | X_OK) == 0) { len = STRLEN ("/usr/lib"); goto done; } #endif /* * 3. Check either $HOME */ if (!(ptr = getenv ("HOME"))) { ptr = (char *) getpwuid (getuid ()); if (ptr) ptr = ((struct passwd *) ptr)->pw_dir; } if (ptr) { #ifdef _BE sprintf (path, "%s/config/lib", ptr); #else sprintf (path, "%s/lib", ptr); #endif if (access (path, R_OK | W_OK | X_OK) == 0) { len = STRLEN (path); goto done; } } if (!mkdir (path, 0755)) goto done; #endif SQLPostInstallerError (ODBC_ERROR_GENERAL_ERR, "Cannot retrieve a directory where to install the driver or translator."); goto quit; done: retcode = TRUE; quit: if (pcbPathOut) *pcbPathOut = len; return retcode; }
int main() { char passwd[GTM_PASSPHRASE_MAX], hex_out[GTM_PASSPHRASE_MAX * 2], mumps_exe[GTM_PATH_MAX], *env_ptr; struct stat stat_info; gtm_string_t passwd_str; struct sigaction reset_term_handler, ignore_handler; int sig; /* Since the obfuscated password depends on $USER and the inode of $gtm_dist/mumps, make sure all the pre-requisites are * available to this process. */ if (NULL == (env_ptr = (char *)getenv(USER_ENV))) { printf(ENV_UNDEF_ERROR "\n", USER_ENV); exit(EXIT_FAILURE); } if (NULL == (env_ptr = (char *)getenv(GTM_DIST_ENV))) { printf(ENV_UNDEF_ERROR "\n", GTM_DIST_ENV); exit(EXIT_FAILURE); } SNPRINTF(mumps_exe, GTM_PATH_MAX, "%s/%s", env_ptr, "mumps"); if (0 != stat(mumps_exe, &stat_info)) { printf("Cannot stat %s\n", mumps_exe); exit(EXIT_FAILURE); } /* We want the process to restore the terminal settings (if they already changed by the time a signal is caught) on the more * conventional terminal signals, such as SIGINT and SIGTERM, and ignore the non-critical other ones. We also do not want to * allow putting the process in the background because the terminal settings may be unsuitable for user interaction at that * point, and the user may decide to "sanitize" them, which might render the entered password visible upon resumption. */ reset_term_handler.sa_handler = maskpass_signal_handler; reset_term_handler.sa_flags = 0; sigfillset(&reset_term_handler.sa_mask); ignore_handler.sa_handler = SIG_IGN; ignore_handler.sa_flags = 0; sigemptyset(&ignore_handler.sa_mask); for (sig = 1; sig <= NSIG; sig++) { switch (sig) { case SIGINT: case SIGTERM: sigaction(sig, &reset_term_handler, NULL); break; case SIGSEGV: case SIGABRT: case SIGBUS: case SIGFPE: case SIGTRAP: case SIGKILL: break; default: sigaction(sig, &ignore_handler, NULL); } } /* Read the password (with terminal echo turned off). */ if (-1 == gc_read_passwd(GTMCRYPT_DEFAULT_PASSWD_PROMPT, passwd, GTM_PASSPHRASE_MAX, &tty)) { printf("%s\n", gtmcrypt_err_string); exit(EXIT_FAILURE); } /* Obfuscate the password. */ passwd_str.address = &passwd[0]; passwd_str.length = (int)STRLEN(passwd); if (-1 == gc_mask_unmask_passwd(2, &passwd_str, &passwd_str)) { printf("%s\n", gtmcrypt_err_string); exit(EXIT_FAILURE); } /* Convert obfuscated password to a hex representation for easy viewing. */ GC_HEX(passwd, hex_out, passwd_str.length * 2); printf("%s\n", hex_out); return 0; }
static int list_join_inner( garray_T *gap, /* to store the result in */ list_T *l, char_u *sep, int echo_style, int restore_copyID, int copyID, garray_T *join_gap) /* to keep each list item string */ { int i; join_T *p; int len; int sumlen = 0; int first = TRUE; char_u *tofree; char_u numbuf[NUMBUFLEN]; listitem_T *item; char_u *s; /* Stringify each item in the list. */ for (item = l->lv_first; item != NULL && !got_int; item = item->li_next) { s = echo_string_core(&item->li_tv, &tofree, numbuf, copyID, echo_style, restore_copyID, !echo_style); if (s == NULL) return FAIL; len = (int)STRLEN(s); sumlen += len; (void)ga_grow(join_gap, 1); p = ((join_T *)join_gap->ga_data) + (join_gap->ga_len++); if (tofree != NULL || s != numbuf) { p->s = s; p->tofree = tofree; } else { p->s = vim_strnsave(s, len); p->tofree = p->s; } line_breakcheck(); if (did_echo_string_emsg) /* recursion error, bail out */ break; } /* Allocate result buffer with its total size, avoid re-allocation and * multiple copy operations. Add 2 for a tailing ']' and NUL. */ if (join_gap->ga_len >= 2) sumlen += (int)STRLEN(sep) * (join_gap->ga_len - 1); if (ga_grow(gap, sumlen + 2) == FAIL) return FAIL; for (i = 0; i < join_gap->ga_len && !got_int; ++i) { if (first) first = FALSE; else ga_concat(gap, sep); p = ((join_T *)join_gap->ga_data) + i; if (p->s != NULL) ga_concat(gap, p->s); line_breakcheck(); } return OK; }
/// ":loadkeymap" command: load the following lines as the keymap. /// /// @param eap void ex_loadkeymap(exarg_T *eap) { char_u *line; char_u *p; char_u *s; #define KMAP_LLEN 200 // max length of "to" and "from" together char_u buf[KMAP_LLEN + 11]; char_u *save_cpo = p_cpo; if (!getline_equal(eap->getline, eap->cookie, getsourceline)) { EMSG(_("E105: Using :loadkeymap not in a sourced file")); return; } // Stop any active keymap and clear the table. keymap_unload(); curbuf->b_kmap_state = 0; ga_init(&curbuf->b_kmap_ga, (int)sizeof(kmap_T), 20); // Set 'cpoptions' to "C" to avoid line continuation. p_cpo = (char_u *)"C"; // Get each line of the sourced file, break at the end. for (;;) { line = eap->getline(0, eap->cookie, 0); if (line == NULL) { break; } p = skipwhite(line); if ((*p != '"') && (*p != NUL)) { kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga); s = skiptowhite(p); kp->from = vim_strnsave(p, (size_t)(s - p)); p = skipwhite(s); s = skiptowhite(p); kp->to = vim_strnsave(p, (size_t)(s - p)); if ((STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN) || (*kp->from == NUL) || (*kp->to == NUL)) { if (*kp->to == NUL) { EMSG(_("E791: Empty keymap entry")); } xfree(kp->from); xfree(kp->to); --curbuf->b_kmap_ga.ga_len; } } xfree(line); } // setup ":lnoremap" to map the keys for (int i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) { vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s %s", ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from, ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to); (void)do_map(2, buf, LANGMAP, FALSE); } p_cpo = save_cpo; curbuf->b_kmap_state |= KEYMAP_LOADED; status_redraw_curbuf(); }
/* lcgi:cfg */ int LCGIResp_Config(LCGIResp *me, UrlParts *pup) { int nErr = EFAILED; const char *cpszUrl = (char*)MEMCHR(pup->cpcPath, '.', UP_PATHLEN(pup)) + 1; AEEResBlob *pBlob = 0; int nBlobLen = 0; if (!LCGIResp_FindOrMakeInvoke(me,pup,&cpszUrl)) { return SUCCESS; } // lcgi:cfg.menu if (STRBEGINS("menu", cpszUrl)) { nErr = Config_Menu(me, &pBlob, &nBlobLen); } else if (LCGIResp_SafeReferer(me)) { if (STRBEGINS("proxies.reset.sub", cpszUrl)) { nErr = Config_ProxyResetDone(me, &pBlob, &nBlobLen); } else if (STRBEGINS("proxies.reset", cpszUrl)) { nErr = Config_ProxyReset(me, &pBlob, &nBlobLen); } else if (STRBEGINS("proxies.ok", cpszUrl)) { char *pszURLData = 0; nErr = ERR_STRDUP((char*)pup->cpcSrch + 1, &pszURLData); if (SUCCESS == nErr) { nErr = Config_ProxySubmit(me,pszURLData,&pBlob,&nBlobLen); } FREEIF(pszURLData); } else if (STRBEGINS("proxies", cpszUrl)) { nErr = Config_Proxies(me, &pBlob, &nBlobLen); } else if (STRBEGINS("cookies.sub", cpszUrl)) { char *pszURLData = 0; nErr = ERR_STRDUP((char*)pup->cpcSrch + 1, &pszURLData); if (SUCCESS == nErr) { nErr = Config_CookiesSubmit(me, pszURLData, &pBlob, &nBlobLen); } FREEIF(pszURLData); } else if (STRBEGINS("cookies.del.sub", cpszUrl)) { nErr = Config_CookiesDeleteDone(me, &pBlob, &nBlobLen); } else if (STRBEGINS("cookies.del", cpszUrl)) { nErr = Config_CookiesDelete(me, &pBlob, &nBlobLen); } else if (STRBEGINS("cookies.info", cpszUrl)) { nErr = Config_CookiesInfo(me, &pBlob, &nBlobLen); } else if (STRBEGINS("cookies", cpszUrl)) { nErr = Config_Cookies(me, &pBlob, &nBlobLen); } else if (STRBEGINS("mailto.reset.sub", cpszUrl)) { nErr = Config_MailResetDone(me, &pBlob, &nBlobLen); } else if (STRBEGINS("mailto.reset", cpszUrl)) { nErr = Config_MailReset(me, &pBlob, &nBlobLen); } else if (STRBEGINS("mailto.sub", cpszUrl)) { char *pszURLData = 0; nErr = ERR_STRDUP((char*)pup->cpcSrch + 1, &pszURLData); if (SUCCESS == nErr) { nErr = Config_MailSubmit(me, pszURLData, &pBlob, &nBlobLen); } FREEIF(pszURLData); } else if (STRBEGINS("mailto", cpszUrl)) { nErr = Config_Mail(me, &pBlob, &nBlobLen); } else if (STRBEGINS("homepage.reset.sub", cpszUrl)) { nErr = Config_HomePageResetDone(me, &pBlob, &nBlobLen); } else if (STRBEGINS("homepage.reset", cpszUrl)) { nErr = Config_HomePageReset(me, &pBlob, &nBlobLen); } else if (STRBEGINS("homepage.sub", cpszUrl)) { char *pszURLData = 0; nErr = ERR_STRDUP((char*)pup->cpcSrch + 1, &pszURLData); if (SUCCESS == nErr) { nErr = Config_HomePageSubmit(me, pszURLData, &pBlob, &nBlobLen); } FREEIF(pszURLData); } else if (STRBEGINS("homepage", cpszUrl)) { nErr = Config_HomePage(me, &pBlob, &nBlobLen); } } if ((AEEResBlob *)0 != pBlob) { if (0 < AEEResBlob_StrRepl(&pBlob, &nBlobLen, "invoke%s\0", me->szInvoke)) { nErr = ENOMEMORY; } if (SUCCESS == nErr) { nErr = ISOURCEUTIL_SourceFromMemory(me->plcgie->piSourceUtil, RESBLOB_DATA(pBlob), STRLEN(RESBLOB_DATA(pBlob)), GET_HELPER()->free, pBlob, &me->wri.pisMessage); } if (SUCCESS == nErr) { me->wri.lContentLength = STRLEN(RESBLOB_DATA(pBlob)); me->wri.nCode = WEBCODE_OK; } else { FREE(pBlob); } } return nErr; }
BOOL INSTAPI SQLInstallTranslatorExW (LPCWSTR lpszTranslator, LPCWSTR lpszPathIn, LPWSTR lpszPathOut, WORD cbPathOutMax, WORD * pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount) { char *_translator_u8 = NULL; char *_pathin_u8 = NULL; char *_pathout_u8 = NULL; BOOL retcode = FALSE; int length; SQLWCHAR *ptr; char *ptr_u8; for (length = 0, ptr = (SQLWCHAR *) lpszTranslator; *ptr; length += WCSLEN (ptr) + 1, ptr += WCSLEN (ptr) + 1); if (length > 0) { if ((_translator_u8 = malloc (length * UTF8_MAX_CHAR_LEN + 1)) != NULL) { for (ptr = (SQLWCHAR *) lpszTranslator, ptr_u8 = _translator_u8; *ptr; ptr += WCSLEN (ptr) + 1, ptr_u8 += STRLEN (ptr_u8) + 1) dm_StrCopyOut2_W2A (ptr, ptr_u8, WCSLEN (ptr) * UTF8_MAX_CHAR_LEN, NULL); *ptr_u8 = '\0'; } } else _translator_u8 = (char *) dm_SQL_WtoU8 ((SQLWCHAR *) lpszTranslator, SQL_NTS); if (_translator_u8 == NULL && lpszTranslator) { PUSH_ERROR (ODBC_ERROR_OUT_OF_MEM); goto done; } _pathin_u8 = (char *) dm_SQL_WtoU8 ((SQLWCHAR *) lpszPathIn, SQL_NTS); if (_pathin_u8 == NULL && lpszPathIn) { PUSH_ERROR (ODBC_ERROR_OUT_OF_MEM); goto done; } if (cbPathOutMax > 0) { if ((_pathout_u8 = malloc (cbPathOutMax * UTF8_MAX_CHAR_LEN + 1)) == NULL) { PUSH_ERROR (ODBC_ERROR_OUT_OF_MEM); goto done; } } retcode = SQLInstallTranslatorEx (_translator_u8, _pathin_u8, _pathout_u8, cbPathOutMax * UTF8_MAX_CHAR_LEN, pcbPathOut, fRequest, lpdwUsageCount); if (retcode == TRUE) { dm_StrCopyOut2_U8toW (_pathout_u8, lpszPathOut, cbPathOutMax, pcbPathOut); } done: MEM_FREE (_translator_u8); MEM_FREE (_pathin_u8); MEM_FREE (_pathout_u8); return retcode; }
static int Config_Proxies(LCGIResp *me, AEEResBlob **ppBlob, int *pnBlobLen) { int nErr; BrewserProxyCfg cfgDef; const BrewserProxyCfg *pcfg = 0; ZEROAT(&cfgDef); nErr = IShell_LoadResBlob(me->plcgie->piShell, BREWSER_RES_FILE, IDX_CFGPROXY, ppBlob, pnBlobLen); if (SUCCESS == nErr) { nErr = Brewser_GetProxyCfgPtr(me->pbsr, &pcfg); if (SUCCESS != nErr) { pcfg = &cfgDef; } } if (SUCCESS == nErr) { const char *cpszHttpHost = pcfg->szStrings; const char *cpszFtpHost = cpszHttpHost + STRLEN(cpszHttpHost) + 1; const char *cpszGophHost = cpszFtpHost + STRLEN(cpszFtpHost) + 1; const char *cpszOthHost = cpszGophHost + STRLEN(cpszGophHost) + 1; const char *cpszOthSchm = cpszOthHost + STRLEN(cpszOthHost) + 1; char szHttpPort[6]; char szFtpPort[6]; char szGophPort[6]; char szOthPort[6]; if (0 != pcfg->usHttpPort) { SNPRINTF(szHttpPort,sizeof(szHttpPort),"%d",pcfg->usHttpPort); } else { szHttpPort[0] = '\0'; } if (0 != pcfg->usFtpPort) { SNPRINTF(szFtpPort,sizeof(szFtpPort),"%d",pcfg->usFtpPort); } else { szFtpPort[0] = '\0'; } if (0 != pcfg->usGophPort) { SNPRINTF(szGophPort,sizeof(szGophPort),"%d",pcfg->usGophPort); } else { szGophPort[0] = '\0'; } if (0 != pcfg->usOthPort) { SNPRINTF(szOthPort,sizeof(szOthPort),"%d",pcfg->usOthPort); } else { szOthPort[0] = '\0'; } /* Template: <html> <h2 align=center>Proxies</h2> <a href="lcgi:cfg.{invoke}.prox.reset">Reset to default</a> <form action="lcgi:cfg.{invoke}.prox.ok"> <input type=checkbox name=httpon {httpon}>Proxy HTTP<br> Host <b>:</b> Port<br> <input type=text size=13 name=httphost value="{httphost}"> <b>:</b> <input type=text size=5 name=httpport value="{httpport}"><br> <input type=checkbox name=ftpon {ftpon}>Proxy FTP<br> Host <b>:</b> Port<br> <input type=text size=13 name=ftphost value="{ftphost}"> <b>:</b> <input type=text size=5 name=ftpport value="{ftpport}"><br> <input type=checkbox name=gophon {gophon}>Proxy Gopher<br> Host <b>:</b> Port<br> <input type=text size=13 name=gophost value="{gophhost}"> <b>:</b> <input type=text size=5 name=gopport value="{gophport}"><br> <input type=checkbox name=othon {othon}>Proxy Other<br> Host <b>:</b> Port<br> <input type=text size=13 name=othhost value="{othhost}"> <b>:</b> <input type=text size=5 name=othport value="{othport}"><br> Schemes: (';' separated)<br> <input type=text size=50 name=othschm value="{othschm}"><br> <a href="x-submit:">Save</a> </form> </html> */ if (0 < AEEResBlob_StrRepl(ppBlob, pnBlobLen, "httpon%s\0httphost%Qs\0httpport%Qs\0" "ftpon%s\0ftphost%Qs\0ftpport%Qs\0" "gophon%s\0gophhost%Qs\0gophport%Qs\0" "othon%s\0othschm%Qs\0" "othhost%Qs\0othport%Qs\0", (pcfg->bHttpOn ? "checked" : ""), cpszHttpHost, szHttpPort, (pcfg->bFtpOn ? "checked" : ""), cpszFtpHost, szFtpPort, (pcfg->bGophOn ? "checked" : ""), cpszGophHost, szGophPort, (pcfg->bOthOn ? "checked" : ""), cpszOthSchm, cpszOthHost, szOthPort)) { nErr = ENOMEMORY; } } return nErr; }
char * gvconfig_libdir(GVC_t * gvc) { static char line[BSZ]; static char *libdir; static boolean dirShown = 0; char *tmp; if (!libdir) { libdir=getenv("GVBINDIR"); if (!libdir) { #ifdef WIN32 int r; char* s; MEMORY_BASIC_INFORMATION mbi; if (VirtualQuery (&gvconfig_libdir, &mbi, sizeof(mbi)) == 0) { agerr(AGERR,"failed to get handle for executable.\n"); return 0; } r = GetModuleFileName ((HMODULE)mbi.AllocationBase, line, BSZ); if (!r || (r == BSZ)) { agerr(AGERR,"failed to get path for executable.\n"); return 0; } s = strrchr(line,'\\'); if (!s) { agerr(AGERR,"no slash in path %s.\n", line); return 0; } *s = '\0'; libdir = line; #else libdir = GVLIBDIR; #ifdef __APPLE__ uint32_t i, c = _dyld_image_count(); size_t len, ind; const char* path; for (i = 0; i < c; ++i) { path = _dyld_get_image_name(i); tmp = strstr(path, "/libgvc."); if (tmp) { if (tmp > path) { /* Check for real /lib dir. Don't accept pre-install /.libs */ char* s = tmp-1; /* back up to previous slash (or head of string) */ while ((*s != '/') && (s > path)) s--; if (strncmp (s, DOTLIBS, STRLEN(DOTLIBS)) == 0) continue; } ind = tmp - path; /* byte offset */ len = ind + sizeof("/graphviz"); if (len < BSZ) libdir = line; else libdir = gmalloc(len); bcopy (path, libdir, ind); /* plugins are in "graphviz" subdirectory */ strcpy(libdir+ind, "/graphviz"); break; } } #else FILE* f = fopen ("/proc/self/maps", "r"); char* path; if (f) { while (!feof (f)) { if (!fgets (line, sizeof (line), f)) continue; if (!strstr (line, " r-xp ")) continue; path = strchr (line, '/'); if (!path) continue; tmp = strstr (path, "/libgvc."); if (tmp) { *tmp = 0; /* Check for real /lib dir. Don't accept pre-install /.libs */ if (strcmp(strrchr(path,'/'), "/.libs") == 0) continue; strcpy(line, path); /* use line buffer for result */ strcat(line, "/graphviz"); /* plugins are in "graphviz" subdirectory */ libdir = line; break; } } fclose (f); } #endif #endif } } if (gvc->common.verbose && !dirShown) { fprintf (stderr, "libdir = \"%s\"\n", (libdir ? libdir : "<null>")); dirShown = 1; } return libdir; }
return -1; } #/* */ EXPORT_DEF int at_parse_ccwa(char* str, unsigned * class) { /* * CCWA may be in form: * in response of AT+CCWA=? * +CCWA: (0,1) * in response of AT+CCWA=? * +CCWA: <n> * in response of "AT+CCWA=[<n>[,<mode>[,<class>]]]" * +CCWA: <status>,<class1> * * unsolicited result code * +CCWA: <number>,<type>,<class>,[<alpha>][,<CLI validity>[,<subaddr>,<satype>[,<priority>]]] */ char delimiters[] = ":,,"; char * marks[STRLEN(delimiters)]; /* parse URC only here */ if(mark_line(str, delimiters, marks) == ITEMS_OF(marks)) { if(sscanf(marks[2] + 1, "%u", class) == 1) return 0; } return -1; }
/* * Initialization routine for vim_findfile(). * * Returns the newly allocated search context or NULL if an error occurred. * * Don't forget to clean up by calling vim_findfile_cleanup() if you are done * with the search context. * * Find the file 'filename' in the directory 'path'. * The parameter 'path' may contain wildcards. If so only search 'level' * directories deep. The parameter 'level' is the absolute maximum and is * not related to restricts given to the '**' wildcard. If 'level' is 100 * and you use '**200' vim_findfile() will stop after 100 levels. * * 'filename' cannot contain wildcards! It is used as-is, no backslashes to * escape special characters. * * If 'stopdirs' is not NULL and nothing is found downward, the search is * restarted on the next higher directory level. This is repeated until the * start-directory of a search is contained in 'stopdirs'. 'stopdirs' has the * format ";*<dirname>*\(;<dirname>\)*;\=$". * * If the 'path' is relative, the starting dir for the search is either VIM's * current dir or if the path starts with "./" the current files dir. * If the 'path' is absolute, the starting dir is that part of the path before * the first wildcard. * * Upward search is only done on the starting dir. * * If 'free_visited' is TRUE the list of already visited files/directories is * cleared. Set this to FALSE if you just want to search from another * directory, but want to be sure that no directory from a previous search is * searched again. This is useful if you search for a file at different places. * The list of visited files/dirs can also be cleared with the function * vim_findfile_free_visited(). * * Set the parameter 'find_what' to FINDFILE_DIR if you want to search for * directories only, FINDFILE_FILE for files only, FINDFILE_BOTH for both. * * A search context returned by a previous call to vim_findfile_init() can be * passed in the parameter "search_ctx_arg". This context is reused and * reinitialized with the new parameters. The list of already visited * directories from this context is only deleted if the parameter * "free_visited" is true. Be aware that the passed "search_ctx_arg" is freed * if the reinitialization fails. * * If you don't have a search context from a previous call "search_ctx_arg" * must be NULL. * * This function silently ignores a few errors, vim_findfile() will have * limited functionality then. */ void * vim_findfile_init ( char_u *path, char_u *filename, char_u *stopdirs, int level, int free_visited, int find_what, void *search_ctx_arg, int tagfile, /* expanding names of tags files */ char_u *rel_fname /* file name to use for "." */ ) { char_u *wc_part; ff_stack_T *sptr; ff_search_ctx_T *search_ctx; /* If a search context is given by the caller, reuse it, else allocate a * new one. */ if (search_ctx_arg != NULL) search_ctx = search_ctx_arg; else { search_ctx = xcalloc(1, sizeof(ff_search_ctx_T)); } search_ctx->ffsc_find_what = find_what; search_ctx->ffsc_tagfile = tagfile; /* clear the search context, but NOT the visited lists */ ff_clear(search_ctx); /* clear visited list if wanted */ if (free_visited == TRUE) vim_findfile_free_visited(search_ctx); else { /* Reuse old visited lists. Get the visited list for the given * filename. If no list for the current filename exists, creates a new * one. */ search_ctx->ffsc_visited_list = ff_get_visited_list(filename, &search_ctx->ffsc_visited_lists_list); if (search_ctx->ffsc_visited_list == NULL) goto error_return; search_ctx->ffsc_dir_visited_list = ff_get_visited_list(filename, &search_ctx->ffsc_dir_visited_lists_list); if (search_ctx->ffsc_dir_visited_list == NULL) goto error_return; } if (ff_expand_buffer == NULL) { ff_expand_buffer = xmalloc(MAXPATHL); } /* Store information on starting dir now if path is relative. * If path is absolute, we do that later. */ if (path[0] == '.' && (vim_ispathsep(path[1]) || path[1] == NUL) && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL) && rel_fname != NULL) { size_t len = (size_t)(path_tail(rel_fname) - rel_fname); if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) { /* Make the start dir an absolute path name. */ STRLCPY(ff_expand_buffer, rel_fname, len + 1); search_ctx->ffsc_start_dir = (char_u *)FullName_save((char *)ff_expand_buffer, FALSE); } else search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len); if (*++path != NUL) ++path; } else if (*path == NUL || !vim_isAbsName(path)) { #ifdef BACKSLASH_IN_FILENAME /* "c:dir" needs "c:" to be expanded, otherwise use current dir */ if (*path != NUL && path[1] == ':') { char_u drive[3]; drive[0] = path[0]; drive[1] = ':'; drive[2] = NUL; if (vim_FullName(drive, ff_expand_buffer, MAXPATHL, TRUE) == FAIL) goto error_return; path += 2; } else #endif if (os_dirname(ff_expand_buffer, MAXPATHL) == FAIL) goto error_return; search_ctx->ffsc_start_dir = vim_strsave(ff_expand_buffer); #ifdef BACKSLASH_IN_FILENAME /* A path that starts with "/dir" is relative to the drive, not to the * directory (but not for "//machine/dir"). Only use the drive name. */ if ((*path == '/' || *path == '\\') && path[1] != path[0] && search_ctx->ffsc_start_dir[1] == ':') search_ctx->ffsc_start_dir[2] = NUL; #endif } /* * If stopdirs are given, split them into an array of pointers. * If this fails (mem allocation), there is no upward search at all or a * stop directory is not recognized -> continue silently. * If stopdirs just contains a ";" or is empty, * search_ctx->ffsc_stopdirs_v will only contain a NULL pointer. This * is handled as unlimited upward search. See function * ff_path_in_stoplist() for details. */ if (stopdirs != NULL) { char_u *walker = stopdirs; while (*walker == ';') walker++; size_t dircount = 1; search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *)); do { char_u *helper; void *ptr; helper = walker; ptr = xrealloc(search_ctx->ffsc_stopdirs_v, (dircount + 1) * sizeof(char_u *)); search_ctx->ffsc_stopdirs_v = ptr; walker = vim_strchr(walker, ';'); if (walker) { assert(walker - helper >= 0); search_ctx->ffsc_stopdirs_v[dircount-1] = vim_strnsave(helper, (size_t)(walker - helper)); walker++; } else /* this might be "", which means ascent till top * of directory tree. */ search_ctx->ffsc_stopdirs_v[dircount-1] = vim_strsave(helper); dircount++; } while (walker != NULL); search_ctx->ffsc_stopdirs_v[dircount-1] = NULL; } search_ctx->ffsc_level = level; /* split into: * -fix path * -wildcard_stuff (might be NULL) */ wc_part = vim_strchr(path, '*'); if (wc_part != NULL) { int64_t llevel; int len; char *errpt; /* save the fix part of the path */ assert(wc_part - path >= 0); search_ctx->ffsc_fix_path = vim_strnsave(path, (size_t)(wc_part - path)); /* * copy wc_path and add restricts to the '**' wildcard. * The octet after a '**' is used as a (binary) counter. * So '**3' is transposed to '**^C' ('^C' is ASCII value 3) * or '**76' is transposed to '**N'( 'N' is ASCII value 76). * If no restrict is given after '**' the default is used. * Due to this technique the path looks awful if you print it as a * string. */ len = 0; while (*wc_part != NUL) { if (len + 5 >= MAXPATHL) { EMSG(_(e_pathtoolong)); break; } if (STRNCMP(wc_part, "**", 2) == 0) { ff_expand_buffer[len++] = *wc_part++; ff_expand_buffer[len++] = *wc_part++; llevel = strtol((char *)wc_part, &errpt, 10); if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255) ff_expand_buffer[len++] = (char_u)llevel; else if ((char_u *)errpt != wc_part && llevel == 0) /* restrict is 0 -> remove already added '**' */ len -= 2; else ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND; wc_part = (char_u *)errpt; if (*wc_part != NUL && !vim_ispathsep(*wc_part)) { EMSG2(_( "E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."), PATHSEPSTR); goto error_return; } } else ff_expand_buffer[len++] = *wc_part++; } ff_expand_buffer[len] = NUL; search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer); } else search_ctx->ffsc_fix_path = vim_strsave(path); if (search_ctx->ffsc_start_dir == NULL) { /* store the fix part as startdir. * This is needed if the parameter path is fully qualified. */ search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path); search_ctx->ffsc_fix_path[0] = NUL; } /* create an absolute path */ if (STRLEN(search_ctx->ffsc_start_dir) + STRLEN(search_ctx->ffsc_fix_path) + 3 >= MAXPATHL) { EMSG(_(e_pathtoolong)); goto error_return; } STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir); add_pathsep((char *)ff_expand_buffer); { size_t eb_len = STRLEN(ff_expand_buffer); char_u *buf = xmalloc(eb_len + STRLEN(search_ctx->ffsc_fix_path) + 1); STRCPY(buf, ff_expand_buffer); STRCPY(buf + eb_len, search_ctx->ffsc_fix_path); if (os_isdir(buf)) { STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path); add_pathsep((char *)ff_expand_buffer); } else { char_u *p = path_tail(search_ctx->ffsc_fix_path); char_u *wc_path = NULL; char_u *temp = NULL; int len = 0; if (p > search_ctx->ffsc_fix_path) { len = (int)(p - search_ctx->ffsc_fix_path) - 1; STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len); add_pathsep((char *)ff_expand_buffer); } else { len = (int)STRLEN(search_ctx->ffsc_fix_path); } if (search_ctx->ffsc_wc_path != NULL) { wc_path = vim_strsave(search_ctx->ffsc_wc_path); temp = xmalloc(STRLEN(search_ctx->ffsc_wc_path) + STRLEN(search_ctx->ffsc_fix_path + len) + 1); STRCPY(temp, search_ctx->ffsc_fix_path + len); STRCAT(temp, search_ctx->ffsc_wc_path); xfree(search_ctx->ffsc_wc_path); xfree(wc_path); search_ctx->ffsc_wc_path = temp; } } xfree(buf); } sptr = ff_create_stack_element(ff_expand_buffer, search_ctx->ffsc_wc_path, level, 0); ff_push(search_ctx, sptr); search_ctx->ffsc_file_to_search = vim_strsave(filename); return search_ctx; error_return: /* * We clear the search context now! * Even when the caller gave us a (perhaps valid) context we free it here, * as we might have already destroyed it. */ vim_findfile_cleanup(search_ctx); return NULL; }
// // Get the INPUT/OUTPUT entry in the MDF for this parameter. // The returned string must be freed by the caller. // char *ParameterDefinition::getMDFString() { int i, typecnt= this->getTypes()->getSize(); const char* const *typeNames = this->getTypeStrings(); char *types = new char[64 * typecnt]; types[0] = '\0'; char *p = types; for (i=0; i<typecnt ; i++, p+=STRLEN(p)) { if (i+1 == typecnt) sprintf(p,"%s",typeNames[i]); else sprintf(p,"%s or ",typeNames[i]); } const char *name = this->getNameString(); char attributes[128]; const char *dflt = this->getDefaultValue(); const char *desc = this->getDescription(); *attributes = '['; p = &attributes[1]; *p = '\0'; if (!this->isViewable()) { sprintf(p,"visible:2 "); p += STRLEN(p); } else if (this->getDefaultVisibility() == false) { sprintf(p,"visible:0 "); p += STRLEN(p); } Cacheability c = this->getDefaultCacheability(); if (this->isInput()) { if (c != InputDerivesOutputCacheTag) { sprintf(p,"cache:%d ",c); p += STRLEN(p); } int output = this->getRerouteOutput(); if (output > 0) { sprintf(p,"reroute:%d ",output-1); // Executive uses 0 based p += STRLEN(p); } } else if (c != OutputFullyCached) { sprintf(p,"cache:%d ", c); p += STRLEN(p); } if (STRLEN(attributes) > 1) strcat(p,"]"); else *attributes = '\0'; int len = STRLEN(name) + STRLEN(attributes) + STRLEN(types) + STRLEN(dflt) + STRLEN(desc) + 20; char *mdf = new char[len]; if (this->isInput()) sprintf(mdf,"INPUT %s %s ; %s ; %s ; %s\n", name, attributes, types, (dflt && !EqualString(dflt,"NULL") ? dflt : ""), (desc ? desc : "")); else sprintf(mdf,"OUTPUT %s %s ; %s ; %s\n", name, attributes, types, (desc ? desc : "")); delete types; return mdf; }
void show_source_line(boolean_t warn) { char *b, *b_top, *c, *c_top, *buf; char source_line_buff[MAX_SRCLINE + SIZEOF(ARROW)]; ssize_t buflen; int chlen, chwidth; unsigned int ch, line_chwidth = 0; boolean_t unable_to_complete_arrow = FALSE; mstr msgstr; DCL_THREADGBL_ACCESS; SETUP_THREADGBL_ACCESS; buf = source_line_buff; buflen = SIZEOF(source_line_buff); b_top = buf + buflen - STR_LIT_LEN(ARROW) - 1; /* allow room for arrow and string terminator */ for (c = (char *)source_buffer, b = buf, c_top = c + TREF(last_source_column) - 1; c < c_top;) { if ('\t' == *c) { if ((b + 1) > b_top) { unable_to_complete_arrow = TRUE; break; } *b++ = *c++; } else if (!gtm_utf8_mode || (ASCII_MAX >= *(uchar_ptr_t)c)) { if ((b + 1) > b_top) { unable_to_complete_arrow = TRUE; break; } *b++ = ' '; c++; } # ifdef UNICODE_SUPPORTED else { chlen = (int)(UTF8_MBTOWC(c, c_top, ch) - (uchar_ptr_t)c); if (WEOF != ch && (0 < (chwidth = UTF8_WCWIDTH(ch)))) /* assignment */ { if ((b + chwidth) > b_top) { unable_to_complete_arrow = TRUE; break; } memset(b, ' ', chwidth); b += chwidth; } c += chlen; } # endif } if (unable_to_complete_arrow) { msgstr.addr = buf; msgstr.len = buflen; dec_nofac = TRUE; gtm_getmsg(ERR_ARROWNTDSP, &msgstr); dec_nofac = FALSE; } else { memcpy(b, ARROW, STR_LIT_LEN(ARROW)); b += STR_LIT_LEN(ARROW); *b = '\0'; } if (warn) { for (c = (char *)source_buffer; c < (char *)source_buffer + STRLEN((char *)source_buffer) - 1; ) { if ('\t' == *c) { line_chwidth++; c++; } else if (!gtm_utf8_mode || (ASCII_MAX >= *(uchar_ptr_t)c)) { line_chwidth++; c++; } else { # ifdef UNICODE_SUPPORTED /* funky positioning makes VMS compiler happy */ chlen = (int)(UTF8_MBTOWC(c, (char *)source_buffer + STRLEN((char *)source_buffer) - 1, ch) - (uchar_ptr_t)c); if ((WEOF != ch) && 0 < (chwidth = UTF8_WCWIDTH(ch))) line_chwidth += chwidth; c += chlen; # endif } } dec_nofac = TRUE; if (MAXLINESIZEFORDISPLAY > line_chwidth) if (unable_to_complete_arrow) dec_err(VARLSTCNT(6) ERR_SRCLIN, 4, LEN_AND_STR((char *)source_buffer), msgstr.len, msgstr.addr); else dec_err(VARLSTCNT(6) ERR_SRCLIN, 4, LEN_AND_STR((char *)source_buffer), b - buf, buf); else dec_err(VARLSTCNT(2) ERR_SRCLNNTDSP, 1, MAXLINESIZEFORDISPLAY); if (!run_time) dec_err(VARLSTCNT(6) ERR_SRCLOC, 4, TREF(last_source_column), source_line, source_name_len, source_file_name); dec_nofac = FALSE; } }
BOOL create_confirm_Internal (HWND hwnd, SQLPOINTER dsn, SQLPOINTER text, SQLCHAR waMode) { EventTypeSpec controlSpec = { kEventClassControl, kEventControlHit }; RgnHandle cursorRgn = NULL; ControlID controlID; ControlRef control; WindowRef wconfirm; TCONFIRM confirm_t; EventRecord event; IBNibRef nibRef; CFStringRef msg; OSStatus err; /* Search the bundle for a .nib file named 'odbcadmin'. */ err = CreateNibReferenceWithCFBundle (CFBundleGetBundleWithIdentifier (CFSTR ("org.iodbc.drvproxy")), CFSTR ("confirmation"), &nibRef); if (err == noErr) { /* Nib found ... so create the window */ CreateWindowFromNib (nibRef, CFSTR ("Dialog"), &wconfirm); DisposeNibReference (nibRef); /* Set the title with the DSN name */ if (dsn) { if (waMode == 'A') msg = CFStringCreateWithBytes (NULL, (unsigned char*)dsn, STRLEN(dsn), kCFStringEncodingUTF8, false); else msg = convert_wchar_to_CFString((wchar_t*)dsn); SetWindowTitleWithCFString (wconfirm, msg); CFRelease(msg); } /* Install handlers for the finish button, the cancel */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, CONFYES_CNTL, wconfirm, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (confirmadm_yes_clicked), 1, &controlSpec, &confirm_t, NULL); GETCONTROLBYID (controlID, CNTL_SIGNATURE, CONFNO_CNTL, wconfirm, control); InstallEventHandler (GetControlEventTarget (control), NewEventHandlerUPP (confirmadm_no_clicked), 1, &controlSpec, &confirm_t, NULL); /* Change the static field with the message */ GETCONTROLBYID (controlID, CNTL_SIGNATURE, CONFTEXT_CNTL, wconfirm, control); if (waMode == 'A') SetControlData (control, 0, kControlEditTextTextTag, STRLEN (text), text); else { msg = convert_wchar_to_CFString((wchar_t*)text); SetControlData (control, 0, kControlEditTextCFStringTag, sizeof(CFStringRef), &msg); CFRelease(msg); } DrawOneControl (control); confirm_t.yes_no = FALSE; confirm_t.mainwnd = wconfirm; /* Show the window and run the loop */ ShowWindow (wconfirm); /* The main loop */ while (confirm_t.mainwnd) WaitNextEvent (everyEvent, &event, 60L, cursorRgn); } else goto error; return confirm_t.yes_no; error: fprintf (stderr, "Can't load Window. Err: %d\n", (int) err); return confirm_t.yes_no; }
bool same_device_check (mstr tname, char *buf) { int fstat_res, gsn_stat; struct stat outbuf1, outbuf2; GTM_SOCKLEN_TYPE socknamelen1; GTM_SOCKLEN_TYPE socknamelen2; GTM_SOCKLEN_TYPE psocknamelen1; GTM_SOCKLEN_TYPE psocknamelen2; struct sockaddr_storage sockname1; struct sockaddr_storage sockname2; struct sockaddr_storage psockname1; struct sockaddr_storage psockname2; char port_buffer1[NI_MAXSERV]; char port_buffer2[NI_MAXSERV]; char pport_buffer1[NI_MAXSERV]; char pport_buffer2[NI_MAXSERV]; char host_buffer1[NI_MAXHOST]; char host_buffer2[NI_MAXHOST]; char phost_buffer1[NI_MAXHOST]; char phost_buffer2[NI_MAXHOST]; int errcode, tmplen, save_errno; const char *errptr; FSTAT_FILE(0, &outbuf1, fstat_res); if (-1 == fstat_res) { save_errno = errno; rts_error_csa(CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, RTS_ERROR_LITERAL("fstat"), CALLFROM, save_errno); } FSTAT_FILE(1, &outbuf2, fstat_res); if (-1 == fstat_res) { save_errno = errno; rts_error_csa(CSA_ARG(NULL) VARLSTCNT(8) ERR_SYSCALL, 5, RTS_ERROR_LITERAL("fstat"), CALLFROM, save_errno); } if ((S_IFMT & outbuf1.st_mode) != (S_IFMT & outbuf2.st_mode)) return FALSE; if (S_ISSOCK(outbuf1.st_mode)) { /* if here then both 0,1 are sockets */ socknamelen1 = SIZEOF(sockname1); if (-1 == (gsn_stat = getsockname(0, (struct sockaddr *)&sockname1, (GTM_SOCKLEN_TYPE *)&socknamelen1))) { save_errno = errno; if (IS_SOCKNAME_UNIXERROR(save_errno)) { /* problem with getsockname for AF_UNIX socket so just assign family for the switch below */ (((sockaddr_ptr)&sockname1)->sa_family) = AF_UNIX; } else { /* process error */ errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } } socknamelen2 = SIZEOF(sockname2); if (-1 == (gsn_stat = getsockname(1, (struct sockaddr *)&sockname2, (GTM_SOCKLEN_TYPE *)&socknamelen2))) { save_errno = errno; if (IS_SOCKNAME_UNIXERROR(save_errno)) { /* problem with getsockname for AF_UNIX socket so just assign family for the switch below */ (((sockaddr_ptr)&sockname2)->sa_family) = AF_UNIX; } else { /* process error */ errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } } /* if both sockets not the same family then not the same device */ if ((((sockaddr_ptr)&sockname1)->sa_family) != (((sockaddr_ptr)&sockname2)->sa_family)) return FALSE; switch(((sockaddr_ptr)&sockname1)->sa_family) { case AF_INET: case AF_INET6: GETNAMEINFO((struct sockaddr *)&sockname1, socknamelen1, host_buffer1, NI_MAXHOST, port_buffer1, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } GETNAMEINFO((struct sockaddr *)&sockname2, socknamelen2, host_buffer2, NI_MAXHOST, port_buffer2, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } /* hosts and ports must be the same */ if (STRCMP(host_buffer1, host_buffer2) || STRCMP(port_buffer1, port_buffer2)) return FALSE; psocknamelen1 = SIZEOF(psockname1); if (-1 == (gsn_stat = getpeername(0, (struct sockaddr *)&psockname1, (GTM_SOCKLEN_TYPE *)&psocknamelen1))) { save_errno = errno; errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } psocknamelen2 = SIZEOF(psockname2); if (-1 == (gsn_stat = getpeername(1, (struct sockaddr *)&psockname2, (GTM_SOCKLEN_TYPE *)&psocknamelen2))) { save_errno = errno; errptr = (char *)STRERROR(save_errno); tmplen = STRLEN(errptr); rts_error_csa(CSA_ARG(NULL) VARLSTCNT(5) ERR_GETSOCKNAMERR, 3, save_errno, tmplen, errptr); } GETNAMEINFO((struct sockaddr *)&psockname1, psocknamelen1, phost_buffer1, NI_MAXHOST, pport_buffer1, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } GETNAMEINFO((struct sockaddr *)&psockname2, psocknamelen2, phost_buffer2, NI_MAXHOST, pport_buffer2, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV, errcode); if (0 != errcode) { RTS_ERROR_ADDRINFO(NULL, ERR_GETNAMEINFO, errcode); return FALSE; } /* hosts and ports for the peer sockets must also be the same */ if (STRCMP(phost_buffer1, phost_buffer2) || STRCMP(pport_buffer1, pport_buffer2)) return FALSE; break; case AF_UNIX: default: /* if inodes are different or st_dev different then not the same device */ if ((outbuf1.st_ino != outbuf2.st_ino) || (outbuf1.st_dev != outbuf2.st_dev)) return FALSE; break; } return TRUE; } else if (S_ISCHR(outbuf1.st_mode)) { /* if here then both 0,1 are character devices */ /* if inodes are different or st_dev different then not the same device */ if ((outbuf1.st_ino != outbuf2.st_ino) || (outbuf1.st_dev != outbuf2.st_dev)) return FALSE; else return TRUE; } else { /* unexpected type so assert */ assert(FALSE); return FALSE; } }
/* * List all features aligned in columns, dictionary style. */ static void list_features(void) { int i; int ncol; int nrow; int nfeat = 0; int width = 0; /* Find the length of the longest feature name, use that + 1 as the column * width */ for (i = 0; features[i] != NULL; ++i) { int l = (int)STRLEN(features[i]); if (l > width) width = l; ++nfeat; } width += 1; if (Columns < width) { /* Not enough screen columns - show one per line */ for (i = 0; features[i] != NULL; ++i) { version_msg(features[i]); if (msg_col > 0) msg_putchar('\n'); } return; } /* The rightmost column doesn't need a separator. * Sacrifice it to fit in one more column if possible. */ ncol = (int) (Columns + 1) / width; nrow = nfeat / ncol + (nfeat % ncol ? 1 : 0); /* i counts columns then rows. idx counts rows then columns. */ for (i = 0; !got_int && i < nrow * ncol; ++i) { int idx = (i / ncol) + (i % ncol) * nrow; if (idx < nfeat) { int last_col = (i + 1) % ncol == 0; msg_puts((char_u *)features[idx]); if (last_col) { if (msg_col > 0) msg_putchar('\n'); } else { while (msg_col % width) msg_putchar(' '); } } else { if (msg_col > 0) msg_putchar('\n'); } } }
static void do_intro_line( int row, char_u *mesg, int add_version, int attr) { char_u vers[20]; int col; char_u *p; int l; int clen; #ifdef MODIFIED_BY # define MODBY_LEN 150 char_u modby[MODBY_LEN]; if (*mesg == ' ') { vim_strncpy(modby, (char_u *)_("Modified by "), MODBY_LEN - 1); l = (int)STRLEN(modby); vim_strncpy(modby + l, (char_u *)MODIFIED_BY, MODBY_LEN - l - 1); mesg = modby; } #endif /* Center the message horizontally. */ col = vim_strsize(mesg); if (add_version) { STRCPY(vers, mediumVersion); if (highest_patch()) { /* Check for 9.9x or 9.9xx, alpha/beta version */ if (isalpha((int)vers[3])) { int len = (isalpha((int)vers[4])) ? 5 : 4; sprintf((char *)vers + len, ".%d%s", highest_patch(), mediumVersion + len); } else sprintf((char *)vers + 3, ".%d", highest_patch()); } col += (int)STRLEN(vers); } col = (Columns - col) / 2; if (col < 0) col = 0; /* Split up in parts to highlight <> items differently. */ for (p = mesg; *p != NUL; p += l) { clen = 0; for (l = 0; p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) { #ifdef FEAT_MBYTE if (has_mbyte) { clen += ptr2cells(p + l); l += (*mb_ptr2len)(p + l) - 1; } else #endif clen += byte2cells(p[l]); } screen_puts_len(p, l, row, col, *p == '<' ? hl_attr(HLF_8) : attr); col += clen; } /* Add the version number to the version line. */ if (add_version) screen_puts(vers, row, col, 0); }
/// Map Farsi keyboard when in fkmap mode. int fkmap(int c) { int tempc; static int revins; if (IS_SPECIAL(c)) { return c; } if (VIM_ISDIGIT(c) || (((c == '.') || (c == '+') || (c == '-') || (c == '^') || (c == '%') || (c == '#') || (c == '=')) && revins)) { if (!revins) { if (curwin->w_cursor.col) { if (!p_ri) { dec_cursor(); } chg_c_toX_orX(); chg_l_toXor_X(); if (!p_ri) { inc_cursor(); } } } arrow_used = TRUE; (void)stop_arrow(); if (!curwin->w_p_rl && revins) { inc_cursor(); } revins++; p_ri = 1; } else { if (revins) { arrow_used = TRUE; (void)stop_arrow(); revins = 0; if (curwin->w_p_rl) { while ((F_isdigit(gchar_cursor()) || (gchar_cursor() == F_PERIOD || gchar_cursor() == F_PLUS || gchar_cursor() == F_MINUS || gchar_cursor() == F_MUL || gchar_cursor() == F_DIVIDE || gchar_cursor() == F_PERCENT || gchar_cursor() == F_EQUALS)) && gchar_cursor() != '\0') { curwin->w_cursor.col++; } } else { if (curwin->w_cursor.col) { while ((F_isdigit(gchar_cursor()) || (gchar_cursor() == F_PERIOD || gchar_cursor() == F_PLUS || gchar_cursor() == F_MINUS || gchar_cursor() == F_MUL || gchar_cursor() == F_DIVIDE || gchar_cursor() == F_PERCENT || gchar_cursor() == F_EQUALS)) && --curwin->w_cursor.col) { } } if (!F_isdigit(gchar_cursor())) { ++curwin->w_cursor.col; } } } } if (!revins) { if (curwin->w_p_rl) { p_ri = 0; } if (!curwin->w_p_rl) { p_ri = 1; } } if ((c < 0x100) && (isalpha(c) || (c == '&') || (c == '^') || (c == ';') || (c == '\'') || (c == ',') || (c == '[') || (c == ']') || (c == '{') || (c == '}'))) { chg_r_to_Xor_X_(); } tempc = 0; switch (c) { case '`': case ' ': case '.': case '!': case '"': case '$': case '%': case '^': case '&': case '/': case '(': case ')': case '=': case '\\': case '?': case '+': case '-': case '_': case '*': case ':': case '#': case '~': case '@': case '<': case '>': case '{': case '}': case '|': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'B': case 'E': case 'F': case 'H': case 'I': case 'K': case 'L': case 'M': case 'O': case 'P': case 'Q': case 'R': case 'T': case 'U': case 'W': case 'Y': case NL: case TAB: if (p_ri && (c == NL) && curwin->w_cursor.col) { // If the char before the cursor is _X_ or X_ do not change // the one under the cursor with X type. dec_cursor(); if (F_isalpha(gchar_cursor())) { inc_cursor(); return NL; } inc_cursor(); } if (!p_ri) { if (!curwin->w_cursor.col) { switch (c) { case '0': return FARSI_0; case '1': return FARSI_1; case '2': return FARSI_2; case '3': return FARSI_3; case '4': return FARSI_4; case '5': return FARSI_5; case '6': return FARSI_6; case '7': return FARSI_7; case '8': return FARSI_8; case '9': return FARSI_9; case 'B': return F_PSP; case 'E': return JAZR_N; case 'F': return ALEF_D_H; case 'H': return ALEF_A; case 'I': return TASH; case 'K': return F_LQUOT; case 'L': return F_RQUOT; case 'M': return HAMZE; case 'O': return '['; case 'P': return ']'; case 'Q': return OO; case 'R': return MAD_N; case 'T': return OW; case 'U': return MAD; case 'W': return OW_OW; case 'Y': return JAZR; case '`': return F_PCN; case '!': return F_EXCL; case '@': return F_COMMA; case '#': return F_DIVIDE; case '$': return F_CURRENCY; case '%': return F_PERCENT; case '^': return F_MUL; case '&': return F_BCOMMA; case '*': return F_STAR; case '(': return F_LPARENT; case ')': return F_RPARENT; case '-': return F_MINUS; case '_': return F_UNDERLINE; case '=': return F_EQUALS; case '+': return F_PLUS; case '\\': return F_BSLASH; case '|': return F_PIPE; case ':': return F_DCOLON; case '"': return F_SEMICOLON; case '.': return F_PERIOD; case '/': return F_SLASH; case '<': return F_LESS; case '>': return F_GREATER; case '?': return F_QUESTION; case ' ': return F_BLANK; } break; } } if (!p_ri) { dec_cursor(); } switch ((tempc = gchar_cursor())) { case _BE: case _PE: case _TE: case _SE: case _JIM: case _CHE: case _HE_J: case _XE: case _SIN: case _SHIN: case _SAD: case _ZAD: case _FE: case _GHAF: case _KAF: case _KAF_H: case _GAF: case _LAM: case _MIM: case _NOON: case _HE: case _HE_: case _TA: case _ZA: put_curr_and_l_to_X(toF_TyA(tempc)); break; case _AYN: case _AYN_: if (!p_ri) { if (!curwin->w_cursor.col) { put_curr_and_l_to_X(AYN); break; } } if (p_ri) { inc_cursor(); } else { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = AYN_; } else { tempc = AYN; } if (p_ri) { dec_cursor(); } else { inc_cursor(); } put_curr_and_l_to_X(tempc); break; case _GHAYN: case _GHAYN_: if (!p_ri) { if (!curwin->w_cursor.col) { put_curr_and_l_to_X(GHAYN); break; } } if (p_ri) { inc_cursor(); } else { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = GHAYN_; } else { tempc = GHAYN; } if (p_ri) { dec_cursor(); } else { inc_cursor(); } put_curr_and_l_to_X(tempc); break; case _YE: case _IE: case _YEE: if (!p_ri) { if (!curwin->w_cursor.col) { put_curr_and_l_to_X((tempc == _YE ? YE : (tempc == _IE ? IE : YEE))); break; } } if (p_ri) { inc_cursor(); } else { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = (tempc == _YE ? YE_ : (tempc == _IE ? IE_ : YEE_)); } else { tempc = (tempc == _YE ? YE : (tempc == _IE ? IE : YEE)); } if (p_ri) { dec_cursor(); } else { inc_cursor(); } put_curr_and_l_to_X(tempc); break; } if (!p_ri) { inc_cursor(); } tempc = 0; switch (c) { case '0': return FARSI_0; case '1': return FARSI_1; case '2': return FARSI_2; case '3': return FARSI_3; case '4': return FARSI_4; case '5': return FARSI_5; case '6': return FARSI_6; case '7': return FARSI_7; case '8': return FARSI_8; case '9': return FARSI_9; case 'B': return F_PSP; case 'E': return JAZR_N; case 'F': return ALEF_D_H; case 'H': return ALEF_A; case 'I': return TASH; case 'K': return F_LQUOT; case 'L': return F_RQUOT; case 'M': return HAMZE; case 'O': return '['; case 'P': return ']'; case 'Q': return OO; case 'R': return MAD_N; case 'T': return OW; case 'U': return MAD; case 'W': return OW_OW; case 'Y': return JAZR; case '`': return F_PCN; case '!': return F_EXCL; case '@': return F_COMMA; case '#': return F_DIVIDE; case '$': return F_CURRENCY; case '%': return F_PERCENT; case '^': return F_MUL; case '&': return F_BCOMMA; case '*': return F_STAR; case '(': return F_LPARENT; case ')': return F_RPARENT; case '-': return F_MINUS; case '_': return F_UNDERLINE; case '=': return F_EQUALS; case '+': return F_PLUS; case '\\': return F_BSLASH; case '|': return F_PIPE; case ':': return F_DCOLON; case '"': return F_SEMICOLON; case '.': return F_PERIOD; case '/': return F_SLASH; case '<': return F_LESS; case '>': return F_GREATER; case '?': return F_QUESTION; case ' ': return F_BLANK; } break; case 'a': tempc = _SHIN; break; case 'A': tempc = WAW_H; break; case 'b': tempc = ZAL; break; case 'c': tempc = ZE; break; case 'C': tempc = JE; break; case 'd': tempc = _YE; break; case 'D': tempc = _YEE; break; case 'e': tempc = _SE; break; case 'f': tempc = _BE; break; case 'g': tempc = _LAM; break; case 'G': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (gchar_cursor() == _LAM) { chg_c_toX_orX(); } else if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri) { if (!curwin->w_cursor.col) { return ALEF_U_H; } } if (!p_ri) { dec_cursor(); } if (gchar_cursor() == _LAM) { chg_c_toX_orX(); chg_l_toXor_X(); tempc = ALEF_U_H; } else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = ALEF_U_H_; chg_l_toXor_X(); } else { tempc = ALEF_U_H; } if (!p_ri) { inc_cursor(); } return tempc; case 'h': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri) { if (!curwin->w_cursor.col) { return ALEF; } } if (!p_ri) { dec_cursor(); } if (gchar_cursor() == _LAM) { chg_l_toXor_X(); del_char(FALSE); AppendCharToRedobuff(K_BS); if (!p_ri) { dec_cursor(); } tempc = LA; } else { if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = ALEF_; chg_l_toXor_X(); } else { tempc = ALEF; } } if (!p_ri) { inc_cursor(); } return tempc; case 'i': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri && !curwin->w_cursor.col) { return _HE; } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = _HE_; } else { tempc = _HE; } if (!p_ri) { inc_cursor(); } break; case 'j': tempc = _TE; break; case 'J': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri) { if (!curwin->w_cursor.col) { return TEE; } } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = TEE_; chg_l_toXor_X(); } else { tempc = TEE; } if (!p_ri) { inc_cursor(); } return tempc; case 'k': tempc = _NOON; break; case 'l': tempc = _MIM; break; case 'm': tempc = _PE; break; case 'n': case 'N': tempc = DAL; break; case 'o': tempc = _XE; break; case 'p': tempc = _HE_J; break; case 'q': tempc = _ZAD; break; case 'r': tempc = _GHAF; break; case 's': tempc = _SIN; break; case 'S': tempc = _IE; break; case 't': tempc = _FE; break; case 'u': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri && !curwin->w_cursor.col) { return _AYN; } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = _AYN_; } else { tempc = _AYN; } if (!p_ri) { inc_cursor(); } break; case 'v': case 'V': tempc = RE; break; case 'w': tempc = _SAD; break; case 'x': case 'X': tempc = _TA; break; case 'y': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (!p_ri && !curwin->w_cursor.col) { return _GHAYN; } if (!p_ri) { dec_cursor(); } if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { tempc = _GHAYN_; } else { tempc = _GHAYN; } if (!p_ri) { inc_cursor(); } break; case 'z': tempc = _ZA; break; case 'Z': tempc = _KAF_H; break; case ';': tempc = _KAF; break; case '\'': tempc = _GAF; break; case ',': tempc = WAW; break; case '[': tempc = _JIM; break; case ']': tempc = _CHE; break; } if ((F_isalpha(tempc) || F_isdigit(tempc))) { if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) { if (!p_ri && !F_is_TyE(tempc)) { chg_c_to_X_orX_(); } if (p_ri) { chg_c_to_X_or_X(); } } if (curwin->w_cursor.col) { if (!p_ri) { dec_cursor(); } if (F_is_TyE(tempc)) { chg_l_toXor_X(); } else { chg_l_to_X_orX_(); } if (!p_ri) { inc_cursor(); } } } if (tempc) { return tempc; } return c; }