added icon and fixed windows hostname resolution
This commit is contained in:
parent
a9ce4edbb5
commit
222d533236
BIN
resource.h
Executable file
BIN
resource.h
Executable file
Binary file not shown.
BIN
resources/xbot.ico
Executable file
BIN
resources/xbot.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
BIN
resources/xbot.png
Executable file
BIN
resources/xbot.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -71,6 +71,7 @@ void add_user_to_channel(char *user, char *host, char *chan)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct user *u, *uc;
|
struct user *u, *uc;
|
||||||
|
char buf[512];
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
BOOL is_op, is_voice, is_halfop, is_owner, is_admin;
|
BOOL is_op, is_voice, is_halfop, is_owner, is_admin;
|
||||||
@ -78,13 +79,12 @@ void add_user_to_channel(char *user, char *host, char *chan)
|
|||||||
bool is_op, is_voice, is_halfop, is_owner, is_admin;
|
bool is_op, is_voice, is_halfop, is_owner, is_admin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct irc_conn *bot = get_bot();
|
||||||
is_op = false;
|
is_op = false;
|
||||||
is_voice = false;
|
is_voice = false;
|
||||||
is_halfop = false;
|
is_halfop = false;
|
||||||
is_owner = false;
|
is_owner = false;
|
||||||
is_admin = false;
|
is_admin = false;
|
||||||
struct irc_conn *bot = get_bot();
|
|
||||||
char buf[512];
|
|
||||||
|
|
||||||
|
|
||||||
if (!strcmp(chan, ""))
|
if (!strcmp(chan, ""))
|
||||||
|
26
src/irc.c
26
src/irc.c
@ -10,7 +10,6 @@
|
|||||||
#include "events.h"
|
#include "events.h"
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -22,6 +21,7 @@
|
|||||||
#define FDOPEN _fdopen
|
#define FDOPEN _fdopen
|
||||||
#define SETBUF setbuf
|
#define SETBUF setbuf
|
||||||
#else
|
#else
|
||||||
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -33,8 +33,13 @@
|
|||||||
void irc_connect(struct irc_conn *bot)
|
void irc_connect(struct irc_conn *bot)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
char titlebuf[256];
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
struct sockaddr_in server;
|
struct sockaddr_in server;
|
||||||
|
struct hostent *host;
|
||||||
|
|
||||||
|
sprintf(titlebuf, "xbot [connecting]: %s:%s", bot->host, bot->port);
|
||||||
|
SetConsoleTitle(titlebuf);
|
||||||
|
|
||||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
|
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
|
||||||
eprint("WSAStartup failed.\n");
|
eprint("WSAStartup failed.\n");
|
||||||
@ -55,6 +60,22 @@ void irc_connect(struct irc_conn *bot)
|
|||||||
server.sin_addr.s_addr = inet_addr(bot->host);
|
server.sin_addr.s_addr = inet_addr(bot->host);
|
||||||
server.sin_port = htons(atoi(bot->port));
|
server.sin_port = htons(atoi(bot->port));
|
||||||
|
|
||||||
|
// resolve hostname
|
||||||
|
if (server.sin_addr.s_addr == INADDR_NONE)
|
||||||
|
{
|
||||||
|
host = gethostbyname(bot->host);
|
||||||
|
if (host == NULL)
|
||||||
|
{
|
||||||
|
eprint("Error resolving hostname: %d\n", WSAGetLastError());
|
||||||
|
closesocket(bot->srv_fd);
|
||||||
|
WSACleanup();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&server.sin_addr, host->h_addr_list[0], host->h_length);
|
||||||
|
}
|
||||||
|
|
||||||
if (connect(bot->srv_fd, (struct sockaddr*)&server, sizeof(server)) == SOCKET_ERROR)
|
if (connect(bot->srv_fd, (struct sockaddr*)&server, sizeof(server)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
eprint("Failed to connect to IRC server: %d\n", WSAGetLastError());
|
eprint("Failed to connect to IRC server: %d\n", WSAGetLastError());
|
||||||
@ -64,6 +85,9 @@ void irc_connect(struct irc_conn *bot)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprintf(titlebuf, "xbot [connected]: %s:%s", bot->host, bot->port);
|
||||||
|
SetConsoleTitle(titlebuf);
|
||||||
#else
|
#else
|
||||||
int srv_fd;
|
int srv_fd;
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include "resource.h"
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
@ -40,6 +41,14 @@ int main()
|
|||||||
char *p;
|
char *p;
|
||||||
int bytesRecv;
|
int bytesRecv;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
HICON hIcon;
|
||||||
|
|
||||||
|
hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
|
||||||
|
SendMessage(GetConsoleWindow(), WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
||||||
|
SetConsoleTitle("xbot [starting]");
|
||||||
|
#endif
|
||||||
|
|
||||||
bot.in = calloc(INBUF_SIZE, sizeof(char));
|
bot.in = calloc(INBUF_SIZE, sizeof(char));
|
||||||
bot.out = calloc(OUTBUF_SIZE, sizeof(char));
|
bot.out = calloc(OUTBUF_SIZE, sizeof(char));
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
#include "timers.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "irc.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "timers.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "irc.h"
|
|
||||||
|
|
||||||
struct timers *timers;
|
struct timers *timers;
|
||||||
int delete_queue[512];
|
int delete_queue[512];
|
||||||
|
2
xbot.cfg
2
xbot.cfg
@ -15,7 +15,7 @@ bot:
|
|||||||
|
|
||||||
server:
|
server:
|
||||||
{
|
{
|
||||||
host = "10.0.0.103";
|
host = "memphis.ephasic.org";
|
||||||
port = "6667";
|
port = "6667";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
10
xbot.vcxproj
10
xbot.vcxproj
@ -62,7 +62,7 @@
|
|||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>lib;include\libconfig-1.7.3\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>.;lib;include\libconfig-1.7.3\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;MY_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;MY_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>true</MinimalRebuild>
|
<MinimalRebuild>true</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
@ -111,6 +111,7 @@
|
|||||||
<ClInclude Include="lib\module.h" />
|
<ClInclude Include="lib\module.h" />
|
||||||
<ClInclude Include="lib\timers.h" />
|
<ClInclude Include="lib\timers.h" />
|
||||||
<ClInclude Include="lib\util.h" />
|
<ClInclude Include="lib\util.h" />
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\channel.c" />
|
<ClCompile Include="src\channel.c" />
|
||||||
@ -123,6 +124,13 @@
|
|||||||
<ClCompile Include="src\timers.c" />
|
<ClCompile Include="src\timers.c" />
|
||||||
<ClCompile Include="src\util.c" />
|
<ClCompile Include="src\util.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="xbot.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="resources\xbot.ico" />
|
||||||
|
<None Include="resources\xbot.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user