Example #1
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_in6_addr - obtain pointer to struct in6_addr from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns struct in6_addr pointer of the input specified by
 * index. On error, it returns NULL and errno is appropriately set.
 */
const struct in6_addr *
nurs_input_in6_addr(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_IN6ADDR, NULL);
	/* XXX: copy? */
	return &input->keys[idx]->in6;
}
Example #2
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_string - obtain string from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns string (char *) of the input specified by
 * index. On error, it returns NULL and errno is appropriately set.
 */
const char *nurs_input_string(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_STRING, NULL);
	/* XXX: copy? */
	return input->keys[idx]->string;
}
Example #3
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_u64 - obtain uint64_t value from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns uint64_t value of the input specified by index.
 * On error, it returns 0 and errno is appropriately set.
 */
uint64_t nurs_input_u64(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_UINT64, 0);
	return input->keys[idx]->u64;
}
Example #4
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_in_addr - obtain in_addr_t value from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns in_addr_t (uint32_t) value of the input specified by
 * index. On error, it returns 0 and errno is appropriately set.
 */
in_addr_t nurs_input_in_addr(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_INADDR, 0);
	return input->keys[idx]->in4;
}
Example #5
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_u32 - obtain uint32_t value from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns uint32_t value of the input specified by index.
 * On error, it returns 0 and errno is appropriately set.
 */
uint32_t nurs_input_u32(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_UINT32, 0);
	return input->keys[idx]->u32;
}
Example #6
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_u16 - obtain uint16_t value from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns uint16_t value of the input specified by index.
 * On error, it returns 0 and errno is appropriately set.
 */
uint16_t nurs_input_u16(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_UINT16, 0);
	return input->keys[idx]->u16;
}
Example #7
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_u8 - obtain uint8_t value from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns uint8_t value of the input specified by index.
 * On error, it returns 0 and errno is appropriately set.
 */
uint8_t nurs_input_u8(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_UINT8, 0);
	return input->keys[idx]->u8;
}
Example #8
0
File: key.c Project: chamaken/nurs
/**
 * nurs_input_bool - obtain bool value from input
 * \param input input passed by callback param
 * \param idx input key index
 *
 * This function returns boolean value of the input specified by index.
 * On error, it returns false and errno is appropriately set.
 */
bool nurs_input_bool(const struct nurs_input *input, uint16_t idx)
{
	check_input_type(NURS_KEY_T_BOOL, false);
	return input->keys[idx]->b;
}
Example #9
0
int process_input_instructions (int argc, char *argv[],
				int * tgt_input_type_ptr, char * tgt_chain_ptr, Descr * tgt_descr, FILE ** tgt_fptr_ptr,
				int * qry_input_type_ptr, char * qry_chain_ptr, Descr * qry_descr, FILE ** qry_fptr_ptr) {


    char tgt_chain = '\0', qry_chain = '\0';
    int  tgt_input_type = 0, qry_input_type = 0;

    FILE *qry_fptr    = NULL, *tgt_fptr = NULL;

    
    char  *cmd_filename = NULL;

    int parse_cmd_line (int argc, char * argv[],  char * tgt_chain_ptr,
			char * qry_chain_ptr, char **cmd_filename_ptr);
    int read_cmd_file (char *filename);

    
    /* process cmd line input */
    if (parse_cmd_line (argc, argv, &tgt_chain,
		        &qry_chain, &cmd_filename)) return 1;

    /* process the command (parameters) file, if provided */
    if (cmd_filename && read_cmd_file(cmd_filename))  return 1;

   
    /* check if the tgt file is  present and readable; open               */
    if ( ! (tgt_fptr = efopen(options.tgt_filename, "r"))) return 1;
    
    
    /* figure out whether we have a pdb or db input:                      */
    tgt_input_type = check_input_type (tgt_fptr);
    if ( tgt_input_type != PDB && tgt_input_type != DB ) {
	fprintf ( stderr, "Unrecognized file type: %s.\n", argv[1]);
	return 1;
    }

    /* for testing purposes we might have both: */
    if ( options.tgt_db) tgt_descr->db_file  =  options.tgt_db;
    if ( options.qry_db) qry_descr->db_file  =  options.qry_db;
    
    
    /*do something about the names for the output:                        */
    if ( tgt_input_type==PDB) {
	improvize_name (options.tgt_filename, tgt_chain, tgt_descr->name);
    }
    
    /**********************************************************************/
    /* the same for the qry file, but may not be necessary if we are      */
    /* preprocessing only                                                 */
    if ( options.qry_filename) {
	if ( ! (qry_fptr = efopen(options.qry_filename, "r"))) return 1;
	
	qry_input_type = check_input_type (qry_fptr);
	if ( qry_input_type != PDB  &&  qry_input_type != DB ) {
	    fprintf ( stderr, "Unrecognized file type: %s.\n", argv[2]);
	    exit (1);
	}
	if ( qry_input_type==PDB) {
	    improvize_name (options.qry_filename, qry_chain, qry_descr->name);
	}
	if (tgt_input_type != PDB  ||  qry_input_type != PDB)  {
	    options.postprocess        = 0;
	    options.number_maps_out = 1;
	}
	
    }
    if( !options.outname[0]
	&& tgt_descr->name && tgt_descr->name[0]
	&& qry_descr->name && qry_descr->name[0]) {
	sprintf (options.outname, "%s_to_%s",  tgt_descr->name, qry_descr->name);
    }
    if ( options.outdir[0] ) {
	/* checkk whether this directory exists */
	struct stat st;
	if ( stat(options.outdir, &st) )  {
	    fprintf (stderr, "%s  not found.\n", options.outdir);
	    return 1;
	}
    }

    if (!options.postprocess) {
         options.number_maps_out = 1;
	 options.print_header    = 0;
    }
    *tgt_input_type_ptr = tgt_input_type;
    *qry_input_type_ptr = qry_input_type;

    *tgt_chain_ptr = tgt_chain;
    *qry_chain_ptr = qry_chain;

    *tgt_fptr_ptr = tgt_fptr;
    *qry_fptr_ptr  = qry_fptr;

    return 0;

}