1
0

ipc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*++
  2. Copyright (c) 2017 Minoca Corp.
  3. This file is licensed under the terms of the GNU Lesser General Public
  4. License version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details.
  6. Module Name:
  7. ipc.h
  8. Abstract:
  9. This header contains definitions for Inter-Process Communications in the
  10. C library.
  11. Author:
  12. Evan Green 24-Mar-2017
  13. --*/
  14. #ifndef _SYS_IPC_H
  15. #define _SYS_IPC_H
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include <libcbase.h>
  20. //
  21. // --------------------------------------------------------------------- Macros
  22. //
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. //
  27. // ---------------------------------------------------------------- Definitions
  28. //
  29. //
  30. // Define flags for msgget, shmget, and shmget.
  31. //
  32. //
  33. // Set this flag to create the object if it does not already exist.
  34. //
  35. #define IPC_CREAT 0x1000
  36. //
  37. // Set this flag in conjunction with IPC_CREAT to create the object and fail if
  38. // it already exists.
  39. //
  40. #define IPC_EXCL 0x2000
  41. //
  42. // Define control commands for msgctl, semctl, and shmctl.
  43. //
  44. //
  45. // Mark the object for deletion once all open references on it are closed.
  46. //
  47. #define IPC_RMID 1
  48. //
  49. // Set permission and ownership information on the object.
  50. //
  51. #define IPC_SET 2
  52. //
  53. // Get information about the object.
  54. //
  55. #define IPC_STAT 3
  56. //
  57. // Define the key value for a mapping that's always created.
  58. //
  59. #define IPC_PRIVATE ((key_t)0)
  60. //
  61. // ------------------------------------------------------ Data Type Definitions
  62. //
  63. /*++
  64. Structure Description:
  65. This structure defines the permission information for an IPC shared object.
  66. Members:
  67. uid - Stores the owner's user ID.
  68. gid - Stores the owner's group ID.
  69. cuid - Stores the creator's user ID.
  70. cgid - Stores the creator's group ID.
  71. mode - Stores the permission bits.
  72. --*/
  73. struct ipc_perm {
  74. uid_t uid;
  75. gid_t gid;
  76. uid_t cuid;
  77. gid_t cgid;
  78. unsigned int mode;
  79. };
  80. //
  81. // -------------------------------------------------------------------- Globals
  82. //
  83. //
  84. // -------------------------------------------------------- Function Prototypes
  85. //
  86. LIBC_API
  87. key_t
  88. ftok (
  89. const char *Path,
  90. int ProjectId
  91. );
  92. /*++
  93. Routine Description:
  94. This routine uses the identify of the given file and the least significant
  95. 8 bits of the given project identifier to create a key suitable for use in
  96. the shmget, semget, or msgget functions.
  97. Arguments:
  98. Path - Supplies a pointer to the path to the file whose identity should be
  99. involved in the key ID.
  100. ProjectId - Supplies an identifier whose least significant 8 bits will be
  101. worked into the result.
  102. Return Value:
  103. Returns a key value suitable for use as a parameter to shmget, semget, or
  104. msgget.
  105. -1 on error, and errno will be set to the stat error information for the
  106. given file path.
  107. --*/
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif