rizin/libr/debug/p/libgdbwrap/interface.c
pancake 3bc0212ee6 * Initial import of the 'configure-plugins' script
- accepts --static and --shared to setup which plugins
    you want to build statically in the library or dynamically
  - normalize .mk and plugin file names to adopt a single standard
  - WARNING: huge commit
* Added 'mk/sloc.mk' with 'sloc' target to count
  lines with sloccount everywhere (yeah!)

--HG--
rename : libr/asm/p/x86bea.mk => libr/asm/p/x86_bea.mk
rename : libr/asm/p/x86nasm.mk => libr/asm/p/x86_nasm.mk
rename : libr/asm/p/x86olly.mk => libr/asm/p/x86_olly.mk
rename : libr/config.h => libr/config.h.head
rename : libr/config.mk => libr/config.mk.head
rename : libr/debug/p/dbg_gdb.c => libr/debug/p/debug_gdb.c
rename : libr/debug/p/dbg_ptrace.c => libr/debug/p/debug_ptrace.c
rename : libr/debug/p/dbg_libgdbwrap/Makefile => libr/debug/p/libgdbwrap/Makefile
rename : libr/debug/p/dbg_libgdbwrap/README => libr/debug/p/libgdbwrap/README
rename : libr/debug/p/dbg_libgdbwrap/client.c => libr/debug/p/libgdbwrap/client.c
rename : libr/debug/p/dbg_libgdbwrap/gdbwrapper.c => libr/debug/p/libgdbwrap/gdbwrapper.c
rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper-internals.h => libr/debug/p/libgdbwrap/include/gdbwrapper-internals.h
rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper-stddef.h => libr/debug/p/libgdbwrap/include/gdbwrapper-stddef.h
rename : libr/debug/p/dbg_libgdbwrap/include/gdbwrapper.h => libr/debug/p/libgdbwrap/include/gdbwrapper.h
rename : libr/debug/p/dbg_libgdbwrap/include/libaspect.h => libr/debug/p/libgdbwrap/include/libaspect.h
rename : libr/debug/p/dbg_libgdbwrap/include/libe2dbg.h => libr/debug/p/libgdbwrap/include/libe2dbg.h
rename : libr/debug/p/dbg_libgdbwrap/include/revm.h => libr/debug/p/libgdbwrap/include/revm.h
rename : libr/debug/p/dbg_libgdbwrap/interface.c => libr/debug/p/libgdbwrap/interface.c
rename : libr/io/p/dbg.mk => libr/io/p/debug.mk
rename : libr/io/p/io_dbg.c => libr/io/p/io_debug.c
2010-01-13 23:42:49 +01:00

43 lines
1.2 KiB
C

#include "gdbwrapper.h"
int gdbwrap_simpleconnect(char *host, int port)
{
int rval;
int sd;
struct sockaddr_in socketaddr;
struct hostent *hostaddr;
struct protoent *protocol;
PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);
hostaddr = gethostbyname(host);
protocol = getprotobyname("tcp");
if (!hostaddr)
PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid gethostbyname", -1);
if (!port)
PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid port", -1);
if (!protocol)
PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid getprotobyname()",
-1);
sd = socket(PF_INET, SOCK_STREAM, protocol->p_proto);
if (sd == -1)
PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid socket", -1);
memset(&socketaddr, 0, sizeof(socketaddr));
socketaddr.sin_family = AF_INET;
socketaddr.sin_port = htons(port);
memcpy(&socketaddr.sin_addr, hostaddr->h_addr, hostaddr->h_length);
rval = connect(sd, (struct sockaddr *)&socketaddr, sizeof(socketaddr));
if (rval == -1)
PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Problem when connecting",
-1);
PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sd);
}