当前位置: 首页>>代码示例>>C++>>正文


C++ STRLEN函数代码示例

本文整理汇总了C++中STRLEN函数的典型用法代码示例。如果您正苦于以下问题:C++ STRLEN函数的具体用法?C++ STRLEN怎么用?C++ STRLEN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了STRLEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SEGGER_RTT_WriteString

/*********************************************************************
*
*       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);
}
开发者ID:craftyjon,项目名称:McuOnEclipse_PEx,代码行数:27,代码来源:SEGGER_RTT.c

示例2: GetTranslator

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");

//.........这里部分代码省略.........
开发者ID:openlink,项目名称:iODBC,代码行数:101,代码来源:SQLGetTranslator.c

示例3: _Concat

VOID ACLStr::Append(IN LPCTSTR str)
{
	_Concat(STRLEN(str), str);
}	//	Append
开发者ID:Fahrni,项目名称:ACLLib,代码行数:4,代码来源:ACLStr.cpp

示例4: get_frame_place_mcode


//.........这里部分代码省略.........
			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;
}
开发者ID:h4ck3rm1k3,项目名称:fis-gtm,代码行数:101,代码来源:get_frame_place_mcode.c

示例5: xmalloc

/*
 * 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

//.........这里部分代码省略.........
开发者ID:dzhou121,项目名称:neovim,代码行数:101,代码来源:file_search.c

示例6: log

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;)
//.........这里部分代码省略.........
开发者ID:bonly,项目名称:Template,代码行数:101,代码来源:File.cpp

示例7: SQLInstallTranslatorEx

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);

//.........这里部分代码省略.........
开发者ID:tws67,项目名称:bayonne-cygwin,代码行数:101,代码来源:SQLInstallTranslatorEx.c

示例8: ConfigDSN

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
//.........这里部分代码省略.........
开发者ID:tws67,项目名称:bayonne-cygwin,代码行数:101,代码来源:ConfigDSN.c

示例9: packet_receive


//.........这里部分代码省略.........
			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;
}
开发者ID:jinfeng-geeya,项目名称:3202C,代码行数:101,代码来源:Packet.c

示例10: while

/// 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;
}
开发者ID:julianchurchill,项目名称:neovim,代码行数:68,代码来源:charset.c

示例11: coladvance2

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
//.........这里部分代码省略.........
开发者ID:ZyX-I,项目名称:neovim,代码行数:101,代码来源:cursor.c

示例12: addtranslators_to_list

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)
//.........这里部分代码省略.........
开发者ID:tws67,项目名称:bayonne-cygwin,代码行数:101,代码来源:translatorchooser.c

示例13: InstallDriverPathLength

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;
	}
    }
//.........这里部分代码省略.........
开发者ID:tws67,项目名称:bayonne-cygwin,代码行数:101,代码来源:SQLInstallDriverEx.c

示例14: main

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;
}
开发者ID:whitten,项目名称:fis-gtm-1,代码行数:76,代码来源:maskpass.c

示例15: list_join_inner

    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;
}
开发者ID:dougfales,项目名称:macvim,代码行数:71,代码来源:list.c


注:本文中的STRLEN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。