Ejemplo n.º 1
0
void testdb_setup(t_testdb *d)
{
	if (!d->d_db) {
		short			path = packages_getpackagepath("testpackage");
		char			fullpath[MAX_PATH_CHARS];
		short			apppath = path_getapppath();
		char			appfullpath[MAX_PATH_CHARS];
		unsigned long	appfullpathlen;
		int				i;
		char			dbfilename[MAX_PATH_CHARS];
		t_db_result		*dbresult = NULL;
		
		path_topathname(apppath, "", appfullpath);
		appfullpathlen = strlen(appfullpath);
		for (i=0; i<appfullpathlen; i++) {
			if (appfullpath[i] == ':' || appfullpath[i] == '/')
				appfullpath[i] ='-';
		}
		strncpy_zero(dbfilename, appfullpath, MAX_PATH_CHARS);
		strncat_zero(dbfilename, "--maxtestresults.db3", MAX_PATH_CHARS);
		
		path_topathname(path, "", fullpath);
		strncat_zero(fullpath, "/", MAX_PATH_CHARS);
		strncat_zero(fullpath, dbfilename, MAX_PATH_CHARS);
		db_open(gensym("unittestdb"), fullpath, &d->d_db);
		
		// cache the fullpath so it can be requested from the outside world
		{
			short apath;
			char afilename[MAX_FILENAME_CHARS];
			path_frompathname(fullpath, &apath, afilename);
			path_toabsolutesystempath(apath, afilename, g_dbpath);
		}

		db_query(d->d_db, &dbresult, "SELECT name FROM sqlite_master WHERE type='table' AND name='tests'");
		if (!db_result_numrecords(dbresult)) {
			db_query_table_new(d->d_db, "tests");
			db_query_table_addcolumn(d->d_db, "tests", "test_name",		"VARCHAR(512)", 0);
			db_query_table_addcolumn(d->d_db, "tests", "test_start",	"DATETIME", 0);
			db_query_table_addcolumn(d->d_db, "tests", "test_finish",	"DATETIME", 0);

			db_query_table_new(d->d_db, "assertions");
			db_query_table_addcolumn(d->d_db, "assertions", "test_id_ext",		"INTEGER", 0);
			db_query_table_addcolumn(d->d_db, "assertions", "assertion_name",	"VARCHAR(512)", 0);
			db_query_table_addcolumn(d->d_db, "assertions", "assertion_value",	"VARCHAR(512)", 0);
			db_query_table_addcolumn(d->d_db, "assertions", "assertion_data",	"VARCHAR(512)", 0);
			db_query_table_addcolumn(d->d_db, "assertions", "assertion_start",	"DATETIME", 0);
			db_query_table_addcolumn(d->d_db, "assertions", "assertion_finish",	"DATETIME", 0);
			db_query_table_addcolumn(d->d_db, "assertions", "assertion_tags",	"VARCHAR(512)", 0);

			db_query_table_new(d->d_db, "logs");
			db_query_table_addcolumn(d->d_db, "logs", "test_id_ext",	"INTEGER", 0);
			db_query_table_addcolumn(d->d_db, "logs", "text",			"VARCHAR(512)", 0);
			db_query_table_addcolumn(d->d_db, "logs", "timestamp",		"DATETIME", 0);
		}
		object_free(dbresult);
	}
}
Ejemplo n.º 2
0
void tralala_paintStrncatPanel(char *dst, long argc, t_atom *argv)
{
    long k = 0;
    char *p = NULL;
    
    if (!(atom_gettext(argc - 1, argv + 1, &k, &p, OBEX_UTIL_ATOM_GETTEXT_SYM_NO_QUOTE))) {
        strncat_zero(dst, p, TLL_STRING_SIZE);
        strncat_zero(dst, "\n", TLL_STRING_SIZE);
        sysmem_freeptr(p);
    }
}
Ejemplo n.º 3
0
void _dict_recurse_array(t_dict_recurse *x, t_atomarray *atomarray, t_int32 depth)
{
  TRACE("_dict_recurse_array");

  t_atom *value;

  // ==== Store the state variables on the beginning of the function
  t_int32 path_len = (t_int32)strlen(x->path);
  t_value_type type_iter_ini = x->type_iter;
  t_atomarray *array_iter_ini = x->array_iter;
  t_int32 index_iter_ini = x->index_iter;

  // ==== Add [ to the path
  strncat_zero(x->path, "[", x->path_len_max);

  // ==== Set the trailing variables before the recursions
  x->type_iter = VALUE_TYPE_ARRAY;
  x->array_iter = atomarray;

  // ==== Get the array of atoms associated with the atomarray
  long array_len;
  t_atom *atom_arr;
  atomarray_getatoms(atomarray, &array_len, &atom_arr);
  t_int32 test;

  // ==== Loop through the array
  for (t_int32 ind = 0; ind < array_len; ind++) {
    
    value = atom_arr + ind;
    x->index_iter = ind;

    // == Update the path
    snprintf_zero(x->str_tmp, MAX_LEN_NUMBER, "%i]", ind);
    strncat_zero(x->path, x->str_tmp, x->path_len_max);

    // == Recurse to the value
    test = _dict_recurse_value(x, value, depth);

    // == If there was a deletion reset the array and shift the index
    if (test == VALUE_DEL) {
      atomarray_getatoms(atomarray, &array_len, &atom_arr);
      ind--; }
  
    // == In loop resetting of the values that changed in this function
    x->path[path_len +  1] = '\0'; }    // End of the loop through the array

  // ==== Restore the remaining state variables to their beginning values
  x->type_iter = type_iter_ini;
  x->array_iter = array_iter_ini;
  x->index_iter = index_iter_ini;
}
Ejemplo n.º 4
0
void _filesys_get_path(t_filesys *x, const char* str_src, char *str_dest)
{
  char str_tmp[MAX_PATH_CHARS];

  if (_filesys_is_abs(x, str_src)) {
    strncpy_zero(str_tmp, str_src, MAX_PATH_CHARS); }
  else {
    strncpy_zero(str_tmp, x->dir_s, MAX_PATH_CHARS);
    strncat_zero(str_tmp, str_src, MAX_PATH_CHARS); }

  path_nameconform(str_tmp, str_dest, PATH_STYLE_NATIVE, PATH_TYPE_PATH);
}
Ejemplo n.º 5
0
void tralala_paintStrncatNote(char *dst, long argc, t_atom *argv)
{
    char a[5];
    char temp[32];
    long p = atom_getlong(argv + 1);
    long v = atom_getlong(argv + 3);
    long d = atom_getlong(argv + 4);
    long c = atom_getlong(argv + 5);
    
    tralala_paintPitchAsString(a, atom_getlong(argv + 2), 5);
    snprintf_zero(temp, 32, "%ld %s %ld %ld %ld\n", p, a, v, d, c);
    strncat_zero(dst, temp, TLL_STRING_SIZE);
}
Ejemplo n.º 6
0
void hub_getstate(t_hub *x)
{
	subscriberList*		subscriber = x->subscriber;	// head of the linked list
	subscriberIterator	i;
	t_subscriber*		t;
	char*				text = NULL;
	long				textsize = 0;

	if(!x->textEditor)
		x->textEditor = (t_object*)object_new(_sym_nobox, _sym_jed, x, 0);
	
	if(!x->textSize){
		x->textSize = 4096;
		x->text = (char*)malloc(sizeof(char) * x->textSize);
	}
	x->text[0] = 0;
	
	critical_enter(0);
	for(i = subscriber->begin(); i != subscriber->end(); ++i) {
		t = *i;
		if(t->type == jps_subscribe_parameter){
			long	ac = NULL; 
			t_atom* av = NULL;
			
			object_attr_getvalueof(t->object, jps_value, &ac, &av);		// get
			atom_gettext(ac, av, &textsize, &text, 0);
			
			// this is a really lame way to do this...
			if(strlen(x->text) > (x->textSize - 1024)){
				x->textSize += 4096;
				x->text = (char*)realloc(x->text, x->textSize);
			}
			
			strncat_zero(x->text, x->osc_name->s_name, x->textSize);
			strncat_zero(x->text, "/", x->textSize);
			strncat_zero(x->text, t->name->s_name, x->textSize);
			strncat_zero(x->text, " ", x->textSize);
			strncat_zero(x->text, text, x->textSize);
			strncat_zero(x->text, "\n", x->textSize);

			sysmem_freeptr(text);
			text = NULL;
			textsize = 0;
		}
	}
	critical_exit(0);
	
	object_method(x->textEditor, _sym_settext, x->text, _sym_utf_8);
	object_attr_setchar(x->textEditor, gensym("scratch"), 1); 
	object_attr_setsym(x->textEditor, _sym_title, gensym("jamoma module state"));
	
	sysmem_freeptr(text);
}
Ejemplo n.º 7
0
void tralala_paintStrncatZone(char *dst, long argc, t_atom *argv, long status)
{
    char a[5];
    char b[5];
    char temp[32];
  
    tralala_paintPitchAsString(a, atom_getlong(argv + 3), 5);
    tralala_paintPitchAsString(b, atom_getlong(argv + 4), 5);
        
    if (status >= TLL_SELECTED_START) {
    //
    switch (status) {
        case TLL_SELECTED_START : snprintf_zero(temp, 32, "Start : %ld\n", atom_getlong(argv + 1)); break;
        case TLL_SELECTED_END   : snprintf_zero(temp, 32, "End : %ld\n", atom_getlong(argv + 2)); break;
        case TLL_SELECTED_DOWN  : snprintf_zero(temp, 32, "Down : %s\n", a); break;
        case TLL_SELECTED_UP    : snprintf_zero(temp, 32, "Up : %s\n", b); break;
    } 
    //
    } else {
        snprintf_zero(temp, 32, "%ld %ld %s %s\n", atom_getlong(argv + 1), atom_getlong(argv + 2), a, b);
    }
    
    strncat_zero(dst, temp, TLL_STRING_SIZE);
}
Ejemplo n.º 8
0
t_max_err attr_set_prefix(t_ui *obj, void *attr, long argc, t_atom *argv)
{
	uiInternalObject	*anObject;
	t_max_err			err = MAX_ERR_NONE;
	char				name[256];
	
	if(argc && argv)
		obj->attrPrefix = atom_getsym(argv);
	else
		obj->attrPrefix = _sym_nothing;
	
	err = hashtab_lookup(obj->hash_internals, gensym("mute"), (t_object**)&anObject);
	if(!err){
		name[0] = 0;
		if (obj->attrPrefix!=gensym(""))
		{
			if(obj->attrPrefix && obj->attrPrefix->s_name[0])
				strncpy_zero(name, obj->attrPrefix->s_name, 256);
			strncat_zero(name, "/mute", 256);
		}
		else
			strncat_zero(name, "mute", 256);		
		anObject->setName(name);
	}
	
	err = hashtab_lookup(obj->hash_internals, gensym("bypass"), (t_object**)&anObject);
	if(!err){
		name[0] = 0;
		if (obj->attrPrefix!=gensym("")) 
		{
			if(obj->attrPrefix && obj->attrPrefix->s_name[0])
				strncpy_zero(name, obj->attrPrefix->s_name, 256);
			strncat_zero(name, "/bypass", 256);
		}
		else
			strncat_zero(name, "bypass", 256);
		anObject->setName(name);
	}
	
	err = hashtab_lookup(obj->hash_internals, gensym("mix"), (t_object**)&anObject);
	if(!err){
		name[0] = 0;
		if (obj->attrPrefix!=gensym(""))
		{
			if(obj->attrPrefix && obj->attrPrefix->s_name[0])
			strncpy_zero(name, obj->attrPrefix->s_name, 256);
			strncat_zero(name, "/mix", 256);
		}
		else
			strncat_zero(name, "mix", 256);
		anObject->setName(name);
	}
	
	err = hashtab_lookup(obj->hash_internals, gensym("gain"), (t_object**)&anObject);
	if(!err){
		name[0] = 0;
		if (obj->attrPrefix!=gensym(""))
		{
			if(obj->attrPrefix && obj->attrPrefix->s_name[0])
				strncpy_zero(name, obj->attrPrefix->s_name, 256);
			strncat_zero(name, "/gain", 256);
		}
		else
			strncat_zero(name, "gain", 256);
		anObject->setName(name);
	}
	
	err = hashtab_lookup(obj->hash_internals, gensym("freeze"), (t_object**)&anObject);
	if(!err){
		name[0] = 0;
		if (obj->attrPrefix!=gensym(""))
		{
			if(obj->attrPrefix && obj->attrPrefix->s_name[0])
				strncpy_zero(name, obj->attrPrefix->s_name, 256);
			strncat_zero(name, "/freeze", 256);
		}
		else
			strncat_zero(name, "freeze", 256);
		anObject->setName(name);
	}
	
	err = hashtab_lookup(obj->hash_internals, gensym("preview"), (t_object**)&anObject);
	if(!err){
		name[0] = 0;
		if (obj->attrPrefix!=gensym(""))
		{
			if(obj->attrPrefix && obj->attrPrefix->s_name[0])
				strncpy_zero(name, obj->attrPrefix->s_name, 256);
			strncat_zero(name, "/preview", 256);
		}
		else
			strncat_zero(name, "preview", 256);
		anObject->setName(name);
	}
	
	return MAX_ERR_NONE;
}
Ejemplo n.º 9
0
void tralala_paintCurrent(t_tll *x, t_object *pv)
{
    long zoneStatus = 0;
    long i, argc, n = 0;
    t_atom *argv = NULL;
    t_symbol *mark = NULL;
    t_symbol **keys = NULL;
    PIZError err = PIZ_GOOD;
    
    char string[TLL_STRING_SIZE] = "";
    
    t_symbol *s[ ] = { 
        TLL_SYM_BPM, 
        TLL_SYM_CHANCE, 
        TLL_SYM_VELOCITY, 
        TLL_SYM_CHANNEL, 
        TLL_SYM_CHORD,
        TLL_SYM_CELL, 
        TLL_SYM_VALUE, 
        TLL_SYM_SCALE
        };
    
    pizArrayClear(x->temp[0]);
    pizArrayClear(x->temp[1]);
    pizArrayClear(x->temp[2]);
    
    TLL_DATA_LOCK
    
    dictionary_getlong(x->status, TLL_SYM_ZONE, &zoneStatus);
    
    for (i = 0; i < 9; i++) {
        if (!(dictionary_getatoms(x->current, s[i], &argc, &argv)) && (argc > 1)) {
            tralala_paintStrncatPanel(string, argc, argv);
        }
    }
    
    if (!(dictionary_getatoms(x->current, TLL_SYM_MUTE, &argc, &argv)) 
        && (argc > 1)
        && (atom_gettype(argv + 1) == A_LONG)
        && (atom_getlong(argv + 1) == 1)) {
        strncat_zero(string, "•\n", TLL_STRING_SIZE);
    } else {
        strncat_zero(string, "\n", TLL_STRING_SIZE);
    }
    
    if (dictionary_hasentry(x->status, TLL_SYM_ZONE)) {
        if (!(dictionary_getatoms(x->current, TLL_SYM_ZONE, &argc, &argv))) {
            tralala_paintStrncatZone(string, argc, argv, zoneStatus);
        } 
    } else if (!(dictionary_getsym(x->status, TLL_SYM_MARK, &mark)) 
        && (!(dictionary_getatoms(x->current, mark, &argc, &argv)))) {
        tralala_paintStrncatNote(string, argc, argv);
    }
    
    if (!(dictionary_getkeys(x->current, &n, &keys))) {
    //
    for (i = 0; i < n; i++) {
    //
    long k, j, p, status = 0; 
    t_symbol *key = (*(keys + i));
    
    if (!(dictionary_getatoms(x->current, key, &argc, &argv)) 
        && (atom_getsym(argv) == TLL_SYM_NOTE)
        && (argc == 6)) { 
        if (k = dictionary_hasentry(x->status, key)) {
           dictionary_getlong(x->status, key, &status);
        }
        if (!k || (status == TLL_LASSO_UNSELECTED)) {
            p = 0;
        } else if (key != mark) {
            p = 1;
        } else {
            p = 2;
        }
        for (j = 1; j < 5; j++) {
            pizArrayAppend(x->temp[p], atom_getlong(argv + j));
        }
    }
    //
    }

    dictionary_freekeys(x->current, n, keys);
    //
    }
    
    err |= (dictionary_getatoms(x->current, TLL_SYM_ZONE, &argc, &argv)) != MAX_ERR_NONE;
    
    TLL_DATA_UNLOCK 
    
    if (!err) {
        if (!zoneStatus) {
            tralala_paintCurrentZone(x, pv, argc, argv, zoneStatus);
            tralala_paintCurrentNote(x, pv);
        } else {
            tralala_paintCurrentNote(x, pv);
            tralala_paintCurrentZone(x, pv, argc, argv, zoneStatus);
        }
        
        if (x->viewText) {
            tralala_paintCurrentText(x, pv, string);
        }
    }
}
Ejemplo n.º 10
0
void _dict_recurse_dict(t_dict_recurse *x, t_dictionary *dict, t_int32 depth)
{
  TRACE("_dict_recurse_dict");

  t_atom atom[1];

  // ==== Store the state variables on the beginning of the function
  t_bool has_match_ini = x->has_match;
  t_int32 path_len_ini = (t_int32)strlen(x->path);
  t_value_type type_iter_ini = x->type_iter;
  t_dictionary *dict_iter_ini = x->dict_iter;
  t_symbol *key_iter_ini = x->key_iter;
  
  // ==== Add :: to the path
  strncat_zero(x->path, "::", x->path_len_max);

  // ==== Get the dictionary keys
  long  key_cnt = 0;
  t_symbol **key_arr = NULL;
  dictionary_getkeys(dict, &key_cnt, &key_arr);

  // ==== Increment the depth
  depth++;

  // ==== Set the trailing variables before for the recursions
  x->type_iter = VALUE_TYPE_DICT;
  x->dict_iter = dict;

  // ==== Loop through the keys
  for (t_int32 ind = 0; ind < key_cnt; ind++) {

    x->key_iter = key_arr[ind];

    // == Opening actions depending on which command is being processed
    switch (x->command) {
    
    case CMD_FIND_KEY_IN:
    case CMD_FIND_KEY:
      if (regexpr_match(x->search_key_expr, x->key_iter)) {
        x->has_match = true; x->count++; }    // x->has_match changed
      break;

    case CMD_REPLACE_KEY:
      if (regexpr_match(x->search_key_expr, x->key_iter)) {
        dictionary_getatom(dict, x->key_iter, atom);
        dictionary_chuckentry(dict, x->key_iter);
        dictionary_appendatom(dict, x->replace_key_sym, atom);
        x->count++;

        if (x->a_verbose == true) {
          POST("  %s%s  replaced by  \"%s\"",
            x->path, x->key_iter->s_name, x->replace_key_sym->s_name); }
        x->key_iter = x->replace_key_sym; }
      break;
    
    case CMD_DELETE_KEY:
      if (regexpr_match(x->search_key_expr, x->key_iter)) {
        dictionary_deleteentry(dict, x->key_iter);
        x->count++;

        if (x->a_verbose == true) {
          POST("  %s%s  deleted",
            x->path, x->key_iter->s_name, x->replace_key_sym->s_name); }

        continue; }    // NB: No further recursion
      break;

    case CMD_REPLACE_VALUE_FROM_DICT:
      if (regexpr_match(x->search_key_expr, x->key_iter)
          && dictionary_hasentry(x->replace_dict, x->key_iter)) {

        t_symbol *key_iter[2]; key_iter[0] = x->key_iter; key_iter[1] = NULL;
        dictionary_copyentries(x->replace_dict, dict, key_iter);    // NB: Strange it does not require the array size
        x->count++;

        if (x->a_verbose == true) {
          POST("  %s%s  replaced from  \"%s\"",
            x->path, x->key_iter->s_name, x->replace_dict_sym->s_name); }

        continue; }    // NB: No further recursion
      break;
        
    default: break;
    }    // >>>> END switch through potential commands

    // == Set the trailing variables before for the recursion
    strncat_zero(x->path, x->key_iter->s_name, x->path_len_max);    // NB: x->path changed
    
    // == Get the value and recurse to it
    dictionary_getatom(dict, x->key_iter, atom);    // NB: This creates a copy
    _dict_recurse_value(x, atom, depth);
    
    // == Reset the values that changed in this loop
    x->path[path_len_ini + 2] = '\0';
    x->has_match = has_match_ini; }    // >>>> END of loop through the keys
  
  // ==== Restore the remaining state variables to their beginning values
  x->type_iter = type_iter_ini;
  x->dict_iter = dict_iter_ini;
  x->key_iter = key_iter_ini;
  
  if (key_arr) { dictionary_freekeys(dict, key_cnt, key_arr); }
}