file_utils.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef NETSNMP_FILE_UTILS_H
  2. #define NETSNMP_FILE_UTILS_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*------------------------------------------------------------------
  7. *
  8. * structures
  9. *
  10. */
  11. typedef struct netsnmp_file_s {
  12. /** file name */
  13. char *name;
  14. /** file descriptor for the file */
  15. int fd;
  16. /** filesystem flags */
  17. int fs_flags;
  18. /** open/create mode */
  19. mode_t mode;
  20. /** netsnmp flags */
  21. u_int ns_flags;
  22. /** file stats */
  23. struct stat *stats;
  24. /*
  25. * future expansion
  26. */
  27. netsnmp_data_list *extras;
  28. } netsnmp_file;
  29. /*------------------------------------------------------------------
  30. *
  31. * Prototypes
  32. *
  33. */
  34. netsnmp_file *netsnmp_file_new(const char *name, int fs_flags, mode_t mode,
  35. u_int ns_flags);
  36. netsnmp_file * netsnmp_file_create(void);
  37. netsnmp_file * netsnmp_file_fill(netsnmp_file * filei, const char* name,
  38. int fs_flags, mode_t mode, u_int ns_flags);
  39. int netsnmp_file_release(netsnmp_file * filei);
  40. int netsnmp_file_open(netsnmp_file * filei);
  41. int netsnmp_file_close(netsnmp_file * filei);
  42. /** support netsnmp_file containers */
  43. int netsnmp_file_compare_name(netsnmp_file *lhs, netsnmp_file *rhs);
  44. void netsnmp_file_container_free(netsnmp_file *file, void *context);
  45. /*------------------------------------------------------------------
  46. *
  47. * flags
  48. *
  49. */
  50. #define NETSNMP_FILE_NO_AUTOCLOSE 0x00000001
  51. #define NETSNMP_FILE_STATS 0x00000002
  52. #define NETSNMP_FILE_AUTO_OPEN 0x00000004
  53. /*------------------------------------------------------------------
  54. *
  55. * macros
  56. *
  57. */
  58. #define NS_FI_AUTOCLOSE(x) (0 == (x & NETSNMP_FILE_NO_AUTOCLOSE))
  59. #define NS_FI_(x) (0 == (x & NETSNMP_FILE_))
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* NETSNMP_FILE_UTILS_H */