api.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. int get_norm_path (const char * path, char * buf, int offset, int size);
  46. #include <linux_list.h>
  47. struct config_store {
  48. struct list_head root, entries;
  49. void * raw_data;
  50. int raw_size;
  51. void * (*malloc) (int);
  52. void (*free) (void *);
  53. };
  54. int read_config (struct config_store * store, int (*filter) (const char *, int),
  55. const char ** errstring);
  56. int free_config (struct config_store * store);
  57. int copy_config (struct config_store * store, struct config_store * new_store);
  58. int write_config (void * file, int (*write) (void *, void *, int),
  59. struct config_store * store);
  60. int get_config (struct config_store * cfg, const char * key,
  61. char * val_buf, int size);
  62. int get_config_entries (struct config_store * cfg, const char * key,
  63. char * key_buf, int size);
  64. int set_config (struct config_store * cfg, const char * key, const char * val);
  65. #define CONFIG_MAX 256
  66. #endif /* API_H */