/usr/include/gmic.h is in libgmic-dev 1.7.9+zart-4build3.
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 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | /*
#
# File : gmic.h
# ( C++ header file )
#
# Description : GREYC's Magic for Image Computing
# ( http://gmic.eu )
#
# Note : Include this file in your C++ source code, if you
# want to use the G'MIC interpreter in your own program.
#
# Copyright : David Tschumperle
# ( http://tschumperle.users.greyc.fr/ )
#
# License : CeCILL v2.0
# ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
#
# This software is governed by the CeCILL license under French law and
# abiding by the rules of distribution of free software. You can use,
# modify and/ or redistribute the software under the terms of the CeCILL
# license as circulated by CEA, CNRS and INRIA at the following URL
# "http://www.cecill.info".
#
# As a counterpart to the access to the source code and rights to copy,
# modify and redistribute granted by the license, users are provided only
# with a limited warranty and the software's author, the holder of the
# economic rights, and the successive licensors have only limited
# liability.
#
# In this respect, the user's attention is drawn to the risks associated
# with loading, using, modifying and/or developing or reproducing the
# software by the user in light of its specific status of free software,
# that may mean that it is complicated to manipulate, and that also
# therefore means that it is reserved for developers and experienced
# professionals having in-depth computer knowledge. Users are therefore
# encouraged to load and test the software's suitability as regards their
# requirements in conditions enabling the security of their systems and/or
# data to be ensured and, more generally, to use and operate it in the
# same conditions as regards security.
#
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.
#
*/
#ifndef gmic_version
#define gmic_version 179
#include <cstdio>
#include <cstring>
#ifndef gmic_build
// Define classes 'gmic_image<T>' and 'gmic_list<T>'.
//---------------------------------------------------
#ifndef cimg_version
#define gmic_image CImg
#define gmic_list CImgList
namespace cimg_library {
// Class 'gmic_image<T>'.
template<typename T> struct gmic_image {
unsigned int _width; // Number of image columns (dimension along the X-axis).
unsigned int _height; // Number of image lines (dimension along the Y-axis)
unsigned int _depth; // Number of image slices (dimension along the Z-axis).
unsigned int _spectrum; // Number of image channels (dimension along the C-axis).
bool _is_shared; // Tells if the data buffer is shared by another structure.
T *_data; // Pointer to the first pixel value.
// Destructor.
~gmic_image();
// Constructor.
gmic_image():_width(0),_height(0),_depth(0),_spectrum(0),_is_shared(false),_data(0) {}
// Allocate memory for specified image dimensions.
gmic_image<T>& assign(const unsigned int size_x, const unsigned int size_y=1,
const unsigned int size_z=1, const unsigned int size_c=1);
// Pixel access.
operator T*() {
return _data;
}
operator const T*() const {
return _data;
}
T& operator()(const unsigned int x, const unsigned int y=0, const unsigned z=0, const unsigned c=0) {
return _data[x + y*_width + z*_width*_height + c*_width*_height*_depth ];
}
const T& operator()(const unsigned int x, const unsigned int y=0, const unsigned z=0, const unsigned c=0) const {
return _data[x + y*_width + z*_width*_height + c*_width*_height*_depth ];
}
};
// Class 'gmic_list<T>'.
template<typename T> struct gmic_list {
unsigned int _width; // Number of images in the list.
unsigned int _allocated_width; // Allocated items in the list (must be 2^N and >size).
gmic_image<T> *_data; // Pointer to the first image of the list.
// Destructor.
~gmic_list();
// Constructor.
gmic_list():_width(0),_allocated_width(0),_data(0) {}
// Allocate memory for specified list dimension.
gmic_list<T>& assign(const unsigned int n);
// Image access.
operator gmic_image<T>*() {
return _data;
}
operator const gmic_image<T>*() const {
return _data;
}
T& operator()(const unsigned int l) {
return _data[l];
}
const T& operator()(const unsigned int l) const {
return _data[l];
}
};
}
#undef gmic_image
#undef gmic_list
#endif // #ifndef cimg_version
#else // #ifndef gmic_build
// Define private functions, used to compile libgmic.
//---------------------------------------------------
#ifndef cimg_verbosity
#define cimg_verbosity 1
#endif // #ifndef cimg_verbosity
#ifdef _MSC_VER
#pragma comment(linker,"/STACK:6291456")
#pragma inline_depth(2)
#endif // #ifdef _MSC_VER
#include <locale>
#ifdef cimg_version
#error "[gmic] *** Error *** File 'gmic_CImg.h' has been already included (should have been done first in file 'gmic.h')."
#endif
#define cimg_plugin "gmic.cpp"
#ifdef cimg_use_abort
static struct cimg_is_abort {
bool value, *ptr;
cimg_is_abort():value(false),ptr(&value) {}
} _cimg_is_abort;
#define cimg_abort_test() if (*_cimg_is_abort.ptr) throw CImgAbortException()
#endif // #ifdef cimg_use_abort
#ifndef cimg_display
#define cimg_display 0
#endif // #ifndef cimg_display
#include "./gmic_CImg.h"
#if cimg_OS==2
#include <process.h>
#include <psapi.h>
#elif cimg_OS==1
#include <cerrno>
#include <sys/resource.h>
#include <signal.h>
#endif // #if cimg_OS==2
// Define some special character codes used for replacement in double quoted strings.
const char gmic_dollar = 23, gmic_lbrace = 24, gmic_rbrace = 25, gmic_comma = 26, gmic_dquote = 28, gmic_newline = 29;
#endif // #ifndef gmic_build
// Define main libgmic class 'gmic'.
//----------------------------------
#define gmic_image cimg_library::CImg
#define gmic_list cimg_library::CImgList
// Class 'gmic'.
struct gmic {
// Destructor.
~gmic();
// Constructors.
gmic();
gmic(const char *const commands_line,
const char *const custom_commands=0,
const bool include_stdlib=true,
float *const p_progress=0, bool *const p_is_abort=0);
template<typename T>
gmic(const char *const commands_line,
gmic_list<T>& images, gmic_list<char>& images_names, const char *const custom_commands=0,
const bool include_stdlib=true, float *const p_progress=0, bool *const p_is_abort=0);
// Run G'MIC pipeline on an already-constructed object.
gmic& run(const char *const commands_line,
float *const p_progress=0, bool *const p_is_abort=0);
template<typename T>
gmic& run(const char *const commands_line,
gmic_list<T> &images, gmic_list<char> &images_names,
float *const p_progress=0, bool *const p_is_abort=0);
// These functions return (or init) G'MIC-specific paths.
static const char* path_user(const char *const custom_path=0);
static const char* path_rc(const char *const custom_path=0);
static bool init_rc(const char *const custom_path=0);
// Functions below should be considered as *private*, and should not be
// used in user's code.
static int _levenshtein(const char *const s, const char *const t,
gmic_image<int>& d, const int i, const int j);
static int levenshtein(const char *const s, const char *const t);
static bool check_filename(const char *const filename);
static unsigned int hashcode(const char *const str, const bool is_variable);
static bool command_has_arguments(const char *const command);
static const char* basename(const char *const str);
static char *strreplace_fw(char *const str);
static char *strreplace_bw(char *const str);
static unsigned int strescape(const char *const str, char *const res);
static const gmic_image<char>& decompress_stdlib();
template<typename T>
void _gmic(const char *const commands_line,
gmic_list<T>& images, gmic_list<char>& images_names,
const char *const custom_commands, const bool include_stdlib,
float *const p_progress, bool *const p_is_abort);
inline const char * set_variable(const char *const name, const char *const value,
const char operation='=',
const unsigned int *const variables_sizes=0);
gmic& add_commands(const char *const data_commands, const char *const commands_file=0);
gmic& add_commands(std::FILE *const file, const char *const filename=0);
gmic_image<char> callstack2string(const bool is_debug=false) const;
gmic_image<char> callstack2string(const gmic_image<unsigned int>& callstack_selection,
const bool is_debug=false) const;
gmic_image<char> callstack2string(const gmic_image<unsigned int>* callstack_selection,
const bool is_debug=false) const;
gmic_image<unsigned int> selection2cimg(const char *const string, const unsigned int indice_max,
const gmic_list<char>& names, const char *const command,
const bool is_selection=true, gmic_image<char> *const new_name=0);
gmic_image<char>& selection2string(const gmic_image<unsigned int>& selection,
const gmic_list<char>& images_names,
const unsigned int display_selection,
gmic_image<char>& res) const;
gmic_list<char> commands_line_to_CImgList(const char *const commands_line);
template<typename T>
void _gmic_substitute_args(const char *const argument, const char *const argument0,
const char *const command, const char *const item,
const gmic_list<T>& images);
gmic& print(const char *format, ...);
gmic& error(const char *format, ...);
gmic& debug(const char *format, ...);
template<typename T>
gmic_image<char> substitute_item(const char *const source,
gmic_list<T>& images, gmic_list<char>& images_names,
gmic_list<T>& parent_images, gmic_list<char>& parent_images_names,
const unsigned int *const variables_sizes,
const gmic_image<unsigned int> *const command_selection,
const bool is_image_expr);
template<typename T>
gmic& print(const gmic_list<T>& list, const gmic_image<unsigned int> *const callstack_selection,
const char *format, ...);
template<typename T>
gmic& warn(const gmic_list<T>& list, const gmic_image<unsigned int> *const callstack_selection,
const bool force_visible, const char *format, ...);
template<typename T>
gmic& error(const gmic_list<T>& list, const gmic_image<unsigned int> *const callstack_selection,
const char *const command, const char *format, ...);
template<typename T>
gmic& debug(const gmic_list<T>& list, const char *format, ...);
template<typename T>
gmic& print_images(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const bool is_header=true);
template<typename T>
gmic& display_images(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
unsigned int *const XYZ,
const bool exit_on_anykey);
template<typename T>
gmic& display_plots(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const unsigned int plot_type, const unsigned int vertex_type,
const double xmin, const double xmax,
const double ymin, const double ymax,
const bool exit_on_anykey);
template<typename T>
gmic& display_objects3d(const gmic_list<T>& images,
const gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const gmic_image<unsigned char>& background3d,
const bool exit_on_anykey);
template<typename T>
gmic_image<T>& check_image(const gmic_list<T>& list, gmic_image<T>& img);
template<typename T>
const gmic_image<T>& check_image(const gmic_list<T>& list, const gmic_image<T>& img);
template<typename T>
gmic& remove_images(gmic_list<T>& images, gmic_list<char>& images_names,
const gmic_image<unsigned int>& selection,
const unsigned int start, const unsigned int end);
template<typename T>
gmic& _run(const gmic_list<char>& commands_line,
gmic_list<T> &images, gmic_list<char> &images_names,
float *const p_progress, bool *const p_is_abort);
template<typename T>
gmic& _run(const gmic_list<char>& commands_line, unsigned int& position,
gmic_list<T>& images, gmic_list<char>&images_names,
gmic_list<T>& parent_images, gmic_list<char>& parent_images_names,
const unsigned int *const variables_sizes,
bool *const is_noargs, const char *const parent_arguments,
const gmic_image<unsigned int> *const command_selection);
// Class variables.
static gmic_image<char> stdlib;
gmic_list<char> *const commands, *const commands_names, *const commands_has_arguments,
*const _variables, *const _variables_names, **const variables, **const variables_names,
commands_files, callstack;
gmic_list<unsigned int> dowhiles, repeatdones;
gmic_image<unsigned char> light3d;
gmic_image<char> status;
void *display_window;
float focale3d, light3d_x, light3d_y, light3d_z, specular_lightness3d, specular_shininess3d, _progress, *progress;
unsigned long reference_time;
unsigned int nb_carriages, debug_filename, debug_line, cimg_exception_mode;
int verbosity, render3d, renderd3d;
bool is_released, is_debug, is_running, is_start, is_return, is_quit, is_double3d, is_debug_info, check_elif;
const char *starting_commands_line;
bool _is_abort, *is_abort, is_abort_thread;
};
// Class 'gmic_exception'.
//------------------------
struct gmic_exception {
gmic_image<char> _command_help, _message;
// Constructors.
gmic_exception() {}
gmic_exception(const char *const command, const char *const message) {
if (command) {
_command_help.assign((unsigned int)std::strlen(command) + 1,1,1,1);
std::strcpy(_command_help._data,command);
}
if (message) {
_message.assign((unsigned int)std::strlen(message) + 1,1,1,1);
std::strcpy(_message._data,message);
}
}
// Return error message.
const char *what() const { // Give the error message returned by the G'MIC interpreter.
return _message._data?_message._data:"";
}
const char *command_help() const {
return _command_help._data?_command_help._data:"";
}
};
#endif // #ifndef gmic_version
// Local Variables:
// mode: c++
// End:
|