#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
Go to the source code of this file.
◆ trace
Definition at line 20 of file hpp.c.
◆ DEFINE
◆ PDEFINE
◆ convert_path()
Definition at line 39 of file hpp.c.
44 newpath =
strdup(origpath);
47 while (newpath[
i] != 0)
50 if (newpath[
i] ==
'\\')
56 if (newpath[
i] ==
'/')
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
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
Referenced by main().
◆ error()
Definition at line 117 of file hpp.c.
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
static __ms_va_list valist
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
Referenced by EvaluateExpression(), main(), ParseInputFile(), and WriteLine().
◆ EvaluateConstant()
◆ EvaluateExpression()
int EvaluateExpression |
( |
char * |
pExpression, |
|
|
char ** |
pNext |
|
) |
| |
Definition at line 253 of file hpp.c.
256 int inv, thisval,
val = 0;
258 trace(
"evaluating expression\n");
263 error(
"Parse error: expected '(' \n");
271 if ((
p[0] ==
'&' &&
p[1] ==
'&') ||
272 (
p[0] ==
'|' &&
p[1] ==
'|'))
296 trace(
"found a num: %d\n", thisval);
304 error(
"..Parse error, expected '(' or constant in line %d\n",
313 if (pstart[0] ==
'(')
317 else if (pstart[0] ==
'&' && pstart[1] ==
'&')
321 else if (pstart[0] ==
'&' && pstart[1] !=
'&')
325 else if (pstart[0] ==
'|' && pstart[1] ==
'|')
327 trace(
"found || val = %d, thisval = %d\n",
val, thisval);
330 else if (pstart[0] ==
'|' && pstart[1] !=
'|')
334 else if (pstart[0] ==
'+')
340 error(
"+Parse error: expected '(' or operator in Line %d, got %c\n",
int error(char *format,...)
_Check_return_ double __cdecl strtod(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr)
int EvaluateExpression(char *pExpression, char **pNext)
int EvaluateConstant(const char *p, char **pNext)
char * GetNextChar(const char *psz)
Referenced by ParseInputFile().
◆ FindDefine()
Definition at line 167 of file hpp.c.
188 pDefine = pDefine->
pNext;
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
int strxlen(const char *psz)
Referenced by EvaluateConstant(), and WriteLine().
◆ GetFolder()
Definition at line 68 of file hpp.c.
◆ GetNextChar()
◆ GetNextLine()
Definition at line 135 of file hpp.c.
138 while (*pszLine != 13 && *pszLine != 10 && *pszLine != 0) pszLine++;
141 if (pszLine[0] == 13 && pszLine[1] == 10)
143 else if (pszLine[0] == 13 || pszLine[0] == 10)
Referenced by ParseInputFile().
◆ LoadFile()
Definition at line 74 of file hpp.c.
77 void* pFileData =
NULL;
80 trace(
"Loading file...");
85 trace(
"Could not open file\n");
92 *pFileSize = iFileSize;
93 trace(
"ok. Size is %d\n", iFileSize);
95 pFileData =
malloc(iFileSize + 1);
97 if (pFileData !=
NULL)
99 if (iFileSize !=
fread(pFileData, 1, iFileSize,
file))
107 trace(
"Could not allocate memory for file\n");
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
WORD WORD PSZ PSZ pszFileName
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
Referenced by ParseInputFile().
◆ main()
hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com
Definition at line 602 of file hpp.c.
604 char *pszInFile, *pszOutFile;
610 error(
"Usage: hpp <inputfile> <outputfile>\n");
617 fileOut =
fopen(pszOutFile,
"wb");
620 error(
"Cannot open output file %s", pszOutFile);
int error(char *format,...)
int ParseInputFile(const char *pszInFile, FILE *fileOut)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
char * convert_path(const char *origpath)
◆ ParseInputFile()
Definition at line 365 of file hpp.c.
367 char* pInputData, *pCurrentLine, *p1, *p2;
368 size_t cbInFileLenth;
369 int iIfLevel, iCopyLevel;
371 trace(
"parsing input file: %s\n", pszInFile);
377 pInputData =
LoadFile(pszInFile, &cbInFileLenth);
380 error(
"Could not load input file %s\n", pszInFile);
385 pInputData[cbInFileLenth] = 0;
387 pCurrentLine = pInputData;
389 iCopyLevel = iIfLevel = 0;
397 if (pCurrentLine[0] !=
'$')
400 if (iCopyLevel == iIfLevel)
413 if (
strncmp(pCurrentLine,
"$endif", 6) == 0)
415 trace(
"found $endif\n");
418 error(
"Parse error: $endif without $if in %s:%d\n", pszInFile,
iLine);
421 if (iCopyLevel == iIfLevel)
432 if (iCopyLevel < iIfLevel)
441 if (
strncmp(pCurrentLine,
"$define", 7) == 0)
444 char *pchName, *pchValue;
447 trace(
"found $define\n");
451 error(
"Parse error: expected '(' at %s:%d\n",
463 trace(
"found $define with assignment\n");
478 error(
"Failed to allocate %u bytes\n",
509 error(
"Parse error: expected ')' at %s:%d\n",
516 else if (
strncmp(pCurrentLine,
"$if", 3) == 0)
520 trace(
"found $if\n");
532 iCopyLevel = iIfLevel;
542 else if (
strncmp(pCurrentLine,
"$include", 8) == 0)
546 trace(
"found $include\n");
550 error(
"Parse error: expected '(' at %s:%d, found '%c'\n",
551 pszInFile,
iLine, *p1);
574 else if (
strncmp(pCurrentLine,
"$$", 2) == 0)
576 trace(
"$$ ignored\n");
583 trace(
"wot:%s\n", pCurrentLine);
595 trace(
"Done with file.\n\n");
int error(char *format,...)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
char * GetNextLine(char *pszLine)
void WriteLine(char *pchLine, FILE *fileOut)
int EvaluateExpression(char *pExpression, char **pNext)
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
void * LoadFile(const char *pszFileName, size_t *pFileSize)
int ParseInputFile(const char *pszInFile, FILE *fileOut)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strchr(const char *String, int ch)
char * GetNextChar(const char *psz)
int strxlen(const char *psz)
Referenced by main().
◆ strxlen()
◆ WriteLine()
Definition at line 194 of file hpp.c.
196 char *
pch, *pchLineEnd, *pchVariable;
200 pchLineEnd =
strchr(pchLine,
'\n');
204 len = pchLineEnd - pchLine + 1;
211 if (pchVariable && (pchVariable < pchLineEnd))
226 error(
"Could not find variable '%.*s'\n",
len, pchVariable);
227 fwrite(pchVariable, 1,
pch - pchVariable, fileOut);
230 len = pchLineEnd -
pch + 1;
int error(char *format,...)
PDEFINE FindDefine(const char *p, char **pNext)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
char * strchr(const char *String, int ch)
int strxlen(const char *psz)
Referenced by CDFParser::Parse(), and ParseInputFile().
◆ gpDefines
◆ gpszCurFile
◆ iLine