summaryrefslogtreecommitdiff
path: root/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp')
-rw-r--r--[-rwxr-xr-x]plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp47
1 files changed, 27 insertions, 20 deletions
diff --git a/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp b/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp
index 7ee05ed..5330492 100755..100644
--- a/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp
+++ b/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp
@@ -1,31 +1,38 @@
/** \file ExtraSocketCatchcopy.cpp
\brief Define the socket of catchcopy
-\author alpha_one_x86
-\version 0002
-\date 2010 */
+\author alpha_one_x86 */
#include "ExtraSocketCatchcopy.h"
+#include <stdio.h>
+
const QString ExtraSocketCatchcopy::pathSocket()
{
#ifdef Q_OS_UNIX
- return "advanced-copier-"+QString::number(getuid());
+ return "advanced-copier-"+QString::number(getuid());
#else
- QString userName;
- DWORD size=0;
- if(GetUserNameW(NULL,&size) || (GetLastError()!=ERROR_INSUFFICIENT_BUFFER))
- {
- }
- else
- {
- WCHAR * userNameW=new WCHAR[size];
- if(GetUserNameW(userNameW,&size))
- {
- userName.fromWCharArray(userNameW,size*2);
- userName=QString(QByteArray((char*)userNameW,size*2-2).toHex());
- }
- delete userNameW;
- }
- return "advanced-copier-"+userName;
+ QString userName;
+ char uname[1024];
+ DWORD len=1023;
+ if(GetUserNameA(uname, &len)!=FALSE)
+ userName=QString::fromLatin1(toHex(uname));
+ return "advanced-copier-"+userName;
#endif
}
+
+char * ExtraSocketCatchcopy::toHex(const char *str)
+{
+ char *p, *sz;
+ size_t len;
+ if (str==NULL)
+ return NULL;
+ len= strlen(str);
+ p = sz = (char *) malloc((len+1)*4);
+ for (size_t i=0; i<len; i++)
+ {
+ sprintf(p, "%.2x00", str[i]);
+ p+=4;
+ }
+ *p=0;
+ return sz;
+}