aboutsummaryrefslogtreecommitdiff
path: root/control/stripdir.c
blob: 10ba19bf101d46a3a191e39fb0a1616f2cf08ed8 (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
/* (C) Guenter Geiger <geiger@epy.co.at> */


#include <m_pd.h>
#include <string.h>
#ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif

/* ------------------------ stripdir ----------------------------- */

static t_class *stripdir_class;


typedef struct _stripdir
{
     t_object x_obj;
} t_stripdir;


void stripdir_symbol(t_stripdir *x,t_symbol* s)
{
     int len = strlen(s->s_name);

     while (len--)
	  if (*(s->s_name + len) == '/') {
	       outlet_symbol(x->x_obj.ob_outlet,gensym(s->s_name + len + 1));
	       break;
	  }

}

static void *stripdir_new()
{
    t_stripdir *x = (t_stripdir *)pd_new(stripdir_class);
    outlet_new(&x->x_obj, &s_float);
    return (x);
}

void stripdir_setup(void)
{
    stripdir_class = class_new(gensym("stripdir"), (t_newmethod)stripdir_new, 0,
				sizeof(t_stripdir), 0,0);
    class_addsymbol(stripdir_class,stripdir_symbol);
}