int main(int argc, char **argv) { sxc_client_t *sx; sxc_logger_t log; struct gengetopt_args_info args; char file[1024]; const char *filter_dir; if(cmdline_parser(argc, argv, &args)) return 1; if(args.version_given) { printf("%s %s\n", CMDLINE_PARSER_PACKAGE, SRC_VERSION); cmdline_parser_free(&args); return 0; } if(args.output_given) snprintf(file, sizeof(file), "%s", args.output_arg); else snprintf(file, sizeof(file), "sxreport-client-%ld.log", (long)time(NULL)); umask(077); if(!(sx = sxc_init(SRC_VERSION, sxc_file_logger(&log, argv[0], file, 1), NULL, NULL))) { cmdline_parser_free(&args); return 1; } if(args.config_dir_given && sxc_set_confdir(sx, args.config_dir_arg)) { cmdline_parser_free(&args); sxc_shutdown(sx, 0); return 1; } sxc_set_verbose(sx, 1); filter_dir = get_filter_dir(sx, args.filter_dir_arg); if(sxc_filter_loadall(sx, filter_dir)) { cmdline_parser_free(&args); sxc_shutdown(sx, 0); return 1; } sxi_report_build_info(sx); #define INFO_PKGCONFIG "" #define INFO_PKGCONFIG_LIBDIR "" #define INFO_PKGCONFIG_PATH "" sxi_report_build_flags(sx); sxi_report_library_versions(sx, SRC_VERSION); sxi_report_system_info(sx); sxi_report_limits(sx); sxi_report_section(sx, "Filters"); sxi_info(sx,"Default filter directory: %s\n", SX_FILTER_DIR); sxi_info(sx,"Current filter directory: %s\n", filter_dir); filter_list(sx); sxi_report_configuration(sx, args.config_dir_arg); printf("Report stored in %s\n", file); printf("You can attach it to a bugreport at %s\n", PACKAGE_BUGREPORT); cmdline_parser_free(&args); sxc_shutdown(sx, 0); return 0; }
void server_done(sxc_client_t **sx) { ERR_free_strings(); sxc_shutdown(*sx, 0); *sx = NULL; log_done(); sxprocdone(); }
/*{ ** Name: sxf_call - The main SXF entry point. ** ** Description: ** The routine checks that the arguments to sxf_call look reasonable. ** The implementing function is then called and operation completion ** status is returned to the caller. ** ** Inputs: ** op_code The SXF operation code. ** rcb The SXF request control block for the operation. ** ** Outputs: ** Returns: ** DB_STATUS ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 9-July-1992 (markg) ** Initial creation. ** 03-sep-1992 (pholman) ** Give calls NULL functionlaity for initial integration ** 20-oct-1992 (markg) ** Updated to have entry points for all SXF operations. */ DB_STATUS sxf_call( SXF_OPERATION op_code, SXF_RCB *rcb) { DB_STATUS status = E_DB_OK; EX_CONTEXT context; i4 error; CLRDBERR(&rcb->sxf_error); /* Make a cursury check for bad parameters. */ if (op_code < SXF_MIN_OPCODE || op_code > SXF_MAX_OPCODE || rcb->sxf_cb_type != SXFRCB_CB || rcb->sxf_length != sizeof (SXF_RCB) || (Sxf_svcb == NULL && op_code != SXC_STARTUP)) { /* Figure out the error in more detail. */ if (op_code < SXF_MIN_OPCODE || op_code > SXF_MAX_OPCODE) SETDBERR(&rcb->sxf_error, 0, E_SX0001_BAD_OP_CODE); else if (rcb->sxf_cb_type != SXFRCB_CB) SETDBERR(&rcb->sxf_error, 0, E_SX0002_BAD_CB_TYPE); else if (rcb->sxf_length != sizeof (SXF_RCB)) { TRdisplay("Bad SXF CB length. Input length %d expected %d\n", rcb->sxf_length, sizeof(SXF_RCB)); SETDBERR(&rcb->sxf_error, 0, E_SX0003_BAD_CB_LENGTH); } else SETDBERR(&rcb->sxf_error, 0, E_SX000F_SXF_NOT_ACTIVE); return (E_DB_ERROR); } if (EXdeclare(ex_handler, &context) == OK && (Sxf_svcb == NULL || (Sxf_svcb->sxf_svcb_status & SXF_CHECK) == 0)) { switch (op_code) { /* Control operations. */ case SXC_STARTUP: status = sxc_startup(rcb); break; case SXC_SHUTDOWN: status = sxc_shutdown(rcb); break; case SXC_BGN_SESSION: status = sxc_bgn_session(rcb); break; case SXC_END_SESSION: status = sxc_end_session(rcb); break; case SXC_ALTER_SESSION: status = sxc_alter_session(rcb); break; case SXC_AUDIT_THREAD: status = sxac_audit_thread(rcb); break; case SXC_AUDIT_WRITER_THREAD: status = sxac_audit_writer_thread(rcb); break; /* Audit file oerations */ case SXA_OPEN: status = sxaf_open(rcb); break; case SXA_CLOSE: status = sxaf_close(rcb); break; /* Audit record operations */ case SXR_WRITE: status = sxar_write(rcb); break; case SXR_POSITION: status = sxar_position(rcb); break; case SXR_READ: status = sxar_read(rcb); break; case SXR_FLUSH: status = sxar_flush(rcb); break; /* Audit state operations */ case SXS_ALTER: status = sxas_alter(rcb); break; case SXS_SHOW: status = sxas_show(rcb); break; } EXdelete(); return (status); } /* ** If exception handler declares or the SXF_SVCB has already been ** marked inconsistent, this is a server fatal condition. In most ** cases it is sufficient to return a server fatal error, and let the ** caller handle the rest. ** ** However, if this is an audit record write operation we have to ** nuke the server ourselves. The reason for this is that if the ** client code does not handle the return status correctly the ** security of the system could be compromised. */ EXdelete(); if (op_code == SXR_WRITE) { _VOID_ ule_format(E_SX0005_INTERNAL_ERROR, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); _VOID_ ule_format(E_SX1048_SERVER_TERMINATE, NULL, ULE_LOG, NULL, NULL, 0L, NULL, &error, 0); _VOID_ CSterminate(CS_KILL, NULL); } SETDBERR(&rcb->sxf_error, 0, E_SX0005_INTERNAL_ERROR); return (E_DB_FATAL); }