80 lines
2.1 KiB
C
80 lines
2.1 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include "VersionAPI.h"
|
|
|
|
#define MAX_NUMBER_LENGTH 16
|
|
#define MAX_BUFFER_LENGTH 4096
|
|
#define intToStr(dst, src) \
|
|
do {\
|
|
char dst[256];\
|
|
snprintf(dst, 256, "%ld", (long int)(src));\
|
|
}while(0)
|
|
|
|
|
|
// get the code version
|
|
//
|
|
version_info_t*
|
|
VersionAPI_getCode(apiClient_t *apiClient)
|
|
{
|
|
list_t *localVarQueryParameters = NULL;
|
|
list_t *localVarHeaderParameters = NULL;
|
|
list_t *localVarFormParameters = NULL;
|
|
list_t *localVarHeaderType = list_createList();
|
|
list_t *localVarContentType = NULL;
|
|
char *localVarBodyParameters = NULL;
|
|
|
|
// create the path
|
|
long sizeOfPath = strlen("/version/")+1;
|
|
char *localVarPath = malloc(sizeOfPath);
|
|
snprintf(localVarPath, sizeOfPath, "/version/");
|
|
|
|
|
|
|
|
list_addElement(localVarHeaderType,"application/json"); //produces
|
|
apiClient_invoke(apiClient,
|
|
localVarPath,
|
|
localVarQueryParameters,
|
|
localVarHeaderParameters,
|
|
localVarFormParameters,
|
|
localVarHeaderType,
|
|
localVarContentType,
|
|
localVarBodyParameters,
|
|
"GET");
|
|
|
|
// uncomment below to debug the error response
|
|
//if (apiClient->response_code == 200) {
|
|
// printf("%s\n","OK");
|
|
//}
|
|
// uncomment below to debug the error response
|
|
//if (apiClient->response_code == 401) {
|
|
// printf("%s\n","Unauthorized");
|
|
//}
|
|
//nonprimitive not container
|
|
cJSON *VersionAPIlocalVarJSON = cJSON_Parse(apiClient->dataReceived);
|
|
version_info_t *elementToReturn = version_info_parseFromJSON(VersionAPIlocalVarJSON);
|
|
cJSON_Delete(VersionAPIlocalVarJSON);
|
|
if(elementToReturn == NULL) {
|
|
// return 0;
|
|
}
|
|
|
|
//return type
|
|
if (apiClient->dataReceived) {
|
|
free(apiClient->dataReceived);
|
|
apiClient->dataReceived = NULL;
|
|
apiClient->dataReceivedLen = 0;
|
|
}
|
|
|
|
|
|
|
|
list_freeList(localVarHeaderType);
|
|
|
|
free(localVarPath);
|
|
return elementToReturn;
|
|
end:
|
|
free(localVarPath);
|
|
return NULL;
|
|
|
|
}
|
|
|