ReactOS 0.4.16-dev-340-g0540c21
util.c File Reference
#include <unistd.h>
#include <errno.h>
#include "winetest.h"
Include dependency graph for util.c:

Go to the source code of this file.

Functions

voidxmalloc (size_t len)
 
voidxrealloc (void *op, size_t len)
 
charxstrdup (const char *str)
 
static charvstrfmtmake (size_t *lenp, const char *fmt, va_list ap)
 
charvstrmake (size_t *lenp, va_list ap)
 
charstrmake (size_t *lenp,...)
 
void xprintf (const char *fmt,...)
 
int goodtagchar (char c)
 
const charfindbadtagchar (const char *tag)
 

Function Documentation

◆ findbadtagchar()

const char * findbadtagchar ( const char tag)

Definition at line 124 of file util.c.

125{
126 while (*tag)
127 if (goodtagchar (*tag)) tag++;
128 else return tag;
129 return NULL;
130}
#define NULL
Definition: types.h:112
int goodtagchar(char c)
Definition: util.c:115
Definition: ecma_167.h:138

Referenced by WinMain().

◆ goodtagchar()

int goodtagchar ( char  c)

Definition at line 115 of file util.c.

116{
117 return (('a'<=c && c<='z') ||
118 ('A'<=c && c<='Z') ||
119 ('0'<=c && c<='9') ||
120 c=='-' || c=='.');
121}
const GLubyte * c
Definition: glext.h:8905

Referenced by EditTagProc(), and findbadtagchar().

◆ strmake()

char * strmake ( size_t lenp,
  ... 
)

Definition at line 82 of file util.c.

83{
84 va_list ap;
85 char *p;
86
87 va_start (ap, lenp);
88 p = vstrmake (lenp, ap);
89 if (!p) report (R_FATAL, "Out of memory.");
90 va_end (ap);
91 return p;
92}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
Definition: protectdata.c:769
GLfloat GLfloat p
Definition: glext.h:8902
char * vstrmake(size_t *lenp, va_list ap)
Definition: util.c:74
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
@ R_FATAL
Definition: winetest.h:56

Referenced by extract_test(), get_subtests(), run_test(), and send_file().

◆ vstrfmtmake()

static char * vstrfmtmake ( size_t lenp,
const char fmt,
va_list  ap 
)
static

Definition at line 50 of file util.c.

51{
52 size_t size = 1000;
53 char *p, *q;
54 int n;
55
56 p = malloc (size);
57 if (!p) return NULL;
58 while (1) {
59 n = vsnprintf (p, size, fmt, ap);
60 if (n < 0) size *= 2; /* Windows */
61 else if ((unsigned)n >= size) size = n+1; /* glibc */
62 else break;
63 q = realloc (p, size);
64 if (!q) {
65 free (p);
66 return NULL;
67 }
68 p = q;
69 }
70 if (lenp) *lenp = n;
71 return p;
72}
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
Definition: dsound.c:943
#define vsnprintf
Definition: tif_win32.c:406

Referenced by vstrmake(), and xprintf().

◆ vstrmake()

char * vstrmake ( size_t lenp,
va_list  ap 
)

Definition at line 74 of file util.c.

75{
76 const char *fmt;
77
78 fmt = va_arg (ap, const char*);
79 return vstrfmtmake (lenp, fmt, ap);
80}
#define va_arg(ap, T)
Definition: acmsvcex.h:89
static char * vstrfmtmake(size_t *lenp, const char *fmt, va_list ap)
Definition: util.c:50

Referenced by guiAsk(), guiDelta(), guiDir(), guiError(), guiOut(), guiStatus(), guiStep(), guiWarning(), send_str(), strmake(), textAsk(), textDelta(), textDir(), textOut(), textStatus(), and textStep().

◆ xmalloc()

void * xmalloc ( size_t  len)

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}
GLenum GLsizei len
Definition: glext.h:6722

◆ xprintf()

void xprintf ( const char fmt,
  ... 
)

Definition at line 94 of file util.c.

95{
96 va_list ap;
97 size_t size;
98 ssize_t written;
99 char *buffer, *head;
100
101 va_start (ap, fmt);
103 head = buffer;
104 va_end (ap);
105 while ((written = write (1, head, size)) != size) {
106 if (written == -1)
107 report (R_FATAL, "Can't write logs: %d", errno);
108 head += written;
109 size -= written;
110 }
111 free (buffer);
112}
#define write
Definition: acwin.h:97
struct outqueuenode * head
Definition: adnsresfilter.c:66
GLuint buffer
Definition: glext.h:5915
int ssize_t
Definition: rosdhcp.h:48
#define errno
Definition: errno.h:18

◆ xrealloc()

void * xrealloc ( void op,
size_t  len 
)

Definition at line 35 of file util.c.

36{
37 void *p = realloc (op, len);
38
39 if (len && !p) report (R_FATAL, "Out of memory.");
40 return p;
41}
UINT op
Definition: effect.c:236

◆ xstrdup()

char * xstrdup ( const char str)

Definition at line 43 of file util.c.

44{
45 char *res = strdup( str );
46 if (!res) report (R_FATAL, "Out of memory.");
47 return res;
48}
GLuint res
Definition: glext.h:9613
const WCHAR * str
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)