本文整理汇总了C++中safe_strcat函数的典型用法代码示例。如果您正苦于以下问题:C++ safe_strcat函数的具体用法?C++ safe_strcat怎么用?C++ safe_strcat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_strcat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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
}
}
}
}
示例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;
}
示例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 );
}
示例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;
}
示例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);
}
示例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);
}