本文整理汇总了C++中parse_integer函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_integer函数的具体用法?C++ parse_integer怎么用?C++ parse_integer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_integer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmd_xmem
cmd_result_t
cmd_xmem(int unit, args_t *a)
{
char *token;
unsigned int addr, data;
if ((token = ARG_GET(a)) == NULL) {
return CMD_USAGE;
}
if (sal_strcasecmp(token, "r") == 0) {
if ((token = ARG_GET(a)) == NULL) {
return CMD_USAGE;
}
addr = parse_integer(token);
cli_out("0x%x: %08x\n", addr, *((unsigned int *)(INT_TO_PTR(addr))));
} else if (sal_strcasecmp(token, "w") == 0) {
if ((token = ARG_GET(a)) == NULL) {
return CMD_USAGE;
}
addr = parse_integer(token);
if ((token = ARG_GET(a)) == NULL) {
return CMD_USAGE;
}
data = parse_integer(token);
*((unsigned int *)(INT_TO_PTR(addr))) = data;
} else {
cli_out(cmd_xmem_usage);
return CMD_FAIL;
}
return CMD_OK;
}
示例2: DSA_new
DSA *DSA_parse_private_key(CBS *cbs) {
DSA *ret = DSA_new();
if (ret == NULL) {
return NULL;
}
CBS child;
uint64_t version;
if (!CBS_get_asn1(cbs, &child, CBS_ASN1_SEQUENCE) ||
!CBS_get_asn1_uint64(&child, &version)) {
OPENSSL_PUT_ERROR(DSA, DSA_R_DECODE_ERROR);
goto err;
}
if (version != 0) {
OPENSSL_PUT_ERROR(DSA, DSA_R_BAD_VERSION);
goto err;
}
if (!parse_integer(&child, &ret->p) ||
!parse_integer(&child, &ret->q) ||
!parse_integer(&child, &ret->g) ||
!parse_integer(&child, &ret->pub_key) ||
!parse_integer(&child, &ret->priv_key) ||
CBS_len(&child) != 0) {
OPENSSL_PUT_ERROR(DSA, DSA_R_DECODE_ERROR);
goto err;
}
return ret;
err:
DSA_free(ret);
return NULL;
}
示例3: cmd_setfanspeed
cmd_result_t
cmd_setfanspeed(int unit, args_t *a)
{
char *d = ARG_GET(a);
char *s = ARG_GET(a);
int devno = -1, speed = -1;
int retv;
if (!sh_check_attached(ARG_CMD(a), unit))
return CMD_FAIL;
if (d) {
devno = parse_integer(d);
}
if (s) {
speed = parse_integer(s);
}
if ((devno < 0) || (devno > 7) || (speed < 0) || (speed > 15)) {
return CMD_USAGE;
}
retv = soc_bsc_max6653_set(unit, devno, speed);
if (retv) {
sal_printf("%s failed\n", FUNCTION_NAME());
return CMD_FAIL;
}
return CMD_OK;
}
示例4: resource_parse_line
static cairo_bool_t
resource_parse_line (char *name, cairo_xcb_resources_t *resources)
{
char *value;
value = strchr (name, ':');
if (value == NULL)
return FALSE;
*value++ = 0;
name = skip_spaces (name);
value = skip_spaces (value);
if (strcmp (name, "Xft.antialias") == 0)
parse_boolean (value, &(resources->xft_antialias));
else if (strcmp (name, "Xft.lcdfilter") == 0)
parse_integer (value, &(resources->xft_lcdfilter));
else if (strcmp (name, "Xft.rgba") == 0)
parse_integer (value, &(resources->xft_rgba));
else if (strcmp (name, "Xft.hinting") == 0)
parse_boolean (value, &(resources->xft_hinting));
else if (strcmp (name, "Xft.hintstyle") == 0)
parse_integer (value, &(resources->xft_hintstyle));
return TRUE;
}
示例5: parse_environment_vars
/**
* Parse environment variables
*/
void parse_environment_vars(parallel_wrapper *par_wrapper)
{
char *value = NULL;
value = getenv("_CONDOR_PROCNO");
parse_integer(value, &par_wrapper -> this_machine -> rank);
value = getenv("_CONDOR_NPROCS");
parse_integer(value, &par_wrapper -> num_procs);
return;
}
示例6: pxebs_exec
/**
* The "pxebs" command
*
* @v argc Argument count
* @v argv Argument list
* @ret rc Return status code
*/
static int pxebs_exec ( int argc, char **argv ) {
struct pxebs_options opts;
struct net_device *netdev;
unsigned int pxe_type;
int rc;
/* Parse options */
if ( ( rc = parse_options ( argc, argv, &pxebs_cmd, &opts ) ) != 0 )
return rc;
/* Parse net device name */
if ( ( rc = parse_netdev ( argv[optind], &netdev ) ) != 0 )
return rc;
/* Parse boot server type */
if ( ( rc = parse_integer ( argv[ optind + 1 ], &pxe_type ) ) != 0 )
return rc;
/* Perform Boot Server Discovery */
if ( ( rc = pxebs ( netdev, pxe_type ) ) != 0 ) {
printf ( "Could not discover boot server on %s: %s\n",
netdev->name, strerror ( rc ) );
return rc;
}
return 0;
}
示例7: get_current_quota
/** Retrieve the amount of quote remaining to a player.
* Figure out a player's quota. Add the RQUOTA attribute if he doesn't
* have one already. This function returns the REMAINING quota, not
* the TOTAL limit.
* \param who player to check.
* \return player's remaining quota.
*/
int
get_current_quota(dbref who)
{
ATTR *a;
int i;
int limit;
int owned = 0;
/* if he's got an RQUOTA attribute, his remaining quota is that */
a = atr_get_noparent(Owner(who), "RQUOTA");
if (a)
return parse_integer(atr_value(a));
/* else, count up his objects. If he has less than the START_QUOTA,
* then his remaining quota is that minus his number of current objects.
* Otherwise, it's his current number of objects. Add the attribute
* if he doesn't have it.
*/
for (i = 0; i < db_top; i++)
if (Owner(i) == Owner(who))
owned++;
owned--; /* don't count the player himself */
if (owned <= START_QUOTA)
limit = START_QUOTA - owned;
else
limit = owned;
(void) atr_add(Owner(who), "RQUOTA", tprintf("%d", limit), GOD, 0);
return limit;
}
示例8: stream_peek
static json_t *parse_value(stream_t *stream, size_t flags, json_error_t *error)
{
json_t *result = NULL;
char *string;
int c = stream_peek(stream);
switch (c) {
case 'd':
result = parse_dict(stream, flags, error);
break;
case 'l':
result = parse_list(stream, flags, error);
break;
case 'i':
stream_getc(stream);
result = parse_integer(stream, flags, error);
break;
case EOF:
error_set(error, stream, "unexpected EOF");
break;
default:
if (json_isdigit(c)) {
string = parse_string(stream, flags, error);
if (string) {
result = json_string_nocheck(string);
jsonp_free(string);
}
} else {
error_set(error, stream, "invalid character: %c", c);
}
}
return result;
}
示例9: skip_whitespace
/**
* Parse the number term 's' and return its resulting value in 'value'.
* Return a pointer behind the last character of the expression.
* Return NULL if a syntax error occurred.
*/
char *parse_number_term(char *s, int *value) {
unsigned char token;
s = skip_whitespace(s);
token = next_token(s);
if (token == TOKEN_DIGITS || token == TOKEN_PLUS || token == TOKEN_MINUS) {
if (s = parse_integer(s, value)) {
return s;
} else {
syntax_error_invalid_number();
}
} else if (token == TOKEN_VAR_NUMBER) {
unsigned int var_name;
unsigned char var_type;
variable *var;
s = parse_variable(s, &var_name, &var_type);
var = find_variable(var_name, VAR_TYPE_INTEGER, NULL);
if (var) {
*value = get_integer_variable_value(var);
return s;
} else {
syntax_error_msg("Variable not found");
}
} else {
syntax_error();
}
return NULL;
}
示例10: u_comp
/** qsort() comparision routine used by sortby() */
int
u_comp(const void *s1, const void *s2)
{
char result[BUFFER_LEN], *rp;
char const *tbuf;
int n;
/* Our two arguments are passed as %0 and %1 to the sortby u-function. */
/* Note that this function is for use in conjunction with our own
* sane_qsort routine, NOT with the standard library qsort!
*/
global_eval_context.wenv[0] = (char *) s1;
global_eval_context.wenv[1] = (char *) s2;
/* Run the u-function, which should return a number. */
tbuf = ucomp_buff;
rp = result;
if (process_expression(result, &rp, &tbuf,
ucomp_executor, ucomp_caller, ucomp_enactor,
PE_DEFAULT, PT_DEFAULT, ucomp_pe_info))
return 0;
n = parse_integer(result);
return n;
}
示例11: parse_integer
uintmax_t
parse_integer (const char *str, gboolean * invalid)
{
uintmax_t n;
char *suffix;
strtol_error_t e;
e = xstrtoumax (str, &suffix, 10, &n, "bcEGkKMPTwYZ0");
if (e == LONGINT_INVALID_SUFFIX_CHAR && *suffix == 'x')
{
uintmax_t multiplier;
multiplier = parse_integer (suffix + 1, invalid);
if (multiplier != 0 && n * multiplier / multiplier != n)
{
*invalid = TRUE;
return 0;
}
n *= multiplier;
}
else if (e != LONGINT_OK)
{
*invalid = TRUE;
n = 0;
}
return n;
}
示例12: parse_value
static struct buffer parse_value(struct buffer buff,
struct rmsgpack_dom_value *value, const char **error)
{
buff = chomp(buff);
if (peek(buff, "nil"))
{
buff.offset += strlen("nil");
value->type = RDT_NULL;
}
else if (peek(buff, "true"))
{
buff.offset += strlen("true");
value->type = RDT_BOOL;
value->val.bool_ = 1;
}
else if (peek(buff, "false"))
{
buff.offset += strlen("false");
value->type = RDT_BOOL;
value->val.bool_ = 0;
}
else if (peek(buff, "b") || peek(buff, "\"") || peek(buff, "'"))
buff = parse_string(buff, value, error);
else if (isdigit((int)buff.data[buff.offset]))
buff = parse_integer(buff, value, error);
return buff;
}
示例13: RSA_new
RSA *RSA_parse_public_key(CBS *cbs) {
RSA *ret = RSA_new();
if (ret == NULL) {
return NULL;
}
CBS child;
if (!CBS_get_asn1(cbs, &child, CBS_ASN1_SEQUENCE) ||
!parse_integer(&child, &ret->n) ||
!parse_integer(&child, &ret->e) ||
CBS_len(&child) != 0) {
OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_ENCODING);
RSA_free(ret);
return NULL;
}
return ret;
}
示例14: DSA_SIG_new
DSA_SIG *DSA_SIG_parse(CBS *cbs) {
DSA_SIG *ret = DSA_SIG_new();
if (ret == NULL) {
return NULL;
}
CBS child;
if (!CBS_get_asn1(cbs, &child, CBS_ASN1_SEQUENCE) ||
!parse_integer(&child, &ret->r) ||
!parse_integer(&child, &ret->s) ||
CBS_len(&child) != 0) {
OPENSSL_PUT_ERROR(DSA, DSA_R_DECODE_ERROR);
DSA_SIG_free(ret);
return NULL;
}
return ret;
}
示例15: next_token
void OrderPropertyParser::parse(StylePropertySetter *setter, const std::string &name, StyleParser &parser)
{
auto &tokens = parser.tokens;
StyleSetValue order;
size_t pos = 0;
StyleToken token = next_token(pos, tokens);
if (token.type == StyleTokenType::ident && pos == tokens.size())
{
if (equals(token.value, "inherit"))
order = StyleSetValue::from_keyword("inherit");
else
return;
}
else if (token.type == StyleTokenType::number && pos == tokens.size())
{
int value = 0;
if (parse_integer(token.value, value))
{
order = StyleSetValue::from_number((float)value);
}
else
{
return;
}
}
else
{
return;
}
setter->set_value("order", order);
}