api.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. size_t strnlen (const char *str, size_t maxlen);
  21. size_t 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, size_t len);
  27. void * memmove (void *dstpp, void *srcpp, size_t len);
  28. void * memset (void *dstpp, int c, size_t len);
  29. int memcmp (const void *s1, const void *s2, size_t 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 inet_pton(int af, const char *src, void *dst);
  35. uint32_t __htonl (uint32_t x);
  36. uint32_t __ntohl (uint32_t x);
  37. uint16_t __htons (uint16_t x);
  38. uint16_t __ntohs (uint16_t x);
  39. extern const char * const * sys_errlist_internal;
  40. #define __alloca __builtin_alloca
  41. #define XSTRINGIFY(x) STRINGIFY(x)
  42. #define STRINGIFY(x) #x
  43. #include <linux_list.h>
  44. struct config_store {
  45. struct list_head root, entries;
  46. void * raw_data;
  47. size_t raw_size;
  48. void * (*malloc) (int);
  49. void (*free) (void *);
  50. };
  51. int read_config (struct config_store * store,
  52. int (*filter) (const char * key, int ken),
  53. const char ** errstring);
  54. int free_config (struct config_store * store);
  55. int copy_config (struct config_store * store, struct config_store * new_store);
  56. int write_config (void * f, size_t (*write) (void *, void *, size_t),
  57. struct config_store * store);
  58. int get_config (struct config_store * cfg, const char * key,
  59. char * val_buf, size_t size);
  60. int get_config_entries (struct config_store * cfg, const char * key,
  61. char * key_buf, size_t size);
  62. int set_config (struct config_store * cfg, const char * key, const char * val);
  63. #define CONFIG_MAX 256
  64. #endif /* API_H */