Beispiel #1
0
main(int argc, char **argv)
{
	int c ;
	char *fsdbdir = NULL ;
	char *snapname = NULL ;

	while ( (c = getopt(argc, argv, "?s:f:")) != EOF) {
		switch (c) {
			case 'f':
				fsdbdir = strdup(optarg) ;
				break ;
			case 's':
				snapname = strdup(optarg) ;
				break ;
			case '?':
			default:
				usage() ;
		}
	}

	if ((! fsdbdir) || (! snapname)) {
		usage() ;
	}

	lock_block_device() ;
	make_snapshot(fsdbdir, snapname) ;
	unlock_block_device() ;
	start_new_fs(snapname) ;
}
Beispiel #2
0
/*
 *   Invalidate the frame.  The VM calls this just before our frame exits.
 *   We make a snapshot of the local variables in the frame, then we set our
 *   frame pointer to null to indicate that we no longer have an active frame
 *   in the stack.  
 */
void CVmObjFrameRef::inval_frame(VMG0_)
{
    if (ext_ != 0 && get_ext()->fp != 0)
    {
        /* make a snapshot of the frame */
        make_snapshot(vmg0_);
        
        /* forget our frame pointer */
        get_ext()->fp = 0;
    }
}
Beispiel #3
0
/*
 *   save
 */
void CVmObjFrameRef::save_to_file(VMG_ class CVmFile *fp)
{
    char buf[VMB_DATAHOLDER];
    
    /* get our extension */
    vm_frameref_ext *ext = get_ext();
    
    /* 
     *   If our frame is still active, make a snapshot of the variables.  The
     *   stack frame itself is inherently transient, so we can only save the
     *   snapshot version.  
     */
    if (ext->fp != 0)
        make_snapshot(vmg0_);

    /* save the variable counts */
    fp->write_uint2(ext->nlocals);
    fp->write_uint2(ext->nparams);

    /* save the entry pointer */
    vmb_put_dh(buf, &ext->entry);
    fp->write_bytes(buf, VMB_DATAHOLDER);

    /* save the method context values */
    vmb_put_dh(buf, &ext->self);
    fp->write_bytes(buf, VMB_DATAHOLDER);
    fp->write_uint4(ext->defobj);
    fp->write_uint4(ext->targobj);
    fp->write_uint2(ext->targprop);
    vmb_put_dh(buf, &ext->invokee);
    fp->write_bytes(buf, VMB_DATAHOLDER);

    /* save the variable snapshot values */
    int i;
    const vm_val_t *v;
    for (i = ext->nparams + ext->nlocals, v = ext->vars ; i > 0 ; --i, ++v)
    {
        vmb_put_dh(buf, v);
        fp->write_bytes(buf, VMB_DATAHOLDER);
    }
}
Beispiel #4
0
int	save_screen_snapshot( void )
{
  static	int snapshot_no = 0;		/* 連番 */

  static const char *suffix[] = { ".bmp", ".ppm", ".raw", };
  static const char *checksuffix[] = { ".ppm",  ".PPM", 
				       ".xpm",  ".XPM", 
				       ".png",  ".PNG", 
				       ".bmp",  ".BMP", 
				       ".rgb",  ".RGB", 
				       ".raw",  ".RAW", 
				       ".gif",  ".GIF", 
				       ".xwd",  ".XWD", 
				       ".pict", ".PICT",
				       ".tiff", ".TIFF",
				       ".tif",  ".TIF", 
				       ".jpeg", ".JPEG",
				       ".jpg",  ".JPG", 
				       NULL
  };

  OSD_FILE *fp;

  char  *filename;
  char  number[8];
  int   i, j, len, success;

  if( snapshot_format >= COUNTOF(suffix) ) return FALSE;
  if( file_snap[0] == '\0' ) return FALSE;


	/* ファイル名のバッファを確保 */


  filename = (char*)malloc( strlen(file_snap) + sizeof( "NNNN.suffix" ) );
  if( filename==NULL ){
    printf( "screen-snapshot : malloc failed\n" );
    return FALSE;
  }


	/* ファイル名の末端が NNNN.suffix なら削除 */

  for( i=0; checksuffix[i]; i++ ){

    if( strlen(file_snap) > strlen(checksuffix[i]) + 4 ){

      char *p = &file_snap[ strlen(file_snap) - strlen(checksuffix[i]) - 4 ];
      if( isdigit( *(p+0) ) &&
	  isdigit( *(p+1) ) &&
	  isdigit( *(p+2) ) &&
	  isdigit( *(p+3) ) &&
	  strcmp( p+4, checksuffix[i] ) == 0 ){

	*p = '\0';

	printf( "screen-snapshot : filename truncated (%s)\n", file_snap );
	break;
      }
    }
  }


	/* 存在しないファイル名を探しだす (0000.suffix〜 9999.suffix) */

  success = FALSE;
  for( j=0; j<10000; j++ ){

    sprintf( number, "%04d", snapshot_no );
    if( ++ snapshot_no > 9999 ) snapshot_no = 0;
    strcpy( filename, file_snap );
    strcat( filename, number );
    len = strlen( filename );

    for( i=0; checksuffix[i]; i++ ){
      filename[ len ] = '\0';
      strcat( filename, checksuffix[ i ] );
      if( osd_file_stat( filename ) != FILE_STAT_NOEXIST ) break;
    }
    if( checksuffix[i] == NULL ){	    /* 見つかった */
      filename[ len ] = '\0';
      strcat( filename, suffix[ snapshot_format ] );
      success = TRUE;
      break;
    }
  }


	/* ファイルを開いて、スナップショットデータを書き込む */
  if( success ){

    success = FALSE;
    if( (fp = osd_fopen( FTYPE_SNAPSHOT_PPM, filename, "wb" ) ) ){

      make_snapshot();

      switch( snapshot_format ){
      case 0:	success = save_snapshot_bmp( fp );		break;
      case 1:	success = save_snapshot_ppm( fp );		break;
      case 2:	success = save_snapshot_raw( fp );		break;
      }

      osd_fclose( fp );
    }
/*
    printf( "screen-snapshot : %s ... %s\n", 
				filename, (success) ? "OK" : "FAILED" );
*/

#ifdef	USE_SSS_CMD

	/* 書き込み成功後、コマンドを実行する */

    if( success ){
      if( snapshot_cmd_enable &&
	  snapshot_cmd_do     &&
	  snapshot_cmd[0]     ){

	int	a_len, b_len;
	char	*cmd, *s, *d;

	a_len = strlen( filename );
	b_len = a_len - 4;		/* サフィックス ".???" の4文字分減算 */

	len = 0;
	s = snapshot_cmd;
	while( *s ){
	  if( *s == '%' ){
	    switch( *(s+1) ){
	    case '%': len ++;		s++;	break; 
	    case 'a': len += a_len;	s++;	break; 
	    case 'b': len += b_len;	s++;	break; 
	    default:  len ++;			break; 
	    }
	  }else       len ++;

	  s++;
	}

	cmd = (char *)malloc( len + 1 );
	if( cmd ){

	  s = snapshot_cmd;
	  d = cmd;
	  while( *s ){
	    if( *s == '%' ){
	      switch( *(s+1) ){
	      case '%': *d++ = *s;				s++;	break; 
	      case 'a': memcpy( d, filename, a_len ); d+=a_len;	s++;	break; 
	      case 'b': memcpy( d, filename, b_len ); d+=b_len;	s++;	break;
	      default:  *d++ = *s;
	      }
	    }else       *d++ = *s;
	    s++;
	  }
	  *d = '\0';

	  printf( "[SNAPSHOT command]%% %s\n", cmd );
	  system( cmd );

	  free(cmd);
	}
      }
    }
#endif	/* USE_SSS_CMD */

  }

  free( filename );

  return success;
}