Development

This commit is contained in:
John Barns 2024-02-23 00:33:44 -06:00
parent df159253cd
commit f8398f24a9
6 changed files with 14 additions and 31 deletions

BIN
bin/fex

Binary file not shown.

View File

@ -5,19 +5,13 @@
#ifndef SANITY_H #ifndef SANITY_H
#define SANITY_H #define SANITY_H
#include <stdbool.h>
#define SANITY_SUCCESS 0 // 0000 - All checks passed #define SANITY_SUCCESS 0 // 0000 - All checks passed
#define SANITY_CON_FAIL 1 // 0001 - /con check failed #define SANITY_CON_FAIL 1 // 0001 - /con check failed
#define SANITY_EXE_FAIL 2 // 0010 - /exe check failed #define SANITY_EXE_FAIL 2 // 0010 - /exe check failed
#define SANITY_UTI_FAIL 4 // 0100 - /uti check failed #define SANITY_UTI_FAIL 4 // 0100 - /uti check failed
#define SANITY_LIB_FAIL 8 // 1000 - /uti/lib check failed
#define SANITY_HDR_FAIL 16 // 100000 - /uti/hdr check failed
/*typedef struct { int isSysSane();
bool conEx;
bool exeEx;
bool utiEx;
} SanityCheckResult;*/
const int isSysSane();
#endif //SANITY_H #endif //SANITY_H

BIN
obj/fex.o

Binary file not shown.

Binary file not shown.

View File

@ -8,8 +8,8 @@
#include <nprint.h> #include <nprint.h>
#include <stdbool.h> #include <stdbool.h>
#include <sanity.h> #include <sanity.h>
#include <config.h> #include "config.h"
#include "debug.h"
void help() { void help() {
@ -25,9 +25,7 @@ int main(int argc, char** argv) {
return 1; return 1;
} }
const char* flagNames[] = {"Install", "Update", "Source", "Remove", "List", "Search","Verbose", "Force", "Upgrade"};
int* flagValues[] = {&fIns, &fUpd, &fSrc, &fUin, &fLis, &fSer, &fVer, &fFrc, &fUpg};
int flagCount = sizeof(flagNames) / sizeof(flagNames[0]); // This should match the number of flags
for(int i = 1; i < argc; i++) { for(int i = 1; i < argc; i++) {
if(argv[i][0] == '-') { if(argv[i][0] == '-') {
@ -73,6 +71,11 @@ int main(int argc, char** argv) {
const int sysSanity = isSysSane(); const int sysSanity = isSysSane();
#ifdef debugEnabled #ifdef debugEnabled
DEBUG_PRINT("sysSanity: %d", sysSanity);
const char* flagNames[] = {"Install", "Update", "Source", "Remove", "List", "Search","Verbose", "Force", "Upgrade"};
int* flagValues[] = {&fIns, &fUpd, &fSrc, &fUin, &fLis, &fSer, &fVer, &fFrc, &fUpg};
int flagCount = sizeof(flagNames) / sizeof(flagNames[0]); // This should match the number of flags
for(int i = 0; i < flagCount; i++) { for(int i = 0; i < flagCount; i++) {
nprint("D", "Flag %s: %d", flagNames[i], *flagValues[i]); nprint("D", "Flag %s: %d", flagNames[i], *flagValues[i]);
} }

View File

@ -1,7 +1,5 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include "../inc/sanity.h"
#include <sanity.h>
#include <nprint.h>
/* /*
* 0: success * 0: success
@ -14,34 +12,22 @@
* 7: total failure * 7: total failure
*/ */
/*SanityCheckResult isSane() { int isSysSane() {
struct stat conStat, exeStat, utiStat; struct stat conStat, exeStat, utiStat;
SanityCheckResult result = {true, true, true}; // Default to true, assume checks will pass*/ int result = 0;
struct stat conStat;
struct stat exeStat;
struct stat utiStat;
int result;
const int isSysSane() {
if (stat("/con", &conStat) != 0 || !(conStat.st_mode & S_IWUSR)) { if (stat("/con", &conStat) != 0 || !(conStat.st_mode & S_IWUSR)) {
//result.conEx = false;
result |= SANITY_CON_FAIL; result |= SANITY_CON_FAIL;
} }
if (stat("/exe", &exeStat) != 0 || !(exeStat.st_mode & S_IWUSR)) { if (stat("/exe", &exeStat) != 0 || !(exeStat.st_mode & S_IWUSR)) {
//result.exeEx = false;
result |= SANITY_EXE_FAIL; result |= SANITY_EXE_FAIL;
} }
if (stat("/uti", &utiStat) != 0 || !(utiStat.st_mode & S_IWUSR)) { if (stat("/uti", &utiStat) != 0 || !(utiStat.st_mode & S_IWUSR)) {
//result.utiEx = false;
result |= SANITY_UTI_FAIL; result |= SANITY_UTI_FAIL;
} }
/*nprint("D", "con: %d", result.conEx);
nprint("D", "exe: %d", result.exeEx);
nprint("D", "uti: %d", result.utiEx);*/
//nprint("D", "Result: %d", sumResult);
return result; return result;
} }