コード例 #1
0
ファイル: ThCopyNL.cpp プロジェクト: caomw/cppfbp
THRCOMP ThCopyNL(_anchor proc_anchor)
{
	void *ptr;
	void *ptr2;
	int value;
	long size;
	char *type;
	port_ent port_tab[2];

	value = dfsdfpt(proc_anchor, 2, port_tab,"IN","OUT");

	value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
	//while (value == 0) {
		value = dfscrep(proc_anchor, &ptr2, size, type);
		memcpy(ptr2,ptr,size);
		value = dfssend(proc_anchor, &ptr2, &port_tab[1], 0);  
		dfsdrop(proc_anchor, &ptr);
		if (value != 0) {
			dfsdrop(proc_anchor, &ptr);
			return(1);
		}
	//	value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
	//}

	return(0);
}
コード例 #2
0
ファイル: thsockwt.cpp プロジェクト: jpaulm/threadn
THRCOMP thsockwt(anchor proc_anchor)
{
    void *ptr;
    char *dptr;
    int value, i;
    long size;
    char *type;
    char string[256];
    int ch;
    port_ent port_tab[3];
    FILE *fp;
    char buffer[256];

    /* We'll leave OPT there for now */

    value = dfsdfpt(proc_anchor, 3, port_tab,"OPT","IN","OUT");

    /*obtain filename parameter
    */
    value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
    memcpy(string,ptr,size);
    value = dfsdrop(proc_anchor, &ptr);
    string[size] = '\0';
    /*
     if ((fp = fopen(string,"wt")) == NULL) {
           sprintf(buffer, "Cannot open file %s", string);
           dfsputs(proc_anchor,buffer);
     return(8);
       }
     */

    i = socket(AF_INET, SOCK_STREAM, 0);

    value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
    while (value == 0)
    {
        dptr = (char *) ptr;
        for (i = 0; i < size; i++) {
            ch = (int) * (dptr + i);
            value = fputc(ch, fp);
        }
        value = fputc('\n',fp);

        value = dfssend(proc_anchor, &ptr, &port_tab[2], 0);
        if (value == 2)
            value = dfsdrop(proc_anchor, &ptr);
        value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
    }
    fclose(fp);
    return(0);
}
コード例 #3
0
ファイル: ThFileWt.cpp プロジェクト: caomw/cppfbp
  THRCOMP ThFileWt (_anchor proc_anchor) {
 
 
  void *ptr;
  char *dptr;
  int value, i;
  long size;
  char *type;
  char fname[256];
  int ch;
  port_ent port_tab[3];
  FILE *fp;
  //char buffer[256];
  

  value = dfsdfpt(proc_anchor, 3, port_tab,"OPT","IN","OUT");

/*obtain filename parameter
*/
  value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
  memcpy(fname,ptr,size);
  value = dfsdrop(proc_anchor, &ptr);
  fname[size] = '\0';
  #ifdef WIN32
    errno_t err;
    if( (err  = fopen_s( &fp, fname, "w" )) !=0 ) {
#else
    if ((f = fopen(fname, "w")) == NULL) {
#endif
        fprintf(stderr, "Cannot open file %s!\n", fname);
		return(8);
    }

    value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
    while (value == 0)
      {
      dptr = (char *) ptr;
      for (i = 0; i < size - 1; i++) {
         ch = (int) * (dptr + i);
         value = fputc(ch, fp);
        }
      value = fputc('\n',fp);

      value = dfssend(proc_anchor, &ptr, &port_tab[2], 0);
     if (value == 2)
	 value = dfsdrop(proc_anchor, &ptr);
      value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
      }
  fclose(fp);
  return(0);
}
コード例 #4
0
ファイル: ThGenIps.cpp プロジェクト: john-r-iii/cppfbp
  THRCOMP ThGenIps(_anchor proc_anchor)
{
  void *ptr;
  char *p;
  char string[256];
  int value, i;
  long size, count;
  char *type;
  port_ent port_tab[3];
  //char buffer[256];

  value = dfsdfpt(proc_anchor, 3, port_tab,"COUNT","OUT","PREFIX");

  value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
  if (value > 0) {
     printf("THGENIPS: No number specified\n");
  //   dfsputs(proc_anchor, buffer);
     return(8);
     }
  memcpy(string,ptr,size);
  string[size] = '\0';
  count = atol(string);

  value = dfsdrop(proc_anchor, &ptr);

  strcpy(string, "Testing ");
  value = dfsrecv(proc_anchor, &ptr, &port_tab[2], 0, &size, &type);
  if (value == 0) {
     memcpy(string,ptr,size);
     string[size] = '\0';
     value = dfsdrop(proc_anchor, &ptr);
  }
 // dfstest(proc_anchor);
  for (i = 0; i < count; i++) {
      value = dfscrep(proc_anchor, &ptr, 32,"G");
      strcpy((char *) ptr, string);
      p = strchr((char *) ptr, '\0');
      _itoa(i, p, 10);
      value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
      }
  return(0);
} 
コード例 #5
0
ファイル: THFILERT.CPP プロジェクト: jpaulm/threadn
  THRCOMP thfilert(anchor proc_anchor)
{
  void *ptr;
  char fname[256];
  char *sp;
  char *sp2;
  char *ssp;
  int value;
  long size;
  char *type;

  unsigned long len;
  port_ent port_tab[2];
  FILE *fp;
  char buffer[256];

  value = dfsdfpt(proc_anchor, 2, port_tab,"OPT","OUT");
  value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
  memcpy(fname,ptr,size);
  fname[size] = '\0';
   if ((fp = fopen(fname,"r")) == NULL) {
	 sprintf(buffer, "Cannot open file %s", fname);
         dfsputs(proc_anchor,buffer);
	 return(8);
     }

  value = dfsdrop(proc_anchor, &ptr);
  ssp =(char *) malloc(32767);
  sp = ssp;
  while (1) {
    while (1) {
      sp2 = fgets (sp, 32765, fp);
      if (sp2 == NULL)
	break;
      sp = sp2;
      len = strlen(sp);
      sp = sp + len;
      if (*(sp - 1) == '\n') {
	 --sp;
	 break;
	 }
      }
    value = dfscrep(proc_anchor, &ptr, sp - ssp, "A");
    memcpy (ptr, ssp, sp - ssp);
    value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
    if (sp2 == NULL)
   	break;

    sp = ssp;
    }
  fclose(fp);
  free(ssp);
  return(0);
}
コード例 #6
0
ファイル: ThLua.cpp プロジェクト: caomw/cppfbp
THRCOMP ThLua(_anchor proc_anchor)
{

	int value;	

	port_ent port_tab[1];

	value = dfsdfpt(proc_anchor, 1, port_tab, "PROG");

	char pgmname [100];
	void * ptr;
	long size;
	char *type;

	value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
	memcpy(pgmname,ptr,size);
	pgmname[size] = '\0';

	value = dfsdrop(proc_anchor, &ptr);

	lua_State *L = lua_open();

	luaL_openlibs (L);

	lua_pushstring(L, "lua_dfsanchor");  /* push key */
	lua_pushlightuserdata(L, (void *)&proc_anchor);  /* push address */

	lua_settable(L, LUA_REGISTRYINDEX);

	lua_register(L, "dfsrecv", thl_recv);
	lua_register(L, "dfsdrop", thl_drop);
	lua_register(L, "dfscrep", thl_crep);
	lua_register(L, "dfssend", thl_send);
	lua_register(L, "dfselct", thl_elct);
	lua_register(L, "dfsclos", thl_clos);
	lua_register(L, "dfsderef", thl_deref);

	lua_register(L, "myprint", myprint);

	int s = luaL_loadfile(L, pgmname);

    if ( s==0 ) {
      // execute Lua program
      s = lua_pcall(L, 0, LUA_MULTRET, 0);
    }
	report_errors(L, s);
	lua_close(L);
	return(0);
}
コード例 #7
0
ファイル: ThFileRd.cpp プロジェクト: caomw/cppfbp
  THRCOMP ThFileRd(_anchor proc_anchor) {
 
 
  void *ptr;
  char fname[256];
  char string[256];
  int value;
  long size;
  char *type;
  unsigned long len;
  port_ent port_tab[2];
  FILE *fp;
  //char buffer[256];

  value = dfsdfpt(proc_anchor, 2, port_tab,"OPT","OUT");

/* read in the filename and open the input file
*/
  value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
  memcpy(fname,ptr,size);
  fname[size] = '\0';
   
#ifdef WIN32
    errno_t err;
    if( (err  = fopen_s( &fp, fname, "r" )) !=0 ) {
#else
    if ((f = fopen(fname, "r")) == NULL) {
#endif
        fprintf(stderr, "Cannot open file %s!\n", fname);
		return(8);
    }
  value = dfsdrop(proc_anchor, &ptr);

/* read records from the input file and create entities from them.  If the
input records are longer than 256 bytes, they will be segmented and put out
as a series of 256 byte entities.
*/
  while ((fgets (string, 256, fp)) != NULL) {
      len = strlen(string);
      if (string[len - 1] == '\n')
	 len = len - 1;
      value = dfscrep(proc_anchor, &ptr, len,"A");
      memcpy (ptr, string, len);
      value = dfssend(proc_anchor, &ptr, &port_tab[1], 0);
      }
  fclose(fp);
  return(0);
} 
コード例 #8
0
ファイル: ThDrop.cpp プロジェクト: caomw/cppfbp
THRCOMP  ThDrop(_anchor proc_anchor)
{
    void *ptr;
    int value;
    long size;
    char *type;
    port_ent port_tab[1];

    value = dfsdfpt(proc_anchor, 1, port_tab,"IN");
    value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
    while (value == 0) {
        value = dfsdrop(proc_anchor, &ptr);
        value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
    }
    return(0);
}
コード例 #9
0
ファイル: ThLua.cpp プロジェクト: caomw/cppfbp
int thl_drop(lua_State *L) {
	
	const void* IPaddr =  lua_topointer(L, -1);  
	
		
	lua_pushstring(L, "lua_dfsanchor");  /* push key */
    lua_gettable(L, LUA_REGISTRYINDEX);  /* retrieve value */

	_anchor * anch = (_anchor *) lua_topointer(L, -1);
	//Process * proc = (Process *) anch -> reserved;

	void * ptr = (void *) IPaddr;
	
//	long size;
	int value = dfsdrop(* anch, &ptr);
	lua_pushnumber(L, value);
	return 1;
}
コード例 #10
0
ファイル: SELurls.CPP プロジェクト: jpaulm/threadn
  THRCOMP SELURLS(anchor proc_anchor)
{
  void *ptr;
  void *ptrn;
  char * p2;
  
  int value;
  long size;
  char *type;
  port_ent port_tab[3];
  
  
  
  /* ports: INT - list of interesting WikiNames    */ 
  /*        IN  - output of RecentChanges          */ 
  /*        OUT - list of lines to be diaplayed    */ 

 
  value = dfsdfpt(proc_anchor, 3, port_tab, "INT", "IN","OUT");

/* build list of interesting URLs                */
  

/* process input entities */
  value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
  while (value == 0) {
      getWikiName((char *) ptr, size);
      printf(WikiName);
      
      value = dfscrep(proc_anchor, &ptrn, size + strlen("<b>  ***  </b>") + 1, "B");
      strncpy((char *) ptrn, (char *) ptr, size);
      p2 = (char *) ptrn + size;

      if  (isitint) 
	  strcpy(p2, "<b>  ***  </b>" );
      else
	  strcpy(p2, "              " );
      value = dfssend(proc_anchor, &ptrn, &port_tab[2], 0);
      value = dfsdrop(proc_anchor, &ptr);
        
      value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
      }
    return(0);
}
コード例 #11
0
ファイル: THASSIGN.CPP プロジェクト: jpaulm/threadn
  THRCOMP THASSIGN(anchor proc_anchor)
{
  void *ptr;
  void *optr;
  char *start_ptr, *length_ptr;
  int  value, i, length, start_pos, PARMOK;
  long size, value_int;
  char *type;
  port_ent port_tab[3];
  struct _instr
  {
     char string[1];
  };
  typedef struct _instr instr;

  struct _optstr
  {
     char string[1];
  };
  typedef struct _optstr optstr;

  instr *inptr;
  optstr *value_ptr, *format_ptr;

  value = dfsdfpt(proc_anchor, 3, port_tab, "VALUE", "IN", "OUT");

/* obtain input parameters VALUE, FORMAT, STARTPOS, LENGTH
*/
  PARMOK = 1;
  length = 4;
  start_pos = 0;
  value = dfsrecv(proc_anchor, &ptr, &port_tab[0], 0, &size, &type);
  if (value == 0)
    {
      value_ptr = (optstr *) strtok((char *)ptr, ",/. ;:");
      if (value_ptr != 0)
	{
	  format_ptr = (optstr *) strtok(0, ",/. ;:");
	  if (format_ptr != 0)
	    {
	      if (!strcmp((char *)format_ptr, "INT"))
                {
		  value_int = atol((char *) value_ptr);
		  value_ptr =(optstr *) &value_int;
	        }
	      start_ptr = strtok(0, ",/. ;:");
	      if (start_ptr != 0)
	        {
	          start_pos = atoi(start_ptr);
		  if (!strcmp((char *)format_ptr, "CHAR"))
		  {
		    length_ptr =  strtok(0, ",/. ;:");
	            if (length_ptr != 0)
		      length = atoi(length_ptr);
		  }
		}
	    }
	  else PARMOK = 0;
	}
      else PARMOK = 0;

      optr = ptr;
    }

/* process input entities
*/
  value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
  while (value == 0)
    {
      inptr = (instr *) ptr;
      if (PARMOK)
      {
        for (i = 0; i < length; i++)
	  {
	    inptr -> string[i + start_pos] = value_ptr -> string[i];
          }
      }
      value = dfssend(proc_anchor, &ptr, &port_tab[2], 0);
      if (value != 0)
	  value = dfsdrop(proc_anchor, &ptr);
      value = dfsrecv(proc_anchor, &ptr, &port_tab[1], 0, &size, &type);
    }
  value = dfsdrop(proc_anchor, &optr);
  return(0);
}