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

C++ safe_strcat函数代码示例

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

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



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

示例1: unacceptable_os

bool unacceptable_os() {
    unsigned int i;
    char buf[1024];

    for (i=0; i<config.ban_os->size(); i++) {
        regex_t& re = (*config.ban_os)[i];
        safe_strcpy(buf, g_request->host.os_name);
        safe_strcat(buf, "\t");
        safe_strcat(buf, g_request->host.os_version);
        if (!regexec(&re, buf, 0, NULL, 0)) {
            log_messages.printf(MSG_NORMAL,
                                "Unacceptable OS %s %s\n",
                                g_request->host.os_name, g_request->host.os_version
                               );
            sprintf(buf, "%s %s %s",
                    _("This project doesn't support operating system"),
                    g_request->host.os_name, g_request->host.os_version
                   );
            g_reply->insert_message(buf, "notice");
            g_reply->set_delay(DELAY_UNACCEPTABLE_OS);
            return true;
        }
    }
    return false;
}
开发者ID:hanxue,项目名称:Boinc,代码行数:25,代码来源:handle_request.cpp


示例2: sentence_in_dictionary

/**
 * This just looks up all the words in the sentence, and builds
 * up an appropriate error message in case some are not there.
 * It has no side effect on the sentence.  Returns TRUE if all
 * went well.
 */
int sentence_in_dictionary(Sentence sent)
{
	int w, ok_so_far;
	char * s;
	Dictionary dict = sent->dict;
	char temp[1024];

	ok_so_far = TRUE;
	for (w=0; w<sent->length; w++)
	{
		s = sent->word[w].string;
		if (!boolean_dictionary_lookup(dict, s) &&
		    !(is_utf8_upper(s)   && dict->capitalized_word_defined) &&
		    !(is_utf8_upper(s) && is_s_word(s) && dict->pl_capitalized_word_defined) &&
		    !(ishyphenated(s) && dict->hyphenated_word_defined)  &&
		    !(is_number(s)	&& dict->number_word_defined) &&
		    !(is_ing_word(s)  && dict->ing_word_defined)  &&
		    !(is_s_word(s)	&& dict->s_word_defined)  &&
		    !(is_ed_word(s)   && dict->ed_word_defined)  &&
		    !(is_ly_word(s)   && dict->ly_word_defined))
		{
			if (ok_so_far) {
				safe_strcpy(temp, "The following words are not in the dictionary:", sizeof(temp));
				ok_so_far = FALSE;
			}
			safe_strcat(temp, " \"", sizeof(temp));
			safe_strcat(temp, sent->word[w].string, sizeof(temp));
			safe_strcat(temp, "\"", sizeof(temp));
		}
	}
	if (!ok_so_far) {
		lperror(NOTINDICT, "\n%s\n", temp);
	}
	return ok_so_far;
}
开发者ID:arv100kri,项目名称:linkparser,代码行数:41,代码来源:tokenize.c


示例3: unacceptable_cpu

bool unacceptable_cpu() {
    unsigned int i;
    char buf[1024];

    for (i=0; i<config.ban_cpu->size(); i++) {
        regex_t& re = (*config.ban_cpu)[i];
        safe_strcpy(buf, g_request->host.p_vendor);
        safe_strcat(buf, "\t");
        safe_strcat(buf, g_request->host.p_model);
        if (!regexec(&re, buf, 0, NULL, 0)) {
            log_messages.printf(MSG_NORMAL,
                                "Unacceptable CPU %s %s\n",
                                g_request->host.p_vendor, g_request->host.p_model
                               );
            sprintf(buf, "%s %s %s",
                    _("This project doesn't support CPU type"),
                    g_request->host.p_vendor, g_request->host.p_model
                   );
            g_reply->insert_message(buf, "notice");
            g_reply->set_delay(DELAY_UNACCEPTABLE_OS);
            return true;
        }
    }
    return false;
}
开发者ID:hanxue,项目名称:Boinc,代码行数:25,代码来源:handle_request.cpp


示例4: file

/****************************************************************************
Append single file to tar file (or not)
***************************************************************************/
static void do_tar(file_info *finfo)
{
  pstring rname;

  if (strequal(finfo->name,"..") || strequal(finfo->name,"."))
    return;

  /* Is it on the exclude list ? */
  if (!tar_excl && clipn) {
    pstring exclaim;

    DEBUG(5, ("Excl: strlen(cur_dir) = %d\n", (int)strlen(cur_dir)));

    safe_strcpy(exclaim, cur_dir, sizeof(pstring));
    *(exclaim+strlen(exclaim)-1)='\0';

    safe_strcat(exclaim, "\\", sizeof(pstring));
    safe_strcat(exclaim, finfo->name, sizeof(exclaim));

    DEBUG(5, ("...tar_re_search: %d\n", tar_re_search));

    if ((!tar_re_search && clipfind(cliplist, clipn, exclaim)) ||
#ifdef HAVE_REGEX_H
	(tar_re_search && !regexec(preg, exclaim, 0, NULL, 0))) {
#else
        (tar_re_search && mask_match(exclaim, cliplist[0], True, False))) {
#endif
      DEBUG(3,("Skipping file %s\n", exclaim));
      return;
    }
  }
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:34,代码来源:clitar.c


示例5: strlen

/* whether you pass in a NULL pointer or your own allocated memory for
 * out_str, you need to free the memory yourself */
char *substitute_char_with_string(const char *str, char **out_str, char to_sub, const char* with_sub)
{
	int amp_count = 0;
	const char *start_ptr;
	char *end_ptr;
	int out_len = 0;
	size_t alloc_len = 0;

	for (start_ptr = str; (start_ptr = strchr(start_ptr, to_sub)) != NULL; start_ptr++)
		amp_count++;

	alloc_len = strlen(str) + amp_count*(strlen(with_sub)-1) + 1;
	*out_str = (char *)realloc(*out_str, alloc_len);
	**out_str = '\0';
	
	for (start_ptr = str; (end_ptr = strchr(start_ptr, to_sub)) != NULL; )
	{
		while (start_ptr < end_ptr)
			(*out_str)[out_len++] = *start_ptr++;
		(*out_str)[out_len] = '\0';

		safe_strcat(*out_str, with_sub, alloc_len);
		out_len = strlen(*out_str);
		start_ptr++;
	}
	safe_strcat(*out_str, start_ptr, alloc_len);
	return *out_str;
}
开发者ID:sorlok,项目名称:Eternal-Lands,代码行数:30,代码来源:asc.c


示例6: unparse_afs_acl

static BOOL unparse_afs_acl(struct afs_acl *acl, char *acl_str)
{
	/* TODO: String length checks!!!! */

	int positives = 0;
	int negatives = 0;
	fstring line;

	*acl_str = 0;

	struct afs_ace *ace = acl->acelist;

	while (ace != NULL) {
		if (ace->positive)
			positives++;
		else
			negatives++;
		ace = ace->next;
	}

	fstr_sprintf(line, "%d\n", positives);
	safe_strcat(acl_str, line, MAXSIZE);

	fstr_sprintf(line, "%d\n", negatives);
	safe_strcat(acl_str, line, MAXSIZE);

	ace = acl->acelist;

	while (ace != NULL) {
		fstr_sprintf(line, "%s\t%d\n", ace->name, ace->rights);
		safe_strcat(acl_str, line, MAXSIZE);
		ace = ace->next;
	}
	return True;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:35,代码来源:vfs_afsacl.c


示例7: SetupCertFilename

static void SetupCertFilename()
{

   char default_priv_filename[] = "server.key";
   char default_pub_filename[] = "server.crt";
   char *priv_filename = getenv("SQCERT_PRIVKEY");
   char *pub_filename = getenv("SQCERT_PUBKEY");
   char *clustername  = getenv("CLUSTERNAME");
   char *homedir  = getenv("HOME");
   char *sqroot  = getenv("MY_SQROOT");
   char *certdir = getenv("SQCERT_DIR");

   // Get the Certificate directory and the filename
   // If the env variable SQCERT_DIR
   // For a Cluster - look

   if (certdir == NULL)
   {
      if (clustername != NULL)
      {
         strncpy (privkey_file, homedir, MS_MON_MAX_PROCESS_PATH);
         privkey_file[MS_MON_MAX_PROCESS_PATH-1] = 0;
      }

      else
      { // it's a workstation

      if (sqroot != NULL)
      {
         strncpy (privkey_file, sqroot, MS_MON_MAX_PROCESS_PATH);
         privkey_file[MS_MON_MAX_PROCESS_PATH-1] = 0;
      }
      else
         strcpy (privkey_file, "/tmp");
      }

      safe_strcat (privkey_file, (char *) "/sqcert/", MS_MON_MAX_PROCESS_PATH);
   }
   else
   {
      strncpy(privkey_file, certdir, MS_MON_MAX_PROCESS_PATH);
      privkey_file[MS_MON_MAX_PROCESS_PATH-1] == 0;
      strcat (privkey_file, "/");
   }

   // Done forming the directory location - copy the same to public file
   strcpy(pubkey_file, privkey_file);

   if (priv_filename != NULL)
      safe_strcat (privkey_file, priv_filename, MS_MON_MAX_PROCESS_PATH);  
   else
      safe_strcat (privkey_file, default_priv_filename, MS_MON_MAX_PROCESS_PATH);

   if (pub_filename != NULL)
      safe_strcat (pubkey_file, pub_filename, MS_MON_MAX_PROCESS_PATH);
   else
      safe_strcat (pubkey_file, default_pub_filename, MS_MON_MAX_PROCESS_PATH);

}
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:59,代码来源:secsrvr.cpp


示例8: exists

/****************************************************************************
Ensure a remote path exists (make if necessary)
***************************************************************************/
static BOOL ensurepath(char *fname)
{
  /* *must* be called with buffer ready malloc'ed */
  /* ensures path exists */

  char *partpath, *ffname;
  char *p=fname, *basehack;

  DEBUG(5, ( "Ensurepath called with: %s\n", fname));

  partpath = string_create_s(strlen(fname));
  ffname = string_create_s(strlen(fname));

  if ((partpath == NULL) || (ffname == NULL)){

    DEBUG(0, ("Out of memory in ensurepath: %s\n", fname));
    return(False);

  }

  *partpath = 0;

  /* fname copied to ffname so can strtok */

  safe_strcpy(ffname, fname, strlen(fname));

  /* do a `basename' on ffname, so don't try and make file name directory */
  if ((basehack=strrchr(ffname, '\\')) == NULL)
    return True;
  else
    *basehack='\0';

  p=strtok(ffname, "\\");

  while (p)
    {
      safe_strcat(partpath, p, strlen(fname) + 1);

      if (!cli_chkpath(cli, partpath)) {
	if (!cli_mkdir(cli, partpath))
	  {
	    DEBUG(0, ("Error mkdirhiering\n"));
	    return False;
	  }
	else
	  DEBUG(3, ("mkdirhiering %s\n", partpath));

      }

      safe_strcat(partpath, "\\", strlen(fname) + 1);
      p = strtok(NULL,"/\\");
    }

    return True;
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:58,代码来源:clitar.c


示例9: memset

int RESULT::parse_from_client(FILE* fin) {
    char buf[256];

    // should be non-zero if exit_status is not found
    exit_status = ERR_NO_EXIT_STATUS;
    memset(this, 0, sizeof(RESULT));
    while (fgets(buf, sizeof(buf), fin)) {
        if (match_tag(buf, "</result>")) {
            return 0;
        }
        if (parse_str(buf, "<name>", name, sizeof(name))) continue;
        if (parse_int(buf, "<state>", client_state)) continue;
        if (parse_double(buf, "<final_cpu_time>", cpu_time)) continue;
        if (parse_double(buf, "<final_elapsed_time>", elapsed_time)) continue;
        if (parse_int(buf, "<exit_status>", exit_status)) continue;
        if (parse_int(buf, "<app_version_num>", app_version_num)) continue;
        if (parse_double(buf, "<fpops_per_cpu_sec>", fpops_per_cpu_sec)) continue;
        if (parse_double(buf, "<fpops_cumulative>", fpops_cumulative)) continue;
        if (parse_double(buf, "<intops_per_cpu_sec>", intops_per_cpu_sec)) continue;
        if (parse_double(buf, "<intops_cumulative>", intops_cumulative)) continue;
        if (match_tag(buf, "<file_info>")) {
            safe_strcat(xml_doc_out, buf);
            while (fgets(buf, sizeof(buf), fin)) {
                safe_strcat(xml_doc_out, buf);
                if (match_tag(buf, "</file_info>")) break;
            }
            continue;
        }
        if (match_tag(buf, "<stderr_out>" )) {
            while (fgets(buf, sizeof(buf), fin)) {
                if (match_tag(buf, "</stderr_out>")) break;
                safe_strcat(stderr_out, buf);
            }
            continue;
        }
        if (match_tag(buf, "<platform>")) continue;
        if (match_tag(buf, "<version_num>")) continue;
        if (match_tag(buf, "<plan_class>")) continue;
        if (match_tag(buf, "<completed_time>")) continue;
        if (match_tag(buf, "<file_name>")) continue;
        if (match_tag(buf, "<file_ref>")) continue;
        if (match_tag(buf, "</file_ref>")) continue;
        if (match_tag(buf, "<open_name>")) continue;
        if (match_tag(buf, "<ready_to_report>")) continue;
        if (match_tag(buf, "<ready_to_report/>")) continue;
        if (match_tag(buf, "<report_deadline>")) continue;
        if (match_tag(buf, "<wu_name>")) continue;

        log_messages.printf(MSG_NORMAL,
            "RESULT::parse_from_client(): unrecognized: %s\n",
            buf
        );
    }
    return ERR_XML_PARSE;
}
开发者ID:freehal,项目名称:boinc-freehal,代码行数:55,代码来源:sched_types.cpp


示例10: update_selectables

void update_selectables(){
	int pos,i;
	hash_entry *he;

	i=0;
	pos=vscrollbar_get_pos(emotes_win, EMOTES_SCROLLBAR_ITEMS);
	memset(selectables,0,sizeof(emote_data*)*EMOTES_SHOWN);
	hash_start_iterator(emotes);
	while((he=hash_get_next(emotes))&&i<EMOTES_SHOWN){
		emote_data *emote;

		emote=((emote_data *)he->item);
		if(!cur_cat&&emote->pose>EMOTE_STANDING) {
			//emotes
			pos--;
			if(pos>=0) continue;
			selectables[i]=emote;
			i++;
		} else if(cur_cat&&emote->pose==(cur_cat-1)){
			//poses
			pos--;
			if(pos>=0) continue;
			selectables[i]=emote;
			i++;
		}
	}

	emote_str1[1]=emote_str2[0]=emote_str2[1]=0;
	if(emote_sel[cur_cat]){
		emote_dict *emd;

		emote_str1[0]=127+c_orange2;
		safe_strcat((char*)emote_str1,(char*)emote_sel[cur_cat]->desc,/*sizeof(emote_str1)*/23);
		hash_start_iterator(emote_cmds);
		while((he=hash_get_next(emote_cmds))){
			emd = (emote_dict*)he->item;
			if (emd->emote==emote_sel[cur_cat]){
				int ll;
				//draw command
				if(!emote_str2[0]) {
					emote_str2[0]=127+c_grey1;
					safe_strcat((char*)emote_str2,"Trigger:",10);
				}
				ll=strlen((char*)emote_str2);
				emote_str2[ll]=127+c_green3;
				emote_str2[ll+1]=emote_str2[ll+2]=' ';
				emote_str2[ll+3]=0;
				safe_strcat((char*)emote_str2,emd->command,/*sizeof(emote_str2)*/23);
				break; //just one command
			}
		}
	}
	
}
开发者ID:Adamantinus,项目名称:Eternal-Lands,代码行数:54,代码来源:emotes.c


示例11: vfs_my_module_create_dir

static int vfs_my_module_create_dir(vfs_handle_struct *handle, const char *dname, const struct smb_filename *smb_fname)
{
	size_t len;
	mode_t mode;
	char *new_dir = NULL;
	char *tmp_str = NULL;
	char *token;
	char *tok_str;
	bool ret = False;
	char *saveptr;
    int i = 0;
	mode = vfs_my_module_directory_mode(handle);

	tmp_str = SMB_STRDUP(dname);
	ALLOC_CHECK(tmp_str, done);
	tok_str = tmp_str;

	len = strlen(dname)+1;
	new_dir = (char *)SMB_MALLOC(len + 1);
	ALLOC_CHECK(new_dir, done);
	*new_dir = '\0';
	if (dname[0] == '/') {
		/* Absolute path. */
		safe_strcat(new_dir,"/",len);
	}

	/* Create directory tree if neccessary */
	for(token = strtok_r(tok_str, "/", &saveptr); token;
	    token = strtok_r(NULL, "/", &saveptr)) {
		safe_strcat(new_dir, token, len);
		if (vfs_my_module_directory_exist(handle, new_dir))
			DEBUG(10, ("CREATE DIR: dir %s already exists\n", new_dir));
		else {
			DEBUG(1, ("CREATE DIR: creating new dir %s\n", new_dir));
			if (SMB_VFS_NEXT_MKDIR(handle, new_dir,mode) != 0) {
				DEBUG(1,("CREATE DIR: failed for %s with error: %s\n", new_dir, strerror(errno)));
				ret = False;
			}

		}
		safe_strcat(new_dir, "/", len);
		mode = vfs_my_module_subdir_mode(handle);
	i++;
	DEBUG(1,("CREATE DIR COUNTER: %d\n", i));
	ret = True;
	}
done:
	SAFE_FREE(tmp_str);
	SAFE_FREE(new_dir);
	return i;
}
开发者ID:int-argc,项目名称:CVFS2.0,代码行数:51,代码来源:vfs_my_module.c


示例12: check_cache

static BOOL check_cache( char *s, size_t maxlen, int snum )
{
	TDB_DATA data_val;
	char *ext_start = NULL;
	char *saved_ext = NULL;

	magic_char = lp_magicchar(snum);

	/* If the cache isn't initialized, give up. */
	if( !tdb_mangled_cache )
		return( False );

	data_val = tdb_fetch_bystring(tdb_mangled_cache, s);

	/* If we didn't find the name *with* the extension, try without. */
	if(data_val.dptr == NULL || data_val.dsize == 0) {
		ext_start = strrchr( s, '.' );
		if( ext_start ) {
			if((saved_ext = SMB_STRDUP(ext_start)) == NULL)
				return False;

			*ext_start = '\0';
			data_val = tdb_fetch_bystring(tdb_mangled_cache, s);
			/* 
			 * At this point s is the name without the
			 * extension. We re-add the extension if saved_ext
			 * is not null, before freeing saved_ext.
			 */
		}
	}

	/* Okay, if we haven't found it we're done. */
	if(data_val.dptr == NULL || data_val.dsize == 0) {
		if(saved_ext) {
			/* Replace the saved_ext as it was truncated. */
			(void)safe_strcat( s, saved_ext, maxlen );
			SAFE_FREE(saved_ext);
		}
		return( False );
	}

	/* If we *did* find it, we need to copy it into the string buffer. */
	(void)safe_strcpy( s, data_val.dptr, maxlen );
	if( saved_ext ) {
		/* Replace the saved_ext as it was truncated. */
		(void)safe_strcat( s, saved_ext, maxlen );
		SAFE_FREE(saved_ext);
	}
	SAFE_FREE(data_val.dptr);
	return( True );
}
开发者ID:DeezNuts12,项目名称:freestyledash,代码行数:51,代码来源:mangle_hash.c


示例13: pre_parse

void pre_parse( char * list, char * victimname, char * containername, char * things )
{
    char arg1[MSL];
    char container_name[MSL];
    char one_object[MSL];
    char holdbuf[MSL];
    char victim_name[MSL];
    char object_list[MSL];
    char * argument = list;
    container_name[0] = '\0';
    victim_name[0] = '\0';
    object_list[0] = '\0';
    for ( ; ; )
    {
        argument = one_argument( argument, arg1 );
        if ( arg1[0] == '\0' )
            break;
        if (  ( !str_cmp( "from", arg1 ) )
            || ( !str_cmp( "in", arg1 ) )  )
        {
            argument = one_argument( argument, container_name );
        }
        else if ( !str_cmp( "to", arg1 ) )
        {
            argument = one_argument( argument, victim_name );
        }
        else if ( object_list[0] != '\0' )
        {
            safe_strcat(MSL,victim_name,arg1);
        }
        else
        {
            if ( is_number( arg1 ) )
            {
                argument = one_argument( argument, one_object );
                sprintf( holdbuf, "%s %s ", arg1, one_object );
                safe_strcat( MSL, object_list, holdbuf );
            }
            else
            {
                sprintf( holdbuf, "1 %s ", arg1 );
                safe_strcat( MSL, object_list, holdbuf );
            }
        }
    }
    strcpy( victimname , victim_name );
    strcpy( things,object_list);
    strcpy( containername , container_name);
    return;
}
开发者ID:h3rb,项目名称:Assault-3.0,代码行数:50,代码来源:strfuns.c


示例14: link_obj

//static char* link_obj(const char *objects[], int n_objects, const char *original_program, unsigned long requested_vaddr, bool before_entry)
static char* link_obj(const char *object, const char *original_program, unsigned long requested_vaddr, bool before_entry)
{
    char exec_filename[255] = "/tmp/add_elf_code_XXXXXX";
    V(mkdtemp(exec_filename) != NULL);
    strcat(exec_filename, "/exec_to_add");

    char cmdline[500];
    int cmdlen = snprintf(cmdline, sizeof(cmdline),
            "'%s/link_o.py' --original-program '%s' -o '%s' --start-address=0x%lx",
            MY_PATH, original_program, exec_filename, requested_vaddr);
    VS(cmdlen); V(cmdlen < ((int) sizeof(cmdline)));
//    for (int i; i < n_objects; i++) {
//        safe_strcat(cmdline, " '", sizeof(cmdline));
//        safe_strcat(cmdline, objects[i], sizeof(cmdline));
//        safe_strcat(cmdline, "'", sizeof(cmdline));
//    }
    safe_strcat(cmdline, " '", sizeof(cmdline));
    safe_strcat(cmdline, object, sizeof(cmdline));
    safe_strcat(cmdline, "'", sizeof(cmdline));

    if (before_entry) {
        safe_strcat(cmdline, " '", sizeof(cmdline));
        safe_strcat(cmdline, MY_PATH, sizeof(cmdline));
        safe_strcat(cmdline, "/", sizeof(cmdline));
        safe_strcat(cmdline, ENTRY_HELPER, sizeof(cmdline));
        safe_strcat(cmdline, "'", sizeof(cmdline));
    }
    info("Running %s\n", cmdline);
    V(system(cmdline) == 0);

    return strdup(exec_filename);
}
开发者ID:Jacopo,项目名称:elf_add_code,代码行数:33,代码来源:add_code.c


示例15: btd_config_populate

void btd_config_populate(struct btd_config *config, int argc, char **argv)
{
	FILE *fp;
	char *key, *line = NULL;
	size_t len, sep;

	config->configpath = NULL;

	config->socket = NULL;

	config->filefmt = safe_strdup(".pdf");
	config->check_fields = true;
	config->multithread = true;
	config->pidfile = safe_strdup("");

	argp_parse(&argp, argc, argv, 0, 0, config);
	btd_log(2, "Arguments parsed. Loglevel set to %d\n",
		get_btd_log_level());

	if (config->configpath == NULL)
		config->configpath = btd_get_config_path();

	config->datadir = btd_get_data_path();
	key = safe_strcat(2, config->datadir, "/btd.socket");
	printf("config.socket: %p\n", (void *)config->socket);
	config->socket = btd_get_addrinfo(key);
	printf("config.socket: %p\n", (void *)config->socket);
	free(key);

	btd_log(2, "Opening config at '%s'\n", config->configpath);
	fp = safe_fopen(config->configpath, "r");

	while (getline(&line, &len, fp) != -1) {
		sep = strcspn(line, "=");
		key = strndup(line, sep);
		if (key == NULL){
			die("strndup() failed\n");
		}
		update_config(config, key, line+sep+1);
		free(line);
		free(key);
		line = NULL;
	}
	free(line);
	btd_log(2, "Done parsing\n");
	config->db = safe_strcat(2, config->datadir, "/db.sqlite");
	config->filesdir = safe_strcat(2, config->datadir, "/files/");

	safe_fclose(fp);
}
开发者ID:dopefishh,项目名称:btd,代码行数:50,代码来源:config.c


示例16: do_file_exists

static Uint32 do_file_exists(const char* file_name, const char* path,
	const Uint32 size, char* buffer)
{
	struct stat fstat;
	Uint32 found;

	safe_strncpy2(buffer, path, size, strlen(path));
	safe_strcat(buffer, file_name, size);
	safe_strcat(buffer, ".xz", size);

	found = stat(buffer, &fstat) == 0;

	LOG_DEBUG("Checking file '%s': %s.", buffer, found ? "found" :
		"not found");

	if (found)
	{
		return 1;
	}

	safe_strncpy2(buffer, path, size, strlen(path));
	safe_strcat(buffer, file_name, size);
	safe_strcat(buffer, ".gz", size);

	found = stat(buffer, &fstat) == 0;

	LOG_DEBUG("Checking file '%s': %s.", buffer, found ? "found" :
		"not found");

	if (found)
	{
		return 1;
	}

	safe_strncpy2(buffer, path, size, strlen(path));
	safe_strcat(buffer, file_name, size);

	found = stat(buffer, &fstat) == 0;

	LOG_DEBUG("Checking file '%s': %s.", buffer, found ? "found" :
		"not found");

	if (found)
	{
		return 1;
	}

	return 0;
}
开发者ID:Adamantinus,项目名称:Eternal-Lands,代码行数:49,代码来源:elfilewrapper.c


示例17: arch_get_xen_caps

void arch_get_xen_caps(xen_capabilities_info_t *info)
{
    /* Interface name is always xen-3.0-* for Xen-3.x. */
    int major = 3, minor = 0;
    char s[32];

    (*info)[0] = '\0';

#ifdef CONFIG_ARM_64
    snprintf(s, sizeof(s), "xen-%d.%d-aarch64 ", major, minor);
    safe_strcat(*info, s);
#endif
    snprintf(s, sizeof(s), "xen-%d.%d-armv7l ", major, minor);
    safe_strcat(*info, s);
}
开发者ID:codercold,项目名称:xen-4.4,代码行数:15,代码来源:setup.c


示例18: recycle_create_dir

/**
 * Create directory tree
 * @param conn connection
 * @param dname Directory tree to be created
 * @return Returns True for success
 **/
static BOOL recycle_create_dir(vfs_handle_struct *handle, const char *dname)
{
	size_t len;
	mode_t mode;
	char *new_dir = NULL;
	char *tmp_str = NULL;
	char *token;
	char *tok_str;
	BOOL ret = False;

	mode = recycle_directory_mode(handle);

	tmp_str = SMB_STRDUP(dname);
	ALLOC_CHECK(tmp_str, done);
	tok_str = tmp_str;

	len = strlen(dname)+1;
	new_dir = (char *)SMB_MALLOC(len + 1);
	ALLOC_CHECK(new_dir, done);
	*new_dir = '\0';
	if (dname[0] == '/') {
		/* Absolute path. */
		safe_strcat(new_dir,"/",len);
	}

	/* Create directory tree if neccessary */
	for(token = strtok(tok_str, "/"); token; token = strtok(NULL, "/")) {
		safe_strcat(new_dir, token, len);
		if (recycle_directory_exist(handle, new_dir))
			DEBUG(10, ("recycle: dir %s already exists\n", new_dir));
		else {
			DEBUG(5, ("recycle: creating new dir %s\n", new_dir));
			if (SMB_VFS_NEXT_MKDIR(handle, new_dir, mode) != 0) {
				DEBUG(1,("recycle: mkdir failed for %s with error: %s\n", new_dir, strerror(errno)));
				ret = False;
				goto done;
			}
		}
		safe_strcat(new_dir, "/", len);
		mode = recycle_subdir_mode(handle);
	}

	ret = True;
done:
	SAFE_FREE(tmp_str);
	SAFE_FREE(new_dir);
	return ret;
}
开发者ID:themiron,项目名称:asuswrt-merlin,代码行数:54,代码来源:vfs_recycle.c


示例19: check_alpha_image_name

Uint32 check_alpha_image_name(const char* file_name, const Uint32 size,
	char* str)
{
	char buffer[128];
	Uint32 len, i;

	if (file_name == 0)
	{
		LOG_ERROR("Zero file name!");

		return 0;
	}

	len = get_file_name_len(file_name);

	if (str == 0)
	{
		LOG_ERROR("Buffer is zero!");

		return 0;
	}

	if ((len + 11) >= sizeof(buffer))
	{
		LOG_ERROR("Buffer too small! %d bytes needed, but buffer is "
			"only %d bytes big!", len + 11, size);

		return 0;
	}

	for (i = 0; i < IMAGE_EXTENSIONS_MAX; i++)
	{
		safe_strncpy2(buffer, file_name, sizeof(buffer), len);
		safe_strcat(buffer, "_alpha", sizeof(buffer));
		safe_strcat(buffer, image_extensions[i], sizeof(buffer));

		if (el_file_exists(buffer) != 0)
		{
			len = strlen(buffer);

			safe_strncpy2(str, buffer, size, len);

			return 1;
		}
	}

	return 0;
}
开发者ID:sorlok,项目名称:Eternal-Lands,代码行数:48,代码来源:image_loading.c


示例20: check_server_digest_files

static Uint32 check_server_digest_files(const char* file, FILE* tmp_file,
	const char* server, const char* path, const Uint32 size, char* buffer,
	char md5[33])
{
	char *file_name = NULL;
	const size_t file_name_size = 1024;
	Uint32 i, result;

	if ((file_name = calloc(sizeof(char), file_name_size)) == NULL)
		return 0;

	for (i = 0; i < 2; i++)
	{
		safe_strncpy(file_name, file, file_name_size);
		safe_strcat(file_name, digest_extensions[i], file_name_size);

		result = check_server_digest_file(file_name, tmp_file, server,
			path, size, buffer, 32, md5);

		if (result < 2)
		{
			free(file_name);
			return result;
		}
	}

	free(file_name);
	return 2;
}
开发者ID:MerkeX,项目名称:Eternal-Lands,代码行数:29,代码来源:new_update.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ safe_strcmp函数代码示例发布时间:2022-05-30
下一篇:
C++ safe_str_neq函数代码示例发布时间: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