void error_handler(int error_flag, const char *string) { switch(error_flag){ case DE_ERROR_MISC_ERROR: add_error_log(comb_2str("ERROR: Misc! ::",string)); break; case DE_ERROR_POINTER_IN_USE: add_error_log(comb_2str("ERROR: Pointer in use! ::",string)); break; case DE_ERROR_UNDEFINED_POINTER: add_error_log(comb_2str("ERROR: Undefined Pointer! ::",string)); break; case DE_ERROR_OUT_OF_MEMORY: add_error_log(comb_2str("ERROR: Server Out Of Memory! ::",string)); break; case DE_ERROR_IO_ERROR: add_error_log(comb_2str("ERROR: I/O Error! ::",string)); break; case DE_ERROR_FILE_ERROR: add_error_log(comb_2str("ERROR: File Error! ::",string)); break; case DE_ERROR_OVERFLOW_ERROR: add_error_log("ERROR: Overflow!\n"); break; case DE_ERROR_SOCKET_ADDR_ERROR: add_error_log("ERROR: Could not establish server address!\n"); break; case DE_ERROR_GLFWINIT_ERROR: add_error_log("ERROR: GLFW Did Not initialize!\n"); break; case DE_ERROR_GLFWWIN_ERROR: add_error_log("ERROR: GLFW Did Not Open Window!\n"); break; case DE_ERROR_IMAGELOADER_ERROR: add_error_log(comb_2str("ERROR: Image Did Not Load! ::",string)); break; case DE_ERROR_PATH_INCORRECT: add_error_log(comb_2str("ERROR: Could not establish Program_Path! ::",string)); break; case DE_ERROR_PATH_NULL: add_error_log(comb_2str("ERROR: Path is NULL. ::",string)); break; case DE_ERROR_GLEWINIT_ERROR: add_error_log("ERROR: GLEW Did Not initialize!\n"); break; case DE_ERROR_POINTER_NULL: add_error_log(comb_2str("ERROR: Pointer is NULL. ::",string)); break; case DE_ERROR_NONE_ACSII: add_error_log("MESSAGE: Does Not Support Unicode characters.\n"); return; case DE_ERROR_SOCKET_INIT: add_error_log("ERROR: Socket did not initialize.\n"); return; case DE_ERROR_SOCKET_WSASTARTUP: add_error_log("ERROR: windows socket startup error.\n"); return; case DE_ERROR_SOCKET_SEND_SIZE: add_error_log(comb_2str("MESSAGE: send size was incorrect. ::",string)); return; case DE_ERROR_SOCKET_CONNECTION_LOSS: add_error_log("MESSAGE: connection was lost\n"); return; case DE_ERROR_INVALID_PACKET_ID: add_error_log(comb_2str("MESSAGE: Packet ID is invalid. ::",string)); return; case DE_ERROR_INVALID_PACKET_OFFSET: add_error_log(comb_2str("MESSAGE: Packet offset equals zero. ::",string)); return; default: add_error_log("ERROR: Unknown Error!\n"); } widget_unload(widget_get_uip()->root); unload_functions(); }
int main(int argc, char * argv[]) { int retCode = 0; int versionGbm = 0; /* On OS/2 the user can provide a fully qualified * name of the GBM.DLL which is checked alternatively * to the automatic lookup. */ char filename_gbm [GBMVER_FILENAME_MAX+1]; char filename_gbmdlg [GBMVER_FILENAME_MAX+1]; char filename_gbmrx [GBMVER_FILENAME_MAX+1]; char filename_gbmdlgrx[GBMVER_FILENAME_MAX+1]; char foundModuleNameGbm [GBMVER_FILENAME_MAX+1] = ""; char foundModuleNameGbmdlg [GBMVER_FILENAME_MAX+1] = ""; char foundModuleNameGbmrx [GBMVER_FILENAME_MAX+1] = ""; char foundModuleNameGbmdlgrx[GBMVER_FILENAME_MAX+1] = ""; HMODULE hModuleGbm = NULLHANDLE; HMODULE hModuleGbmdlg = NULLHANDLE; HMODULE hModuleGbmrx = NULLHANDLE; HMODULE hModuleGbmdlgrx = NULLHANDLE; if (argc == 2) { /* check if the user specified a trailing \ */ if (strlen(argv[1]) > GBMVER_FILENAME_MAX) { printf("Provided pathname is too long.\n"); return 1; } if (argv[1][strlen(argv[1])-1] == '\\') { sprintf(filename_gbm , "%sgbm.dll" , argv[1]); sprintf(filename_gbmdlg , "%sgbmdlg.dll" , argv[1]); sprintf(filename_gbmrx , "%sgbmrx.dll" , argv[1]); sprintf(filename_gbmdlgrx, "%sgbmdlgrx.dll", argv[1]); } else { sprintf(filename_gbm , "%s\\gbm.dll" , argv[1]); sprintf(filename_gbmdlg , "%s\\gbmdlg.dll" , argv[1]); sprintf(filename_gbmrx , "%s\\gbmrx.dll" , argv[1]); sprintf(filename_gbmdlgrx, "%s\\gbmdlgrx.dll", argv[1]); } } else { strcpy(filename_gbm , "gbm"); strcpy(filename_gbmdlg , "gbmdlg"); strcpy(filename_gbmrx , "gbmrx"); strcpy(filename_gbmdlgrx, "gbmdlgrx"); } printf("===============================================\n"); printf("Checking for \"%s\"...\n", filename_gbm); /* load GBM.DLL */ hModuleGbm = load_functions(filename_gbm, GBM_FUNCTION_TABLE, GBM_FUNCTION_TABLE_LENGTH, foundModuleNameGbm, GBMVER_FILENAME_MAX); if (hModuleGbm == NULLHANDLE) { printf("Not found or unresolved dependencies.\n\n"); return 1; } /* get version from GBM.DLL */ if (GBM_FUNCTION_TABLE[GBM_VERSION_ID].functionAddress == NULL) { printf("Is not valid.\n"); unload_functions(hModuleGbm, GBM_FUNCTION_TABLE, GBM_FUNCTION_TABLE_LENGTH); hModuleGbm = NULLHANDLE; return 1; } versionGbm = GBM_FUNCTION_TABLE[GBM_VERSION_ID].functionAddress(); printf("-> Found version %.2f\n", GET_GBM_VERSION(versionGbm)); /* show GBM.DLL info */ if (! show_info(GBM_FUNCTION_TABLE, GBM_FUNCTION_TABLE_LENGTH, foundModuleNameGbm, versionGbm)) { retCode = 1; unload_functions(hModuleGbm, GBM_FUNCTION_TABLE, GBM_FUNCTION_TABLE_LENGTH); hModuleGbm = NULLHANDLE; } else { printf("This GBM.DLL can be used with all applications\n" \ "developed for GBM.DLL version >=%.2f.\n\n", GET_GBM_VERSION(GBM_MIN_VERSION)); } printf("===============================================\n"); printf("Checking for \"%s\"...\n", filename_gbmdlg); /* load GBMDLG.DLL */ hModuleGbmdlg = load_functions(filename_gbmdlg, GBMDLG_FUNCTION_TABLE, GBMDLG_FUNCTION_TABLE_LENGTH, foundModuleNameGbmdlg, GBMVER_FILENAME_MAX); if (hModuleGbmdlg == NULLHANDLE) { printf("Not found or unresolved dependencies.\n"); unload_functions(hModuleGbm, GBM_FUNCTION_TABLE, GBM_FUNCTION_TABLE_LENGTH); hModuleGbm = NULLHANDLE; return 1; } /* show GBMDLG.DLL info */ if (! show_info(GBMDLG_FUNCTION_TABLE, GBMDLG_FUNCTION_TABLE_LENGTH, foundModuleNameGbmdlg, 0 /* no version info */)) { retCode = 1; unload_functions(hModuleGbmdlg, GBMDLG_FUNCTION_TABLE, GBMDLG_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbm , GBM_FUNCTION_TABLE , GBM_FUNCTION_TABLE_LENGTH); hModuleGbmdlg = NULLHANDLE; hModuleGbm = NULLHANDLE; } printf("===============================================\n"); printf("Checking for \"%s\"...\n", filename_gbmrx); /* load GBMRX.DLL */ hModuleGbmrx = load_functions(filename_gbmrx, GBMRX_FUNCTION_TABLE, GBMRX_FUNCTION_TABLE_LENGTH, foundModuleNameGbmrx, GBMVER_FILENAME_MAX); if (hModuleGbmrx == NULLHANDLE) { printf("Not found or unresolved dependencies.\n"); unload_functions(hModuleGbmrx , GBMRX_FUNCTION_TABLE , GBMRX_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbmdlg, GBMDLG_FUNCTION_TABLE, GBMDLG_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbm , GBM_FUNCTION_TABLE , GBM_FUNCTION_TABLE_LENGTH); hModuleGbmrx = NULLHANDLE; hModuleGbmdlg = NULLHANDLE; hModuleGbm = NULLHANDLE; return 1; } /* show GBMRX.DLL info */ if (! show_info(GBMRX_FUNCTION_TABLE, GBMRX_FUNCTION_TABLE_LENGTH, foundModuleNameGbmrx, 101 /* no public version info */)) { retCode = 1; unload_functions(hModuleGbmrx , GBMRX_FUNCTION_TABLE , GBMRX_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbmdlg, GBMDLG_FUNCTION_TABLE, GBMDLG_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbm , GBM_FUNCTION_TABLE , GBM_FUNCTION_TABLE_LENGTH); hModuleGbmrx = NULLHANDLE; hModuleGbmdlg = NULLHANDLE; hModuleGbm = NULLHANDLE; } printf("===============================================\n"); printf("Checking for \"%s\"...\n", filename_gbmdlgrx); /* load GBMDLGRX.DLL */ hModuleGbmdlgrx = load_functions(filename_gbmdlgrx, GBMDLGRX_FUNCTION_TABLE, GBMDLGRX_FUNCTION_TABLE_LENGTH, foundModuleNameGbmdlgrx, GBMVER_FILENAME_MAX); if (hModuleGbmdlgrx == NULLHANDLE) { printf("Not found or unresolved dependencies.\n"); unload_functions(hModuleGbmdlgrx, GBMDLGRX_FUNCTION_TABLE, GBMDLGRX_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbmrx , GBMRX_FUNCTION_TABLE , GBMRX_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbmdlg , GBMDLG_FUNCTION_TABLE, GBMDLG_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbm , GBM_FUNCTION_TABLE , GBM_FUNCTION_TABLE_LENGTH); hModuleGbmdlgrx = NULLHANDLE; hModuleGbmrx = NULLHANDLE; hModuleGbmdlg = NULLHANDLE; hModuleGbm = NULLHANDLE; return 1; } /* show GBMDLGRX.DLL info */ if (! show_info(GBMDLGRX_FUNCTION_TABLE, GBMDLGRX_FUNCTION_TABLE_LENGTH, foundModuleNameGbmdlgrx, 101 /* no public version info */)) { retCode = 1; } unload_functions(hModuleGbmdlgrx, GBMDLGRX_FUNCTION_TABLE, GBMDLGRX_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbmrx , GBMRX_FUNCTION_TABLE , GBMRX_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbmdlg , GBMDLG_FUNCTION_TABLE, GBMDLG_FUNCTION_TABLE_LENGTH); unload_functions(hModuleGbm , GBM_FUNCTION_TABLE , GBM_FUNCTION_TABLE_LENGTH); hModuleGbmdlgrx = NULLHANDLE; hModuleGbmrx = NULLHANDLE; hModuleGbmdlg = NULLHANDLE; hModuleGbm = NULLHANDLE; return retCode; }