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.

51 rivejä
1.6 KiB

11 vuotta sitten
11 vuotta sitten
11 vuotta sitten
  1. // This file is part of Jiffy released under the MIT license.
  2. // See the LICENSE file for more information.
  3. #ifndef JIFFY_H
  4. #define JIFFY_H
  5. #include "erl_nif.h"
  6. #define MAP_SUPPORT ((ERL_NIF_MAJOR_VERSION == 2 && ERL_NIF_MINOR_VERSION >= 6) || (ERL_NIF_MAJOR_VERSION > 2))
  7. typedef struct {
  8. ERL_NIF_TERM atom_ok;
  9. ERL_NIF_TERM atom_error;
  10. ERL_NIF_TERM atom_null;
  11. ERL_NIF_TERM atom_true;
  12. ERL_NIF_TERM atom_false;
  13. ERL_NIF_TERM atom_bignum;
  14. ERL_NIF_TERM atom_bignum_e;
  15. ERL_NIF_TERM atom_bigdbl;
  16. ERL_NIF_TERM atom_partial;
  17. ERL_NIF_TERM atom_uescape;
  18. ERL_NIF_TERM atom_pretty;
  19. ERL_NIF_TERM atom_force_utf8;
  20. #ifdef MAP_SUPPORT
  21. ERL_NIF_TERM atom_map;
  22. #endif
  23. ERL_NIF_TERM ref_object;
  24. ERL_NIF_TERM ref_array;
  25. } jiffy_st;
  26. ERL_NIF_TERM make_atom(ErlNifEnv* env, const char* name);
  27. ERL_NIF_TERM make_ok(jiffy_st* st, ErlNifEnv* env, ERL_NIF_TERM data);
  28. ERL_NIF_TERM make_error(jiffy_st* st, ErlNifEnv* env, const char* error);
  29. ERL_NIF_TERM decode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
  30. ERL_NIF_TERM encode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
  31. int int_from_hex(const unsigned char* p);
  32. int int_to_hex(int val, char* p);
  33. int utf8_len(int c);
  34. int utf8_esc_len(int c);
  35. int utf8_validate(unsigned char* data, size_t size);
  36. int utf8_to_unicode(unsigned char* buf, size_t size);
  37. int unicode_to_utf8(int c, unsigned char* buf);
  38. int unicode_from_pair(int hi, int lo);
  39. int unicode_uescape(int c, char* buf);
  40. int double_to_shortest(char *buf, size_t size, size_t* len, double val);
  41. #endif // Included JIFFY_H