const acl_int64* json_node::get_int64(void) const { if (!is_number()) return NULL; const char* txt = get_text(); if (txt == NULL || *txt == 0) return NULL; const_cast<json_node*>(this)->node_val_.n = acl_atoi64(txt); return &node_val_.n; }
static void __update_conf_int64_vars(ACL_CONFIG_INT64_TABLE cit[], const char *name, const char *value) { int i; for (i = 0; cit[i].name != 0; i++) { if (strcasecmp(cit[i].name, name) == 0) *(cit[i].target) = acl_atoi64(value); } }
int http_hdr_res_range(HTTP_HDR_RES *hdr_res, http_off_t *range_from, http_off_t *range_to, http_off_t *total_length) { const char* myname = "http_hdr_res_range"; const char* value; char buf[256], *ptr, *pfrom, *pto; if (hdr_res == NULL) acl_msg_fatal("%s(%d): hdr_res null", myname, __LINE__); if (range_from == NULL) acl_msg_fatal("%s(%d): range_from null", myname, __LINE__); if (range_to == NULL) acl_msg_fatal("%s(%d): range_to null", myname, __LINE__); value = http_hdr_entry_value(&hdr_res->hdr, "Content-Range"); if (value == NULL) return (-1); ACL_SAFE_STRNCPY(buf, value, sizeof(buf)); /* 响应的 Range 数据格式:Content-Range: bytes {range_from}-{range_to}/{total_length} * 其中: {range_from}, {range_to} 的下标是从0开始的 */ /* Content-Range: bytes 2250000-11665200/11665201 */ /* value: bytes 2250000-11665200/11665201 */ if (strncasecmp(buf, "bytes", sizeof("bytes") - 1) != 0) return (-1); ptr = buf + sizeof("bytes") -1; while (*ptr == ' ' || *ptr == '\t') { ptr++; } if (*ptr == 0) return (-1); /* ptr: 2250000-11665200/11665201 */ pfrom = ptr; pto = strchr(pfrom, '-'); if (pto == NULL || pto == pfrom) return (-1); *pto++ = 0; /* pto: 11665200/11665201 */ ptr = strchr(pto, '/'); if (ptr == NULL || ptr == pto) return (-1); *ptr++ = 0; /* pto: 11665200; ptr: 11665201 */ *range_from = acl_atoi64(pfrom); if (*range_from < 0) return (-1); *range_to = acl_atoi64(pto); if (*range_to < 0) return (-1); /* 可选项 */ if (total_length) { *total_length = acl_atoi64(ptr); if (*total_length < 0) return (-1); } return (0); }