diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-03-03 05:24:57 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-03-03 05:24:57 +0000 |
commit | b7aa7ea29a5fab12adc0e4ca105e437d16fee555 (patch) | |
tree | 831765c9d9e4a666a8243cb8ec6bb333801869cd /plugins/NotifyAnything | |
parent | b2c26e66f54b87f2d2b035ad4a41c1f764ee38c6 (diff) |
- restored files, deleted by mistake
git-svn-id: http://svn.miranda-ng.org/main/trunk@3857 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NotifyAnything')
-rw-r--r-- | plugins/NotifyAnything/sendlog/SLImp.cpp | 94 | ||||
-rw-r--r-- | plugins/NotifyAnything/sendlog/SendLog.cpp | 38 | ||||
-rw-r--r-- | plugins/NotifyAnything/sendlog/SendLogWin.cpp | 30 | ||||
-rw-r--r-- | plugins/NotifyAnything/sendlog/compile.bat | 31 |
4 files changed, 193 insertions, 0 deletions
diff --git a/plugins/NotifyAnything/sendlog/SLImp.cpp b/plugins/NotifyAnything/sendlog/SLImp.cpp new file mode 100644 index 0000000000..0a4b69e81c --- /dev/null +++ b/plugins/NotifyAnything/sendlog/SLImp.cpp @@ -0,0 +1,94 @@ +#define _WINSOCKAPI_ // don't include winsock 1.x
+#include <windows.h>
+#include <winioctl.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string>
+#include <iostream>
+
+void implementation(int argc, char **argv, bool console)
+{
+ int port = 12001;
+ bool tcp = false;
+ const char *target = "127.0.0.1";
+
+ if (argc >= 2 && !strcmp("-T", argv[1])) {
+ tcp = true;
+ argc -= 1;
+ argv += 1;
+ }
+
+ if (argc >= 3 && !strcmp("-H", argv[1])) {
+ target = argv[2];
+ argc -= 2;
+ argv += 2;
+ }
+
+ if (argc >= 3 && !strcmp("-P", argv[1])) {
+ port = atoi(argv[2]);
+ argc -= 2;
+ argv += 2;
+ }
+
+ WSADATA wsaData;
+ int err = WSAStartup(MAKEWORD(2, 2), &wsaData);
+ if (err)
+ throw (DWORD) err;
+
+ char portbuf[10];
+ sprintf(portbuf, "%i", port);
+
+ ADDRINFO hints;
+ memset(&hints, 0, sizeof hints);
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_family = PF_INET;
+ ADDRINFO *res;
+ err = getaddrinfo(target, portbuf, &hints, &res);
+
+ if (err || !res)
+ throw (DWORD) err;
+
+ SOCKET sock;
+ SOCKADDR_IN to = *(SOCKADDR_IN*)res->ai_addr;
+
+ sock = socket(AF_INET, tcp ? SOCK_STREAM : SOCK_DGRAM, tcp ? IPPROTO_TCP : IPPROTO_UDP);
+ if (sock == INVALID_SOCKET)
+ throw (DWORD) WSAGetLastError();
+
+ SOCKADDR_IN self;
+ ZeroMemory(&self, sizeof self);
+ self.sin_family = AF_INET;
+
+ if (bind(sock, (const SOCKADDR *) &self, sizeof self))
+ throw (DWORD) WSAGetLastError();
+
+ if (connect(sock, (const SOCKADDR *) &to, sizeof to))
+ throw (DWORD) WSAGetLastError();
+
+ if (console && (argc == 1 || argc == 3 && !strcmp("-p", argv[1]))) {
+ std::string prefix;
+ if (argc == 3)
+ prefix = argv[2];
+ std::string line;
+ while (std::getline(std::cin, line)) {
+ std::string data = prefix + line;
+ send(sock, data.data(), data.size(), 0);
+ }
+ } else {
+ std::string message = argv[1];
+ for (int i=2; i<argc; ++i) {
+ message += ' ';
+ message += argv[i];
+ }
+ send(sock, message.data(), message.size(), 0);
+ }
+
+ shutdown(sock, SD_BOTH);
+ closesocket(sock);
+
+ WSACleanup();
+}
diff --git a/plugins/NotifyAnything/sendlog/SendLog.cpp b/plugins/NotifyAnything/sendlog/SendLog.cpp new file mode 100644 index 0000000000..5cb46932da --- /dev/null +++ b/plugins/NotifyAnything/sendlog/SendLog.cpp @@ -0,0 +1,38 @@ +#include <windows.h>
+#include <winsock.h>
+
+#include <iostream>
+#include <string>
+
+void implementation(int argc, char **argv, bool console);
+
+int main(int argc, char **argv)
+try
+{
+ if (argc == 2 && !strcmp("/?", argv[1])) {
+ std::cout << "\n"
+ "Syntax: sendlog [-T] [-H host] [-P port] [-p prefix]\n"
+ "\tSends each input line as a separate message, with optional prefix.\n"
+ "\n"
+ "Syntax: sendlog text\n"
+ "\tSends single text message.\n"
+ "\n"
+ << std::flush;
+ return 0;
+ }
+
+ implementation(argc, argv, true);
+}
+catch (DWORD err) {
+ LPVOID lpMsgBuf;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
+
+ std::cerr << (LPCTSTR)lpMsgBuf << std::endl;
+ if (!std::cerr)
+ MessageBox(NULL, (LPCTSTR)lpMsgBuf, "sendlog", MB_OK);
+
+ LocalFree(lpMsgBuf);
+
+ return 1;
+}
diff --git a/plugins/NotifyAnything/sendlog/SendLogWin.cpp b/plugins/NotifyAnything/sendlog/SendLogWin.cpp new file mode 100644 index 0000000000..37f112efb8 --- /dev/null +++ b/plugins/NotifyAnything/sendlog/SendLogWin.cpp @@ -0,0 +1,30 @@ +#include <windows.h>
+#include <winsock.h>
+
+#include <iostream>
+#include <string>
+
+void implementation(int argc, char **argv, bool console);
+
+int main(int argc, char **argv)
+try
+{
+ if (argc == 1 || argc == 2 && !strcmp("/?", argv[1])) {
+ MessageBox(NULL, "Syntax: sendlog32 [-T] [-H host] [-P port] text\n"
+ "\tSends single text message.", "Sendlog32", MB_OK);
+ return 0;
+ }
+
+ implementation(argc, argv, false);
+}
+catch (DWORD err) {
+ LPVOID lpMsgBuf;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
+
+ MessageBox(NULL, (LPCTSTR)lpMsgBuf, "sendlog32", MB_OK);
+
+ LocalFree(lpMsgBuf);
+
+ return 1;
+}
diff --git a/plugins/NotifyAnything/sendlog/compile.bat b/plugins/NotifyAnything/sendlog/compile.bat new file mode 100644 index 0000000000..f5dc4d40f0 --- /dev/null +++ b/plugins/NotifyAnything/sendlog/compile.bat @@ -0,0 +1,31 @@ +rem @echo off
+if not "%VS100COMNTOOLS%" == "" (
+ call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat"
+ "%VS100COMNTOOLS%\..\..\vc\bin\cl.exe" /MD /O2 /Os /EHsc SendLog.cpp SLImp.cpp /link ws2_32.lib user32.lib
+ "%VS100COMNTOOLS%\..\..\vc\bin\cl.exe" /MD /O2 /Os /EHsc SendLogWin.cpp SLImp.cpp /link ws2_32.lib user32.lib
+ call :ProcessFiles 10
+)
+
+if not "%VS110COMNTOOLS%" == "" (
+ call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat"
+ "%VS110COMNTOOLS%\..\..\vc\bin\cl.exe" /MD /O2 /Os /EHsc SendLog.cpp SLImp.cpp /link ws2_32.lib user32.lib
+ "%VS110COMNTOOLS%\..\..\vc\bin\cl.exe" /MD /O2 /Os /EHsc SendLogWin.cpp SLImp.cpp /link ws2_32.lib user32.lib
+ call :ProcessFiles 11
+)
+goto :eof
+
+:ProcessFiles
+mkdir ..\..\..\bin%1\Debug 2>nul
+copy /Y *.exe ..\..\..\bin%1\Debug >nul
+
+mkdir ..\..\..\bin%1\Debug64 2>nul
+copy /Y *.exe ..\..\..\bin%1\Debug64 >nul
+
+mkdir ..\..\..\bin%1\Release 2>nul
+copy /Y *.exe ..\..\..\bin%1\Release >nul
+
+mkdir ..\..\..\bin%1\Release64 2>nul
+copy /Y *.exe ..\..\..\bin%1\Release64 >nul
+
+del *.obj;*.exe >nul
+goto :eof
|