/******************************************************************* * OpenDribbleFile: Function will display the common file dialog and * will open a dribble file. ******************************************************************/ void OpenDribbleFile ( HWND hMain, WORD wParam ) { extern HANDLE hInst; OPENFILENAME ofn; char File[256], FileTitle[256], Filter[256]; UINT i, cbString; char Replace; HMENU hMenu = GetMenu(hMain); if ( !DribbleActive() ) { File[0] = '\0'; memset ( &ofn,0, sizeof (OPENFILENAME)); ofn.lpstrTitle = "Select CLIPS Dribble File"; if ((cbString = LoadString ( (HINSTANCE) hInst, IDS_DRIBBLE, Filter, sizeof (Filter))) == 0 ) return; Replace = Filter[cbString-1]; for (i=0; Filter[i] != '\0'; i++) if ( Filter[i] == Replace) Filter[i] = '\0'; ofn.lStructSize = sizeof ( OPENFILENAME ); ofn.hwndOwner = hMain; ofn.lpstrFilter = Filter; ofn.nFilterIndex = 1; ofn.lpstrFile = File; ofn.nMaxFile = sizeof (File ); ofn.lpstrFileTitle = FileTitle; ofn.nMaxFileTitle = sizeof (FileTitle); ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_OVERWRITEPROMPT; if ( GetSaveFileName ( &ofn ) ) { UpdateCursor ( WAIT_CURSOR ); ModifyMenu (hMenu, wParam, MF_BYCOMMAND, wParam, "Turn Dribble Off"); DribbleOn ( ofn.lpstrFile ); } } else { UpdateCursor ( WAIT_CURSOR ); ModifyMenu (hMenu, wParam, MF_BYCOMMAND, wParam, "Turn Dribble On..."); DribbleOff( ); } }
//Setup all routers. Parse through the WebCLIPS.INI and open // all required routers. int SetupRouters(void) { char szRouterList[MAX_SETTINGS_LINE_LEN], *p, szEchoEntry[MAX_ROUTER_NAME_LEN + 4 + 1]; //<router> "Echo" = 4 char szRouterFile[MAXNAMLEN + 1]; int iMaxPriority = 40; char szRouterTemp[MAX_ROUTER_NAME_LEN + 1], szRouterTemp2[MAX_ROUTER_NAME_LEN + 1]; struct WebCLIPSRouter *pWCRouter; int bSetRouterResult, bResult; //Get the list of routers GetWebCLIPSSettings( g_szScreenName, // section name "RouterList", // entry name "", // default value szRouterList, // return value sizeof(szRouterList), // max length g_szWebCLIPSINI ); //Set up the standard CLIPS routers : stdout, wdialog, wwarning, werror if(InitializeStdCLIPSRouters() != 0) return(-1); //If no additional routers requested then exit if(strlen(szRouterList) == 0) { return(0); } //Search for '|'. Set each router name in the string array p = strtok(szRouterList, "|"); g_pUDFWebCLIPSRouter = (struct WebCLIPSRouter *)calloc(1, sizeof(struct WebCLIPSRouter)); pWCRouter = g_pUDFWebCLIPSRouter; while(p) { strcpy(szRouterTemp2, p); Trim(szRouterTemp2, szRouterTemp); strcpy(szEchoEntry, szRouterTemp); strcat(szEchoEntry, "Echo"); //Get <router>Echo entry GetWebCLIPSSettings( g_szScreenName, // section name szEchoEntry, // entry name "", // default value szRouterFile, // return value sizeof(szRouterFile), // max length g_szWebCLIPSINI ); //If router is set to 'no' or is absent then get the next router. Also, if // there is a request for stdout, wdialog, wwarning, werror to be directed // to the screen, then ignore it. These will be handled by automatically. // // Also, ignore requests to 'dribble' to screen. The reason is that because // there are no </form> tags any facts that are asserted from a screen actually // get asserted TWICE..this is undesirable if(strcasecmp(szRouterFile, "no") == 0 || strlen(szRouterFile) == 0 || (strcasecmp(szRouterFile, "screen") == 0 && (strcasecmp(szRouterTemp, "stdout") == 0 || strcasecmp(szRouterTemp, "dribble") == 0 || strcasecmp(szRouterTemp, "wdialog") == 0 || strcasecmp(szRouterTemp, "wwarning") == 0|| strcasecmp(szRouterTemp, "werror") == 0))) { p = strtok(NULL, "|"); continue; } //Set the name of the router. pWCRouter->szRouter = (char *)malloc(strlen(szRouterTemp) + 1); if (!pWCRouter->szRouter) { ProcessErrorCode("ROUT0003", szRouterTemp, 'n', 'n'); return(-1); } strcpy(pWCRouter->szRouter, szRouterTemp); //If router is to be directed to the screen, then get a // temporary file name else use the entry in WebCLIPS.INI if(strcasecmp(szRouterFile, "screen") == 0) { pWCRouter->cDestination = WCRouter_ToScreen; //Generate temporary filename. bResult = GenerateTempFileName(&pWCRouter->szRouterFileName); if(bResult == FALSE) { ProcessErrorCode("ROUT0001", szRouterFile, 'n', 'n'); return(-1); } } else { pWCRouter->cDestination = WCRouter_ToFile; pWCRouter->szRouterFileName = (char *)malloc(strlen(szRouterFile) + 1); if (!pWCRouter->szRouterFileName) { ProcessErrorCode("ROUT0003", szRouterFile, 'n', 'n'); return(-1); } strcpy(pWCRouter->szRouterFileName, szRouterFile); } //Router request for dribble. if(strcasecmp(szRouterTemp, "dribble") == 0) { bSetRouterResult = DribbleOn(pWCRouter->szRouterFileName); if(bSetRouterResult == FALSE) //Error, process error and end program { ProcessErrorCode("DRBL0002", szRouterFile, 'n', 'n'); return(-1); } pWCRouter->cRouterType = WCRouter_Dribble; } else { if((pWCRouter->fp = fopen(pWCRouter->szRouterFileName, "wb")) == NULL) { ProcessErrorCode("ROUT0003", pWCRouter->szRouterFileName, 'n', 'n'); return(FALSE); } pWCRouter->cRouterType = WCRouter_Userdefined; } //System-defined router. Set priority appropriately if(strcasecmp(szRouterTemp, "wclips") == 0 || strcasecmp(szRouterTemp, "wtrace") == 0 || strcasecmp(szRouterTemp, "wagenda") == 0 || strcasecmp(szRouterTemp, "stdout") == 0 || strcasecmp(szRouterTemp, "wdialog") == 0 || strcasecmp(szRouterTemp, "wwarning") == 0 || strcasecmp(szRouterTemp, "werror") == 0 || strcasecmp(szRouterTemp, "wdisplay") == 0) iMaxPriority = 20; //Get next router p = &p[strlen(p) + 1]; p = strtok(p, "|"); //If there is another router to process, then allocate space for it if(p != NULL) { pWCRouter->pNextRouter = (struct WebCLIPSRouter *)calloc(1, sizeof(struct WebCLIPSRouter)); pWCRouter = pWCRouter->pNextRouter; } } // while(p) if(AddRouter(USERDEFINED_ROUTER, iMaxPriority, UDFWCQuery, UDFWCPrint, NULL, NULL, UDFWCExit) == 0) { ProcessErrorCode("ROUT0005", "User-Defined WebCLIPS Routers", 'n', 'n'); return(-1); } return(0); }