mpm

morphux package manager
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/mpm

commit 7166c6fc2524a5d99a4e15a6ecb7cb51b713c3f5
parent 786d0c9800d8f35d966dc535843812c8169aa0ad
Author: Louis Solofrizzo <l.solofrizzo@gmail.com>
Date:   Fri,  2 Jan 2015 18:19:08 +0100

Options sort done

Diffstat:
Msrc/Makefile.am | 5++++-
Msrc/Makefile.in | 12++++++++++--
Asrc/help.c | 12++++++++++++
Msrc/main.c | 6+++++-
Asrc/options.c | 31+++++++++++++++++++++++++++++++
Asrc/package.c | 25+++++++++++++++++++++++++
6 files changed, 87 insertions(+), 4 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am @@ -1,2 +1,5 @@ bin_PROGRAMS= mpm -mpm_SOURCES= main.c +mpm_SOURCES= main.c \ + help.c \ + options.c \ + package.c diff --git a/src/Makefile.in b/src/Makefile.in @@ -62,7 +62,8 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_mpm_OBJECTS = main.$(OBJEXT) +am_mpm_OBJECTS = main.$(OBJEXT) help.$(OBJEXT) options.$(OBJEXT) \ + package.$(OBJEXT) mpm_OBJECTS = $(am_mpm_OBJECTS) mpm_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -166,7 +167,11 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -mpm_SOURCES = main.c +mpm_SOURCES = main.c \ + help.c \ + options.c \ + package.c + all: all-am .SUFFIXES: @@ -251,7 +256,10 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/package.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/src/help.c b/src/help.c @@ -0,0 +1,12 @@ +#include "../inc/mpm.h" + +void help(void) { + printf("mpm, The Morphux Package Manager.\n"); + printf("Version: %s\n", VERSION); + printf("Actions:\n"); + printf("\tinstall: \tInstall a package\n"); + printf("\tremove: \tRemove a package\n"); + printf("\tget: \t\tGet the source of a package\n"); + printf("\tupdate: \tUpdate the packages\n"); + _exit(1); +} diff --git a/src/main.c b/src/main.c @@ -8,6 +8,10 @@ #include "../inc/mpm.h" int main(int ac, char **av) { - printf("Hi, this is %s\n", PACKAGE_STRING); + if (ac == 1) + help(); + else + get_opt(ac, av); + print_list(options.package); return 0; } diff --git a/src/options.c b/src/options.c @@ -0,0 +1,31 @@ +#include "../inc/mpm.h" + +static void _init_opt(void) { + options.install = 0; + options.remove = 0; + options.update = 0; + options.get = 0; + options.package = NULL; +} + +void get_opt(int ac, char **av) { + int i; + + _init_opt(); + for (i = 1; i < ac; i++) { + if (i == 1) { + if (!strcmp(av[i], "install")) + options.install = 1; + else if (!strcmp(av[i], "remove")) + options.remove = 1; + else if (!strcmp(av[i], "update")) + options.update = 1; + else if (!strcmp(av[i], "get")) + options.get = 1; + else + help(); + } else { + options.package = add_package(options.package, av[i]); + } + } +} diff --git a/src/package.c b/src/package.c @@ -0,0 +1,25 @@ +#include "../inc/mpm.h" + +mpm_package *add_package(mpm_package *package, char *name) { + mpm_package *tmp, *tmp2; + + tmp2 = package; + tmp = malloc(sizeof(mpm_package)); + tmp->package = name; + tmp->url = NULL; + tmp->version = 0; + tmp->next = NULL; + if (package == NULL) + return tmp; + while (tmp->next) + tmp2 = tmp2->next; + tmp2->next = tmp; + return package; +} + +void print_list(mpm_package *package) { + while (package) { + printf("%s\n", package->package); + package = package->next; + } +}