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


C++ BU_STR_EQUAL函数代码示例

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


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

示例1: state_file

void
state_file(const char *buffer, com_table *ctp, struct rt_i *UNUSED(rtip))
{
    int i = 0;      /* current position on the *buffer */
    static char *new_name;

    while (isspace((int)*(buffer+i)))
	++i;

    if (*(buffer+i) == '\0') {
	/* display current state name */
	printf("statefile = '%s'\n", sf_name);
	return;
    }

    if (BU_STR_EQUAL(buffer + i, "?")) {
	com_usage(ctp);
	return;
    }

    if (BU_STR_EQUAL(buffer + i, "default")) {
	new_name = def_sf_name;
    } else {
	new_name = bu_malloc(strlen(buffer + i)+1, "new_state_filename");
	snprintf(new_name, strlen(buffer+i), "%s", buffer + i);
    }

    /* Clean up from previous output destination */
    if (sf_name != def_sf_name)
	bu_free(sf_name, "new(now old)statefile");

    /* Establish the new destination */
    sf_name = new_name;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:34,代码来源:parse_fmt.c

示例2: do_silly_nastran_shortcuts

HIDDEN void
do_silly_nastran_shortcuts(void)
{
    int field_no;

    for (field_no=0; field_no < NO_OF_FIELDS; field_no++) {
	if (BU_STR_EQUAL(curr_rec[field_no], "=")) {
	    bu_strlcpy(curr_rec[field_no], prev_rec[field_no], FIELD_LENGTH);
	} else if (BU_STR_EQUAL(curr_rec[field_no], "==")) {
	    while (field_no < NO_OF_FIELDS) {
		bu_strlcpy(curr_rec[field_no], prev_rec[field_no], FIELD_LENGTH);
		field_no++;
	    }
	} else if (curr_rec[field_no][0] == '*') {
	    int i=0;

	    while (curr_rec[field_no][++i] == '(');

	    if (strchr(prev_rec[field_no], '.')) {
		fastf_t a, b;

		a = atof(prev_rec[field_no]);
		b = atof(&curr_rec[field_no][i]);
		sprintf(curr_rec[field_no], "%-#*E", FIELD_LENGTH-6, a+b);
	    } else {
		int a, b;

		a = atoi(prev_rec[field_no]);
		b = atoi(&curr_rec[field_no][i]);
		sprintf(curr_rec[field_no], "%d", a+b);
	    }
	}
    }
}
开发者ID:kanzure,项目名称:brlcad,代码行数:34,代码来源:nastran-g.c

示例3: nirt_units

void
nirt_units(char *buffer, com_table *ctp, struct rt_i *rtip)
{
    double tmp_dbl;
    int i = 0;      /* current position on the *buffer */

    double mk_cvt_factor();

    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) == '\0') {
	/* display current destination */
	fprintf(stdout, "units = '%s'\n", local_u_name);
	return;
    }

    if (BU_STR_EQUAL(buffer + i, "?")) {
	com_usage(ctp);
	return;
    } else if (BU_STR_EQUAL(buffer + i, "default")) {
	base2local = rtip->rti_dbip->dbi_base2local;
	local2base = rtip->rti_dbip->dbi_local2base;
	bu_strlcpy(local_u_name, bu_units_string(base2local), sizeof(local_u_name));
    } else {
	tmp_dbl = bu_units_conversion(buffer + i);
	if (tmp_dbl <= 0.0) {
	    bu_log("Invalid unit specification: '%s'\n", buffer + i);
	    return;
	}
	bu_strlcpy(local_u_name, buffer + i, sizeof(local_u_name));
	local2base = tmp_dbl;
	base2local = 1.0 / tmp_dbl;
    }
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:34,代码来源:command.c

示例4: bu_file_delete

int
bu_file_delete(const char *path)
{
    int fd = 0;
    int ret = 0;
    int retry = 0;
    struct stat sb;

    /* reject empty, special, or non-existent paths */
    if (!path
	|| BU_STR_EQUAL(path, "")
	|| BU_STR_EQUAL(path, ".")
	|| BU_STR_EQUAL(path, "..")
	|| !bu_file_exists(path, &fd))
    {
	return 0;
    }

    do {

	if (retry++) {
	    /* second pass, try to force deletion by changing file
	     * permissions (similar to rm -f).
	     */
	    if (fstat(fd, &sb) == -1) {
		break;
	    }
	    bu_fchmod(fd, (sb.st_mode|S_IRWXU));
	}

	ret = (remove(path) == 0) ? 0 : 1;

    } while (ret == 0 && retry < 2);
    close(fd);

    /* all boils down to whether the file still exists, not whether
     * remove thinks it succeeded.
     */
    if (bu_file_exists(path, &fd)) {
	/* failure */
	if (retry > 1) {
	    /* restore original file permission */
	    bu_fchmod(fd, sb.st_mode);
	}
	close(fd);
	return 0;
    } else {
	/* deleted */
	return 1;
    }
}
开发者ID:kanzure,项目名称:brlcad,代码行数:51,代码来源:file.c

示例5: main

/*
 *	Get ascii input file and output file names.
 */
int
main(int argc, char **argv)
{
    char		*afile = "-", *bfile = "nmg.g";
    FILE		*fpin;
    struct rt_wdb	*fpout;

    if ( BU_STR_EQUAL(argv[1],"-h") || BU_STR_EQUAL(argv[1],"-?")) {
	usage();
	bu_exit(1, NULL);
    }

    if (isatty(fileno(stdin)) && isatty(fileno(stdout)) && argc == 1) {
	usage();
	bu_log("       Program continues running:\n");
    }

    bu_setprogname(argv[0]);

    /* Get ascii NMG input file name. */
    if (bu_optind >= argc || (int)(*argv[1]) == '-') {
	fpin = stdin;
	setmode(fileno(fpin), O_BINARY);
	bu_log("%s: will be reading from stdin\n",argv[0]);
    } else {
	afile = argv[bu_optind];
	if ((fpin = fopen(afile, "rb")) == NULL) {
	    fprintf(stderr,
		    "%s: cannot open %s for reading\n",
		    argv[0], afile);
	    bu_exit(1, NULL);
	}
    bu_log("%s: will be reading from file %s\n",argv[0],afile);
    }

    /* Get BRL-CAD output data base name. */
    bu_optind++;
    if (bu_optind < argc)
	bfile = argv[bu_optind];
    if ((fpout = wdb_fopen(bfile)) == NULL) {
	fprintf(stderr, "%s: cannot open %s for writing\n",
		argv[0], bfile);
	bu_exit(1, NULL);
    }
    bu_log("%s: will be creating file %s\n",argv[0],bfile);

    ascii_to_brlcad(fpin, fpout, "nmg", NULL);
    fclose(fpin);
    wdb_close(fpout);
    return 0;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:54,代码来源:asc-nmg.c

示例6: GetArgs

static int
GetArgs(int argc, const char *argv[])			/* process command arguments */
    /* argument count */
    /* argument strings */
{
    static int iflag = 0;	/* set if "-i" option found */
    static int oflag = 0;	/* set if "-o" option found */
    int c;		/* option letter */

    bu_optind = 1;
    while ((c = bu_getopt(argc, (char * const *)argv, "i:o:h?")) != -1)
	switch (c) {
	    case 'i':
		if (iflag) {
		    printf("cad_parea: too many -i options\n");
		    return 0;
		}
		iflag = 1;

		if (!BU_STR_EQUAL(bu_optarg, "-")
		    && freopen(bu_optarg, "r", stdin) == NULL
		    ) {
		    printf("cad_parea: can't open \"%s\" for reading\n", bu_optarg);
		    return 0;
		}
		break;

	    case 'o':
		if (oflag) {
		    printf("cad_parea: too many -o options\n");
		    return 0;
		}
		oflag = 1;

		if (!BU_STR_EQUAL(bu_optarg, "-")
		    && freopen(bu_optarg, "w", stdout) == NULL
		    ) {
		    printf("cad_parea: can't open \"%s\" for writing\n", bu_optarg);
		    return 0;
		}
		break;

	    default:
		Usage();	/* print usage message */
		return 0;
	}

    return 1;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:49,代码来源:cad_parea.c

示例7: main

int
main(int argc, char **argv)
{
    fb *fbp;
    FILE *fp;
    int fbsize = 512;
    int i;

    while (argc > 1) {
	if (BU_STR_EQUAL(argv[1], "-H")) {
	    fbsize = 1024;
	} else if (argv[1][0] == '-') {
	    if ( (!BU_STR_EQUAL(argv[1], "-?")) && (!BU_STR_EQUAL(argv[1], "-h")) )
		fprintf(stderr, "fb-cmap: unknown flag %s\n", argv[1]);
	    bu_exit(1, "%s", usage);
	} else
	    break;	/* must be a filename */
	argc--;
	argv++;
    }

    if (argc > 1) {
	if ((fp = fopen(argv[1], "wb")) == NULL) {
	    fprintf(stderr, "fb-cmap: can't open \"%s\"\n", argv[1]);
	    bu_exit(2, "%s", usage);
	}
    } else {
	fp = stdout;
	if (isatty(fileno(fp)))
	    fprintf(stderr, "%s       Program continues running:\n", usage);
    }

    if ((fbp = fb_open(NULL, fbsize, fbsize)) == FB_NULL)
	bu_exit(2, "Unable to open framebuffer\n");

    i = fb_rmap(fbp, &cm);
    fb_close(fbp);
    if (i < 0) {
	bu_exit(3, "fb-cmap: can't read colormap\n");
    }

    for (i = 0; i <= 255; i++) {
	fprintf(fp, "%d\t%04x %04x %04x\n", i,
		cm.cm_red[i], cm.cm_green[i], cm.cm_blue[i]);
    }

    return 0;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:48,代码来源:fb-cmap.c

示例8: automatic_test

/* Test against basename UNIX tool */
void
automatic_test(const char *input)
{

    char buf_input[1000];
    char *ans = NULL;
    char *res = (char *)bu_calloc(strlen(buf_input), sizeof(char), "automatic_test res");

#ifdef HAVE_BASENAME
    if (input)
	bu_strlcpy(buf_input, input, strlen(input)+1);

    /* build UNIX 'basename' command */
    if (!input)
	ans = basename(NULL);
    else
	ans = basename(buf_input);

    if (!input)
	bu_basename(res, NULL);
    else
	bu_basename(res, buf_input);

    if (BU_STR_EQUAL(res, ans))
	printf("%24s -> %24s [PASSED]\n", input, res);
    else
	bu_exit(EXIT_FAILURE, "%24s -> %24s (should be: %s) [FAIL]\n", input, res, ans);
    bu_free(res, NULL);

#else
    printf("BASENAME not available on this platform\n");
#endif
    /* FIXME: this does not functionally halt */
}
开发者ID:kanzure,项目名称:brlcad,代码行数:35,代码来源:bu_basename.c

示例9: db_lookup

struct directory *
db_lookup(const struct db_i *dbip, const char *name, int noisy)
{
    struct directory *dp;
    char n0;
    char n1;

    if (!name || name[0] == '\0') {
	if (noisy || RT_G_DEBUG&DEBUG_DB)
	    bu_log("db_lookup received NULL or empty name\n");
	return RT_DIR_NULL;
    }

    n0 = name[0];
    n1 = name[1];

    RT_CK_DBI(dbip);

    dp = dbip->dbi_Head[db_dirhash(name)];
    for (; dp != RT_DIR_NULL; dp=dp->d_forw) {
	char *this_obj;

	/* first two checks are for speed */
	if ((n0 == *(this_obj=dp->d_namep)) && (n1 == this_obj[1]) && (BU_STR_EQUAL(name, this_obj))) {
	    if (RT_G_DEBUG&DEBUG_DB)
		bu_log("db_lookup(%s) %p\n", name, (void *)dp);
	    return dp;
	}
    }

    if (noisy || RT_G_DEBUG&DEBUG_DB)
	bu_log("db_lookup(%s) failed: %s does not exist\n", name, name);

    return RT_DIR_NULL;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:35,代码来源:db_lookup.c

示例10: compare_tcl_combs

int
compare_tcl_combs(Tcl_Obj *obj1, struct directory *dp1, Tcl_Obj *obj2)
{
    int junk;
    struct bu_vls adjust = BU_VLS_INIT_ZERO;
    int different = 0;

    /* first check if there is any difference */
    if (BU_STR_EQUAL(Tcl_GetStringFromObj(obj1, &junk), Tcl_GetStringFromObj(obj2, &junk)))
	return 0;

    if (mode != HUMAN) {
	bu_vls_printf(&adjust, "db adjust %s", dp1->d_namep);
    }

    different = do_compare(PARAMS, &adjust, obj1, obj2, dp1->d_namep);

    if (mode != HUMAN) {
	printf("%s\n", bu_vls_addr(&adjust));
    }

    bu_vls_free(&adjust);

    return different;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:25,代码来源:gdiff.c

示例11: open_file

void
open_file(FILE **fp, char *name)
{
    /* check for special names */
    if (BU_STR_EQUAL(name, "-")) {
	*fp = stdin;
	return;
    } else if (BU_STR_EQUAL(name, ".")) {
	*fp = fopen("/dev/null", "r");
	return;
    }

    if ((*fp = fopen(name, "r")) == NULL) {
	bu_exit(2, "d2-c: Can't open \"%s\"\n", name);
    }
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:16,代码来源:d2-c.c

示例12: cho_open

HIDDEN struct bu_cmdhist_obj *
cho_open(ClientData UNUSED(clientData), Tcl_Interp *interp, const char *name)
{
    struct bu_cmdhist_obj *chop;

    /* check to see if command history object exists */
    for (BU_LIST_FOR(chop, bu_cmdhist_obj, &HeadCmdHistObj.l)) {
	if (BU_STR_EQUAL(name, bu_vls_addr(&chop->cho_name))) {
	    Tcl_AppendResult(interp, "ch_open: ", name,
			     " exists.\n", (char *)NULL);
	    return BU_CMDHIST_OBJ_NULL;
	}
    }

    BU_GET(chop, struct bu_cmdhist_obj);
    bu_vls_init(&chop->cho_name);
    bu_vls_strcpy(&chop->cho_name, name);
    BU_LIST_INIT(&chop->cho_head.l);
    bu_vls_init(&chop->cho_head.h_command);
    chop->cho_head.h_start.tv_sec = chop->cho_head.h_start.tv_usec =
	chop->cho_head.h_finish.tv_sec = chop->cho_head.h_finish.tv_usec = 0L;
    chop->cho_head.h_status = TCL_OK;
    chop->cho_curr = &chop->cho_head;

    BU_LIST_APPEND(&HeadCmdHistObj.l, &chop->l);
    return chop;
}
开发者ID:cogitokat,项目名称:brlcad,代码行数:27,代码来源:cmdhist_obj.c

示例13: select_non_lights

/* return 0 when IS a light or an error occurred. regions are skipped
 * when this function returns 0.
 */
static int
select_non_lights(struct db_tree_state *UNUSED(tsp), const struct db_full_path *pathp, const struct rt_comb_internal *UNUSED(combp), void *UNUSED(client_data))
{
    struct directory *dp;
    struct rt_db_internal intern;
    struct rt_comb_internal *comb;
    int id;

    RT_CK_FULL_PATH(pathp);
    dp = DB_FULL_PATH_CUR_DIR(pathp);

    id = rt_db_get_internal(&intern, dp, dbip, (matp_t)NULL, &rt_uniresource);
    if (id < 0) {
	/* error occurred retrieving object */
	bu_log("Warning: Can not load internal form of %s\n", dp->d_namep);
	return 0;
    }

    if ((dp->d_flags & RT_DIR_COMB) && (id == ID_COMBINATION)) {
	comb = (struct rt_comb_internal *)intern.idb_ptr;
	RT_CK_COMB(comb);
	if (BU_STR_EQUAL(bu_vls_addr(&comb->shader), "light")) {
	    rt_db_free_internal(&intern);
	    return 0;
	}
    }

    return 1;
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:32,代码来源:vrml_write.c

示例14: find_ref

HIDDEN void
find_ref(struct db_i *dbip,
	 struct rt_comb_internal *comb,
	 union tree *comb_leaf,
	 void *object,
	 void *comb_name_ptr,
	 void *user_ptr3,
	 void *UNUSED(user_ptr4))
{
    char *obj_name;
    char *comb_name;
    struct ged *gedp = (struct ged *)user_ptr3;

    if (dbip) RT_CK_DBI(dbip);
    if (comb) RT_CK_COMB(comb);
    RT_CK_TREE(comb_leaf);

    obj_name = (char *)object;
    if (!BU_STR_EQUAL(comb_leaf->tr_l.tl_name, obj_name))
	return;

    comb_name = (char *)comb_name_ptr;

    bu_vls_printf(gedp->ged_result_str, "%s ", comb_name);
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:25,代码来源:find.c

示例15: rt_arbn_get

/**
 * Routine to format the parameters of an ARBN primitive for "db get"
 *
 * Legal requested parameters include:
 *	"N" - number of equations
 *	"P" - list of all the planes
 *	"P#" - the specified plane number (0 based)
 *	no arguments returns everything
 */
int
rt_arbn_get(struct bu_vls *logstr, const struct rt_db_internal *intern, const char *attr)
{
    struct rt_arbn_internal *arbn=(struct rt_arbn_internal *)intern->idb_ptr;
    size_t i;
    long val;

    RT_ARBN_CK_MAGIC(arbn);

    if (attr == (char *)NULL) {
	bu_vls_strcpy(logstr, "arbn");
	bu_vls_printf(logstr, " N %zu", arbn->neqn);
	for (i = 0; i < arbn->neqn; i++) {
	    bu_vls_printf(logstr, " P%zu {%.25g %.25g %.25g %.25g}", i,
			  V4ARGS(arbn->eqn[i]));
	}
    } else if (BU_STR_EQUAL(attr, "N")) {
	bu_vls_printf(logstr, "%zu", arbn->neqn);
    } else if (BU_STR_EQUAL(attr, "P")) {
	for (i = 0; i < arbn->neqn; i++) {
	    bu_vls_printf(logstr, " P%zu {%.25g %.25g %.25g %.25g}", i,
			  V4ARGS(arbn->eqn[i]));
	}
    } else if (attr[0] == 'P') {
	if (isdigit((int)attr[1]) == 0) {
	    bu_vls_printf(logstr, "ERROR: Illegal plane number\n");
	    return BRLCAD_ERROR;
	}

	val = atol(&attr[1]);
	if (val < 0 || (size_t)val >= arbn->neqn) {
	    bu_vls_printf(logstr, "ERROR: Illegal plane number [%ld]\n", val);
	    return BRLCAD_ERROR;
	}
	i = (size_t)val;

	bu_vls_printf(logstr, "%.25g %.25g %.25g %.25g", V4ARGS(arbn->eqn[i]));
    } else {
	bu_vls_printf(logstr, "ERROR: Unknown attribute, choices are N, P, or P#\n");
	return BRLCAD_ERROR;
    }

    return BRLCAD_OK;
}
开发者ID:kanzure,项目名称:brlcad,代码行数:53,代码来源:arbn.c


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