v4.0.2-rc - modify return values for some functions
This commit is contained in:
parent
7d495ec7b6
commit
d10dcd190b
16
Makefile
16
Makefile
@ -1,5 +1,9 @@
|
||||
include config.mk
|
||||
|
||||
COLOR_GREEN=\033[0;32m
|
||||
COLOR_BLUE=\033[0;34m
|
||||
COLOR_RESET=\033[0m
|
||||
|
||||
all:
|
||||
@echo "Run 'make test' for the test binary, or 'make lib' to generate a static library."
|
||||
@echo "Run 'make help' for a full list of options."
|
||||
@ -22,11 +26,15 @@ lib:
|
||||
$(AR) -rc build/lib/libglacier.a build/lib/libglacier.o
|
||||
|
||||
install:
|
||||
@echo "$(COLOR_BLUE)[i]$(COLOR_RESET) Installing static library to $(PREFIX)/lib..."
|
||||
install lib/libglacier.a $(PREFIX)/lib
|
||||
install include/glacier_config.h $(PREFIX)/include
|
||||
install include/glacier_log.h $(PREFIX)/include
|
||||
install include/glacier_pkgops.h $(PREFIX)/include
|
||||
install include/glacier_runtime.h $(PREFIX)/include
|
||||
install include/config.h $(PREFIX)/include/glacier
|
||||
install include/data.h $(PREFIX)/include/glacier
|
||||
install include/log.h $(PREFIX)/include/glacier
|
||||
install include/pkgops.h $(PREFIX)/include/glacier
|
||||
install include/runtime.h $(PREFIX)/include/glacier
|
||||
install include/security.h $(PREFIX)/include/glacier
|
||||
@echo "$(COLOR_GREEN)[*]$(COLOR_RESET) Finished installing static library to $(PREFIX)/lib."
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* glacier.h - Function declarations for libglacier
|
||||
* config.h - Function declarations for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* glacier_log.h - Data structures for libglacier
|
||||
* data.h - Data structures for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
33
include/globals.h
Normal file
33
include/globals.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* globals.h - Global variables for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GLOBALS_H_
|
||||
#define GLOBALS_H_
|
||||
|
||||
extern config_t cfg;
|
||||
extern config_setting_t *setting;
|
||||
extern const char str;
|
||||
|
||||
extern const char *GLACIER_REPO;
|
||||
extern const char *GLACIER_ARCH;
|
||||
extern const char *GLACIER_TARGET;
|
||||
extern const char *GLACIER_LOCALDB;
|
||||
extern const char *GLACIER_SYSTEM_PROFILE;
|
||||
|
||||
const char *runtime_files[];
|
||||
|
||||
#endif
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* glacier_log.h - Logging function declarations for libglacier
|
||||
* log.h - Logging function declarations for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* glacier_pkgops.h - Package-related function declarations for libglacier
|
||||
* pkgops.h - Package-related function declarations for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* glacier_runtime.h - Runtime function declarations for libglacier
|
||||
* runtime.h - Runtime function declarations for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* glacier_runtime.h - Runtime function declarations for libglacier
|
||||
* security.h - Runtime function declarations for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* GNU Lesser General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||
* You should have received a copy of the GNU Lesser General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
27
libglacier.c
27
libglacier.c
@ -20,6 +20,7 @@
|
||||
#include <errno.h>
|
||||
#include <libconfig.h>
|
||||
#include <locale.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -30,6 +31,7 @@
|
||||
#include <wchar.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "include/globals.h"
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
#define MAX_CHILDREN 64
|
||||
@ -648,5 +650,30 @@ run_make_task(char TASK[])
|
||||
int
|
||||
compare_file_hash(char ORIG_HASH[], char FILE[])
|
||||
{
|
||||
FILE *pkg;
|
||||
|
||||
pkg = fopen(FILE, "rb");
|
||||
if (pkg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned char hash[SHA256_DIGEST_LENGTH];
|
||||
SHA256_CTX sha256;
|
||||
|
||||
SHA256_Init(&sha256);
|
||||
|
||||
const int hashBufferSize = 1024;
|
||||
unsigned char hashBuffer[hashBufferSize];
|
||||
int bytesRead;
|
||||
|
||||
while ((byesRead = fread(hashBuffer, 1, hashBufferSize, pkg)) != 0) {
|
||||
SHA256_Update(&sha256, hashBuffer, bytesRead);
|
||||
}
|
||||
|
||||
SHA256_Final(hash, &sha256);
|
||||
fclose(pkg);
|
||||
|
||||
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
|
||||
printf("%02x", hash[i]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user