diff Renderer/Engine/lindaapi.cc @ 919:1a5de2a29987

add linda_test
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Mon, 26 Jul 2010 00:37:26 +0900
parents dbcfa04ee4db
children
line wrap: on
line diff
--- a/Renderer/Engine/lindaapi.cc	Sat Jul 17 15:09:48 2010 +0900
+++ b/Renderer/Engine/lindaapi.cc	Mon Jul 26 00:37:26 2010 +0900
@@ -373,6 +373,18 @@
     return(r);
 }
 
+extern int psx_callback_update(unsigned int tspace_id, unsigned int id,
+							   unsigned char *data, unsigned int size,
+							   void(*callback)(unsigned char *,void *),void * obj) {
+    int r;
+    if ((r = psx_queue(tspace_id, id, size, data, 'u', callback, obj)) == FAIL) {
+        return(FAIL);
+    }
+    DEB( fprintf(stdout, "psx_update: size = %d, command = %s\n",
+                 q_end->size, q_end->command+LINDA_HEADER_SIZE));
+    return(r);
+}
+
 /*-------------------------------------------------------------------/
   int
   psx_ld (unsigned tspace_id, unsigned int id,
@@ -417,7 +429,7 @@
     unsigned char *ans;
     
     DEB(fprintf(stdout, "psx_reply: search of seq = %d\n", seq));
-    PSX_Debug(("psx_reply: seq %d", seq)); 
+    PSX_Debug(("psx_reply: seq %x\n", seq)); 
     for(q = NULL,p = reply; p; q = p,p = p->next){
         if (p->seq == seq){
             DEB(fprintf(stdout, "psx_reply: match of seq = %d\n", seq));
@@ -434,11 +446,11 @@
                         r_end = q;
                     }
                 }
-                PSX_Debug(("psx_reply: reply %x r_end %x p %x q %x",reply,r_end,p,q)); 
+                PSX_Debug(("psx_reply: reply %p r_end %p p %p q %p\n",reply,r_end,p,q)); 
                 psx_free(p);
-                DEB( for(p=reply;p;p=p->next) { PSX_Debug(("psx_queue dump: seq %d mode %c %x %x",p->seq,p->mode,p,p->next))});
+                DEB( for(p=reply;p;p=p->next) { PSX_Debug(("psx_queue dump: seq %d mode %c %x %x\n",p->seq,p->mode,p,p->next))});
                 DEB( fprintf(stdout, "psx_reply: returned answer = %s\n", ans));
-                PSX_Debug(("psx_reply: answer %s",ans));
+                PSX_Debug(("psx_reply: answer %s\n",ans));
                 return(ans);
             } else {
                 if (p->mode == '?'){
@@ -449,7 +461,7 @@
         }
 
     }
-    PSX_Debug(("psx_reply: no match seq %d",seq));
+    PSX_Debug(("psx_reply: no match seq %d\n",seq));
     DEB(fprintf(stdout, "psx_reply: no match of seq\n"));
     return(NULL);
 }
@@ -555,7 +567,7 @@
     }
 
     /* データ受け取り要求(in,rd,wait)なら受け取り用の箱を用意 */
-    if (mode != 'o') {  
+    if (mode != 'o') {
         if (reply == NULL){
             if ((reply = (REPLY *) malloc (sizeof(REPLY))) == NULL){
                 return(FAIL);
@@ -571,7 +583,7 @@
         p->seq = (unsigned long)p;  // 構造体のアドレスで識別
         p->callback = callback;
         p->obj = obj;
-        PSX_Debug(("psx_queue: seq %d reply %x p %x r_end %x",seq,reply,p,r_end));
+        PSX_Debug(("psx_queue: seq %d reply %p p %p r_end %p\n",p->seq,reply,p,r_end));
     } else {
         p = 0;
     }
@@ -641,11 +653,11 @@
     mode = psx_get_mode(tuple);
     i = psx_get_id(tuple);
     unsigned int k = psx_get_seq(tuple);
-    PSX_Debug(("psx_chkserv: anser packet size = %d id %d seq %d", pkt,i,k)); 
+    PSX_Debug(("psx_chkserv: anser packet size = %d id %d seq %d\n", pkt,i,k)); 
     DEB(fprintf(stdout, "psx_chkserv: data from server: %s id=%d seq = %d\n", tuple, i, k));
     DEB (
         for(p=reply;p;p=p->next) {
-        PSX_Debug(printf("psx_queue dump: seq %d mode %c %x %x",p->seq,p->mode,p,p->next));
+        PSX_Debug(printf("psx_queue dump: seq %d mode %c %x %x\n",p->seq,p->mode,p,p->next));
         })
         
     for(prev = NULL,r = reply; r; prev = r,r = r->next){
@@ -666,13 +678,13 @@
                 }
                 psx_free(r);
             }else{                // normal reply
-                PSX_Debug(("psx_chkserv: copy answer r %x seq %d",r,k));
+                PSX_Debug(("psx_chkserv: copy answer r %p seq %d\n",r,k));
                 if(mode == 'a'){
-		    r->answer = tuple;
-		}else{
-		    r->answer = NULL;
-		}
-		r->mode = '!';
+					r->answer = tuple;
+				}else{
+					r->answer = NULL;
+				}
+				r->mode = '!';
             }
             break;
         }