format code by clang-format
This commit is contained in:
parent
13ca75a3bf
commit
7812b19878
@ -2,7 +2,7 @@ root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
@ -10,8 +10,10 @@ insert_final_newline = true
|
||||
|
||||
[{*.c,*.h}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[.gitmodules]
|
||||
indent_style = tab
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
> This project use Semantic Versioning 2.0.0 https://semver.org/
|
||||
|
||||
## 31/07/2023 - (1.0.3)
|
||||
- ♻️ - Format code via `clang-format --style=LLVM`
|
||||
|
||||
## 31/07/2023 - (1.0.2)
|
||||
- ♻️ - Update software executable name
|
||||
- ♻️ - Update Makefile
|
||||
|
10
format-code
Executable file
10
format-code
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
files=(
|
||||
"src/main.c"
|
||||
)
|
||||
|
||||
for file in "${files[@]}"
|
||||
do
|
||||
clang-format -i --style=LLVM --sort-includes=false $file
|
||||
done
|
45
src/main.c
45
src/main.c
@ -12,11 +12,10 @@
|
||||
|
||||
void usage();
|
||||
void info(cJSON *json);
|
||||
void generate_library_list(cJSON * input_json, cJSON * output_json, char output_system);
|
||||
void generate_library_list(cJSON *input_json, cJSON *output_json,
|
||||
char output_system);
|
||||
|
||||
int
|
||||
main(int argc, char const * argv[])
|
||||
{
|
||||
int main(int argc, char const *argv[]) {
|
||||
if (argc != 3) {
|
||||
usage();
|
||||
} else {
|
||||
@ -67,11 +66,9 @@ main(int argc, char const * argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
printf("%s\n%s: %s\n\n", "Minecraft Libraries List Generator",
|
||||
"Version", VERSION);
|
||||
void usage() {
|
||||
printf("%s\n%s: %s\n\n", "Minecraft Libraries List Generator", "Version",
|
||||
VERSION);
|
||||
printf("%s\n", "Usage:");
|
||||
printf(" %s\n\n", "mc-libs-string <version.json> <system>");
|
||||
printf(" %s\n\n", "<system> - w|l|x (windows or linux or osx)");
|
||||
@ -79,13 +76,13 @@ usage()
|
||||
printf(" %s\n", "mc-libs-string <version.json> i - to get version info");
|
||||
}
|
||||
|
||||
void
|
||||
info(cJSON * json)
|
||||
{
|
||||
char *minecraft_version = cJSON_GetStringValue(cJSON_GetObjectItem(json, "id"));
|
||||
void info(cJSON *json) {
|
||||
char *minecraft_version =
|
||||
cJSON_GetStringValue(cJSON_GetObjectItem(json, "id"));
|
||||
printf("Minecraft Version: %s\n", minecraft_version);
|
||||
|
||||
char *assets_version = cJSON_GetStringValue(cJSON_GetObjectItem(json, "assets"));
|
||||
char *assets_version =
|
||||
cJSON_GetStringValue(cJSON_GetObjectItem(json, "assets"));
|
||||
printf("Minecraft Assets Version: %s\n", assets_version);
|
||||
|
||||
cJSON *libraries = cJSON_GetObjectItem(json, "libraries");
|
||||
@ -93,9 +90,8 @@ info(cJSON * json)
|
||||
printf("Minecraft libraries count: %d\n", libraries_array_size);
|
||||
}
|
||||
|
||||
void
|
||||
generate_library_list(cJSON * input_json, cJSON * output_json, char output_system)
|
||||
{
|
||||
void generate_library_list(cJSON *input_json, cJSON *output_json,
|
||||
char output_system) {
|
||||
cJSON *input_libraries = cJSON_GetObjectItem(input_json, "libraries");
|
||||
cJSON *output_libraries = cJSON_GetObjectItem(output_json, "libraries");
|
||||
int libraries_array_size = cJSON_GetArraySize(input_libraries);
|
||||
@ -124,17 +120,22 @@ generate_library_list(cJSON * input_json, cJSON * output_json, char output_syste
|
||||
cJSON *rules = cJSON_GetObjectItem(library, "rules");
|
||||
cJSON *rules_item = cJSON_GetArrayItem(rules, 0);
|
||||
cJSON *os_type = cJSON_GetObjectItem(rules_item, "os");
|
||||
char *os_name = cJSON_GetStringValue(cJSON_GetObjectItem(os_type, "name"));
|
||||
char *os_name =
|
||||
cJSON_GetStringValue(cJSON_GetObjectItem(os_type, "name"));
|
||||
|
||||
if (os_name != 0) {
|
||||
char *library_path = cJSON_GetStringValue(cJSON_GetObjectItem(artifact, "path"));
|
||||
char *library_path =
|
||||
cJSON_GetStringValue(cJSON_GetObjectItem(artifact, "path"));
|
||||
|
||||
if (strcmp(output_system_name, os_name) == 0) {
|
||||
cJSON_AddItemToArray(output_libraries, cJSON_CreateString(library_path));
|
||||
cJSON_AddItemToArray(output_libraries,
|
||||
cJSON_CreateString(library_path));
|
||||
}
|
||||
} else {
|
||||
char *library_path = cJSON_GetStringValue(cJSON_GetObjectItem(artifact, "path"));
|
||||
cJSON_AddItemToArray(output_libraries, cJSON_CreateString(library_path));
|
||||
char *library_path =
|
||||
cJSON_GetStringValue(cJSON_GetObjectItem(artifact, "path"));
|
||||
cJSON_AddItemToArray(output_libraries,
|
||||
cJSON_CreateString(library_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user