Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions bin/elasticurl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
# pragma warning(disable : 4221) /* Local var in declared initializer */
#endif

#define ELASTICURL_VERSION "0.2.0"

struct elasticurl_ctx {
struct aws_allocator *allocator;
const char *verb;
Expand All @@ -60,7 +62,7 @@ struct elasticurl_ctx {
bool exchange_completed;
};

static void s_usage(void) {
static void s_usage(int exit_code) {

fprintf(stderr, "usage: elasticurl [options] url\n");
fprintf(stderr, " url: url to make a request to. The default is a GET request.\n");
Expand All @@ -81,10 +83,11 @@ static void s_usage(void) {
fprintf(stderr, " -k, --insecure: turns off SSL/TLS validation.\n");
fprintf(stderr, " -o, --output FILE: dumps content-body to FILE instead of stdout.\n");
fprintf(stderr, " -t, --trace FILE: dumps logs to FILE instead of stderr.\n");
fprintf(stderr, " -v, --verbose ERROR|INFO|DEBUG|TRACE: log level to configure. Default is none.\n");
fprintf(stderr, " -v, --verbose: ERROR|INFO|DEBUG|TRACE: log level to configure. Default is none.\n");
fprintf(stderr, " --version: print the version of elasticurl.\n");
fprintf(stderr, " -h, --help\n");
fprintf(stderr, " Display this message and quit.\n");
exit(1);
exit(exit_code);
}

static struct aws_cli_option s_long_options[] = {
Expand All @@ -105,6 +108,7 @@ static struct aws_cli_option s_long_options[] = {
{"output", AWS_CLI_OPTIONS_REQUIRED_ARGUMENT, NULL, 'o'},
{"trace", AWS_CLI_OPTIONS_REQUIRED_ARGUMENT, NULL, 't'},
{"verbose", AWS_CLI_OPTIONS_REQUIRED_ARGUMENT, NULL, 'v'},
{"version", AWS_CLI_OPTIONS_NO_ARGUMENT, NULL, 'V'},
{"help", AWS_CLI_OPTIONS_NO_ARGUMENT, NULL, 'h'},
/* Per getopt(3) the last element of the array has to be filled with all zeros */
{NULL, AWS_CLI_OPTIONS_NO_ARGUMENT, NULL, 0},
Expand All @@ -113,7 +117,7 @@ static struct aws_cli_option s_long_options[] = {
static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) {
while (true) {
int option_index = 0;
int c = aws_cli_getopt_long(argc, argv, "a:b:c:e:f:H:d:g:M:GPHiko:t:v:h", s_long_options, &option_index);
int c = aws_cli_getopt_long(argc, argv, "a:b:c:e:f:H:d:g:M:GPHiko:t:v:Vh", s_long_options, &option_index);
if (c == -1) {
break;
}
Expand All @@ -140,7 +144,7 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) {
case 'H':
if (ctx->header_line_count >= sizeof(ctx->header_lines) / sizeof(const char *)) {
fprintf(stderr, "currently only 10 header lines are supported.\n");
s_usage();
s_usage(1);
}
ctx->header_lines[ctx->header_line_count++] = aws_cli_optarg;
break;
Expand All @@ -152,7 +156,7 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) {
ctx->data_file = fopen(aws_cli_optarg, "rb");
if (!ctx->data_file) {
fprintf(stderr, "unable to open file %s.\n", aws_cli_optarg);
s_usage();
s_usage(1);
}
break;
case 'M':
Expand All @@ -178,7 +182,7 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) {

if (!ctx->output) {
fprintf(stderr, "unable to open file %s.\n", aws_cli_optarg);
s_usage();
s_usage(1);
}
break;
case 't':
Expand All @@ -195,15 +199,18 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) {
ctx->log_level = AWS_LL_ERROR;
} else {
fprintf(stderr, "unsupported log level %s.\n", aws_cli_optarg);
s_usage();
s_usage(1);
}
break;
case 'V':
fprintf(stderr, "elasticurl %s\n", ELASTICURL_VERSION);
exit(0);
case 'h':
s_usage();
s_usage(0);
break;
default:
fprintf(stderr, "Unknown option\n");
s_usage();
s_usage(1);
}
}

Expand All @@ -216,11 +223,11 @@ static void s_parse_options(int argc, char **argv, struct elasticurl_ctx *ctx) {
"Failed to parse uri %s with error %s\n",
(char *)uri_cursor.ptr,
aws_error_debug_str(aws_last_error()));
s_usage();
s_usage(1);
};
} else {
fprintf(stderr, "A URI for the request must be supplied.\n");
s_usage();
s_usage(1);
}
}

Expand Down
48 changes: 48 additions & 0 deletions continuous-delivery/build-elasticurl-manylinux-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: 0.2
#this build spec assumes the manylinux1 image for pypi
#additional packages we installed: cmake 3.5, libcrypto 1.1.0j, gcc 4.8.4
phases:
install:
commands:
pre_build:
commands:
- export CC=gcc
build:
commands:
- echo Build started on `date`
- mkdir /tmp/install
- mkdir /tmp/aws-c-common-build
- mkdir /tmp/aws-c-compression-build
- mkdir /tmp/aws-c-io-build
- mkdir /tmp/aws-c-http-build
- mkdir /tmp/s2n-build
- cd /tmp/aws-c-common-build
- cmake -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-common
- make -j
- make install
- cd /tmp/aws-c-compression-build
- cmake -DCMAKE_PREFIX_PATH=/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-compression
- make -j
- make install
- cd /tmp/s2n-build
- cmake -DCMAKE_PREFIX_PATH=/opt/openssl;/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_s2n
- make -j
- make install
- cd /tmp/aws-c-io-build
- cmake -DCMAKE_PREFIX_PATH=/opt/openssl;/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-io
- make -j
- make install
- cd /tmp/aws-c-http-build
- cmake -DCMAKE_PREFIX_PATH=/opt/openssl;/tmp/install -DCMAKE_INSTALL_PREFIX=/tmp/install -DBUILD_TESTING=OFF $CODEBUILD_SRC_DIR_aws-c-http
- make -j
- make install
- /tmp/install/bin/elasticurl --version
- /tmp/install/bin/elasticurl -v TRACE https://example.com
post_build:
commands:
- echo Build completed on `date`

artifacts:
files:
- '/tmp/install/bin/elasticurl'

33 changes: 33 additions & 0 deletions continuous-delivery/build-elasticurl-osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
#before running this, you'll need cmake3 and a compiler.
set -e
export MACOSX_DEPLOYMENT_TARGET="10.9"
mkdir install
mkdir aws-c-common-build
mkdir aws-c-io-build
mkdir aws-c-compression-build
mkdir aws-c-http-build
cd aws-c-common-build
cmake -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-common
make -j
make install
cd ..
cd aws-c-compression-build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-compression
make -j
make install
cd ..
cd aws-c-io-build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-io
make -j
make install
cd ..
cd aws-c-http-build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-http
make -j
make install
cd ..

install/bin/elasticurl --version
install/bin/elasticurl -v TRACE https://example.com

38 changes: 38 additions & 0 deletions continuous-delivery/build-elasticurl-unix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#before running this, you'll need cmake3 and a compiler.
set -e
mkdir install
mkdir aws-c-common-build
mkdir aws-c-compression-build
mkdir aws-c-io-build
mkdir aws-c-http-build
mkdir s2n-build
cd aws-c-common-build
cmake -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-common
make -j
make install
cd ..
cd aws-c-compression-build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-compression
make -j
make install
cd ..
cd s2n-build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../s2n
make -j
make install
cd ..
cd aws-c-io-build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-io
make -j
make install
cd ..
cd aws-c-http-build
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install -DCMAKE_INSTALL_PREFIX=`pwd`/../install -DBUILD_TESTING=OFF ../aws-c-http
make -j
make install
cd ..

install/bin/elasticurl --version
install/bin/elasticurl -v TRACE https://example.com

35 changes: 35 additions & 0 deletions continuous-delivery/build-elasticurl-win64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

mkdir install
cd install
set INSTALL_DIR %cd%
cd ..
mkdir aws-c-common-build
mkdir aws-c-compression-build
mkdir aws-c-io-build
mkdir aws-c-http-build
cd aws-c-common-build
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-common || goto error
cmake --build .\ --target install --config RelWithDebInfo || goto error
cd ..
cd aws-c-compression-build
cmake -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-compression || goto error
cmake --build .\ --target install --config RelWithDebInfo || goto error
cd ..
cd aws-c-io-build
cmake -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-io || goto error
cmake --build .\ --target install --config RelWithDebInfo || goto error
cd ..
cd aws-c-http-build
cmake -DCMAKE_PREFIX_PATH=%INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DBUILD_TESTING=OFF ..\aws-c-http || goto error
cmake --build .\ --target install --config RelWithDebInfo || goto error
cd ..

%INSTALL_DIR%\bin\elasticurl --version || goto error
%INSTALL_DIR%\bin\elasticurl -v TRACE https://example.com || goto error

goto :EOF

:error
echo Failed with error #%errorlevel%.
exit /b %errorlevel%