/*--------------------------------------------------------------------- * M A I N P R O G R A M *---------------------------------------------------------------------*/ int main(int argc, char **argv) { params_t oci_params; /* Outbound connection info */ conn_info_t xout_params = {XOUT_USER, XOUT_USER_LEN, XOUT_PSW, XOUT_PSW_LEN, XOUT_DB, XOUT_DB_LEN, XOUT_APPLY, XOUT_APPLY_LEN}; /* Database connection info */ conn_info_t db_params = {DB_USER, DB_USER_LEN, DB_PSW, DB_PSW_LEN, XOUT_DB, XOUT_DB_LEN, (oratext *) 0, 0}; myctx_t ctx; oci_t *ocip = (oci_t *)NULL; ub2 obdb_char_csid = 0; /* outbound db char csid */ ub2 obdb_nchar_csid = 0; /* outbound db nchar csid */ memset(&ctx, 0, sizeof(ctx)); ctx.longform = TRUE; /* parse command line arguments */ get_inputs(&ctx, &xout_params, &db_params, argc, argv); /* Get the outbound database CHAR and NCHAR character set info */ get_db_charsets(&xout_params, &obdb_char_csid, &obdb_nchar_csid); /* connect to the source database */ connect_db(&xout_params, &ocip, obdb_char_csid, obdb_nchar_csid); /* Attach to outbound server */ attach_session(ocip, &xout_params, TRUE); ctx.outbound_ocip = ocip; /* connect to source database to do query and inserts on source tables */ ocip = (oci_t *)NULL; connect_db(&db_params, &ocip, obdb_char_csid, obdb_nchar_csid); ctx.sql_sel_ocip = ocip; /* Get lcrs from outbound server and send to inbound server */ get_lcrs(&ctx); /* Detach from XStream servers */ detach_session(ctx.outbound_ocip, FALSE); /* Disconnect from outbound database */ disconnect_db(ctx.outbound_ocip); free(ctx.outbound_ocip); /* Disconnect from sql database */ disconnect_db(ctx.sql_sel_ocip); free(ctx.sql_sel_ocip); return 0; }
int runattachsessiontest(char *hostname, char *username, char *password) { int session_id = -1; init_client(hostname, username, password); session_id = create_session(); if(session_id < 0) { fprintf(stderr, "create_session() failed\n"); return -1; } attach_session(session_id); close_session(session_id); printf("AttachSessionTest passed\n"); return 0; }
int main(int argc, char **argv) { int ret; int session_id; plan_tests(NUM_TESTS); diag("Live unit tests"); ret = connect_viewer("localhost"); ok(ret == 0, "Connect viewer to relayd"); ret = establish_connection(); ok(ret == 0, "Established connection and version check with %d.%d", VERSION_MAJOR, VERSION_MINOR); ret = list_sessions(&session_id); ok(ret > 0, "List sessions : %d session(s)", ret); ret = attach_session(session_id); ok(ret > 0, "Attach to session, %d streams received", ret); ret = get_metadata(); ok(ret > 0, "Get metadata, received %d bytes", ret); ret = get_next_index(); ok(ret == 0, "Get one index per stream"); ret = get_data_packet(first_packet_stream_id, first_packet_offset, first_packet_len); ok(ret == first_packet_len, "Get one data packet for stream %d, offset %d, len %d", first_packet_stream_id, first_packet_offset, first_packet_len); return exit_status(); }