int BMatch_s(TCHAR *str, TCHAR *target, TCHAR *targetstartp, TCHAR *targetendp, int one_shot, BREGEXP **rxp, TCHAR *msg) { TRACE(_T("BMatch(): '%s' (%p), %p, %p, %p\n"), str, str, target, targetstartp, targetendp); set_new_throw_bad_alloc(); if (check_params(target, targetstartp, targetendp, rxp, msg, false) < 0) { return -1; } bregonig *rx = static_cast<bregonig*>(*rxp); *rxp = rx = recompile_onig(rx, PTN_MATCH, str, msg); if (rx == NULL) { return -1; } int err_code = regexec_onig(rx, targetstartp, targetendp, target, 0, 1, one_shot, msg); #if 0 if (err_code > 0 && rx->nparens && rx->endp[1] > rx->startp[1]) { int len = rx->endp[1] - rx->startp[1]; TCHAR *tp = new (std::nothrow) TCHAR[len+1]; if (tp == NULL) { asc2tcs(msg, "match out of space", BREGEXP_MAX_ERROR_MESSAGE_LEN); return -1; } memcpy(tp,rx->startp[1],len*sizeof(TCHAR)); rx->outp = tp; rx->outendp = tp + len; *(rx->outendp) = '\0'; } #endif return err_code; }
/* * i2c_read - Read from i2c memory * @chip: target i2c address * @addr: address to read from * @alen: * @buffer: buffer for read data * @len: no of bytes to be read * * Read from i2c memory. */ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) { unsigned long start_time_rx; if (check_params(addr, alen, buffer, len)) return 1; if (i2c_xfer_init(chip, addr)) return 1; start_time_rx = get_timer(0); while (len) { writel(IC_CMD, &i2c_regs_p->ic_cmd_data); if (readl(&i2c_regs_p->ic_status) & IC_STATUS_RFNE) { *buffer++ = (uchar)readl(&i2c_regs_p->ic_cmd_data); len--; start_time_rx = get_timer(0); } else if (get_timer(start_time_rx) > I2C_BYTE_TO) { printf("Timed out. i2c read Failed\n"); return 1; } } return i2c_xfer_finish(); }
/* * i2c_write - Write to i2c memory * @chip: target i2c address * @addr: address to read from * @alen: * @buffer: buffer for read data * @len: no of bytes to be read * * Write to i2c memory. */ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) { int nb = len; unsigned long start_time_tx; if (check_params(addr, alen, buffer, len)) return 1; if (i2c_xfer_init(chip, addr)) return 1; start_time_tx = get_timer(0); while (len) { if (readl(&i2c_regs_p->ic_status) & IC_STATUS_TFNF) { writel(*buffer, &i2c_regs_p->ic_cmd_data); buffer++; len--; start_time_tx = get_timer(0); } else if (get_timer(start_time_tx) > (nb * I2C_BYTE_TO)) { printf("Timed out. i2c write Failed\n"); return 1; } } return i2c_xfer_finish(); }
// Main entry to the interpret. No tests will be launched, only // pure interpret will be compiled int main(int argc, char *argv[]) { int result; if ((result = check_params(argc, argv))) { return result; } // naalokujeme sdilenou datovou strukturu make_data_structure(); // otevrem soubor set_input(argv[1]); #ifdef LEX_TEST do { get_token(); } while (d->token->type != EOF); #else // parse parser_prepare(d); d = parser_run(); if (d->error != CODE_OK) { return 2; } InterpretInit(d->tree->d.list); // interpret the list InterpretRun(); #endif return 0; }
/* * Send a transactional request, no dialogs involved */ int request(str* m, str* ruri, str* to, str* from, str* h, str* b, str *oburi, transaction_cb cb, void* cbp,release_tmcb_param release_func) { str callid, fromtag; dlg_t* dialog; int res; if (check_params(m, to, from, &dialog) < 0) goto err; generate_callid(&callid); generate_fromtag(&fromtag, &callid); if (new_dlg_uac(&callid, &fromtag, DEFAULT_CSEQ, from, to, &dialog) < 0) { LM_ERR("failed to create temporary dialog\n"); goto err; } if (ruri) { dialog->rem_target.s = ruri->s; dialog->rem_target.len = ruri->len; dialog->hooks.request_uri = &dialog->rem_target; } if (oburi && oburi->s) dialog->hooks.next_hop = oburi; w_calculate_hooks(dialog); res = t_uac(m, h, b, dialog, cb, cbp, release_func); dialog->rem_target.s = 0; free_dlg(dialog); return res; err: return -1; }
void ft_sub(t_env *env, t_process *proc) { t_list *params; t_param **param; int op_size; params = get_parameters(env, proc); op_size = calculate_size(env->arena[(proc->pc + 1) % MEM_SIZE], 3, 4); if (!(param = check_params(params))) { proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE); ft_free(params); return ; } proc->carry = 0; proc->reg[param[2]->value - 1] = param[0]->real_value - param[1]->real_value; if (env->flags->v && env->flags->verbose->show_operations) verb_sub(env, proc); proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE); if (proc->reg[param[2]->value - 1] == 0) proc->carry = 1; ft_free(params); free(param); }
params(const boost::property_tree::ptree &p) : AMGCL_PARAMS_IMPORT_VALUE(p, enable), AMGCL_PARAMS_IMPORT_VALUE(p, min_per_proc), AMGCL_PARAMS_IMPORT_VALUE(p, shrink_ratio) { check_params(p, {"enable", "min_per_proc", "shrink_ratio"}); }
static ast_result_t sugar_ffi(ast_t* ast) { AST_GET_CHILDREN(ast, id, typeargs, args, named_args); const char* name = ast_name(id); size_t len = ast_name_len(id); // Check for \0 in ffi name (it may be a string literal) if(memchr(name, '\0', len) != NULL) { ast_error(ast, "FFI function names cannot include nul characters"); return AST_ERROR; } // Prefix '@' to the name char* new_name = (char*)pool_alloc_size(len + 2); new_name[0] = '@'; memcpy(new_name + 1, name, len); new_name[len + 1] = '\0'; ast_t* new_id = ast_from_string(id, stringtab_consume(new_name, len + 2)); ast_replace(&id, new_id); if(ast_id(ast) == TK_FFIDECL) return check_params(args); return AST_OK; }
void ft_ld(t_env *env, t_process *proc) { t_list *params; int op_size; t_param **param; params = get_parameters(env, proc); op_size = calculate_size(env->arena[(proc->pc + 1) % MEM_SIZE], 2, 4); if (!(param = check_params(params))) { proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE); ft_free(params); return ; } proc->carry = 0; if (param[0]->type == IND_CODE) proc->reg[param[1]->value - 1] = ft_getnumber(env->arena , (proc->pc + param[0]->value % IDX_MOD) % MEM_SIZE, 4); else proc->reg[param[1]->value - 1] = param[0]->value; if (env->flags->v && env->flags->verbose->show_operations) verb_ld(proc, param); proc->pc = ft_mod((proc->pc + op_size + 2) % MEM_SIZE); if (proc->reg[param[1]->value - 1] == 0) proc->carry = 1; ft_free(params); free(param); }
/* * Send an initial request that will start a dialog * WARNING: writes uac_r->dialog */ int req_outside(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop) { str callid, fromtag; if (check_params(uac_r, to, from) < 0) goto err; generate_callid(&callid); generate_fromtag(&fromtag, &callid); if (new_dlg_uac(&callid, &fromtag, DEFAULT_CSEQ, from, to, &uac_r->dialog) < 0) { LOG(L_ERR, "req_outside(): Error while creating new dialog\n"); goto err; } if (ruri) { uac_r->dialog->rem_target.s = ruri->s; uac_r->dialog->rem_target.len = ruri->len; /* hooks will be set from w_calculate_hooks */ } if (next_hop) uac_r->dialog->dst_uri = *next_hop; w_calculate_hooks(uac_r->dialog); return t_uac(uac_r); err: /* callback parameter must be freed outside of tm module if (cbp) shm_free(cbp); */ return -1; }
/* * Send a transactional request, no dialogs involved */ int request(str* m, str* ruri, str* to, str* from, str* h, str* b, transaction_cb c, void* cp) { str callid, fromtag; dlg_t* dialog; int res; if (check_params(m, to, from, &dialog) < 0) goto err; generate_callid(&callid); generate_fromtag(&fromtag, &callid); if (new_dlg_uac(&callid, &fromtag, DEFAULT_CSEQ, from, to, &dialog) < 0) { LOG(L_ERR, "request(): Error while creating temporary dialog\n"); goto err; } if (ruri) { dialog->rem_target.s = ruri->s; dialog->rem_target.len = ruri->len; dialog->hooks.request_uri = &dialog->rem_target; } w_calculate_hooks(dialog); res = t_uac(m, h, b, dialog, c, cp); dialog->rem_target.s = 0; free_dlg(dialog); return res; err: if (cp) shm_free(cp); return -1; }
hypergeometric_distribution(unsigned r, unsigned n, unsigned N) // Constructor. : m_n(n), m_N(N), m_r(r) { static const char* function = "boost::math::hypergeometric_distribution<%1%>::hypergeometric_distribution"; RealType ret; check_params(function, &ret); }
int gpio_setdir(int port, int pin, int direction) { if (check_params(port, pin)) { return -1; } const unsigned int *bitmask = get_bitmask(port); register volatile unsigned int *r, *c; volatile int position; position = get_index(port, pin); if ((position < 0) || (position >= GPIO_ADDRESS_MAX)) { fprintf(stderr,"error: invalid position: %d\n", position); return -1; } /** set GPIO on the pad control */ c = (void *)gpio.control + get_control(port, pin); *c |= 0x07; /** set register address */ r = (void*)gpio.address[position] + GPIO_OE; switch(direction) { case GPIO_DIR_OUTPUT: *r &= ~(bitmask[pin]); break; case GPIO_DIR_INPUT: *r |= (bitmask[pin]); break; default: fprintf(stderr,"error: invalid direction %d\n", direction); return -1; } return 0; }
MuError mu_cmd_extract (MuConfig *opts, GError **err) { int rv; g_return_val_if_fail (opts, MU_ERROR_INTERNAL); g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_EXTRACT, MU_ERROR_INTERNAL); if (!check_params (opts)) { g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_IN_PARAMETERS, "error in parameters"); return MU_ERROR_IN_PARAMETERS; } if (!opts->params[2] && !opts->parts && !opts->save_attachments && !opts->save_all) rv = show_parts (opts->params[1], opts, err); /* show, don't save */ else { rv = mu_util_check_dir(opts->targetdir, FALSE, TRUE); if (!rv) mu_util_g_set_error (err, MU_ERROR_FILE_CANNOT_WRITE, "target '%s' is not a writable directory", opts->targetdir); else rv = save_parts (opts->params[1], opts->params[2], opts); /* save */ } return rv ? MU_OK : MU_ERROR; }
Scalar* Function<Scalar>::get_dxy_values(int component) const { #ifdef _DEBUG check_params(component, cur_node, num_components); check_table(component, cur_node, 5, "DXY values"); #endif return cur_node->values[component][5]; }
/* * Send a transactional request, no dialogs involved * WARNING: writes uac_r->dialog */ int request(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop) { str callid, fromtag; dlg_t* dialog; int res; if (check_params(uac_r, to, from) < 0) goto err; if (uac_r->callid == NULL || uac_r->callid->len <= 0) generate_callid(&callid); else callid = *uac_r->callid; generate_fromtag(&fromtag, &callid); if (new_dlg_uac(&callid, &fromtag, DEFAULT_CSEQ, from, to, &dialog) < 0) { LOG(L_ERR, "request(): Error while creating temporary dialog\n"); goto err; } if (ruri) { dialog->rem_target.s = ruri->s; dialog->rem_target.len = ruri->len; /* hooks will be set from w_calculate_hooks */ } if (next_hop) dialog->dst_uri = *next_hop; w_calculate_hooks(dialog); /* WARNING: * to be clean it should be called * set_dlg_target(dialog, ruri, next_hop); * which sets both uris if given [but it duplicates them in shm!] * * but in this case the _ruri parameter in set_dlg_target * must be optional (it is needed now) and following hacks * dialog->rem_target.s = 0; * dialog->dst_uri.s = 0; * before freeing dialog here must be removed */ uac_r->dialog = dialog; if(uac_r->ssock!=NULL && uac_r->ssock->len>0 && uac_r->dialog->send_sock==NULL) { /* set local send socket */ uac_r->dialog->send_sock = lookup_local_socket(uac_r->ssock); } res = t_uac(uac_r); dialog->rem_target.s = 0; dialog->dst_uri.s = 0; free_dlg(dialog); uac_r->dialog = 0; return res; err: /* callback parameter must be freed outside of tm module if (cp) shm_free(cp); */ return -1; }
void Function<Scalar>::get_dx_dy_values(Scalar*& dx, Scalar*& dy, int component) const { #ifdef _DEBUG check_params(component, cur_node, num_components); check_table(component, cur_node, 1, "DX values"); check_table(component, cur_node, 2, "DY values"); #endif dx = cur_node->values[component][1]; dy = cur_node->values[component][2]; }
/*! \brief * Checks the validity of a selection method. * * \param[in] fp File handle to use for diagnostic messages * (can be NULL). * \param[in,out] method Method to check. * \param[in] symtab Symbol table (used for checking overlaps). * * Checks the validity of the given selection method data structure * that does not have \ref SMETH_MODIFIER set. * If you remove a check, please make sure that the selection parser, * compiler, and evaluation functions can deal with the method. */ static bool check_method(FILE *fp, gmx_ana_selmethod_t *method, const gmx::SelectionParserSymbolTable &symtab) { bool bOk = true; /* Check the type */ if (method->type == NO_VALUE) { report_error(fp, method->name, "error: no value type specified"); bOk = false; } if (method->type == STR_VALUE && method->nparams > 0) { report_error(fp, method->name, "error: evaluates to a string but is not a keyword"); bOk = false; } /* Check flags */ if (method->type == GROUP_VALUE) { /* Group methods should always have SMETH_SINGLEVAL, * so set it for convenience. */ method->flags |= SMETH_SINGLEVAL; /* Check that conflicting flags are not present. */ if (method->flags & SMETH_VARNUMVAL) { report_error(fp, method->name, "error: SMETH_VARNUMVAL cannot be set for group-valued methods"); bOk = false; } } else { if ((method->flags & SMETH_SINGLEVAL) && (method->flags & SMETH_VARNUMVAL)) { report_error(fp, method->name, "error: SMETH_SINGLEVAL and SMETH_VARNUMVAL both set"); bOk = false; } } if ((method->flags & SMETH_CHARVAL) && method->type != STR_VALUE) { report_error(fp, method->name, "error: SMETH_CHARVAL can only be specified for STR_VALUE methods"); bOk = false; } /* Check the parameters */ if (!check_params(fp, method->name, method->nparams, method->param, symtab)) { bOk = false; } /* Check the callback pointers */ if (!check_callbacks(fp, method)) { bOk = false; } return bOk; }
int main(int argc, char** argv) { if(!check_params(argc, argv)) { putline("0"); return (0); } do_op(argv[i], argv[2], argv[3]); return (0); }
EFP_EXPORT enum efp_result efp_compute(struct efp *efp, int do_gradient) { enum efp_result res; assert(efp); if (efp->grad == NULL) { efp_log("call efp_prepare after all fragments are added"); return (EFP_RESULT_FATAL); } efp->do_gradient = do_gradient; if ((res = check_params(efp))) return (res); memset(&efp->energy, 0, sizeof(struct efp_energy)); memset(&efp->stress, 0, sizeof(mat_t)); memset(efp->grad, 0, efp->n_frag * sizeof(six_t)); memset(efp->ptc_grad, 0, efp->n_ptc * sizeof(vec_t)); efp_balance_work(efp, compute_two_body_range, NULL); if ((res = efp_compute_pol(efp))) return res; if ((res = efp_compute_ai_elec(efp))) return res; if ((res = efp_compute_ai_disp(efp))) return res; #ifdef WITH_MPI efp_allreduce(&efp->energy.electrostatic, 1); efp_allreduce(&efp->energy.dispersion, 1); efp_allreduce(&efp->energy.exchange_repulsion, 1); efp_allreduce(&efp->energy.charge_penetration, 1); if (efp->do_gradient) { efp_allreduce((double *)efp->grad, 6 * efp->n_frag); efp_allreduce((double *)efp->ptc_grad, 3 * efp->n_ptc); efp_allreduce((double *)&efp->stress, 9); } #endif efp->energy.total = efp->energy.electrostatic + efp->energy.charge_penetration + efp->energy.electrostatic_point_charges + efp->energy.polarization + efp->energy.dispersion + efp->energy.ai_dispersion + efp->energy.exchange_repulsion; return EFP_RESULT_SUCCESS; }
bool parse_message(t_parser *parser, char *message) { if (message == NULL) return (false); if (check_prefixe(parser, message) == true && check_command(parser, message) == true && check_params(parser, message) == true && check_crlf(parser, message) == true) return (true); return (false); }
/* read parameter file */ int sps_options::read_param_file(std::string infilename){ //open file std::ifstream infile(infilename.c_str()); if(! infile.is_open() ){ std::cerr<<"\nERROR CAN'T OPEN PARAMETER FILE: "<<infilename<<"\n"<<std::endl; exit(1); } //read param names for the first line std::string line,param_name; std::stringstream temp_sstr; std::vector<std::string> param_names; getline(infile,line); temp_sstr<<line; while(temp_sstr>>param_name){ param_names.push_back(param_name); } //check params check_params(param_names); //read params from the other lines while ( getline (infile,line) ){ std::map<std::string,double> temp_params; std::string temp_str; temp_sstr.clear(); temp_sstr<<line; int i=0; while(temp_sstr>>temp_str){ //read numerical params if (param_names[i]!="sfr_filename"){ temp_params.insert(std::pair<std::string,double>(param_names[i],strtod(temp_str.c_str(),NULL))); } //read sfr fileanem param else { this->sfr_filenames.push_back(temp_str); } i++; } //save params this->num_params.push_back(temp_params); } //read sfr files read_sfr_file_list(); infile.close(); return 0; }
int main(int argc, char *argv[]) { spma_init_privileged(); sp_init_vga(); spcf_pre_check_options(argc, argv); check_params(argc, argv); sp_init(); start_spectemu(); /* This function DOES NOT return */ return 0; }
/* * i2c_write - Write to i2c memory * @chip: target i2c address * @addr: address to read from * @alen: * @buffer: buffer for read data * @len: no of bytes to be read * * Write to i2c memory. */ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) { int nb = len; unsigned long start_time_tx; #ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW /* * EEPROM chips that implement "address overflow" are ones * like Catalyst 24WC04/08/16 which has 9/10/11 bits of * address and the extra bits end up in the "chip address" * bit slots. This makes a 24WC08 (1Kbyte) chip look like * four 256 byte chips. * * Note that we consider the length of the address field to * still be one byte because the extra address bits are * hidden in the chip address. */ chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW); addr &= ~(CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW << (alen * 8)); debug("%s: fix addr_overflow: chip %02x addr %02x\n", __func__, chip, addr); #endif if (check_params(addr, alen, buffer, len)) return 1; if (i2c_xfer_init(chip, addr)) return 1; start_time_tx = get_timer(0); while (len) { if (readl(&i2c_regs_p->ic_status) & IC_STATUS_TFNF) { if (--len == 0) writel(*buffer | IC_STOP, &i2c_regs_p->ic_cmd_data); else writel(*buffer, &i2c_regs_p->ic_cmd_data); buffer++; start_time_tx = get_timer(0); } else if (get_timer(start_time_tx) > (nb * I2C_BYTE_TO)) { printf("Timed out. i2c write Failed\n"); return 1; } } return i2c_xfer_finish(); }
EmObject * bltin_list(EmObject *self, EmObject *v) { static BltinmethodParamsDesc desc = { -1, 0, "size value", }; EmObject *pparams, *keywords; EmObject *kw, *item; EmObject *retval; int ii, size; if (check_params(&desc, v) == 0) { return NULL; } if (v == &nulobj) { retval = newlistobject(0); } else { pparams = listobject_get(v, 0); keywords = listobject_get(v, 1); size = listobject_len(pparams); if (keywords != &nulobj) { kw = hashobject_lookup_by_string(keywords, "size"); if (kw != NULL) { if (size < ((EmIntObject *) kw)->ival) { size = ((EmIntObject *) kw)->ival; } DECREF(kw); } } retval = newlistobject_of_null(size); if (keywords != &nulobj) { kw = hashobject_lookup_by_string(keywords, "value"); if (kw != NULL) { for (ii=0;ii<listobject_len(retval);ii++) { listobject_set(retval, ii, kw); } DECREF(kw); } } for (ii=0;ii<listobject_len(pparams);ii++) { item = listobject_get(pparams, ii); listobject_set(retval, ii, item); DECREF(item); } DECREF(pparams); DECREF(keywords); } return retval; }
int main(int argc, char **argv){ int res = 0, code; char *file_name; char *operation; char *entidad; printf("\n\033[1;37m Tp0 - Cargador Masivo\n"); printf(" ---------------------\n\033[0m"); res = check_params(argc, 0); if(res == RES_OK){ operation = argv[1]; res = UNKNOWN_PARAM; if (strncmp(operation, "-i", 2) == 0 ){ res = check_params(argc, 4); if(res == RES_OK){ entidad = argv[2]; file_name = argv[3]; res = load_data(file_name, entidad); } } if (strncmp(operation, "-l", 2) == 0 ){ res = check_params(argc, 3); if(res == RES_OK){ entidad = argv[2]; res = list_data(entidad); } } if (strncmp(operation, "-k", 2) == 0 ){ res = check_params(argc, 4); if(res == RES_OK){ code = atoi(argv[2]); entidad = argv[3]; res = search_by_code(entidad, code); } } if (strncmp(operation, "-ok", 3) == 0 ){ res = check_params(argc, 3); if(res == RES_OK){ entidad = argv[2]; res = order_by_code(entidad); } } if (strncmp(operation, "-on", 3) == 0 ){ res = check_params(argc, 3); if(res == RES_OK){ entidad = argv[2]; res = order_by_name(entidad); } } } error_handler(res); return res; }
int main(int argc, char **argv) { if (argc != 5) { printf("ERROR: incorrect number of parameters."); printf("usage: ./cmd_proc <NodeA> <NodeB> <code> <weight>\n"); exit(0); } if (!check_params(argc, argv)) { exit(0); } return 0; }
/* * Send a transactional request, no dialogs involved */ int request(str* m, str* ruri, str* to, str* from, str* h, str* b, str *next_hop, transaction_cb c, void* cp) { str callid, fromtag; dlg_t* dialog; int res; if (check_params(m, to, from, &dialog) < 0) goto err; generate_callid(&callid); generate_fromtag(&fromtag, &callid); if (new_dlg_uac(&callid, &fromtag, DEFAULT_CSEQ, from, to, &dialog) < 0) { LOG(L_ERR, "request(): Error while creating temporary dialog\n"); goto err; } if (ruri) { dialog->rem_target.s = ruri->s; dialog->rem_target.len = ruri->len; /* hooks will be set from w_calculate_hooks */ } if (next_hop) dialog->dst_uri = *next_hop; w_calculate_hooks(dialog); /* WARNING: * to be clean it should be called * set_dlg_target(dialog, ruri, next_hop); * which sets both uris if given [but it duplicates them in shm!] * * but in this case the _ruri parameter in set_dlg_target * must be optional (it is needed now) and following hacks * dialog->rem_target.s = 0; * dialog->dst_uri.s = 0; * before freeing dialog here must be removed */ res = t_uac(m, h, b, dialog, c, cp); dialog->rem_target.s = 0; dialog->dst_uri.s = 0; free_dlg(dialog); return res; err: if (cp) shm_free(cp); return -1; }
int gpio_write(int port, int pin, int status) { if (check_params(port, pin)) { return -1; } const unsigned int *bitmask = get_bitmask(port); volatile int position; position = get_index(port, pin); if ((position < 0) || (position >= GPIO_ADDRESS_MAX)) { fprintf(stderr,"error: invalid position: %d\n", position); return -1; } status = ((status == GPIO_ON) ? GPIO_SETDATAOUT : GPIO_CLEARDATAOUT); *((unsigned int *)((void *)gpio.address[position] + status)) = bitmask[pin]; return 0; }
int init_params(int ac, char **av) { char t_nbr[2]; srandom(time(0) * getpid()); if (ac != 3) fprintf(stderr, USAGE_MSG); if (ac < 2) { t_nbr[0] = random() % 6 + 1 + 48; t_nbr[1] = '\0'; av[1] = t_nbr; } if (ac < 3) av[2] = "20"; return (check_params(av[1], av[2])); }