/usr/include/cpl_recipedefine.h is in libcpl-dev 7.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | /*
* This file is part of the ESO Common Pipeline Library
* Copyright (C) 2001-2017 European Southern Observatory
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef CPL_RECIPEDEFINE_H
#define CPL_RECIPEDEFINE_H
/*-----------------------------------------------------------------------------
Includes
-----------------------------------------------------------------------------*/
#include <cpl_recipe.h>
#include <cpl_plugininfo.h>
#include <cpl_version.h>
#include <cpl_errorstate.h>
CPL_BEGIN_DECLS
/*----------------------------------------------------------------------------*/
/**
@hideinitializer
@ingroup cpl_recipedefine
@brief Generate the recipe copyright and license text (GPL v.2)
@param PACKAGE_NAME The name as a string literal, e.g. from config.h
@param YEAR The year(s) as a string literal
@return The recipe copyright and license text as a string literal
Example:
@code
const char * eso_gpl_license = cpl_get_license(PACKAGE_NAME, "2005, 2008");
@endcode
*/
/*----------------------------------------------------------------------------*/
#define cpl_get_license(PACKAGE_NAME, YEAR) \
"This file is part of the " PACKAGE_NAME "\n" \
"Copyright (C) " YEAR " European Southern Observatory\n" \
"\n" \
"This program is free software; you can redistribute it and/or modify\n" \
"it under the terms of the GNU General Public License as published by\n" \
"the Free Software Foundation; either version 2 of the License, or\n" \
"(at your option) any later version.\n" \
"\n" \
"This program is distributed in the hope that it will be useful,\n" \
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \
"GNU General Public License for more details.\n" \
"\n" \
"You should have received a copy of the GNU General Public License\n" \
"along with this program; if not, write to the Free Software\n" \
"Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, \n" \
"MA 02111-1307 USA"
/*----------------------------------------------------------------------------*/
/**
@hideinitializer
@ingroup cpl_recipedefine
@brief Define a standard CPL recipe
@param RECIPE_NAME The name as an identifier
@param RECIPE_VERSION The binary version number
@param RECIPE_AUTHOR The author as a string literal
@param RECIPE_EMAIL The contact email as a string literal
@param RECIPE_YEAR The copyright year as a string literal
@param RECIPE_SYNOPSIS The synopsis as a string literal
@param RECIPE_DESCRIPTION The man-page as a string literal
A CPL-based recipe may use this macro to define its four mandatory
functions: cpl_plugin_get_info(), \<recipe\>_create(), \<recipe\>_exec() and
\<recipe\>_destroy(), as well as declaring the actual data reduction
function, \<recipe\>() as
@code
static int <recipe>(cpl_frameset *, const cpl_parameterlist *);
@endcode
The macro also declares the recipe-specific function that fills the
recipe parameterlist with the supported parameters as
@code
static cpl_error_code <recipe>_fill_parameterlist(cpl_parameterlist *self);
@endcode
A recipe that invokes cpl_recipe_define() must define this function.
The macro cpl_recipe_define() may be used by defining a macro, e.g. in
my_recipe.h:
@code
#define MY_RECIPE_DEFINE(NAME, SYNOPSIS, DESCRIPTION) \
cpl_recipe_define(NAME, MY_BINARY_VERSION, \
"Firstname Lastname", "2006, 2008", SYNOPSIS, DESCRIPTION)
@endcode
- and then by invoking this macro in each recipe:
@code
#include "my_recipe.h"
MY_RECIPE_DEFINE(instrume_img_dark,
"Dark recipe",
"instrume_img_dark -- imaging dark recipe.\n"
" ... recipe man-page\n");
static
cpl_error_code instrume_img_dark_fill_parameterlist(cpl_parameterlist *self);
{
// Fill the parameterlist with the parameters supported by the recipe.
retun CPL_ERROR_NONE;
}
@endcode
*/
/*----------------------------------------------------------------------------*/
#define cpl_recipe_define(RECIPE_NAME, RECIPE_VERSION, RECIPE_AUTHOR, \
RECIPE_EMAIL, RECIPE_YEAR, \
RECIPE_SYNOPSIS, RECIPE_DESCRIPTION) \
\
/* The prototypes of the recipe create, exec and destroy functions */ \
static int CPL_CONCAT2X(RECIPE_NAME,create) (cpl_plugin * plugin); \
static int CPL_CONCAT2X(RECIPE_NAME,exec) (cpl_plugin * plugin); \
static int CPL_CONCAT2X(RECIPE_NAME,destroy)(cpl_plugin * plugin); \
\
/* The prototype of the function called by the recipe exec function */ \
static int RECIPE_NAME(cpl_frameset *, const cpl_parameterlist *); \
\
/* The prototype of the parameterlist filler function */ \
static cpl_error_code CPL_CONCAT2X(RECIPE_NAME,fill_parameterlist) \
(cpl_parameterlist *); \
\
int cpl_plugin_get_info(cpl_pluginlist * list) \
{ \
/* Propagate error, if any. Return 1 on failure */ \
return cpl_recipedefine_init(list, CPL_VERSION_CODE, \
RECIPE_VERSION, \
#RECIPE_NAME, \
RECIPE_SYNOPSIS, \
RECIPE_DESCRIPTION, \
RECIPE_AUTHOR, \
RECIPE_EMAIL, \
cpl_get_license(PACKAGE_NAME, RECIPE_YEAR), \
CPL_CONCAT2X(RECIPE_NAME,create), \
CPL_CONCAT2X(RECIPE_NAME,exec), \
CPL_CONCAT2X(RECIPE_NAME,destroy)) \
? ((void)cpl_error_set_where(cpl_func), 1) : 0; \
} \
\
/* The definition of the recipe create function */ \
static int CPL_CONCAT2X(RECIPE_NAME,create)(cpl_plugin * plugin) \
{ \
cpl_recipe * recipe = (cpl_recipe *)plugin; /* Needed for the fill */ \
cpl_errorstate prestate = cpl_errorstate_get(); /* To check the fill */ \
\
/* Propagate error, if any */ \
/* - Need two function calls to ensure plugin validity before the fill */ \
return cpl_recipedefine_create(plugin) \
|| cpl_recipedefine_create_is_ok(prestate, \
CPL_CONCAT2X(RECIPE_NAME,fill_parameterlist)(recipe->parameters)) \
? (int)cpl_error_set_where(cpl_func) : 0; \
} \
\
/* The definition of the recipe exec function */ \
static int CPL_CONCAT2X(RECIPE_NAME,exec)(cpl_plugin * plugin) \
{ \
/* Propagate error, if any */ \
return cpl_recipedefine_exec(plugin, RECIPE_NAME) \
? (int)cpl_error_set_where(cpl_func) : 0; \
} \
\
/* The definition of the recipe destroy function */ \
static int CPL_CONCAT2X(RECIPE_NAME,destroy)(cpl_plugin * plugin) \
{ \
/* Propagate error, if any */ \
return cpl_recipedefine_destroy(plugin) \
? (int)cpl_error_set_where(cpl_func) : 0; \
} \
\
/* This dummy declaration requires the macro to be invoked as if it was \
a kind of function declaration, with a terminating ; */ \
extern int cpl_plugin_end
/*----------------------------------------------------------------------------*/
/**
@hideinitializer
@ingroup cpl_recipedefine
@brief Define a standard CPL recipe
@param RECIPE_NAME The name as an identifier
@param RECIPE_VERSION The binary version number
@param RECIPE_FILL_PARAMS A function call to fill the recipe parameterlist.
Must evaluate to zero if and only if successful
@param RECIPE_AUTHOR The author as a string literal
@param RECIPE_AUTHOR_EMAIL The author email as a string literal
@param RECIPE_YEAR The copyright year as a string literal
@param RECIPE_SYNOPSIS The synopsis as a string literal
@param RECIPE_DESCRIPTION The man-page as a string literal
@deprecated Use cpl_recipe_define()
*/
/*----------------------------------------------------------------------------*/
#define CPL_RECIPE_DEFINE(RECIPE_NAME, RECIPE_VERSION, RECIPE_FILL_PARAMS, \
RECIPE_AUTHOR, RECIPE_AUTHOR_EMAIL, RECIPE_YEAR, \
RECIPE_SYNOPSIS, RECIPE_DESCRIPTION) \
\
/* The prototypes of the recipe create, exec and destroy functions */ \
static int CPL_CONCAT2X(RECIPE_NAME,create) (cpl_plugin * plugin); \
static int CPL_CONCAT2X(RECIPE_NAME,exec) (cpl_plugin * plugin); \
static int CPL_CONCAT2X(RECIPE_NAME,destroy)(cpl_plugin * plugin); \
\
/* The prototype of the function called by the recipe exec function */ \
static int RECIPE_NAME(cpl_frameset *, const cpl_parameterlist *); \
\
int cpl_plugin_get_info(cpl_pluginlist * list) \
{ \
/* Propagate error, if any. Return 1 on failure */ \
return cpl_recipedefine_init(list, CPL_VERSION_CODE, \
RECIPE_VERSION, \
#RECIPE_NAME, \
RECIPE_SYNOPSIS, \
RECIPE_DESCRIPTION, \
RECIPE_AUTHOR, \
RECIPE_AUTHOR_EMAIL, \
cpl_get_license(PACKAGE_NAME, RECIPE_YEAR), \
CPL_CONCAT2X(RECIPE_NAME,create), \
CPL_CONCAT2X(RECIPE_NAME,exec), \
CPL_CONCAT2X(RECIPE_NAME,destroy)) \
? ((void)cpl_error_set_where(cpl_func), 1) : 0; \
} \
\
/* The definition of the recipe create function */ \
static int CPL_CONCAT2X(RECIPE_NAME,create)(cpl_plugin * plugin) \
{ \
cpl_recipe * recipe = (cpl_recipe *)plugin; /* Needed for the fill */ \
cpl_errorstate prestate = cpl_errorstate_get(); /* To check the fill */ \
\
/* Propagate error, if any */ \
/* - Need two function calls to ensure plugin validity before the fill */ \
return cpl_recipedefine_create(plugin) \
|| cpl_recipedefine_create_is_ok(prestate, (RECIPE_FILL_PARAMS)) \
? (int)cpl_error_set_where(cpl_func) : 0; \
} \
\
/* The definition of the recipe exec function */ \
static int CPL_CONCAT2X(RECIPE_NAME,exec)(cpl_plugin * plugin) \
{ \
/* Propagate error, if any */ \
return cpl_recipedefine_exec(plugin, RECIPE_NAME) \
? (int)cpl_error_set_where(cpl_func) : 0; \
} \
\
/* The definition of the recipe destroy function */ \
static int CPL_CONCAT2X(RECIPE_NAME,destroy)(cpl_plugin * plugin) \
{ \
/* Propagate error, if any */ \
return cpl_recipedefine_destroy(plugin) \
? (int)cpl_error_set_where(cpl_func) : 0; \
} \
\
/* This dummy declaration requires the macro to be invoked as if it was \
a kind of function declaration, with a terminating ; */ \
extern int cpl_plugin_end
/*-----------------------------------------------------------------------------
Function prototypes
-----------------------------------------------------------------------------*/
cpl_error_code cpl_recipedefine_init(cpl_pluginlist *, unsigned long,
unsigned long, const char *, const char *,
const char *, const char *, const char *,
const char *, cpl_plugin_func,
cpl_plugin_func, cpl_plugin_func)
#ifdef CPL_HAVE_ATTR_NONNULL
__attribute__((nonnull(9, 10, 11, 12)))
#endif
;
cpl_error_code cpl_recipedefine_create(cpl_plugin *);
cpl_error_code cpl_recipedefine_create_is_ok(cpl_errorstate, cpl_error_code);
cpl_error_code cpl_recipedefine_exec(cpl_plugin *,
int (*)(cpl_frameset *,
const cpl_parameterlist *));
cpl_error_code cpl_recipedefine_destroy(cpl_plugin *);
CPL_END_DECLS
#endif
/* end of cpl_recipedefine.h */
|