ReactOS  0.4.15-dev-2956-g61e7ea5
strlist.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS WHERE command
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Providing string list
5  * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  */
7 
8 #pragma once
9 
10 #define str_clone _wcsdup
11 
12 typedef struct strlist_t
13 {
15  unsigned int count;
16 } strlist_t;
17 #define strlist_default { NULL, 0 }
18 
19 static inline void strlist_init(strlist_t *plist)
20 {
21  plist->ppsz = NULL;
22  plist->count = 0;
23 }
24 
25 static inline LPWSTR strlist_get_at(strlist_t *plist, unsigned int i)
26 {
27  return plist->ppsz[i];
28 }
29 
31 {
32  LPWSTR *ppsz, clone = str_clone(psz);
33  if (!clone)
34  return 0;
35  ppsz = (LPWSTR *)realloc(plist->ppsz, (plist->count + 1) * sizeof(LPWSTR));
36  if (!ppsz)
37  {
38  free(clone);
39  return 0;
40  }
41  plist->ppsz = ppsz;
42  plist->ppsz[plist->count] = clone;
43  ++(plist->count);
44  return 1;
45 }
46 
48 {
49  unsigned int i;
50  for (i = 0; i < plist->count; ++i)
51  free(plist->ppsz[i]);
52  plist->count = 0;
53  free(plist->ppsz);
54  plist->ppsz = NULL;
55 }
56 
57 static inline int strlist_find_i(strlist_t *plist, LPCWSTR psz)
58 {
59  unsigned int i;
60  for (i = 0; i < plist->count; ++i)
61  {
62  if (_wcsicmp(plist->ppsz[i], psz) == 0)
63  return i;
64  }
65  return -1;
66 }
#define realloc
Definition: debug_ros.c:6
static Parse plist[]
Definition: dwarfinfo.c:340
static int strlist_add(strlist_t *plist, LPCWSTR psz)
Definition: strlist.h:30
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
LPWSTR * ppsz
Definition: strlist.h:14
#define free
Definition: debug_ros.c:5
static int strlist_find_i(strlist_t *plist, LPCWSTR psz)
Definition: strlist.h:57
#define str_clone
Definition: strlist.h:10
static void strlist_destroy(strlist_t *plist)
Definition: strlist.h:47
unsigned int count
Definition: strlist.h:15
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
static void strlist_init(strlist_t *plist)
Definition: strlist.h:19
#define NULL
Definition: types.h:112
struct strlist_t strlist_t
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static LPWSTR strlist_get_at(strlist_t *plist, unsigned int i)
Definition: strlist.h:25
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)