• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sizearray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_key_len

int get_key_len(const char **user){
    char section[50]; //nazwa sekcji
    char mobile[50]; //nazwa telefonu dla uzytkownika

	int key_len; // dlogosc klucza z konfigu
    int  s; //iterator sekcji
    int  b; // enabled, true/false

//  Szukaj uzytkownikow
	for (s = 0; ini_getsection(s, section, sizearray(section), inifile_users) > 0; s++) {
		printf("get_key_len() [%s] user: %s\n", section, *user);
		if (!strcmp(*user, section)){
			printf("user cfg exists\n");
			b = ini_getbool(section, "enabled", 0, inifile_users);
			if(b == 1){
			//pobierz nazwe telfonu przypisanego do uzytkownika
				ini_gets(section, "mobile", "0", mobile, sizearray(mobile), inifile_users);
			//  pobierz dlugosc klucza i klucz
				key_len = ini_getl(mobile, "key_len", 1, inifile_mobiles);
				printf("get_key_len(): key length: %d\n", key_len);
				return key_len;
			}
		}
	} /* for */
	return -1;
}
开发者ID:slaweksiluk,项目名称:BlueAuth,代码行数:26,代码来源:check_user.c


示例2: actuator_initfunc

void actuator_initfunc(char *cfgfile, int devno) {
  char cmd[255];
  char *cmd_with_path;
  char *cmd_only;
  
  debug("[external actuator plugin] actuator_initfunc device %d\n",devno);

  if (devno==0) {
    ini_gets("actuator_plugin_external", "actuator_on", EXTACTON, ext_act_cfg.extactuatoron[0],
              sizearray(ext_act_cfg.extactuatoron[0]), cfgfile);
    ini_gets("actuator_plugin_external", "actuator_off", EXTACTOFF, ext_act_cfg.extactuatoroff[0],
              sizearray(ext_act_cfg.extactuatoroff[0]), cfgfile);
  }
  if (devno==1) {
    ini_gets("actuator_plugin_external", "stirring_device_on", EXTSTIRON,
              ext_act_cfg.extactuatoron[1], sizearray(ext_act_cfg.extactuatoron[1]), cfgfile);
    ini_gets("actuator_plugin_external", "stirring_device_off", EXTSTIRON,
              ext_act_cfg.extactuatoroff[1], sizearray(ext_act_cfg.extactuatoroff[1]), cfgfile);
  }
  // check if command is available in PATH
  strcpy(cmd,ext_act_cfg.extactuatoron[devno]);
  cmd_only=strtok(cmd," ");
  if (0==searchXfile(cmd_only,&cmd_with_path))
    free(cmd_with_path);
  else
    die("[external actuator plugin] can not find command >%s<\n",cmd_only);
}
开发者ID:gnovotny,项目名称:web20mash,代码行数:27,代码来源:external.c


示例3: processPostData

int processPostData(char *postData)
{

    char *token;
    char buf[1024];
    char decodedToken[100];
    char action[80];
    char section[80];
    char field[80];
    char value[80];
    int smartDnsUpdatePerformed;
    char smartDnsProviderPrimary[1024];
    char smartDnsProviderSecondary[1024];
    int n;

    sscanf(postData, "action=%[0-9a-zA-Z]", &action);
    if(compStr(action, "update", sizearray(action)))
    {
        token = strtok (postData,"&");
        while (token != NULL)
        {
            //check if contains / so we know it's a var to update
            urldecode2(decodedToken, token);
            if(strstr(decodedToken, "/") != NULL)
            {
                sscanf(decodedToken, "%[0-9a-zA-Z]/%[0-9a-zA-Z]=%[0-9a-zA-Z.:/_%-]", section, field, value);
                //check if DNS update and allowed to perform
                if(compStr(section, "DNS", sizearray(section)) && !compStr(field, "useDHCP", sizearray(field)) && (smartDnsUpdatePerformed == 1))
                {
                    //do nothing
                }
                else
                {
                    n = write_config_var(section, field, value);
                }
                //Check if an update for smartDNS selected which is not set to other
                if(compStr(section, "SmartDNS", sizearray(section)) && compStr(field, "selected", sizearray(section)) && !compStr(value, "other", sizearray(section)))
                {
                    strcpy(buf, "SmartDNS-");
                    strcat(buf, value);
                    //get DNS details for SmartDNS provider
                    read_config_var(buf, "primary", smartDnsProviderPrimary);
                    read_config_var(buf, "secondary", smartDnsProviderSecondary);
                    //set DNS details to selected SmartDNS Provider
                    n = write_config_var("DNS", "primary", smartDnsProviderPrimary);
                    n = write_config_var("DNS", "secondary", smartDnsProviderSecondary);
                    //set that DNS update has been performed so any unwanted commits don't occur after
                    smartDnsUpdatePerformed=1;
                }
            }
            token = strtok (NULL, "&");
        }

    }
}
开发者ID:fkrone,项目名称:Eureka-Panel,代码行数:55,代码来源:webpanel.c


示例4: get_user_data

// Wejscie:
//      user - login
// Wyjscia
//      btaddr
//      port
//      mobile_id 
//      rssi
int get_user_data(const char **user, char* btaddr, int *port, char *mobile_id,
        float *rssi){
    char section[50]; //nazwa sekcji
    char mobile[50]; //nazwa telefonu dla uzytkownika
    char addr[18];

    int  s; //iterator sekcji
    int  b; // enabled, true/false
    int  p; // port
    float min_rssi; // rssi
    //char user_login[] = *user;

      for (s = 0; ini_getsection(s, section, sizearray(section), inifile_users) > 0; s++) {
        //printf("    [%s] user: %s\n", section, *user);

        if (!strcmp(*user, section)){
            printf("user cfg exists\n");

            b = ini_getbool(section, "enabled", 0, inifile_users);
            if(b == 1){
//pobierz nazwe telfonu przypisanego do uzytkownika
                ini_gets(section, "mobile", "0", mobile, sizearray(mobile), inifile_users);
//pobierrz btaddr i port telefonu o ww nazwie
                ini_gets(mobile, "btaddr", "999", addr, sizearray(addr),
                 inifile_mobiles);
                p = ini_getl(mobile, "port", 999, inifile_mobiles);
//  pobierz wartosc progu RSSI
                min_rssi = ini_getf(mobile, "min_rssi", "-5.0", inifile_users);
                
                printf("user %s enabled with mobile: %s\n", *user, mobile);
                printf("mobile btaddr: %s, port: %d\n", addr, p);
                printf("rssi threshold: %f\n", min_rssi);
                //printf("check_user(): key length: %d, key: %s\n", key_len, k);

//zapisz btaddr, port i klucz do adresow z argumetu
                strcpy(btaddr,addr);
                strcpy(mobile_id, mobile);
                *port = p;
                *rssi = min_rssi;
                return 0;
            }

            //for (k = 0; ini_getkey(section, k, str, sizearray(str), inifile) > 0; k++) {
            //  printf("\t%s\n", str);
            //} /* for */
        }
      } /* for */
return E_INI_FILE;
}
开发者ID:slaweksiluk,项目名称:BlueAuth,代码行数:56,代码来源:check_user.c


示例5: Profile_GetBoolean

int Profile_GetBoolean(const char *Section, const char *Key, int DefValue)
{
    char buff[64];
    int len = Profile_GetString(Section, Key, "", buff, sizearray(buff));
    int ret = 0;
    //  printf("int %s \n",buff);

    if (len == 0)
    {
        return DefValue;
    }

    if((buff[0] == 'y') || (buff[0] == 'Y') || (buff[0] == '1') || (buff[0] == 't') || (buff[0] == 'T'))
    {
        ret = 1 ;
    }
    else if((buff[0] == 'n') || (buff[0] == 'N') || (buff[0] == '0') || (buff[0] == 'f') || (buff[0] == 'F'))
    {
        ret = 0 ;
    }
    else
    {
        ret = DefValue ;
    }
    return ret;
}
开发者ID:Scorpio92,项目名称:mstar6a918,代码行数:26,代码来源:iniparser.c


示例6: ini_getbool_OpenedFile

int ini_getbool_OpenedFile(
		const mTCHAR *Section,
		const mTCHAR *Key,
		int DefValue,
		INI_FILETYPE* pFile
)
{
	TCHAR LocalBuffer[2];
	int ret;
	int pos = 0;

	(void) ini_seek(pFile, &pos);

	ini_gets_OpenedFile(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), pFile);

	LocalBuffer[0] = (TCHAR) toupper(LocalBuffer[0]);
	if (LocalBuffer[0] == 'Y' || LocalBuffer[0] == '1' || LocalBuffer[0] == 'T')
		ret = 1;
	else if (LocalBuffer[0] == 'N' || LocalBuffer[0] == '0' || LocalBuffer[0] == 'F')
		ret = 0;
	else
		ret = DefValue;

	return (ret);
}
开发者ID:jdaheron,项目名称:BLDR,代码行数:25,代码来源:minIni.c


示例7: ini_getl

/** ini_getl()
 * \param Section     the name of the section to search for
 * \param Key         the name of the entry to find the value of
 * \param DefValue    the default value in the event of a failed read
 * \param Filename    the name of the .ini file to read from
 *
 * \return            the value located at Key
 */
long ini_getl(const TCHAR *Section, const TCHAR *Key, long DefValue, const TCHAR *Filename)
{
  TCHAR LocalBuffer[64];
  int len = ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename);
  return (len == 0) ? DefValue : ((len >= 2 && _totupper(LocalBuffer[1]) == 'X') ? _tcstol(LocalBuffer, NULL, 16)
                                                                      : _tcstol(LocalBuffer, NULL, 10));
}
开发者ID:jdaheron,项目名称:BLDR,代码行数:15,代码来源:minIni.c


示例8: main

int main()
{
    sizearray();
    char * text = pointertest();
    printf("\nOutput of pointer: %s\n",text);
	printf("3x3x3=%d",do_pow(3)); 
    return 0;
}
开发者ID:jelledebock,项目名称:c-files-schakelprogramma,代码行数:8,代码来源:les1.c


示例9: Profile_GetInteger

/** Profile_GetInteger()
* \param Section     the name of the section to search for
* \param Key         the name of the entry to find the value of
* \param DefValue    the default value in the event of a failed read
*
* \return            the value located at Key
*/
long Profile_GetInteger(const char *Section, const char *Key, long DefValue)
{
    char buff[64];
    int len = Profile_GetString(Section, Key, "", buff, sizearray(buff));
    //  printf("int %s \n",buff);

    if (len == 0)
    return DefValue;

    if (buff[0] == '0' && String_ToUpperCase(buff[1]) == 'X')
    return String_AParseHexU32(buff);
        else
            return _tcstol(buff,NULL,10);
}
开发者ID:Scorpio92,项目名称:mstar6a918,代码行数:21,代码来源:iniparser.c


示例10: ini_getl_OpenedFile

long ini_getl_OpenedFile(
		const mTCHAR *Section,
		const mTCHAR *Key,
		long DefValue,
		INI_FILETYPE* pFile)
{
	TCHAR LocalBuffer[64];
	int pos = 0;

//	(void) ini_seek(pFile, &pos);

	int len = ini_gets_OpenedFile(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), pFile);
	return (len == 0) ? DefValue : ((len >= 2 && _totupper(LocalBuffer[1]) == 'X') ? _tcstol(LocalBuffer, NULL, 16)
																	  : _tcstol(LocalBuffer, NULL, 10));
}
开发者ID:jdaheron,项目名称:BLDR,代码行数:15,代码来源:minIni.c


示例11: ini_getbool

/** ini_getbool()
 * \param Section     the name of the section to search for
 * \param Key         the name of the entry to find the value of
 * \param DefValue    default value in the event of a failed read; it should
 *                    zero (0) or one (1).
 * \param Buffer      a pointer to the buffer to copy into
 * \param BufferSize  the maximum number of characters to copy
 * \param Filename    the name and full path of the .ini file to read from
 *
 A true boolean is found if one of the following is matched:

  - A string starting with 'y'
  - A string starting with 'Y'
  - A string starting with 't'
  - A string starting with 'T'
  - A string starting with '1'

  A false boolean is found if one of the following is matched:

  - A string starting with 'n'
  - A string starting with 'N'
  - A string starting with 'f'
  - A string starting with 'F'
  - A string starting with '0'
 *
 * \return            the true/false flag as interpreted at Key
 */
int ini_getbool(const TCHAR *Section, const TCHAR *Key, int DefValue, const TCHAR *Filename)
{
  TCHAR buff[2];
  int ret;

  ini_gets(Section, Key, __T(""), buff, sizearray(buff), Filename);
  buff[0] = toupper(buff[0]);
  if (buff[0]=='Y' || buff[0]=='1' || buff[0]=='T')
    ret = 1;
  else if (buff[0]=='N' || buff[0]=='0' || buff[0]=='F')
    ret = 0;
  else
    ret = DefValue;

  return(ret);
}
开发者ID:AALeadDev,项目名称:Authentication-Server,代码行数:43,代码来源:minIni.c


示例12: ini_getbool

/** ini_getbool()
 * \param Section     the name of the section to search for
 * \param Key         the name of the entry to find the value of
 * \param DefValue    default value in the event of a failed read; it should
 *                    zero (0) or one (1).
 * \param Buffer      a pointer to the buffer to copy into
 * \param BufferSize  the maximum number of characters to copy
 * \param Filename    the name and full path of the .ini file to read from
 *
 * A true boolean is found if one of the following is matched:
 * - A string starting with 'y' or 'Y'
 * - A string starting with 't' or 'T'
 * - A string starting with '1'
 *
 * A false boolean is found if one of the following is matched:
 * - A string starting with 'n' or 'N'
 * - A string starting with 'f' or 'F'
 * - A string starting with '0'
 *
 * \return            the true/false flag as interpreted at Key
 */
int ini_getbool(const TCHAR *Section, const TCHAR *Key, int DefValue, const TCHAR *Filename)
{
  TCHAR LocalBuffer[2];
  int ret;

  ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename);
  LocalBuffer[0] = (TCHAR)toupper(LocalBuffer[0]);
  if (LocalBuffer[0] == 'Y' || LocalBuffer[0] == '1' || LocalBuffer[0] == 'T')
    ret = 1;
  else if (LocalBuffer[0] == 'N' || LocalBuffer[0] == '0' || LocalBuffer[0] == 'F')
    ret = 0;
  else
    ret = DefValue;

  return(ret);
}
开发者ID:Daniel-Eckert,项目名称:piksi_firmware,代码行数:37,代码来源:minIni.c


示例13: addchild

/* Inserts a subtree into the given expression tree, with pos being
 * the index of where to add the child branch.
 */
static int addchild(struct exptree *t, struct exptree *sub, int pos)
{
    int n;

    if (t->childcount == sizearray(t->child) || !sub)
	return FALSE;
    if (pos < -1 || pos > t->childcount)
	return FALSE;

    if (pos == -1 || pos == t->childcount) {
	t->child[t->childcount] = sub;
    } else {
	for (n = t->childcount ; n > pos ; --n)
	    t->child[n] = t->child[n - 1];
	t->child[pos] = sub;
    }
    ++t->childcount;
    return TRUE;
}
开发者ID:pix,项目名称:cppp,代码行数:22,代码来源:exptree.c


示例14: amx_exec_run

cell amx_exec_run(AMX *amx,cell *retval,unsigned char *data)
{
static const void * const amx_opcodelist[] = {
        /* core set */
        &&op_nop,         &&op_load_pri,    &&op_load_alt,    &&op_load_s_pri,
        &&op_load_s_alt,  &&op_lref_s_pri,  &&op_lref_s_alt,  &&op_load_i,
        &&op_lodb_i,      &&op_const_pri,   &&op_const_alt,   &&op_addr_pri,
        &&op_addr_alt,    &&op_stor,        &&op_stor_s,      &&op_sref_s,
        &&op_stor_i,      &&op_strb_i,      &&op_align_pri,   &&op_lctrl,
        &&op_sctrl,       &&op_xchg,        &&op_push_pri,    &&op_push_alt,
        &&op_pushr_pri,   &&op_pop_pri,     &&op_pop_alt,     &&op_pick,
        &&op_stack,       &&op_heap,        &&op_proc,        &&op_ret,
        &&op_retn,        &&op_call,        &&op_jump,        &&op_jzer,
        &&op_jnz,         &&op_shl,         &&op_shr,         &&op_sshr,
        &&op_shl_c_pri,   &&op_shl_c_alt,   &&op_smul,        &&op_sdiv,
        &&op_add,         &&op_sub,         &&op_and,         &&op_or,
        &&op_xor,         &&op_not,         &&op_neg,         &&op_invert,
        &&op_eq,          &&op_neq,         &&op_sless,       &&op_sleq,
        &&op_sgrtr,       &&op_sgeq,        &&op_inc_pri,     &&op_inc_alt,
        &&op_inc_i,       &&op_dec_pri,     &&op_dec_alt,     &&op_dec_i,
        &&op_movs,        &&op_cmps,        &&op_fill,        &&op_halt,
        &&op_bounds,      &&op_sysreq,      &&op_switch,      &&op_swap_pri,
        &&op_swap_alt,    &&op_break,       &&op_casetbl,
        /* patched instructions */
        /* if op_sysreq_d and/or op_sysreq_nd are not implemented, their entries
         * in this table must be NULL
         */
        &&op_sysreq_d,    &&op_sysreq_nd,
        /* overlay instructions */
        &&op_call_ovl,    &&op_retn_ovl,    &&op_switch_ovl,  &&op_casetbl_ovl,
        /* supplemental and macro instructions */
#if !defined AMX_NO_MACRO_INSTR
        &&op_lidx,        &&op_lidx_b,      &&op_idxaddr,     &&op_idxaddr_b,
        &&op_push_c,      &&op_push,        &&op_push_s,      &&op_push_adr,
        &&op_pushr_c,     &&op_pushr_s,     &&op_pushr_adr,   &&op_jeq,
        &&op_jneq,        &&op_jsless,      &&op_jsleq,       &&op_jsgrtr,
        &&op_jsgeq,       &&op_sdiv_inv,    &&op_sub_inv,     &&op_add_c,
        &&op_smul_c,      &&op_zero_pri,    &&op_zero_alt,    &&op_zero,
        &&op_zero_s,      &&op_eq_c_pri,    &&op_eq_c_alt,    &&op_inc,
        &&op_inc_s,       &&op_dec,         &&op_dec_s,       &&op_sysreq_n,
        &&op_pushm_c,     &&op_pushm,       &&op_pushm_s,     &&op_pushm_adr,
        &&op_pushrm_c,    &&op_pushrm_s,    &&op_pushrm_adr,  &&op_load2,
        &&op_load2_s,     &&op_const,       &&op_const_s,
#endif
#if !defined AMX_NO_PACKED_OPC
        &&op_load_p_pri,  &&op_load_p_alt,  &&op_load_p_s_pri,&&op_load_p_s_alt,
        &&op_lref_p_s_pri,&&op_lref_p_s_alt,&&op_lodb_p_i,    &&op_const_p_pri,
        &&op_const_p_alt, &&op_addr_p_pri,  &&op_addr_p_alt,  &&op_stor_p,
        &&op_stor_p_s,    &&op_sref_p_s,    &&op_strb_p_i,    &&op_lidx_p_b,
        &&op_idxaddr_p_b, &&op_align_p_pri, &&op_push_p_c,    &&op_push_p,
        &&op_push_p_s,    &&op_push_p_adr,  &&op_pushr_p_c,   &&op_pushr_p_s,
        &&op_pushr_p_adr, &&op_pushm_p_c,   &&op_pushm_p,     &&op_pushm_p_s,
        &&op_pushm_p_adr, &&op_pushrm_p_c,  &&op_pushrm_p_s,  &&op_pushrm_p_adr,
        &&op_stack_p,     &&op_heap_p,      &&op_shl_p_c_pri, &&op_shl_p_c_alt,
        &&op_add_p_c,     &&op_smul_p_c,    &&op_zero_p,      &&op_zero_p_s,
        &&op_eq_p_c_pri,  &&op_eq_p_c_alt,  &&op_inc_p,       &&op_inc_p_s,
        &&op_dec_p,       &&op_dec_p_s,     &&op_movs_p,      &&op_cmps_p,
        &&op_fill_p,      &&op_halt_p,      &&op_bounds_p,
#endif
};
  AMX_HEADER *hdr;
  cell pri,alt,stk,frm,hea;
  cell reset_stk, reset_hea, *cip;
  cell offs,val;
  int num,i;
  #if !defined AMX_NO_PACKED_OPC
    int op;
  #endif

  assert(amx!=NULL);
  /* HACK: return label table and opcode count (for VerifyPcode()) if amx
   * structure has the flags set to all ones (see amx_exec_list() above)
   */
  if (amx->flags==~0) {
    assert(sizeof(cell)==sizeof(void *));
    assert(data==NULL);
    assert(retval!=NULL);
    *retval=(cell)amx_opcodelist;
    return sizearray(amx_opcodelist);
  } /* if */

  /* set up the registers */
  hdr=(AMX_HEADER *)amx->base;
  assert(hdr->magic==AMX_MAGIC);
  assert(hdr->file_version>=11);
  cip=(cell*)amx->cip;
  hea=amx->hea;
  stk=amx->stk;
  reset_stk=stk;
  reset_hea=hea;
  alt=frm=pri=0;/* just to avoid compiler warnings */
  num=0;        /* just to avoid compiler warnings */

  /* start running */
  assert(amx->code!=NULL);
  assert(data!=NULL);
  cip=(cell *)(amx->code+(int)amx->cip);
  NEXT(cip,op);

  op_nop:
//.........这里部分代码省略.........
开发者ID:jay1109,项目名称:pawnscript,代码行数:101,代码来源:amxexec_gcc.c


示例15: error

/*  error
 *
 *  Outputs an error message (note: msg is passed optionally).
 *  If an error is found, the variable "errflag" is set and subsequent
 *  errors are ignored until lex() finds a semicolon or a keyword
 *  (lex() resets "errflag" in that case).
 *
 *  Global references: inpfname   (reffered to only)
 *                     fline      (reffered to only)
 *                     fcurrent   (reffered to only)
 *                     errflag    (altered)
 */
SC_FUNC int error(long number,...)
{
static char *prefix[3]={ "error", "fatal error", "warning" };
static int lastline,errorcount;
static short lastfile;
  char *msg,*pre,*filename;
  va_list argptr;
  char string[256];
  int notice;

  /* split the error field between the real error/warning number and an optional
   * "notice" number
   */
  notice=number >> (sizeof(long)*4);
  number&=((unsigned long)~0) >> (sizeof(long)*4);
  assert(number>0 && number<300);

  /* errflag is reset on each semicolon.
   * In a two-pass compiler, an error should not be reported twice. Therefore
   * the error reporting is enabled only in the second pass (and only when
   * actually producing output). Fatal errors may never be ignored.
   */
  if ((errflag || sc_status!=statWRITE) && (number<100 || number>=200))
    return 0;

  /* also check for disabled warnings */
  if (number>=200) {
    int index=(number-200)/8;
    int mask=1 << ((number-200)%8);
    if ((warndisable[index] & mask)!=0) {
      errline=-1;
      errfile=-1;
      return 0;
    } /* if */
  } /* if */

  if (number<100){
    assert(number>0 && number<sizearray(errmsg));
    msg=errmsg[number];
    pre=prefix[0];
    errflag=TRUE;       /* set errflag (skip rest of erroneous expression) */
    errnum++;
  } else if (number<200) {
    assert((number-100)>=0 && (number-100)<sizearray(fatalmsg));
    msg=fatalmsg[number-100];
    pre=prefix[1];
    errnum++;           /* a fatal error also counts as an error */
  } else {
    assert((number-200)>=0 && (number-200)<sizearray(warnmsg));
    msg=warnmsg[number-200];
    pre=prefix[2];
    warnnum++;
  } /* if */

  strexpand(string,(unsigned char *)msg,sizeof string-2,SCPACK_TABLE);
  if (notice>0) {
    int len;
    assert(notice<sizearray(noticemsg));
    strcat(string,"; ");
    len=strlen(string);
    strexpand(string+len,(unsigned char *)noticemsg[notice],sizeof string-len-1,SCPACK_TABLE);
  } /* if */
  strcat(string,"\n");

  if (errline>0)
    errstart=errline;           /* forced error position, set single line destination */
  else
    errline=fline;              /* normal error, errstart may (or may not) have been marked, endpoint is current line */
  if (errstart>errline)
    errstart=errline;           /* special case: error found at end of included file */
  if (errfile>=0) {
    filename=get_inputfile(errfile);/* forced filename */
  } else {
    filename=inpfname;          /* current file */
    if (filename==NULL || strlen(filename)==0)
      filename=get_sourcefile(0);
    if (filename==NULL || strlen(filename)==0)
      filename="(none)";
  } /* if */
  assert(filename!=NULL);

  va_start(argptr,number);
  if (strlen(errfname)==0) {
    int start= (errstart==errline) ? -1 : errstart;
    if (pc_error((int)number,string,filename,start,errline,argptr)) {
      if (outf!=NULL) {
        pc_closeasm(outf,TRUE);
        outf=NULL;
//.........这里部分代码省略.........
开发者ID:dmschwartz,项目名称:QuadPawn,代码行数:101,代码来源:sc5.c


示例16: while

bool CXFFont::Read(const char *path)
{
  FILE *fp;
  if ((fp = fopen(path, "r")) == NULL)
    return false;

  bool result = true;
  char line[128]; /* lines in CXF fonts are short */
  while (fgets(line, sizearray(line), fp) != NULL && result) {
    if (line[0] == '#') {
      /* parse header line */
      char *ptr = line + 1;
      while (*ptr != '\0' && *ptr <= ' ')
        ptr++;
      if (strncasecmp(ptr, "LetterSpacing", 13) == 0) {
        ptr += 13;
        if (*ptr == ':')
          ptr++;
        m_LetterSpacing = (float)strtod(ptr, NULL);
      } else if (strncasecmp(ptr, "WordSpacing", 11) == 0) {
        ptr += 11;
        if (*ptr == ':')
          ptr++;
        m_WordSpacing = (float)strtod(ptr, NULL);
      } else if (strncasecmp(ptr, "LineSpacingFactor", 17) == 0) {
        ptr += 17;
        if (*ptr == ':')
          ptr++;
        m_LineSpacingFactor = (float)strtod(ptr, NULL);
      }
    } else if (line[0] == '[') {
      /* parse glyph */
      char *ptr;
      unsigned short code;
      if (line[1] == '#' && line[2] != ']') {
        /* Unicode character as a hexadecimal code */
        code = (unsigned short)strtol(line + 2, &ptr, 16);
      } else {
        /* ASCII character */
        code = line[1];
        ptr = line + 2;
      }
      if (*ptr != ']') {
        result = false; /* invalid (or unsupported) file format */
        break;
      }
      unsigned short count = (unsigned short)strtol(ptr + 1, NULL, 10);
      if (count == 0) {
        result = false; /* invalid (or unsupported) file format */
        break;
      }
      /* now parse the line segments, and collect consecutive segments into a
         polyline */
      CXFGlyph glyph(code);
      CXFPolyLine stroke;
      float xp = -1, yp = -1; /* force new stroke for the first coordinates */
      float width = 0;
      for (unsigned short i = 0; i < count; i++) {
        if (fgets(line, sizearray(line), fp) == 0)
          break;
        assert(line[0] == 'L');
        float x1, y1, x2, y2;
        sscanf(line, "L %f,%f,%f,%f", &x1, &y1, &x2, &y2);
        /* see whether we can continue the stroke, or whether a new one must be
           added */
        if (xp < x1 - EPSILON || xp > x1 + EPSILON || yp < y1 - EPSILON || yp > y1 + EPSILON) {
          /* non-continuous line segments, finish this polyline and start a new one */
          if (stroke.GetCount() > 0) {
            glyph.AddStroke(stroke);
            stroke.Clear();
          }
          stroke.AddPoint(CXFPoint(x1, y1));
          if (width < x1)
            width = x1;
        }
        stroke.AddPoint(CXFPoint(x2, y2));
        xp = x2;
        yp = y2;
        if (width < x2)
          width = x2;
      }
      if (stroke.GetCount() > 0)
        glyph.AddStroke(stroke);	/* add the final stroke */
      glyph.SetWidth(width);
      m_Glyphs.push_back(glyph);
    }
  }
  fclose(fp);

  /* analyze a few characters to find the typical font metrics */
  float dummy;
  GetGlyphVSize('A', &m_CapsHeight, &dummy);
  GetGlyphVSize('x', &m_XHeight, &dummy);
  GetGlyphVSize('h', &m_Ascender, &dummy);
  GetGlyphVSize('p', &dummy, &m_Descender);

  return result;
}
开发者ID:bitdivision,项目名称:KiCad-Librarian,代码行数:98,代码来源:cxffont.cpp


示例17: ini_puts

/** ini_puts()
 * \param Section     the name of the section to write the string in
 * \param Key         the name of the entry to write, or NULL to erase all keys in the section
 * \param Value       a pointer to the buffer the string, or NULL to erase the key
 * \param Filename    the name and full path of the .ini file to write to
 *
 * \return            1 if successful, otherwise 0
 */
int ini_puts(const TCHAR *Section, const TCHAR *Key, const TCHAR *Value, const TCHAR *Filename)
{
  INI_FILETYPE rfp;
  INI_FILETYPE wfp;
  INI_FILEPOS mark;
  TCHAR *sp, *ep;
  TCHAR LocalBuffer[INI_BUFFERSIZE];
  int len, match, flag, cachelen;

  assert(Filename != NULL);
  if (!ini_openread(Filename, &rfp)) {
    /* If the .ini file doesn't exist, make a new file */
    if (Key != NULL && Value != NULL) {
      if (!ini_openwrite(Filename, &wfp))
        return 0;
      writesection(LocalBuffer, Section, &wfp);
      writekey(LocalBuffer, Key, Value, &wfp);
      (void)ini_close(&wfp);
    } /* if */
    return 1;
  } /* if */

  /* If parameters Key and Value are valid (so this is not an "erase" request)
   * and the setting already exists and it already has the correct value, do
   * nothing. This early bail-out avoids rewriting the INI file for no reason.
   */
  if (Key != NULL && Value != NULL) {
    (void)ini_tell(&rfp, &mark);
    match = getkeystring(&rfp, Section, Key, -1, -1, LocalBuffer, sizearray(LocalBuffer));
    if (match && _tcscmp(LocalBuffer,Value) == 0) {
      (void)ini_close(&rfp);
      return 1;
    } /* if */
    /* key not found, or different value -> proceed (but rewind the input file first) */
    (void)ini_seek(&rfp, &mark);
  } /* if */

  /* Get a temporary file name to copy to. Use the existing name, but with
   * the last character set to a '~'.
   */
  ini_tempname(LocalBuffer, Filename, INI_BUFFERSIZE);
  if (!ini_openwrite(LocalBuffer, &wfp)) {
    (void)ini_close(&rfp);
    return 0;
  } /* if */
  (void)ini_tell(&rfp, &mark);
  cachelen = 0;

  /* Move through the file one line at a time until a section is
   * matched or until EOF. Copy to temp file as it is read.
   */
  len = (Section != NULL) ? _tcslen(Section) : 0;
  if (len > 0) {
    do {
      if (!ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp)) {
        /* Failed to find section, so add one to the end */
        flag = cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark);
        if (Key!=NULL && Value!=NULL) {
          if (!flag)
            (void)ini_write(INI_LINETERM, &wfp);  /* force a new line behind the last line of the INI file */
          writesection(LocalBuffer, Section, &wfp);
          writekey(LocalBuffer, Key, Value, &wfp);
        } /* if */
        return close_rename(&rfp, &wfp, Filename, LocalBuffer);  /* clean up and rename */
      } /* if */
      /* Copy the line from source to dest, but not if this is the section that
       * we are looking for and this section must be removed
       */
      sp = skipleading(LocalBuffer);
      ep = _tcschr(sp, ']');
      match = (*sp == '[' && ep != NULL && (int)(ep-sp-1) == len && _tcsnicmp(sp + 1,Section,len) == 0);
      if (!match || Key != NULL) {
        if (!cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE)) {
          cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark);
          (void)ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp);
          cache_accum(LocalBuffer, &cachelen, INI_BUFFERSIZE);
        } /* if */
      } /* if */
    } while (!match);
  } /* if */
  cache_flush(LocalBuffer, &cachelen, &rfp, &wfp, &mark);
  /* when deleting a section, the section head that was just found has not been
   * copied to the output file, but because this line was not "accumulated" in
   * the cache, the position in the input file was reset to the point just
   * before the section; this must now be skipped (again)
   */
  if (Key == NULL) {
    (void)ini_read(LocalBuffer, INI_BUFFERSIZE, &rfp);
    (void)ini_tell(&rfp, &mark);
  } /* if */

  /* Now that the section has been found, find the entry. Stop searching
//.........这里部分代码省略.........
开发者ID:Daniel-Eckert,项目名称:piksi_firmware,代码行数:101,代码来源:minIni.c


示例18: ini_getf

/** ini_getf()
 * \param Section     the name of the section to search for
 * \param Key         the name of the entry to find the value of
 * \param DefValue    the default value in the event of a failed read
 * \param Filename    the name of the .ini file to read from
 *
 * \return            the value located at Key
 */
INI_REAL ini_getf(const TCHAR *Section, const TCHAR *Key, INI_REAL DefValue, const TCHAR *Filename)
{
  TCHAR LocalBuffer[64];
  int len = ini_gets(Section, Key, __T(""), LocalBuffer, sizearray(LocalBuffer), Filename);
  return (len == 0) ? DefValue : ini_atof(LocalBuffer);
}
开发者ID:Daniel-Eckert,项目名称:piksi_firmware,代码行数:14,代码来源:minIni.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sizenode函数代码示例发布时间:2022-05-30
下一篇:
C++ size_type函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap