pure-data/src/s_main.c

/* Copyright (c) 1997-1999 Miller Puckette and others.
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */

#include "m_pd.h"
#include "m_imp.h"
#include "s_stuff.h"
#include "s_net.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <io.h>
#include <windows.h>
#include <winbase.h>
#endif
#ifdef __APPLE__
#include <mach-o/dyld.h> // for _NSGetExecutablePath
#endif
#include "m_private_utils.h"

#define stringify(s)
#define str(s)

char *pd_version =;

char pd_compiletime[] =;
char pd_compiledate[] =;

void pd_init(void);
void pd_term(void);
int sys_argparse(int argc, const char **argv);
void sys_findprogdir(const char *progname);
void sys_setsignalhandlers(void);
int sys_startgui(const char *guipath);
void sys_stopgui(void);
void sys_setrealtime(const char *guipath);
int m_mainloop(void);
int m_batchmain(void);
void sys_addhelppath(char *p);
#ifdef USEAPI_ALSA
void alsa_adddev(const char *name);
#endif
int sys_oktoloadfiles(int done);
void sys_doneglobinit( void);

int sys_debuglevel;
int sys_verbose;
int sys_noloadbang;
static int sys_dontstartgui;
int sys_hipriority =;    /* -1 = not specified; 0 = no; 1 = yes */
int sys_guisetportnumber;   /* if started from the GUI, this is the port # */
int sys_nosleep =;  /* skip all "sleep" calls and spin instead */
int sys_defeatrt;       /* flag to cancel real-time */
t_symbol *sys_flags;    /* more command-line flags */

const char *sys_guicmd;
t_symbol *sys_libdir;

t_patchlist;

static t_patchlist *sys_openlist;
static t_namelist *sys_messagelist;
static int sys_version;
int sys_oldtclversion;      /* hack to warn g_rtext.c about old text sel */

int sys_nmidiout =;
int sys_nmidiin =;
int sys_midiindevlist[MAXMIDIINDEV] =;
int sys_midioutdevlist[MAXMIDIOUTDEV] =;

#if __APPLE__
char sys_font[100] = "Menlo"; /* hack until DVSM bug is fixed on macOS 10.15+ */
char sys_fontweight[10] = "normal";
#else
char sys_font[100] =;
char sys_fontweight[10] =;
#endif

static int sys_listplease;

int sys_externalschedlib;
char sys_externalschedlibname[MAXPDSTRING];
int sys_batch;
const char *pd_extraflags =;
int sys_run_scheduler(const char *externalschedlibname,
    const char *sys_extraflagsstring);
int sys_noautopatch;    /* temporary hack to defeat new 0.42 editing */

t_sample *get_sys_soundout() {}
t_sample *get_sys_soundin() {}
double *get_sys_time_per_dsp_tick() {}
int *get_sys_schedblocksize() {}
double *get_sys_time() {}
t_float *get_sys_dacsr() {}
int *get_sys_schedadvance() {}
t_namelist *sys_searchpath;  /* so old versions of GEM might compile */

t_fontinfo;

    /* these give the nominal point size and maximum height of the characters
    in the six fonts.  */

static t_fontinfo sys_fontspec[] =;
#define NFONT
#define NZOOM

    /* here are actual measured font sizes; they are overwritten from the
    GUI if/when the GUI starts up. */
static t_fontinfo sys_gotfonts[NZOOM][NFONT]  =;

/* here are some measured font size structs for example:
MSW:
font 8 5 9 8 5 11
font 10 7 13 10 6 13
font 12 9 16 14 8 16
font 16 10 20 16 10 18
font 24 15 25 16 10 18
font 36 25 42 36 22 41

linux:
font 8 5 9 8 5 9
font 10 7 13 12 7 13
font 12 9 16 14 9 15
font 16 10 20 16 10 19
font 24 15 25 24 15 24
font 36 25 42 36 22 41
*/

static int sys_findfont(int fontsize)
{}

int sys_nearestfontsize(int fontsize)
{}

int sys_hostfontsize(int fontsize, int zoom)
{}

int sys_zoomfontwidth(int fontsize, int zoomarg, int worstcase)
{}

int sys_zoomfontheight(int fontsize, int zoomarg, int worstcase)
{}

int sys_fontwidth(int fontsize) /* old version for extern compatibility */
{}

int sys_fontheight(int fontsize)
{}

int sys_defaultfont;
#define DEFAULTFONT

static t_patchlist * patchlist_append(t_patchlist *listwas,
    const char *files, const char *args)
{}

static void patchlist_free(t_patchlist *list)
{}

static void openit(const char *dirname, const char *filename, const char *args)
{}

/* this is called from the gui process.  The first argument is ignored,
the second one flags an old version of TK which for back compatibility, and
succeeding args give the widths and heights of known fonts.  We wait until
these are known to open files and send messages specified on the command line.
We ask the GUI to specify the "cwd" in case we don't have a local OS to get it
from; for instance we could be some kind of RT embedded system.  However, to
really make this make sense we would have to implement
open(), read(), etc, calls to be served somehow from the GUI too. */

void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv)
{}

static void sys_init_midi(void);
static void sys_init_paths(void);
static void sys_printusage(void);
void sys_init_audio(void);  /* bad that init_midi is here but init_audio not */



/* this is called from main() in s_entry.c */
int sys_main(int argc, const char **argv)
{}

static char *(usagemessage[]) =;

static void sys_printusage(void)
{}

    /* parse a comma-separated numeric list, returning the number found */
static int sys_parsedevlist(int *np, int *vecp, int max, const char *str)
{}

static int sys_getmultidevchannels(int n, int *devlist)
{}


    /* this routine tries to figure out where to find the auxiliary files
    Pd will need to run.  This is either done by looking at the command line
    invocation for Pd, or if that fails, by consulting the variable
    INSTALL_PREFIX.  In MSW, we don't try to use INSTALL_PREFIX. */
void sys_findprogdir(const char *progname)
{}

    /* Parse command line arguments.  This may be called twice, from
    "preferences (s_file.c), then from command-line arguments. */
int sys_argparse(int argc, const char **argv)
{}

int sys_getblksize(void)
{}

    /* initialize paths after parsing arguments and loading preferences */
static void sys_init_paths(void)
{}

    /* initialize MIDI after parsing arguments and loading preferences */
static void sys_init_midi(void)
{}

static int string2args(const char * cmd, int * retArgc, const char *** retArgv);

void sys_doflags(void)
{}

/* undo pdtl_encodedialog.  This allows dialogs to send spaces, commas,
    dollars, and semis down here. */
t_symbol *sys_decodedialog(t_symbol *s)
{}


/* start the generic preference window */
void sys_gui_preferences(void);
void sys_gui_audiopreferences(void);
void sys_gui_midipreferences(void);
void glob_start_preference_dialog(t_pd *dummy, t_symbol*s)
{}


    /* start a search path dialog window */
void glob_start_path_dialog(t_pd *dummy)
{}

    /* new values from dialog window */
void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
{}

    /* add one item to search path (intended for use by Deken plugin).
    if "saveit" is > 0, this also saves all settings,
    if "saveit" is < 0, the path is only added temporarily */
void glob_addtopath(t_pd *dummy, t_symbol *path, t_float saveit)
{}

    /* start a startup dialog window */
void glob_start_startup_dialog(t_pd *dummy)
{}

    /* new values from dialog window */
void glob_startup_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
{}


/*
 * the following string2args function is based on from sash-3.8 (the StandAlone SHell)
 * Copyright (c) 2014 by David I. Bell
 * Permission is granted to use, distribute, or modify this source,
 * provided that this copyright notice remains intact.
 */
#define isBlank(ch)
int string2args(const char * cmd, int * retArgc, const char *** retArgv)
{}