rename + modifications pour que ça compile => tcpd cleaned
parent
fc44447e27
commit
f451e0f88d
|
@ -3,7 +3,7 @@ CFLAGS=-Wall -g
|
||||||
LDFLAGS= -pthread
|
LDFLAGS= -pthread
|
||||||
CFILES=$(wildcard *.c) # CFILES => recompiles everything on a C file change
|
CFILES=$(wildcard *.c) # CFILES => recompiles everything on a C file change
|
||||||
EXEC=$(basename $(wildcard *.c))
|
EXEC=$(basename $(wildcard *.c))
|
||||||
SOURCES=$(wildcard ../lib/communication.c ../lib/process.c)
|
SOURCES=$(wildcard ../../lib/communication.c ../../lib/process.c)
|
||||||
OBJECTS=$(SOURCES:.c=.o)
|
OBJECTS=$(SOURCES:.c=.o)
|
||||||
TESTS=$(addsuffix .test, $(EXEC))
|
TESTS=$(addsuffix .test, $(EXEC))
|
||||||
LCBOR=-lbor
|
LCBOR=-lbor
|
|
@ -1,4 +1,4 @@
|
||||||
#include "tcpdserver.h"
|
#include "tcpd.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
|
@ -6,7 +6,7 @@
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "../lib/communication.h"
|
#include "../../lib/communication.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct sockaddr_in c_addr;
|
struct sockaddr_in c_addr;
|
|
@ -1,4 +1,4 @@
|
||||||
#include "../lib/communication.h"
|
#include "../../lib/communication.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
@ -9,16 +9,16 @@
|
||||||
do { perror(msg); exit(EXIT_FAILURE); } while (0)
|
do { perror(msg); exit(EXIT_FAILURE); } while (0)
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
char *srv_message = malloc(1024);
|
char *srv_message = malloc(BUFSIZ);
|
||||||
char *pidfile = malloc(1024);
|
char *pidfile = malloc(BUFSIZ);
|
||||||
char *buffer = malloc(1024);
|
char *buffer = malloc(BUFSIZ);
|
||||||
|
|
||||||
snprintf(srv_message , 1024, "%s %d 1 1" ,"connect 127.0.0.1 6000" , getpid());
|
snprintf(srv_message, BUFSIZ, "%s %d 1 1", "connect 127.0.0.1 6000", getpid());
|
||||||
snprintf(pidfile, 1024,"%s%d-1-1", "/tmp/ipc/", getpid());
|
snprintf(pidfile, BUFSIZ, "%s%d-1-1", "/tmp/ipc/", getpid());
|
||||||
|
|
||||||
char *proc_message = "hello frero";
|
char *proc_message = "hello frero";
|
||||||
|
|
||||||
int sfd;
|
int sfd;
|
||||||
struct sockaddr_un my_addr;
|
struct sockaddr_un my_addr;
|
||||||
socklen_t peer_addr_size;
|
socklen_t peer_addr_size;
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ int main(int argc, char * argv[]) {
|
||||||
|
|
||||||
peer_addr_size = sizeof(struct sockaddr_un);
|
peer_addr_size = sizeof(struct sockaddr_un);
|
||||||
if(connect(sfd,(struct sockaddr *) &my_addr, peer_addr_size) == -1)
|
if(connect(sfd,(struct sockaddr *) &my_addr, peer_addr_size) == -1)
|
||||||
{
|
{
|
||||||
perror("connect()");
|
perror("connect()");
|
||||||
exit(errno);
|
exit(errno);
|
||||||
}
|
}
|
||||||
//printf("connected...\n");
|
//printf("connected...\n");
|
||||||
file_write(sfd, srv_message, strlen(srv_message));
|
file_write(sfd, srv_message, strlen(srv_message));
|
||||||
//printf("%s\n", proc_message);
|
//printf("%s\n", proc_message);
|
||||||
|
@ -62,5 +62,5 @@ int main(int argc, char * argv[]) {
|
||||||
|
|
||||||
// close(cfd);
|
// close(cfd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Reference in New Issue