void acpi_db_set_scope ( NATIVE_CHAR *name) { if (!name || name[0] == 0) { acpi_os_printf ("Current scope: %s\n", acpi_gbl_db_scope_buf); return; } acpi_db_prep_namestring (name); /* TBD: [Future] Validate scope here */ if (name[0] == '\\') { STRCPY (acpi_gbl_db_scope_buf, name); STRCAT (acpi_gbl_db_scope_buf, "\\"); } else { STRCAT (acpi_gbl_db_scope_buf, name); STRCAT (acpi_gbl_db_scope_buf, "\\"); } acpi_os_printf ("New scope: %s\n", acpi_gbl_db_scope_buf); }
bool util_findFile(const char* dirs[], unsigned int numDirs, const char* relativeFilePath, char* absoluteFilePath) { bool found = false; // check if it is an absolute file path if (util_fileExists(relativeFilePath)) { STRCPY(absoluteFilePath, relativeFilePath); found = true; } unsigned int d; for (d=0; d < numDirs && !found; ++d) { // do the following: tmpPath = dirs[d] + sPS + relativeFilePath char* tmpPath = util_allocStr(strlen(dirs[d]) + 1 + strlen(relativeFilePath)); //char tmpPath[strlen(dirs[d]) + 1 + strlen(relativeFilePath) + 1]; tmpPath[0]= '\0'; tmpPath = STRCAT(tmpPath, dirs[d]); tmpPath = STRCAT(tmpPath, sPS); tmpPath = STRCAT(tmpPath, relativeFilePath); if (util_fileExists(tmpPath)) { STRCPY(absoluteFilePath, tmpPath); found = true; } free(tmpPath); } return found; }
static void AcpiDbExecuteSetup ( DB_METHOD_INFO *Info) { /* Catenate the current scope to the supplied name */ Info->Pathname[0] = 0; if ((Info->Name[0] != '\\') && (Info->Name[0] != '/')) { STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); } STRCAT (Info->Pathname, Info->Name); AcpiDbPrepNamestring (Info->Pathname); AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT); AcpiOsPrintf ("Executing %s\n", Info->Pathname); if (Info->Flags & EX_SINGLE_STEP) { AcpiGbl_CmSingleStep = TRUE; AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT); } else { /* No single step, allow redirection to a file */ AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT); } }
//==============[Oid:: operator += const char *a ]========================= // append operator, appends a string // // allocate some space for a max oid string // extract current string into space // concat new string // free up existing oid // make a new oid from string // delete allocated space Oid& Oid::operator+=(const char *a) { unsigned int n; if (!a) return *this; if (*a == '.') ++a; n = (smival.value.oid.len * SNMPCHARSIZE) + (smival.value.oid.len) + 1 + SAFE_UINT_CAST(strlen(a)); char *ptr = new char[n]; if (ptr) { /// @todo optimze this function (avoid conversion to string) OidToStr(&smival.value.oid, n, ptr); if (ptr[0]) STRCAT(ptr,"."); STRCAT(ptr,a); delete_oid_ptr(); StrToOid(ptr, &smival.value.oid); delete [] ptr; } return *this; }
// Append to_append to path with a slash in between. int append_path(char *path, const char *to_append, int max_len) { int current_length = STRLEN(path); int to_append_length = STRLEN(to_append); // Do not append empty strings. if (to_append_length == 0) { return OK; } // Do not append a dot. if (STRCMP(to_append, ".") == 0) { return OK; } // Glue both paths with a slash. if (current_length > 0 && path[current_length-1] != '/') { current_length += 1; // Count the trailing slash. // +1 for the NUL at the end. if (current_length + 1 > max_len) { return FAIL; } STRCAT(path, "/"); } // +1 for the NUL at the end. if (current_length + to_append_length + 1 > max_len) { return FAIL; } STRCAT(path, to_append); return OK; }
void acpi_db_execute_setup ( db_method_info *info) { /* Catenate the current scope to the supplied name */ info->pathname[0] = 0; if ((info->name[0] != '\\') && (info->name[0] != '/')) { STRCAT (info->pathname, acpi_gbl_db_scope_buf); } STRCAT (info->pathname, info->name); acpi_db_prep_namestring (info->pathname); acpi_db_set_output_destination (DB_DUPLICATE_OUTPUT); acpi_os_printf ("Executing %s\n", info->pathname); if (info->flags & EX_SINGLE_STEP) { acpi_gbl_cm_single_step = TRUE; acpi_db_set_output_destination (DB_CONSOLE_OUTPUT); } else { /* No single step, allow redirection to a file */ acpi_db_set_output_destination (DB_REDIRECTABLE_OUTPUT); } }
int SearchPath(char* oudzp, char* filename, char* whatever, int maxlen, char* nieuwzp, char** ach) { FILE* fp; char* p, * f; if (filename[0] == '/') { STRCPY(nieuwzp, maxlen, filename); } else { STRCPY(nieuwzp, maxlen, oudzp); if (*nieuwzp && nieuwzp[strlen(nieuwzp)] != '/') { STRCAT(nieuwzp, maxlen, "/"); } STRCAT(nieuwzp, maxlen, filename); } if (ach) { p = f = nieuwzp; while (*p) { if (*p == '/') { f = p + 1; } ++p; } *ach = f; } if (FOPEN_ISOK(fp, nieuwzp, "r")) { fclose(fp); return 1; } return 0; }
/*! ************************************************************************************* * \brief reopen log file when finish setting current path * * \param pCtx context pCtx * \param pCurPath current path string * * \return NONE * * \note N/A ************************************************************************************* */ void WelsReopenTraceFile( void *pCtx, str_t *pCurPath ) { #ifdef ENABLE_TRACE_FILE sWelsEncCtx *pEncCtx = (sWelsEncCtx *)pCtx; if (wlog == WelsLogDefault) { str_t strTraceFile[MAX_FNAME_LEN] = {0}; int32_t len = 0; if (pEncCtx->pFileLog != NULL) { fclose(pEncCtx->pFileLog); pEncCtx->pFileLog = NULL; } pEncCtx->uiSizeLog = 0; len = STRNLEN( pCurPath, MAX_FNAME_LEN-1 ); // confirmed_safe_unsafe_usage if (len >= MAX_FNAME_LEN) return; STRNCPY(strTraceFile, MAX_FNAME_LEN, pCurPath, len); // confirmed_safe_unsafe_usage #ifdef __GNUC__ STRCAT(strTraceFile, MAX_FNAME_LEN-len, "/wels_encoder_trace.txt"); // confirmed_safe_unsafe_usage pEncCtx->pFileLog = FOPEN(strTraceFile, "wt+"); // confirmed_safe_unsafe_usage #elif WIN32 STRCAT(strTraceFile, MAX_FNAME_LEN-len, "\\wels_encoder_trace.txt");// confirmed_safe_unsafe_usage #if _MSC_VER >= 1500 FOPEN(&pEncCtx->pFileLog, strTraceFile, "wt+"); // confirmed_safe_unsafe_usage #else pEncCtx->pFileLog = FOPEN(strTraceFile, "wt+"); // confirmed_safe_unsafe_usage #endif//_MSC_VER>=1500 #else #endif//__GNUC__ } #endif//ENABLE_TRACE_FILE }
// this function is called when your application is starting up boolean PocketRocketForBrew_InitAppData(PocketRocketForBrew* pMe) { AECHAR os[] = {'B','r','e','w','\0'}; char resx[5]; char resy[5]; AECHAR wresx[5]; AECHAR wresy[5]; AECHAR url[512]; char curl[512]; AECHAR fchunk[] = {'?','O','S','=','B','r','e','w','&','H','E','I','G','H','T','=','\0'}; AECHAR schunk[] = {'&','W','I','D','T','H','=','\0'}; AECHAR tchunk[] = {'&','I','D','=','1','\0'}; // Get the device information for this handset. // Reference all the data by looking at the pMe->DeviceInfo structure // Check the API reference guide for all the handy device info you can get pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo); ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo); // std::string a; STRCPY(url,XID_URL); // str itoa((int)pMe->DeviceInfo.cyScreen,resx,10); itoa((int)pMe->DeviceInfo.cxScreen,resy,10); STRTOWSTR(wresx,resx,strlen(resx)); STRTOWSTR(wresy,resy,strlen(resy)); //strcp STRCAT(url,fchunk); STRCAT(url,wresy); STRCAT(url,schunk); STRCAT(url,wresx); STRCAT(url,tchunk); WSTRTOSTR(curl,url,strlen(curl)); printf(url); //strcat( // Insert your code here for initializing or allocating resources... //XOsApplication *xosApplication = new XOsApplication("Testing"); // if there have been no failures up to this point then return success return TRUE; }
/* ** char MakeCompressedName(char ARG_PTR *pszFileName); ** ** Make a file name into the corresponding compressed file name. ** ** Arguments: pszOriginalName - file name to convert to compressed file name ** ** Returns: char - Uncompressed file name extension character that was ** replaced. '\0' if no character needed to be replaced. ** ** Globals: none ** ** N.b., assumes pszFileName's buffer is long enough to hold an extra two ** characters ("._"). ** ** For DBCS filenames, we know we can have at most one DBCS character in the ** extension. So instead of just blindly replacing the last character of a ** three-byte extension with an underscore, we replace the last single-byte ** character with an underscore. */ CHAR MakeCompressedName(CHAR ARG_PTR *pszFileName) { CHAR chReplaced = '\0'; CHAR ARG_PTR *pszExt; #ifdef DBCS if ((pszExt = ExtractExtension(pszFileName)) != NULL) { if (STRLEN(pszExt) >= 3) { // Replace the last single-byte character in the extension with an // underscore. if (! IsDBCSLeadByte(*pszExt) && IsDBCSLeadByte(pszExt[1])) { // Assert: The first character in the extension is a single-byte // character and the second character in the extension is a // double-byte character. chReplaced = *pszExt; *pszExt = chEXTENSION_CHAR; } else { // Assert: The third character in the extension is a single-byte // character. The first two bytes may be two single-byte // characters or a double-byte character. chReplaced = pszExt[2]; pszExt[2] = chEXTENSION_CHAR; } } else STRCAT(pszExt, pszEXTENSION_STR); } else STRCAT(pszFileName, pszNULL_EXTENSION); #else if ((pszExt = ExtractExtension(pszFileName)) != NULL) { if (STRLEN(pszExt) >= 3) { chReplaced = pszExt[STRLEN(pszExt) - 1]; pszExt[STRLEN(pszExt) - 1] = chEXTENSION_CHAR; } else STRCAT(pszExt, pszEXTENSION_STR); } else STRCAT(pszFileName, pszNULL_EXTENSION); #endif return(chReplaced); }
/* * Append a message to IObuff for the encryption/decryption method being used. */ void crypt_append_msg( buf_T *buf) { if (crypt_get_method_nr(buf) == 0) STRCAT(IObuff, _("[crypted]")); else { STRCAT(IObuff, "["); STRCAT(IObuff, *buf->b_p_cm == NUL ? p_cm : buf->b_p_cm); STRCAT(IObuff, "]"); } }
void workshop_init(void) { char_u buf[64]; int is_dirty = FALSE; int width, height; XtInputMask mask; /* * Turn on MenuBar, ToolBar, and Footer. */ STRCPY(buf, p_go); if (vim_strchr(p_go, GO_MENUS) == NULL) { STRCAT(buf, "m"); is_dirty = TRUE; } if (vim_strchr(p_go, GO_TOOLBAR) == NULL) { STRCAT(buf, "T"); is_dirty = TRUE; } if (vim_strchr(p_go, GO_FOOTER) == NULL) { STRCAT(buf, "F"); is_dirty = TRUE; } if (is_dirty) set_option_value((char_u *)"go", 0L, buf, 0); /* * Set size from workshop_get_width_height(). */ width = height = 0; if (workshop_get_width_height(&width, &height)) { XtVaSetValues(vimShell, XmNwidth, width, XmNheight, height, NULL); } /* * Now read in the initial messages from eserve. */ while ((mask = XtAppPending(app_context)) && (mask & XtIMAlternateInput) && !workshopInitDone) XtAppProcessEvent(app_context, (XtInputMask)XtIMAlternateInput); }
void CTB_unlink(char *name) { char str[MAXPATH], *p = ctb_last_punct(name); if (p) *p = '\0'; STRCPY(str, name); STRCAT(str, ".CTB"); UNLINK(str); STRCPY(str, name); STRCAT(str, ".IND"); UNLINK(str); return; }
int main(int argc, char** argv) { char_t strExeFullPath[kMAX_PATH]; UNUSED_PARAM(argc); UNUSED_PARAM(argv); if (FALSE == lockFile()) { PRINTF("Lock File %s Failed.\n may be the other collector is running.",gStrLockFile ); getchar(); return 0; } signal(SIGINT,ctrl_handler); BZERO_ARR(strExeFullPath); if (_getcwd(strExeFullPath, sizeof(strExeFullPath))) { STRCAT(strExeFullPath, sizeof(strExeFullPath), STR_DIR_SEP); } else { STRCPY(strExeFullPath, sizeof(strExeFullPath), NULL_STR); } PRINTF("%s\n", strExeFullPath); StartService(&g_Interrupt, strExeFullPath); getchar(); unlockFile(); return 0; }
char* util_allocStrCpyCat(const char* toPart1, const char* toPart2) { char* copy = (char*) calloc(strlen(toPart1)+strlen(toPart2)+1, sizeof(char)); STRCPY(copy, toPart1); STRCAT(copy, toPart2); return copy; }
void __create_message (HWND hwnd, SQLPOINTER dsn, SQLPOINTER text, SQLCHAR waMode, AlertType id) { CFStringRef msg, msg1; DialogRef dlg; SInt16 out; char buf[1024]; if (hwnd == NULL) return; if (waMode == 'A') { if (dsn) { STRCPY(buf, "DSN: "); STRCAT(buf, dsn); msg = CFStringCreateWithBytes (NULL, (unsigned char*)buf, STRLEN(buf), kCFStringEncodingUTF8, false); msg1 = CFStringCreateWithBytes (NULL, (unsigned char*)text, STRLEN(text), kCFStringEncodingUTF8, false); } else { STRCPY(buf, ""); msg = CFStringCreateWithBytes (NULL, (unsigned char*)text, STRLEN(text), kCFStringEncodingUTF8, false); msg1 = CFStringCreateWithBytes (NULL, (unsigned char*)buf, STRLEN(buf), kCFStringEncodingUTF8, false); } } else { if (dsn) { WCSCPY(buf, L"DSN: "); WCSCAT(buf, dsn); msg = convert_wchar_to_CFString((wchar_t*)buf); msg1 = convert_wchar_to_CFString((wchar_t*)text); } else { WCSCPY(buf, L""); msg = convert_wchar_to_CFString((wchar_t*)text); msg1 = convert_wchar_to_CFString((wchar_t*)buf); } } CreateStandardAlert (id, msg, msg1, NULL, &dlg); RunStandardAlert (dlg, NULL, &out); CFRelease(msg); CFRelease(msg1); return; }
/* * Function given to ExpandGeneric() to obtain the list of menus and menu * entries. */ char_u *get_menu_names(expand_T *xp, int idx) { static vimmenu_T *menu = NULL; #define TBUFFER_LEN 256 static char_u tbuffer[TBUFFER_LEN]; /*hack*/ char_u *str; static int should_advance = FALSE; if (idx == 0) { /* first call: start at first item */ menu = expand_menu; should_advance = FALSE; } /* Skip Browse-style entries, popup menus and separators. */ while (menu != NULL && ( menu_is_hidden(menu->dname) || (expand_emenu && menu_is_separator(menu->dname)) || menu_is_tearoff(menu->dname) || menu->dname[STRLEN(menu->dname) - 1] == '.' )) menu = menu->next; if (menu == NULL) /* at end of linked list */ return NULL; if (menu->modes & expand_modes) { if (menu->children != NULL) { if (should_advance) STRLCPY(tbuffer, menu->en_dname, TBUFFER_LEN - 1); else { STRLCPY(tbuffer, menu->dname, TBUFFER_LEN - 1); if (menu->en_dname == NULL) should_advance = TRUE; } /* hack on menu separators: use a 'magic' char for the separator * so that '.' in names gets escaped properly */ STRCAT(tbuffer, "\001"); str = tbuffer; } else { if (should_advance) str = menu->en_dname; else { str = menu->dname; if (menu->en_dname == NULL) should_advance = TRUE; } } } else str = (char_u *)""; if (should_advance) /* Advance to next menu entry. */ menu = menu->next; should_advance = !should_advance; return str; }
char* ValidateLabel(char* naam) { char* np = naam,* lp,* label,* mlp = macrolabp; int p = 0,l = 0; label = new char[LINEMAX]; if (label == NULL) { Error("No enough memory!", 0, FATAL); } lp = label; label[0] = 0; if (mlp && *np == '@') { ++np; mlp = 0; } switch (*np) { case '@': p = 1; ++np; break; case '.': l = 1; ++np; break; default: break; } naam = np; if (!isalpha((unsigned char) * np) && *np != '_') { Error("Invalid labelname", naam); return 0; } while (*np) { if (isalnum((unsigned char) * np) || *np == '_' || *np == '.' || *np == '?' || *np == '!' || *np == '#' || *np == '@') { ++np; } else { Error("Invalid labelname", naam); return 0; } } if (strlen(naam) > LABMAX) { Error("Label too long", naam, PASS1); naam[LABMAX] = 0; } if (mlp && l) { STRCAT(lp, LINEMAX, macrolabp); STRCAT(lp, LINEMAX, ">"); } else { if (!p && ModuleName) { //int len1=strlen(lp); //int len2=strlen(ModuleName); STRCAT(lp, LINEMAX, ModuleName); STRCAT(lp, LINEMAX, "."); } if (l) { STRCAT(lp, LINEMAX, vorlabp); STRCAT(lp, LINEMAX, "."); } else { free(vorlabp); vorlabp = STRDUP(naam); if (vorlabp == NULL) { Error("No enough memory!", 0, FATAL); } } } STRCAT(lp, LINEMAX, naam); return label; }
_TCHAR * get_nice_number( __int64 num, size_t width ) { size_t len, i; _TCHAR * pb1 = get_next_buffer(); _TCHAR * pb2 = get_next_buffer(); SPRINTF(pb1, "%lld", num); nice_num( pb2, pb1 ); len = STRLEN(pb2); if( len < width ) { *pb1 = 0; i = width - len; // get pad while(i--) STRCAT(pb1, " "); STRCAT(pb1,pb2); pb2 = pb1; } return pb2; }
boolean TS_AddExtension(char ** ppszExtList, char * psz) { char * pExt; if (!ppszExtList || !psz) return FALSE; if (*ppszExtList) pExt = REALLOC(*ppszExtList, STRLEN(*ppszExtList) + STRLEN(psz) + STRLEN(MP_EXT_SEPARATOR) + 1); else pExt = MALLOC(STRLEN(psz) + STRLEN(MP_EXT_SEPARATOR) + 1); if (!pExt) return FALSE; STRCAT(pExt, psz); STRCAT(pExt, MP_EXT_SEPARATOR); *ppszExtList = pExt; return TRUE; }
/* ** void MakePathName(char ARG_PTR *pszPath, char ARG_PTR *pszFileName); ** ** Append a filename to a path string. ** ** Arguments: pszPath - path string to which pszFileName will be appended ** pszFileName - file name to append ** ** Returns: void ** ** Globals: none */ VOID MakePathName(CHAR ARG_PTR *pszPath, CHAR ARG_PTR *pszFileName) { CHAR chLastPathChar; // Make sure we have an isolated file name. pszFileName = ExtractFileName(pszFileName); // Dont append to a NULL string or a single ".". #ifdef DBCS if (*pszFileName != '\0' && ! (! IsDBCSLeadByte(pszFileName[0]) && pszFileName[0] == PERIOD && ! IsDBCSLeadByte(pszFileName[1]) && pszFileName[1] == '\0')) { CHAR ARG_PTR *psz, *pszPrevious; for (psz = pszPrevious = pszPath; *psz != '\0'; psz = AnsiNext(psz)) pszPrevious = psz; chLastPathChar = *pszPrevious; if (! IsDBCSLeadByte(chLastPathChar) && ! ISSLASH(chLastPathChar) && chLastPathChar != COLON) STRCAT(pszPath, SEP_STR); STRCAT(pszPath, pszFileName); } #else if (*pszFileName != '\0' && ! (*pszFileName == PERIOD && pszFileName[1] == '\0')) { chLastPathChar = pszPath[STRLEN(pszPath) - 1]; if (! ISSLASH(chLastPathChar) && chLastPathChar != COLON) STRCAT(pszPath, SEP_STR); STRCAT(pszPath, pszFileName); } #endif }
/// For a growing array that contains a list of strings: concatenate all the /// strings with a separating comma. /// /// @param gap /// /// @returns NULL when out of memory. char_u* ga_concat_strings(garray_T *gap) { int i; int len = 0; char_u *s; for (i = 0; i < gap->ga_len; ++i) { len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + 1; } s = alloc(len + 1); *s = NUL; for (i = 0; i < gap->ga_len; ++i) { if (*s != NUL) { STRCAT(s, ","); } STRCAT(s, ((char_u **)(gap->ga_data))[i]); } return s; }
inline int getDisplayName(IPropertyTree * parent, char * buffer, size32_t buffsz) const { *buffer = 0; size32_t insz = buffsz; switch(type) { case TLT_root: case TLT_property: STRCAT(buffer, buffsz, " "); STRCAT(buffer, buffsz, getName(parent)); if(ShowAttrsOnProps) { bool first = true; IAttributeIterator * attrIterator = pTree->getAttributes(); attrIterator->first(); while(attrIterator->isValid()) { STRCAT(buffer, buffsz, " "); if(first) { STRCAT(buffer, buffsz, "<"); first = false; } STRCAT(buffer, buffsz, attrIterator->queryName() + 1); STRCAT(buffer, buffsz, "="); STRCAT(buffer, buffsz, attrIterator->queryValue()); attrIterator->next(); } attrIterator->Release(); if(!first) STRCAT(buffer, buffsz, ">"); } break; case TLT_attribute: STRCAT(buffer, buffsz, "= "); STRCAT(buffer, buffsz, getName(NULL)); break; } return insz - buffsz; }
void FileTransfer::GetTVPath(HWND hwnd, HTREEITEM hTItem, char *path) { char szText[rfbMAX_PATH]; TVITEM _tvi; path[0] = '\0'; do { _tvi.mask = TVIF_TEXT | TVIF_HANDLE; _tvi.hItem = hTItem; _tvi.pszText = szText; _tvi.cchTextMax = rfbMAX_PATH; TreeView_GetItem(hwnd, &_tvi); STRNCAT(path, "\\", rfbMAX_PATH); STRNCAT(path, _tvi.pszText, rfbMAX_PATH); hTItem = TreeView_GetParent(hwnd, hTItem); } while (hTItem != NULL); char path_tmp[rfbMAX_PATH], path_out[rfbMAX_PATH]; path_tmp[0] = '\0'; path_out[0] = '\0'; int len = (int)strlen(path); int ii = 0; for (int i = (len - 1); i >= 0; i--) { if (path[i] == '\\') { StrInvert(path_tmp); STRCAT(path_out, path_tmp); STRCAT(path_out, "\\"); path_tmp[0] = '\0'; ii = 0; } else { path_tmp[ii] = path[i]; path_tmp[ii + 1] = '\0'; ii++; } } if (path_out[strlen(path_out) - 1] == '\\') path_out[strlen(path_out) - 1] = '\0'; STRNCPY(path, path_out, rfbMAX_PATH); }
/* * Translate a string into allocated memory, replacing special chars with * printable chars. Returns NULL when 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 len += 4; /* illegal byte sequence */ } } 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)) STRNCAT(res, p, l); /* append printable multi-byte char */ else transchar_hex(res + STRLEN(res), c); p += l; } else STRCAT(res, transchar_byte(*p++)); } } return res; }
void GPSRadar_SetCommand_GMC1030(RADARSET_TYPE ubType, MMP_UBYTE ubValue) { MMP_BYTE chCommand[15]; MMP_BYTE chTempBuffer[2]; MMP_UBYTE ubXorTemp =0, i; MEMSET(chCommand, 0, 15); MEMSET(chTempBuffer, 0, 2); STRCAT(chCommand, "$2,"); //Command Type. if(ubType <10) STRCAT(chCommand, "0"); sprintf(chTempBuffer, "%d",ubType); STRCAT(chCommand, chTempBuffer); STRCAT(chCommand, ":"); //Command Value if(ubValue <10) STRCAT(chCommand, "0"); sprintf(chTempBuffer, "%d",ubValue); STRCAT(chCommand, chTempBuffer); STRCAT(chCommand, "*"); //Checksum for(i = 1; i<8; i++) //Between $ to * ubXorTemp ^= chCommand[i]; sprintf(chTempBuffer, "%x",ubXorTemp); STRCAT(chCommand ,chTempBuffer); //Tail STRCAT(chCommand, "\r\n"); printc("chCommand : %s\r\n",chCommand); //Write fixed-length(13) ASCII codes to Radar MMPF_Uart_Write(GPSRADAR_UART_NUM, chCommand, 13 ); }
static unsigned int util_listFilesRec(const char* dir, const char* suffix, char** fileNames, bool recursive, const unsigned int maxFileNames, unsigned int numFiles, const char* relPath) { struct dirent** files; util_initFileSelector(suffix); unsigned int currentNumFiles = util_listFilesU(dir, &files); unsigned int f; for (f = 0; f < currentNumFiles && numFiles < maxFileNames; ++f) { char fileRelPath[strlen(relPath) + strlen(files[f]->d_name) + 1]; STRCPY(fileRelPath, relPath); STRCAT(fileRelPath, files[f]->d_name); fileNames[numFiles++] = util_allocStrCpy(fileRelPath); } /* for (; f < currentNumFiles; ++f) { free(files[f]); } */ if (recursive) { struct stat dirStat; util_initFileSelector(""); currentNumFiles = util_listFilesU(dir, &files); for (f = 0; f < currentNumFiles && numFiles < maxFileNames; ++f) { if (strcmp(files[f]->d_name, ".") == 0 || strcmp(files[f]->d_name, "..") == 0) { continue; } char subDir[strlen(dir) + strlen("/") + strlen(relPath) + strlen(files[f]->d_name) + 1]; STRCPY(subDir, dir); STRCAT(subDir, "/"); STRCAT(subDir, relPath); STRCAT(subDir, files[f]->d_name); char subRelPath[strlen(relPath) + strlen(files[f]->d_name) + strlen("/") + 1]; STRCPY(subRelPath, relPath); STRCAT(subRelPath, files[f]->d_name); STRCAT(subRelPath, "/"); int retStat = stat(subDir, &dirStat); if (retStat == 0 && S_ISDIR(dirStat.st_mode)) { numFiles = util_listFilesRec(subDir, suffix, fileNames, recursive, maxFileNames, numFiles, subRelPath); } } } return numFiles; }
BOOL ManageDataSources (HWND hwndParent) { void *handle; pAdminBoxFunc pAdminBox; BOOL retcode = FALSE; #if defined (__APPLE__) && !(defined (NO_FRAMEWORKS) || defined (_LP64)) CFStringRef libname = NULL; CFBundleRef bundle; CFURLRef liburl; char name[1024] = { 0 }; #endif /* Load the Admin dialbox function */ #if defined (__APPLE__) && !(defined (NO_FRAMEWORKS) || defined (_LP64)) bundle = CFBundleGetBundleWithIdentifier (CFSTR ("org.iodbc.inst")); if (bundle) { /* Search for the iODBCadm library */ liburl = CFBundleCopyResourceURL (bundle, CFSTR ("iODBCadm.bundle"), NULL, NULL); if (liburl && (libname = CFURLCopyFileSystemPath (liburl, kCFURLPOSIXPathStyle))) { CFStringGetCString (libname, name, sizeof (name), kCFStringEncodingASCII); STRCAT (name, "/Contents/MacOS/iODBCadm"); CALL_ADMIN_DIALBOX (name); } if (liburl) CFRelease (liburl); if (libname) CFRelease (libname); } #else CALL_ADMIN_DIALBOX ("libiodbcadm.so.2"); #endif return retcode; }
void workshop_toolbar_end() { char_u buf[64]; #ifdef WSDEBUG_TRACE if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE)) { wstrace("workshop_toolbar_end()\n"); } #endif /* * Turn on ToolBar. */ STRCPY(buf, p_go); if (vim_strchr(p_go, 'T') == NULL) { STRCAT(buf, "T"); set_option_value((char_u *)"go", 0L, buf, 0); } workshopInitDone = True; }
bool util_findDir(const char* dirs[], unsigned int numDirs, const char* relativeDirPath, char* absoluteDirPath, bool searchOnlyWriteable, bool create) { bool found = false; // check if it is an absolute file path if (util_fileExists(relativeDirPath)) { STRCPY(absoluteDirPath, relativeDirPath); found = true; } if (searchOnlyWriteable && numDirs > 1) { numDirs = 1; } unsigned int d; for (d=0; d < numDirs && !found; ++d) { // do the following: tmpPath = dirs[d] + sPS + relativeFilePath char* tmpPath = util_allocStr(strlen(dirs[d]) + 1 + strlen(relativeDirPath)); //char tmpPath[strlen(dirs[d]) + 1 + strlen(relativeDirPath) + 1]; tmpPath[0]= '\0'; tmpPath = STRCAT(tmpPath, dirs[d]); tmpPath = STRCAT(tmpPath, sPS); tmpPath = STRCAT(tmpPath, relativeDirPath); if (util_fileExists(tmpPath)) { STRCPY(absoluteDirPath, tmpPath); found = true; } free(tmpPath); } // not found -> create it if (!found && create && numDirs >= 1) { STRCAT(absoluteDirPath, dirs[0]); STRCAT(absoluteDirPath, sPS); STRCAT(absoluteDirPath, relativeDirPath); found = util_makeDir(absoluteDirPath); } return found; }