Exemple #1
0
/* This implements the fs_library_vtable_t.hotcopy() API.  Copy a
   possibly live Subversion filesystem SRC_FS from SRC_PATH to a
   DST_FS at DEST_PATH. If INCREMENTAL is TRUE, make an effort not to
   re-copy data which already exists in DST_FS.
   The CLEAN_LOGS argument is ignored and included for Subversion
   1.0.x compatibility.  The NOTIFY_FUNC and NOTIFY_BATON arguments
   are also currently ignored.
   Perform all temporary allocations in SCRATCH_POOL. */
static svn_error_t *
x_hotcopy(svn_fs_t *src_fs,
          svn_fs_t *dst_fs,
          const char *src_path,
          const char *dst_path,
          svn_boolean_t clean_logs,
          svn_boolean_t incremental,
          svn_fs_hotcopy_notify_t notify_func,
          void *notify_baton,
          svn_cancel_func_t cancel_func,
          void *cancel_baton,
          svn_mutex__t *common_pool_lock,
          apr_pool_t *scratch_pool,
          apr_pool_t *common_pool)
{
  /* Open the source repo as usual. */
  SVN_ERR(x_open(src_fs, src_path, common_pool_lock, scratch_pool,
                 common_pool));
  if (cancel_func)
    SVN_ERR(cancel_func(cancel_baton));

  SVN_ERR(svn_fs__check_fs(dst_fs, FALSE));
  SVN_ERR(initialize_fs_struct(dst_fs));

  /* In INCREMENTAL mode, svn_fs_x__hotcopy() will open DST_FS.
     Otherwise, it's not an FS yet --- possibly just an empty dir --- so
     can't be opened.
   */
  return svn_fs_x__hotcopy(src_fs, dst_fs, src_path, dst_path,
                            incremental, notify_func, notify_baton,
                            cancel_func, cancel_baton, common_pool_lock,
                            scratch_pool, common_pool);
}
Exemple #2
0
/* This implements the fs_library_vtable_t.open_for_recovery() API. */
static svn_error_t *
x_open_for_recovery(svn_fs_t *fs,
                    const char *path,
                    svn_mutex__t *common_pool_lock,
                    apr_pool_t *scratch_pool,
                    apr_pool_t *common_pool)
{
  svn_error_t * err;
  svn_revnum_t youngest_rev;
  apr_pool_t * subpool = svn_pool_create(scratch_pool);

  /* Recovery for FSFS is currently limited to recreating the 'current'
     file from the latest revision. */

  /* The only thing we have to watch out for is that the 'current' file
     might not exist or contain garbage.  So we'll try to read it here
     and provide or replace the existing file if we couldn't read it.
     (We'll also need it to exist later anyway as a source for the new
     file's permissions). */

  /* Use a partly-filled fs pointer first to create 'current'. */
  fs->path = apr_pstrdup(fs->pool, path);

  SVN_ERR(initialize_fs_struct(fs));

  /* Figure out the repo format and check that we can even handle it. */
  SVN_ERR(svn_fs_x__read_format_file(fs, subpool));

  /* Now, read 'current' and try to patch it if necessary. */
  err = svn_fs_x__youngest_rev(&youngest_rev, fs, subpool);
  if (err)
    {
      const char *file_path;

      /* 'current' file is missing or contains garbage.  Since we are trying
       * to recover from whatever problem there is, being picky about the
       * error code here won't do us much good.  If there is a persistent
       * problem that we can't fix, it will show up when we try rewrite the
       * file a few lines further below and we will report the failure back
       * to the caller.
       *
       * Start recovery with HEAD = 0. */
      svn_error_clear(err);
      file_path = svn_fs_x__path_current(fs, subpool);

      /* Best effort to ensure the file exists and is valid.
       * This may fail for r/o filesystems etc. */
      SVN_ERR(svn_io_remove_file2(file_path, TRUE, subpool));
      SVN_ERR(svn_io_file_create_empty(file_path, subpool));
      SVN_ERR(svn_fs_x__write_current(fs, 0, subpool));
    }

  uninitialize_fs_struct(fs);
  svn_pool_destroy(subpool);

  /* Now open the filesystem properly by calling the vtable method directly. */
  return x_open(fs, path, common_pool_lock, scratch_pool, common_pool);
}
Exemple #3
0
static svn_error_t *
x_pack(svn_fs_t *fs,
       const char *path,
       svn_fs_pack_notify_t notify_func,
       void *notify_baton,
       svn_cancel_func_t cancel_func,
       void *cancel_baton,
       svn_mutex__t *common_pool_lock,
       apr_pool_t *scratch_pool,
       apr_pool_t *common_pool)
{
  SVN_ERR(x_open(fs, path, common_pool_lock, scratch_pool, common_pool));
  return svn_fs_x__pack(fs, 0, notify_func, notify_baton,
                        cancel_func, cancel_baton, scratch_pool);
}
Exemple #4
0
int main(int argc, char ** argv)
{
    if ( argc != 2 ) {
        fprintf(stderr, "Usage: pricelist FILENAME\n");
        return EXIT_FAILURE;
    }

    const int dbfd = x_open(argv[1], O_RDWR | O_CREAT, 0644);

    bool should_quit = false;

    while ( !should_quit ) {
        print_summary(dbfd, argv[1]);
        int choice = get_menu_choice();

        struct record record;

        switch ( choice ) {
            case MENU_LIST:
                list_records(dbfd);
                break;

            case MENU_ADD:
                get_new_record(&record);
                write_record(dbfd, &record, -1);
                break;

            case MENU_DELETE:
                printf("Enter record number to delete: ");
                fflush(stdout);
                delete_record(dbfd, get_integer());
                break;

            case MENU_QUIT:
                printf("Goodbye!\n");
                should_quit = true;
                break;

            default:
                printf("Invalid menu choice. Try again.\n\n");
                break;
        }
    }

    x_close(dbfd);

    return 0;
}
Exemple #5
0
static svn_error_t *
x_verify(svn_fs_t *fs,
         const char *path,
         svn_revnum_t start,
         svn_revnum_t end,
         svn_fs_progress_notify_func_t notify_func,
         void *notify_baton,
         svn_cancel_func_t cancel_func,
         void *cancel_baton,
         svn_mutex__t *common_pool_lock,
         apr_pool_t *scratch_pool,
         apr_pool_t *common_pool)
{
  SVN_ERR(x_open(fs, path, common_pool_lock, scratch_pool, common_pool));
  return svn_fs_x__verify(fs, start, end, notify_func, notify_baton,
                          cancel_func, cancel_baton, scratch_pool);
}
Exemple #6
0
static int print_file(WINDOW *w, int item)
{
	/* int handle, error = 0, i, key, result = 0, r; DjV 033 010203 */
	int handle, error = 0, i, result = 0; /* DjV 033 010203 */
	char *buffer;
	const char *name;
	long l;			/* index in buffer[] */
	int ll = 0;		/* DjV 031 150203 line length counter */
	boolean stop = FALSE;

	if ((name = itm_fullname(w, item)) == NULL)
		return XFATAL;

	buffer = x_alloc(PBUFSIZ);

	if (buffer != NULL)
	{
		graf_mouse(HOURGLASS, NULL);

		if ((handle = x_open(name, O_DENYW | O_RDONLY)) >= 0)
		{
			do
			{
				if ((l = x_read(handle, PBUFSIZ, buffer)) >= 0)
				{
					for (i = 0; i < (int) l; i++)
					{
						/* DjV 031 150203 ---vvv--- */
						/* 
						 * line wrap & new line handling;
						 */
						ll++;
						if ( (buffer[i] == (char)13) || (buffer[i] == (char)10) || (buffer[i] == (char)12) )
							ll = 0; /* reset linelength counter at CR, LF or FF */
						else if ( ll >= plinelen )
						{
							ll = 0;
							if (( stop = print_eol() ) == TRUE)
								break;
						}
						/* DjV 031 150203 ---^^^--- */

						if ((stop = prtchar(buffer[i])) == TRUE)
							break;
					}
					/* DjV 033 010203 ---vvv--- */
					/*
					if ((r = key_state(&key, TRUE)) > 0)
					{
						if (key == ESCAPE)
							stop = TRUE;
					}
					else if (r < 0)
						stop = TRUE;
					*/

					if ( escape_abort(TRUE) )
						stop = TRUE;

					/* DjV 033 010203 ---^^^--- */
				}
				else
					error = (int) l;
			}
			while ((l == PBUFSIZ) && (stop == FALSE));

			x_close(handle);
			print_eol(); /* DjV 031 150203 print cr lf at end of file */
		}
		else
			error = handle;

		if (stop == TRUE)
			result = XABORT;

		if (error != 0)
			result = xhndl_error(MEPRINT, error, itm_name(w, item));

		graf_mouse(ARROW, NULL);
		x_free(buffer);
	}
	else
	{
		xform_error(ENSMEM);
		result = XFATAL;
	}

	free(name);

	return result;
}
void SetupVgaEnvironment()
{
        int a, i;
        union REGS rg;
        __dpmi_regs d_rg;
        UBYTE ctab[768];

        if (use_vesa)
        {
          /*try to open VESA mode*/
          use_vesa=VESA_open(vesa_mode,vesa_memptr,vesa_memsize,&vesa_linear,&vesa_selector);
        }
        if (!use_vesa) /*if '-novesa' specified or VESA_open failed */
          switch(video_mode)
          {
            case 0:
              rg.x.ax = 0x0013;
              int86(0x10, &rg, &rg); /*vga 320x200*/
              break;
            case 1:
              x_open(2);             /*xmode 320x240*/
              break;
            case 2:
            case 3:
              x_open(5);             /*xmode 320x480*/
              break;
          }

	screen_visible_x1 = first_col;
	screen_visible_x2 = first_col + 320;
	if (video_mode == 0) {
		screen_visible_y1 = first_lno;
		screen_visible_y2 = first_lno + 200;
	}
	else {
		screen_visible_y1 = 0;
		screen_visible_y2 = 240;
	}

        vga_started = 1;

        /* setting all palette at once is faster....*/
        for (a = 0, i = 0; a < 256; a++) {
          ctab[i++]=(colortable[a] >> 18) & 0x3f;
          ctab[i++]=(colortable[a] >> 10) & 0x3f;
          ctab[i++]=(colortable[a] >> 2) & 0x3f;
        }
        /*copy ctab to djgpp transfer buffer in DOS memory*/
        dosmemput(ctab,768,__tb&0xfffff);
        d_rg.x.ax=0x1012;
        d_rg.x.bx=0;
        d_rg.x.cx=256;
        d_rg.x.dx=__tb&0xf; /*offset of transfer buffer*/
        d_rg.x.es=(__tb >> 4) & 0xffff;  /*segment of transfer buffer*/
        __dpmi_int(0x10,&d_rg);  /*VGA set palette block*/

	/* initialize mouse */
	if (mouse_mode != MOUSE_OFF) {
		union REGS rg;
		rg.x.ax = 0;
		int86(0x33, &rg, &rg);
		if (rg.x.ax != 0xffff) {
			Aprint("Can't find mouse!");
			mouse_mode = MOUSE_OFF;
		}
	}

        key_init(); /*initialize keyboard handler*/
}