Skip to content

Commit

Permalink
Apply clang-format with adapted settings (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Nov 17, 2019
1 parent 36fc784 commit b19a2a4
Show file tree
Hide file tree
Showing 57 changed files with 1,132 additions and 1,178 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BasedOnStyle: LLVM
ColumnLimit: 100
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
AlignTrailingComments: true
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

[*.{c,h,cpp,hpp}]
indent_size = 4
29 changes: 22 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ language: c

sudo: false

compiler:
- clang
- gcc

addons:
apt:
sources:
- llvm-toolchain-trusty
packages:
- uuid-dev
- uuid-runtime
- clang-format-9
- uuid-dev
- uuid-runtime

before_script:
- clang-format --version

matrix:
include:
- env: BUILD=1
compiler: clang
- env: BUILD=1
compiler: gcc
- env: FORMAT=1

script:
- make
- if [ -n "$BUILD" ]; then make; fi
- |
if [ -n "$FORMAT" ]; then
clang-format -i sml/include/sml/* sml/src/*
test -z "$(git status --porcelain)" || (git status; git diff; false)
fi
9 changes: 3 additions & 6 deletions sml/include/sml/sml_attention_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,21 @@
// along with libSML. If not, see <http://www.gnu.org/licenses/>.

#ifndef SML_ATTENTION_RESPONSE_H_
#define SML_ATTENTION_RESPONSE_H_
#define SML_ATTENTION_RESPONSE_H_

#include "sml_shared.h"
#include "sml_octet_string.h"
#include "sml_shared.h"
#include "sml_tree.h"

#ifdef __cplusplus
extern "C" {
#endif


typedef struct {
octet_string *server_id;
octet_string *attention_number;
octet_string *attention_message; // optional
sml_tree *attention_details; // optional
sml_tree *attention_details; // optional
} sml_attention_response;

sml_attention_response *sml_attention_response_init();
Expand All @@ -44,6 +43,4 @@ void sml_attention_response_free(sml_attention_response *msg);
}
#endif


#endif /* SML_ATTENTION_RESPONSE_H_ */

4 changes: 1 addition & 3 deletions sml/include/sml/sml_boolean.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// along with libSML. If not, see <http://www.gnu.org/licenses/>.

#ifndef SML_BOOLEAN_H_
#define SML_BOOLEAN_H_
#define SML_BOOLEAN_H_

#define SML_BOOLEAN_TRUE 0xFF
#define SML_BOOLEAN_FALSE 0x00
Expand All @@ -39,6 +39,4 @@ void sml_boolean_free(sml_boolean *b);
}
#endif


#endif /* SML_BOOLEAN_H_ */

6 changes: 2 additions & 4 deletions sml/include/sml/sml_close_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#ifndef SML_CLOSE_REQUEST_H_
#define SML_CLOSE_REQUEST_H_

#include "sml_shared.h"
#include "sml_octet_string.h"
#include "sml_shared.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -31,14 +31,12 @@ typedef struct {
} sml_close_request;

sml_close_request *sml_close_request_init();
sml_close_request * sml_close_request_parse(sml_buffer *buf);
sml_close_request *sml_close_request_parse(sml_buffer *buf);
void sml_close_request_write(sml_close_request *msg, sml_buffer *buf);
void sml_close_request_free(sml_close_request *msg);

#ifdef __cplusplus
}
#endif


#endif /* SML_CLOSE_REQUEST_H_ */

2 changes: 0 additions & 2 deletions sml/include/sml/sml_close_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ void sml_close_response_free(sml_close_response *msg);
}
#endif


#endif /* SML_CLOSE_RESPONSE_H_ */

6 changes: 2 additions & 4 deletions sml/include/sml/sml_crc16.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ extern "C" {
#endif

// CRC16 FSC implementation based on DIN 62056-46
u16 sml_crc16_calculate(unsigned char *cp, int len) ;
u16 sml_crc16_calculate(unsigned char *cp, int len);

// CRC-16/CCITT(Kermit) implementation poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000
u16 sml_crc16kermit_calculate(unsigned char *cp, int len) ;
u16 sml_crc16kermit_calculate(unsigned char *cp, int len);

#ifdef __cplusplus
}
#endif


#endif /* SML_CRC16_H_ */

10 changes: 4 additions & 6 deletions sml/include/sml/sml_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// along with libSML. If not, see <http://www.gnu.org/licenses/>.

#ifndef SML_FILE_H_
#define SML_FILE_H_
#define SML_FILE_H_

#include "sml_message.h"
#include "sml_shared.h"
Expand All @@ -29,9 +29,9 @@ extern "C" {

// a SML file consist of multiple SML messages
typedef struct {
sml_message **messages;
short messages_len;
sml_buffer *buf;
sml_message **messages;
short messages_len;
sml_buffer *buf;
} sml_file;

sml_file *sml_file_init();
Expand All @@ -46,6 +46,4 @@ void sml_file_print(sml_file *file);
}
#endif


#endif /* SML_FILE_H_ */

16 changes: 7 additions & 9 deletions sml/include/sml/sml_get_list_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
#ifndef SML_GET_LIST_REQUEST_H_
#define SML_GET_LIST_REQUEST_H_

#include "sml_shared.h"
#include "sml_list.h"
#include "sml_octet_string.h"
#include "sml_shared.h"
#include "sml_time.h"
#include "sml_list.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
octet_string *client_id;
octet_string *server_id; // optional
octet_string *username; // optional
octet_string *password; // optional
octet_string *list_name; // optional
octet_string *server_id; // optional
octet_string *username; // optional
octet_string *password; // optional
octet_string *list_name; // optional
} sml_get_list_request;

sml_get_list_request* sml_get_list_request_init();
sml_get_list_request *sml_get_list_request_init();
sml_get_list_request *sml_get_list_request_parse(sml_buffer *buf);
void sml_get_list_request_write(sml_get_list_request *msg, sml_buffer *buf);
void sml_get_list_request_free(sml_get_list_request *msg);
Expand All @@ -45,6 +45,4 @@ void sml_get_list_request_free(sml_get_list_request *msg);
}
#endif


#endif /* SML_GET_LIST_REQUEST_H_ */

12 changes: 5 additions & 7 deletions sml/include/sml/sml_get_list_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
#ifndef SML_GET_LIST_RESPONSE_H_
#define SML_GET_LIST_RESPONSE_H_

#include "sml_shared.h"
#include "sml_list.h"
#include "sml_octet_string.h"
#include "sml_shared.h"
#include "sml_time.h"
#include "sml_list.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
octet_string *client_id; // optional
octet_string *client_id; // optional
octet_string *server_id;
octet_string *list_name; // optional
octet_string *list_name; // optional
sml_time *act_sensor_time; // optional
sml_list *val_list;
sml_signature *list_signature; // optional
sml_time *act_gateway_time; // optional
sml_time *act_gateway_time; // optional
} sml_get_list_response;

sml_get_list_response *sml_get_list_response_init();
Expand All @@ -47,6 +47,4 @@ void sml_get_list_response_free(sml_get_list_response *msg);
}
#endif


#endif /* SML_GET_LIST_RESPONSE_H_ */

14 changes: 6 additions & 8 deletions sml/include/sml/sml_get_proc_parameter_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
#ifndef SML_GET_PROC_PARAMETER_REQUEST_H_
#define SML_GET_PROC_PARAMETER_REQUEST_H_

#include "sml_shared.h"
#include "sml_octet_string.h"
#include "sml_shared.h"
#include "sml_tree.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
octet_string *server_id; // optional
octet_string *username; // optional
octet_string *password; // optional
sml_tree_path *parameter_tree_path;
octet_string *attribute; // optional
octet_string *server_id; // optional
octet_string *username; // optional
octet_string *password; // optional
sml_tree_path *parameter_tree_path;
octet_string *attribute; // optional
} sml_get_proc_parameter_request;

sml_get_proc_parameter_request *sml_get_proc_parameter_request_init();
Expand All @@ -44,6 +44,4 @@ void sml_get_proc_parameter_request_free(sml_get_proc_parameter_request *msg);
}
#endif


#endif /* SML_GET_PROC_PARAMETER_REQUEST_H_ */

4 changes: 1 addition & 3 deletions sml/include/sml/sml_get_proc_parameter_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#ifndef SML_GET_PROC_PARAMETER_RESPONSE_H_
#define SML_GET_PROC_PARAMETER_RESPONSE_H_

#include "sml_shared.h"
#include "sml_octet_string.h"
#include "sml_shared.h"
#include "sml_tree.h"

#ifdef __cplusplus
Expand All @@ -42,6 +42,4 @@ void sml_get_proc_parameter_response_free(sml_get_proc_parameter_response *msg);
}
#endif


#endif /* SML_GET_PROC_PARAMETER_RESPONSE_H_ */

2 changes: 0 additions & 2 deletions sml/include/sml/sml_get_profile_list_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@ typedef sml_get_profile_pack_request sml_get_profile_list_request;
}
#endif


#endif /* SML_GET_PROFILE_LIST_REQUEST_H_ */

6 changes: 2 additions & 4 deletions sml/include/sml/sml_get_profile_list_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#ifndef SML_GET_PROFILE_LIST_RESPONSE_H_
#define SML_GET_PROFILE_LIST_RESPONSE_H_

#include "sml_shared.h"
#include "sml_list.h"
#include "sml_octet_string.h"
#include "sml_shared.h"
#include "sml_time.h"
#include "sml_list.h"
#include "sml_tree.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -50,6 +50,4 @@ void sml_get_profile_list_response_free(sml_get_profile_list_response *msg);
}
#endif


#endif /* SML_GET_PROFILE_LIST_RESPONSE_H_ */

21 changes: 9 additions & 12 deletions sml/include/sml/sml_get_profile_pack_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#ifndef SML_GET_PROFILE_PACK_REQUEST_H_
#define SML_GET_PROFILE_PACK_REQUEST_H_

#include "sml_shared.h"
#include "sml_list.h"
#include "sml_octet_string.h"
#include "sml_shared.h"
#include "sml_time.h"
#include "sml_list.h"
#include "sml_tree.h"

#ifdef __cplusplus
Expand All @@ -42,18 +42,17 @@ typedef struct sml_obj_req_entry_list_entry {
} sml_obj_req_entry_list;

typedef struct {
octet_string *server_id; // optional
octet_string *username; // optional
octet_string *password; // optional
sml_boolean *with_rawdata; // optional
sml_time *begin_time; // optional
sml_time *end_time; // optional
octet_string *server_id; // optional
octet_string *username; // optional
octet_string *password; // optional
sml_boolean *with_rawdata; // optional
sml_time *begin_time; // optional
sml_time *end_time; // optional
sml_tree_path *parameter_tree_path;
sml_obj_req_entry_list *object_list; // optional
sml_tree *das_details; // optional
sml_tree *das_details; // optional
} sml_get_profile_pack_request;


sml_get_profile_pack_request *sml_get_profile_pack_request_parse(sml_buffer *buf);
sml_get_profile_pack_request *sml_get_profile_pack_request_init();
void sml_get_profile_pack_request_write(sml_get_profile_pack_request *msg, sml_buffer *buf);
Expand All @@ -63,6 +62,4 @@ void sml_get_profile_pack_request_free(sml_get_profile_pack_request *msg);
}
#endif


#endif /* SML_GET_PROFILE_PACK_REQUEST_H_ */

Loading

0 comments on commit b19a2a4

Please sign in to comment.