ReactOS  0.4.14-dev-77-gd9e7c48
utils.h File Reference
#include "widltypes.h"
#include <stddef.h>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __attribute__(X)
 
#define MAKEVERSION(major, minor)   ((((minor) & 0xffff) << 16) | ((major) & 0xffff))
 
#define MAJORVERSION(version)   ((version) & 0xffff)
 
#define MINORVERSION(version)   (((version) >> 16) & 0xffff)
 
#define max(a, b)   (((a) > (b)) ? (a) : (b))
 
#define min(a, b)   (((a) < (b)) ? (a) : (b))
 

Functions

voidxmalloc (size_t)
 
voidxrealloc (void *, size_t)
 
charxstrdup (const char *str)
 
int strendswith (const char *str, const char *end)
 
void parser_error (const char *s) __attribute__((noreturn))
 
int parser_warning (const char *s,...) __attribute__((format(printf
 
int void error_loc (const char *s,...) __attribute__((format(printf
 
int void __attribute__ ((noreturn))
 
void error (const char *s,...) __attribute__((format(printf
 
void error_loc_info (const loc_info_t *, const char *s,...) __attribute__((format(printf
 
void warning (const char *s,...) __attribute__((format(printf
 
void void warning_loc_info (const loc_info_t *, const char *s,...) __attribute__((format(printf
 
void void void chat (const char *s,...) __attribute__((format(printf
 
void void void chardup_basename (const char *name, const char *ext)
 
size_t widl_getline (char **linep, size_t *lenp, FILE *fp)
 
UUIDparse_uuid (const char *u)
 
int is_valid_uuid (const char *s)
 
void init_output_buffer (void)
 
void flush_output_buffer (const char *name)
 
void add_output_to_resources (const char *type, const char *name)
 
void flush_output_resources (const char *name)
 
void put_data (const void *data, size_t size)
 
void put_byte (unsigned char val)
 
void put_word (unsigned short val)
 
void put_dword (unsigned int val)
 
void put_qword (unsigned int val)
 
void put_pword (unsigned int val)
 
void put_str (int indent, const char *format,...) __attribute__((format(printf
 
void void align_output (unsigned int align)
 

Variables

int byte_swapped
 
unsigned charoutput_buffer
 
size_t output_buffer_pos
 
size_t output_buffer_size
 

Macro Definition Documentation

◆ __attribute__

Definition at line 34 of file utils.h.

◆ MAJORVERSION

#define MAJORVERSION (   version)    ((version) & 0xffff)

Definition at line 75 of file utils.h.

◆ MAKEVERSION

#define MAKEVERSION (   major,
  minor 
)    ((((minor) & 0xffff) << 16) | ((major) & 0xffff))

Definition at line 74 of file utils.h.

◆ max

#define max (   a,
  b 
)    (((a) > (b)) ? (a) : (b))

Definition at line 79 of file utils.h.

◆ min

#define min (   a,
  b 
)    (((a) < (b)) ? (a) : (b))

Definition at line 82 of file utils.h.

◆ MINORVERSION

#define MINORVERSION (   version)    (((version) >> 16) & 0xffff)

Definition at line 76 of file utils.h.

Function Documentation

◆ __attribute__()

int void __attribute__ ( (noreturn)  )

Definition at line 201 of file pseh3.c.

206 {
207  if (RegistrationFrame->ScopeTable->HandlerType == _SEH3$_CLANG_HANDLER)
208  {
209  asm volatile (
210  /* Load the registers */
211  "movl 24(%%ecx), %%esp\n\t"
212  "movl 28(%%ecx), %%ebp\n\t"
213 
214  "movl 36(%%ecx), %%ebx\n\t"
215  "movl 40(%%ecx), %%esi\n\t"
216  "movl 44(%%ecx), %%edi\n\t"
217 
218  /* Stack pointer is 4 off from the call to __SEH3$_RegisterFrame */
219  "addl $4, %%esp\n\t"
220 
221  /* Jump into the exception handler */
222  "jmp *%[Target]"
223  : :
224  "c" (RegistrationFrame),
225  "a" (RegistrationFrame->ScopeTable),
226  [Target] "m" (RegistrationFrame->ScopeTable->Target)
227  );
228  }
229  else
230  {
231  asm volatile (
232  /* Load the registers */
233  "movl 24(%%ecx), %%esp\n\t"
234  "movl 28(%%ecx), %%ebp\n\t"
235 
236  /* Stack pointer is 4 off from the call to __SEH3$_RegisterFrame */
237  "addl $4, %%esp\n\t"
238 
239  /* Jump into the exception handler */
240  "jmp *%[Target]"
241  : :
242  "c" (RegistrationFrame),
243  "a" (RegistrationFrame->ScopeTable),
244  [Target] "m" (RegistrationFrame->ScopeTable->Target)
245  );
246  }
247 
248  __builtin_unreachable();
249 }
#define _SEH3
Definition: pseh3.c:38
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068

◆ add_output_to_resources()

void add_output_to_resources ( const char type,
const char name 
)

Definition at line 307 of file utils.c.

308 {
309  size_t data_size = output_buffer_pos;
310  size_t header_size = 5 * sizeof(unsigned int) + 2 * sizeof(unsigned short);
311 
312  assert( nb_resources < sizeof(resources)/sizeof(resources[0]) );
313 
314  if (type[0] != '#') header_size += (strlen( type ) + 1) * sizeof(unsigned short);
315  else header_size += 2 * sizeof(unsigned short);
316  if (name[0] != '#') header_size += (strlen( name ) + 1) * sizeof(unsigned short);
317  else header_size += 2 * sizeof(unsigned short);
318 
319  header_size = (header_size + 3) & ~3;
320  align_output( 4 );
321  check_output_buffer_space( header_size );
322  resources[nb_resources].size = header_size + output_buffer_pos;
324 
325  output_buffer_pos = 0;
326  put_dword( data_size ); /* ResSize */
327  put_dword( header_size ); /* HeaderSize */
328  put_resource_id( type ); /* ResType */
329  put_resource_id( name ); /* ResName */
330  align_output( 4 );
331  put_dword( 0 ); /* DataVersion */
332  put_word( 0 ); /* Memory options */
333  put_word( 0 ); /* Language */
334  put_dword( 0 ); /* Version */
335  put_dword( 0 ); /* Characteristics */
336 
339 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
void init_output_buffer(void)
Definition: utils.c:272
void put_dword(unsigned int val)
Definition: utils.c:395
void put_word(unsigned short val)
Definition: utils.c:389
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
static struct resource resources[16]
static void put_resource_id(const char *str)
Definition: utils.c:289
void align_output(unsigned int align)
Definition: utils.c:449
static void check_output_buffer_space(size_t size)
Definition: utils.c:263
static unsigned int nb_resources
Definition: utils.c:261
size_t output_buffer_pos
Definition: utils.c:253
Definition: name.c:36
unsigned char * output_buffer
Definition: utils.c:252
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by output_typelib_regscript(), save_all_changes(), and write_regscript().

◆ align_output()

void void align_output ( unsigned int  align)

Definition at line 449 of file utils.c.

450 {
451  size_t size = align - (output_buffer_pos % align);
452 
453  if (size == align) return;
457 }
int align(int length, int align)
Definition: dsound8.c:36
GLsizeiptr size
Definition: glext.h:5919
static void check_output_buffer_space(size_t size)
Definition: utils.c:263
size_t output_buffer_pos
Definition: utils.c:253
#define memset(x, y, z)
Definition: compat.h:39

Referenced by add_output_to_resources().

◆ chat()

void void void chat ( const char s,
  ... 
)

◆ dup_basename()

void void void char* dup_basename ( const char name,
const char ext 
)

Definition at line 143 of file utils.c.

144 {
145  int namelen;
146  int extlen = strlen(ext);
147  char *base;
148  char *slash;
149 
150  if(!name)
151  name = "widl.tab";
152 
153  slash = strrchr(name, '/');
154  if (!slash)
155  slash = strrchr(name, '\\');
156 
157  if (slash)
158  name = slash + 1;
159 
160  namelen = strlen(name);
161 
162  /* +6 for later extension (strlen("_r.rgs")) and +1 for '\0' */
163  base = xmalloc(namelen +6 +1);
164  strcpy(base, name);
165  if(!strcasecmp(name + namelen-extlen, ext))
166  {
167  base[namelen - extlen] = '\0';
168  }
169  return base;
170 }
#define strcasecmp
Definition: fake.h:9
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
GLint namelen
Definition: glext.h:7232
GLuint base
Definition: 3dtext.c:35
char ext[3]
Definition: mkdosfs.c:358
void * xmalloc(size_t size)
Definition: utils.c:201
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by add_filename_node(), dup_basename_token(), gen_name(), main(), and write_import().

◆ error()

void error ( const char s,
  ... 
)

◆ error_loc()

int void error_loc ( const char s,
  ... 
)

◆ error_loc_info()

void error_loc_info ( const loc_info_t ,
const char s,
  ... 
)

◆ flush_output_buffer()

void flush_output_buffer ( const char name)

Definition at line 279 of file utils.c.

280 {
281  int fd = open( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666 );
282  if (fd == -1) error( "Error creating %s\n", name );
284  error( "Error writing to %s\n", name );
285  close( fd );
286  free( output_buffer );
287 }
#define open
Definition: acwin.h:95
#define free
Definition: debug_ros.c:5
static int fd
Definition: io.c:51
#define write
Definition: acwin.h:97
#define O_WRONLY
Definition: acwin.h:111
void error(const char *s,...)
Definition: utils.c:104
#define O_TRUNC
Definition: acwin.h:112
#define close
Definition: acwin.h:98
#define O_BINARY
Definition: acwin.h:109
size_t output_buffer_pos
Definition: utils.c:253
Definition: name.c:36
#define O_CREAT
Definition: acwin.h:110

◆ flush_output_resources()

void flush_output_resources ( const char name)

Definition at line 341 of file utils.c.

342 {
343  int fd;
344  unsigned int i;
345 
346  /* all output must have been saved with add_output_to_resources() first */
348 
349  put_dword( 0 ); /* ResSize */
350  put_dword( 32 ); /* HeaderSize */
351  put_word( 0xffff ); /* ResType */
352  put_word( 0x0000 );
353  put_word( 0xffff ); /* ResName */
354  put_word( 0x0000 );
355  put_dword( 0 ); /* DataVersion */
356  put_word( 0 ); /* Memory options */
357  put_word( 0 ); /* Language */
358  put_dword( 0 ); /* Version */
359  put_dword( 0 ); /* Characteristics */
360 
361  fd = open( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666 );
362  if (fd == -1) error( "Error creating %s\n", name );
364  error( "Error writing to %s\n", name );
365  for (i = 0; i < nb_resources; i++)
366  {
367  if (write( fd, resources[i].data, resources[i].size ) != resources[i].size)
368  error( "Error writing to %s\n", name );
369  free( resources[i].data );
370  }
371  close( fd );
372  nb_resources = 0;
373  free( output_buffer );
374 }
#define open
Definition: acwin.h:95
#define free
Definition: debug_ros.c:5
#define assert(x)
Definition: debug.h:53
static int fd
Definition: io.c:51
void put_dword(unsigned int val)
Definition: utils.c:395
void put_word(unsigned short val)
Definition: utils.c:389
#define write
Definition: acwin.h:97
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define O_WRONLY
Definition: acwin.h:111
static struct resource resources[16]
GLsizeiptr size
Definition: glext.h:5919
void error(const char *s,...)
Definition: utils.c:104
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define O_TRUNC
Definition: acwin.h:112
#define close
Definition: acwin.h:98
#define O_BINARY
Definition: acwin.h:109
static unsigned int nb_resources
Definition: utils.c:261
size_t output_buffer_pos
Definition: utils.c:253
Definition: name.c:36
#define O_CREAT
Definition: acwin.h:110

Referenced by save_all_changes(), write_regscript(), and write_typelib_regscript().

◆ init_output_buffer()

void init_output_buffer ( void  )

Definition at line 272 of file utils.c.

273 {
274  output_buffer_size = 1024;
275  output_buffer_pos = 0;
277 }
size_t output_buffer_size
Definition: utils.c:254
void * xmalloc(size_t size)
Definition: utils.c:201
size_t output_buffer_pos
Definition: utils.c:253

Referenced by add_output_to_resources().

◆ is_valid_uuid()

int is_valid_uuid ( const char s)

Definition at line 7046 of file parser.tab.c.

7047 {
7048  int i;
7049 
7050  for (i = 0; i < 36; ++i)
7051  if (i == 8 || i == 13 || i == 18 || i == 23)
7052  {
7053  if (s[i] != '-')
7054  return FALSE;
7055  }
7056  else
7057  if (!isxdigit(s[i]))
7058  return FALSE;
7059 
7060  return s[i] == '\0';
7061 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLdouble s
Definition: gl.h:2039
#define isxdigit(c)
Definition: acclib.h:70

Referenced by yyparse().

◆ parse_uuid()

UUID* parse_uuid ( const char u)

Definition at line 793 of file parser.yy.c.

794 {
795  UUID* uuid = xmalloc(sizeof(UUID));
796  char b[3];
797  /* it would be nice to use UuidFromStringA */
798  uuid->Data1 = strtoul(u, NULL, 16);
799  uuid->Data2 = strtoul(u+9, NULL, 16);
800  uuid->Data3 = strtoul(u+14, NULL, 16);
801  b[2] = 0;
802  memcpy(b, u+19, 2); uuid->Data4[0] = strtoul(b, NULL, 16);
803  memcpy(b, u+21, 2); uuid->Data4[1] = strtoul(b, NULL, 16);
804  memcpy(b, u+24, 2); uuid->Data4[2] = strtoul(b, NULL, 16);
805  memcpy(b, u+26, 2); uuid->Data4[3] = strtoul(b, NULL, 16);
806  memcpy(b, u+28, 2); uuid->Data4[4] = strtoul(b, NULL, 16);
807  memcpy(b, u+30, 2); uuid->Data4[5] = strtoul(b, NULL, 16);
808  memcpy(b, u+32, 2); uuid->Data4[6] = strtoul(b, NULL, 16);
809  memcpy(b, u+34, 2); uuid->Data4[7] = strtoul(b, NULL, 16);
810  return uuid;
811 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
void * xmalloc(int size)
Definition: uimain.c:747
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: msctf.idl:510

Referenced by while(), and yyparse().

◆ parser_error()

void parser_error ( const char s)

Definition at line 80 of file utils.c.

81 {
82  error_loc("%s\n", s);
83 }
void error_loc(const char *s,...)
Definition: utils.c:69
GLdouble s
Definition: gl.h:2039

◆ parser_warning()

int parser_warning ( const char s,
  ... 
)

◆ put_byte()

void put_byte ( unsigned char  val)

Definition at line 383 of file utils.c.

384 {
387 }
GLuint GLfloat * val
Definition: glext.h:7180
static void check_output_buffer_space(size_t size)
Definition: utils.c:263
size_t output_buffer_pos
Definition: utils.c:253

◆ put_data()

void put_data ( const void data,
size_t  size 
)

Definition at line 376 of file utils.c.

377 {
381 }
GLsizeiptr size
Definition: glext.h:5919
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void check_output_buffer_space(size_t size)
Definition: utils.c:263
size_t output_buffer_pos
Definition: utils.c:253

Referenced by ctl2_write_segment(), ctl2_write_typeinfos(), put_dword(), put_word(), save_all_changes(), sltg_write_header(), sltg_write_helpstrings(), sltg_write_nametable(), sltg_write_remainder(), and sltg_write_typeinfo().

◆ put_dword()

void put_dword ( unsigned int  val)

Definition at line 395 of file utils.c.

396 {
397  if (byte_swapped)
398  val = ((val << 24) | ((val << 8) & 0x00ff0000) | ((val >> 8) & 0x0000ff00) | (val >> 24));
399  put_data( &val, sizeof(val) );
400 }
GLuint GLfloat * val
Definition: glext.h:7180
int byte_swapped
Definition: utils.c:251
void put_data(const void *data, size_t size)
Definition: utils.c:376

Referenced by add_output_to_resources(), flush_output_resources(), put_pword(), and put_qword().

◆ put_pword()

void put_pword ( unsigned int  val)

Definition at line 417 of file utils.c.

418 {
419  if (pointer_size == 8) put_qword( val );
420  else put_dword( val );
421 }
void put_qword(unsigned int val)
Definition: utils.c:402
void put_dword(unsigned int val)
Definition: utils.c:395
GLuint GLfloat * val
Definition: glext.h:7180
unsigned int pointer_size
Definition: widl.c:158

◆ put_qword()

void put_qword ( unsigned int  val)

Definition at line 402 of file utils.c.

403 {
404  if (byte_swapped)
405  {
406  put_dword( 0 );
407  put_dword( val );
408  }
409  else
410  {
411  put_dword( val );
412  put_dword( 0 );
413  }
414 }
void put_dword(unsigned int val)
Definition: utils.c:395
GLuint GLfloat * val
Definition: glext.h:7180
int byte_swapped
Definition: utils.c:251

Referenced by put_pword().

◆ put_str()

void put_str ( int  indent,
const char format,
  ... 
)

◆ put_word()

void put_word ( unsigned short  val)

Definition at line 389 of file utils.c.

390 {
391  if (byte_swapped) val = (val << 8) | (val >> 8);
392  put_data( &val, sizeof(val) );
393 }
GLuint GLfloat * val
Definition: glext.h:7180
int byte_swapped
Definition: utils.c:251
void put_data(const void *data, size_t size)
Definition: utils.c:376

Referenced by add_output_to_resources(), flush_output_resources(), and put_resource_id().

◆ strendswith()

int strendswith ( const char str,
const char end 
)

Definition at line 238 of file utils.c.

239 {
240  int l = strlen(str);
241  int m = strlen(end);
242  return l >= m && strcmp(str + l - m, end) == 0;
243 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint end
Definition: gl.h:1545
const GLfloat * m
Definition: glext.h:10848
const WCHAR * str
r l[0]
Definition: byte_order.h:167
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by main(), save_all_changes(), write_regscript(), and write_typelib_regscript().

◆ warning()

void warning ( const char s,
  ... 
)

◆ warning_loc_info()

void void warning_loc_info ( const loc_info_t ,
const char s,
  ... 
)

◆ widl_getline()

size_t widl_getline ( char **  linep,
size_t lenp,
FILE fp 
)

Definition at line 172 of file utils.c.

173 {
174  char *line = *linep;
175  size_t len = *lenp;
176  size_t n = 0;
177 
178  if (!line)
179  {
180  len = 64;
181  line = xmalloc(len);
182  }
183 
184  while (fgets(&line[n], len - n, fp))
185  {
186  n += strlen(&line[n]);
187  if (line[n - 1] == '\n')
188  break;
189  else if (n == len - 1)
190  {
191  len *= 2;
192  line = xrealloc(line, len);
193  }
194  }
195 
196  *linep = line;
197  *lenp = len;
198  return n;
199 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
void * xrealloc(void *p, size_t size)
Definition: utils.c:216
GLdouble n
Definition: glext.h:7729
Definition: parser.c:48
void * xmalloc(size_t size)
Definition: utils.c:201
char line[200]
Definition: main.c:97
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)

Referenced by write_dlldata().

◆ xmalloc()

void* xmalloc ( size_t  )

Definition at line 27 of file util.c.

28 {
29  void *p = malloc (len);
30 
31  if (!p) report (R_FATAL, "Out of memory.");
32  return p;
33 }
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
GLenum GLsizei len
Definition: glext.h:6722
#define malloc
Definition: debug_ros.c:4
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by dup_basename(), init_output_buffer(), widl_getline(), xstrdup(), and xstrsave().

◆ xrealloc()

void* xrealloc ( void ,
size_t   
)

Definition at line 736 of file uimain.c.

737 {
738  if (size < 1)
739  {
740  size = 1;
741  }
742  return realloc(in, size);
743 }
#define realloc
Definition: debug_ros.c:6
GLsizeiptr size
Definition: glext.h:5919
GLuint in
Definition: glext.h:9616

Referenced by check_output_buffer_space(), and widl_getline().

◆ xstrdup()

char* xstrdup ( const char str)

Definition at line 768 of file uimain.c.

769 {
770  int len;
771  char * p;
772 
773  if (s == 0)
774  {
775  return 0;
776  }
777  len = strlen(s);
778  p = (char *) xmalloc(len + 1);
779  strcpy(p, s);
780  return p;
781 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
void * xmalloc(int size)
Definition: uimain.c:747
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by generic_msg(), and main().

Variable Documentation

◆ byte_swapped

int byte_swapped

Definition at line 251 of file utils.c.

Referenced by put_dword(), put_qword(), put_word(), and save_all_changes().

◆ output_buffer

unsigned char* output_buffer

Definition at line 252 of file utils.c.

Referenced by add_output_to_resources().

◆ output_buffer_pos

◆ output_buffer_size

size_t output_buffer_size

Definition at line 254 of file utils.c.

Referenced by check_output_buffer_space(), init_output_buffer(), and put_str().