Cleanup and buildup
This commit is contained in:
parent
c0cf20b869
commit
6b8d91e94c
BIN
bin/install
BIN
bin/install
Binary file not shown.
@ -6,11 +6,12 @@
|
||||
#define DEBUG_H
|
||||
|
||||
#include "nprint.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef debugEnabled
|
||||
#define DEBUG_PRINT(fmt, ...) nprint("D", fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT(fmg, ...) void(0)
|
||||
#define DEBUG_PRINT(fmt, ...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#endif //DEBUG_H
|
||||
|
13
inc/fex.h
13
inc/fex.h
@ -7,14 +7,15 @@
|
||||
|
||||
enum Flags {
|
||||
FLAG_INSTALL = 1 << 0,
|
||||
FLAG_SOURCE = 1 << 1,
|
||||
FLAG_UNINSTALL = 1 << 2,
|
||||
FLAG_LIST = 1 << 3,
|
||||
FLAG_SEARCH = 1 << 4,
|
||||
FLAG_FORCE = 1 << 5,
|
||||
FLAG_UPGRADE = 1 << 6,
|
||||
//FLAG_SOURCE = 1 << 1,
|
||||
//FLAG_UNINSTALL = 1 << 1,
|
||||
FLAG_LIST = 1 << 1,
|
||||
FLAG_SEARCH = 1 << 2,
|
||||
FLAG_FORCE = 1 << 3,
|
||||
FLAG_UPGRADE = 1 << 4,
|
||||
};
|
||||
|
||||
extern char* flagNames[];
|
||||
extern int flagSource, flagUninstall;
|
||||
|
||||
#endif //FEX_H
|
||||
|
10
inc/install.h
Normal file
10
inc/install.h
Normal file
@ -0,0 +1,10 @@
|
||||
//
|
||||
// Created by auric on 2/28/24.
|
||||
//
|
||||
|
||||
#ifndef INSTALL_H
|
||||
#define INSTALL_H
|
||||
|
||||
int installPackages(char** package, int pkgCount, int source, int uninstall);
|
||||
|
||||
#endif //INSTALL_H
|
BIN
obj/install.o
BIN
obj/install.o
Binary file not shown.
BIN
obj/sanity.o
BIN
obj/sanity.o
Binary file not shown.
38
src/fex.c
38
src/fex.c
@ -5,22 +5,25 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <nprint.h>
|
||||
#include <sanity.h>
|
||||
#include "sanity.h"
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
#include "fex.h"
|
||||
#include "install.h"
|
||||
|
||||
void help() {
|
||||
nprint("E", "Usage: fex (OPT) (PACKAGES)");
|
||||
}
|
||||
|
||||
char* flagNames[] = {"INSTALL", "SOURCE", "UNINSTALL", "LIST", "SEARCH", "FORCE", "UPGRADE"};
|
||||
char* flagNames[] = {"INSTALL","LIST", "SEARCH", "FORCE", "UPGRADE"};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
unsigned int flags = 0;
|
||||
char* packages[argc - 1];
|
||||
int pkgCount = 0;
|
||||
int flagSource, flagUninstall = 0;
|
||||
|
||||
if (argc < 2) {
|
||||
help();
|
||||
@ -35,10 +38,12 @@ int main(int argc, char** argv) {
|
||||
flags |= FLAG_INSTALL;
|
||||
break;
|
||||
case 'S': // source, 1
|
||||
flags |= FLAG_SOURCE;
|
||||
//flags |= FLAG_SOURCE;
|
||||
flagSource = 1;
|
||||
break;
|
||||
case 'r': // remove, 2
|
||||
flags |= FLAG_UNINSTALL;
|
||||
//flags |= FLAG_UNINSTALL;
|
||||
flagUninstall = 1;
|
||||
break;
|
||||
case 'l': // list, 3
|
||||
flags |= FLAG_LIST;
|
||||
@ -69,7 +74,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
#ifdef debugEnabled
|
||||
DEBUG_PRINT("sysSanity: %d", sysSanity);
|
||||
unsigned int flagValues[] = {0b0000001, 0b0000010, 0b0000100, 0b0001000, 0b0010000, 0b0100000, 0b1000000};
|
||||
unsigned int flagValues[] = {0b00001, 0b00010, 0b00100, 0b01000, 0b10000};
|
||||
int numFlags = sizeof(flagValues) / sizeof(flagValues[0]);
|
||||
for(int i = 0; i < numFlags; i++) {
|
||||
if (flags & flagValues[i]) {
|
||||
@ -86,9 +91,26 @@ int main(int argc, char** argv) {
|
||||
/* End Prelogic */
|
||||
DEBUG_PRINT("[!] Break parselogic");
|
||||
|
||||
for(int i = 0; i < numFlags; i++) {
|
||||
DEBUG_PRINT("Iterating over %s", flagNames[i]);
|
||||
|
||||
if(flags & FLAG_LIST) {
|
||||
DEBUG_PRINT("HIT: List");
|
||||
// list packages
|
||||
}
|
||||
if(flags & FLAG_SEARCH) {
|
||||
DEBUG_PRINT("HIT: Search");
|
||||
// search packages
|
||||
}
|
||||
if(!(getuid())) {
|
||||
if (flags & FLAG_INSTALL) {
|
||||
DEBUG_PRINT("HIT: Install. Source: %d; Uninstall: %d", flagSource, flagUninstall);
|
||||
installPackages(packages, pkgCount, flagSource, flagUninstall);
|
||||
}
|
||||
if(flags & FLAG_UPGRADE) {
|
||||
DEBUG_PRINT("HIT: Upgrade");
|
||||
//upgrade
|
||||
}
|
||||
} else {
|
||||
nprint("E", "Superuser permissions required for this operation.");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -2,14 +2,11 @@
|
||||
Created by auric on 2/21/24.
|
||||
|
||||
*/
|
||||
#include "../inc/debug.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <nprint.h>
|
||||
/* Prototype main for suite instead of a unified manager. Obviously never developed
|
||||
int main() {
|
||||
nprint("I", "Information");
|
||||
int installPackages(char** packages, int pkgCount, int source, int uninstall) {
|
||||
for(int i = 0; i < pkgCount; i++) {
|
||||
DEBUG_PRINT("PACKAGE: %s", packages[i]);
|
||||
DEBUG_PRINT("pkgCount ('i'): %d", i);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
10
src/sanity.c
10
src/sanity.c
@ -13,8 +13,6 @@
|
||||
* exist, and if the owner can write to them. This notably does not check if the program is run as superuser.
|
||||
*/
|
||||
|
||||
/* For a root check - simply use conditional checking for a zero value in some way, such as !(getuid()) */
|
||||
|
||||
int isSysSane() {
|
||||
struct stat conStat, exeStat, utiStat, libStat, hdrStat;
|
||||
int result = 0;
|
||||
@ -34,12 +32,12 @@ int isSysSane() {
|
||||
}
|
||||
|
||||
int isSyntaxSane(unsigned int flags, int pkgCount) {
|
||||
if((flags & FLAG_INSTALL) && (flags & FLAG_UNINSTALL)) {
|
||||
nprint("E", "You cannot install and uninstall at the same time"); // TODO: allow for this to happen by parsing the flags in order. e.g fex -i japes -u japes2 should install japes and uninstall japes2
|
||||
/*if((flags & FLAG_INSTALL)) {
|
||||
nprint("E", "You cannot install and uninstall at the same time"); // Sequential parsing of flags would leave so many ambiguous cases and expand these checks greatly. Not worth it without extensive research
|
||||
return 1;
|
||||
}
|
||||
}*/
|
||||
|
||||
if(((flags & FLAG_INSTALL) || (flags & FLAG_UNINSTALL)) && (pkgCount == 0)) {
|
||||
if((flags & FLAG_INSTALL) && (pkgCount == 0)) {
|
||||
nprint("E", "You must specify at least one package");
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user