t_net *net;
t_display *display;
t_input *input;
+ unsigned int addr[3];
- net=(t_net *)allineed;
- display=(t_display *)(allineed+sizeof(t_net));
- input=(t_input *)(allineed+sizeof(t_net)+sizeof(t_display));
+ memcpy(addr,allineed,3*sizeof(unsigned int));
+ net=(t_net *)addr[0];
+ display=(t_display *)addr[1];
+ input=(t_input *)addr[2];
switch(input->content[0]) {
case GUI_INFO:
int fd;
+ unsigned int addr[3];
void *allyouneed;
+ allyouneed=(void *)addr;
+
+ addr[0]=(unsigned int)&net;
+ addr[1]=(unsigned int)&display;
+ addr[2]=(unsigned int)&input;
+
/* default values */
strcpy(logfile,LOGFILE);
strcpy(server_ip,"");
return -1;
}
- allyouneed=malloc(sizeof(t_net)+sizeof(t_display)+sizeof(t_input));
- memcpy(allyouneed,&net,sizeof(t_net));
- memcpy(allyouneed+sizeof(t_net),&display,sizeof(t_display));
- memcpy(allyouneed+sizeof(t_net)+sizeof(t_display),&input,sizeof(t_input));
-
/* input init */
input_init(&input,fd);
input.mode=CONTENT_BUFFER|LINE_BUFFERED|INPUT_ECHO;
t_client *c;
unsigned char data;
d3_lattice d3l;
+ unsigned int addr[4];
- net=(t_net *)allineed;
- c_list=(t_list *)(allineed+sizeof(t_net));
- g_list=(t_list *)(allineed+sizeof(t_net)+sizeof(t_list));
- job=(t_list *)(allineed+sizeof(t_net)+2*sizeof(t_list));
+ memcpy(addr,allineed,4*sizeof(unsigned int));
+
+ net=(t_net *)addr[0];
+ c_list=(t_list *)addr[1];
+ g_list=(t_list *)addr[2];
+ job=(t_list *)addr[3];
count_j=list_count(job);
count_c=list_count(c_list);
t_net *net;
t_list *c_list,*g_list,*job;
+ unsigned int addr[4];
+
+ memcpy(addr,allineed,4*sizeof(unsigned int));
- net=(t_net *)allineed;
- c_list=(t_list *)(allineed+sizeof(t_net));
- g_list=(t_list *)(allineed+sizeof(t_net)+sizeof(t_list));
- job=(t_list *)(allineed+sizeof(t_net)+2*sizeof(t_list));
+ net=(t_net *)addr[0];
+ c_list=(t_list *)addr[1];
+ g_list=(t_list *)addr[2];
+ job=(t_list *)addr[3];
/* decide what to do */
if(FD_ISSET(net->l_fd,&(event->rfds))) {
t_list g_list;
t_list job;
void *allyouneed;
+ unsigned int addr[4];
/* tzzz ... */
- allyouneed=malloc(sizeof(t_net)+3*sizeof(t_list));
- memcpy(allyouneed,&net,sizeof(t_net));
- memcpy(allyouneed+sizeof(t_net),&c_list,sizeof(t_list));
- memcpy(allyouneed+sizeof(t_net)+sizeof(t_list),&g_list,sizeof(t_list));
- memcpy(allyouneed+sizeof(t_net)+2*sizeof(t_list),&job,sizeof(t_list));
+ allyouneed=(void *)addr;
+ addr[0]=(unsigned int)&net;
+ addr[1]=(unsigned int)&c_list;
+ addr[2]=(unsigned int)&g_list;
+ addr[3]=(unsigned int)&job;
/* default values */
port=1025;
/* 10 sec event timeout - distributing jobs */
event_set_timeout(&event,10,0);
+ /* list init */
+ list_init(&c_list,1);
+ list_init(&g_list,1);
+ list_init(&job,1);
+
/* connect to server */
network_init(&net,1);
network_set_listen_port(&net,port);
/* wait for events :) */
event_math(net.l_fd,&event,READ,ADD);
+ printf("\nNLSOP_SERVER started!\n\n");
event_start(&event,allyouneed,parse_incoming,distribute_jobs);
return 1;