/*
* ftelnetd - fake telnet daemon
*
* wrapper.c
* Own wrapper, for making easier to use functions. I think that it is also
* helpful for better design. So don't expect too much here.
*
* Sat Feb 10 23:57:06 CET 2007
*
* by Levent Kayan
* levent[at]corehack[org]
* www.corehack.org
*/
#include "ftelnetd.h"
#include "ferror.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int xsocket(int domain, int type, int protocol)
{
int listenfd;
if ( (listenfd = socket(domain, type, protocol)) < 0 ) {
ERR_GEN;
}
return listenfd;
}
void xbind(int s, const struct sockaddr *addr, socklen_t addrlen)
{
if (bind(s, addr, addrlen) < 0 ) {
ERR_GEN;
}
}
void xlisten(int s, int backlog)
{
if (listen(s, backlog) < 0) {
ERR_GEN;
}
}
void xwrite(int connfd, char *ptr, size_t count)
{
if (write(connfd, ptr, count) < 0 ) {
ERR_GEN;
}
}
void *xmalloc(size_t size)
{
void *buff;
if ( (buff = malloc(size)) == NULL) {
perror("[-] error: ");
exit(EXIT_FAILURE);
}
return buff;
}
void xshutdown(int s, int how)
{
if (shutdown(s, how) < 0 ) {
perror("[-] error: ");
exit(EXIT_FAILURE);
}
}
/* EOF */
syntax highlighted by Code2HTML, v. 0.9.1