Exemple #1
0
// open that puppy!!!  gets the file opened and the data structs read for use
bool upkg::open(file_reader * p_reader)
{
	if (pkg_opened)		// is there a pkg opened already?
		return false;	// if so, don't try to open another one!

	if (p_reader == NULL)
		return false;

	reader = p_reader;

	if (reader->read(header, 4096) < 4096) {
		return false;
	}

	if (load_upkg() != 0) {
		return false;
	}

	pkg_opened = 1;

	get_names();		// this order is important.
	get_imports();
	get_exports();
	get_types();

	return true;
}
Exemple #2
0
int	synthaxe_error(char *str)
{
  char  *tab_synthaxe[20];

  int   i;
  int   alright;

  alright = 0;
  i = 0;
  init_types(tab_synthaxe);
  early_space(str);
  while (tab_synthaxe[i] != NULL)
    {
      if (strncmp(str, tab_synthaxe[i], strlen(tab_synthaxe[i])) == 0)
	{
	  alright = 1;
	  printf("Déclaration de la %s %s de type %s\n",
		 get_parenthesis(get_name(str)) ? "variable" : "fonction",
		 get_name(str), get_types(str,tab_synthaxe));
	  break;
	}
      i++;
    }
  if (alright == 0)
    return (fprintf(stderr, "%s n'est pas un type valide \n", str));
  return (check_integrity(str, strlen(tab_synthaxe[i])));
}
Exemple #3
0
PyObject* info( int type, const char *name)
{
	PyObject* output = NULL;

	switch(type) {
	/* display requested info */
	case TYPE:
		output = get_types(name, policy);
		break;
	case ATTRIBUTE:
		output = get_attribs(name, policy);
		break;
	case ROLE:
		output = get_roles(name, policy);
		break;
	case USER:
		output = get_users(name, policy);
		break;
	case CLASS:
		output = get_classes(name, policy);
		break;
	case BOOLEAN:
		output = get_booleans(name, policy);
		break;
	case PORT:
		output = get_ports(name, policy);
		break;
	default:
		errno = EINVAL;
		PyErr_SetString(PyExc_RuntimeError,strerror(errno));
		break;
	}

	return output;
}
Exemple #4
0
format unification_app_mismatch_exception::pp(formatter const & fmt, options const & opts) const {
    unsigned indent     = get_pp_indent(opts);
    auto const & ctx    = get_context();
    expr const & app    = get_expr();
    auto args_it        = get_args().begin();
    auto args_end       = get_args().end();
    auto types_it       = get_types().begin();
    format app_fmt      = fmt(ctx, app, false, opts);
    format r            = format{format(what()), nest(indent, compose(line(), app_fmt))};
    format fun_type_fmt = fmt(ctx, *types_it, false, opts);
    r += compose(line(), format("Function type:"));
    r += nest(indent, compose(line(), fun_type_fmt));
    ++args_it;
    ++types_it;
    if (get_args().size() > 2)
        r += compose(line(), format("Arguments types:"));
    else
        r += compose(line(), format("Argument type:"));
    for (; args_it != args_end; ++args_it, ++types_it) {
        format arg_fmt    = fmt(ctx, *args_it, false, opts);
        format type_fmt   = fmt(ctx, *types_it, false, opts);
        r += nest(indent, compose(line(), group(format{arg_fmt, space(), colon(), nest(indent, format{line(), type_fmt})})));
    }
    r += pp_elaborator_state(fmt, get_elaborator(), opts);
    return r;
}
Exemple #5
0
int get_rule(Resources *res, TStack *stack) {
    args_assert(res != NULL && stack != NULL, INTERNAL_ERROR);
    
    int values [MAX_RULE_LENGTH + 1];
    int i;
    int err = get_types(&res->struct_buff, stack, values);
    catch_internal_error(err, INTERNAL_ERROR, "Failed to get types of token");
    catch_syntax_error(err, SYNTAX_ERROR, "Failed to get types of token", 1);

#if DEBUG
    char *short_rule_symbol[2];
    short_rule_symbol[0] = "id";
    short_rule_symbol[1] = "li";

    char * long_rule_symbol[11];
    long_rule_symbol[0] = "RVALUE == RVALUE -> RVALUE";
    long_rule_symbol[1] = "RVALUE > RVALUE -> RVALUE";
    long_rule_symbol[2] = "RVALUE < RVALUE -> RVALUE";
    long_rule_symbol[3] = "RVALUE >= RVALUE -> RVALUE";
    long_rule_symbol[4] = "RVALUE <= RVALUE -> RVALUE";
    long_rule_symbol[5] = "RVALUE != RVALUE -> RVALUE";
    long_rule_symbol[6] = "RVALUE + RVALUE -> RVALUE";
    long_rule_symbol[7] = "RVALUE - RVALUE -> RVALUE";
    long_rule_symbol[8] = "RVALUE * RVALUE -> RVALUE";
    long_rule_symbol[9] = "RVALUE / RVALUE -> RVALUE";
    long_rule_symbol[10] = "( RVALUE ) -> RVALUE";
#endif

    if (values[0] == 1) {
        for (i = 0; i < 2; i++) {
            if (short_rules[i] == values[1]) {
#if DEBUG
               debug_print("%s %s %s\n", "APPLIED RULE:", short_rule_symbol[i], "-> RVALUE");
#endif
               return short_reduction(res, stack);

            }
        }
        return SYNTAX_ERROR;
    } else if (values[0] == 3) {
        for (i = 0; i < 11; i++) {
            if (!(memcmp(long_rules[i], &values[1], sizeof(long_rules[i])))) {
#if DEBUG
                debug_print("%s %s\n", "APPLIED RULE:", long_rule_symbol[i]);
#endif
                return long_reduction(res, stack, i);
            }
        }
        return SYNTAX_ERROR;
    } else 
        return SYNTAX_ERROR;
}
Exemple #6
0
foreign_t del_handler(term_t server, term_t msg, term_t types)
{
	my_server_thread s;
	char	*pattern, *typespec;
	char	buffer[256]; // !! space for up to 255 arguments
	int	rc;

	rc = get_server(server,&s) 
		&& get_msg(msg,&pattern) 
		&& get_types(types,buffer,256,&typespec);

	if (rc) lo_server_del_method(s->s,pattern,typespec);
	return rc;
}
Exemple #7
0
foreign_t add_handler(term_t server, term_t msg, term_t types, term_t goal)
{
	my_server_thread s;
	lo_method method;
	char	*pattern, *typespec;
	char	buffer[256]; // !! space for up to 255 arguments
	int	rc;

	rc = get_server(server,&s) 
		&& get_msg(msg,&pattern) 
		&& get_types(types,buffer,256,&typespec);

	if (rc) {
		record_t goal_record=PL_record(goal);
		method = lo_server_add_method(s->s, pattern, typespec, prolog_handler, (void *)goal_record);
	} 
	return rc;
}
Exemple #8
0
void		tab_fill(t_argtab *tab, int argc, char *argv[])
{
	int		i;
	int		get;

	i = 0;
	while (i < argc)
	{
		get = get_types(argv[i]);
		tab_distrib(tab, get, argv[i]);
		if (get == 3)
			tab->error.data[tab->error.size++] = argv[i];
		i++;
	}
	i = 0;
	while (i++ < tab->file.size)
		tab->file.ptr[i - 1] = &tab->file.data[i - 1];
	i = 0;
	while (i++ < tab->dir.size)
		tab->dir.ptr[i - 1] = &tab->dir.data[i - 1];
}
Exemple #9
0
static QStringList supportedHashTypes(const QString &provider)
{
	return get_types(get_hash_types, provider);
}
Exemple #10
0
static QStringList supportedMACTypes(const QString &provider)
{
	return get_types(get_mac_types, provider);
}
Exemple #11
0
static QStringList supportedCipherTypes(const QString &provider)
{
	return get_types(get_cipher_types, provider);
}
Exemple #12
0
int pg_cmd(db_cmd_t* cmd)
{
	struct pg_cmd* pcmd;
 
	pcmd = (struct pg_cmd*)pkg_malloc(sizeof(struct pg_cmd));
	if (pcmd == NULL) {
		ERR("postgres: No memory left\n");
		goto error;
	}
	memset(pcmd, '\0', sizeof(struct pg_cmd));
	if (db_drv_init(&pcmd->gen, pg_cmd_free) < 0) goto error;

	switch(cmd->type) {
	case DB_PUT:
		if (build_insert_sql(&pcmd->sql_cmd, cmd) < 0) goto error;
		break;
		
	case DB_DEL:
		if (build_delete_sql(&pcmd->sql_cmd, cmd) < 0) goto error;
		break;

	case DB_GET:
		if (build_select_sql(&pcmd->sql_cmd, cmd) < 0) goto error;
		break;

	case DB_UPD:
		if (build_update_sql(&pcmd->sql_cmd, cmd) < 0) goto error;
		break;
		
	case DB_SQL:
		pcmd->sql_cmd.s = (char*)pkg_malloc(cmd->table.len + 1);
		if (pcmd->sql_cmd.s == NULL) {
			ERR("postgres: Out of private memory\n");
			goto error;
		}
		memcpy(pcmd->sql_cmd.s,cmd->table.s, cmd->table.len);
		pcmd->sql_cmd.s[cmd->table.len] = '\0';
		pcmd->sql_cmd.len = cmd->table.len;
        break;
	}

	DB_SET_PAYLOAD(cmd, pcmd);

	/* Create parameter arrays for PostgreSQL API functions */
	if (create_pg_params(cmd) < 0) goto error;	

	/* Generate a unique name for the command on the server */
	if (gen_cmd_name(cmd) != 0) goto error; 

	/* Upload the command to the server */
	if (upload_cmd(cmd) != 0) goto error;

	/* Obtain the description of the uploaded command, this includes
	 * information about result and parameter fields */
	if (get_types(cmd) != 0) goto error;

	/* Update fields based on the information retrieved from the */
	if (pg_resolve_param_oids(cmd->vals, cmd->match,
							  cmd->vals_count, cmd->match_count,
							  pcmd->types)) 
		goto error;
	if (pg_resolve_result_oids(cmd->result, cmd->result_count, pcmd->types)) 
		goto error;

	if (check_types(cmd)) goto error;

	return 0;

 error:
	if (pcmd) {
		DB_SET_PAYLOAD(cmd, NULL);
		free_pg_params(&pcmd->params);

		if (pcmd->types) PQclear(pcmd->types);
		if (pcmd->name) pkg_free(pcmd->name);
		if (pcmd->sql_cmd.s) pkg_free(pcmd->sql_cmd.s);

		db_drv_free(&pcmd->gen);
		pkg_free(pcmd);
	}
	return -1;
}
/* get all the data in .debug_types */
extern void
print_types(Dwarf_Debug dbg, enum type_type_e type_type)
{
    Dwarf_Type *typebuf = NULL;
    Dwarf_Signed count = 0;
    Dwarf_Signed i = 0;
    char *name = NULL;
    int gtres = 0;

    char *section_name = NULL;
    char *offset_err_name = NULL;
    char *section_open_name = NULL;
    char *print_name_prefix = NULL;
    int (*get_types) (Dwarf_Debug, Dwarf_Type **, Dwarf_Signed *,
        Dwarf_Error *) = 0;
    int (*get_offset) (Dwarf_Type, char **, Dwarf_Off *, Dwarf_Off *,
        Dwarf_Error *) = NULL;
    int (*get_cu_offset) (Dwarf_Type, Dwarf_Off *, Dwarf_Error *) =
        NULL;
    void (*dealloctype) (Dwarf_Debug, Dwarf_Type *, Dwarf_Signed) =
        NULL;

    /* Do nothing if in check mode */
    if (!do_print_dwarf) {
        return;
    }
  

    if (type_type == DWARF_PUBTYPES) {
        section_name = ".debug_pubtypes";
        offset_err_name = "dwarf_pubtype_name_offsets";
        section_open_name = "dwarf_get_pubtypes";
        print_name_prefix = "pubtype";
        get_types = dwarf_get_pubtypes;
        get_offset = dwarf_pubtype_name_offsets;
        get_cu_offset = dwarf_pubtype_cu_offset;
        dealloctype = dwarf_pubtypes_dealloc;
    } else {
        /* SGI_TYPENAME */
        section_name = ".debug_typenames";
        offset_err_name = "dwarf_type_name_offsets";
        section_open_name = "dwarf_get_types";
        print_name_prefix = "type";
        get_types = dwarf_get_types;
        get_offset = dwarf_type_name_offsets;
        get_cu_offset = dwarf_type_cu_offset;
        dealloctype = dwarf_types_dealloc;
    }



    gtres = get_types(dbg, &typebuf, &count, &err);
    if (gtres == DW_DLV_ERROR) {
        print_error(dbg, section_open_name, gtres, err);
    } else if (gtres == DW_DLV_NO_ENTRY) {
        /* no types */
    } else {
        Dwarf_Unsigned maxoff = get_info_max_offset(dbg);

        /*  Before July 2005, the section name was printed
            unconditionally, now only prints if non-empty section really 
            exists. */
        printf("\n%s\n", section_name);

        for (i = 0; i < count; i++) {
            int tnres = 0;
            int cures3 = 0;
            Dwarf_Off die_off = 0;
            Dwarf_Off cu_off = 0;
            Dwarf_Off global_cu_off = 0;

            tnres =
                get_offset(typebuf[i], &name, &die_off, &cu_off, &err);
            deal_with_name_offset_err(dbg, offset_err_name, name,
                die_off, tnres, err);
            cures3 = get_cu_offset(typebuf[i], &global_cu_off, &err);
            if (cures3 != DW_DLV_OK) {
                print_error(dbg, "dwarf_var_cu_offset", cures3, err);
            }
            print_pubname_style_entry(dbg,
                print_name_prefix,
                name, die_off, cu_off,
                global_cu_off, maxoff);

            /* print associated die too? */
        }
        dealloctype(dbg, typebuf, count);
    }
}   /* print_types() */
Exemple #14
0
int main(int argc, char **argv){
  type_info tinfo;
  int flag = 1;
  int file_counter=0; 
  int nsample = 0;

  if ( argc != 4 ){
    fprintf(stderr, "Arguments: <type> <numb. of blocks per sample> <dir>\n"); 
    exit(EXIT_FAILURE);
  }

  char type = argv[1][0];
  int num_blocks_per_sample = atoi(argv[2]);
  int dir = atoi(argv[3]);

  double dt = get_types(&tinfo, type, "00001_mol.conf");
  
  double **omega = sep_matrix(num_blocks_per_sample, tinfo.nmols_type);
  double *acf = sep_vector(num_blocks_per_sample);

  while (1) {

    printf("\r");
    printf("Processing sample %d  ", nsample);
    fflush(stdout);

    for ( int n=0;  n<num_blocks_per_sample; n++ ){
      char file[256];
      sprintf(file, "%05d_mol.conf", file_counter);
      file_counter++;
      if ( file_exists(file) == 1 ){
	read_entry_from_file(omega, n, file, dir, tinfo);
	flag = 1;
      }
      else {
	flag = 0;
	break;
      }
    }
    
    if ( flag == 1 ){
      for ( int i=0; i<tinfo.nmols_type; i++ )
	for ( int k=0; k<num_blocks_per_sample; k++ )
	  for ( int kk=0; kk<num_blocks_per_sample-k; kk++ )
	    acf[k] += omega[kk][i]*omega[k+kk][i];   
      
      nsample++;
    }
    else if ( flag == 0 ) break;

  }
  printf("\n");

  FILE *fout = fopen("single_mavacf.dat", "w");
  if ( fout == NULL )
    sep_error("Couldn't open file - BAILING OUT");

  for ( int k=0; k< num_blocks_per_sample; k++ ){
    double t   = dt*(k+0.5);
    double fac = 1.0/((num_blocks_per_sample-k)*tinfo.nmols_type*nsample);
    fprintf(fout, "%f %f\n", t, acf[k]*fac);
  }

  fclose(fout);

  sep_free_matrix(omega, num_blocks_per_sample);
  free(acf);

  return 0;
}
Exemple #15
0
isc_result_t
acl_configure_zone_ssutable(const char *policy_str, dns_zone_t *zone)
{
	isc_result_t result = ISC_R_SUCCESS;
	cfg_parser_t *parser = NULL;
	const cfg_listelt_t *el;
	cfg_obj_t *policy = NULL;
	dns_ssutable_t *table = NULL;
	ld_string_t *new_policy_str = NULL;
	isc_mem_t *mctx;

	REQUIRE(zone != NULL);

	mctx = dns_zone_getmctx(zone);

	if (policy_str == NULL)
		goto cleanup;

	CHECK(bracket_str(mctx, policy_str, &new_policy_str));

	CHECK(cfg_parser_create(mctx, dns_lctx, &parser));
	result = cfg_parse_strbuf(parser, str_buf(new_policy_str), &cfg_type_update_policy, &policy);

	if (result != ISC_R_SUCCESS) {
		dns_zone_log(zone, ISC_LOG_ERROR,
			     "failed to parse policy string");
		goto cleanup;
	}

	CHECK(dns_ssutable_create(mctx, &table));

	for (el = cfg_list_first(policy); el != NULL; el = cfg_list_next(el)) {
		const cfg_obj_t *stmt;
		isc_boolean_t grant;
		unsigned int match_type;
		dns_fixedname_t fname, fident;
		dns_rdatatype_t *types;
		unsigned int n;

		types = NULL;

		stmt = cfg_listelt_value(el);
		CHECK(get_mode(stmt, &grant));
		CHECK(get_match_type(stmt, &match_type));

		CHECK(get_fixed_name(stmt, "identity", &fident));

		/* Use zone name for 'zonesub' match type */
		result = get_fixed_name(stmt, "name", &fname);
		if (result == ISC_R_NOTFOUND &&
		    match_type == DNS_SSUMATCHTYPE_SUBDOMAIN) {
			dns_fixedname_init(&fname);
			CHECK(dns_name_copy(dns_zone_getorigin(zone),
					    dns_fixedname_name(&fname),
					    &fname.buffer));
		}
		else if (result != ISC_R_SUCCESS)
			goto cleanup;

		CHECK(get_types(mctx, stmt, &types, &n));

		if (match_type == DNS_SSUMATCHTYPE_WILDCARD &&
		    !dns_name_iswildcard(dns_fixedname_name(&fname))) {
			char name[DNS_NAME_FORMATSIZE];
			dns_name_format(dns_fixedname_name(&fname), name,
					DNS_NAME_FORMATSIZE);
			dns_zone_log(zone, ISC_LOG_ERROR,
				     "invalid update policy: "
				     "name '%s' is expected to be a wildcard",
				     name);
			CLEANUP_WITH(DNS_R_BADNAME);
		}

		result = dns_ssutable_addrule(table, grant,
					      dns_fixedname_name(&fident),
					      match_type,
					      dns_fixedname_name(&fname),
					      n, types);

		SAFE_MEM_PUT(mctx, types, n * sizeof(dns_rdatatype_t));
		if (result != ISC_R_SUCCESS)
			goto cleanup;

	}

 cleanup:
	if (result == ISC_R_SUCCESS)
		dns_zone_setssutable(zone, table);

	str_destroy(&new_policy_str);
	if (policy != NULL)
		cfg_obj_destroy(parser, &policy);
	if (parser != NULL)
		cfg_parser_destroy(&parser);
	if (table != NULL)
		dns_ssutable_detach(&table);

	return result;
}