Jim Flynn
/
aws-iot-device-sdk-mbed-c
Changes to enabled on-line compiler
src/aws_iot_jobs_types.c@0:082731ede69f, 2018-05-30 (annotated)
- Committer:
- JMF
- Date:
- Wed May 30 20:59:51 2018 +0000
- Revision:
- 0:082731ede69f
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 0:082731ede69f | 1 | /* |
JMF | 0:082731ede69f | 2 | * Copyright 2015-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
JMF | 0:082731ede69f | 3 | * |
JMF | 0:082731ede69f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
JMF | 0:082731ede69f | 5 | * You may not use this file except in compliance with the License. |
JMF | 0:082731ede69f | 6 | * A copy of the License is located at |
JMF | 0:082731ede69f | 7 | * |
JMF | 0:082731ede69f | 8 | * http://aws.amazon.com/apache2.0 |
JMF | 0:082731ede69f | 9 | * |
JMF | 0:082731ede69f | 10 | * or in the "license" file accompanying this file. This file is distributed |
JMF | 0:082731ede69f | 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
JMF | 0:082731ede69f | 12 | * express or implied. See the License for the specific language governing |
JMF | 0:082731ede69f | 13 | * permissions and limitations under the License. |
JMF | 0:082731ede69f | 14 | */ |
JMF | 0:082731ede69f | 15 | |
JMF | 0:082731ede69f | 16 | #ifdef __cplusplus |
JMF | 0:082731ede69f | 17 | extern "C" { |
JMF | 0:082731ede69f | 18 | #endif |
JMF | 0:082731ede69f | 19 | |
JMF | 0:082731ede69f | 20 | #include <string.h> |
JMF | 0:082731ede69f | 21 | #include "aws_iot_jobs_types.h" |
JMF | 0:082731ede69f | 22 | |
JMF | 0:082731ede69f | 23 | const char *JOB_EXECUTION_QUEUED_STR = "QUEUED"; |
JMF | 0:082731ede69f | 24 | const char *JOB_EXECUTION_IN_PROGRESS_STR = "IN_PROGRESS"; |
JMF | 0:082731ede69f | 25 | const char *JOB_EXECUTION_FAILED_STR = "FAILED"; |
JMF | 0:082731ede69f | 26 | const char *JOB_EXECUTION_SUCCEEDED_STR = "SUCCEEDED"; |
JMF | 0:082731ede69f | 27 | const char *JOB_EXECUTION_CANCELED_STR = "CANCELED"; |
JMF | 0:082731ede69f | 28 | const char *JOB_EXECUTION_REJECTED_STR = "REJECTED"; |
JMF | 0:082731ede69f | 29 | |
JMF | 0:082731ede69f | 30 | JobExecutionStatus aws_iot_jobs_map_string_to_job_status(const char *str) { |
JMF | 0:082731ede69f | 31 | if (str == NULL || str[0] == '\0') { |
JMF | 0:082731ede69f | 32 | return JOB_EXECUTION_STATUS_NOT_SET; |
JMF | 0:082731ede69f | 33 | } else if (strcmp(str, JOB_EXECUTION_QUEUED_STR) == 0) { |
JMF | 0:082731ede69f | 34 | return JOB_EXECUTION_QUEUED; |
JMF | 0:082731ede69f | 35 | } else if(strcmp(str, JOB_EXECUTION_IN_PROGRESS_STR) == 0) { |
JMF | 0:082731ede69f | 36 | return JOB_EXECUTION_IN_PROGRESS; |
JMF | 0:082731ede69f | 37 | } else if(strcmp(str, JOB_EXECUTION_FAILED_STR) == 0) { |
JMF | 0:082731ede69f | 38 | return JOB_EXECUTION_FAILED; |
JMF | 0:082731ede69f | 39 | } else if(strcmp(str, JOB_EXECUTION_SUCCEEDED_STR) == 0) { |
JMF | 0:082731ede69f | 40 | return JOB_EXECUTION_SUCCEEDED; |
JMF | 0:082731ede69f | 41 | } else if(strcmp(str, JOB_EXECUTION_CANCELED_STR) == 0) { |
JMF | 0:082731ede69f | 42 | return JOB_EXECUTION_CANCELED; |
JMF | 0:082731ede69f | 43 | } else if(strcmp(str, JOB_EXECUTION_REJECTED_STR) == 0) { |
JMF | 0:082731ede69f | 44 | return JOB_EXECUTION_REJECTED; |
JMF | 0:082731ede69f | 45 | } else { |
JMF | 0:082731ede69f | 46 | return JOB_EXECUTION_UNKNOWN_STATUS; |
JMF | 0:082731ede69f | 47 | } |
JMF | 0:082731ede69f | 48 | } |
JMF | 0:082731ede69f | 49 | |
JMF | 0:082731ede69f | 50 | const char *aws_iot_jobs_map_status_to_string(JobExecutionStatus status) { |
JMF | 0:082731ede69f | 51 | switch(status) { |
JMF | 0:082731ede69f | 52 | case JOB_EXECUTION_QUEUED: |
JMF | 0:082731ede69f | 53 | return JOB_EXECUTION_QUEUED_STR; |
JMF | 0:082731ede69f | 54 | case JOB_EXECUTION_IN_PROGRESS: |
JMF | 0:082731ede69f | 55 | return JOB_EXECUTION_IN_PROGRESS_STR; |
JMF | 0:082731ede69f | 56 | case JOB_EXECUTION_FAILED: |
JMF | 0:082731ede69f | 57 | return JOB_EXECUTION_FAILED_STR; |
JMF | 0:082731ede69f | 58 | case JOB_EXECUTION_SUCCEEDED: |
JMF | 0:082731ede69f | 59 | return JOB_EXECUTION_SUCCEEDED_STR; |
JMF | 0:082731ede69f | 60 | case JOB_EXECUTION_CANCELED: |
JMF | 0:082731ede69f | 61 | return JOB_EXECUTION_CANCELED_STR; |
JMF | 0:082731ede69f | 62 | case JOB_EXECUTION_REJECTED: |
JMF | 0:082731ede69f | 63 | return JOB_EXECUTION_REJECTED_STR; |
JMF | 0:082731ede69f | 64 | case JOB_EXECUTION_STATUS_NOT_SET: |
JMF | 0:082731ede69f | 65 | case JOB_EXECUTION_UNKNOWN_STATUS: |
JMF | 0:082731ede69f | 66 | default: |
JMF | 0:082731ede69f | 67 | return NULL; |
JMF | 0:082731ede69f | 68 | } |
JMF | 0:082731ede69f | 69 | } |
JMF | 0:082731ede69f | 70 | |
JMF | 0:082731ede69f | 71 | #ifdef __cplusplus |
JMF | 0:082731ede69f | 72 | } |
JMF | 0:082731ede69f | 73 | #endif |