X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=AcessNative%2Fld-acess_src%2Frequest.c;h=8655377ea658e3f80276fd38073ec2b10978c7a0;hb=e7d0a33cc9b8bf0005799ab2fb5151f78a255772;hp=c5e89efc98de16e41eac0c22e51382d8ff75ee78;hpb=9ed2477f5f7e5b01501368719e93259aa336932f;p=tpg%2Facess2.git diff --git a/AcessNative/ld-acess_src/request.c b/AcessNative/ld-acess_src/request.c index c5e89efc..8655377e 100644 --- a/AcessNative/ld-acess_src/request.c +++ b/AcessNative/ld-acess_src/request.c @@ -1,5 +1,15 @@ /* */ +#define DEBUG 0 + + +#if DEBUG +# define DEBUG_S printf +#else +# define DEBUG_S(...) +# define DONT_INCLUDE_SYSCALL_NAMES +#endif + #include #include #include @@ -89,6 +99,7 @@ int _InitSyscalls() #endif exit(0); } + giSyscall_ClientID = gSocket; // A bit of a hack really :( #endif #if 0 @@ -130,7 +141,7 @@ int _InitSyscalls() return 0; } -int SendRequest(tRequestHeader *Request, int RequestSize) +int SendRequest(tRequestHeader *Request, int RequestSize, int ResponseSize) { if( gSocket == INVALID_SOCKET ) { @@ -153,38 +164,38 @@ int SendRequest(tRequestHeader *Request, int RequestSize) { int i; char *data = (char*)&Request->Params[Request->NParams]; - printf("Request #%i\n", Request->CallID); + DEBUG_S("Request #%i (%s) -", Request->CallID, casSYSCALL_NAMES[Request->CallID]); for( i = 0; i < Request->NParams; i ++ ) { - printf("%i: ", i); switch(Request->Params[i].Type) { case ARG_TYPE_INT32: - printf("INT32 %x", *(uint32_t*)data); + DEBUG_S(" 0x%08x", *(uint32_t*)data); data += sizeof(uint32_t); break; case ARG_TYPE_INT64: - printf("INT64 %llx", *(uint64_t*)data); + DEBUG_S(" 0x%016llx", *(uint64_t*)data); data += sizeof(uint64_t); break; case ARG_TYPE_STRING: - printf("STRING '%s'", (char*)data); + DEBUG_S(" '%s'", (char*)data); data += Request->Params[i].Length; break; case ARG_TYPE_DATA: - printf("DATA %i %p", Request->Params[i].Length, (char*)data); - data += Request->Params[i].Length; + DEBUG_S(" %p:0x%x", (char*)data, Request->Params[i].Length); + if( !(Request->Params[i].Flags & ARG_FLAG_ZEROED) ) + data += Request->Params[i].Length; break; } - printf("\n"); } + DEBUG_S("\n"); } // Send it off SendData(Request, RequestSize); // Wait for a response (no timeout) - return ReadData(Request, RequestSize, 0); + return ReadData(Request, ResponseSize, 0); } void SendData(void *Data, int Length) @@ -245,7 +256,7 @@ int ReadData(void *Dest, int MaxLength, int Timeout) exit(-1); } - printf("%i bytes read from socket\n", ret); + DEBUG_S("%i bytes read from socket\n", ret); return ret; }