/** * \brief Compare old and new channels and produce change flags * * This function compares channels and as result it produces flags with * changes. For more information see #PEVENTS_CHANGE. * \note The function MUST be successfully mapped, otherwise information * do not make sense. * \param[in] ch_old Old channel (from a profiler) * \param[in] ch_new New channel (from a profiler) * \return Flags with changes. */ static uint16_t pevents_update_mapper_change_flags(void *ch_old, void *ch_new) { void *prfl_new = channel_get_profile(ch_new); void *prfl_old = channel_get_profile(ch_old); uint16_t flags = 0U; // Check storage directory const char *dir_new = profile_get_directory(prfl_new); const char *dir_old = profile_get_directory(prfl_old); if (strcmp(dir_new, dir_old) != 0) { // The directory has been changed flags |= PEVENTS_CHANGE_DIR; } // Check profile type enum PROFILE_TYPE type_new = profile_get_type(prfl_new); enum PROFILE_TYPE type_old = profile_get_type(prfl_old); if (type_new != type_old) { // The type has been changed flags |= PEVENTS_CHANGE_TYPE; } return flags; }
/* * FIXME: fetching from the backend is not stubbed yet! */ void Ut_ProfileValueTests::profilevaluefetchFromBackend() { #ifdef HAVE_LIBPROFILE QFETCH(QString, key); QString type (profile_get_type(key.toAscii().data())); QProfileValue tc(key); tc.fetchFromBackend (); SYS_DEBUG ("*** key = %s", SYS_STR(key)); SYS_DEBUG ("*** value = %s", SYS_STR(tc.value().toString())); SYS_DEBUG ("*** type = %s", SYS_STR(type)); if (type == "SOUNDFILE") { QVERIFY (!tc.value().toString().isEmpty ()); } else if (type == "INTEGER 0-3") { QVERIFY (0 <= tc.value().toInt() && 3 >= tc.value().toInt()); } else { SYS_WARNING ("Unhandled type: %s", SYS_STR(type)); } #endif }
int main(int argc, char **argv) { int opt; char *p,*k,*v,**w; while( (opt = getopt(argc, argv, "hp:s:d:g:t:TlkvV:B:I:D:G:rR:")) != -1 ) { switch (opt) { case 'h': write(STDOUT_FILENO, usage, sizeof usage - 1); exit(0); case 'p': profile_set_profile(optarg); break; case 'l': p = profile_get_profile(); w = profile_get_profiles(); for( size_t i = 0; w && w[i]; ++i ) { printf("%s%s\n", w[i], strcmp(w[i],p) ? "" : "*"); } profile_free_profiles(w); free(p); break; case 'k': w = profile_get_keys(); for( size_t i = 0; w && w[i]; ++i ) { printf("%s\n", w[i]); } profile_free_keys(w); break; case 'r': w = profile_get_keys(); for( size_t i = 0; w && w[i]; ++i ) { profile_set_value(0, w[i], ""); } profile_free_keys(w); break; case 'R': w = profile_get_keys(); for( size_t i = 0; w && w[i]; ++i ) { profile_set_value(optarg, w[i], ""); } profile_free_keys(w); break; case 'v': case 'V': { p = (opt == 'v') ? 0 : optarg; profileval_t *t = profile_get_values(p); for( size_t i = 0; t && t[i].pv_key; ++i ) { printf("%s = %s (%s)\n", t[i].pv_key, t[i].pv_val, t[i].pv_type); } profile_free_values(t); } break; case 'T': exit(track()); case 's': parse(optarg, &p,&k,&v); profile_set_value(p, k, v); break; case 'd': parse(optarg, &p,&k,&v); profile_set_value(p, k, ""); break; case 'g': parse(optarg, &p,&k,&v); v = profile_get_value(p,k); printf("%s\n", v); free(v); break; case 'G': { parse(optarg, &p,&k,&v); char *s = profile_get_value(p,k); printf("STRING: '%s'\n", s); free(s); int b = profile_get_value_as_bool(p,k); printf("BOOL: %s (%d)\n", b ? "On" : "Off", b); int i = profile_get_value_as_int(p,k); printf("INT: %d\n", i); double d = profile_get_value_as_double(p,k); printf("DOUBLE:%g\n", d); } break; case 'B': { parse(optarg, &p,&k,&v); int v = profile_get_value_as_bool(p,k); printf("BOOL:%s (%d)\n", v ? "On" : "Off", v); } break; case 'I': { parse(optarg, &p,&k,&v); int v = profile_get_value_as_int(p,k); printf("INT:%d\n", v); } break; case 'D': { parse(optarg, &p,&k,&v); double v = profile_get_value_as_double(p,k); printf("DOUBLE:%g\n", v); } break; case 't': v = profile_get_type(optarg); printf("%s\n", v); free(v); break; default: /* '?' */ fprintf(stderr, "(use -h for usage info)\n"); exit(EXIT_FAILURE); } } return 0; }