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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apiClient_t *apiClient_create() {
apiClient->basePath = strdup("{{{basePath}}}");
apiClient->sslConfig = NULL;
apiClient->curlConfig = NULL;
apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -67,6 +68,7 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
apiClient->curlConfig->keepidle = 120;
apiClient->curlConfig->keepintvl = 60;

apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -155,6 +157,8 @@ void apiClient_free(apiClient_t *apiClient) {
apiClient->curlConfig = NULL;
}

apiClient->curl_pre_invoke_func = NULL;

free(apiClient);
}

Expand Down Expand Up @@ -564,6 +568,10 @@ void apiClient_invoke(apiClient_t *apiClient,
curl_easy_setopt(handle, CURLOPT_VERBOSE, apiClient->curlConfig->verbose);
}

if(apiClient->curl_pre_invoke_func) {
apiClient->curl_pre_invoke_func(handle);
}

res = curl_easy_perform(handle);

curl_slist_free_all(headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void (*curl_pre_invoke_func)(CURL *);
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
1 change: 1 addition & 0 deletions samples/client/others/c/bearerAuth/include/apiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void (*curl_pre_invoke_func)(CURL *);
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
8 changes: 8 additions & 0 deletions samples/client/others/c/bearerAuth/src/apiClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apiClient_t *apiClient_create() {
apiClient->basePath = strdup("http://api.example.com/v1");
apiClient->sslConfig = NULL;
apiClient->curlConfig = NULL;
apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -44,6 +45,7 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
apiClient->curlConfig->keepidle = 120;
apiClient->curlConfig->keepintvl = 60;

apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -71,6 +73,8 @@ void apiClient_free(apiClient_t *apiClient) {
apiClient->curlConfig = NULL;
}

apiClient->curl_pre_invoke_func = NULL;

free(apiClient);
}

Expand Down Expand Up @@ -419,6 +423,10 @@ void apiClient_invoke(apiClient_t *apiClient,
curl_easy_setopt(handle, CURLOPT_VERBOSE, apiClient->curlConfig->verbose);
}

if(apiClient->curl_pre_invoke_func) {
apiClient->curl_pre_invoke_func(handle);
}

res = curl_easy_perform(handle);

curl_slist_free_all(headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void (*curl_pre_invoke_func)(CURL *);
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
8 changes: 8 additions & 0 deletions samples/client/petstore/c-useJsonUnformatted/src/apiClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apiClient_t *apiClient_create() {
apiClient->basePath = strdup("http://petstore.swagger.io/v2");
apiClient->sslConfig = NULL;
apiClient->curlConfig = NULL;
apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -46,6 +47,7 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
apiClient->curlConfig->keepidle = 120;
apiClient->curlConfig->keepintvl = 60;

apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -98,6 +100,8 @@ void apiClient_free(apiClient_t *apiClient) {
apiClient->curlConfig = NULL;
}

apiClient->curl_pre_invoke_func = NULL;

free(apiClient);
}

Expand Down Expand Up @@ -456,6 +460,10 @@ void apiClient_invoke(apiClient_t *apiClient,
curl_easy_setopt(handle, CURLOPT_VERBOSE, apiClient->curlConfig->verbose);
}

if(apiClient->curl_pre_invoke_func) {
apiClient->curl_pre_invoke_func(handle);
}

res = curl_easy_perform(handle);

curl_slist_free_all(headers);
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/c/include/apiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef struct apiClient_t {
char *basePath;
sslConfig_t *sslConfig;
curlConfig_t *curlConfig;
void (*curl_pre_invoke_func)(CURL *);
void *dataReceived;
long dataReceivedLen;
void (*data_callback_func)(void **, long *);
Expand Down
8 changes: 8 additions & 0 deletions samples/client/petstore/c/src/apiClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ apiClient_t *apiClient_create() {
apiClient->basePath = strdup("http://petstore.swagger.io/v2");
apiClient->sslConfig = NULL;
apiClient->curlConfig = NULL;
apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -46,6 +47,7 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
apiClient->curlConfig->keepidle = 120;
apiClient->curlConfig->keepintvl = 60;

apiClient->curl_pre_invoke_func = NULL;
apiClient->dataReceived = NULL;
apiClient->dataReceivedLen = 0;
apiClient->data_callback_func = NULL;
Expand Down Expand Up @@ -98,6 +100,8 @@ void apiClient_free(apiClient_t *apiClient) {
apiClient->curlConfig = NULL;
}

apiClient->curl_pre_invoke_func = NULL;

free(apiClient);
}

Expand Down Expand Up @@ -456,6 +460,10 @@ void apiClient_invoke(apiClient_t *apiClient,
curl_easy_setopt(handle, CURLOPT_VERBOSE, apiClient->curlConfig->verbose);
}

if(apiClient->curl_pre_invoke_func) {
apiClient->curl_pre_invoke_func(handle);
}

res = curl_easy_perform(handle);

curl_slist_free_all(headers);
Expand Down
7 changes: 7 additions & 0 deletions samples/client/petstore/c/unit-tests/manual-PetAPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <curl/curl.h>
#include "../api/PetAPI.h"

void preInvokeFunc(CURL *curl);

#define EXAMPLE_CATEGORY_NAME "Example Category"
#define EXAMPLE_CATEGORY_ID 5
Expand All @@ -16,10 +18,15 @@
#define EXAMPLE_TAG_2_ID 542353
#define EXAMPLE_PET_ID 1234 // Set to 0 to generate a new pet

void preInvokeFunc(CURL *curl) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
printf("CURL pre-invoke function called - verbose mode enabled\n");
}

int main() {
// Add pet test
apiClient_t *apiClient = apiClient_create();
apiClient->curl_pre_invoke_func = preInvokeFunc;

char *categoryName = malloc(strlen(EXAMPLE_CATEGORY_NAME) + 1);
strcpy(categoryName, EXAMPLE_CATEGORY_NAME);
Expand Down
Loading