auth.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef _AUTH_H_
  2. #define _AUTH_H_
  3. #include <stdint.h>
  4. #define PRIV_NONE 0x0000
  5. #define PRIV_BUILD 0x0001 /* build/interact */
  6. #define PRIV_TELEPORT 0x0002 /* teleport */
  7. #define PRIV_SETTIME 0x0004 /* set the time */
  8. #define PRIV_PRIVS 0x0008 /* grant/revoke privs */
  9. #define PRIV_SERVER 0x0010 /* server management (shutdown/settings/etc) */
  10. #define PRIV_SHOUT 0x0020 /* chat */
  11. #define PRIV_BAN 0x0040 /* ban/unban */
  12. /* increment this if a priv is added */
  13. #define PRIV_COUNT 7
  14. #define PRIV_DEFAULT (PRIV_BUILD|PRIV_SHOUT)
  15. #define PRIV_ALL 0x7FFFFFFFFFFFFFFF
  16. #define PRIV_INVALID 0x8000000000000000
  17. #ifndef _HAVE_AUTHDATA_TYPE
  18. #define _HAVE_AUTHDATA_TYPE
  19. typedef struct authdata_s {
  20. char pwd[64];
  21. uint64_t privs;
  22. } authdata_t;
  23. #endif
  24. /* defined in auth.c */
  25. int auth_privs2str(uint64_t privs, char* buff, int size);
  26. uint64_t auth_str2privs(char* str);
  27. int auth_init(char* file);
  28. void auth_exit(void);
  29. void auth_load(void);
  30. void auth_save(void);
  31. int auth_exists(char* name);
  32. void auth_set(char* name, authdata_t data);
  33. void auth_add(char* name);
  34. int auth_getpwd(char* name, char buff[64]);
  35. void auth_setpwd(char* name, char* pwd);
  36. uint64_t auth_getprivs(char* name);
  37. void auth_setprivs(char* name, uint64_t privs);
  38. #endif