scripts.h File Reference

#include <qstring.h>
#include <stdio.h>
#include "index.h"
#include "process.h"
#include "common.h"
Include dependency graph for scripts.h:
This graph shows which files directly or indirectly include this file:

Defines

#define RAW_EXT   ".raw"
#define IDX_EXT   ".idx"
#define SHELL_HEADER   "#!/bin/bash\n"
#define RAW2WAV   "sox -r 44100 -s -w -c 2 "
#define BPLAY   "bplay -s 44100 -S -b 16 "
#define SSH   " ssh -X -T -e none "
#define PROCESS_MIX   "./process_mix.sh"
#define MIXDUMP_NAME   "mix.raw"
#define TAILDUMP_NAME   "tail.raw"
#define HEADDUMP_NAME   "head.raw"
#define BPMMIXED_NAME   "bpm-mixed.raw"

Functions

char * getRawFilename (const char *dir, const char *name)
FILE * openRawFile (Index *index, const char *dir)
FILE * openScriptFile (const char *name)
FILE * openRawFileForWriting (Index *index, const char *dir)
void removeRawFile (Index *index, const char *dir)
void removeAllRaw (const char *dir)
void removeAllLog ()
void dumpAudio (const char *fname, unsigned4 *buffer, long length)
int bpmdjraw (bool synchronous, const char *fname, const char *where)
int bpmdjraw (bool synchronous, const char *fname, QString where)
void start_mkdir (const QString &dir)
void start_cp (const QString &from, const QString &to)
int start_mv (const QString &from, const QString &to)
void start_rm (const QString &what)
void remove (QString str)
char * escape (const char *in)
QString escape (const QString &in)
bool execute (QString description, QString script)
bool vexecute (const char *script,...)

Define Documentation

#define BPLAY   "bplay -s 44100 -S -b 16 "
#define BPMMIXED_NAME   "bpm-mixed.raw"
#define HEADDUMP_NAME   "head.raw"
#define IDX_EXT   ".idx"
#define MIXDUMP_NAME   "mix.raw"
#define PROCESS_MIX   "./process_mix.sh"
#define RAW2WAV   "sox -r 44100 -s -w -c 2 "
#define RAW_EXT   ".raw"

Referenced by main(), and removeAllRaw().

#define SHELL_HEADER   "#!/bin/bash\n"

Referenced by openScriptFile().

#define SSH   " ssh -X -T -e none "

The SSH prefix requires some attention. -X makes the target to forward the X events -T disables the allocation of a pseudotty. This was the reason of bug #1047 -e none disables the presence of an escape character.

Referenced by delete_remote(), remote(), and to_remote().

#define TAILDUMP_NAME   "tail.raw"

Function Documentation

int bpmdjraw ( bool  synchronous,
const char *  fname,
QString  where 
)

References bpmdjraw().

int bpmdjraw ( bool  synchronous,
const char *  fname,
const char *  where 
)

Will start bpmdjraw and wait for the result or not depending on the synchronous flag. The return value is the process id in the asynchronous case, 0 when there was an error. The location to place the rawfile is obtained through the raw_location() function call.

References bpmdj_deallocate, escape(), execute(), spawn(), and sprintf().

Referenced by bpmdjraw(), wave_open(), and DecoderChecker::works().

void dumpAudio ( const char *  fname,
unsigned4 buffer,
long  length 
)

References fclose(), FILE, and writesamples().

QString escape ( const QString &  in  ) 

References bpmdj_deallocate, and escape().

char* escape ( const char *  in  ) 

This function returns a new string with all characters escaped as necessary, if passing through to a remote shell double escaping might be necessary. For instance when trying to pass a parameter through a secure shell command.

The escaping necessary for ssh to work is ridiculous.. An ordinary containment within " ... " does not work, so we must escape every character on its own. Especially the & is important because this would otherwise spawn a background process.

References assert(), and i.

Referenced by Md5Analyzer::analyze(), bpmdjraw(), ActiveFragmentCreator::createOneFor(), delete_remote(), SongSelectorLogic::doAutoMix(), escape(), from_remote(), SongSlot::getAnalCommand(), SongSlot::getPlayCommand(), remote(), removeAllRaw(), start_cp(), start_mkdir(), start_mv(), start_rm(), and to_remote().

bool execute ( QString  description,
QString  script 
)

executes the given command. Returns a simple true if successful, false otherwise. The description will be printed to the terminal. The script will be executed.

Two wrappers which will simply return true or false

References assert(), Error(), ExitStatus::error(), exec(), ExitStatus::exit(), ExitStatus::exited(), and status.

Referenced by bpmdjraw(), ActiveFragmentCreator::createOneFor(), remote(), removeAllLog(), start_mv(), and vexecute().

char* getRawFilename ( const char *  dir,
const char *  name 
)
FILE* openRawFile ( Index index,
const char *  dir 
)
FILE* openRawFileForWriting ( Index index,
const char *  dir 
)
FILE* openScriptFile ( const char *  name  ) 

References assert(), FILE, script, and SHELL_HEADER.

Referenced by SongSelectorLogic::doAutoMix().

void remove ( QString  str  ) 

References remove().

Referenced by remove().

void removeAllLog (  ) 

References execute().

Referenced by main().

void removeAllRaw ( const char *  dir  ) 

References bpmdj_deallocate, escape(), RAW_EXT, and vexecute().

Referenced by main().

void removeRawFile ( Index index,
const char *  dir 
)
void start_cp ( const QString &  from,
const QString &  to 
)
void start_mkdir ( const QString &  dir  ) 

References escape(), exec(), and sprintf().

Referenced by ActiveSongCopier::fetchNextSong().

int start_mv ( const QString &  from,
const QString &  to 
)

References escape(), execute(), and sprintf().

Referenced by UpdateSongFilename::change().

void start_rm ( const QString &  what  ) 

References escape(), and vexecute().

Referenced by main().

bool vexecute ( const char *  script,
  ... 
)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by  doxygen 1.6.2