コード例 #1
0
ファイル: thzclos.cpp プロジェクト: caomw/cppfbp
int thzclosc(Process *proc, char * port ){
	int elem_no = 0;
	char port_name[100];
	char * p = strchr(port, '[');
	char * q;
	port_ent pe;

	if (p == 0) 
		strcpy (port_name, port);
	else {
		q = strchr(p, ']');
		long n = q - p - 1;
		char no[10];		
		strncpy(no, p + 1, n);
		elem_no = atoi(no);
		char * r = port;
		strncpy (port_name, port, p - r);
		port_name[p - r] = '\0';
	}

	//port_ent* pe = (port_ent *) malloc(sizeof(port_ent));   

	strcpy(pe.port_name, port_name);
	cp * cpp = proc -> in_cps;
	while (cpp != 0)
	{
		
			if (0 == strcmp(cpp -> port_name, port_name)){
				break;
			}
		 
		cpp = cpp -> succ;
	}
	pe.cpptr = cpp;
	pe.elem_count = cpp -> elem_count;  
	pe.ret_code = 0;
	
	int value = thzclos(proc, &pe, elem_no);

	//free (pe);
	return value;
}
コード例 #2
0
ファイル: thz.cpp プロジェクト: john-r-iii/cppfbp
   int thz(int code, Process *proc, ...)
   {
   va_list ap;
   int value = 0;
	   int port_count, elem_no;
   long IPsize;
   long *size;
   char *type;
   char **typep;
   port_ent *peptr;
   void **ptr;
   char * port;
  
   va_start (ap, proc);
   if (code == 0)
	   return 0;
   switch (code) {
   case 1: ptr = va_arg(ap,void **);
           peptr = va_arg(ap,port_ent *);
	   elem_no = va_arg(ap,int);
	   value = thzsend(proc, ptr, peptr, elem_no); break;
   case 2: ptr = va_arg(ap,void **);
	   peptr = va_arg(ap,port_ent *);
	   elem_no = va_arg(ap,int);
           size = va_arg(ap,long *);
	   typep = va_arg(ap, char **);
	   value = thzrecv(proc, ptr, peptr, elem_no,
	     size, typep); break;
   case 3: ptr = va_arg(ap,void **);
           IPsize = va_arg(ap,long);
	   type = va_arg(ap,char *);
	   value = thzcrep(proc, ptr, IPsize, type); break;
   case 4: ptr = va_arg(ap,void **);
	   value = thzdrop(proc, ptr); break;
   case 5: port_count = va_arg(ap,int);
           peptr = va_arg(ap,port_ent *);
	   value = thzdfpt(proc, port_count, peptr); break;
   case 6: ptr = va_arg(ap,void **);
	   value = thzpush(proc, ptr); break;
   case 7: ptr = va_arg(ap,void **);
           size = va_arg(ap,long *);
	   typep = va_arg(ap, char **);
	   value = thzpop(proc, ptr, size, typep); break;
   case 8: peptr = va_arg(ap,port_ent *);
	   elem_no = va_arg(ap,int);
	   value = thzclos(proc, peptr, elem_no); break;

   case 9: ptr = va_arg(ap,void **);          
	  IPsize = thzgsize(proc, ptr); 
	   return IPsize; break;

case 10: //ptr = va_arg(ap,void **); 
	peptr = va_arg(ap,port_ent *);
	   value = thzelct(proc, peptr); 
	   break;

   case 11: ptr = va_arg(ap,void **);
           port = va_arg(ap,char *);	 
	 value = thzsendc(proc, ptr, port); 
	   break;
   case 12: ptr = va_arg(ap,void **);
	      port = va_arg(ap,char *);
	      size = va_arg(ap,long *);
	   typep = va_arg(ap, char **);
	   value = thzrecvc(proc, ptr, port,
	     size, typep); break;
	case 13:    port = va_arg(ap,char *);	  
 	  value = thzclosc(proc, port); 
	   break;
	case 14: //ptr = va_arg(ap,void **); 
	port = va_arg(ap,char *);	
	  value = thzelctc(proc, port); 
	   break;
   }
   va_end(ap);
   if (code < 10 && proc -> trace && value > 0)
       MSG2("%s: Service retcode %d\n",
	  proc -> procname, value);
     

   return(value);

}