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.

43 lines
1.3 KiB

  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. typedef struct {
  7. ERL_NIF_TERM atom_ok;
  8. ERL_NIF_TERM atom_error;
  9. ERL_NIF_TERM atom_null;
  10. ERL_NIF_TERM atom_true;
  11. ERL_NIF_TERM atom_false;
  12. ERL_NIF_TERM atom_bignum;
  13. ERL_NIF_TERM atom_bignum_e;
  14. ERL_NIF_TERM atom_bigdbl;
  15. ERL_NIF_TERM atom_partial;
  16. ERL_NIF_TERM atom_uescape;
  17. ERL_NIF_TERM atom_pretty;
  18. ERL_NIF_TERM ref_object;
  19. ERL_NIF_TERM ref_array;
  20. } jiffy_st;
  21. ERL_NIF_TERM make_atom(ErlNifEnv* env, const char* name);
  22. ERL_NIF_TERM make_ok(jiffy_st* st, ErlNifEnv* env, ERL_NIF_TERM data);
  23. ERL_NIF_TERM make_error(jiffy_st* st, ErlNifEnv* env, const char* error);
  24. ERL_NIF_TERM decode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
  25. ERL_NIF_TERM encode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
  26. int int_from_hex(const unsigned char* p);
  27. int int_to_hex(int val, char* p);
  28. int utf8_len(int c);
  29. int utf8_esc_len(int c);
  30. int utf8_validate(unsigned char* data, size_t size);
  31. int utf8_to_unicode(unsigned char* buf, size_t size);
  32. int unicode_to_utf8(int c, unsigned char* buf);
  33. int unicode_from_pair(int hi, int lo);
  34. int unicode_uescape(int c, char* buf);
  35. #endif // Included JIFFY_H