]> hackdaworld.org Git - physik/nlsop.git/commitdiff
fixed all{you,i}need issues
authorhackbard <hackbard>
Fri, 5 Nov 2004 11:00:07 +0000 (11:00 +0000)
committerhackbard <hackbard>
Fri, 5 Nov 2004 11:00:07 +0000 (11:00 +0000)
nlsop_gui.c
nlsop_server.c

index 477d2649af5c4e5d0d655dd937e20d2608b382bf..8649442a8b1d417a1e71e9641516cb3f7f49faeb 100644 (file)
@@ -222,10 +222,12 @@ int get_command(t_event *event,void *allineed) {
   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:
@@ -271,8 +273,15 @@ int main(int argc,char **argv)
 
   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,"");
@@ -310,11 +319,6 @@ int main(int argc,char **argv)
     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;
index 5d11e484a312c7832b5ce93d21cb6fb00c6f3084..e68a4493a90c7b5fdce4f689c51056e3e3df3b3b 100644 (file)
@@ -309,11 +309,14 @@ int distribute_jobs(t_event *event,void *allineed) {
   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);
@@ -367,11 +370,14 @@ int parse_incoming(t_event *event,void *allineed) {
 
   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))) {
@@ -402,13 +408,14 @@ int main(int argc,char **argv)
   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;
@@ -421,6 +428,11 @@ int main(int argc,char **argv)
   /* 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);
@@ -431,6 +443,7 @@ int main(int argc,char **argv)
 
   /* 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;