Add-in development tools for fx-9860G and fx-CG 50, to use with GCC and gint.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5KB

  1. //---
  2. // util: Utility functions
  3. //---
  4. #ifndef FXOS_UTIL
  5. #define FXOS_UTIL
  6. /* integer(): Convert base 8, 10 or 16 into integers
  7. Prints an error message and sets *error to 1 in case of conversion error or
  8. overflow.
  9. @str Original integer representation ("10", "0x1f", "07")
  10. @error Set to 1 on error, otherwise unchanged (can be NULL)
  11. Returns result of conversion (valid if *error is not 1) */
  12. long long integer(const char *str, int *error);
  13. /* match_table_name(): Some specific matching on filenames
  14. Returns the table name to associate with the file located at @path for a
  15. table of type @type, with file suffix @suffix.
  16. Essentially if the basename of the file at @path is on the form
  17. {@type}-{x}{@suffix}
  18. then an malloc'ed copy of x is returned. Otherwise an malloc'ed copy of the
  19. basename is returned. */
  20. char *match_table_name(char const *path, char const *type, char const *suffix);
  21. /* map(): Map a file to memory
  22. Maps a file given by its path to memory, and return the associated region,
  23. a file descriptor and the size.
  24. @path File path
  25. @fd Will be set to fd of open file
  26. @size Will be set to file size
  27. Returns NULL no error, in which case the file is closed and [*fd] and
  28. [*size] are undefined; otherwise, returns a pointer to mapped data. */
  29. void *map(char const *path, int *fd, size_t *size);
  30. /* unmap(): Unmap a file loaded with map()
  31. @data Region returned by map()
  32. @fd File descriptor set by map()
  33. @size Size set by map() */
  34. void unmap(void *data, int fd, size_t size);
  35. #endif /* FXOS_UTIL */