-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterject.c
More file actions
180 lines (166 loc) · 5.92 KB
/
interject.c
File metadata and controls
180 lines (166 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* 'interject': interject for a moment
* Copyright (C) 2016-2017 Alexei Frolov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
/* the name of the program */
static const char *PROG_NAME = "interject";
/* all modifiable components */
static const char *osname = "Linux";
static const char *gnu = "GNU";
static const char *operating = "operating system";
static const char *useful = "GNU corelibs, shell utilities and vital "
"system components";
static const char *os = "OS";
static const char *defined = "POSIX";
static const char *developed = "GNU Project";
static const char *kernel = "kernel";
static const char *description = "the program in the system that allocates the "
"machine's resources to the other programs "
"that you run";
static int head = 0;
static void interject(void);
static int isvowel(char c);
static void usage(const char *s, FILE *f);
int main(int argc, char **argv)
{
int c;
static struct option long_opts[] = {
{ "description", required_argument, 0, 'c' },
{ "defined", required_argument, 0, 'd' },
{ "developed", required_argument, 0, 'e' },
{ "gnu", required_argument, 0, 'g' },
{ "head", no_argument, 0, 'h' },
{ "help", no_argument, 0, 'H' },
{ "kernel", required_argument, 0, 'k' },
{ "operating", required_argument, 0, 'o' },
{ "os", required_argument, 0, 'p' },
{ "useful", required_argument, 0, 'u' },
{ "version", no_argument, 0, 'v' },
{ 0, 0, 0, 0 }
};
while ((c = getopt_long(argc, argv, "hvH", long_opts, NULL)) != EOF) {
switch (c) {
case 'c':
description = optarg;
break;
case 'd':
defined = optarg;
break;
case 'e':
developed = optarg;
break;
case 'g':
gnu = optarg;
break;
case 'h':
head = 1;
break;
case 'k':
kernel = optarg;
break;
case 'o':
operating = optarg;
break;
case 'p':
os = optarg;
break;
case 'u':
useful = optarg;
break;
case 'v':
printf("%s v0.1.0\nCopyright (C) 2016 Alexei Frolov\n"
"This program is distributed as free "
"software under the\nterms of the GNU "
"General Public License, version 3\n",
PROG_NAME);
return EXIT_SUCCESS;
case 'H':
usage(PROG_NAME, stdout);
return EXIT_SUCCESS;
default:
usage(argv[0], stderr);
return EXIT_FAILURE;
}
}
if (optind != argc) {
if (optind == argc - 1) {
osname = argv[optind];
} else {
usage(argv[0], stderr);
return EXIT_FAILURE;
}
}
interject();
putchar('\n');
return EXIT_SUCCESS;
}
/* interject for a moment */
static void interject(void)
{
printf("I'd just like to interject for a moment. What you're ");
printf("referring to as %s, is in fact, %s/%s, ", osname, gnu, osname);
printf("or as I've recently taken to calling it, %s plus %s. ",
gnu, osname);
if (head)
return;
printf("%s is not a%s %s unto itself ", osname,
isvowel(operating[0]) ? "n" : "", operating);
printf("but rather another free component of a fully functioning "
"%s system made useful by the %s ", gnu, useful);
printf("comprising a full %s as defined by %s. ", os, defined);
printf("Many computer users run a modified version of the %s system "
"every day, without realizing it. ", gnu);
printf("Through a peculiar turn of events, the version of %s which is "
"widely used today is often called \"%s\"", gnu, osname);
printf(", and many of its users are not aware that it is basically the "
"%s system, developed by the %s. ", gnu, developed);
printf("There really is a %s, and these people are using it, but it is "
"just a part of the system they use. ", osname);
printf("%s is the %s: %s. ", osname, kernel, description);
printf("The %s is an essential part of a%s %s, ", kernel,
isvowel(operating[0]) ? "n" : "", operating);
printf("but useless by itself; it can only function within the "
"context of a complete %s. ", operating);
printf("%s is normally used in combination with the %s %s: the whole "
"system is basically %s with %s added, or %s/%s", osname,
gnu, operating, gnu, osname, gnu, osname);
printf(". All these so-called \"%s\" distributions are really "
"distributions of %s/%s.", osname, gnu, osname);
}
static int isvowel(char c)
{
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
static void usage(const char *s, FILE *f)
{
fprintf(f, "usage: %s [OPTION]... [SYSTEM]\n", s);
fprintf(f, "interject that SYSTEM is really GNU/SYSTEM\n\n");
fprintf(f, "\t--description=DESC\n\t\tLinux is the kernel: DESC\n");
fprintf(f, "\t--defined=DEF\n\t\tfull OS as defined by DEF\n");
fprintf(f, "\t--developed=DEV\n\t\tthe GNU system, developed by DEV\n");
fprintf(f, "\t--gnu=GNU\n\t\tset the proper system prefix\n");
fprintf(f, "\t-h, --head\n\t\tprint only the first sentence\n");
fprintf(f, "\t-H, --help\n\t\tdisplay this help text and exit\n");
fprintf(f, "\t--kernel=KERN\n\t\tLinux is the KERN\n");
fprintf(f, "\t--operating=OPER\n\t\tLinux is not an OPER unto itself\n");
fprintf(f, "\t--os=OSYS\n\t\tcomrpising a full OSYS as defined by\n");
fprintf(f, "\t--useful=USE\n\t\tfully functioning GNU system made "
"useful by the USE\n");
fprintf(f, "\t-v, --version\n\t\tdisplay version information and exit\n");
}