Commiting an example use case that mimicks the movie scene in sneakers.
This commit is contained in:
parent
164d487349
commit
7bfe0b9ff5
6
Makefile
6
Makefile
@ -8,9 +8,15 @@ LDLIBS = -lncurses
|
||||
${BIN}/nms: ${OBJ}/nms.o ${OBJ}/main.o
|
||||
$(CC) -o $@ $^ $(LDLIBS)
|
||||
|
||||
sneakers: ${OBJ}/nms.o ${OBJ}/sneakers.o
|
||||
$(CC) -o ${BIN}/$@ $^ $(LDLIBS)
|
||||
|
||||
${OBJ}/main.o: ${SRC}/main.c ${SRC}/nms.h
|
||||
$(CC) -o $@ -c ${SRC}/main.c
|
||||
|
||||
${OBJ}/sneakers.o: ${SRC}/sneakers.c ${SRC}/nms.h
|
||||
$(CC) -o $@ -c ${SRC}/sneakers.c
|
||||
|
||||
${OBJ}/nms.o: ${SRC}/nms.c ${SRC}/nms.h
|
||||
$(CC) -o $@ -c ${SRC}/nms.c
|
||||
|
||||
|
159
src/sneakers.c
Normal file
159
src/sneakers.c
Normal file
@ -0,0 +1,159 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "nms.h"
|
||||
|
||||
int main(void) {
|
||||
int l, termLines, termCols, spaces = 0;
|
||||
char display[2000];
|
||||
char *head1Left = "DATANET PROC RECORD: 45-3456-W-3452";
|
||||
char *head1Right = "Transnet on/xc-3";
|
||||
char *head2Center = "FEDERAL RESERVE TRANSFER NODE";
|
||||
char *head3Center = "National Headquarters";
|
||||
char *head4Center = "************ Remote Systems Network Input Station ************";
|
||||
char *head5Center = "================================================================";
|
||||
char *menu1 = "[1] Interbank Funds transfer (Code Prog: 485-GWU)";
|
||||
char *menu2 = "[2] International telelink Access (Code Lim: XRP-262)";
|
||||
char *menu3 = "[3] Remote Facsimile Send/receive (Code Tran: 2LZP-517)";
|
||||
char *menu4 = "[4] Regional bank Interconnect (Security Code: 47-B34)";
|
||||
char *menu5 = "[5] Update System Parameters (Entry Auth. Req.)";
|
||||
char *menu6 = "[6] Remote Operator Logon/Logoff";
|
||||
char *foot1Center = "================================================================";
|
||||
char *foot2Center = "[ ] Select Option or ESC to Abort";
|
||||
|
||||
// Get terminal dimentions (needed for centering)
|
||||
struct winsize w;
|
||||
ioctl(0, TIOCGWINSZ, &w);
|
||||
termLines = w.ws_row;
|
||||
termCols = w.ws_col;
|
||||
|
||||
// Start building the display string
|
||||
strcpy(display, head1Left);
|
||||
|
||||
spaces = termCols - strlen(head1Left) - strlen(head1Right);
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, head1Right);
|
||||
|
||||
strcat(display, "\n");
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = (termCols - strlen(head2Center)) / 2;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, head2Center);
|
||||
|
||||
strcat(display, "\n");
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = (termCols - strlen(head3Center)) / 2;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, head3Center);
|
||||
|
||||
strcat(display, "\n");
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = (termCols - strlen(head4Center)) / 2;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, head4Center);
|
||||
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = (termCols - strlen(head5Center)) / 2;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, head5Center);
|
||||
|
||||
strcat(display, "\n");
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, menu1);
|
||||
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, menu2);
|
||||
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, menu3);
|
||||
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, menu4);
|
||||
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, menu5);
|
||||
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = ((termCols - strlen(head5Center)) / 2) + 3;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, menu6);
|
||||
|
||||
strcat(display, "\n");
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = (termCols - strlen(foot1Center)) / 2;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, foot1Center);
|
||||
|
||||
strcat(display, "\n");
|
||||
strcat(display, "\n");
|
||||
|
||||
spaces = (termCols - strlen(foot2Center)) / 2;
|
||||
while (spaces > 0) {
|
||||
strcat(display, " ");
|
||||
--spaces;
|
||||
}
|
||||
strcat(display, foot2Center);
|
||||
|
||||
// Display characters
|
||||
nmsexec(display);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user