trilogy_w_prepared_statements 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/LICENSE +22 -0
 - data/README.md +80 -0
 - data/Rakefile +22 -0
 - data/ext/trilogy-ruby/cast.c +277 -0
 - data/ext/trilogy-ruby/cext.c +1048 -0
 - data/ext/trilogy-ruby/extconf.rb +17 -0
 - data/ext/trilogy-ruby/inc/trilogy/blocking.h +281 -0
 - data/ext/trilogy-ruby/inc/trilogy/buffer.h +64 -0
 - data/ext/trilogy-ruby/inc/trilogy/builder.h +165 -0
 - data/ext/trilogy-ruby/inc/trilogy/charset.h +277 -0
 - data/ext/trilogy-ruby/inc/trilogy/client.h +760 -0
 - data/ext/trilogy-ruby/inc/trilogy/error.h +44 -0
 - data/ext/trilogy-ruby/inc/trilogy/packet_parser.h +34 -0
 - data/ext/trilogy-ruby/inc/trilogy/protocol.h +1014 -0
 - data/ext/trilogy-ruby/inc/trilogy/reader.h +216 -0
 - data/ext/trilogy-ruby/inc/trilogy/socket.h +111 -0
 - data/ext/trilogy-ruby/inc/trilogy/vendor/curl_hostcheck.h +29 -0
 - data/ext/trilogy-ruby/inc/trilogy/vendor/openssl_hostname_validation.h +51 -0
 - data/ext/trilogy-ruby/inc/trilogy.h +8 -0
 - data/ext/trilogy-ruby/src/blocking.c +358 -0
 - data/ext/trilogy-ruby/src/buffer.c +60 -0
 - data/ext/trilogy-ruby/src/builder.c +236 -0
 - data/ext/trilogy-ruby/src/charset.c +212 -0
 - data/ext/trilogy-ruby/src/client.c +903 -0
 - data/ext/trilogy-ruby/src/error.c +17 -0
 - data/ext/trilogy-ruby/src/packet_parser.c +140 -0
 - data/ext/trilogy-ruby/src/protocol.c +1175 -0
 - data/ext/trilogy-ruby/src/reader.c +282 -0
 - data/ext/trilogy-ruby/src/socket.c +623 -0
 - data/ext/trilogy-ruby/src/vendor/curl_hostcheck.c +206 -0
 - data/ext/trilogy-ruby/src/vendor/openssl_hostname_validation.c +175 -0
 - data/ext/trilogy-ruby/trilogy-ruby.h +37 -0
 - data/lib/trilogy/version.rb +3 -0
 - data/lib/trilogy.rb +61 -0
 - data/trilogy.gemspec +27 -0
 - metadata +107 -0
 
| 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #ifndef TRILOGY_ERROR_H
         
     | 
| 
      
 2 
     | 
    
         
            +
            #define TRILOGY_ERROR_H
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #define TRILOGY_ERROR_CODES(XX)                                                                                        \
         
     | 
| 
      
 5 
     | 
    
         
            +
                XX(TRILOGY_OK, 0)                                                                                                  \
         
     | 
| 
      
 6 
     | 
    
         
            +
                XX(TRILOGY_ERR, -1)                                                                                                \
         
     | 
| 
      
 7 
     | 
    
         
            +
                XX(TRILOGY_EOF, -2)                                                                                                \
         
     | 
| 
      
 8 
     | 
    
         
            +
                XX(TRILOGY_SYSERR, -3) /* check errno */                                                                           \
         
     | 
| 
      
 9 
     | 
    
         
            +
                XX(TRILOGY_UNEXPECTED_PACKET, -4)                                                                                  \
         
     | 
| 
      
 10 
     | 
    
         
            +
                XX(TRILOGY_TRUNCATED_PACKET, -5)                                                                                   \
         
     | 
| 
      
 11 
     | 
    
         
            +
                XX(TRILOGY_PROTOCOL_VIOLATION, -6)                                                                                 \
         
     | 
| 
      
 12 
     | 
    
         
            +
                XX(TRILOGY_AUTH_PLUGIN_TOO_LONG, -7)                                                                               \
         
     | 
| 
      
 13 
     | 
    
         
            +
                XX(TRILOGY_EXTRA_DATA_IN_PACKET, -8)                                                                               \
         
     | 
| 
      
 14 
     | 
    
         
            +
                XX(TRILOGY_INVALID_CHARSET, -9)                                                                                    \
         
     | 
| 
      
 15 
     | 
    
         
            +
                XX(TRILOGY_AGAIN, -10)                                                                                             \
         
     | 
| 
      
 16 
     | 
    
         
            +
                XX(TRILOGY_CLOSED_CONNECTION, -11)                                                                                 \
         
     | 
| 
      
 17 
     | 
    
         
            +
                XX(TRILOGY_HAVE_RESULTS, -12)                                                                                      \
         
     | 
| 
      
 18 
     | 
    
         
            +
                XX(TRILOGY_NULL_VALUE, -13)                                                                                        \
         
     | 
| 
      
 19 
     | 
    
         
            +
                XX(TRILOGY_INVALID_SEQUENCE_ID, -14)                                                                               \
         
     | 
| 
      
 20 
     | 
    
         
            +
                XX(TRILOGY_TYPE_OVERFLOW, -15)                                                                                     \
         
     | 
| 
      
 21 
     | 
    
         
            +
                XX(TRILOGY_OPENSSL_ERR, -16) /* check ERR_get_error() */                                                           \
         
     | 
| 
      
 22 
     | 
    
         
            +
                XX(TRILOGY_UNSUPPORTED, -17)                                                                                       \
         
     | 
| 
      
 23 
     | 
    
         
            +
                XX(TRILOGY_DNS_ERR, -18)                                                                                           \
         
     | 
| 
      
 24 
     | 
    
         
            +
                XX(TRILOGY_AUTH_SWITCH, -19)                                                                                       \
         
     | 
| 
      
 25 
     | 
    
         
            +
                XX(TRILOGY_UNKNOWN_TYPE, -20)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            enum {
         
     | 
| 
      
 28 
     | 
    
         
            +
            #define XX(name, code) name = code,
         
     | 
| 
      
 29 
     | 
    
         
            +
                TRILOGY_ERROR_CODES(XX)
         
     | 
| 
      
 30 
     | 
    
         
            +
            #undef XX
         
     | 
| 
      
 31 
     | 
    
         
            +
            };
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            /* trilogy_error - Get the string version of an Trilogy error code.
         
     | 
| 
      
 34 
     | 
    
         
            +
             *
         
     | 
| 
      
 35 
     | 
    
         
            +
             * This can be useful for logging or debugging as printing the error value
         
     | 
| 
      
 36 
     | 
    
         
            +
             * integer itself doesn't provide much context.
         
     | 
| 
      
 37 
     | 
    
         
            +
             *
         
     | 
| 
      
 38 
     | 
    
         
            +
             * error - An Trilogy error code integer.
         
     | 
| 
      
 39 
     | 
    
         
            +
             *
         
     | 
| 
      
 40 
     | 
    
         
            +
             * Returns an error name constant from TRILOGY_ERROR_CODES as a C-string.
         
     | 
| 
      
 41 
     | 
    
         
            +
             */
         
     | 
| 
      
 42 
     | 
    
         
            +
            const char *trilogy_error(int error);
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            #endif
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #ifndef TRILOGY_PACKET_PARSER_H
         
     | 
| 
      
 2 
     | 
    
         
            +
            #define TRILOGY_PACKET_PARSER_H
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #include <stddef.h>
         
     | 
| 
      
 5 
     | 
    
         
            +
            #include <stdint.h>
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            // Data between client and server is exchanged in packets of max 16MByte size.
         
     | 
| 
      
 8 
     | 
    
         
            +
            #define TRILOGY_MAX_PACKET_LEN 0xffffff
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            typedef struct {
         
     | 
| 
      
 11 
     | 
    
         
            +
                int (*on_packet_begin)(void *);
         
     | 
| 
      
 12 
     | 
    
         
            +
                int (*on_packet_data)(void *, const uint8_t *, size_t);
         
     | 
| 
      
 13 
     | 
    
         
            +
                int (*on_packet_end)(void *);
         
     | 
| 
      
 14 
     | 
    
         
            +
            } trilogy_packet_parser_callbacks_t;
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            typedef struct {
         
     | 
| 
      
 17 
     | 
    
         
            +
                void *user_data;
         
     | 
| 
      
 18 
     | 
    
         
            +
                const trilogy_packet_parser_callbacks_t *callbacks;
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                uint8_t sequence_number;
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                // private:
         
     | 
| 
      
 23 
     | 
    
         
            +
                unsigned bytes_remaining : 24;
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                unsigned state : 3;
         
     | 
| 
      
 26 
     | 
    
         
            +
                unsigned fragment : 1;
         
     | 
| 
      
 27 
     | 
    
         
            +
                unsigned deferred_end_callback : 1;
         
     | 
| 
      
 28 
     | 
    
         
            +
            } trilogy_packet_parser_t;
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            void trilogy_packet_parser_init(trilogy_packet_parser_t *parser, const trilogy_packet_parser_callbacks_t *callbacks);
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            size_t trilogy_packet_parser_execute(trilogy_packet_parser_t *parser, const uint8_t *buf, size_t len, int *error);
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            #endif
         
     |