protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

error.h (720B)


      1 
      2 #ifndef PROTOVERSE_ERROR_H
      3 #define PROTOVERSE_ERROR_H
      4 
      5 #include "cursor.h"
      6 
      7 struct error {
      8 	int pos;
      9 	const char *msg;
     10 };
     11 
     12 struct errors {
     13 	struct cursor cur;
     14 	int enabled;
     15 };
     16 
     17 #define note_error(errs, p, fmt, ...) note_error_(errs, p, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
     18 
     19 static inline int cursor_push_error(struct cursor *cur, struct error *err)
     20 {
     21 	return cursor_push_int(cur, err->pos) &&
     22 	       cursor_push_c_str(cur, err->msg);
     23 }
     24 
     25 static inline int cursor_pull_error(struct cursor *cur, struct error *err)
     26 {
     27 	return cursor_pull_int(cur, &err->pos) &&
     28 	       cursor_pull_c_str(cur, &err->msg);
     29 }
     30 
     31 int note_error_(struct errors *errs, struct cursor *p, const char *fmt, ...);
     32 
     33 #endif /* PROTOVERSE_ERROR_H */