//------------------------------------------------------------------------------ // // SendFile() - stands-in for system provided sendfile // //------------------------------------------------------------------------------ int32 CSimpleSocket::SendFile(int32 nOutFd, int32 nInFd, off_t *pOffset, int32 nCount) { int32 nOutCount = CSimpleSocket::SocketError; static char szData[SOCKET_SENDFILE_BLOCKSIZE]; int32 nInCount = 0; if (lseek(nInFd, *pOffset, SEEK_SET) == -1) { return -1; } while (nOutCount < nCount) { nInCount = (nCount - nOutCount) < SOCKET_SENDFILE_BLOCKSIZE ? (nCount - nOutCount) : SOCKET_SENDFILE_BLOCKSIZE; if ((read(nInFd, szData, nInCount)) != (int32)nInCount) { return -1; } if ((SEND(nOutFd, szData, nInCount, 0)) != (int32)nInCount) { return -1; } nOutCount += nInCount; } *pOffset += nOutCount; TranslateSocketError(); return nOutCount; }
int act_up(char *param, t_client *client, t_info *info) { (void)param; move_up(client, client->direction, info); SEND(client->buf_write, OK); return (0); }
void echo_connection_handler(schedule* s, void* args) { int connfd = (int)(intptr_t)args; const size_t len = 1024; char buf[len] = { 0 }; while (true) { memset(buf, 0, len); ssize_t n = RECV(connfd, buf, len, 0); if (n <= 0) { printf("RECV return %ld\n", n); break; } cnt += 1; if (cnt % 2) { set_device_online("abc", "xyz", 0); } else { set_device_offline("abc", "xyz"); } printf("receive: %s\n", buf); SEND(connfd, buf, n, 0); } close(connfd); }
void CDPLoginClient::SendCreatePlayer(BYTE nSlot, LPCSTR lpszPlayer/*, LPDWORD adwEquipment*/, BYTE nFace, BYTE nCostume, BYTE nSkinSet, BYTE nHairMesh, DWORD dwHairColor, BYTE nSex, BYTE nJob, BYTE nHeadMesh ) #endif // __2ND_PASSWORD_SYSTEM { BEFORESENDSOLE( ar, PACKETTYPE_CREATE_PLAYER, DPID_UNKNOWN ); #ifdef __GPAUTH_01 ar.WriteString( g_Neuz.m_bGPotatoAuth?g_Neuz.m_szGPotatoNo: g_Neuz.m_szAccount ); #else // __GPAUTH_01 ar.WriteString( g_Neuz.m_szAccount ); #endif // __GPAUTH_01 ar.WriteString( g_Neuz.m_szPassword ); ar << nSlot; if( strlen( lpszPlayer ) > 16 ) Error( "CDPLoginClient::SendCreatePlayer에서 이상 캐릭터 명 E: %s", lpszPlayer ); ar.WriteString( lpszPlayer ); if( strlen( lpszPlayer ) > 16 ) Error( "CDPLoginClient::SendCreatePlayer에서 이상 캐릭터 명 F: %s", lpszPlayer ); // ar.Write( adwEquipment, sizeof(DWORD) * MAX_HUMAN_PARTS ); ar << nFace << nCostume << nSkinSet << nHairMesh; ar << dwHairColor; ar << nSex << nJob << nHeadMesh; #if __VER >= 15 // __2ND_PASSWORD_SYSTEM ar << nBankPW; #endif // __2ND_PASSWORD_SYSTEM ar << g_Neuz.m_dwAuthKey; SEND( ar, this, DPID_SERVERPLAYER ); }
void FunctionResponse(uint8_t *MessageID, uint8_t Token) { FUNCTION_RESPONSE[4] = MessageID[0]; FUNCTION_RESPONSE[5] = MessageID[1]; FUNCTION_RESPONSE[6] = Token; SEND(FUNCTION_RESPONSE, 12); // }
void Team(unsigned char team, Resource gold) { Message msg; msg.push_back("TEAM"); msg.push_back((long) team); msg.push_back((double) gold); SEND(msg, false); }
long CALLBACK NETsendPadData(void *pData, int Size) { if (PadSendSize == -1) { PadSendSize = Size; if (SEND(&PadSendSize, 1, PSE_NET_BLOCKING) == -1) return -1; if (RECV(&PadRecvSize, 1, PSE_NET_BLOCKING) == -1) return -1; } memcpy(&PadSendData[PadCount], pData, Size); if (SEND(pData, PadSendSize, PSE_NET_BLOCKING) == -1) return -1; return 0; }
/* called when RecvPacket timed out */ void transfer_timeout(int signum) { if (otries++>=NUM_TRIES) { fprintf(stderr,"No reply from terminal ! Assuming dead, hence aborting\n"); transfer_abort(RET_EPROTO); } SEND(obuf,osize); alarm(1); }
void send_stream(int fd, char *msg, uint32_t msg_size) { ssize_t wrote_size = 0; struct stream_hdr hdr; hdr.magic = 0xFEEDDEAD; hdr.xor = 0; hdr.len = msg_size; SEND(fd, &hdr, sizeof (hdr)); wrote_size = SEND(fd, msg, msg_size); #ifdef DEBUG printf("--(%3u/%3u)-> ", (unsigned) wrote_size, msg_size); printf("\033[1;31m%s\033[0m\n", msg); #endif }
static void led_info() { int mode; char* on_msg = "LED IS ON\r\n"; char* off_msg = "LED IS OFF\r\n"; char msg[256]; while (1) { receive (&mode); switch (mode) { case 0: SEND(off_msg, strlen (off_msg) + 1, 4); break; case 1: SEND(on_msg, strlen (on_msg) + 1, 4); break; } } }
static void readf() { char msg[256]; while (1) { receive (msg); kprint ("%s", msg); SEND("", 1, 1); } }
void VMClass_assemble_system_class(class_generation_context* cgc, pVMClass system_class ) { //System classes have only to be filed with fields and methods. // instance-bound SEND(system_class, set_instance_invokables, Universe_new_array_list(cgc->instance_methods)); SEND(system_class, set_instance_fields, Universe_new_array_list(cgc->instance_fields)); // class-bound == class-instance-bound pVMClass super_mclass = SEND(system_class, get_class); SEND(super_mclass, set_instance_invokables, Universe_new_array_list(cgc->class_methods)); SEND(super_mclass, set_instance_fields, Universe_new_array_list(cgc->class_fields)); }
void Build(GridPoint g, Structure *s) { Message msg; msg.push_back("BUILD"); msg.push_back(convert(g)); msg.push_back((string) *s); SEND(msg, true); }
void Destroy(GridPoint g, Player::Id pid) { Message msg; msg.push_back("DESTROY"); msg.push_back(convert(g)); msg.push_back((long) pid); SEND(msg, false); }
void CDPLoginSrvr::SendLoginProtect( const char* lpszAccount, const char* lpszPlayer, u_long idPlayer, BOOL bLogin, DPID dpId ) { BEFORESENDSOLE( ar, PACKETTYPE_LOGIN_PROTECT_CERT, dpId ); ar.WriteString( lpszAccount ); ar.WriteString( lpszPlayer ); ar << idPlayer << bLogin; SEND( ar, this, DPID_ALLPLAYERS ); }
int TcpSocket::rawSendBytes(char *buffer, shared_int num_bytes) { int rc = this->SOCKET_FAIL; rc = SEND(this->getSockHandle(), buffer, num_bytes, 0); return rc; }
void vClient::SendWCWantedReward(u_long idPlayer, u_long idAttacker, char* szFormat, DWORD dwWorldID, const D3DXVECTOR3& vPos, int nLayer) { BEFORESENDDUAL(ar, 34603162, -1, -1 ); ar << idPlayer << idAttacker << dwWorldID << vPos; ar.WriteString(szFormat); ar << nLayer; SEND( ar, addrCoreClient, 1 ); }
size_t _List_indexOfCString(void* _self, const char* cstring) { pList self = (pList)_self; pListElem elem = self->head; for(size_t result = 0; elem; result++, elem = elem->next) if(strcmp(cstring, SEND((pString)elem->data, chars)) == 0) return result; return -1; }
int act_fork(char *param, t_client *client, t_info *info) { (void)param; (void)info; info->zone[client->x][client->y].nb_egg++; SEND(client->buf_write, OK); return (0); }
int smtrdns_init (void) { AGENT *agent; /* Handle for our agent */ THREAD *thread; /* Handle to various threads */ # include "smtrdns.i" /* Include dialog interpreter */ /* Shutdown event comes from Kernel */ declare_smtlib_shutdown (shutdown_event, SMT_PRIORITY_MAX); /* Reply events from socket agent */ declare_smtsock_ok (ok_event, 0); declare_smtsock_connect_ok (ok_event, 0); declare_smtsock_closed (sock_closed_event, 0); declare_smtsock_error (sock_error_event, 0); declare_smtsock_timeout (sock_timeout_event, 0); /* Public methods supported by this agent */ declare_smtrdns_get_host_name (get_host_event, 0); declare_smtrdns_get_host_ip (get_ip_event, 0); /* Reply events from timer agent */ declare_smttime_reply (timer_event, SMT_PRIORITY_LOW); /* Private methods used to pass initial thread events */ method_declare (agent, "_MASTER", master_event, 0); method_declare (agent, "_CLIENT", client_event, 0); /* Ensure that operator console is running, else start it up */ smtoper_init (); if ((thread = thread_lookup (SMT_OPERATOR, "")) != NULL) operq = thread-> queue-> qid; else return (-1); /* Ensure that socket i/o agent is running, else start it up */ smtsock_init (); if ((thread = thread_lookup (SMT_SOCKET, "")) != NULL) sockq = thread-> queue-> qid; else return (-1); /* Ensure that timer agent is running, else start it up */ if (smttime_init ()) return (-1); /* Create initial thread to manage master port */ if ((thread = thread_create (AGENT_NAME, "")) != NULL) { SEND (&thread-> queue-> qid, "_MASTER", ""); ((TCB *) thread-> tcb)-> thread_type = master_event; } else return (-1); /* Signal okay to caller that we initialised okay */ return (0); }
void send_stream(int fd, const char *msg, uint32_t msg_size) { char *compressed = wf_compress_query(msg); char *buffer = NULL; #ifdef DEBUG if (crypt_is_ready()) printf("%s==(%3u)=> ", compressed ? "##" : "==", msg_size); else printf("%s--(%3u)-> ", compressed ? "##" : "--", msg_size); printf("\033[1;31m%s\033[0m\n", msg); #endif if (compressed != NULL && strstr(msg, "to='k01.warface'") == NULL ) { msg_size = strlen(compressed); buffer = compressed; } else { buffer = strdup(msg); free(compressed); compressed = buffer; } #ifdef USE_PROTECT struct stream_hdr hdr; hdr.magic = STREAM_MAGIC; hdr.se = SE_PLAIN; hdr.len = msg_size; if (crypt_is_ready()) { hdr.se = SE_ENCRYPTED; crypt_encrypt((uint8_t *) buffer, msg_size); } SEND(fd, &hdr, sizeof (hdr)); #endif /* USE_PROTECT */ SEND(fd, buffer, msg_size); free(compressed); }
static int listDevices(ClientElem_t *pClient) { int res = 0; int size = 8192; TCHAR *pszDevices = 0; long dwChars = 0; TCHAR *ptr; while (res == 0 && dwChars == 0) { pszDevices = malloc(size); if (pszDevices != 0) { dwChars = QueryDosDevice(NULL, pszDevices, size/sizeof(TCHAR)); if (dwChars == 0) { DWORD err = GetLastError(); if (err == ERROR_INSUFFICIENT_BUFFER) { size *= 2; if (size > 1024*1024) { SEND("ERROR cannot list com ports, QueryDosDevice too hungry"); res = -1; } else { free(pszDevices); } } else { SEND("ERROR cannot list com ports, %i", err); res = -1; } } } else { SEND("ERROR cannot list com ports, out of memory"); res = -1; } } ptr = pszDevices; while (res >= 0 && dwChars > 0) { int port; TCHAR *pTmp; if (swscanf(ptr, TEXT("COM%i"), &port) == 1) { SEND("COM%i", port); } pTmp = wcschr(ptr, 0); dwChars -= (DWORD)((pTmp - ptr) / sizeof(TCHAR) + 1); ptr = pTmp + 1; } free(pszDevices); return res; }
void _VMClass_add_instance_primitive(void* _self, pVMPrimitive value, bool warn) { pVMClass self = (pVMClass)_self; if(SEND(self, add_instance_invokable, (pVMObject)value) && warn) { pVMSymbol sym = TSEND(VMInvokable, value, get_signature); debug_warn("Primitive %s is not in class definition for class %s.\n", sym->chars, self->name->chars); } }
void CDPCoreClient::SendPreJoin( DWORD dwAuthKey, const TCHAR* lpszAccount, u_long idPlayer, const TCHAR* lpszPlayer ) { BEFORESEND( ar, PACKETTYPE_PRE_JOIN ); ar << dwAuthKey; ar.WriteString( lpszAccount ); ar << idPlayer; ar.WriteString( lpszPlayer ); SEND( ar, this, DPID_SERVERPLAYER ); }
void CGuildHouseDBCtrl::SendGuildHouse( DPID dpId ) { if( !GuildHouseMng->IsEmpty() ) { BEFORESENDDUAL( ar, PACKETTYPE_GUILDHOUSE_LOAD, DPID_UNKNOWN, DPID_UNKNOWN ); GuildHouseMng->Serialize( ar ); SEND( ar, CDPTrans::GetInstance(), dpId ); } }
/** * * Initialize a VMArray * */ void _VMArray_init(void* _self, ...) { pVMArray self = (pVMArray)_self; va_list args; va_start(args, _self); size_t fields = SEND(self, _get_offset) + va_arg(args, size_t); va_end(args); SUPER(VMObject, _self, init, fields); }
/*----------------------------------------------------------------------------*/ int http_sendHeader(char* key, char* value) { int numPrinted; numPrinted = snprintf(readBuffer, BUF_SIZE, "%s: %s" CRLF, key, value); readBuffer[BUF_SIZE] = 0; SEND(readBuffer, numPrinted); return 0; }
void Attack(GridPoint g, double damage, bool self) { Message msg; msg.push_back("ATTACK"); msg.push_back(convert(g)); msg.push_back((double) damage); msg.push_back((long) (self ? 1 : 0)); SEND(msg, true); }
/*----------------------------------------------------------------------------*/ int http_sendResponseStatus(int statusCode) { int numPrinted; numPrinted = snprintf(readBuffer, BUF_SIZE, "HTTP/1.1 %3i %s" CRLF, statusCode, http_message(statusCode)); readBuffer[BUF_SIZE] = 0; SEND(readBuffer, numPrinted); return 0; }
void Hit(Player::Id pid, double damage, bool self) { Message msg; msg.push_back("HIT"); msg.push_back((long) pid); msg.push_back((double) damage); msg.push_back((long) (self ? 1 : 0)); SEND(msg, true); }