Initial commit

This commit is contained in:
2021-10-01 20:24:05 +02:00
commit 860c025165
194 changed files with 4846 additions and 0 deletions

17
kapitel15/matte/Makefile Normal file
View File

@@ -0,0 +1,17 @@
CC=cc
CFLAGS=-Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=600
matte: matte.o minmattefunk.o usage.o
$(CC) -o matte matte.o minmattefunk.o usage.o
matte.o: matte.c minmattefunk.h usage.h
$(CC) $(CFLAGS) -c matte.c
minmattefunk.o: minmattefunk.c
$(CC) $(CFLAGS) -c minmattefunk.c
usage.o: usage.c
$(CC) $(CFLAGS) -c usage.c
clean:
rm matte minmattefunk.o matte.o usage.o

34
kapitel15/matte/matte.c Normal file
View File

@@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "minmattefunk.h"
#include "usage.h"
int main(int argc, char **argv)
{
int opt;
if (argc == 1)
{
printUsage(argv[0]);
return 1;
}
while ((opt = getopt(argc, argv, "s:c:")) != -1)
{
switch (opt)
{
case 's':
printf("%d squared is %d\n", atoi(optarg),
kvadrat(atoi(optarg)));
break;
case 'c':
printf("%d cubed is %d \n", atoi(optarg),
kubik(atoi(optarg)));
break;
default:
printUsage(argv[0]);
return 1;
}
}
return 0;
}

View File

@@ -0,0 +1,9 @@
int kvadrat(int x)
{
return x*x;
}
int kubik(int x)
{
return x*x*x;
}

View File

@@ -0,0 +1,2 @@
int kvadrat(int x);
int kubik(int x);

8
kapitel15/matte/usage.c Normal file
View File

@@ -0,0 +1,8 @@
#include <stdio.h>
void printUsage(char *arg)
{
printf("Usage: %s (-s) | (-c) (integer)\n"
"-s = calculate the square of an integer\n"
"-c = calculate the cube of an integer\n", arg);
}

1
kapitel15/matte/usage.h Normal file
View File

@@ -0,0 +1 @@
void printUsage(char *arg);

View File

@@ -0,0 +1,10 @@
CC=cc
CFLAGS=-Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=600
matte: matte.o minmattefunk.o usage.o
$(CC) -o matte matte.o minmattefunk.o usage.o
matte.o: minmattefunk.h usage.h
clean:
rm matte minmattefunk.o matte.o usage.o

View File

@@ -0,0 +1,11 @@
CC=cc
CFLAGS=-Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=600
OBJS=matte.o minmattefunk.o usage.o
matte: $(OBJS)
$(CC) -o matte $(OBJS)
matte.o: minmattefunk.h usage.h
clean:
rm matte $(OBJS)

View File

@@ -0,0 +1,18 @@
CC=cc
CFLAGS=-Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=600
OBJS=matte.o minmattefunk.o usage.o
PREFIX=/usr/local
matte: $(OBJS)
$(CC) -o matte $(OBJS)
matte.o: minmattefunk.h usage.h
clean:
rm matte $(OBJS)
install:
cp matte $(DESTDIR)$(PREFIX)/bin/matte
uninstall:
rm $(DESTDIR)$(PREFIX)/bin/matte