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

Method peek_fmt

lib_acl_cpp/src/beanstalk/beanstalk.cpp:607–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

605}
606
607unsigned long long beanstalk::peek_fmt(string& buf, const char* fmt, ...)
608{
609 buf.clear(); // ��Ȼ����������Ҳ����ջ���
610
611 string cmdline(128);
612 va_list ap;
613 va_start(ap, fmt);
614 cmdline.vformat(fmt, ap);
615 va_end(ap);
616
617 ACL_ARGV* tokens = beanstalk_request(cmdline);
618 if (tokens == NULL) {
619 logger_error("'%s' error", cmdline.c_str());
620 return 0;
621 }
622 if (tokens->argc < 3 || strcasecmp(tokens->argv[0], "FOUND")) {
623 errbuf_ = tokens->argv[0];
624 acl_argv_free(tokens);
625 return 0;
626 }
627
628#ifdef MINGW
629 unsigned long long id = (unsigned long long) atol(tokens->argv[1]);
630#else
631 unsigned long long id = (unsigned long long) atoll(tokens->argv[1]);
632#endif
633 unsigned short n = (unsigned short) atoi(tokens->argv[2]);
634 acl_argv_free(tokens);
635
636 if (n == 0) {
637 logger_error("peek data's length 0");
638 errbuf_ = "peek";
639 close();
640 return 0;
641 }
642
643 // ��ȡ�涨���ֽ���
644 if (!conn_.read(buf, n, true)) {
645 logger_error("peek read body failed");
646 errbuf_ = "read";
647 close();
648 return 0;
649 } else if (!conn_.gets(cmdline)) {
650 logger_error("peek: gets last line falied");
651 errbuf_ = "gets";
652 close();
653 return 0;
654 }
655 return id;
656}
657
658unsigned long long beanstalk::peek(string& buf, unsigned long long id)
659{

Callers

nothing calls this directly

Calls 7

acl_argv_freeFunction · 0.85
getsMethod · 0.80
closeFunction · 0.50
clearMethod · 0.45
vformatMethod · 0.45
c_strMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected