~ubuntu-branches/ubuntu/natty/pd-zexy/natty

« back to all changes in this revision

Viewing changes to src/rawprint.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard, IOhannes m zmölnig, Jonas Smedegaard
  • Date: 2010-08-20 12:17:41 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100820121741-4kxozn8b9rhee9fr
Tags: 2.2.3-1
* New upstream version

[ IOhannes m zmölnig ]
* Adopt package, on behalf of Multimedia Team.
  Closes: #546964
* Simply debian/rules with CDBS, and don't unconditionally strip
  binaries.
  Closes: #437763
* Install into /usr/lib/pd/extra/zexy/. Document usage in REAME.Debian
  and warn about change in NEWS.
* git'ify package. Add Vcs-* stanzas to control file.
* Use dpkg source format 3.0 (quilt). Drop build-dependency on quilt.

[ Jonas Smedegaard ]
* Enable CDBS copyright-check routine.
* Add copyright and licensing header to debian/rules.
* Add myself as uploader.
* Rewrite debian/copyright using rev. 135 of draft DEP5 format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
 *
 
3
 * zexy - implementation file
 
4
 *
 
5
 * copyleft (c) IOhannes m zm�lnig
 
6
 *
 
7
 *   1999:forum::f�r::uml�ute:2004
 
8
 *
 
9
 *   institute of electronic music and acoustics (iem)
 
10
 *
 
11
 ******************************************************
 
12
 *
 
13
 * license: GNU General Public License v.2
 
14
 *
 
15
 ******************************************************/
 
16
 
 
17
/* print the incoming message as raw as possible */
 
18
 
 
19
#include "zexy.h"
 
20
#include <stdio.h>
 
21
 
 
22
static t_class *rawprint_class;
 
23
 
 
24
typedef struct _rawprint {
 
25
  t_object  x_obj;
 
26
  t_symbol*label;
 
27
} t_rawprint;
 
28
 
 
29
static void rawprint_any(t_rawprint *x, t_symbol*s, int argc, t_atom*argv)
 
30
{
 
31
  char buf[MAXPDSTRING];
 
32
  if(x->label) {
 
33
    startpost("%s: ", x->label->s_name);
 
34
  }
 
35
  startpost("\"%s\"", s->s_name);
 
36
  while(argc--) {
 
37
    switch(argv->a_type) {
 
38
    case A_FLOAT:
 
39
      snprintf(buf, MAXPDSTRING-1, "%f", atom_getfloat(argv));
 
40
      break;
 
41
    case A_SYMBOL:
 
42
      snprintf(buf, MAXPDSTRING-1, "'%s'", atom_getsymbol(argv)->s_name);
 
43
      break;
 
44
    case A_POINTER:
 
45
      snprintf(buf, MAXPDSTRING-1, "pointer[0x%X]", argv->a_w.w_gpointer);
 
46
      break;
 
47
    case A_SEMI:
 
48
      snprintf(buf, MAXPDSTRING-1, "SEMI");
 
49
      break;
 
50
    case A_COMMA:
 
51
      snprintf(buf, MAXPDSTRING-1, "COMMA");
 
52
      break;
 
53
    case A_DEFFLOAT:
 
54
      snprintf(buf, MAXPDSTRING-1, "DEFFLOAT[%f]", atom_getfloat(argv));
 
55
      break;
 
56
    case A_DEFSYM:
 
57
      snprintf(buf, MAXPDSTRING-1, "DEFSYM['%s']", atom_getsymbol(argv)->s_name);
 
58
      break;
 
59
    case A_DOLLAR:
 
60
      snprintf(buf, MAXPDSTRING-1, "DOLLAR['%s']", atom_getsymbol(argv)->s_name);
 
61
      break;
 
62
    case A_DOLLSYM:
 
63
      snprintf(buf, MAXPDSTRING-1, "DOLLSYM['%s']", atom_getsymbol(argv)->s_name);
 
64
      break;
 
65
    case A_GIMME:
 
66
      snprintf(buf, MAXPDSTRING-1, "GIMME");
 
67
      break;
 
68
    case A_CANT: // we _really_ cannot do CANT
 
69
      snprintf(buf, MAXPDSTRING-1, "CANT");
 
70
      break;
 
71
    default:
 
72
      snprintf(buf, MAXPDSTRING-1, "unknown[%d]", argv->a_type);
 
73
    }
 
74
    buf[MAXPDSTRING-1]=0;
 
75
    
 
76
    startpost(" %s", buf);
 
77
    argv++;
 
78
  }
 
79
  endpost();
 
80
 
 
81
}
 
82
 
 
83
static void *rawprint_new(t_symbol*s)
 
84
{
 
85
  t_rawprint *x = (t_rawprint *)pd_new(rawprint_class);
 
86
  x->label=NULL;
 
87
  if(s&&gensym("")!=s)
 
88
    x->label=s;
 
89
 
 
90
  return (x);
 
91
}
 
92
 
 
93
void rawprint_setup(void) {
 
94
  rawprint_class = class_new(gensym("rawprint"),
 
95
                             (t_newmethod)rawprint_new,
 
96
                             0, sizeof(t_rawprint),
 
97
                             CLASS_DEFAULT, A_DEFSYMBOL, 0);
 
98
 
 
99
  class_addanything(rawprint_class, rawprint_any);
 
100
  zexy_register("rawprint");
 
101
}