ardour
Classes | Macros | Functions | Variables
smfsh.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sysexits.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include "smf.h"
#include "config.h"

Go to the source code of this file.

Classes

struct  command_struct
 

Macros

#define COMMAND_LENGTH   10
 
#define BUFFER_SIZE   1024
 

Functions

static void log_handler (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer notused)
 
static int cmd_track (char *arg)
 
static int cmd_load (char *file_name)
 
static int cmd_save (char *file_name)
 
static int cmd_ppqn (char *new_ppqn)
 
static int cmd_format (char *new_format)
 
static int cmd_tracks (char *notused)
 
static int parse_track_number (const char *arg)
 
static int cmd_trackadd (char *notused)
 
static int cmd_trackrm (char *arg)
 
static int show_event (smf_event_t *event)
 
static int cmd_events (char *notused)
 
static int parse_event_number (const char *arg)
 
static int cmd_event (char *arg)
 
static int decode_hex (char *str, unsigned char **buffer, int *length)
 
static void eventadd_usage (void)
 
static int cmd_eventadd (char *str)
 
static int cmd_text (char *str)
 
static int cmd_eventaddeot (char *time)
 
static int cmd_eventrm (char *number)
 
static int cmd_tempo (char *notused)
 
static int cmd_length (char *notused)
 
static int cmd_version (char *notused)
 
static int cmd_exit (char *notused)
 
static int cmd_help (char *notused)
 
static void strip_unneeded_whitespace (char *str, int len)
 
static char * read_command (void)
 
static int execute_command (char *line)
 
static void read_and_execute_command (void)
 
static void usage (void)
 
int main (int argc, char *argv[])
 

Variables

smf_track_tselected_track = NULL
 
smf_event_tselected_event = NULL
 
smf_tsmf = NULL
 
char * last_file_name = NULL
 
static struct command_struct commands []
 

Detailed Description

"SMF shell", command line utility.

Definition in file smfsh.c.

Macro Definition Documentation

#define BUFFER_SIZE   1024

Definition at line 334 of file smfsh.c.

#define COMMAND_LENGTH   10

Definition at line 54 of file smfsh.c.

Function Documentation

static int cmd_event ( char *  arg)
static

Definition at line 436 of file smfsh.c.

static int cmd_eventadd ( char *  str)
static

Definition at line 519 of file smfsh.c.

static int cmd_eventaddeot ( char *  time)
static

Definition at line 662 of file smfsh.c.

static int cmd_eventrm ( char *  number)
static

Definition at line 694 of file smfsh.c.

static int cmd_events ( char *  notused)
static

Definition at line 371 of file smfsh.c.

static int cmd_exit ( char *  notused)
static

Definition at line 749 of file smfsh.c.

static int cmd_format ( char *  new_format)
static

Definition at line 185 of file smfsh.c.

static int cmd_help ( char *  notused)
static

Definition at line 790 of file smfsh.c.

static int cmd_length ( char *  notused)
static

Definition at line 733 of file smfsh.c.

static int cmd_load ( char *  file_name)
static

Definition at line 68 of file smfsh.c.

static int cmd_ppqn ( char *  new_ppqn)
static

Definition at line 154 of file smfsh.c.

static int cmd_save ( char *  file_name)
static

Definition at line 121 of file smfsh.c.

static int cmd_tempo ( char *  notused)
static

Definition at line 712 of file smfsh.c.

static int cmd_text ( char *  str)
static

Definition at line 585 of file smfsh.c.

static int cmd_track ( char *  arg)
static

Definition at line 261 of file smfsh.c.

static int cmd_trackadd ( char *  notused)
static

Definition at line 297 of file smfsh.c.

static int cmd_trackrm ( char *  arg)
static

Definition at line 315 of file smfsh.c.

static int cmd_tracks ( char *  notused)
static

Definition at line 216 of file smfsh.c.

static int cmd_version ( char *  notused)
static

Definition at line 741 of file smfsh.c.

static int decode_hex ( char *  str,
unsigned char **  buffer,
int *  length 
)
static

Definition at line 466 of file smfsh.c.

static void eventadd_usage ( void  )
static

Definition at line 512 of file smfsh.c.

static int execute_command ( char *  line)
static

Definition at line 892 of file smfsh.c.

static void log_handler ( const gchar *  log_domain,
GLogLevelFlags  log_level,
const gchar *  message,
gpointer  notused 
)
static

Definition at line 57 of file smfsh.c.

int main ( int  argc,
char *  argv[] 
)

Definition at line 992 of file smfsh.c.

static int parse_event_number ( const char *  arg)
static

Definition at line 398 of file smfsh.c.

static int parse_track_number ( const char *  arg)
static

Definition at line 227 of file smfsh.c.

static void read_and_execute_command ( void  )
static

Definition at line 915 of file smfsh.c.

static char* read_command ( void  )
static

Definition at line 852 of file smfsh.c.

static int show_event ( smf_event_t event)
static

Definition at line 337 of file smfsh.c.

static void strip_unneeded_whitespace ( char *  str,
int  len 
)
static

Removes (in place) all whitespace characters before the first non-whitespace and all trailing whitespace characters. Replaces more than one consecutive whitespace characters with one.

Definition at line 821 of file smfsh.c.

static void usage ( void  )
static

Definition at line 984 of file smfsh.c.

Variable Documentation

struct command_struct commands[]
static
Initial value:
= {{"help", cmd_help, "Show this help."},
{"?", cmd_help, NULL},
{"load", cmd_load, "Load named file."},
{"open", cmd_load},
{"save", cmd_save, "Save to named file."},
{"ppqn", cmd_ppqn, "Show ppqn (aka division), or set ppqn if used with parameter."},
{"format", cmd_format, "Show format, or set format if used with parameter."},
{"tracks", cmd_tracks, "Show number of tracks."},
{"track", cmd_track, "Show number of currently selected track, or select a track."},
{"trackadd", cmd_trackadd, "Add a track and select it."},
{"trackrm", cmd_trackrm, "Remove currently selected track."},
{"events", cmd_events, "Show events in the currently selected track."},
{"event", cmd_event, "Show number of currently selected event, or select an event."},
{"add", cmd_eventadd, "Add an event and select it."},
{"text", cmd_text, "Add textual event and select it."},
{"eventadd", cmd_eventadd, NULL},
{"eot", cmd_eventaddeot, "Add an End Of Track event."},
{"eventaddeot", cmd_eventaddeot, NULL},
{"eventrm", cmd_eventrm, NULL},
{"rm", cmd_eventrm, "Remove currently selected event."},
{"tempo", cmd_tempo, "Show tempo map."},
{"length", cmd_length, "Show length of the song."},
{"version", cmd_version, "Show libsmf version."},
{"exit", cmd_exit, "Exit to shell."},
{"quit", cmd_exit, NULL},
{"bye", cmd_exit, NULL},
{NULL, NULL, NULL}}
static int cmd_save(char *file_name)
Definition: smfsh.c:121
static int cmd_trackrm(char *arg)
Definition: smfsh.c:315
static int cmd_eventrm(char *number)
Definition: smfsh.c:694
static int cmd_events(char *notused)
Definition: smfsh.c:371
static int cmd_track(char *arg)
Definition: smfsh.c:261
static int cmd_help(char *notused)
Definition: smfsh.c:790
static int cmd_exit(char *notused)
Definition: smfsh.c:749
static int cmd_tracks(char *notused)
Definition: smfsh.c:216
static int cmd_format(char *new_format)
Definition: smfsh.c:185
static int cmd_trackadd(char *notused)
Definition: smfsh.c:297
static int cmd_version(char *notused)
Definition: smfsh.c:741
static int cmd_event(char *arg)
Definition: smfsh.c:436
static int cmd_length(char *notused)
Definition: smfsh.c:733
static int cmd_eventaddeot(char *time)
Definition: smfsh.c:662
static int cmd_ppqn(char *new_ppqn)
Definition: smfsh.c:154
static int cmd_eventadd(char *str)
Definition: smfsh.c:519
static int cmd_text(char *str)
Definition: smfsh.c:585
static int cmd_tempo(char *notused)
Definition: smfsh.c:712
static int cmd_load(char *file_name)
Definition: smfsh.c:68
char* last_file_name = NULL

Definition at line 52 of file smfsh.c.

smf_event_t* selected_event = NULL

Definition at line 50 of file smfsh.c.

smf_track_t* selected_track = NULL

Definition at line 49 of file smfsh.c.

smf_t* smf = NULL

Definition at line 51 of file smfsh.c.