Begin writing it...
Better late than never
This commit is contained in:
commit
969f4e26b8
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
18
.idea/misc.xml
Normal file
18
.idea/misc.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MakefileSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<MakefileProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="version" value="2" />
|
||||
</MakefileProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
31
Makefile
Normal file
31
Makefile
Normal file
@ -0,0 +1,31 @@
|
||||
SRCd := src
|
||||
BINd := bin
|
||||
OBJd := obj
|
||||
INCd := inc
|
||||
CC = gcc
|
||||
LDFLAGS =
|
||||
CFLAGS = -Iinclude -Iinc -Wall -O2 -g
|
||||
|
||||
SRC = $(wildcard $(SRCd)/*.c)
|
||||
OBJ = $(SRC:$(SRCd)/%.c=$(OBJd)/%.o)
|
||||
TARGETS = $(SRC:$(SRCd)/%.c=$(BINd)/%)
|
||||
|
||||
main: $(OBJ) $(OBJd)/nprint.o # The option of a single program instead of a suite. WARN: Requires modification of source to remove multiple main()
|
||||
$(CC) $(LDFLAGS) -o $(BINd)/fex $^
|
||||
|
||||
multi: $(TARGETS)
|
||||
|
||||
$(BINd)/%: $(OBJd)/%.o $(OBJd)/nprint.o
|
||||
$(CC) $(LDFLAGS) -o $@ $^
|
||||
|
||||
$(OBJd)/%.o: $(SRCd)/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJd)/nprint.o: $(INCd)/nprint.c $(INCd)/nprint.h
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
clean:
|
||||
rm -f $(OBJd)/*.o $(BINd)/*
|
||||
|
||||
.PHONY: all clean
|
BIN
bin/install
Executable file
BIN
bin/install
Executable file
Binary file not shown.
49
inc/nprint.c
Normal file
49
inc/nprint.c
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// Created by auric on 2/21/24.
|
||||
//
|
||||
|
||||
#include "nprint.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void nprint(const char *tag, const char *format, ...) {
|
||||
const char *color = "";
|
||||
const char *bgcolor = "";
|
||||
const char *reset = "\033[0m";
|
||||
va_list args;
|
||||
|
||||
switch(*tag) {
|
||||
case 'X':
|
||||
color = "\033[1;30m";
|
||||
bgcolor = "\033[43m";
|
||||
break;
|
||||
case 'E':
|
||||
color = "\033[1;31m";
|
||||
break;
|
||||
case 'S':
|
||||
color = "\033[1;32m";
|
||||
break;
|
||||
case 'W':
|
||||
color = "\033[1;33m";
|
||||
break;
|
||||
case 'I':
|
||||
color = "\033[1;34m";
|
||||
break;
|
||||
case 'D':
|
||||
color = "\033[1;35m";
|
||||
break;
|
||||
case 'Y':
|
||||
color = "\033[1;35m";
|
||||
bgcolor = "\033[43m";
|
||||
break;
|
||||
default:
|
||||
color = "\033[1m";
|
||||
}
|
||||
|
||||
printf("[%s%s%s%s] ", bgcolor, color, tag, reset);
|
||||
|
||||
va_start(args, format);
|
||||
vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
printf("\n");
|
||||
}
|
12
inc/nprint.h
Normal file
12
inc/nprint.h
Normal file
@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by auric on 2/21/24.
|
||||
//
|
||||
|
||||
#ifndef NPRINT_H
|
||||
#define NPRINT_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
void nprint(const char *tag, const char *format, ...);
|
||||
|
||||
#endif //NPRINT_H
|
12
inc/sanity.h
Normal file
12
inc/sanity.h
Normal file
@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by auric on 2/22/24.
|
||||
//
|
||||
|
||||
#ifndef SANITY_H
|
||||
#define SANITY_H
|
||||
|
||||
# include <stdbool.h>
|
||||
|
||||
int sanity_check();
|
||||
|
||||
#endif //SANITY_H
|
BIN
obj/install.o
Normal file
BIN
obj/install.o
Normal file
Binary file not shown.
BIN
obj/nprint.o
Normal file
BIN
obj/nprint.o
Normal file
Binary file not shown.
BIN
obj/sanity.o
Normal file
BIN
obj/sanity.o
Normal file
Binary file not shown.
36
src/fex.c
Normal file
36
src/fex.c
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// Created by auric on 2/21/24.
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <nprint.h>
|
||||
|
||||
char* opt = NULL;
|
||||
void help() {
|
||||
nprint("E", "Usage: fex (OPT) (PACKAGES)");
|
||||
}
|
||||
int main(int argc, char** argv) {
|
||||
if (argc < 2) {
|
||||
help();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argv[1][0] == '-' || argv[1][0] == '+' ) {
|
||||
opt = argv[1];
|
||||
} else {
|
||||
nprint("E", "First argument must be OPT");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (opt[0] == '+' && opt[1] != '\0') {
|
||||
nprint("D", "Placeholder");
|
||||
}
|
||||
|
||||
if (argc < 3) {
|
||||
nprint("E", "No packages specified");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
15
src/install.c
Normal file
15
src/install.c
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
Created by auric on 2/21/24.
|
||||
|
||||
*/
|
||||
|
||||
#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");
|
||||
}
|
||||
*/
|
||||
|
28
src/sanity.c
Normal file
28
src/sanity.c
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by auric on 2/22/24.
|
||||
//
|
||||
|
||||
/*
|
||||
* 0: Success
|
||||
* 1: Failure
|
||||
* 2: Root check failure
|
||||
* 3: /con check failure
|
||||
* 4: /exe check filuse
|
||||
* 5: /con and /exe check failure
|
||||
*/
|
||||
|
||||
#include <sanity.h>
|
||||
#include <unistd.h>
|
||||
|
||||
bool isSane = true;
|
||||
bool isRoot = false;
|
||||
|
||||
int sanity_check() {
|
||||
if (getuid() == 0) {
|
||||
isRoot = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user