| 1 | #include <getopt.h> |
| 2 | #include <stdio.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <mariadb_version.h> |
| 5 | |
| 6 | static char *mariadb_progname; |
| 7 | |
| 8 | #define INCLUDE "-I/usr/local/include/mariadb -I/usr/local/include/mariadb/mysql" |
| 9 | #define LIBS "-L/usr/local/lib/mariadb/ -lmariadb" |
| 10 | #define LIBS_SYS "-lzlibstatic -ldl -lglibc-compatibility -lpthread -lssl -lcrypto" |
| 11 | #define CFLAGS INCLUDE |
| 12 | #define VERSION "10.4.3" |
| 13 | #define CC_VERSION "3.1.4" |
| 14 | #define PLUGIN_DIR "/usr/local/" |
| 15 | #define SOCKET "/tmp/mysql.sock" |
| 16 | #define PORT "3306" |
| 17 | #define TLS_LIBRARY_VERSION "OpenSSL " |
| 18 | |
| 19 | static struct option long_options[]= |
| 20 | { |
| 21 | {"cflags" , no_argument, 0, 'a'}, |
| 22 | {"help" , no_argument, 0, 'b'}, |
| 23 | {"include" , no_argument, 0, 'c'}, |
| 24 | {"libs" , no_argument, 0, 'd'}, |
| 25 | {"libs_r" , no_argument, 0, 'e'}, |
| 26 | {"libs_sys" , no_argument, 0, 'l'}, |
| 27 | {"version" , no_argument, 0, 'f'}, |
| 28 | {"cc_version" , no_argument, 0, 'g'}, |
| 29 | {"socket" , no_argument, 0, 'h'}, |
| 30 | {"port" , no_argument, 0, 'i'}, |
| 31 | {"plugindir" , no_argument, 0, 'j'}, |
| 32 | {"tlsinfo" , no_argument, 0, 'k'}, |
| 33 | {NULL, 0, 0, 0} |
| 34 | }; |
| 35 | |
| 36 | static const char *values[]= |
| 37 | { |
| 38 | CFLAGS, |
| 39 | NULL, |
| 40 | INCLUDE, |
| 41 | LIBS, |
| 42 | LIBS, |
| 43 | LIBS_SYS, |
| 44 | VERSION, |
| 45 | CC_VERSION, |
| 46 | SOCKET, |
| 47 | PORT, |
| 48 | PLUGIN_DIR, |
| 49 | TLS_LIBRARY_VERSION |
| 50 | }; |
| 51 | |
| 52 | void usage(void) |
| 53 | { |
| 54 | int i=0; |
| 55 | puts("Copyright 2011-2019 MariaDB Corporation AB" ); |
| 56 | puts("Get compiler flags for using the MariaDB Connector/C." ); |
| 57 | printf("Usage: %s [OPTIONS]\n" , mariadb_progname); |
| 58 | while (long_options[i].name) |
| 59 | { |
| 60 | if (values[i]) |
| 61 | printf(" --%-12s [%s]\n" , long_options[i].name, values[i]); |
| 62 | i++; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | |
| 67 | int main(int argc, char **argv) |
| 68 | { |
| 69 | int c; |
| 70 | mariadb_progname= argv[0]; |
| 71 | |
| 72 | if (argc <= 1) |
| 73 | { |
| 74 | usage(); |
| 75 | exit(0); |
| 76 | } |
| 77 | |
| 78 | while(1) |
| 79 | { |
| 80 | int option_index= 0; |
| 81 | c= getopt_long(argc, argv, "abcdefghijkl" , long_options, &option_index); |
| 82 | |
| 83 | switch(c) { |
| 84 | case 'a': |
| 85 | puts(CFLAGS); |
| 86 | break; |
| 87 | case 'b': |
| 88 | usage(); |
| 89 | break; |
| 90 | case 'c': |
| 91 | puts(INCLUDE); |
| 92 | break; |
| 93 | case 'd': |
| 94 | case 'e': |
| 95 | puts(LIBS); |
| 96 | break; |
| 97 | case 'f': |
| 98 | puts(VERSION); |
| 99 | break; |
| 100 | case 'g': |
| 101 | puts(CC_VERSION); |
| 102 | break; |
| 103 | case 'h': |
| 104 | puts(SOCKET); |
| 105 | break; |
| 106 | case 'i': |
| 107 | puts(PORT); |
| 108 | break; |
| 109 | case 'j': |
| 110 | puts(PLUGIN_DIR); |
| 111 | break; |
| 112 | case 'k': |
| 113 | puts(TLS_LIBRARY_VERSION); |
| 114 | break; |
| 115 | case 'l': |
| 116 | puts(LIBS_SYS); |
| 117 | break; |
| 118 | default: |
| 119 | exit((c != -1)); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | exit(0); |
| 124 | } |
| 125 | |
| 126 | |