这篇教程C++ EI_TRACE_ERR0函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EI_TRACE_ERR0函数的典型用法代码示例。如果您正苦于以下问题:C++ EI_TRACE_ERR0函数的具体用法?C++ EI_TRACE_ERR0怎么用?C++ EI_TRACE_ERR0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EI_TRACE_ERR0函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ei_unpublish_tmo/* stop the specified node */int ei_unpublish_tmo(const char *alive, unsigned ms){ char buf[EPMDBUF]; char *s = (char*)buf; int len = 1 + strlen(alive); int fd, res; if (len > sizeof(buf)-3) { erl_errno = ERANGE; return -1; } put16be(s,len); put8(s,EI_EPMD_STOP_REQ); strcpy(s, alive); /* FIXME can't connect, return success?! At least commen whats up */ if ((fd = ei_epmd_connect_tmo(NULL,ms)) < 0) return fd; if ((res = ei_write_fill_t(fd, buf, len+2,ms)) != len+2) { closesocket(fd); erl_errno = (res == -2) ? ETIMEDOUT : EIO; return -1; } EI_TRACE_CONN1("ei_unpublish_tmo","-> STOP %s",alive); if ((res = ei_read_fill_t(fd, buf, 7, ms)) != 7) { closesocket(fd); erl_errno = (res == -2) ? ETIMEDOUT : EIO; return -1; } closesocket(fd); buf[7]=(char)0; /* terminate the string */ if (!strcmp("STOPPED",(char *)buf)) { EI_TRACE_CONN0("ei_unpublish_tmo","<- STOPPED (success)"); return 0; } else if (!strcmp("NOEXIST",(char *)buf)) { EI_TRACE_ERR0("ei_unpublish_tmo","<- NOEXIST (failure)"); erl_errno = EIO; return -1; } else { EI_TRACE_ERR0("ei_unpublish_tmo","<- unknown (failure)"); erl_errno = EIO; return -1; /* this shouldn't happen */ } return 0;}
开发者ID:Bwooce,项目名称:otp,代码行数:52,
示例2: initWinSockstatic int initWinSock(void){ WORD wVersionRequested; WSADATA wsaData; int i; static LONG volatile initialized = 0; wVersionRequested = MAKEWORD(1, 1); if (InterlockedCompareExchange((LPLONG) &initialized,1L,0L) == 0L) { /* FIXME not terminate, just a message?! */ if ((i = WSAStartup(wVersionRequested, &wsaData))) { EI_TRACE_ERR1("ei_connect_init", "ERROR: can't initialize windows sockets: %d",i); initialized = 2L; return 0; } if (LOBYTE(wsaData.wVersion) != 1 || HIBYTE(wsaData.wVersion) != 1) { EI_TRACE_ERR0("initWinSock","ERROR: this version of windows " "sockets not supported"); WSACleanup(); initialized = 2L; return 0; } initialized = 3L; } else while (initialized < 2) { SwitchToThread(); } return (int) (initialized - 2);}
开发者ID:616050468,项目名称:otp,代码行数:31,
示例3: send_challenge_ackstatic int send_challenge_ack(int fd, unsigned char digest[16], unsigned ms) { char *s; char buf[DEFBUF_SIZ]; int siz = 2 + 1 + 16; int res; s = buf; put16be(s,siz - 2); put8(s, 'a'); memcpy(s, digest, 16); if ((res = ei_write_fill_t(fd, buf, siz, ms)) != siz) { EI_TRACE_ERR0("recv_challenge_reply", "-> SEND_CHALLENGE_ACK socket write failed"); erl_errno = (res == -2) ? ETIMEDOUT : EIO; return -1; } if (ei_tracelevel >= 3) { char buffer[33]; EI_TRACE_CONN1("recv_challenge_reply", "-> SEND_CHALLENGE_ACK (ok) digest = %s",hex((char *)digest,buffer)); } return 0;}
开发者ID:616050468,项目名称:otp,代码行数:28,
示例4: send_statusstatic int send_status(int fd, char *status, unsigned ms){ char *buf, *s; char dbuf[DEFBUF_SIZ]; int siz = strlen(status) + 1 + 2; int res; buf = (siz > DEFBUF_SIZ) ? malloc(siz) : dbuf; if (!buf) { erl_errno = ENOMEM; return -1; } s = buf; put16be(s,siz - 2); put8(s, 's'); memcpy(s, status, strlen(status)); if ((res = ei_write_fill_t(fd, buf, siz, ms)) != siz) { EI_TRACE_ERR0("send_status","-> SEND_STATUS socket write failed"); if (buf != dbuf) free(buf); erl_errno = (res == -2) ? ETIMEDOUT : EIO; return -1; } EI_TRACE_CONN1("send_status","-> SEND_STATUS (%s)",status); if (buf != dbuf) free(buf); return 0;}
开发者ID:616050468,项目名称:otp,代码行数:29,
示例5: recv_challenge_replystatic int recv_challenge_reply (int fd, unsigned our_challenge, char cookie[], unsigned *her_challenge, unsigned ms){ char dbuf[DEFBUF_SIZ]; char *buf = dbuf; int is_static = 1; int buflen = DEFBUF_SIZ; int rlen; char *s; char tag; char her_digest[16], expected_digest[16]; erl_errno = EIO; /* Default */ if ((rlen = read_2byte_package(fd, &buf, &buflen, &is_static, ms)) != 21) { EI_TRACE_ERR1("recv_challenge_reply", "<- RECV_CHALLENGE_REPLY socket read failed (%d)",rlen); goto error; } s = buf; if ((tag = get8(s)) != 'r') { EI_TRACE_ERR2("recv_challenge_reply", "<- RECV_CHALLENGE_REPLY incorrect tag, " "expected 'r' got '%c' (%u)",tag,tag); goto error; } *her_challenge = get32be(s); memcpy(her_digest, s, 16); gen_digest(our_challenge, cookie, (unsigned char*)expected_digest); if (memcmp(her_digest, expected_digest, 16)) { EI_TRACE_ERR0("recv_challenge_reply", "<- RECV_CHALLENGE_REPLY authorization failure"); goto error; } if (!is_static) free(buf); if (ei_tracelevel >= 3) { char buffer[33]; EI_TRACE_CONN2("recv_challenge_reply", "<- RECV_CHALLENGE_REPLY (ok) challenge = %u, digest = %s", *her_challenge,hex(her_digest,buffer)); } erl_errno = 0; return 0; error: if (!is_static) free(buf); return -1;}
开发者ID:616050468,项目名称:otp,代码行数:56,
示例6: ei_accept_tmoint ei_accept_tmo(ei_cnode* ec, int lfd, ErlConnect *conp, unsigned ms){ int fd; struct sockaddr_in cli_addr; int cli_addr_len=sizeof(struct sockaddr_in); unsigned her_version, her_flags; ErlConnect her_name; erl_errno = EIO; /* Default error code */ EI_TRACE_CONN0("ei_accept","<- ACCEPT waiting for connection"); if ((fd = ei_accept_t(lfd, (struct sockaddr*) &cli_addr, &cli_addr_len, ms )) < 0) { EI_TRACE_ERR0("ei_accept","<- ACCEPT socket accept failed"); erl_errno = (fd == -2) ? ETIMEDOUT : EIO; goto error; } EI_TRACE_CONN0("ei_accept","<- ACCEPT connected to remote"); if (recv_name(fd, &her_version, &her_flags, &her_name, ms)) { EI_TRACE_ERR0("ei_accept","<- ACCEPT initial ident failed"); goto error; } if (her_version <= 4) { EI_TRACE_ERR0("ei_accept","<- ACCEPT remote version not compatible"); goto error; } else { unsigned our_challenge; unsigned her_challenge; unsigned char our_digest[16]; if (send_status(fd,"ok", ms)) goto error; our_challenge = gen_challenge(); if (send_challenge(fd, ec->thisnodename, our_challenge, her_version, ms)) goto error; if (recv_challenge_reply(fd, our_challenge, ec->ei_connect_cookie, &her_challenge, ms)) goto error; gen_digest(her_challenge, ec->ei_connect_cookie, our_digest); if (send_challenge_ack(fd, our_digest, ms)) goto error; put_ei_socket_info(fd, her_version, null_cookie, ec); } if (conp) *conp = her_name; EI_TRACE_CONN1("ei_accept","<- ACCEPT (ok) remote = %s",her_name.nodename); erl_errno = 0; /* No error */ return fd; error: EI_TRACE_ERR0("ei_accept","<- ACCEPT failed"); closesocket(fd); return ERL_ERROR;} /* ei_accept */
开发者ID:616050468,项目名称:otp,代码行数:63,
示例7: ei_xconnect_tmo /* ip_addr is now in network byte order * * first we have to get hold of the portnumber to * the node through epmd at that host **/int ei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned ms){ struct in_addr *ip_addr=(struct in_addr *) adr; int rport = 0; /*uint16 rport = 0;*/ int sockd; int one = 1; int dist = 0; ErlConnect her_name; unsigned her_flags, her_version; erl_errno = EIO; /* Default error code */ EI_TRACE_CONN1("ei_xconnect","-> CONNECT attempt to connect to %s", alivename); if ((rport = ei_epmd_port_tmo(ip_addr,alivename,&dist, ms)) < 0) { EI_TRACE_ERR0("ei_xconnect","-> CONNECT can't get remote port"); /* ei_epmd_port_tmo() has set erl_errno */ return ERL_NO_PORT; } /* we now have port number to enode, try to connect */ if((sockd = cnct((uint16)rport, ip_addr, sizeof(struct in_addr),ms)) < 0) { EI_TRACE_ERR0("ei_xconnect","-> CONNECT socket connect failed"); /* cnct() has set erl_errno */ return ERL_CONNECT_FAIL; } EI_TRACE_CONN0("ei_xconnect","-> CONNECT connected to remote"); /* FIXME why connect before checking 'dist' output from ei_epmd_port() ?! */ if (dist <= 4) { EI_TRACE_ERR0("ei_xconnect","-> CONNECT remote version not compatible"); goto error; } else { unsigned our_challenge, her_challenge; unsigned char our_digest[16]; if (send_name(sockd, ec->thisnodename, (unsigned) dist, ms)) goto error; if (recv_status(sockd, ms)) goto error; if (recv_challenge(sockd, &her_challenge, &her_version, &her_flags, &her_name, ms)) goto error; our_challenge = gen_challenge(); gen_digest(her_challenge, ec->ei_connect_cookie, our_digest); if (send_challenge_reply(sockd, our_digest, our_challenge, ms)) goto error; if (recv_challenge_ack(sockd, our_challenge, ec->ei_connect_cookie, ms)) goto error; put_ei_socket_info(sockd, dist, null_cookie, ec); /* FIXME check == 0 */ } setsockopt(sockd, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one)); setsockopt(sockd, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, sizeof(one)); EI_TRACE_CONN1("ei_xconnect","-> CONNECT (ok) remote = %s",alivename); erl_errno = 0; return sockd; error: EI_TRACE_ERR0("ei_xconnect","-> CONNECT failed"); closesocket(sockd); return ERL_ERROR;} /* ei_xconnect */
开发者ID:616050468,项目名称:otp,代码行数:75,
示例8: ei_connect_tmo /* * Set up a connection to a given Node, and * interchange hand shake messages with it. * Returns a valid file descriptor at success, * otherwise a negative error code.*/int ei_connect_tmo(ei_cnode* ec, char *nodename, unsigned ms){ char *hostname, alivename[BUFSIZ]; struct hostent *hp;#if !defined (__WIN32__) /* these are needed for the call to gethostbyname_r */ struct hostent host; char buffer[1024]; int ei_h_errno;#endif /* !win32 */ /* extract the host and alive parts from nodename */ if (!(hostname = strchr(nodename,'@'))) { EI_TRACE_ERR0("ei_connect","Node name has no @ in name"); return ERL_ERROR; } else { strncpy(alivename, nodename, hostname - nodename); alivename[hostname - nodename] = 0x0; hostname++; } #ifndef __WIN32__ hp = ei_gethostbyname_r(hostname,&host,buffer,1024,&ei_h_errno); if (hp == NULL) { char thishostname[EI_MAXHOSTNAMELEN+1]; if (gethostname(thishostname,EI_MAXHOSTNAMELEN) < 0) { EI_TRACE_ERR0("ei_connect_tmo", "Failed to get name of this host"); erl_errno = EHOSTUNREACH; return ERL_ERROR; } else { char *ct; /* We use a short node name */ if ((ct = strchr(thishostname, '.')) != NULL) *ct = '/0'; } if (strcmp(hostname,thishostname) == 0) /* Both nodes on same standalone host, use loopback */ hp = ei_gethostbyname_r("localhost",&host,buffer,1024,&ei_h_errno); if (hp == NULL) { EI_TRACE_ERR2("ei_connect", "Can't find host for %s: %d/n",nodename,ei_h_errno); erl_errno = EHOSTUNREACH; return ERL_ERROR; } }#else /* __WIN32__ */ if ((hp = ei_gethostbyname(hostname)) == NULL) { char thishostname[EI_MAXHOSTNAMELEN+1]; if (gethostname(thishostname,EI_MAXHOSTNAMELEN) < 0) { EI_TRACE_ERR1("ei_connect_tmo", "Failed to get name of this host: %d", WSAGetLastError()); erl_errno = EHOSTUNREACH; return ERL_ERROR; } else { char *ct; /* We use a short node name */ if ((ct = strchr(thishostname, '.')) != NULL) *ct = '/0'; } if (strcmp(hostname,thishostname) == 0) /* Both nodes on same standalone host, use loopback */ hp = ei_gethostbyname("localhost"); if (hp == NULL) { char reason[1024]; win32_error(reason,sizeof(reason)); EI_TRACE_ERR2("ei_connect", "Can't find host for %s: %s",nodename,reason); erl_errno = EHOSTUNREACH; return ERL_ERROR; } }#endif /* win32 */ return ei_xconnect_tmo(ec, (Erl_IpAddr) *hp->h_addr_list, alivename, ms);} /* ei_connect */
开发者ID:616050468,项目名称:otp,代码行数:80,
示例9: ei_connect_init/** Initialize by set: thishostname, thisalivename, * thisnodename and thisipaddr. At success return 0,* otherwise return -1.*/int ei_connect_init(ei_cnode* ec, const char* this_node_name, const char *cookie, short creation){ struct hostent *hp; char thishostname[EI_MAXHOSTNAMELEN+1]; char thisnodename[MAXNODELEN+1]; char thisalivename[EI_MAXALIVELEN+1];#ifdef __WIN32__ if (!initWinSock()) { EI_TRACE_ERR0("ei_connect_xinit","can't initiate winsock"); return ERL_ERROR; }#endif /* win32 */#ifdef _REENTRANT if (ei_sockets_lock == NULL) { ei_sockets_lock = ei_mutex_create(); }#endif /* _REENTRANT */ if (gethostname(thishostname, EI_MAXHOSTNAMELEN) == -1) {#ifdef __WIN32__ EI_TRACE_ERR1("ei_connect_init","Failed to get host name: %d", WSAGetLastError());#else EI_TRACE_ERR1("ei_connect_init","Failed to get host name: %d", errno);#endif /* win32 */ return ERL_ERROR; } if (this_node_name == NULL) { sprintf(thisalivename, "c%d", (int) getpid()); } else if (strlen(this_node_name) >= sizeof(thisalivename)) { EI_TRACE_ERR0("ei_connect_init","ERROR: this_node_name too long"); return ERL_ERROR; } else { strcpy(thisalivename, this_node_name); } if ((hp = ei_gethostbyname(thishostname)) == 0) { /* Looking up IP given hostname fails. We must be on a standalone host so let's use loopback for communication instead. */ if ((hp = ei_gethostbyname("localhost")) == 0) {#ifdef __WIN32__ char reason[1024]; win32_error(reason,sizeof(reason)); EI_TRACE_ERR2("ei_connect_init", "Can't get ip address for host %s: %s", thishostname, reason);#else EI_TRACE_ERR2("ei_connect_init", "Can't get ip address for host %s: %d", thishostname, h_errno);#endif /* win32 */ return ERL_ERROR; } } { char* ct; if (strcmp(hp->h_name, "localhost") == 0) { /* We use a short node name */ if ((ct = strchr(thishostname, '.')) != NULL) *ct = '/0'; sprintf(thisnodename, "%[email C++ EI_TRACE_ERR1函数代码示例 C++ EINA_SAFETY_ON_NULL_RETURN_VAL函数代码示例
|