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--plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp b/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp
new file mode 100644
index 0000000..9cd8373
--- /dev/null
+++ b/plugins/Listener/catchcopy-v0002/catchcopy-api-0002/ExtraSocketCatchcopy.cpp
@@ -0,0 +1,38 @@
+/** \file ExtraSocketCatchcopy.cpp
+\brief Define the socket of catchcopy
+\author alpha_one_x86 */
+
+#include "ExtraSocketCatchcopy.h"
+
+#include <stdio.h>
+
+const std::string ExtraSocketCatchcopy::pathSocket()
+{
+#ifdef Q_OS_UNIX
+ return "advanced-copier-"+std::to_string(getuid());
+#else
+ QString userName;
+ char uname[1024];
+ DWORD len=1023;
+ if(GetUserNameA(uname, &len)!=FALSE)
+ userName=QString::fromLatin1(toHex(uname));
+ return "advanced-copier-"+userName.toStdString();
+#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;
+}