Added argument parameters.

This commit is contained in:
Nicolás Ortega Froysa 2019-03-22 11:58:19 +01:00
parent 41fd95fde9
commit 5161b37943
4 changed files with 102 additions and 3 deletions

View File

@ -1,8 +1,25 @@
# Copyright (C) 2019 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
# Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
CC=gcc
DEBUG=0
INCFLAGS=`pkg-config jack --cflags`
LDFLAGS=`pkg-config jack --libs` -lreadline
CFLAGS=$(INCFLAGS) -std=c99 -Wall -Wextra -Wfatal-errors -Werror
HDRS=src/args.h
OBJS=src/main.o
ifeq ($(DEBUG),1)
@ -11,7 +28,7 @@ else
CFLAGS+=-O2 -DNDEBUG
endif
%.o:%.c
%.o:%.c $(HDRS)
$(CC) -c -o $@ $< $(CFLAGS)
saus: $(OBJS)

5
README
View File

@ -1,8 +1,8 @@
============
*** SAUS ***
============
Scripted AUdio Software is a command-line tool for real-time audio
scripted filtering via JACK audio inputs. The user writes scripts which
Scripted AUdio Software is a command-line tool for real-time scripted
audio filtering via JACK audio inputs. The user writes scripts which
modify the frequency and amplitude of the sound waves coming from the
JACK input.
@ -13,6 +13,7 @@ To build the project you will require the following dependencies:
* GNU Make
* C99 compatible compiler
* JACK2
* GNU Readline
## Compiling
To compile the project simply run the `make' command in the root

72
src/args.h Normal file
View File

@ -0,0 +1,72 @@
/*
* Copyright (C) 2019 Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
* Author: Ortega Froysa, Nicolás <nortega@themusicinnoise.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <argp.h>
const char *argp_program_version = "SAUS v1.0";
const char *argp_program_bug_address = "<nortega@themusicinnoise.net>";
static char doc[] = "saus -- a command-line tool for real-time "
"scripted audio filtering.";
static char args_doc[] = "[-v] -f FILE | -l FILE";
static struct argp_option options[] = {
{ "verbose", 'v', 0, 0, "Make output verbose", 0 },
{ "file", 'f', "FILE", 0, "Script file", 0 },
{ "playlist", 'l', "FILE", 0, "Playlist of script files", 0 },
{ 0 }
};
struct arguments {
int verbose;
char *script_file;
char *playlist_file;
};
static error_t parse_opt(int key, char *arg, struct argp_state *state) {
struct arguments *arguments = state->input;
switch(key)
{
case 'v':
arguments->verbose = 1;
break;
case 'f':
arguments->script_file = arg;
break;
case 'l':
arguments->playlist_file = arg;
break;
/*case ARGP_KEY_ARG:
if(state->arg_num > 2)
argp_usage(state);
break;
case ARGP_KEY_END:
if(state->arg_num < 1)
argp_usage(state);
break;*/
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp argp = { options, parse_opt, args_doc, doc, 0, 0, 0 };

View File

@ -16,8 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "args.h"
#include <stdio.h>
#include <readline/readline.h>
int main(int argc, char *argv[]) {
struct arguments arguments;
arguments.verbose = 0;
arguments.script_file = NULL;
arguments.playlist_file = NULL;
argp_parse(&argp, argc, argv, 0, 0, &arguments);
return 0;
}