Exemple #1
0
void *lua_engine::getparam(lua_State *L, int idx, const char *tname)
{
	void *p = checkparam(L, idx, tname);
	char msg[256];
	sprintf(msg, "%s expected", tname);
	luaL_argcheck(L, p, idx, msg);
	return p;
}
Exemple #2
0
streng *os2_beep( tsd_t *TSD, cparamboxptr parms )
{
   int freq=0,dur=1;

   checkparam(  parms,  2,  1 , "BEEP" ) ;

   if (parms && parms->value)
   {
      freq = atopos( TSD, parms->value, "BEEP", 1 ) ;
      if (freq < 37 || freq > 32767)
         exiterror( ERR_INCORRECT_CALL, 0 );
   }
   if (parms->next && parms->next->value)
   {
      dur = atopos( TSD, parms->next->value, "BEEP", 2 ) ;
      if (dur < 1 || freq > 60000)
         exiterror( ERR_INCORRECT_CALL, 0 );
   }

#if defined(WIN32)
   Beep( (DWORD)freq, (DWORD)dur );
#elif defined (__EMX__)
   if (_osmode != DOS_MODE)
      DosBeep( freq, dur );
   else
   {
      int hdl;

      /* stdout and/or stderr may be redirected */
      if ((hdl = open("con", O_WRONLY)) != -1)
      {
         write(hdl, "\x07" /* ^G == bell */, 1);
         close(hdl);
      }
   }
#elif defined(DOS)
   putchar(7);
#elif defined(OS2)
   DosBeep( freq, dur );
#elif defined(__QNX__)
   printf("\a");
#elif defined(__WATCOMC__)
   sound( freq );
   delay( dur );
   nosound( );
#elif defined(__DJGPP__)
   sound( freq );
   delay( dur );
   nosound( );
#elif defined(__WINS__) || defined(__EPOC32__)
   beep( freq, dur );
#endif
   return nullstringptr();
}
Exemple #3
0
streng *os2_filespec( tsd_t *TSD, cparamboxptr parms )
{
   streng *result=NULL ;
   streng *inpath=NULL;
   char format = '?' ;
#if defined(DJGPP)
   char fdrive[MAXDRIVE], fdir[MAXDIR], fname[MAXFILE], fext[MAXEXT];
#elif defined(__EMX__)
   char fdrive[_MAX_DRIVE], fdir[_MAX_DIR], fname[_MAX_FNAME], fext[_MAX_EXT];
#elif defined(HAVE__SPLITPATH2)
   char fpath[_MAX_PATH2], *fdrive=NULL, *fdir=NULL, *fname=NULL, *fext=NULL;
#elif defined(HAVE__SPLITPATH)
   char fdrive[_MAX_PATH], fdir[_MAX_PATH], fname[_MAX_PATH], fext[_MAX_PATH];
#else
   char fpath[REXX_PATH_MAX+5],*fdrive=NULL,*fdir=NULL,*fname=NULL,*fext=NULL;
#endif

   checkparam(  parms,  2,  2 , "FILESPEC" ) ;
   format = getoptionchar( TSD, parms->value, "FILESPEC", 1, "DNP", "?" ) ;
   inpath = Str_dupstrTSD( parms->next->value ) ;
#if defined(DJGPP)
   fnsplit( inpath->value, fdrive, fdir, fname, fext );
#elif defined(__EMX__)
   _splitpath( inpath->value, fdrive, fdir, fname, fext );
#elif defined(HAVE__SPLITPATH2)
   _splitpath2( inpath->value, fpath, &fdrive, &fdir, &fname, &fext );
#elif defined(HAVE__SPLITPATH)
   _splitpath( inpath->value, fdrive, fdir, fname, fext );
#else
   my_splitpath2( inpath->value, fpath, &fdrive, &fdir, &fname, &fext );
#endif
   switch( format )
   {
      case 'D':
         result = Str_creTSD( fdrive );
         break;
      case 'N':
         result = Str_makeTSD( strlen( fname) + strlen( fext ) );
         Str_catstrTSD( result, fname );
         Str_catstrTSD( result, fext );
         break;
      case 'P':
         result = Str_creTSD( fdir );
         break;
   }
   FreeTSD( inpath );
   return result;
}
Exemple #4
0
streng *os2_directory( tsd_t *TSD, cparamboxptr parms )
{
   streng *result=NULL ;
   int ok=HOOK_GO_ON ;
   char *path;

   checkparam(  parms,  0,  1 , "DIRECTORY" ) ;

   if (parms&&parms->value)
   {
      if (TSD->systeminfo->hooks & HOOK_MASK(HOOK_SETCWD))
         ok = hookup_output( TSD, HOOK_SETCWD, parms->value ) ;

      if (ok==HOOK_GO_ON)
      {
         path = str_of( TSD, parms->value ) ;
         if (chdir( path ) )
         {
            FreeTSD( path ) ;
            return nullstringptr() ;
         }
         FreeTSD( path ) ;
      }
   }

   /*
    * The remainder of this is for obtaining the current working directory...
    */
   if (TSD->systeminfo->hooks & HOOK_MASK(HOOK_GETCWD))
      ok = hookup_input( TSD, HOOK_GETCWD, &result ) ;

   if (ok==HOOK_GO_ON)
   {
      result = Str_makeTSD( REXX_PATH_MAX );
      my_fullpath( result->value, "." );
      result->len = strlen( result->value );
   }
   return result;
}
int main(int argc, const char **argv)
{
#ifdef _WIN32
    // for windows service must be static (main returns)
    static
#endif
    CPostgresRFS rfsserver;
    if (!rfsserver.init(argc,argv)) {
        usage();
        return 1;
    }
    char server[256];
    char user[256];
    char password[256];
    char db[256];
    char pgport[32];
    char pgopt[1024];
    char tempdir[256];
    strcpy(server,"localhost");
    user[0] = 0;
    password[0] = 0;
    pgport[0] = 0;
    pgopt[0] = 0;
    db[0] = 0;
    tempdir[0] = 0;
    for (int i=1;i<argc;i++) {
        if (checkparam(argv[i],"pgserver",server,sizeof(server))) continue;
        if (checkparam(argv[i],"user",user,sizeof(user))) continue;
        if (checkparam(argv[i],"password",password,sizeof(password))) continue;
        if (checkparam(argv[i],"db",db,sizeof(db))) continue;
        if (checkparam(argv[i],"pgport",pgport,sizeof(pgport))) continue;
        if (checkparam(argv[i],"pgopt",pgport,sizeof(pgopt))) continue;
        if (checkparam(argv[i],"tempdir",tempdir,sizeof(tempdir))) continue;
    }
    if (!db) {
        usage();
        return 0;
    }
    return rfsserver.run(server,user,password,db,pgport,pgopt,tempdir);
}
Exemple #6
0
int main(int argc, char *argv[])
{
  double u[NN], v[NN], p[NN], fat[NN], Vc[NN], w[NN][N2], a[NX+1][NY+1][NZ+1], B[NX+1][NY+1][NZ+1], u_ave[NN];
  double xx[NN], yy[NN], zz[NN], r[NN];
  double ageb[NN], agek[NN];
  int state[NN], div_times[NN], touch[NN];
  int lj[NN][N2];
  int indx[NN]; // lj[i][0...indx-1]
  int ljd[NN][N2];
  int ljd_indx[NN]; // ljd[i][0...ljd_indx-1]

  /* debug */
  int pair[NN], pair2[NN], pair_indx = 0;
  double L[NN]; 
  int other_cell[NN];
  int tb[NN];
  int ncell_var, num;
  int i, j, k;
  int KEY_INPUT_DATA;
  char celldata_name[100];
  char str[100], str_chem[100];
  FILE *finput, *fdebug;
  void checkstate(int [], int );
  void checkparam();

  int nmx = (int)(COMPRESS_FACTOR * LX/(2.0*R_memb));
  int nmy = (int)(COMPRESS_FACTOR * LY/(2.0*R_memb));

  printf("mkdir %s\n", OUTPUTDIR );
  sprintf(str, "mkdir -p %s", OUTPUTDIR);
  system(str);

  checkparam();

  if (fabs(dx-dh)>EPS || fabs(dy-dh)>EPS || fabs(dz-dh)>EPS) {
    printf("error: dx=%f dy=%f dz=%f.\n", dx, dy, dz);
    printf("grid size must be dh=%f.\n", dh);
    exit(1);
  }
  if (argc <= 1) { 
    printf("input file name required\n");
    exit(1);
  }

  strcpy(celldata_name, argv[1]);

  if((finput = fopen(celldata_name, "r")) == NULL) {
    printf("input file error2\n");
    exit(1);
  }

  if ((num = count_line(finput)) != NN) {
    printf(" error: input data file not consistent.\n");
    printf("input file lines = %d: NN = %d\n", num, NN);
    exit(5);
  }

  fclose(finput);
  if((finput = fopen(celldata_name, "r")) == NULL) {
    printf("input file error2\n");
    exit(1);
  }
  
  initialize_state(state, ageb, agek, fat, Vc);
  /* input vales, initialize gj, return first blank cell's index*/
  initialize_vars(finput, xx, yy, zz, lj, state, r, ageb, agek, div_times, fat, Vc, touch, L, other_cell, tb, &ncell_var, &NDER, &NMEMB);
  printf("variables initialized: NDER=%d NMEMB=%d ncell=%d NN=%d\n", NDER, NMEMB, ncell_var, NN);

  if (nmx != NMX || nmy != NMY) {
    printf("error: number of membrane particles inconsistent with parameter file\n");
    exit(1);
  }

  checkstate(state, ncell_var);
  
  connect_lj(lj, state, ncell_var, xx, yy, zz, r, indx);
  printf("lj connection initialized\n");  

  check_pair(ncell_var, xx, yy, zz, pair, pair2, &pair_indx, L, other_cell);
  
  fclose(finput);
  
  initial_u(u, v, p, a, B, w); // initialization

  KEY_INPUT_DATA = atoi(argv[2]);
  if (KEY_INPUT_DATA != 1 && KEY_INPUT_DATA != 0) {
    printf("error: 2nd argument must be 0 or 1\n");
    exit(3);
  }
  
  if (KEY_INPUT_DATA) {
    printf("chemical data read from recycled_data\n");
    
    sprintf(str_chem, "recycled_data");
    input_uvp(str_chem, u, v, p, a, B, w, ncell_var);
  }

  if (SYSTEM == WHOLE) {
    printf("computing the whole epidermis.\n");
    //    SYSTEM = WHOLE;
  }
  else if (SYSTEM == BASAL) {
    printf("computing only the basal layer and the dermis.\n");
    //    SYSTEM = BASAL;
  }
  else {
    printf("parameter SYSTEM must be 'WHOLE' or 'BASAL'\n");
    exit(1);
  }

  if (KEY_FORCED_SC) 
    printf("forced cornification enabled\n");
  else
    printf("forced cornification disabled\n");

  if (KEY_INPUT_DATA && KEY_FORCED_SC) {
    printf("error: forced cornification must be disabled\n");
    exit(1);
  }
  else if (!KEY_INPUT_DATA && !KEY_FORCED_SC) {
    printf("WARNING: sc formation would take longer without forced cornification.\n");
  }

  if (KEY_DERMAL_CHANGE)
    printf("computing dermal change\n");
  else 
    printf("fixed dermal shape\n");

  printf("divmax=%d, accel_div=%f MALIGNANT=%d\n", 
	 div_max, accel_div, MALIGNANT);
    printf("K_TOTAL=%f, K_DESMOSOME_RATIO=%f\n", K_TOTAL, K_DESMOSOME_RATIO);
  
  evolution(u, v, p, w, a, B, xx, yy, zz, r, ageb, agek, state, div_times, fat, 
	    Vc, touch, lj, indx, &ncell_var, u_ave, pair, pair2,  &pair_indx,  L, other_cell,
            ljd, ljd_indx, tb);  

  printf("finished\n");

  return 0;
}
Exemple #7
0
/**
 * Check if file should be recycled
 **/
static int recycle_unlink(vfs_handle_struct *handle, connection_struct *conn, const char *file_name)
{
	char *path_name = NULL;
       	char *temp_name = NULL;
	char *final_name = NULL;
	const char *base;
	char *repository = NULL;
	int i = 1;
	int maxsize;
	SMB_OFF_T file_size; /* space_avail;	*/
	BOOL exist;
	int rc = -1;

	repository = alloc_sub_conn(conn, recycle_repository(handle));
	ALLOC_CHECK(repository, done);
	/* shouldn't we allow absolute path names here? --metze */
	trim_char(repository, '/', '/');
	
	if(!repository || *(repository) == '\0') {
		DEBUG(3, ("recycle: repository path not set, purging %s...\n", file_name));
		rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
		goto done;
	}

	/* we don't recycle the recycle bin... */
	if (strncmp(file_name, repository, strlen(repository)) == 0) {
		DEBUG(3, ("recycle: File is within recycling bin, unlinking ...\n"));
		rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
		goto done;
	}

	file_size = recycle_get_file_size(handle, file_name);
	/* it is wrong to purge filenames only because they are empty imho
	 *   --- simo
	 *
	if(fsize == 0) {
		DEBUG(3, ("recycle: File %s is empty, purging...\n", file_name));
		rc = SMB_VFS_NEXT_UNLINK(handle,conn,file_name);
		goto done;
	}
	 */

	/* FIXME: this is wrong, we should check the hole size of the recycle bin is
	 * not greater then maxsize, not the size of the single file, also it is better
	 * to remove older files
	 */
	maxsize = recycle_maxsize(handle);
	if(maxsize > 0 && file_size > maxsize) {
		DEBUG(3, ("recycle: File %s exceeds maximum recycle size, purging... \n", file_name));
		rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
		goto done;
	}

	/* FIXME: this is wrong: moving files with rename does not change the disk space
	 * allocation
	 *
	space_avail = SMB_VFS_NEXT_DISK_FREE(handle, conn, ".", True, &bsize, &dfree, &dsize) * 1024L;
	DEBUG(5, ("space_avail = %Lu, file_size = %Lu\n", space_avail, file_size));
	if(space_avail < file_size) {
		DEBUG(3, ("recycle: Not enough diskspace, purging file %s\n", file_name));
		rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
		goto done;
	}
	 */

	/* extract filename and path */
	base = strrchr(file_name, '/');
	if (base == NULL) {
		base = file_name;
		path_name = SMB_STRDUP("/");
		ALLOC_CHECK(path_name, done);
	}
	else {
		path_name = SMB_STRDUP(file_name);
		ALLOC_CHECK(path_name, done);
		path_name[base - file_name] = '\0';
		base++;
	}

	DEBUG(10, ("recycle: fname = %s\n", file_name));	/* original filename with path */
	DEBUG(10, ("recycle: fpath = %s\n", path_name));	/* original path */
	DEBUG(10, ("recycle: base = %s\n", base));		/* filename without path */

	if (matchparam(recycle_exclude(handle), base)) {
		DEBUG(3, ("recycle: file %s is excluded \n", base));
		rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
		goto done;
	}

	/* FIXME: this check will fail if we have more than one level of directories,
	 * we shoud check for every level 1, 1/2, 1/2/3, 1/2/3/4 .... 
	 * 	---simo
	 */
	if (checkparam(recycle_exclude_dir(handle), path_name)) {
		DEBUG(3, ("recycle: directory %s is excluded \n", path_name));
		rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
		goto done;
	}

	if (recycle_keep_dir_tree(handle) == True) {
		asprintf(&temp_name, "%s/%s", repository, path_name);
	} else {
		temp_name = SMB_STRDUP(repository);
	}
	ALLOC_CHECK(temp_name, done);

	exist = recycle_directory_exist(handle, temp_name);
	if (exist) {
		DEBUG(10, ("recycle: Directory already exists\n"));
	} else {
		DEBUG(10, ("recycle: Creating directory %s\n", temp_name));
		if (recycle_create_dir(handle, temp_name) == False) {
			DEBUG(3, ("recycle: Could not create directory, purging %s...\n", file_name));
			rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
			goto done;
		}
	}

	asprintf(&final_name, "%s/%s", temp_name, base);
	ALLOC_CHECK(final_name, done);
	DEBUG(10, ("recycle: recycled file name: %s\n", final_name));		/* new filename with path */

	/* check if we should delete file from recycle bin */
	if (recycle_file_exist(handle, final_name)) {
		if (recycle_versions(handle) == False || matchparam(recycle_noversions(handle), base) == True) {
			DEBUG(3, ("recycle: Removing old file %s from recycle bin\n", final_name));
			if (SMB_VFS_NEXT_UNLINK(handle, conn, final_name) != 0) {
				DEBUG(1, ("recycle: Error deleting old file: %s\n", strerror(errno)));
			}
		}
	}

	/* rename file we move to recycle bin */
	i = 1;
	while (recycle_file_exist(handle, final_name)) {
		SAFE_FREE(final_name);
		asprintf(&final_name, "%s/Copy #%d of %s", temp_name, i++, base);
	}

	DEBUG(10, ("recycle: Moving %s to %s\n", file_name, final_name));
	rc = SMB_VFS_NEXT_RENAME(handle, conn, file_name, final_name);
	if (rc != 0) {
		DEBUG(3, ("recycle: Move error %d (%s), purging file %s (%s)\n", errno, strerror(errno), file_name, final_name));
		rc = SMB_VFS_NEXT_UNLINK(handle, conn, file_name);
		goto done;
	}

	/* touch access date of moved file */
	if (recycle_touch(handle) == True )
		recycle_do_touch(handle, final_name);

done:
	SAFE_FREE(path_name);
	SAFE_FREE(temp_name);
	SAFE_FREE(final_name);
	SAFE_FREE(repository);
	return rc;
}