MCPcopy Create free account
hub / github.com/acl-dev/acl / load_param

Method load_param

lib_acl_cpp/src/http/http_mime.cpp:41–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void http_mime_node::load_param(const char* path) {
42 ifstream in;
43 if (!in.open_read(path)) {
44 logger_error("open file %s error(%s)", path, last_serror());
45 return;
46 }
47 long long begin = get_bodyBegin();
48 long long end = get_bodyEnd();
49 if (begin < 0 || end < 0) {
50 logger_error("invalid file offset, begin: %d, end: %d",
51 (int) begin, (int) end);
52 return;
53 }
54
55 // ��� begin >= end ��˵���ýڵ�û������ -- zsx, 2019.7.9
56 if (begin >= end) {
57 return;
58 }
59
60 if (in.fseek(begin, SEEK_SET) == -1) {
61 logger_error("fseek file %s error(%s), begin: %d",
62 path, last_serror(), (int) begin);
63 return;
64 }
65
66 size_t len = (size_t) (end - begin);
67 char* buf = (char*) acl_mymalloc(len + 1);
68 if (in.read(buf, len) == -1) {
69 acl_myfree(buf);
70 logger_error("read file %s error(%s)", path, last_serror());
71 return;
72 }
73 buf[len] = 0;
74 char* ptr = buf + len - 1;
75 while (ptr >= buf) {
76 if (*ptr == '\r' || *ptr == '\n' || *ptr == ' ' || *ptr == '\t') {
77 *ptr-- = 0;
78 continue;
79 }
80
81 break;
82 }
83 if (*buf == 0) {
84 acl_myfree(buf);
85 return;
86 }
87
88 char* value = acl_url_decode(buf, NULL);
89 if (value == NULL) {
90 value = buf;
91 } else {
92 acl_myfree(buf);
93 }
94
95 const char* fromCharset = get_charset();
96 const char* toCharset = get_toCharset();
97 if (*fromCharset && toCharset && *toCharset
98 && strcasecmp(fromCharset, toCharset) != 0) {

Callers

nothing calls this directly

Calls 11

acl_url_decodeFunction · 0.85
fseekMethod · 0.80
convertMethod · 0.80
last_serrorFunction · 0.50
get_bodyBeginFunction · 0.50
get_bodyEndFunction · 0.50
get_charsetFunction · 0.50
get_toCharsetFunction · 0.50
open_readMethod · 0.45
readMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected