changes to make it build with a c++ compiler
authorAschwin Marsman <a.marsman@aynik.com>
Mon, 11 Jul 2016 19:29:28 +0000 (21:29 +0200)
committerAschwin Marsman <a.marsman@aynik.com>
Mon, 11 Jul 2016 19:29:28 +0000 (21:29 +0200)
include/tlspool/commands.h
include/tlspool/starttls.h

index 7262868..a67cda6 100644 (file)
@@ -4,6 +4,10 @@
 #ifndef TLSPOOL_COMMANDS_H
 #define TLSPOOL_COMMANDS_H
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
 
 #include <stdint.h>
 
@@ -101,6 +105,27 @@ enum anciltype {
  */
 
 #pragma pack(push,2)
+
+struct pioc_pinentry {
+        uint32_t flags;                // PIOF_PINENTRY_xxx below
+        uint32_t attempt;      // Attempt counter -- display!
+        uint32_t timeout_us;   // Timeout in microseconds
+        char pin [128];                // Empty string means no PIN
+        char prompt [128];     // Prompt from TLS Pool
+        char token_manuf[32 + 1 + 3];  // PKCS #11 token manufacturer
+        char token_model[16 + 1 + 3];  // PKCS #11 token model
+        char token_serial[16 + 1 + 3]; // PKCS #11 token serial number
+        char token_label[32 + 1 + 3];  // PKCS #11 token label
+};
+
+struct pioc_lidentry {
+    uint32_t flags;    // PIOF_LIDENTRY_xxx below
+    uint16_t maxlevels;        // Max # iterations for concrete ID
+    uint32_t timeout;  // Regtimeout[s] or resptimeout
+    char localid [128];        // Local ID or empty string
+    char remoteid [128];// Remote ID or empty string
+};
+
 struct tlspool_command {
        uint16_t pio_reqid;     // Request->Response request identifier
        uint16_t pio_cbid;      // Response->Request callback identifier
@@ -125,24 +150,8 @@ struct tlspool_command {
                        uint8_t service [TLSPOOL_SERVICELEN];   // Names from IANA
                        uint32_t timeout;       // in ms, 0=default, ~0=infinite
                } pioc_starttls;
-               struct pioc_pinentry {
-                       uint32_t flags;         // PIOF_PINENTRY_xxx below
-                       uint32_t attempt;       // Attempt counter -- display!
-                       uint32_t timeout_us;    // Timeout in microseconds
-                       char pin [128];         // Empty string means no PIN
-                       char prompt [128];      // Prompt from TLS Pool
-                       char token_manuf[32 + 1 + 3];   // PKCS #11 token manufacturer
-                       char token_model[16 + 1 + 3];   // PKCS #11 token model
-                       char token_serial[16 + 1 + 3];  // PKCS #11 token serial number
-                       char token_label[32 + 1 + 3];   // PKCS #11 token label
-               } pioc_pinentry;
-               struct pioc_lidentry {
-                       uint32_t flags;         // PIOF_LIDENTRY_xxx below
-                       uint16_t maxlevels;     // Max # iterations for concrete ID
-                       uint32_t timeout;       // Regtimeout[s] or resptimeout
-                       char localid [128];     // Local ID or empty string
-                       char remoteid [128];    // Remote ID or empty string
-               } pioc_lidentry;
+                struct pioc_pinentry pioc_pinentry;
+                struct pioc_lidentry pioc_lidentry;
                struct pioc_control {
                        uint32_t flags;         // PIOF_CONTROL_xxx, none yet
                        uint8_t ctlkey [TLSPOOL_CTLKEYLEN]; // Control key
@@ -741,6 +750,9 @@ typedef struct pioc_lidentry lidentry_t;
  */
 #define PIOF_LIDENTRY_ONTHEFLY                 0x00200000
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif //TLSPOOL_COMMANDS_H
 
index 99be34b..1da8bd2 100644 (file)
@@ -3,11 +3,17 @@
 #ifndef TLSPOOL_STARTTLS_H
 #define TLSPOOL_STARTTLS_H
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
 
 #include <tlspool/commands.h>
 
 #ifdef WINDOWS_PORT
 #include <windows.h>
+#else
+#include <unistd.h>
 #endif /* WINDOWS_PORT */
 
 
@@ -240,7 +246,7 @@ int tlspool_localid_service (char *path, uint32_t regflags, int responsetimeout,
  *
  * This function returns -1 on error, or 0 on success.
  */
-int tlspool_pin_service (char *path, uint32_t regflags, int responsetimeout_usec, void (*cb) (struct pioc_pinentry *entry, void *data), void *data);
+int tlspool_pin_service (char *path, uint32_t regflags, int responsetimeout_usec, void (*cb) (pinentry_t *entry, void *data), void *data);
 
 /* Generate a pseudo-random sequence based on session cryptographic keys.
  *
@@ -290,4 +296,8 @@ int tlspool_prng (char *label, char *opt_ctxvalue,
                uint16_t prng_len, uint8_t *prng_buf,
                uint8_t *ctlkey);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif // TLSPOOL_STARTTLS_H