예제 #1
0
/* output an import library for a Win32 module and additional object files */
void output_import_lib( DLLSPEC *spec, char **argv )
{
    struct strarray *args = strarray_init();
    char *def_file;

    if (target_platform != PLATFORM_WINDOWS)
        fatal_error( "Unix-style import libraries not supported yet\n" );

    def_file = get_temp_file_name( output_file_name, ".def" );
    fclose( output_file );
    if (!(output_file = fopen( def_file, "w" )))
        fatal_error( "Unable to create output file '%s'\n", def_file );
    output_def_file( spec, 0 );
    fclose( output_file );
    output_file = NULL;

    strarray_add( args, find_tool( "dlltool", NULL ), "-k", "-l", output_file_name, "-d", def_file, NULL );
    spawn( args );
    strarray_free( args );

    if (argv[0])
    {
        args = strarray_init();
        strarray_add( args, find_tool( "ar", NULL ), "rs", output_file_name, NULL );
        strarray_addv( args, argv );
        spawn( args );
        strarray_free( args );
    }
    output_file_name = NULL;
}
예제 #2
0
파일: model_main.c 프로젝트: bert/fpgatools
int fpga_build_model(struct fpga_model* model, int fpga_rows,
	const char* columns, const char* left_wiring, const char* right_wiring)
{
	int rc;

	memset(model, 0, sizeof(*model));
	model->cfg_rows = fpga_rows;
	strncpy(model->cfg_columns, columns, sizeof(model->cfg_columns)-1);
	strncpy(model->cfg_left_wiring, left_wiring,
		sizeof(model->cfg_left_wiring)-1);
	strncpy(model->cfg_right_wiring, right_wiring,
		sizeof(model->cfg_right_wiring)-1);
	strarray_init(&model->str, STRIDX_64K);
	rc = get_xc6_routing_bitpos(&model->sw_bitpos, &model->num_bitpos);
	if (rc) FAIL(rc);

	// The order of tiles, then devices, then ports, then
	// connections and finally switches is important so
	// that the codes can build upon each other.

	rc = init_tiles(model);
	if (rc) FAIL(rc);

	rc = init_devices(model);
	if (rc) FAIL(rc);

	if (s_high_speed_replicate) {
		rc = replicate_routing_switches(model);
		if (rc) FAIL(rc);
	}

	// todo: compare.ports only works if other switches and conns
	//       are disabled, as long as not all connections are supported
	rc = init_ports(model, /*dup_warn*/ !s_high_speed_replicate);
	if (rc) FAIL(rc);

	rc = init_conns(model);
	if (rc) FAIL(rc);

	rc = init_switches(model, /*routing_sw*/ !s_high_speed_replicate);
	if (rc) FAIL(rc);
	return 0;
fail:
	return rc;
}
예제 #3
0
/*
 * Set the current user to 'identifier'.  'cacheid', if non-null,
 * points to a 16-byte binary key to cache identifier's information
 * with.
 */
static struct auth_state *mynewstate(const char *identifier)
{
    struct auth_state *newstate;
    struct passwd *pwd;
    struct group *grp;
#if defined(HAVE_GETGROUPLIST) && defined(__GLIBC__)
    gid_t gid, *groupids = NULL;
    int ret, ngroups = 10, oldngroups;
#else
    char **mem;
#endif

    identifier = mycanonifyid(identifier, 0);
    if (!identifier) return 0;
    if (!strncmp(identifier, "group:", 6)) return 0;
    
    newstate = (struct auth_state *)xmalloc(sizeof(struct auth_state));

    strcpy(newstate->userid, identifier);
    strarray_init(&newstate->groups);
    
    if(!libcyrus_config_getswitch(CYRUSOPT_AUTH_UNIX_GROUP_ENABLE))
	return newstate;

    pwd = getpwnam(identifier);

#if defined(HAVE_GETGROUPLIST) && defined(__GLIBC__)
    gid = pwd ? pwd->pw_gid : (gid_t) -1;

    /* get the group ids */
    do {
	groupids = (gid_t *)xrealloc((gid_t *)groupids,
				     ngroups * sizeof(gid_t));

	oldngroups = ngroups; /* copy of ngroups for comparision */
	ret = getgrouplist(identifier, gid, groupids, &ngroups);
	/*
	 * This is tricky. We do this as long as getgrouplist tells us to
	 * realloc _and_ the number of groups changes. It tells us to realloc
	 * also in the case of failure...
	 */
    } while (ret == -1 && ngroups != oldngroups);

    if (ret == -1)
	goto err;

    while (ngroups--) {
	if (pwd || groupids[ngroups] != gid) {
	    if ((grp = getgrgid(groupids[ngroups])))
		strarray_append(&newstate->groups, grp->gr_name);
	}
    }

err:
    if (groupids) free(groupids);

#else /* !HAVE_GETGROUPLIST */
    setgrent();
    while ((grp = getgrent())) {
	for (mem = grp->gr_mem; *mem; mem++) {
	    if (!strcmp(*mem, identifier)) break;
	}

	if (*mem || (pwd && pwd->pw_gid == grp->gr_gid))
	    strarray_append(&newstate->groups, grp->gr_name);
    }
    endgrent();
#endif /* HAVE_GETGROUPLIST */

    return newstate;
}
예제 #4
0
파일: res32.c 프로젝트: r6144/wine
/* output the resources into a .o file */
void output_res_o_file( DLLSPEC *spec )
{
    unsigned int i;
    char *res_file = NULL;
    int fd;

    if (!spec->nb_resources) fatal_error( "--resources mode needs at least one resource file as input\n" );
    if (!output_file_name) fatal_error( "No output file name specified\n" );

    byte_swapped = 0;
    init_output_buffer();

    put_dword( 0 );      /* ResSize */
    put_dword( 32 );     /* HeaderSize */
    put_word( 0xffff );  /* ResType */
    put_word( 0x0000 );
    put_word( 0xffff );  /* ResName */
    put_word( 0x0000 );
    put_dword( 0 );      /* DataVersion */
    put_word( 0 );       /* Memory options */
    put_word( 0 );       /* Language */
    put_dword( 0 );      /* Version */
    put_dword( 0 );      /* Characteristics */

    for (i = 0; i < spec->nb_resources; i++)
    {
        unsigned int header_size = get_resource_header_size( &spec->resources[i] );

        put_dword( spec->resources[i].data_size );
        put_dword( (header_size + 3) & ~3 );
        put_string( &spec->resources[i].type );
        put_string( &spec->resources[i].name );
        align_output( 4 );
        put_dword( 0 );
        put_word( spec->resources[i].mem_options );
        put_word( spec->resources[i].lang );
        put_dword( 0 );
        put_dword( 0 );
        put_data( spec->resources[i].data, spec->resources[i].data_size );
        align_output( 4 );
    }

    /* if the output file name is a .res too, don't run the results through windres */
    if (strendswith( output_file_name, ".res"))
    {
        flush_output_buffer();
        return;
    }

    res_file = get_temp_file_name( output_file_name, ".res" );
    if ((fd = open( res_file, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600 )) == -1)
        fatal_error( "Cannot create %s\n", res_file );
    if (write( fd, output_buffer, output_buffer_pos ) != output_buffer_pos)
        fatal_error( "Error writing to %s\n", res_file );
    close( fd );
    free( output_buffer );

    if (res_file)
    {
        struct strarray *args = strarray_init();
        strarray_add( args, find_tool( "windres", NULL ), "-i", res_file, "-o", output_file_name, NULL );
        spawn( args );
        strarray_free( args );
    }
    output_file_name = NULL;  /* so we don't try to assemble it */
}
예제 #5
0
파일: pair2net.c 프로젝트: bert/fpgatools
int main(int argc, char** argv)
{
	char line[1024], point_a[1024], point_b[1024];
	struct hashed_strarray connpt_names;
	FILE* fp = 0;
	int i, rc, point_a_idx, point_b_idx, existing_net_idx, new_net_idx;
	int net_data_idx;
	uint32_t** nets;

	if (argc < 2) {
		fprintf(stderr,
			"\n"
			"pair2net - finds all pairs connected to the same net\n"
			"Usage: %s <data_file> | '-' for stdin\n", argv[0]);
		goto xout;
	}
	if (strarray_init(&connpt_names, STRIDX_1M)) {
		fprintf(stderr, "Out of memory in %s:%i\n", __FILE__, __LINE__);
		goto xout;
	}

	nets = calloc(STRIDX_1M, sizeof(*nets));
	if (!nets) {
		fprintf(stderr, "Out of memory in %s:%i\n", __FILE__, __LINE__);
		goto xout;
	}
	if (!strcmp(argv[1], "-"))
		fp = stdin;
	else {
		fp = fopen(argv[1], "r");
		if (!fp) {
			fprintf(stderr, "Error opening %s.\n", argv[1]);
			goto xout;
		}
	}
	while (fgets(line, sizeof(line), fp)) {
		i = sscanf(line, "%s%s", point_a, point_b);
		if (i != 2) continue;

		i = strlen(point_b);
		if (i && point_b[i-1] == '\n')
			point_b[i-1] = 0;
		rc = strarray_add(&connpt_names, point_a, &point_a_idx);
		if (rc) {
			fprintf(stderr, "Out of memory in %s:%i\n",
				__FILE__, __LINE__);
			goto xout;
		}
		rc = strarray_add(&connpt_names, point_b, &point_b_idx);
		if (rc) {
			fprintf(stderr, "Out of memory in %s:%i\n",
				__FILE__, __LINE__);
			goto xout;
		}
		if (nets[point_a_idx] && nets[point_b_idx]) {
			continue;}
		if (nets[point_a_idx] || nets[point_b_idx]) {
			if (nets[point_a_idx]) {
				existing_net_idx = point_a_idx;
				new_net_idx = point_b_idx;
			} else { // point_b_idx exists
				existing_net_idx = point_b_idx;
				new_net_idx = point_a_idx;
			}
			if ((uint64_t) nets[existing_net_idx] & 1)
				net_data_idx = (uint64_t) nets[existing_net_idx] >> 32;
			else
				net_data_idx = existing_net_idx;
			// add new_net_idx to net data
			rc = add_entry(&nets[net_data_idx], new_net_idx);
			if (rc) goto xout;
			// point to net data from new_net_idx
			nets[new_net_idx] = (uint32_t*) (((uint64_t) net_data_idx << 32) | 1);
		} else {