Exemple #1
0
   static Area * insert_area_after(Area_List *Plist, Area *Parea,
                                   int x1, int y1, int x2, int y2)
   {
      Area *p, *Pnew_area = alloc_area(Plist);

      p = Parea->Pnext;

      p->Pprev = Pnew_area;

      Pnew_area->Pnext = p;
      Pnew_area->Pprev = Parea;

      Parea->Pnext = Pnew_area;

      Pnew_area->x1 = x1;
      Pnew_area->y1 = y1;
      Pnew_area->x2 = x2;
      Pnew_area->y2 = y2;

      return (Pnew_area);
   }
int
main (int argc, char** argv)
{
  char *cswidth_name;

  com_name = argv[0];
  init (argc, argv);

  if ((cswidth_name = get_cswidth_name (WNN_DEFAULT_LANG)) != NULL)
    {
      set_cswidth (create_cswidth (cswidth_name));
    }

#ifdef CHINESE
  ujis_header (&which_dict);    /* read header of UJIS dic  */
#else
  ujis_header ();               /* read header of UJIS dic  */
#endif
  /* like comment,total,hinsi  */
#ifdef CHINESE
  read_ujis (reverse_dict, to_esc, which_dict);

  if (which_dict != CWNN_REV_DICT && which_dict != BWNN_REV_DICT)
    reverse_yomi ();
#else
  read_ujis (reverse_dict, to_esc, (which_dict == WNN_REV_DICT) ? 1 : 0);
#ifndef CONVERT_from_TOP
  reverse_yomi ();
#endif
#endif

  if ((ofpter = fopen (outfile, "w")) == NULL)
    {
      fprintf (stderr, "Can't open the output file %s.\n", outfile);
      perror ("");
      exit (1);
    }

#ifdef CHINESE
  if ((which_dict & 0xff) == WNN_REV_DICT)
    {
#else
  if (which_dict == WNN_REV_DICT)
    {
#endif
      create_rev_dict ();
    }
  else
    {
      alloc_area ();
      if (which_dict == WNN_STATIC_DICT)
        {
          sdic_sort ();
          uniq_je (sort_func_sdic);
          output_dic_data ();
          ujistosd (0, 0);
        }
      else
        {
          sort_if_not_sorted ();
          uniq_je (sort_func_je);
          output_dic_data ();
          ujistoud ();
          set_pter1 ();
        }
    }
  output_dic_index ();
  rewind (ofpter);
  output_header (ofpter, &jt, &file_head);
#ifdef nodef
  output_comment (ofpter);      /* In order to change the byte order */
  output_hinsi_list (ofpter);   /* In order to change the byte order */
#endif
  exit (0);
}


w_char *
addyomient (int tn, w_char* yomi)
{
  int len = wnn_Strlen (yomi);
  tary[tn].yomi2 = 0;
  tary[tn].yomi1 = yomi[0] << 16;

  uhopter->yomi[0] = len;
  if (yomi[1])
    {
      tary[tn].yomi1 |= yomi[1];
      if (yomi[2])
        {
          tary[tn].yomi2 = yomi[2] << 16;
          if (yomi[3])
            {
              tary[tn].yomi2 |= yomi[3];
            }
          if (len > 4)
            {
              wnn_Strncpy (uhopter->yomi + 1, yomi + 4, len - 4);
              return (uhopter->yomi + 1 + len - 4);
            }
        }
    }
  return (uhopter->yomi + 1);
}
Exemple #3
0
int dm_create_persistent(struct exception_store *store, uint32_t chunk_size)
{
	int r;
	struct pstore *ps;

	r = dm_io_get(sectors_to_pages(chunk_size));
	if (r)
		return r;

	/* allocate the pstore */
	ps = kmalloc(sizeof(*ps), GFP_KERNEL);
	if (!ps) {
		r = -ENOMEM;
		goto bad;
	}

	ps->snap = store->snap;
	ps->valid = 1;
	ps->version = SNAPSHOT_DISK_VERSION;
	ps->chunk_size = chunk_size;
	ps->exceptions_per_area = (chunk_size << SECTOR_SHIFT) /
	    sizeof(struct disk_exception);
	ps->next_free = 2;	/* skipping the header and first area */
	ps->current_committed = 0;

	r = alloc_area(ps);
	if (r)
		goto bad;

	/*
	 * Allocate space for all the callbacks.
	 */
	ps->callback_count = 0;
	atomic_set(&ps->pending_count, 0);
	ps->callbacks = vcalloc(ps->exceptions_per_area,
				sizeof(*ps->callbacks));

	if (!ps->callbacks) {
		r = -ENOMEM;
		goto bad;
	}

	store->destroy = persistent_destroy;
	store->read_metadata = persistent_read_metadata;
	store->prepare_exception = persistent_prepare;
	store->commit_exception = persistent_commit;
	store->drop_snapshot = persistent_drop;
	store->fraction_full = persistent_fraction_full;
	store->context = ps;

	return 0;

      bad:
	dm_io_put(sectors_to_pages(chunk_size));
	if (ps) {
		if (ps->callbacks)
			vfree(ps->callbacks);

		kfree(ps);
	}
	return r;
}