From 00f662e3684c4897a65a6983a0a78a0d9fb511ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 26 Nov 2012 14:36:28 +0000 Subject: common functions to both audio- and midi-settings svn path=/trunk/externals/iem/mediasettings/; revision=16590 --- mediasettings.h | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 mediasettings.h diff --git a/mediasettings.h b/mediasettings.h new file mode 100644 index 0000000..2b31d40 --- /dev/null +++ b/mediasettings.h @@ -0,0 +1,100 @@ +/****************************************************** + * + * audiosettings - get/set audio preferences from within Pd-patches + * Copyright (C) 2010-2012 IOhannes m zmölnig + * + * forum::für::umläute + * + * institute of electronic music and acoustics (iem) + * university of music and dramatic arts, graz (kug) + * + * + ****************************************************** + * + * license: GNU General Public License v.3 or later + * + ******************************************************/ +#include "m_pd.h" +#include "s_stuff.h" +#include +#include +#include + +#define MAXNDEV 20 +#define DEVDESCSIZE 80 + +/** + * find EOS of a string of tokens + * where EOS might be indicated by \0, } + */ +unsigned int findEOT(const char*s, unsigned int length) { + unsigned int len=0; + do { + char c=s[len]; + len++; + switch(c) { + case '{': + len+=findEOT(s+len, length-len); + break; + case '}': + if('{'!=s[0]) + return len; + else + return len-1; + case '\0': + return len; + } + } while(len=0) + stop--; + + start=stop; + while(start>=0) { + char c=str[start]; + if(c<48 || c>=57) break; + start--; + } + if(start==stop || start<0) + return ret; + + stop1=start; + while(stop1>=0) { + char c=str[stop1]; + if(!isspace(c)) + break; + stop1--; + } + if(stop1<0) + return ret; + + if(( str[start1]=='"' && str[stop1]=='"') + || (str[start1]=='\'' && str[stop1]=='\'') + || (str[start1]=='{' && str[stop1]=='}') + ) { + start1++; + stop1--; + } + stop1+=2; + if(stop1>=length)stop1=length-1; + snprintf(name, stop1-start1, "%s", str+start1); + ret=(1==sscanf(str+start, "%d", id)); + + return ret; +} -- cgit v1.2.1