diff options
Diffstat (limited to 'plugins/helpers')
-rw-r--r-- | plugins/helpers/gen_helpers.h | 24 | ||||
-rw-r--r-- | plugins/helpers/stshelpers.cpp | 303 | ||||
-rw-r--r-- | plugins/helpers/stshelpers.h | 35 | ||||
-rw-r--r-- | plugins/helpers/xmlhelpers.cpp | 418 | ||||
-rw-r--r-- | plugins/helpers/xmlhelpers.h | 17 |
5 files changed, 0 insertions, 797 deletions
diff --git a/plugins/helpers/gen_helpers.h b/plugins/helpers/gen_helpers.h index 110ea9d30a..896b2638f4 100644 --- a/plugins/helpers/gen_helpers.h +++ b/plugins/helpers/gen_helpers.h @@ -94,28 +94,4 @@ static __inline int log_fatalA(const char* fmt, ...) { return 0; } static __inline int log_fatal(const TCHAR* fmt, ...) { return 0; }
#endif
-int Hlp_UnicodeCheck(char *szPluginName, BOOL bFore, const char *szModule);
-#define UnicodeCheck(x, y) Hlp_UnicodeCheck(x, y, MODULENAME)
-
-static __inline char *variables_parsedupA(char *szFormat, char *szExtraText, HANDLE hContact) {
-
- if (ServiceExists(MS_VARS_FORMATSTRING)) {
- FORMATINFO fi;
- char *szParsed, *szResult;
-
- ZeroMemory(&fi, sizeof(fi));
- fi.cbSize = sizeof(fi);
- fi.szFormat = szFormat;
- fi.szExtraText = szExtraText;
- fi.hContact = hContact;
- szParsed = (char *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- if (szParsed) {
- szResult = _strdup(szParsed);
- CallService(MS_VARS_FREEMEMORY, (WPARAM)szParsed, 0);
- return szResult;
- }
- }
- return szFormat?_strdup(szFormat):szFormat;
-}
-
#endif
diff --git a/plugins/helpers/stshelpers.cpp b/plugins/helpers/stshelpers.cpp deleted file mode 100644 index abea62b3ba..0000000000 --- a/plugins/helpers/stshelpers.cpp +++ /dev/null @@ -1,303 +0,0 @@ -#include "commonheaders.h"
-#include "gen_helpers.h"
-#include <m_statusplugins.h>
-#include "stshelpers.h"
-
-static struct ProtoInfo {
- const char *szProto;
- UINT idEvent;
-};
-
-// note: accesses to pi are not synchronized... 'cause I'm a lazy SOB (and it's not necessary ATM)
-static struct ProtoInfo *pi = NULL;
-static int piCount = 0;
-static UINT g_idEvent = 0;
-static HWND hMessageWindow = NULL;
-static HANDLE hProtoAckHook = NULL;
-
-static VOID CALLBACK EnableProtoTimer(HWND hwnd, UINT message, UINT idEvent, DWORD dwTime) {
-
- int i;
-
- KillTimer(hwnd, idEvent);
- log_debugA("EnableProtoTimer");
- for (i=0;i<piCount;i++) {
- if (pi[i].idEvent == idEvent) {
- log_debugA("cleaning timer %d (%d) for %s (%x) (%d) (%d events left)", i, idEvent, pi[i].szProto, pi[i].szProto, pi[i].idEvent, piCount);
- if (i < piCount-1) {
- log_debugA("(1) pi[%d] (%s %x) pi[%d] (%s %x )", i, pi[i].szProto, pi[i].szProto, i+1, pi[i+1].szProto, pi[i+1].szProto);
- MoveMemory(&pi[i], &pi[i+1], (piCount-i-1)*sizeof(struct ProtoInfo));
- log_debugA("(2) pi[%d] (%s %x) pi[%d] (%s %x )", i, pi[i].szProto, pi[i].szProto, i+1, pi[i+1].szProto, pi[i+1].szProto);
- }
- if (piCount > 1) {
- pi = realloc(pi, (piCount-1)*sizeof(struct ProtoInfo));
- }
- else {
- free(pi);
- pi = NULL;
- log_debugA("(3) pi freed");
- }
- piCount -= 1;
- }
- }
-}
-
-static int ProtoAck(WPARAM wParam, LPARAM lParam) {
-
- int status;
- ACKDATA *ack;
-
- ack = (ACKDATA*)lParam;
- if (ack->type != ACKTYPE_STATUS) return 0;
- if (ack->result != ACKRESULT_SUCCESS) return 0;
- log_debugA("StatusHandling ProtoAck");
- status = CallProtoService(ack->szModule, PS_GETSTATUS, 0, 0);
- log_debugA("StatusHandling ProtoAck status=%d", status);
- if ( (status < MIN_STATUS) || (status > MAX_STATUS) ) {
- return 0;
- }
- pi = realloc(pi, (piCount+1)*sizeof(struct ProtoInfo));
- g_idEvent += 1;
- pi[piCount].idEvent = g_idEvent;
- pi[piCount].szProto = ack->szModule;
- piCount += 1;
- log_debugA("added timer %d for pi[%d] %s (%x)", pi[piCount-1].idEvent, piCount-1, ack->szModule, ack->szModule);
- SetTimer(hMessageWindow, g_idEvent, CONNECTIONTIMEOUT, EnableProtoTimer);
-
- return 0;
-}
-
-int InitProtoStatusChangedHandling() {
-
- if (hMessageWindow == NULL) {
- int i, count;
- PROTOCOLDESCRIPTOR **protos;
-
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&count, (LPARAM)&protos);
- for(i=0;i<count;i++) {
- if (protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue;
- //pi = realloc(pi, (piCount + 1)*sizeof(struct ProtoInfo));
- //ZeroMemory(&pi[piCount], sizeof(struct ProtoInfo));
- //pi[piCount].szProto = protos[i].szName;
- log_debugA("InitProtoStatusChangedHandling: %s added", protos[i]->szName);
- }
- hMessageWindow = CreateWindowExA(0, "STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
- hProtoAckHook = HookEvent(ME_PROTO_ACK, ProtoAck);
-
- return 0;
- }
-
- return 1;
-}
-
-int ProtoChangedStatus(char *szProto) {
-
- int i;
-
- log_debugA("ProtoChangedStatus %s", szProto);
- if (szProto != NULL) {
- for (i=0;i<piCount;i++) {
- if ( (pi[i].szProto != NULL) && (szProto != NULL) && (!strcmp(pi[i].szProto, szProto)) ) {
- log_debugA("%s just changed status", szProto);
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-int Flag2Status(unsigned long flag) {
-
- switch(flag) {
- case PF2_ONLINE: return ID_STATUS_ONLINE;
- case PF2_OFFLINE:
- case 0: return ID_STATUS_OFFLINE;
- case PF2_INVISIBLE: return ID_STATUS_INVISIBLE;
- case PF2_OUTTOLUNCH: return ID_STATUS_OUTTOLUNCH;
- case PF2_ONTHEPHONE: return ID_STATUS_ONTHEPHONE;
- case PF2_SHORTAWAY: return ID_STATUS_AWAY;
- case PF2_LONGAWAY: return ID_STATUS_NA;
- case PF2_LIGHTDND: return ID_STATUS_OCCUPIED;
- case PF2_HEAVYDND: return ID_STATUS_DND;
- case PF2_FREECHAT: return ID_STATUS_FREECHAT;
- case PF2_IDLE: return ID_STATUS_IDLE;
- case PF2_CURRENT: return ID_STATUS_CURRENT;
- case PF2_FROMTRIGGER: return ID_STATUS_FROMTRIGGER;
- }
- return 0;
-}
-
-unsigned long Status2Flag(int status) {
-
- switch(status) {
- case ID_STATUS_ONLINE: return PF2_ONLINE;
- case ID_STATUS_OFFLINE: return PF2_OFFLINE;
- case ID_STATUS_INVISIBLE: return PF2_INVISIBLE;
- case ID_STATUS_OUTTOLUNCH: return PF2_OUTTOLUNCH;
- case ID_STATUS_ONTHEPHONE: return PF2_ONTHEPHONE;
- case ID_STATUS_AWAY: return PF2_SHORTAWAY;
- case ID_STATUS_NA: return PF2_LONGAWAY;
- case ID_STATUS_OCCUPIED: return PF2_LIGHTDND;
- case ID_STATUS_DND: return PF2_HEAVYDND;
- case ID_STATUS_FREECHAT: return PF2_FREECHAT;
- case ID_STATUS_IDLE: return PF2_IDLE;
- case ID_STATUS_CURRENT: return PF2_CURRENT;
- case ID_STATUS_FROMTRIGGER: return PF2_FROMTRIGGER;
- }
- return 0;
-}
-
-static int GetActualStatus(SETSTATUSINFO *ssi) {
-
- if ( (ssi->status == ID_STATUS_CURRENT) || (ssi->flags&SSIF_DONTSETSTATUS) ) {
- return CallProtoService(ssi->szProto, PS_GETSTATUS, 0, 0);
- }
-
- return ssi->status;
-}
-
-static int EqualsGlobalStatus(SETSTATUSINFO *ssi, int count) {
-
- PROTOCOLDESCRIPTOR **protos;
- int i, j, protoCount, pstatus, gstatus;
-
- if ( (count == 1) && (ssi[0].flags&SSIF_USEAWAYSYS) && (ssi[0].szProto == NULL) ) {
- return ssi[0].status;
- }
- pstatus = gstatus = 0;
- CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&protos);
- for (i=0;i<protoCount;i++) {
- if ( (protos[i]->type != PROTOTYPE_PROTOCOL) || (CallProtoService(ssi[i].szProto, PS_GETCAPS, PFLAGNUM_2, 0) == 0)) continue;
- pstatus = 0;
- for (j=0;j<count;j++) {
- if (!strcmp(protos[i]->szName, ssi[j].szProto)) {
- if (ssi[j].flags&SSIF_DONTSETSTATUS) {
- // not all proto's will be set
- return 0;
- }
- if (!(ssi[j].flags&SSIF_USEAWAYSYS)) {
- // not all proto's handled by awaysys
- return 0;
- }
- pstatus = GetActualStatus(&ssi[j]);
- }
- else {
- // not all proto's will be set
- return 0;
- }
- }
- if (pstatus == 0) {
- pstatus = CallProtoService(protos[i]->szName, PS_GETSTATUS, 0, 0);
- }
- if (gstatus == 0) {
- gstatus = pstatus;
- }
- if (pstatus != gstatus) {
- return 0;
- }
- }
-
- return gstatus;
-}
-
-// helper, from core
-static char *GetDefaultMessage(int status)
-{
- switch(status) {
- case ID_STATUS_AWAY: return Translate("I've been away since %time%.");
- case ID_STATUS_NA: return Translate("Give it up, I'm not in!");
- case ID_STATUS_OCCUPIED: return Translate("Not right now.");
- case ID_STATUS_DND: return Translate("Give a guy some peace, would ya?");
- case ID_STATUS_FREECHAT: return Translate("I'm a chatbot!");
- case ID_STATUS_ONLINE: return Translate("Yep, I'm here.");
- case ID_STATUS_OFFLINE: return Translate("Nope, not here.");
- case ID_STATUS_INVISIBLE: return Translate("I'm hiding from the mafia.");
- case ID_STATUS_ONTHEPHONE: return Translate("That'll be the phone.");
- case ID_STATUS_OUTTOLUNCH: return Translate("Mmm...food.");
- case ID_STATUS_IDLE: return Translate("idleeeeeeee");
- }
- return NULL;
-}
-
-static char *GetDefaultStatusMessage(int newstatus) {
-
- char *sMsg, *tMsg;
-
- sMsg = NULL;
- if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) {
- tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, 0);
- if (tMsg != NULL) {
- sMsg = _strdup(tMsg);
- mir_free(tMsg);
- }
- }
- else {
- tMsg = GetDefaultMessage(newstatus); /* awaysys doesn't define the service above */
- if (tMsg != NULL) {
- sMsg = _strdup(tMsg);
- }
- }
-
- return sMsg;
-}
-
-int Hlp_SetStatus(SETSTATUSINFO *ssi, int count) {
-
- int i, status;
- char *szMsg;
-
- status = EqualsGlobalStatus(ssi, count);
- if (status != 0) {
- log_debugA("Hlp_SetStatus: Setting global status");
- CallService(MS_CLIST_SETSTATUSMODE, (WPARAM)status, 0);
- return 0;
- }
- for (i=0;i<count;i++) {
- if (!CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)ssi[i].szProto)) {
- log_debugA("Hlp_SetStatus: %s not loaded", ssi[i].szProto);
- continue;
- }
- status = GetActualStatus(&ssi[i]);
- if (!(ssi[i].flags&SSIF_DONTSETSTATUS)) {
- if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) {
- log_debugA("Hlp_SetStatus: Announcing status change to KeepStatus");
- announce_status_change(ssi[i].szProto, status, ssi[i].flags&SSIF_DONTSETMESSAGE?NULL:ssi[i].szMsg);
- }
- log_debugA("Hlp_SetStatus: Setting status %d for %s", status, ssi[i].szProto);
- CallProtoService(ssi[i].szProto, PS_SETSTATUS, (WPARAM)status, 0);
- }
- if (!(ssi[i].flags&SSIF_DONTSETMESSAGE)) {
- if (ssi[i].flags&SSIF_USEAWAYSYS) {
- szMsg = GetDefaultStatusMessage(status);
- }
- else {
- if (ssi[i].szMsg != NULL) {
- szMsg = _strdup(ssi[i].szMsg);
- }
- else {
- szMsg = NULL;
- }
- }
- log_debugA("Hlp_SetStatus: Setting statusmessage for %d for %s", status, ssi[i].szProto);
- CallProtoService(ssi[i].szProto, PS_SETAWAYMSG, (WPARAM)status, (LPARAM)szMsg);
- if (szMsg != NULL) {
- free(szMsg);
- }
- }
- }
-
- return 0;
-}
-
-void Hlp_FreeStatusInfo(SETSTATUSINFO *ssi, int count) {
-
- int i;
-
- for (i=0;i<count;i++) {
- if (ssi[i].szMsg != NULL) {
- free(ssi[i].szMsg);
- }
- }
-}
\ No newline at end of file diff --git a/plugins/helpers/stshelpers.h b/plugins/helpers/stshelpers.h deleted file mode 100644 index f0fbca8fae..0000000000 --- a/plugins/helpers/stshelpers.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __STSHELPERS__
-#define __STSHELPERS__
-#define PF2_FROMTRIGGER 0x00002000
-#define PF2_CURRENT 0x00001000
-#define PF2_OFFLINE 0x00000800
-#define ID_STATUS_CURRENT 41000
-#define ID_STATUS_FROMTRIGGER 41001
-
-#define MIN_STATUS ID_STATUS_OFFLINE
-#define MAX_STATUS ID_STATUS_OUTTOLUNCH
-
-#define SSIF_DONTSETSTATUS 0x01
-#define SSIF_DONTSETMESSAGE 0x02
-#define SSIF_USEAWAYSYS 0x04
-
-typedef struct {
- char *szProto;
- int flags;
- int status;
- char *szMsg;
-} SETSTATUSINFO;
-
-// find out whether a proto just changed status
-#define CONNECTIONTIMEOUT 6000 // same value as NewStatusNotify
-// call this...
-int InitProtoStatusChangedHandling();
-// ...if you want to use this
-int ProtoChangedStatus(char *szProto);
-
-int Flag2Status(unsigned long flag); // only if flag is only one status
-unsigned long Status2Flag(int status);
-int Hlp_SetStatus(SETSTATUSINFO *ssi, int count);
-void Hlp_FreeStatusInfo(SETSTATUSINFO *ssi, int count);
-
-#endif
diff --git a/plugins/helpers/xmlhelpers.cpp b/plugins/helpers/xmlhelpers.cpp deleted file mode 100644 index b6d3fa70c8..0000000000 --- a/plugins/helpers/xmlhelpers.cpp +++ /dev/null @@ -1,418 +0,0 @@ -#include "commonheaders.h"
-#include "gen_helpers.h"
-
-char *XMLEncodeString(TCHAR *tszSrc) {
-
- int cur, len;
- TCHAR *tszEsc, *tszRep;
- char *szRes;
-
- if (tszSrc == NULL) {
- return NULL;
- }
- tszEsc = _tcsdup(tszSrc);
- cur = len = 0;
- while (tszEsc[cur] != _T('\0')) {
- tszRep = NULL;
- switch (tszEsc[cur]) {
- case _T('<'):
- len = 1;
- tszRep = _T("<");
- break;
- case _T('>'):
- len = 1;
- tszRep = _T(">");
- break;
- case _T('&'):
- len = 1;
- tszRep = _T("&");
- break;
- case _T('\''):
- len = 1;
- tszRep = _T("'");
- break;
- case _T('"'):
- len = 1;
- tszRep = _T(""");
- break;
- case _T('\r'):
- if (tszEsc[cur+1] == _T('\n')) {
- len = 2;
- tszRep = _T("
");
- }
- break;
- case _T('\n'):
- len = 1;
- tszRep = _T("
");
- break;
- }
- // tszRep > len !!!
- if (tszRep != NULL) {
- tszEsc = realloc(tszEsc, (_tcslen(tszEsc) + _tcslen(tszRep) - len + 1)*sizeof(TCHAR));
- MoveMemory(&tszEsc[cur+_tcslen(tszRep) - len], &tszEsc[cur], _tcslen(&tszEsc[cur]) + 1);
- CopyMemory(&tszEsc[cur], tszRep, _tcslen(tszRep)*sizeof(TCHAR));
- cur += _tcslen(tszRep);
- }
- else {
- cur++;
- }
- }
-#ifdef UNICODE
- szRes = Utf8EncodeUcs2(tszEsc);
-#else
- szRes = Utf8Encode(tszEsc);
-#endif
- free(tszEsc);
-
- return szRes;
-}
-
-char *XMLEncodeStringA(char *szSrc) {
-
- int cur, len;
- char *szEsc, *szRep;
-
- if (szSrc == NULL) {
- return NULL;
- }
- szEsc = _strdup(szSrc);
- cur = len = 0;
- while (szEsc[cur] != '\0') {
- szRep = NULL;
- switch (szEsc[cur]) {
- case '<':
- len = 1;
- szRep = "<";
- break;
- case '>':
- len = 1;
- szRep = ">";
- break;
- case '&':
- len = 1;
- szRep = "&";
- break;
- case '\'':
- len = 1;
- szRep = "'";
- break;
- case '"':
- len = 1;
- szRep = """;
- break;
- case '\r':
- if (szEsc[cur+1] == '\n') {
- len = 2;
- szRep = "
";
- }
- break;
- case '\n':
- len = 1;
- szRep = "
";
- break;
- }
- if (szRep != NULL) {
- szEsc = realloc(szEsc, (strlen(szEsc) + strlen(szRep) - len + 1));
- MoveMemory(&szEsc[cur+strlen(szRep) - len], &szEsc[cur], strlen(&szEsc[cur]) + 1);
- CopyMemory(&szEsc[cur], szRep, strlen(szRep));
- cur+=strlen(szRep);
- }
- else {
- cur++;
- }
- }
-
- return szEsc;
-}
-
-TCHAR *DecodeXMLString(char *szSrc) {
-
- int cur;
- TCHAR *tszEsc, *tszRep, *tszTrans;
- char *szEsc;
-#ifdef UNICODE
- wchar_t *wszEsc;
-#endif
-
- if (szSrc == NULL) {
- return NULL;
- }
- szEsc = _strdup(szSrc);
-#ifdef UNICODE
- Utf8Decode(szEsc, &wszEsc);
- tszEsc = wszEsc;
- free(szEsc);
-#else
- Utf8Decode(szEsc, NULL);
- tszEsc = szEsc;
-#endif
- cur= 0;
- while (tszEsc[cur] != _T('\0')) {
- tszRep = NULL;
- if (!_tcsncmp(&tszEsc[cur], _T("<"), 4)) {
- tszRep = _T("<");
- tszTrans = _T("<");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T(">"), 4)) {
- tszRep = _T(">");
- tszTrans = _T(">");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("&"), 5)) {
- tszRep = _T("&");
- tszTrans = _T("&");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("'"), 6)) {
- tszRep = _T("'");
- tszTrans = _T("\'");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("""), 6)) {
- tszRep = _T(""");
- tszTrans = _T("&");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("
"), 5)) {
- tszRep = _T("
");
- tszTrans = _T("\r\n");
- }
- if (tszRep != NULL) {
- tszEsc = realloc(tszEsc, (_tcslen(tszEsc) - _tcslen(tszRep) + _tcslen(tszTrans) + 1)*sizeof(TCHAR));
- MoveMemory(&tszEsc[cur+_tcslen(tszTrans)], &tszEsc[cur+_tcslen(tszRep)], _tcslen(&tszEsc[cur+_tcslen(tszRep)]) + 1);
- CopyMemory(&tszEsc[cur], tszTrans, _tcslen(tszTrans)*sizeof(TCHAR));
- cur += _tcslen(tszTrans);
- }
- else {
- cur++;
- }
- }
-
- return tszEsc;
-}
-
-char *DecodeXMLStringA(char *szSrc, BOOL bUtfDecode) {
-
- int cur;
- char *szEsc, *szRep, *szTrans;
-
- if (szSrc == NULL) {
- return NULL;
- }
- szEsc = _strdup(szSrc);
- if (bUtfDecode) {
- Utf8Decode(szEsc, NULL);
- }
- cur= 0;
- while (szEsc[cur] != '\0') {
- szRep = NULL;
- if (!strncmp(&szEsc[cur], "<", 4)) {
- szRep = "<";
- szTrans = "<";
- }
- else if (!strncmp(&szEsc[cur], ">", 4)) {
- szRep = ">";
- szTrans = ">";
- }
- else if (!strncmp(&szEsc[cur], "&", 5)) {
- szRep = "&";
- szTrans = "&";
- }
- else if (!strncmp(&szEsc[cur], "'", 6)) {
- szRep = "'";
- szTrans = "'";
- }
- else if (!strncmp(&szEsc[cur], """, 6)) {
- szRep = """;
- szTrans = "&";
- }
- else if (!strncmp(&szEsc[cur], "
", 5)) {
- szRep = "
";
- szTrans = "\r\n";
- }
- if (szRep != NULL) {
- szEsc = realloc(szEsc, (strlen(szEsc) - strlen(szRep) + strlen(szTrans) + 1));
- MoveMemory(&szEsc[cur+strlen(szTrans)], &szEsc[cur+strlen(szRep)], strlen(&szEsc[cur+strlen(szRep)]) + 1);
- CopyMemory(&szEsc[cur], szTrans, strlen(szTrans));
- cur += strlen(szTrans);
- }
- else {
- cur++;
- }
- }
-
- return szEsc;
-}
-
-void AppendXMLOpeningTag(char **szBuf, char *szTag, int *depth) {
-
- char *cur;
-
- *depth += 1;
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + *depth + 4);
- cur = *szBuf+strlen(*szBuf);
- *cur = '\n';
- if (*depth > 0) {
- memset(cur+1, ' ', *depth);
- }
- *(cur+1+*depth) = '\0';
- sprintf(*szBuf+strlen(*szBuf), "<%s>", szTag);
-}
-
-void AppendXMLClosingTag(char **szBuf, char *szTag, int *depth) {
-
- char *cur;
-
- *depth -= 1;
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + *depth + 5);
- cur = *szBuf+strlen(*szBuf);
- *cur = '\n';
- if (*depth > 0) {
- memset(cur+1, ' ', *depth);
- }
- *(cur+1+*depth) = '\0';
- sprintf(*szBuf+strlen(*szBuf), "</%s>", szTag);
-}
-
-void AppendXMLTag(char **szBuf, char *szTag, char *szAtts, int *depth) {
-
- char *cur;
-
- *depth += 1;
- if (szAtts != NULL) {
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + strlen(szAtts) + *depth + 6);
- }
- else {
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + *depth + 5);
- }
- cur = *szBuf+strlen(*szBuf);
- *cur = '\n';
- if (*depth > 0) {
- memset(cur+1, ' ', *depth);
- }
- *(cur+1+*depth) = '\0';
- if (szAtts != NULL) {
- sprintf(*szBuf+strlen(*szBuf), "<%s %s/>", szTag, szAtts);
- }
- else {
- sprintf(*szBuf+strlen(*szBuf), "<%s/>", szTag);
- }
- *depth -= 1;
-}
-
-char *GetSettingType(BYTE type) {
-
- switch (type) {
- case DBVT_BYTE:
- return "BYTE";
- case DBVT_WORD:
- return "WORD";
- case DBVT_DWORD:
- return "DWORD";
- case DBVT_ASCIIZ:
- return "ASCIIZ";
- case DBVT_BLOB:
- return "BLOB";
- case DBVT_UTF8:
- return "UTF8";
- case DBVT_WCHAR:
- return "WCHAR";
- }
- return "UNKNOWN";
-}
-
-void AppendXMLTagTString(char **szBuf, char *szTag, TCHAR *tszVal, int *depth) {
-
- char *szVal, *szAtts, *szType;
-
- szVal = XMLEncodeString(tszVal);
-#ifdef UNICODE
- szType = GetSettingType(DBVT_WCHAR);
-#else
- szType = GetSettingType(DBVT_ASCIIZ);
-#endif
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
- free(szVal);
-}
-
-void AppendXMLTagString(char **szBuf, char *szTag, char *szVal, int *depth) {
-
- char *szEnc, *szAtts, *szType;
-
- szEnc = XMLEncodeStringA(szVal);
- szType = GetSettingType(DBVT_ASCIIZ);
- szAtts = malloc(strlen(szEnc) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szEnc);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
- free(szEnc);
-}
-
-void AppendXMLTagUtfString(char **szBuf, char *szTag, char *szVal, int *depth) {
-
- char *szEnc, *szAtts, *szType;
-
- szEnc = XMLEncodeStringA(szVal);
- szType = GetSettingType(DBVT_UTF8);
- szAtts = malloc(strlen(szEnc) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szEnc);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
- free(szEnc);
-}
-
-void AppendXMLTagByte(char **szBuf, char *szTag, BYTE bVal, int *depth) {
-
- char szVal[64], *szAtts, *szType;
-
- mir_snprintf(szVal, sizeof(szVal), "0x%x", bVal);
- szType = GetSettingType(DBVT_BYTE);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
-
-void AppendXMLTagWord(char **szBuf, char *szTag, WORD wVal, int *depth) {
-
- char szVal[64], *szAtts, *szType;
-
- mir_snprintf(szVal, sizeof(szVal), "0x%x", wVal);
- szType = GetSettingType(DBVT_WORD);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
-
-void AppendXMLTagDword(char **szBuf, char *szTag, DWORD dVal, int *depth) {
-
- char szVal[64], *szAtts, *szType;
-
- mir_snprintf(szVal, sizeof(szVal), "0x%x", dVal);
- szType = GetSettingType(DBVT_DWORD);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
-
-void AppendXMLTagBlob(char **szBuf, char *szTag, BYTE *pBlob, int cbBlob, int *depth) {
-
- int maxLen;
- char *szType, *szVal, *szAtts;
- NETLIBBASE64 nlb;
-
- maxLen = Netlib_GetBase64EncodedBufferSize(cbBlob);
- szVal = malloc(maxLen + 1);
- ZeroMemory(&nlb, sizeof(NETLIBBASE64));
- nlb.cbDecoded = cbBlob;
- nlb.pbDecoded = pBlob;
- nlb.cchEncoded = maxLen;
- nlb.pszEncoded = szVal;
- CallService(MS_NETLIB_BASE64ENCODE, 0, (LPARAM)&nlb);
- szType = GetSettingType(DBVT_BLOB);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
diff --git a/plugins/helpers/xmlhelpers.h b/plugins/helpers/xmlhelpers.h deleted file mode 100644 index dd0cc822a7..0000000000 --- a/plugins/helpers/xmlhelpers.h +++ /dev/null @@ -1,17 +0,0 @@ -void AppendXMLOpeningTag(char **szBuf, char *szTag, int *depth);
-void AppendXMLClosingTag(char **szBuf, char *szTag, int *depth);
-void AppendXMLTag(char **szBuf, char *szTag, char *szAtts, int *depth);
-
-char *GetSettingType(BYTE type);
-void AppendXMLTagTString(char **szBuf, char *szTag, TCHAR *tszVal, int *depth);
-void AppendXMLTagString(char **szBuf, char *szTag, char *szVal, int *depth);
-void AppendXMLTagUtfString(char **szBuf, char *szTag, char *szVal, int *depth);
-void AppendXMLTagByte(char **szBuf, char *szTag, BYTE bVal, int *depth);
-void AppendXMLTagWord(char **szBuf, char *szTag, WORD wVal, int *depth);
-void AppendXMLTagDword(char **szBuf, char *szTag, DWORD dVal, int *depth);
-void AppendXMLTagBlob(char **szBuf, char *szTag, BYTE *pBlob, int cbBlob, int *depth);
-
-char *XMLEncodeString(TCHAR *szSrc);
-char *XMLEncodeStringA(char *tszSrc);
-TCHAR *DecodeXMLString(char *szSrc);
-char *DecodeXMLStringA(char *szSrc, BOOL bUtfDecode);
|