Пример #1
0
static void
parse_error (GMarkupParseContext *context,
             GError              *error,
             gpointer             data)
{
  GnomeXkbInfoPrivate *priv = GNOME_XKB_INFO (data)->priv;

  free_option_group (priv->current_parser_group);
  free_option (priv->current_parser_option);
  free_layout (priv->current_parser_layout);
  free_layout (priv->current_parser_variant);
  g_free (priv->current_parser_iso639Id);
}
Пример #2
0
static void free_layout(LAYOUT *base)
{
    LAYOUT *tmp1, *tmp2;
    
    tmp1 = base;
    while (tmp1) {
        tmp2 = tmp1;
        if (tmp1->child)
            free_layout(tmp1->child);
        tmp1 = tmp1->next;
        free(tmp2);
    }
}
Пример #3
0
void Descriptor_free(void* _self) {
  Descriptor* self = _self;
  upb_msgdef_unref(self->msgdef, &self->msgdef);
  if (self->layout) {
    free_layout(self->layout);
  }
  if (self->fill_handlers) {
    upb_handlers_unref(self->fill_handlers, &self->fill_handlers);
  }
  if (self->fill_method) {
    upb_pbdecodermethod_unref(self->fill_method, &self->fill_method);
  }
  if (self->pb_serialize_handlers) {
    upb_handlers_unref(self->pb_serialize_handlers,
                       &self->pb_serialize_handlers);
  }
  if (self->json_serialize_handlers) {
    upb_handlers_unref(self->pb_serialize_handlers,
                       &self->json_serialize_handlers);
  }
  xfree(self);
}
Пример #4
0
static void
parse_end_element (GMarkupParseContext  *context,
                   const gchar          *element_name,
                   gpointer              data,
                   GError              **error)
{
  GnomeXkbInfoPrivate *priv = GNOME_XKB_INFO (data)->priv;

  if (strcmp (element_name, "layout") == 0)
    {
      if (!priv->current_parser_layout->description || !priv->current_parser_layout->xkb_name)
        {
          g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
                       "'layout' elements must enclose 'description' and 'name' elements");
          return;
        }

      priv->current_parser_layout->id = g_strdup (priv->current_parser_layout->xkb_name);

      if (g_hash_table_contains (priv->layouts_table, priv->current_parser_layout->id))
        {
          if (priv->current_parser_layout != NULL) {
            free_layout (priv->current_parser_layout);
            priv->current_parser_layout = NULL;
          }
          return;
        }

      if (priv->current_parser_layout->short_desc)
        maybe_replace (priv->layouts_by_short_desc,
                       priv->current_parser_layout->short_desc, priv->current_parser_layout);

      g_hash_table_replace (priv->layouts_table,
                            priv->current_parser_layout->id,
                            priv->current_parser_layout);
      priv->current_parser_layout = NULL;
    }
  else if (strcmp (element_name, "variant") == 0)
    {
      if (!priv->current_parser_variant->description || !priv->current_parser_variant->xkb_name)
        {
          g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
                       "'variant' elements must enclose 'description' and 'name' elements");
          return;
        }

      priv->current_parser_variant->id = g_strjoin ("+",
                                                    priv->current_parser_layout->xkb_name,
                                                    priv->current_parser_variant->xkb_name,
                                                    NULL);

      if (priv->current_parser_variant->short_desc)
        maybe_replace (priv->layouts_by_short_desc,
                       priv->current_parser_variant->short_desc, priv->current_parser_variant);

      g_hash_table_replace (priv->layouts_table,
                            priv->current_parser_variant->id,
                            priv->current_parser_variant);
      priv->current_parser_variant = NULL;
    }
  else if (strcmp (element_name, "iso639Id") == 0)
    {
      gboolean replaced = FALSE;

      if (!priv->current_parser_iso639Id)
        {
          g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
                       "'iso639Id' elements must enclose text");
          return;
        }

      if (priv->current_parser_layout)
        replaced = maybe_replace (priv->layouts_by_iso639,
                                  priv->current_parser_iso639Id, priv->current_parser_layout);
      else if (priv->current_parser_variant)
        replaced = maybe_replace (priv->layouts_by_iso639,
                                  priv->current_parser_iso639Id, priv->current_parser_variant);

      if (!replaced)
        g_free (priv->current_parser_iso639Id);

      priv->current_parser_iso639Id = NULL;
    }
  else if (strcmp (element_name, "group") == 0)
    {
      if (!priv->current_parser_group->description || !priv->current_parser_group->id)
        {
          g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
                       "'group' elements must enclose 'description' and 'name' elements");
          return;
        }

      g_hash_table_replace (priv->option_groups_table,
                            priv->current_parser_group->id,
                            priv->current_parser_group);
      priv->current_parser_group = NULL;
    }
  else if (strcmp (element_name, "option") == 0)
    {
      if (!priv->current_parser_option->description || !priv->current_parser_option->id)
        {
          g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
                       "'option' elements must enclose 'description' and 'name' elements");
          return;
        }

      g_hash_table_replace (priv->current_parser_group->options_table,
                            priv->current_parser_option->id,
                            priv->current_parser_option);
      priv->current_parser_option = NULL;
    }
}
Пример #5
0
/***********************************************************************
 *
 * Name :       populate_trailer_layout()
 *
 * Description: Retrieves the feed layout structure from database and
 *              populates local layout structure.
 *
 * Inputs  :    None
 * Outputs :    None
 * Returns :    SUCCESS/FAILURE
 *
 **********************************************************************/
void
populate_trailer_layout(JNL_FEED_DESC *trailer, tiny trailer_type)
{
    JNL_FEED_LAYOUT_REC current;
    int                 trail_pos = 0;
    int                 header_size = 0;
    int                 field_size  = 0;

    free_layout(trailer);

    arb_setup_results(&jnl_get_trailer_layout_proc,
                      ARB_TYPE_INT8,    &current.type,
                      ARB_TYPE_INT8,    &current.position,
                      ARB_TYPE_INT8,    &current.table,
                      ARB_TYPE_INT8,    &current.field,
                      ARB_TYPE_INT8,    &current.field_size,
                      ARB_TYPE_STRING,  current.hardcoded_value, JNL_FEED_TRAILER_trl_hardcoded_SZ,
                      ARB_TYPE_INT8,    &current.format,
                      ARB_TYPE_INT8,    &current.trim,
                      ARB_TYPE_INT8,    &current.in_feed_report,
                      ARB_TYPE_STRING,  current.description, JNL_FEED_TRAILER_trl_field_description_SZ);

    arb_setup_proc_exec(g_spDBcustfetch, &jnl_get_trailer_layout_proc,
                        SQL_DEFER_EXECUTE,
                        "trailer_type", trailer_type, ARG_NOT_NULL,
                        NO_MORE_ARGS);

    while (arb_next_row(g_spDBcustfetch) == ARB_MORE_DATA)
    {
        header_size = strlen(current.description);
        header_size = MAX(header_size, 30);
        field_size = MAX(header_size, current.field_size);

        realloc_layout(&trailer->layout, trail_pos);

        realloc_values(&trailer->values, trail_pos);
        memset(&trailer->values[trail_pos], 0, sizeof(JNL_VALUES));

        realloc_values(&trailer->binds, trail_pos);
        memset(&trailer->binds[trail_pos], 0, sizeof(JNL_VALUES));

        process_pre_formatted(&current, trailer->values[trail_pos].value);

        memcpy(&trailer->layout[trail_pos], &current, sizeof(JNL_FEED_LAYOUT_REC));

        trailer->record_size += current.field_size;

        if (current.in_feed_report == TRUE)
            trailer->display_length += field_size + 1;

        trail_pos++;
    }

    arb_clear_proc_io (&jnl_get_trailer_layout_proc);

    JNL_CHECK_FETCH (g_spDBcustfetch, "jnl_get_trailier_layout");

    trailer->count = trail_pos;

    return;
}
Пример #6
0
main()
{
    static PACKINFO pinf[100];
    int i=0,level,flag=0;
    int padx, pady, count;
LAYOUT *base, *tmpxx;

    padx = 4;
    pady = 4;
/*
    flag = FILL_X | FILL_Y | GRID_X;
    flag = ALIGNY_CENTER  ;
*/

flag=   GRID_X | FILL_Y;
 i=0;

    level = 0; 
    pinf[i].level =  level;
    pinf[i].width = 50;
    pinf[i].height= 50;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
    
   level++;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 1;
    pinf[i].height= 1;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;

    level++;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 8;
    pinf[i].height= 5;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag; 

    level--;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 50;
    pinf[i].height= 20;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
    
    i++;
    pinf[i].level =  level;
    pinf[i].width = 1;
    pinf[i].height= 1;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = FILL_X;

    i++;
    pinf[i].level =  level;
    pinf[i].width = 40;
    pinf[i].height= 10;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
 
 
    i++;
    pinf[i].level =  level;
    pinf[i].width = 1;
    pinf[i].height= 1;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_VERTICAL;
    pinf[i].flag = flag;
 
    level++;
    i++;
    pinf[i].level =  level;
    pinf[i].width = 20;
    pinf[i].height= 16;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_HORIZONTAL;
    pinf[i].flag = FILL_Y;

   i++;
    pinf[i].level =  level;
    pinf[i].width = 38;
    pinf[i].height= 9;
    pinf[i].marginx = padx;
    pinf[i].marginy = pady;
    pinf[i].direction = PACK_HORIZONTAL;
    pinf[i].flag = FILL_Y;
    
    count = i+1;
/*
                   pinf[i].borderx, 
                   pinf[i].border_bottom, 

*/
    base = new_layout();
    for (i=0;i<count;i++) {
        add_layout(base, 
                   pinf[i].level, 
                   pinf[i].width, 
                   pinf[i].height,
                   pinf[i].direction, 
                   pinf[i].marginx, 
                   pinf[i].marginy, 
                   5, 
                   8, 
                   2, 
                   pinf[i].flag,
                   &(pinf[i]));
    }
    calc_total_layout(base);
    transfer_results(base);
    free_layout(base);

   
{
FILE *file = fopen("blaa.ps","w");
if (file==NULL)
    return; 

   ps_header( file, 2.0);

    for (i=0;i<count;i++) {

           fprintf(file,"%d %d %d %d dr\n",
                pinf[i].x, 
                pinf[i].y, 
                pinf[i].x+pinf[i].width, 
                pinf[i].y+pinf[i].height);

}    
    ps_footer(file);
fclose(file);
}


}
Пример #7
0
void manage_layout(PACKINFO *pinf)
{
    LAYOUT *base, *tmp;
    int i,level,flag;
    int padx, pady;
PACKINFO *tmpxx;
FILE *file;
    padx = 6;
    pady = 10;
/*
    flag = FILL_X | FILL_Y | GRID_X;
*/
    flag = ALIGN_Y_CENTER  ;

tmpxx=pinf;

//file = fopen("blaa","w");
//if (file==NULL)
  //  return;

    base = new_layout();
    level = 0;
    while (pinf) {
        if (pinf->level < 0) {
            free_layout(base);
            return;
        }
        add_layout(base, 
                   pinf->level, 
                   pinf->width, 
                   pinf->height,
                   pinf->direction, 
                   pinf->marginx, 
                   pinf->marginy, 
                   pinf->borderx, 
                   pinf->border_top, 
                   pinf->border_bottom, 
                   pinf->flag,
                   pinf);
//fprintf(file, "%d %d %d\n",pinf->level, 
    //               pinf->width, 
      //             pinf->height);



        pinf = pinf->next;
    }
//fclose(file);

    calc_total_layout(base);
    transfer_results(base);
    free_layout(base);

#ifdef debuggg
{
FILE *file = fopen("blaa.ps","w");
if (file==NULL)
    return;

   ps_header( file, 1.0);
pinf=tmpxx;
    while (pinf) {

           fprintf(file,"%d %d %d %d dr\n",
                pinf->x, 
                pinf->y, 
                pinf->x+pinf->width, 
                pinf->y+pinf->height);
pinf=pinf->next;
}
    ps_footer(file);
fclose(file);
}
#endif
}