diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-01 13:20:49 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-01 13:20:55 +0200 |
commit | 06f45b04aaa8a9832599035cafee142f09700b9b (patch) | |
tree | b928a166e1dec9b55c85562de57cd67e03f60906 /src/include | |
parent | 2032f3ce3ed0ed7a6c1c6fb9df6222d85758bf70 (diff) | |
download | gnunet-06f45b04aaa8a9832599035cafee142f09700b9b.tar.gz gnunet-06f45b04aaa8a9832599035cafee142f09700b9b.zip |
-move DB-agnostic types to GNUNET_DB
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_db_lib.h | 43 | ||||
-rw-r--r-- | src/include/gnunet_pq_lib.h | 67 |
2 files changed, 53 insertions, 57 deletions
diff --git a/src/include/gnunet_db_lib.h b/src/include/gnunet_db_lib.h index 85ad13e31..63c45112d 100644 --- a/src/include/gnunet_db_lib.h +++ b/src/include/gnunet_db_lib.h | |||
@@ -61,4 +61,47 @@ enum GNUNET_DB_QueryStatus | |||
61 | that returned more than one result. */ | 61 | that returned more than one result. */ |
62 | }; | 62 | }; |
63 | 63 | ||
64 | |||
65 | /** | ||
66 | * Handle for an active LISTENer to a database. | ||
67 | */ | ||
68 | struct GNUNET_DB_EventHandler; | ||
69 | |||
70 | /** | ||
71 | * Function called on events received from Postgres. | ||
72 | * | ||
73 | * @param cls closure | ||
74 | * @param extra additional event data provided | ||
75 | * @param extra_size number of bytes in @a extra | ||
76 | */ | ||
77 | typedef void | ||
78 | (*GNUNET_DB_EventCallback)(void *cls, | ||
79 | const void *extra, | ||
80 | size_t extra_size); | ||
81 | |||
82 | GNUNET_NETWORK_STRUCT_BEGIN | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Header of a structure that describes an | ||
87 | * event channel we may subscribe to or notify on. | ||
88 | */ | ||
89 | struct GNUNET_DB_EventHeaderP | ||
90 | { | ||
91 | /** | ||
92 | * The length of the struct (in bytes, including the length field itself), | ||
93 | * in big-endian format. | ||
94 | */ | ||
95 | uint16_t size GNUNET_PACKED; | ||
96 | |||
97 | /** | ||
98 | * The type of the message (GNUNET_DB_EVENT_TYPE_XXXX), in big-endian format. | ||
99 | */ | ||
100 | uint16_t type GNUNET_PACKED; | ||
101 | |||
102 | }; | ||
103 | |||
104 | GNUNET_NETWORK_STRUCT_END | ||
105 | |||
106 | |||
64 | #endif | 107 | #endif |
diff --git a/src/include/gnunet_pq_lib.h b/src/include/gnunet_pq_lib.h index 1f2915165..ecc2b9719 100644 --- a/src/include/gnunet_pq_lib.h +++ b/src/include/gnunet_pq_lib.h | |||
@@ -853,7 +853,7 @@ GNUNET_PQ_reconnect (struct GNUNET_PQ_Context *db); | |||
853 | 853 | ||
854 | 854 | ||
855 | /** | 855 | /** |
856 | * Function called whenever the socket needed for | 856 | * Function called whenever the socket needed for |
857 | * notifications from postgres changes. | 857 | * notifications from postgres changes. |
858 | * | 858 | * |
859 | * @param cls closure | 859 | * @param cls closure |
@@ -868,7 +868,7 @@ typedef void | |||
868 | * Obtain the file descriptor to poll on for notifications. | 868 | * Obtain the file descriptor to poll on for notifications. |
869 | * Useful if the GNUnet scheduler is NOT to be used for | 869 | * Useful if the GNUnet scheduler is NOT to be used for |
870 | * such notifications. | 870 | * such notifications. |
871 | * | 871 | * |
872 | * @param db database handle | 872 | * @param db database handle |
873 | * @param sc function to call with the socket | 873 | * @param sc function to call with the socket |
874 | * @param sc_cls closure for @a sc | 874 | * @param sc_cls closure for @a sc |
@@ -911,55 +911,8 @@ GNUNET_PQ_event_scheduler_stop (struct GNUNET_PQ_Context *db); | |||
911 | 911 | ||
912 | 912 | ||
913 | /** | 913 | /** |
914 | * Handle for an active LISTENer to the database. | ||
915 | */ | ||
916 | struct GNUNET_PQ_EventHandler; | ||
917 | |||
918 | /** | ||
919 | * Function called on events received from Postgres. | ||
920 | * | ||
921 | * @param cls closure | ||
922 | * @param extra additional event data provided | ||
923 | * @param extra_size number of bytes in @a extra | ||
924 | */ | ||
925 | typedef void | ||
926 | (*GNUNET_PQ_EventCallback)(void *cls, | ||
927 | const void *extra, | ||
928 | size_t extra_size); | ||
929 | |||
930 | GNUNET_NETWORK_STRUCT_BEGIN | ||
931 | |||
932 | |||
933 | /** | ||
934 | * Header of a structure that describes an | ||
935 | * event channel we may subscribe to or notify on. | ||
936 | */ | ||
937 | struct GNUNET_PQ_EventHeaderP | ||
938 | { | ||
939 | /** | ||
940 | * The length of the struct (in bytes, including the length field itself), | ||
941 | * in big-endian format. | ||
942 | */ | ||
943 | uint16_t size GNUNET_PACKED; | ||
944 | |||
945 | /** | ||
946 | * The type of the message (GNUNET_PQ_EVENT_TYPE_XXXX), in big-endian format. | ||
947 | */ | ||
948 | uint16_t type GNUNET_PACKED; | ||
949 | |||
950 | }; | ||
951 | |||
952 | GNUNET_NETWORK_STRUCT_END | ||
953 | |||
954 | |||
955 | /** | ||
956 | * Handle for an active LISTENer to the database. | ||
957 | */ | ||
958 | struct GNUNET_PQ_EventHandler; | ||
959 | |||
960 | /** | ||
961 | * Register callback to be invoked on events of type @a es. | 914 | * Register callback to be invoked on events of type @a es. |
962 | * | 915 | * |
963 | * Unlike many other calls, this function is thread-safe | 916 | * Unlike many other calls, this function is thread-safe |
964 | * and may be called from threads that are different | 917 | * and may be called from threads that are different |
965 | * from the one that setup @a db. However, the @a cb | 918 | * from the one that setup @a db. However, the @a cb |
@@ -973,16 +926,16 @@ struct GNUNET_PQ_EventHandler; | |||
973 | * @param cb_cls closure for @a cb | 926 | * @param cb_cls closure for @a cb |
974 | * @return handle useful to cancel the listener | 927 | * @return handle useful to cancel the listener |
975 | */ | 928 | */ |
976 | struct GNUNET_PQ_EventHandler * | 929 | struct GNUNET_DB_EventHandler * |
977 | GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db, | 930 | GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db, |
978 | const struct GNUNET_PQ_EventHeaderP *es, | 931 | const struct GNUNET_DB_EventHeaderP *es, |
979 | GNUNET_PQ_EventCallback cb, | 932 | GNUNET_DB_EventCallback cb, |
980 | void *cb_cls); | 933 | void *cb_cls); |
981 | 934 | ||
982 | 935 | ||
983 | /** | 936 | /** |
984 | * Stop notifications. | 937 | * Stop notifications. |
985 | * | 938 | * |
986 | * Unlike many other calls, this function is thread-safe | 939 | * Unlike many other calls, this function is thread-safe |
987 | * and may be called from threads that are different | 940 | * and may be called from threads that are different |
988 | * from the one that setup @a db. However, the @a cb | 941 | * from the one that setup @a db. However, the @a cb |
@@ -992,12 +945,12 @@ GNUNET_PQ_event_listen (struct GNUNET_PQ_Context *db, | |||
992 | * @param eh handle to unregister. | 945 | * @param eh handle to unregister. |
993 | */ | 946 | */ |
994 | void | 947 | void |
995 | GNUNET_PQ_event_listen_cancel (struct GNUNET_PQ_EventHandler *eh); | 948 | GNUNET_PQ_event_listen_cancel (struct GNUNET_DB_EventHandler *eh); |
996 | 949 | ||
997 | 950 | ||
998 | /** | 951 | /** |
999 | * Notify all that listen on @a es of an event. | 952 | * Notify all that listen on @a es of an event. |
1000 | * | 953 | * |
1001 | * Unlike many other calls, this function is thread-safe | 954 | * Unlike many other calls, this function is thread-safe |
1002 | * and may be called from threads that are different | 955 | * and may be called from threads that are different |
1003 | * from the one that setup @a db. However, the @a cb | 956 | * from the one that setup @a db. However, the @a cb |
@@ -1011,7 +964,7 @@ GNUNET_PQ_event_listen_cancel (struct GNUNET_PQ_EventHandler *eh); | |||
1011 | */ | 964 | */ |
1012 | void | 965 | void |
1013 | GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db, | 966 | GNUNET_PQ_event_notify (struct GNUNET_PQ_Context *db, |
1014 | const struct GNUNET_PQ_EventHeaderP *es, | 967 | const struct GNUNET_DB_EventHeaderP *es, |
1015 | const void *extra, | 968 | const void *extra, |
1016 | size_t extra_size); | 969 | size_t extra_size); |
1017 | 970 | ||