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.

50 lines
1.6 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 atom_force_utf8;
  19. ERL_NIF_TERM ref_object;
  20. ERL_NIF_TERM ref_array;
  21. ErlNifResourceType* res_dec;
  22. } jiffy_st;
  23. ERL_NIF_TERM make_atom(ErlNifEnv* env, const char* name);
  24. ERL_NIF_TERM make_ok(jiffy_st* st, ErlNifEnv* env, ERL_NIF_TERM data);
  25. ERL_NIF_TERM make_error(jiffy_st* st, ErlNifEnv* env, const char* error);
  26. ERL_NIF_TERM decode_init(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
  27. ERL_NIF_TERM decode_iter(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
  28. ERL_NIF_TERM encode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]);
  29. void dec_destroy(ErlNifEnv* env, void* obj);
  30. int int_from_hex(const unsigned char* p);
  31. int int_to_hex(int val, char* p);
  32. int utf8_len(int c);
  33. int utf8_esc_len(int c);
  34. int utf8_validate(unsigned char* data, size_t size);
  35. int utf8_to_unicode(unsigned char* buf, size_t size);
  36. int unicode_to_utf8(int c, unsigned char* buf);
  37. int unicode_from_pair(int hi, int lo);
  38. int unicode_uescape(int c, char* buf);
  39. int double_to_shortest(char *buf, size_t size, size_t* len, double val);
  40. #endif // Included JIFFY_H