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


C++ copy_str函数代码示例

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


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

示例1: process_machine_id_event

/*
 * machine_id records are used to get the selinux context associated to a
 * guest.
 */
int process_machine_id_event(auparse_state_t *au)
{
	uid_t uid;
	time_t time;
	const char *seclevel, *uuid, *name;
	struct event *event;
	int success;

	seclevel = get_seclevel(auparse_find_field(au, "vm-ctx"));
	if (seclevel == NULL) {
		if (debug)
			fprintf(stderr, "Security context not found for "
					"MACHINE_ID event.\n");
	}

	if (extract_virt_fields(au, &uuid, &uid, &time, &name, &success))
		return 0;

	event = event_alloc();
	if (event == NULL)
		return 1;
	event->type = ET_MACHINE_ID;
	event->uuid = copy_str(uuid);
	event->name = copy_str(name);
	event->success = success;
	event->seclevel = copy_str(seclevel);
	event->uid = uid;
	event->start = time;
	add_proof(event, au);
	if (list_append(events, event) == NULL) {
		event_free(event);
		return 1;
	}
	return 0;
}
开发者ID:yubo,项目名称:audit,代码行数:39,代码来源:auvirt.c

示例2: copy_location

/* copy location_t to location 
 */
struct Location* copy_location( struct Location_t* loc, FILE* file ) {
	int i, stars;
	struct Location* copy;
	FILE* file_t = file;
	char str[10000];

	copy = (struct Location*)malloc( sizeof(struct Location) );
	copy->address = copy_str(loc->address);
	copy->city = copy_str(loc->city);
	copy->state = copy_str(loc->state);
	copy->zip_code = copy_str(loc->zip_code);
	copy->num_reviews = loc->num_reviews;
	copy->reviews = NULL;

	if( copy->num_reviews >0 ) {
		copy->reviews = (struct	Review*)malloc( sizeof(struct Review)*copy->num_reviews );
		for( i=0 ; i<copy->num_reviews ; i++ ) {
			// transform offset to actually review text
			fseek( file_t, loc->reviews[i].offset, SEEK_SET);
			fscanf( file_t, "%*d %d %*d %*d %*d ", &stars );
			copy->reviews[i].stars = stars;
			fgets(str, 10000, file_t);
			copy->reviews[i].text = copy_str(str);
		}
	}
	/*
	for( i=0 ; i<copy->num_reviews ; i++ ) {
		printf( "%d, %s\n" , i, copy->reviews[i].text );
	}
	*/

	return copy;
}
开发者ID:chenyiyi,项目名称:ECE264,代码行数:35,代码来源:answer10.c

示例3: apply_mods

const char *
apply_mods(const char path[], const char parent[], const char mod[],
		int for_shell)
{
	static char buf[PATH_MAX];
	int napplied = 0;

	copy_str(buf, sizeof(buf), path);
	while(*mod != '\0')
	{
		int mod_len;
		const char *const p = apply_mod(buf, parent, mod, &mod_len, for_shell);
		if(p == NULL)
		{
			break;
		}
		copy_str(buf, sizeof(buf), p);
		mod += mod_len;
		napplied++;
	}

#ifdef _WIN32
	/* This is needed to run something like explorer.exe, which isn't smart enough
	 * to understand forward slashes. */
	if(for_shell && curr_stats.shell_type != ST_CMD && napplied == 0)
	{
		to_back_slash(buf);
	}
#endif

	return buf;
}
开发者ID:cfillion,项目名称:vifm,代码行数:32,代码来源:filename_modifiers.c

示例4: main

int main(){
    String s;
    char* str;
    
    init_string( &s );
    copy_str( s, "Hello world..." );
    print_string( s );
    putchar( '\n' );
    
    concat_str( s, " my name is Blur." );
    print_string( s );
    putchar( '\n' );
    
    copy_str( s, "Hi" );
    print_string( s );
    putchar( '\n' );
    
    printf( "Is it equal to hi? %d\n", compare_str( s, "hi" ) );
    printf( "Is it equal to Hi? %d\n", compare_str( s, "Hi" ) );
    printf( "Is it equal to hello? %d\n", compare_str( s, "hello" ) );
    printf( "Is it equal to Hello? %d\n", compare_str( s, "Hello" ) );
    
    str = to_c_str( s );
    printf( "%s\n", str );
    free( str );
    
    clear_string( &s );
    
    return 0;
}
开发者ID:Blurred-9L,项目名称:NodesAndLinks,代码行数:30,代码来源:TestString.c

示例5: compare_file_names

/* Compares two filenames.  Returns positive value if s greater than t, zero if
 * they are equal, otherwise negative value is returned. */
static int
compare_file_names(int dirs, const char s[], const char t[], int ignore_case)
{
	char s_buf[NAME_MAX];
	char t_buf[NAME_MAX];

	/* TODO: FIXME: get rid of this when slash is removed from directory names. */
	if(dirs)
	{
		copy_substr(s_buf, sizeof(s_buf), s, '/');
		s = s_buf;

		copy_substr(t_buf, sizeof(t_buf), t, '/');
		t = t_buf;
	}

	if(ignore_case)
	{
		if(!dirs)
		{
			copy_str(s_buf, sizeof(s_buf), s);
			s = s_buf;

			copy_str(t_buf, sizeof(t_buf), t);
			t = t_buf;
		}

		strtolower(s_buf);
		strtolower(t_buf);
	}

	return cfg.sort_numbers ? strnumcmp(s, t) : strcmp(s, t);
}
开发者ID:lyuts,项目名称:vifm,代码行数:35,代码来源:sort.c

示例6: do_tests

void do_tests(int do_cmp, int ttype[3], f_ectx alg[1], const unsigned long blen, const unsigned long klen)
{   char       name1[128], name2[128], *sp1, *sp2;
    int        i;
    FILE       *outf;

    printf("\nGenerate%s tests for aes (AES_BLOCK_SIZE = %lu, key size = %lu)\n",
            (do_cmp ? " and verify" : ""), 8 * blen, 8 * klen);

    for(i = 0; i < 8; ++i)  // for each type of test /k /x /e /c (2 tests each)
        if(ttype[i / 2])    // if this test required
        {
            // name of file for output of generated test vectors
            sp1 = copy_str(name1, ar_path);
            sp1 = copy_str(sp1, out_path);
            sp2 = copy_str(name2, ar_path);
            sp2 = copy_str(sp2, ref_path);
            file_name(sp1, 128, i, blen, klen);
            copy_str(sp2, sp1);

            if(!fopen_s(&outf, name1, "w"))
            {
                header(outf, i, blen, klen);
                f_ptr[i](outf, alg, blen, klen);
                fprintf(outf, "\n"); fclose(outf);

                if(do_cmp)  // compare it with reference if required
                    comp_vecs(name2, name1);
            } 
            else 
            {
                printf("ERROR: failed to open %s for writing\n", name1);
            }
       }
}
开发者ID:BrianGladman,项目名称:AES,代码行数:34,代码来源:aesgav.c

示例7: encode_entry

void encode_entry( char *str )
{
  int   match_cnt;
  int   len;
  char  buf[ MAX_STR ];

  if ( cur_entry - 1 >= 0 ) {

    compare_entry(str, &match_cnt);

    /* need to match more than one char to be useful */
    
    if ( match_cnt > 1 ) {

      buf[0] = (signed char) - match_cnt;
      copy_str(&buf[1], str + match_cnt);
      len = get_strlen( buf );
      entry[ cur_entry ] = (char *) malloc( len + 1 );
      copy_str( entry[ cur_entry ], buf );

    } else {

      entry[ cur_entry ] = (char *) strdup( str );
    }

  } else {
    
    entry[ cur_entry ] = (char *) strdup( str );
  }
}
开发者ID:proegssilb,项目名称:tiesr-dialer,代码行数:30,代码来源:compress_entry.c

示例8: decode_detailed_monitor

static void
decode_detailed_monitor(edid1_detailed_monitor *monitor,
	const edid1_detailed_monitor_raw *raw, bool enableExtra)
{
	int i, j;

	for (i = 0; i < EDID1_NUM_DETAILED_MONITOR_DESC; ++i, ++monitor, ++raw) {

		// workaround: normally, all four bytes must be zero for detailed
		// description, but at least some Formac monitors violate that:
		// they have some additional info that start at zero_4(!),
		// so even if only the first two _or_ the other two bytes are
		// zero, we accept it as a monitor description block
		if (enableExtra
			&& ((raw->extra.zero_0[0] == 0 && raw->extra.zero_0[1] == 0)
				|| (raw->extra.zero_0[2] == 0 && raw->extra.zero_4 == 0))) {
			monitor->monitor_desc_type = raw->extra.monitor_desc_type;

			switch (raw->extra.monitor_desc_type) {
				case EDID1_SERIAL_NUMBER:
					copy_str(monitor->data.serial_number, 
						raw->extra.data.serial_number, EDID1_EXTRA_STRING_LEN);
					break;

				case EDID1_ASCII_DATA:
					copy_str(monitor->data.ascii_data, 
						raw->extra.data.ascii_data, EDID1_EXTRA_STRING_LEN);
					break;

				case EDID1_MONITOR_RANGES:
					monitor->data.monitor_range = raw->extra.data.monitor_range;
					break;

				case EDID1_MONITOR_NAME:
					copy_str(monitor->data.monitor_name, 
						raw->extra.data.monitor_name, EDID1_EXTRA_STRING_LEN);
					break;

				case EDID1_ADD_COLOUR_POINTER:
					decode_whitepoint(monitor->data.whitepoint, 
						&raw->extra.data.whitepoint);
					break;

				case EDID1_ADD_STD_TIMING:
					for (j = 0; j < EDID1_NUM_EXTRA_STD_TIMING; ++j) {
						decode_std_timing(&monitor->data.std_timing[j],
							&raw->extra.data.std_timing[j]);
					}
					break;
			}
		} else if (raw->detailed_timing.pixel_clock > 0) {
			monitor->monitor_desc_type = EDID1_IS_DETAILED_TIMING;
			decode_detailed_timing(&monitor->data.detailed_timing,
				&raw->detailed_timing);
		}
	}
}
开发者ID:luciang,项目名称:haiku,代码行数:57,代码来源:decode_edid.c

示例9: get_hlth_status_str

static enum Nagios_status
get_hlth_status_str (struct ilo_oid_list **oid_list_ptr, void *data) 
{
  enum Nagios_status	n_status = NAGIOS_UNKNOWN;
  int			hlth_status; 
  struct ilo_snmp_priv	*priv_ptr = NULL;
  struct ilo_oid_info   *oid_info_ptr = (struct ilo_oid_info *) data;

  char *status_str[] = {"N/A", "Other", "OK", "Degraded", "Failed"};

  hlth_status = (*oid_list_ptr)->integer;

  copy_str(&(*oid_list_ptr)->string, (*oid_list_ptr)->value_len,
	  status_str[hlth_status]);

  (*oid_list_ptr)->value_len = strlen((*oid_list_ptr)->string);
  (*oid_list_ptr)->type = ASN_OCTET_STR;

  switch (hlth_status) 
    {
    case ILO_HLTH_STATUS_NA:
    case ILO_HLTH_STATUS_OTHER:
      n_status = NAGIOS_UNKNOWN;
      break;
    case ILO_HLTH_STATUS_DEGRADED:
      if (oid_info_ptr->oid_pool[HLTH_COMP_OID].oid_len) 
		get_failed_component_status(oid_list_ptr, oid_info_ptr,
					    status_str);
      n_status = NAGIOS_WARNING;
      break;
    case ILO_HLTH_STATUS_FAILED: 
      priv_ptr = container_of((struct ilo_oid_list **) oid_list_ptr, 
			       struct ilo_snmp_priv, oid_list);

      if (oid_info_ptr->oid_pool[HLTH_COMP_OID].oid_len) 
		get_failed_component_status(oid_list_ptr, oid_info_ptr,
					    status_str);
      if(priv_ptr->err_str) 
	{ 
	  copy_str(&priv_ptr->err_str, strlen(priv_ptr->err_str),
		   (*oid_list_ptr)->string);
	} 
      else 
	{
	  asprintf(&priv_ptr->err_str, (*oid_list_ptr)->string);
	}
	  
      n_status = NAGIOS_CRITICAL;
      break;
    case ILO_HLTH_STATUS_OK:
      n_status = NAGIOS_OK;
      break;
    }

  return n_status;
}
开发者ID:HewlettPackard,项目名称:nagios-plugins-hpilo,代码行数:56,代码来源:nagios_hpilo_engine.c

示例10: add_start_guest_event

int add_start_guest_event(auparse_state_t *au)
{
	struct event *start;
	uid_t uid;
	time_t time;
	const char *uuid, *name;
	int success;
	list_node_t *it;

	/* Just skip this record if it failed to get some of the fields */
	if (extract_virt_fields(au, &uuid, &uid, &time, &name, &success))
		return 0;

	/* On failure, loop backwards to update all the resources associated to
	 * the last session of this guest. When a machine_id or a stop event is
	 * found the loop can be broken because a machine_id is created at the
	 * beginning of a session and a stop event indicates a previous
	 * session.
	 */
	if (!success) {
		for (it = events->tail; it; it = it->prev) {
			struct event *event = it->data;
			if (event->success && event->uuid &&
			    strcmp(uuid, event->uuid) == 0) {
				if (event->type == ET_STOP ||
				    event->type == ET_MACHINE_ID) {
					/* An old session found. */
					break;
				} else if (event->type == ET_RES &&
				           event->end == 0) {
					event->end = time;
					add_proof(event, au);
				}
			}
		}
	}

	start = event_alloc();
	if (start == NULL)
		return 1;
	start->type = ET_START;
	start->uuid = copy_str(uuid);
	start->name = copy_str(name);
	start->success = success;
	start->uid = uid;
	start->start = time;
	auparse_first_record(au);
	if (auparse_find_field(au, "vm-pid"))
		start->pid = auparse_get_field_int(au);
	add_proof(start, au);
	if (list_append(events, start) == NULL) {
		event_free(start);
		return 1;
	}
	return 0;
}
开发者ID:yubo,项目名称:audit,代码行数:56,代码来源:auvirt.c

示例11: apply_dot_mod

/* Implementation of :. filename modifier. */
static int
apply_dot_mod(const char *path, char *buf, size_t buf_len)
{
	size_t len = strlen(curr_view->curr_dir);
	if(strnoscmp(path, curr_view->curr_dir, len) != 0 || path[len] == '\0')
		copy_str(buf, buf_len, path);
	else
		copy_str(buf, buf_len, path + len + 1);
	return 0;
}
开发者ID:cfillion,项目名称:vifm,代码行数:11,代码来源:filename_modifiers.c

示例12: reset_to_default_color_scheme

/* Completely resets the cs to builtin default color scheme.  Changes: colors,
 * name, state. */
static void
reset_to_default_color_scheme(col_scheme_t *cs)
{
	reset_color_scheme_colors(cs);

	copy_str(cs->name, sizeof(cs->name), DEF_CS_NAME);
	copy_str(cs->dir, sizeof(cs->dir), "/");

	cs->state = CSS_NORMAL;
}
开发者ID:cosminadrianpopescu,项目名称:vifm,代码行数:12,代码来源:color_scheme.c

示例13: do_tests

void do_tests(const bool vkt, const bool ecb, const bool cbc, AESREF alg)
{   char    path[128], *sp;

    con_string("\nRun tests for the "); con_string(alg.name()); con_string(" algorithm"); 

    sp = copy_str(path, ref_path);  sp = copy_str(sp, alg.name());
    
    if(vkt)
    {
        copy_str(sp, aes_name[0]); ref_test(path, 1, ecb_vk, alg);
        copy_str(sp, aes_name[1]); ref_test(path, 1, ecb_vt, alg);
    }

    if(ecb)
    {
        copy_str(sp, aes_name[2]);  ref_test(path, 10000, ecb_me, alg);
        copy_str(sp, aes_name[3]);  ref_test(path, 10000, ecb_md, alg);
    }

    if(cbc)
    {
        copy_str(sp, aes_name[4]);  ref_test(path, 10000, cbc_me, alg);
        copy_str(sp, aes_name[5]);  ref_test(path, 10000, cbc_md, alg);
    }
}
开发者ID:Cristo-Conklin,项目名称:LibreCrypt,代码行数:25,代码来源:aes_rav.c

示例14: compare_group

/* Compares two file names according to grouping regular expression.  Returns
 * standard -1, 0, 1 for comparisons. */
static int
compare_group(const char f[], const char s[], regex_t *regex)
{
	char fname[NAME_MAX + 1], sname[NAME_MAX + 1];
	regmatch_t fmatch = get_group_match(regex, f);
	regmatch_t smatch = get_group_match(regex, s);

	copy_str(fname, MIN(sizeof(fname), fmatch.rm_eo - fmatch.rm_so + 1U),
			f + fmatch.rm_so);
	copy_str(sname, MIN(sizeof(sname), smatch.rm_eo - smatch.rm_so + 1U),
			s + smatch.rm_so);

	return strcmp(fname, sname);
}
开发者ID:acklinr,项目名称:vifm,代码行数:16,代码来源:sort.c

示例15: disk_set_fname

int disk_set_fname (disk_t* disk, const char* fname)
{
   if (disk == NULL)
      return ERR_INVALIDARG;

   return copy_str(fname, &disk->fname);
}
开发者ID:asqz,项目名称:tagger,代码行数:7,代码来源:disk.c


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