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

Function mime_node_dump

lib_acl_cpp/src/mime/mime.cpp:770–873  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

768}
769
770static void mime_node_dump(const char* from_path, const char* dump_path,
771 MIME_NODE *node, bool decode) {
772 ifstream in;
773 fstream out;
774 string path;
775 char *pbuf;
776 static int i = 0;
777
778 if (!in.open_read(from_path)) {
779 return;
780 }
781
782 path.format("%s/node_%d.txt", dump_path, i++);
783 if (!out.open_trunc(path.c_str())) {
784 logger_error("open %s error(%s)", path.c_str(), last_serror());
785 return;
786 }
787
788 ssize_t dlen = (ssize_t) node->header_end - (ssize_t) node->header_begin;
789
790 out.puts(">---------header begin--------<");
791 long long pos = (long long) in.fseek(node->header_begin, SEEK_SET);
792 pbuf = (char*) acl_mymalloc(dlen);
793 printf(">>>%s: header begin: %ld, end: %ld, len: %ld, pos=%ld\n",
794 __FUNCTION__, (long int) node->header_begin,
795 (long int) node->header_end, (long int) dlen, (long) pos);
796
797 int ret;
798 if ((ret = in.read(pbuf, dlen, true)) < 0) {
799 acl_myfree(pbuf);
800 return;
801 }
802 printf(">>>%s: ret: %d\n", __FUNCTION__, ret);
803
804 out.write(pbuf, ret);
805
806 out.puts(">---------header end----------<");
807 acl_myfree(pbuf);
808
809 dlen = (ssize_t) (node->body_end - node->body_begin);
810 printf(">>>%s: body begin: %ld, end: %ld, len: %ld\r\n",
811 __FUNCTION__, (long int) node->body_begin,
812 (long int) node->body_end, (long int) dlen);
813
814 out.format(">---------body begin(length: %d)----------<\r\n", (int) dlen);
815
816 if (dlen <= 0) {
817 printf(">>>%s: body_begin(%ld) >= body_end(%ld), len: %d\r\n",
818 __FUNCTION__, (long int) node->body_begin,
819 (long int) node->body_end, (int) dlen);
820 out.close();
821 in.close();
822 return;
823 }
824 pos = (long long) in.fseek(node->body_begin, SEEK_SET);
825 if (pos == -1) {
826 printf(">>>%s: fseek error(%s)\r\n", __FUNCTION__,
827 last_serror());

Callers 1

mime_debugMethod · 0.85

Calls 15

putsMethod · 0.80
fseekMethod · 0.80
last_serrorFunction · 0.50
createFunction · 0.50
open_readMethod · 0.45
formatMethod · 0.45
open_truncMethod · 0.45
c_strMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
decode_updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…