aboutsummaryrefslogtreecommitdiff
path: root/system.c
blob: b52e0549fe77100db33159173b1eba4ed083f315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*************************************************************************** 
 * File: system.c 
 * Auth: Iain Mott [iain.mott@bigpond.com] 
 * Maintainer: Iain Mott [iain.mott@bigpond.com] 
 * Version: Part of motex_1.1.2 
 * Date: January 2001
 * 
 * Description: Pd external. Send a system message to the console 
 * See supporting Pd patch: system.pd
 * 
 * Copyright (C) 2001 by Iain Mott [iain.mott@bigpond.com] 
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2, 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 General Public License, which should be included with this 
 * program, for more details. 
 * 
 ****************************************************************************/ 

/* code for system pd class */

#include "m_pd.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
 
typedef struct system
{
  t_object t_ob;
} t_system;


void system_anything(t_system *x, t_symbol *s, int ac, t_atom *av, t_floatarg f)
{
  char buf[MAXPDSTRING], message[MAXPDSTRING];
  int i;
  strcpy(message, s->s_name);
  strcat(message, " ");
  for (i = 0; i < ac; i++)
    {
      atom_string(av+i, buf, MAXPDSTRING);
      strcat(message, buf);
      if (i < (ac - 1))
	strcat(message, " ");
    }
  system(message);
}


void system_free(void)
{
  /*      post("system_free"); */
}

t_class *system_class;

void *system_new(void)
{
  t_system *x = (t_system *)pd_new(system_class);
  return (void *)x;
}

void system_setup(void)
{
  post("system_setup");
  system_class = class_new(gensym("system"), (t_newmethod)system_new,
			   (t_method)system_free, sizeof(t_system), 0, 0);
  class_addanything(system_class, system_anything);
}