Skip to content

Commit

Permalink
Adapted to comply to Notepad++'s standard locations for a plug-in, it…
Browse files Browse the repository at this point in the history
…s configuration file and its support files.

i.e.
    Notepad++
    \--- plugins
         |    XMLTools.dll
         +--- Config
         |       XMLToolsExt.ini
         \--- XMLTools
                 libcurl.dll
                 libiconv-2.dll
                 etc.
  • Loading branch information
MAPJe71 committed Aug 14, 2016
1 parent 7fca0fb commit 3b266ec
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 182 deletions.
41 changes: 26 additions & 15 deletions LoadLibrary.cpp
Expand Up @@ -77,8 +77,8 @@ int (*pXmlKeepBlanksDefault)(int val);
int (*pXmlThrDefIndentTreeOutput)(int v);
const char * (*pXmlThrDefTreeIndentString)(const char * v);

void (*pXmlNanoHTTPInit)(void);
void (*pXmlNanoHTTPScanProxy)(const char * URL);
void (*pXmlNanoHTTPInit)(void);
void (*pXmlNanoHTTPScanProxy)(const char * URL);
const char * (*pXmlNanoHTTPAuthHeader)(void *ctx);


Expand All @@ -96,21 +96,32 @@ xsltTransformContextPtr(*pXsltNewTransformContext)(xsltStylesheetPtr style, xmlD
//-------------------------------------------------------------------------------------------------

HINSTANCE loadExtLib(const wchar_t* libFilename, const wchar_t* nppMainPath, const wchar_t* appDataPath) {
wchar_t pszPath[MAX_PATH] = { '\0' };
HINSTANCE res = LoadLibrary(libFilename);
wchar_t pszPath[MAX_PATH] = { '\0' };

// try loading from NPP plugins path (standard NPP location)
Report::strcpy(pszPath, nppMainPath);
PathAppend(pszPath, L"plugins\\XMLTools\\");
PathAppend(pszPath, libFilename);
HINSTANCE res = LoadLibrary(pszPath);

if (res == NULL) {
// try loading from main npp path
Report::strcpy(pszPath, nppMainPath);
PathAppend(pszPath, L"\\XMLTools\\");
// try loading from %appdata% path (standard NPP UAC/AppData location)
Report::strcpy(pszPath, appDataPath);
PathAppend(pszPath, L"Notepad++\\");
PathAppend(pszPath, libFilename);
res = LoadLibrary(pszPath);
res = LoadLibrary(pszPath);

// try loading from %appdata% path
if (res == NULL) {
Report::strcpy(pszPath, appDataPath);
PathAppend(pszPath, L"\\Notepad++\\");
// try loading from NPP sub path
Report::strcpy(pszPath, nppMainPath);
PathAppend(pszPath, L"XMLTools\\");
PathAppend(pszPath, libFilename);
res = LoadLibrary(pszPath);

if (res == NULL) {
// try loading (from NPP main path)
res = LoadLibrary(libFilename);
}
}
}
return res;
Expand All @@ -121,18 +132,18 @@ int loadLibraries(wchar_t* nppMainPath, wchar_t* appDataPath) {
HKEY hKey = NULL;
DWORD size = MAX_PATH;

// loading dependances
// loading dependencies
if (loadExtLib(L"libiconv-2.dll", nppMainPath, appDataPath) == NULL) return -1;
if (loadExtLib(L"zlib1.dll", nppMainPath, appDataPath) == NULL) return -1;
if (loadExtLib(L"libwinpthread-1.dll", nppMainPath, appDataPath) == NULL) return -1;

// loading libxml
// loading LIBXML
hInstLibXML = loadExtLib(L"libxml2-2.dll", nppMainPath, appDataPath);
if (hInstLibXML == NULL) {
return -1;
}

// loading libxslt
// loading LIBXSLT
hInstLibXSL = loadExtLib(L"libxslt-1.dll", nppMainPath, appDataPath);
if (hInstLibXSL == NULL) {
return -1;
Expand Down Expand Up @@ -221,7 +232,7 @@ int loadLibraries(wchar_t* nppMainPath, wchar_t* appDataPath) {
}

/*
xmlNodePtr pXmlRemoveNs(xmlNodePtr tree,xmlNsPtr ns) {
xmlNodePtr pXmlRemoveNs(xmlNodePtr tree, xmlNsPtr ns) {
xmlNsPtr nsDef,prev;
xmlNodePtr node = tree;
xmlNodePtr declNode = NULL;
Expand Down
2 changes: 1 addition & 1 deletion OptionsDlg.cpp
Expand Up @@ -52,7 +52,7 @@ BOOL COptionsDlg::OnInitDialog()
((CButton*) GetDlgItem(IDC_CHKENABLEPROXY))->SetCheck(BST_UNCHECKED);
}
GetDlgItem(IDC_EDITPROXYHOST)->SetWindowTextW(this->proxyoptions->host);
GetDlgItem(IDC_EDITPROXYPORT)->SetWindowTextW(std::to_wstring(this->proxyoptions->port).c_str());
GetDlgItem(IDC_EDITPROXYPORT)->SetWindowTextW(std::to_wstring(static_cast<long long>(this->proxyoptions->port)).c_str());
//GetDlgItem(IDC_EDITPROXYUSERNAME)->SetWindowTextW(this->proxyoptions->username);
//GetDlgItem(IDC_EDITPROXYPASSWORD)->SetWindowTextW(this->proxyoptions->password);
}
Expand Down

0 comments on commit 3b266ec

Please sign in to comment.