~ubuntu-branches/ubuntu/intrepid/graphicsmagick/intrepid

« back to all changes in this revision

Viewing changes to magick/utility.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2006-05-06 16:28:08 UTC
  • Revision ID: james.westby@ubuntu.com-20060506162808-vt2ni3r5nytcszms
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (C) 2003, 2004 GraphicsMagick Group
 
3
  Copyright (C) 2002 ImageMagick Studio
 
4
  Copyright 1991-1999 E. I. du Pont de Nemours and Company
 
5
 
 
6
  This program is covered by multiple licenses, which are described in
 
7
  Copyright.txt. You should have received a copy of Copyright.txt with this
 
8
  package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
9
 
 
10
  ImageMagick Utility Methods.
 
11
*/
 
12
#ifndef _MAGICK_UTILITY_H
 
13
#define _MAGICK_UTILITY_H
 
14
 
 
15
#if defined(__cplusplus) || defined(c_plusplus)
 
16
extern "C" {
 
17
#endif
 
18
 
 
19
/*
 
20
  Enum declarations.
 
21
*/
 
22
typedef enum
 
23
{
 
24
  RootPath,
 
25
  HeadPath,
 
26
  TailPath,
 
27
  BasePath,
 
28
  ExtensionPath,
 
29
  MagickPath,
 
30
  SubImagePath,
 
31
  FullPath
 
32
} PathType;
 
33
 
 
34
/*
 
35
  Typedef declarations.
 
36
*/
 
37
typedef struct _TokenInfo
 
38
{
 
39
  int
 
40
    state;
 
41
 
 
42
  unsigned int
 
43
    flag;
 
44
 
 
45
  long
 
46
    offset;
 
47
 
 
48
  char
 
49
    quote;
 
50
} TokenInfo;
 
51
 
 
52
/*
 
53
  Utilities methods.
 
54
*/
 
55
#if !defined(__GNUC__) && !defined(__attribute__)
 
56
#  define __attribute__(x) /*nothing*/
 
57
#endif
 
58
 
 
59
extern MagickExport char
 
60
  *AcquireString(const char *),
 
61
  *AllocateString(const char *),
 
62
  *Base64Encode(const unsigned char *,const size_t,size_t *),
 
63
  *EscapeString(const char *,const char),
 
64
  *GetPageGeometry(const char *),
 
65
  **ListFiles(const char *,const char *,long *),
 
66
  *SetClientName(const char *),
 
67
  **StringToArgv(const char *,int *),
 
68
  **StringToList(const char *),
 
69
  *TranslateText(const ImageInfo *,Image *,const char *);
 
70
 
 
71
extern MagickExport const char
 
72
  *GetClientFilename(void),
 
73
  *SetClientFilename(const char *),
 
74
  *GetClientName(void),
 
75
  *GetClientPath(void),
 
76
  *SetClientPath(const char *);
 
77
 
 
78
extern MagickExport double
 
79
  StringToDouble(const char *,const double);
 
80
 
 
81
extern MagickExport int
 
82
  GetGeometry(const char *,long *,long *,unsigned long *,unsigned long *),
 
83
  GlobExpression(const char *,const char *),
 
84
  LocaleNCompare(const char *,const char *,const size_t),
 
85
  LocaleCompare(const char *,const char *),
 
86
  GetMagickDimension(const char *str,double *width,double *height),
 
87
  GetMagickGeometry(const char *,long *,long *,unsigned long *,unsigned long *),
 
88
  SubstituteString(char **,const char*,const char *),
 
89
  SystemCommand(const unsigned int,const char *),
 
90
  Tokenizer(TokenInfo *,unsigned,char *,size_t,char *,char *,char *,char *,
 
91
    char,char *,int *,char *);
 
92
 
 
93
extern MagickExport unsigned char
 
94
  *Base64Decode(const char *, size_t *);
 
95
 
 
96
extern MagickExport unsigned int
 
97
  CloneString(char **,const char *),
 
98
  ConcatenateString(char **,const char *),
 
99
  ExpandFilenames(int *,char ***),
 
100
  GetExecutionPath(char *),
 
101
  GetExecutionPathUsingName(char *),
 
102
  IsAccessible(const char *),
 
103
  IsAccessibleNoLogging(const char *),
 
104
  IsAccessibleAndNotEmpty(const char *),
 
105
  IsGeometry(const char *),
 
106
  IsGlob(const char *);
 
107
 
 
108
extern MagickExport unsigned long
 
109
  MultilineCensus(const char *);
 
110
 
 
111
extern MagickExport void
 
112
  *AcquireMemory(const size_t),
 
113
  AppendImageFormat(const char *,char *),
 
114
  *CloneMemory(void *,const void *,const size_t),
 
115
  DefineClientName(const char *),
 
116
  DefineClientPathAndName(const char *),
 
117
  ExpandFilename(char *),
 
118
  FormatSize(const magick_int64_t size,char *format),
 
119
  GetPathComponent(const char *,PathType,char *),
 
120
  GetToken(const char *,char **,char *),
 
121
  LiberateMemory(void **),
 
122
  LocaleLower(char *),
 
123
  LocaleUpper(char *),
 
124
  ReacquireMemory(void **,const size_t),
 
125
  Strip(char *),
 
126
  SetGeometry(const Image *,RectangleInfo *),
 
127
  TemporaryFilename(char *);
 
128
 
 
129
extern MagickExport void
 
130
  FormatString(char *,const char *,...) __attribute__((format (printf,2,3)));
 
131
 
 
132
#if defined(MAGICK_IMPLEMENTATION)
 
133
 
 
134
/*
 
135
  Allocate memory
 
136
*/
 
137
#define MagickAllocateMemory(type,size) ((type) malloc((size_t) (size)))
 
138
 
 
139
/*
 
140
  Free memory and set pointer to NULL
 
141
*/
 
142
#define MagickFreeMemory(memory) \
 
143
{ \
 
144
    void *_magick_mp; \
 
145
    if (memory != 0) \
 
146
      { \
 
147
        _magick_mp=memory; \
 
148
        free(_magick_mp); \
 
149
        memory=0; \
 
150
      } \
 
151
}
 
152
 
 
153
/*
 
154
  Reallocate memory using provided pointer.  If pointer value is null,
 
155
  then allocate new memory. If reallocation fails then free memory,
 
156
  setting pointer to NULL.
 
157
  C++ does not accept the final memory=_magick_mp without a cast.
 
158
*/
 
159
#define MagickReallocMemory(memory,size) \
 
160
{ \
 
161
    void *_magick_mp; \
 
162
    if (memory == 0) \
 
163
      _magick_mp=malloc((size_t) (size)); \
 
164
    else \
 
165
      { \
 
166
        _magick_mp=realloc(memory,(size_t) (size)); \
 
167
        if (_magick_mp == 0) \
 
168
          free(memory); \
 
169
      } \
 
170
    memory=_magick_mp; \
 
171
}
 
172
 
 
173
/*
 
174
  Force argument into range accepted by <ctype.h> functions.
 
175
*/
 
176
#define CTYPE_ARG(value) ((int) ((unsigned char) (value)))
 
177
 
 
178
#endif /* defined(MAGICK_IMPLEMENTATION) */
 
179
 
 
180
#if defined(__cplusplus) || defined(c_plusplus)
 
181
}
 
182
#endif
 
183
 
 
184
#endif