File: action_class_set_missing.c

package info (click to toggle)
grib-api 1.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,008 kB
  • ctags: 10,015
  • sloc: ansic: 63,157; sh: 9,355; f90: 2,545; makefile: 2,496; yacc: 519; perl: 240; lex: 217
file content (127 lines) | stat: -rw-r--r-- 3,692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* Copyright 2005-2007 ECMWF
*
* Licensed under the GNU Lesser General Public License which
* incorporates the terms and conditions of version 3 of the GNU
* General Public License.
* See LICENSE and gpl-3.0.txt for details.
*/

/***************************************************************************
 *  Enrico Fucile                                                                         *
 ***************************************************************************/
#include "grib_api_internal.h"
/*
   This is used by make_class.pl

   START_CLASS_DEF
   CLASS      = action
   IMPLEMENTS = dump
   IMPLEMENTS = destroy;execute
   MEMBERS    = char *name
   END_CLASS_DEF

 */

/* START_CLASS_IMP */

/*

Don't edit anything between START_CLASS_IMP and END_CLASS_IMP
Instead edit values between START_CLASS_DEF and END_CLASS_DEF
or edit "action.class" and rerun ./make_class.pl

*/

static void init_class      (grib_action_class*);
static void dump            (grib_action* d, FILE*,int);
static void destroy         (grib_context*,grib_action*);
static int execute(grib_action* a,grib_handle* h);


typedef struct grib_action_set_missing {
    grib_action          act;  
/* Members defined in set_missing */
	char *name;
} grib_action_set_missing;


static grib_action_class _grib_action_class_set_missing = {
    0,                              /* super                     */
    "action_class_set_missing",                              /* name                      */
    sizeof(grib_action_set_missing),            /* size                      */
    0,                                   /* inited */
    &init_class,                         /* init_class */
    0,                               /* init                      */
    &destroy,                            /* destroy */

    &dump,                               /* dump                      */
    0,                               /* xref                      */

    0,             /* create_accessor*/

    0,                            /* notify_change */
    0,                            /* reparse */
    &execute,                            /* execute */
};

grib_action_class* grib_action_class_set_missing = &_grib_action_class_set_missing;

static void init_class(grib_action_class* c)
{
}
/* END_CLASS_IMP */

grib_action* grib_action_create_set_missing( grib_context* context,
  const char* name)
{
  char buf[1024];

  grib_action_set_missing* a ;
  grib_action_class* c   = grib_action_class_set_missing;
  grib_action* act       = (grib_action*)grib_context_malloc_clear_persistent(context,c->size);
  act->op              = grib_context_strdup_persistent(context,"set_missing");

  act->cclass       = c;
  a                 = (grib_action_set_missing*)act;
  act->context      = context;

  a->name        = grib_context_strdup_persistent(context,name);


  sprintf(buf,"set_missing_%s",name);

  act->name      = grib_context_strdup_persistent(context,buf);

  return act;
}

static int execute(grib_action* a, grib_handle *h)
{
  grib_action_set_missing* self = (grib_action_set_missing*) a;

  return grib_set_missing(h,self->name);
}


static void dump(grib_action* act, FILE* f, int lvl)
{
  int i =0;
  grib_action_set_missing* self=(grib_action_set_missing*)act;
  for (i=0;i<lvl;i++)
    grib_context_print(act->context,f,"     ");
  grib_context_print(act->context,f,self->name);
  printf("\n");
}


static void destroy(grib_context* context,grib_action* act)
{
  grib_action_set_missing* a = (grib_action_set_missing*) act;

  grib_context_free_persistent(context, a->name);
  grib_context_free_persistent(context, act->name);
  grib_context_free_persistent(context, act->op);

}