コード例 #1
0
/* CURLMOPT_SOCKETFUNCTION */
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) {
    std::cout << std::endl << __PRETTY_FUNCTION__ << " called" << std::endl;
    fprintf(MSG_OUT, "\nsock_cb: socket=%d, what=%d, sockp=%p", s, what, sockp);

    GlobalInfo *g = (GlobalInfo*) cbp;
    int *actionp = (int *) sockp;
    const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" };

    fprintf(MSG_OUT, "\nsocket callback: s=%d e=%p what=%s ", s, e,
            whatstr[what]);

    if (what == CURL_POLL_REMOVE) {
        fprintf(MSG_OUT, "\n");
        remsock(actionp, g);
    } else {
        if (!actionp) {
            fprintf(MSG_OUT, "\nAdding data: %s", whatstr[what]);
            addsock(s, e, what, g);
        } else {
            fprintf(MSG_OUT, "\nChanging action from %s to %s",
                    whatstr[*actionp], whatstr[what]);
            setsock(actionp, s, e, what, *actionp, g);
        }
    }

    return 0;
}
コード例 #2
0
/* CURLMOPT_SOCKETFUNCTION */
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
  GlobalInfo *g = (GlobalInfo*) cbp;
  SockInfo *fdp = (SockInfo*) sockp;
  const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };

  fprintf(MSG_OUT,
          "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
  if (what == CURL_POLL_REMOVE) {
    fprintf(MSG_OUT, "\n");
    remsock(fdp);
  }
  else {
    if (!fdp) {
      fprintf(MSG_OUT, "Adding data: %s\n", whatstr[what]);
      addsock(s, e, what, g);
    }
    else {
      fprintf(MSG_OUT,
              "Changing action from %s to %s\n",
              whatstr[fdp->action], whatstr[what]);
      setsock(fdp, s, e, what, g);
    }
  }
  return 0;
}
コード例 #3
0
ファイル: ghiper.c プロジェクト: Aakanksha/c-twitter
/* CURLMOPT_SOCKETFUNCTION */
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
  GlobalInfo *g = (GlobalInfo*) cbp;
  SockInfo *fdp = (SockInfo*) sockp;
  static const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" };

  MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]);
  if (what == CURL_POLL_REMOVE) {
    MSG_OUT("\n");
    remsock(fdp);
  } else {
    if (!fdp) {
      MSG_OUT("Adding data: %s%s\n",
             what&CURL_POLL_IN?"READ":"",
             what&CURL_POLL_OUT?"WRITE":"" );
      addsock(s, e, what, g);
    }
    else {
      MSG_OUT(
        "Changing action from %d to %d\n", fdp->action, what);
      setsock(fdp, s, e, what, g);
    }
  }
  return 0;
}
コード例 #4
0
ファイル: spider.c プロジェクト: codeape/polyorc
/* Notifies about updates on a socket file descriptor */
static int sock_cb(CURL *handle, curl_socket_t curl_soc, int what, void *cbp,
                   void *sockp)
{
    orcout(orcm_debug, "%s handle %p curl_soc %i what %i cbp %p sockp %p\n",
         __PRETTY_FUNCTION__, handle, curl_soc, what, cbp, sockp);
    global_info *global = (global_info *)cbp;
    sock_info *soc = (sock_info *)sockp;
    const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" };

    orcout(orcm_debug, "socket callback: s=%d e=%p what=%s ",
           curl_soc, handle, whatstr[what]);
    if (what == CURL_POLL_REMOVE) {
        orcout(orcm_debug, "\n");
        remsock(soc, global);
    } else {
        if (!soc) {
            orcout(orcm_debug, "Adding data: %s\n", whatstr[what]);
            addsock(curl_soc, handle, what, global);
        } else {
            orcout(orcm_debug, "Changing action from %s to %s\n",
                   whatstr[soc->action], whatstr[what]);
            setsock(soc, curl_soc, handle, what, global);
        }
    }
    return 0;
}