示例#1
0
SelectionList
SelectionCollection::parseFromString(const std::string &str)
{
    yyscan_t scanner;

    _gmx_sel_init_lexer(&scanner, &impl_->sc_, false, -1,
                        impl_->bExternalGroupsSet_,
                        impl_->grps_);
    _gmx_sel_set_lex_input_str(scanner, str.c_str());
    return runParser(scanner, false, -1, std::string());
}
示例#2
0
SelectionList
SelectionCollection::parseFromStdin(int nr, bool bInteractive,
                                    const std::string &context)
{
    yyscan_t scanner;

    _gmx_sel_init_lexer(&scanner, &impl_->sc_, bInteractive, nr,
                        impl_->bExternalGroupsSet_,
                        impl_->grps_);
    return runParser(scanner, true, nr, context);
}
示例#3
0
    int Ecppc::runDependencies()
    {
      log_trace("runDependencies");

      tnt::ecppc::Dependencygenerator generator(_inputfile);

      std::ifstream in(_inputfile);
      if (!in)
        throw std::runtime_error(std::string("can't read ") + _inputfile);

      if (!_binary)
        runParser(in, generator, false);

      if (_ofile.empty())
        generator.getDependencies(std::cout);
      else
      {
        std::ofstream out(_ofile.c_str());
        generator.getDependencies(out);
      }

      return 0;
    }
示例#4
0
SelectionList
SelectionCollection::parseFromFile(const std::string &filename)
{

    try
    {
        yyscan_t scanner;
        File     file(filename, "r");
        // TODO: Exception-safe way of using the lexer.
        _gmx_sel_init_lexer(&scanner, &impl_->sc_, false, -1,
                            impl_->bExternalGroupsSet_,
                            impl_->grps_);
        _gmx_sel_set_lex_input_file(scanner, file.handle());
        return runParser(scanner, false, -1, std::string());
    }
    catch (GromacsException &ex)
    {
        ex.prependContext(formatString(
                                  "Error in parsing selections from file '%s'",
                                  filename.c_str()));
        throw;
    }
}
BOOL OpenThemeClass(HWND hwnd, char szFilename[], CBZDATA * pCBZData, char szClassName[])
{
    PLUGIN_LIST List;
    char szError[128], tempText[64];
    int i, i2, index;
    HWND hwndControl;
    PAPPLYFN pApplyFn;

    if (!runParser(szFilename, szClassName, &List, szError))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "OpenThemeClass", szError, 0UL);
        return FALSE;
    }

    //Clear the current selected plugins by placing them back into the
    // AvailablePlugins ListBox
    hwndControl = WinWindowFromID(hwnd, LBID_SELECTEDPLUGINS);
    index = (SHORT) WinSendMsg(hwndControl, LM_QUERYITEMCOUNT,
                               MPFROMLONG(0),
                               MPFROMLONG(0));
    for (i = 0; i < index; i++)
    {
        hwndControl = WinWindowFromID(hwnd, LBID_SELECTEDPLUGINS);

        //Save the text so it can be added to Available Plugin Listbox
        WinSendMsg(hwndControl, LM_QUERYITEMTEXT,
                   MPFROM2SHORT((SHORT) 0, 64),
                   MPFROMP((PSZ) tempText));
        //remove item from Selected Plugin ListBox
        WinSendMsg(hwndControl, LM_DELETEITEM,
                   MPFROMSHORT((SHORT) 0),
                   MPFROMLONG(0));

        //Add the item to the Available Plugins ListBox
        hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINS);
        i2 = (SHORT) WinSendMsg(hwndControl, LM_INSERTITEM,
                                MPFROMSHORT((SHORT) LIT_SORTASCENDING),
                                MPFROMP((PSZ) tempText));

        //Add the dll name to the AvailablePluginsDLL ListBox at the correct index
        strcpy(tempText, pCBZData->Plugins[0].szPluginDLL);
        hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINDLLS);
        WinSendMsg(hwndControl, LM_INSERTITEM,
                   MPFROMSHORT((SHORT) i2),
                   MPFROMP((PSZ) tempText));

        //remove the plugin from the pTBData structure
        if (!RemovePlugin(pCBZData, 0))
        {
            PSUTErrorFunc(hwnd,
                          "Error",
                          "OpenThemeClass",
                          "Error Removing Plugin!",
                          0UL);
            //Put it back in Selected Plugin ListBox?
            break;
        }

    }

    //Try selecting each plugin from the themeFile out of the AvailablePlugins ListBox
    for (i = 0; i < List.cbPlugins; i++)
    {
        hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINDLLS);
        //find the index of the plugin in the AvailablePlugins ListBox
        index = (SHORT) WinSendMsg(hwndControl, LM_SEARCHSTRING,
                                   MPFROM2SHORT(LSS_CASESENSITIVE, LIT_FIRST),
                                   MPFROMP(List.pPluginAttributes[i].szPluginName));

        if (index == LIT_NONE)  //Plugin not found

        {
            PSUTErrorFunc(hwnd,
                          "Error",
                          "OpenThemeClass - Plugin Not Found",
                          List.pPluginAttributes[i].szPluginName,
                          0UL);
            break;
        }

        hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINS);
        //Get the text from the Available Plugin ListBox
        WinSendMsg(hwndControl, LM_QUERYITEMTEXT,
                   MPFROM2SHORT((SHORT) index, 64),
                   MPFROMP((PSZ) tempText));
        //remove the selected item from the Available Plugins ListBox
        WinSendMsg(hwndControl, LM_DELETEITEM,
                   MPFROMSHORT((SHORT) index),
                   MPFROMLONG(0));

        //Add the queried text to the Selected Plugin ListBox
        hwndControl = WinWindowFromID(hwnd, LBID_SELECTEDPLUGINS);
        i2 = (SHORT) WinSendMsg(hwndControl, LM_INSERTITEM,
                                MPFROMSHORT((SHORT) LIT_END),
                                MPFROMP((PSZ) tempText));

        //Get the selected plugin DLL name from the AvailablePluginDLLS listbox
        hwndControl = WinWindowFromID(hwnd, LBID_AVAILABLEPLUGINDLLS);
        WinSendMsg(hwndControl, LM_QUERYITEMTEXT,
                   MPFROM2SHORT((SHORT) index, 64),
                   MPFROMP((PSZ) tempText));
        //remove it from the AvailablePluginDLLS listbox
        WinSendMsg(hwndControl, LM_DELETEITEM,
                   MPFROMSHORT((SHORT) index),
                   MPFROMLONG(0));

        if (!AddPlugin(hwnd, pCBZData, List.pPluginAttributes[i].szPluginName, ""))
        {
            //Error in AddPlugin... Put the plugin back into AvailableListbox?
            DosBeep(500, 50);
        }

        if (DosQueryProcAddr(pCBZData->Plugins[pCBZData->cbPlugins - 1].hModDll,
                             0, "CBZApply", (PFN *) & pApplyFn) == NO_ERROR)
        {
            //check return code from this to make sure it was sucessful.. if not disable the plugin
            pApplyFn(szClassName, (List.pPluginAttributes[i].keyValue),
                     List.pPluginAttributes[i].cbAttributes,
                     List.pPluginAttributes[i].enabledState,
                     pCBZData->Plugins[i].pData);
        }
        else
        {
            PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed Querying Procedure Address for CBZApply", 0UL);
        }
    }

    CBZFreePLUGIN_LIST(&List);
    return TRUE;
}
int ApplyPreviewBlock(HWND hwnd, char themeFile[], char szClass[], char szBase[], HINI hIni, int count)
{
    CBZSHARE *pCBZShare;
    CBZDATA *pCBZData;
    PLUGIN_LIST List;
    PAPPLYFN pApplyFn;
    PINITFN  pInitFn;
    char szError[CCHMAXPATH];
    char szProfile[CCHMAXPATH + 1];
    char szFile[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH + 1];
    char *tempPtr;
    int i,j;

    // get it for writing, so let's hurry
    if (DosGetNamedSharedMem((PPVOID) & pCBZShare, CBZ_SHARE, PAG_READ)
            != NO_ERROR)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed to Get Shared Memory", 0UL);
        return count;
    }

    if ((pCBZData = WinQueryWindowPtr(hwnd, pCBZShare->ulDataOffset)) == NULL)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Window Data", szFile, 0UL);
        DosFreeMem(pCBZShare);
        return count;
    }
    DosFreeMem(pCBZShare);


    //update the shared memory.
    if (strcmp(szClass, "TITLEBAR") == 0)
        pCBZData->sTitlebarIndex = count;
    else if (strcmp(szClass, "FRAME") == 0)
        pCBZData->sFrameBackgroundIndex = count;
    else if (strcmp(szClass, "FRAMEBRDR") == 0)
        pCBZData->sFrameBorderIndex = count;
    else if (strcmp(szClass, "PUSHBUTTON") == 0)
        pCBZData->sPushButtonIndex = count;
    else if (strcmp(szClass, "RADIOBUTTON") == 0)
        pCBZData->sRadioButtonIndex = count;
    else if (strcmp(szClass, "CHECKBOX") == 0)
        pCBZData->sCheckBoxIndex = count;
    else if (strcmp(szClass, "MINMAX") == 0)
        pCBZData->sMinMaxIndex = count;
    else if (strcmp(szClass, "MENU") == 0)
        pCBZData->sMenuIndex = count;


    if (!runParser(themeFile, szClass, &List, szError))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyBlock", szError, 0UL);
        return count;
    }

    if (List.cbPlugins <= 0)
        return count;


    pCBZData->cbPlugins = count + List.cbPlugins;

    if (List.cbPlugins > 0)
    {
        if (strcmp(szClass, "TITLEBAR") == 0)
            pCBZData->bTitlebarEnabled = TRUE;
        else if (strcmp(szClass, "FRAME") == 0)
            pCBZData->bFrameBackgroundEnabled = TRUE;
        else if (strcmp(szClass, "FRAMEBRDR") == 0)
            pCBZData->bFrameBorderEnabled = TRUE;
        else if (strcmp(szClass, "PUSHBUTTON") == 0)
            pCBZData->bPushButtonEnabled = TRUE;
        else if (strcmp(szClass, "RADIOBUTTON") == 0)
            pCBZData->bRadioButtonEnabled = TRUE;
        else if (strcmp(szClass, "CHECKBOX") == 0)
            pCBZData->bCheckBoxEnabled = TRUE;
        else if (strcmp(szClass, "MINMAX") == 0)
            pCBZData->bMinMaxEnabled = TRUE;
        else if (strcmp(szClass, "MENU") == 0)
            pCBZData->bMenuEnabled = TRUE;
    }
    else
    {
        if (strcmp(szClass, "TITLEBAR") == 0)
            pCBZData->bTitlebarEnabled = FALSE;
        else if (strcmp(szClass, "FRAME") == 0)
            pCBZData->bFrameBackgroundEnabled = FALSE;
        else if (strcmp(szClass, "FRAMEBRDR") == 0)
            pCBZData->bFrameBorderEnabled = FALSE;
        else if (strcmp(szClass, "PUSHBUTTON") == 0)
            pCBZData->bPushButtonEnabled = FALSE;
        else if (strcmp(szClass, "RADIOBUTTON") == 0)
            pCBZData->bRadioButtonEnabled = FALSE;
        else if (strcmp(szClass, "CHECKBOX") == 0)
            pCBZData->bCheckBoxEnabled = FALSE;
        else if (strcmp(szClass, "MINMAX") == 0)
            pCBZData->bMinMaxEnabled = FALSE;
        else if (strcmp(szClass, "MENU") == 0)
            pCBZData->bMenuEnabled = FALSE;
    }


    strcpy(szPluginBase, szBase);
    strcat(szPluginBase, "plugins\\");


    for (j = 0; j < List.cbPlugins; j++)
    {
        //copy plugin names to shared memory.
        strcpy(pCBZData->Plugins[count + j].szPluginDLL,
               List.pPluginAttributes[j].szPluginName);

        for (i = 0; i < List.pPluginAttributes[j].cbAttributes; i++)
        {
            //If there is a %CBZBaseDir% in the attribute, replace it with the basePath
            if (strstr(List.pPluginAttributes[j].keyValue[i].value, "%CBZBaseDir%") != NULL)
            {
                //%CBZBaseDir% must be at the start of the string
                //allocate space for the new string
                tempPtr = (char *) malloc(sizeof(char) * (strlen(szBase) + strlen(List.pPluginAttributes[j].keyValue[i].value) - strlen("%CBZBaseDir%") + 1));
                tempPtr[0] = '\0';
                strcat(tempPtr, szBase);
                sscanf(List.pPluginAttributes[j].keyValue[i].value, "%%CBZBaseDir%%\\%s", szProfile);
                strcat(tempPtr, szProfile);
                free(List.pPluginAttributes[j].keyValue[i].value);
                //replace the old string with the new string.
                List.pPluginAttributes[j].keyValue[i].value = tempPtr;
            }
        }

        //plugins might not be in LIBPATH, create full path here.
        _makepath(szFile, NULL, szPluginBase, List.pPluginAttributes[j].szPluginName, "DLL");

        if (DosLoadModule(szError, sizeof(szError), szFile, &(pCBZData->Plugins[count + j].hModDll)) == NO_ERROR)
        {

            //Query The Plugin's CBZPluginDataSize Function
            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZInit",
                                 (PFN *) & (pInitFn)) != NO_ERROR)
            {
                //error in Plugin's initialization...disable the plugin!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                continue;           //end this iteration..try next plugin.

            }
            //Call the Plugins Init function.
            if (!pInitFn(hIni, "", szClass, (PVOID *) & (pCBZData->Plugins[count + j].pData)))
            {
                //error in Plugin's initialization...disable the plugin!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                continue;           //end this iteration..try next plugin.

            }

            //Query the Plugin's Window Procedure.
            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZPluginWndProc",
                    (PFN *) & (pCBZData->Plugins[count + j].pPluginWndProc)) != NO_ERROR)
            {
                //error getting the Plugin's WndProc...disable the plugin!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                DosFreeMem(pCBZData->Plugins[count + j].pData);
                continue;           //end this iteration...try next plugin.

            }

            //Query the address of the plugin's Render function.
            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZPluginRender",
                   (PFN *) & (pCBZData->Plugins[count + j].pfnPluginRender)) != NO_ERROR)
            {
                //Error getting CBZPluginRender function!
                pCBZData->Plugins[count + j].bActiveEnabled = FALSE;
                pCBZData->Plugins[count + j].bInactiveEnabled = FALSE;
                DosFreeModule(pCBZData->Plugins[count + j].hModDll);
                DosFreeMem(pCBZData->Plugins[count + j].pData);
                continue;           //end this iteration...try next plugin.

            }



            if (DosQueryProcAddr(pCBZData->Plugins[count + j].hModDll, 0, "CBZApply", (PFN *) & pApplyFn) == NO_ERROR)
            {
                //check return code from this to make sure it was sucessful.. if not disable the plugin
                pApplyFn(szClass, (List.pPluginAttributes[j].keyValue),
                         List.pPluginAttributes[j].cbAttributes,
                         List.pPluginAttributes[j].enabledState,
                         pCBZData->Plugins[count + j].pData);
            }
            else
            {
                PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed Querying Procedure Address for CBZApply", 0UL);
            }
        }
        else
        {
            PSUTErrorFunc(NULLHANDLE, "Error", "ApplyBlock", "Error Querying Plugin Module.. (Missing?)", 0UL);
            pCBZData->cbPlugins = j - 1;
            break;
            //disable it here
        }

    }


    i = List.cbPlugins;
    //delete all the attributes in the plugin/key/value list
    CBZFreePLUGIN_LIST(&List);
    return count + i;
}
BOOL _ApplyPreviewBlock(HWND hwnd, char themeFile[], char szCBZBase[], char szShare[], char szClass[], int index)
{
    PSFRAMESHARE *pFrameShare;
    PLUGIN_LIST List;
    HMODULE hMod;
    PAPPLYFN pApplyFn;
    PINITFN pInitFn;
    char szError[CCHMAXPATH];
    char szProfile[CCHMAXPATH + 1];
    char szFile[CCHMAXPATH + 1];
    char szSaveName[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH + 1];
    char *tempPtr;
    int i, j;
    PSTBDATA *pTBData;
    HINI hIni;
    PDESTROYFN pDestroyFn;
    ULONG ulDataOffset;

//    if (DosGetNamedSharedMem((PPVOID) & pFrameShare, PSFRAME_SHARE, PAG_READ) != NO_ERROR)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Shared Memory", szFile, 0UL);
        return FALSE;
    }
    ulDataOffset = pFrameShare->ulDataOffset + index * sizeof(void *);
    DosFreeMem(pFrameShare);

    if ((pTBData = WinQueryWindowPtr(hwnd, ulDataOffset)) == NULL)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "Couldn't get Window Data", szFile, 0UL);
        return FALSE;
    }

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "Profile",
                               NULL,
                               szFile,
                               CCHMAXPATH))
        return FALSE;
    if ((hIni = PrfOpenProfile(WinQueryAnchorBlock(hwnd), szFile)) == NULLHANDLE)
        return FALSE;

    // free plugin resources
    for (i = 0; i < pTBData->cbPlugins; i++)
    {
        //Query The Plugin's CBZInit Function
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZDestroy",
                             (PFN *) & (pDestroyFn)) == NO_ERROR)
        {
            //Call the plugins destroy function.
            pDestroyFn(pTBData->Plugins[i].pData);
        }

        if (pTBData->Plugins[i].hModDll != NULLHANDLE)
            DosFreeModule(pTBData->Plugins[i].hModDll);
    }

    if (!runParser(themeFile, szClass, &List, szError))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", szError, 0UL);
        PrfCloseProfile(hIni);
        return FALSE;
    }

    strcpy(szPluginBase, szCBZBase);
    strcat(szPluginBase, "plugins\\");

    //update the windows memory.
    pTBData->cbPlugins = List.cbPlugins;

    //fill in ptb2 structure.
    for (i = 0; i < (pTBData->cbPlugins); i++)
    {
        //Initialize to some initial values...
        pTBData->Plugins[i].bActiveEnabled = TRUE;
        pTBData->Plugins[i].bInactiveEnabled = TRUE;
        pTBData->Plugins[i].pData = NULL;
        pTBData->Plugins[i].cbData = 0;

        //copy plugin names to shared memory.
        strcpy(pTBData->Plugins[i].szPluginDLL,
               List.pPluginAttributes[i].szPluginName);

        _makepath(szFile, NULL, szPluginBase, pTBData->Plugins[i].szPluginDLL, "DLL");
        //Load the Plugin Module
        if (DosLoadModule(szError, sizeof(szError), szFile,
                          &(pTBData->Plugins[i].hModDll)) != NO_ERROR)
        {
            //Error loading the dll...disable this plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            continue;           //end this iteration...try next plugin.

        }

        //Query The Plugin's CBZPluginDataSize Function
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZInit",
                             (PFN *) & (pInitFn)) != NO_ERROR)
        {
            //error in Plugin's initialization...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            continue;           //end this iteration..try next plugin.

        }
        //Call the Plugins Init function.
        if (!pInitFn(hIni, "", szClass, (PVOID *) & (pTBData->Plugins[i].pData)))
        {
            //error in Plugin's initialization...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            continue;           //end this iteration..try next plugin.

        }

        //Query the Plugin's Window Procedure.
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZPluginWndProc",
                (PFN *) & (pTBData->Plugins[i].pPluginWndProc)) != NO_ERROR)
        {
            //error getting the Plugin's WndProc...disable the plugin!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            DosFreeMem(pTBData->Plugins[i].pData);
            continue;           //end this iteration...try next plugin.

        }

        //Query the address of the plugin's Render function.
        if (DosQueryProcAddr(pTBData->Plugins[i].hModDll, 0, "CBZPluginRender",
               (PFN *) & (pTBData->Plugins[i].pfnPluginRender)) != NO_ERROR)
        {
            //Error getting CBZPluginRender function!
            pTBData->Plugins[i].bActiveEnabled = FALSE;
            pTBData->Plugins[i].bInactiveEnabled = FALSE;
            DosFreeModule(pTBData->Plugins[i].hModDll);
            DosFreeMem(pTBData->Plugins[i].pData);
            continue;           //end this iteration...try next plugin.

        }
    }                           //end active plugin for(..) loop

    for (j = 0; j < List.cbPlugins; j++)
    {

        for (i = 0; i < List.pPluginAttributes[j].cbAttributes; i++)
        {
            //If there is a %CBZBaseDir% in the attribute, replace it with the basePath
            if (strstr(List.pPluginAttributes[j].keyValue[i].value, "%CBZBaseDir%") != NULL)
            {
                //%CBZBaseDir% must be at the start of the string
                //allocate space for the new string
                tempPtr = (char *) malloc(sizeof(char) * (strlen(szCBZBase) + strlen(List.pPluginAttributes[j].keyValue[i].value) - strlen("%CBZBaseDir%") + 1));
                tempPtr[0] = '\0';
                strcat(tempPtr, szCBZBase);
                sscanf(List.pPluginAttributes[j].keyValue[i].value, "%%CBZBaseDir%%\\%s", szProfile);
                strcat(tempPtr, szProfile);
                free(List.pPluginAttributes[j].keyValue[i].value);
                //replace the old string with the new string.
                List.pPluginAttributes[j].keyValue[i].value = tempPtr;
            }
        }

        //plugins might not be in LIBPATH, create full path here.
        _makepath(szFile, NULL, szPluginBase, List.pPluginAttributes[j].szPluginName, "DLL");

        if (DosLoadModule(szError, sizeof(szError), szFile, &hMod) == NO_ERROR)
        {
            if (DosQueryProcAddr(hMod, 0, "CBZApply", (PFN *) & pApplyFn) == NO_ERROR)
            {
                if (pApplyFn == NULL)
                {
                    PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "pApplyFn is NULL!", 0UL);
                }

                //check return code from this to make sure it was sucessful.. if not disable the plugin
                pApplyFn(szClass, (List.pPluginAttributes[j].keyValue),
                         List.pPluginAttributes[j].cbAttributes,
                         List.pPluginAttributes[j].enabledState,
                         pTBData->Plugins[j].pData);
            }
            else
            {
                PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Failed Querying Procedure Address for CBZApply", 0UL);
            }
            DosFreeModule(hMod);
        }
        else
        {
            PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewBlock", "Error Querying Plugin Module.. (Missing?)", 0UL);
            pTBData->cbPlugins = j - 1;
            break;
            //disable it here
        }

    }

    //delete all the attributes in the plugin/key/value list
    CBZFreePLUGIN_LIST(&List);

    PrfCloseProfile(hIni);
    return TRUE;
}
示例#8
0
    int Ecppc::runGenerator()
    {
      // strip cpp-extension from outputfilename
      if (_ofile.size() == _ofile.rfind(".cpp") + 4)
        _ofile = _ofile.substr(0, _ofile.size() - 4);

      // create generator
      tnt::ecppc::Generator generator(_componentname);

      // initialize
      generator.enableLinenumbers(!_disableLinenumbers);
      Bodypart::enableLinenumbers(!_disableLinenumbers);

      if (!_mimetype.empty())
        generator.setMimetype(_mimetype);
      else if (!_extname.empty() && !_multibinary)
      {
        tnt::MimeDb db(_mimedb);
        std::string mimeType = db.getMimetype(_extname);
        if (mimeType.empty())
        {
          if (_extname != "ecpp")
            std::cerr << "warning: unknown mimetype" << std::endl;
        }
        else
          generator.setMimetype(mimeType);
      }

      generator.setCompress(_compress);
      generator.setLogCategory(_logCategory);

      std::string obase = _odir;
      if (!obase.empty())
        obase += '/';
      obase += _ofile;

      //
      // parse sourcefile
      //

      if (_multibinary)
      {
        tnt::MimeDb mimeDb;
        if (_mimetype.empty())
          mimeDb.read(_mimedb);

        for (inputfiles_type::const_iterator it = _inputFiles.begin(); it != _inputFiles.end(); ++it)
        {
          std::string key = it->first;
          std::string ifile = it->second;

          struct stat st;
          log_debug("check for input file " << ifile);
          if (stat(ifile.c_str(), &st) != 0)
          {
            // search for input file in includes list
            for (includes_type::const_iterator incl = _includes.begin(); incl != _includes.end(); ++incl)
            {
              std::string inputfile = *incl + '/' + it->second;
              log_debug("check for input file " << inputfile);
              if (stat(inputfile.c_str(), &st) == 0)
              {
                ifile = inputfile;
                break;
              }
            }
          }

          log_debug("read input file " << ifile);
          std::ifstream in(ifile.c_str());
          if (!in)
            throw std::runtime_error("can't read " + ifile);

          std::ostringstream content;
          content << in.rdbuf();

          std::string mime;
          if (!_mimetype.empty())
            mime = _mimetype;
          else
          {
            mime = mimeDb.getMimetype(ifile);
            if (mime.empty())
            {
              mime = "application/x-data";
              std::cerr << "warning: no mimetype found for \"" << ifile << "\" using " << mime << std::endl;
            }
          }

          generator.addImage(key, content.str(), mime, st.st_ctime);
        }
      }
      else
      {
        std::ifstream in(_inputfile);
        if (!in)
          throw std::runtime_error(std::string("can't read ") + _inputfile);

        if (_binary)
        {
          std::ostringstream html;
          html << in.rdbuf();
          generator.onHtml(html.str());
          generator.setRawMode();

          struct stat st;
          if (stat(_inputfile, &st) == 0)
            generator.setLastModifiedTime(st.st_ctime);
        }
        else
        {
          bool success = runParser(in, generator, true);
          if (!success)
            return 1;
        }
      }

      //
      // generate code
      //
      if (_verbose)
        std::cout << "generate " << obase << ".cpp" << std::endl;
      std::ofstream sout((obase + ".cpp").c_str());
      generator.getCpp(sout, _ofile + ".cpp");
      sout.close();

      if (!sout)
        throw std::runtime_error("error writing file \"" + _ofile + ".cpp\"");

      return 0;
    }
示例#9
0
bool ParseFile::parse(QString const& filePath, bool& addToFileList)
{
   QFileInfo fileInfo(filePath);
   addToFileList = true;
   
   if (!fileInfo.exists()) {
      QString msg("File not found: ");
      msg += fileInfo.filePath();
      m_filePaths.removeAll(filePath);
      m_errorList.append(msg);
      return false;
   }

   QString extension(fileInfo.suffix().toLower());
   Base* parser(0);

   if (extension == "run" || extension == "err" || extension == "bat") {
      return false;
   }

   if (extension == "xyz") {
      parser = new Xyz;
   }

   if (extension == "txt") {
      parser = new Xyz;
   }

   if (extension == "efp") {
      parser = new EfpFragment;
   }

   if (extension == "esp" || extension == "mo" || extension == "hf") {
      parser = new QChemPlot;
   }

   if (extension == "in"  || extension == "qcin"  || extension == "inp") {
      parser = new QChemInput;
   }

   if (extension == "out"  || extension == "qcout") {
      parser = new QChemOutput;
   }

   if (extension == "iqmol" || extension == "iqm") {
      parser = new IQmol;
   }

   if (extension == "cube" || extension == "cub") {
      parser = new Cube;
   }

   if (extension == "chg") {
      parser = new ExternalCharges;
   }

   if (extension == "fchk" || extension == "fck" || extension == "fch") {
      parser = new FormattedCheckpoint;
   }

   if (extension == "ply" || extension == "obj" || 
       extension == "stl" || extension == "off" ) {
       QLOG_DEBUG() << "Using Mesh parser";
      parser = new Mesh;
   }

   if (extension == "yaml" || extension == "cfg") {
      addToFileList = false;
      QLOG_DEBUG() << "Using Yaml parser";
      parser = new Yaml;
   }
 
   if (extension == "inc" || extension == "pov") {
      addToFileList = false;
      QLOG_DEBUG() << "Using PovRay parser";
      parser = new PovRay;
   }
   
   if (!parser && OpenBabel::formatSupported(extension)) {
      // Only if we do not have a custom parser do we let Open Babel at it
      QLOG_DEBUG() << "Using OpenBabel parser";
      parser = new OpenBabel;
   }

   if (!parser) {
      QLOG_WARN() << "Failed to find parser for file:" << filePath << " extension " << extension;
      return false;
   }

   runParser(parser, filePath);
   delete parser;
   return m_errorList.isEmpty();
}