Curseshelper. structures for settings

This commit is contained in:
2018-03-26 11:50:10 +02:00
parent 6a4b0fd126
commit 6519092f7c
6 changed files with 56 additions and 10 deletions

View File

@@ -9,15 +9,16 @@
#include "config.h"
#include "sound.h"
#include "udpserver.h"
#include "curseshelper.h"
int main(int argc, char *argv[]) {
const char *short_options = "hsi:l";
const char *short_options = "hsi:lv";
struct option long_options[] = {
{"server", no_argument, NULL, 's'},
{"ip", required_argument, NULL, 'i'},
{"help", no_argument, NULL, 'h'},
{"local", no_argument, NULL, 'l'}
{"local", no_argument, NULL, 'l'},
{"verbose", no_argument, NULL, 'v'}
};
int c;
@@ -27,6 +28,8 @@ int main(int argc, char *argv[]) {
return 0;
}
ao_initialize();
settings csset = {0};
csset.verbose = 0; //Off by default
while ( (c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1 ) {
switch (c) {
@@ -37,12 +40,16 @@ int main(int argc, char *argv[]) {
break;
case 'h':
//show the help page
showHelp();
showHelp(&csset);
break;
case 'i':
//connect to a csoundbox server
inputNetwork(optarg);
break;
case 'v':
//set a verbose flag
csset.verbose = 1;
break;
case 'l':
default:
//start local
@@ -110,14 +117,21 @@ void printCursesWelcome(void) {
x /= 2;
const char *msg = "Press enter to exit.";
const char *msg2 = "Press F1 to kill the server + client";
mvprintw(y, x - (strlen(msg) / 2), msg);
mvprintw(y + 1, x - (strlen(msg2) / 2), msg2);
// mvprintw(y, x - (strlen(msg) / 2), msg);
// mvprintw(y + 1, x - (strlen(msg2) / 2), msg2);
printCenter(msg);
printCenterOffset(msg2, 2);
}
void showHelp(void) {
void showHelp(settings *s) {
if (s->verbose) {
printf("Test\n");
}
printf("-h: Show the help screen and exit\n");
printf("-s: Start the server\n");
printf("-i <ip>: connect to a server\n");
printf("-l or without arguments: Start local\n");
}