int32_t __zrt_log_write( int handle, const char* buf, int32_t size, int64_t offset){ if ( s_log_prolog_mode_enabled ){ if ( s_buffered_len ){ /*write to log buffer, that is using internally by tfp_printf*/ int wr = zvm_pwrite(handle, s_logbuf, s_buffered_len, offset); s_buffered_len=0; return wr; } } else return zvm_pwrite(handle, buf, size, offset); return 0; }
int main(int argc, char** argv) { ATest t; BTest t2; ATest* ptr = new ATest(); ATest* ptr2 = new BTest(); t.init(); t2.init(); g.init(); g2.init(); ptr->init(); ptr2->init(); int sum = 0; for (int i=0;i<1000;++i) sum += i; const char buffer[] = "Hello, trusted!\n"; // breakpoint here! do not move 'sum = 0' from line 100 zvm_pwrite(1, buffer, sizeof(buffer), 0); // delete ptr; delete ptr2; return 0; }
int main(int argc, char **argv) { int64_t position = 0; int64_t insize; int64_t outsize; char *buffer = NULL; #ifdef LOGFIX /* set up the log */ int retcode = ERR_CODE; struct SetupList setup; retcode = zvm_setup(&setup); retcode = log_set(&setup); if(retcode) return retcode; #endif /* allocate buffer */ if((buffer = (char*) malloc(CHUNK_SIZE)) == NULL) LEAVE(buffer, -1); /* copy input channel to output channel */ while((insize = zvm_pread(InputChannel, buffer, CHUNK_SIZE, position)) > 0) { outsize = zvm_pwrite(OutputChannel, buffer, insize, position); fprintf(stderr, "read [%lld] bytes, written %lld bytes\n", insize, outsize); if(insize != outsize) LEAVE(buffer, -2); /* check if some bytes lost in action */ position += insize; fprintf(stderr, "position = %lld\n", position); } LEAVE(buffer, 0) return 0; /* not reachable */ }
int main(int argc , char **argv) { char buffer[BUFSIZE]; struct sockaddr_in addr = {0}; int result; int s; /* create socket */ s = zvm_socket(PF_INET, SOCK_STREAM, 0); FAILIF(s < 0, 1, "socket: %d\n", s); /* populate a sockaddr_in structure with the remote IP and port */ addr.sin_family = AF_INET; addr.sin_port = 0x5000; // 80 in network order. htons(PORT) addr.sin_addr.s_addr = 0x7146C2AD; // 173.194.70.113. htonl(INADDR_ANY) /* connect the socket to the far end */ result = zvm_connect(s, (void*)&addr, sizeof addr); FAILIF(result < 0, 2, "connect: %d\n", result); /* send the request string */ result = zvm_send(s, REQUEST, sizeof REQUEST, 0); FAILIF(result < sizeof REQUEST, 3, "write: %d\n", result); /* read the data */ while((result = zvm_recv(s, buffer, BUFSIZE, 0)) > 0) { FAILIF(result < 0, 4, "read: %d\n", result); result = zvm_pwrite(STDOUT_NO, buffer, result, 0); FAILIF(result < 0, 5, "write: %d\n", result); } /* close the socket */ result = zvm_close(s); FAILIF(result < 0, 6, "close: %d\n", result); return(0); }
int32_t zrtlog_write( int handle, const char* buf, int32_t size, int64_t offset){ return zvm_pwrite(handle, buf, size, offset); }