api.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 OSCAR lab, Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #ifndef API_H
  16. #define API_H
  17. #include <stddef.h>
  18. #include <stdint.h>
  19. #include <stdarg.h>
  20. int strnlen (const char *str, int maxlen);
  21. int strlen (const char *str);
  22. long strtol (const char *s, char **endptr, int base);
  23. int atoi (const char *nptr);
  24. long int atol (const char *nptr);
  25. char * strchr (const char *s, int c_in);
  26. void * memcpy (void *dstpp, const void *srcpp, int len);
  27. void * memmove (void *dstpp, void *srcpp, int len);
  28. void * memset (void *dstpp, int c, int len);
  29. int memcmp (const void *s1, const void *s2, int len);
  30. void fprintfmt (void (*_fputch)(void *, int, void *), void * f, void * putdat,
  31. const char * fmt, ...);
  32. void vfprintfmt (void (*_fputch)(void *, int, void *), void * f, void * putdat,
  33. const char * fmt, va_list *ap);
  34. int snprintf (char * buf, int n, const char * fmt, ...);
  35. int inet_pton4 (const char *src, int len, void *dst);
  36. int inet_pton6 (const char *src, int len, void *dst);
  37. uint32_t __htonl (uint32_t x);
  38. uint32_t __ntohl (uint32_t x);
  39. uint16_t __htons (uint16_t x);
  40. uint16_t __ntohs (uint16_t x);
  41. extern const char * const * sys_errlist_internal;
  42. #define __alloca __builtin_alloca
  43. #define XSTRINGIFY(x) STRINGIFY(x)
  44. #define STRINGIFY(x) #x
  45. #include <linux_list.h>
  46. struct config_store {
  47. struct list_head root, entries;
  48. void * raw_data;
  49. int raw_size;
  50. void * (*malloc) (int);
  51. void (*free) (void *);
  52. };
  53. int read_config (struct config_store * store, int (*filter) (const char *, int),
  54. const char ** errstring);
  55. int free_config (struct config_store * store);
  56. int copy_config (struct config_store * store, struct config_store * new_store);
  57. int write_config (void * file, int (*write) (void *, void *, int),
  58. struct config_store * store);
  59. int get_config (struct config_store * cfg, const char * key,
  60. char * val_buf, int size);
  61. int get_config_entries (struct config_store * cfg, const char * key,
  62. char * key_buf, int size);
  63. int set_config (struct config_store * cfg, const char * key, const char * val);
  64. #define CONFIG_MAX 256
  65. #endif /* API_H */