grub_lua.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * BURG - Brand-new Universal loadeR from GRUB
  3. * Copyright 2009 Bean Lee - All Rights Reserved
  4. *
  5. * BURG is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * BURG is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with BURG. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef GRUB_LUA_HEADER
  19. #define GRUB_LUA_HEADER 1
  20. #include <grub/types.h>
  21. #include <grub/mm.h>
  22. #include <grub/err.h>
  23. #include <grub/misc.h>
  24. #include <grub/setjmp.h>
  25. #define INT_MAX 2147483647
  26. #define UCHAR_MAX 255
  27. #define SHRT_MAX 32767
  28. #undef UNUSED
  29. #define UNUSED (void)
  30. #define memcpy grub_memcpy
  31. #define memcmp grub_memcmp
  32. #define strcpy grub_strcpy
  33. #define strstr grub_strstr
  34. #define strchr grub_strchr
  35. #define strlen grub_strlen
  36. #define strtoul grub_strtoul
  37. #define strtod(s,e) grub_strtoul(s,e,0)
  38. #define snprintf grub_snprintf
  39. #define strncpy grub_strncpy
  40. #define strcat grub_strcat
  41. #define strncat grub_strncat
  42. #define strcoll grub_strcmp
  43. #define strcmp grub_strcmp
  44. #define tolower grub_tolower
  45. #define toupper grub_toupper
  46. #define malloc grub_malloc
  47. #define realloc grub_realloc
  48. #define free grub_free
  49. #define exit(a) grub_exit()
  50. #define jmp_buf grub_jmp_buf
  51. #define setjmp grub_setjmp
  52. #define longjmp grub_longjmp
  53. #define fputs(s,f) grub_printf("%s", s)
  54. #define isdigit grub_isdigit
  55. #define isalpha grub_isalpha
  56. #define isspace grub_isspace
  57. static inline int
  58. isalnum (int c)
  59. {
  60. return (isalpha (c) || isdigit (c));
  61. }
  62. static inline int
  63. iscntrl (int c)
  64. {
  65. return ((c <= 0x1f) || (c == 0x7f));
  66. }
  67. static inline int
  68. isupper (int c)
  69. {
  70. return ((c >= 'A') && (c <= 'Z'));
  71. }
  72. static inline int
  73. islower (int c)
  74. {
  75. return ((c >= 'a') && (c <= 'z'));
  76. }
  77. static inline int
  78. ispunct (int c)
  79. {
  80. return ((! isspace (c)) && (! isalnum (c)));
  81. }
  82. static inline int
  83. isxdigit (int c)
  84. {
  85. return (isdigit (c) || ((c >= 'a') && (c <= 'f')) ||
  86. ((c >= 'A') && (c <= 'F')));
  87. }
  88. static inline int
  89. abs (int c)
  90. {
  91. return (c >= 0) ? : -c;
  92. }
  93. int strcspn (const char *s1, const char *s2);
  94. char *strpbrk (const char *s1, const char *s2);
  95. void *memchr (const void *s, int c, size_t n);
  96. #endif