/** @internal * @brief initialise internationalisation * * @since Oyranos: version 0.x.x * @date 26 november 2007 (API 0.0.1) */ void oyI18NInit_() { DBG_PROG_START oy_lang_ = oyStringCopy_("C", oyAllocateFunc_); #ifdef USE_GETTEXT if(!oy_country_ || !oy_language_) { char * temp = 0; if(getenv("OY_LOCALEDIR") && oyStrlen_(getenv("OY_LOCALEDIR"))) oy_domain_path = oyStringCopy_(getenv("OY_LOCALEDIR"), oyAllocateFunc_); oyStringAdd_( &temp, "NLSPATH=", oyAllocateFunc_, oyDeAllocateFunc_); oyStringAdd_( &temp, oy_domain_path, oyAllocateFunc_, oyDeAllocateFunc_); putenv(temp); /* Solaris */ #if 0 if(oy_debug_memory) oyFree_m_(temp); /* putenv requires a static string ??? */ #endif if(oy_debug) WARNc2_S("bindtextdomain( %s, %s )", oy_domain, oy_domain_path ); bindtextdomain( oy_domain, oy_domain_path ); DBG_NUM2_S("oy_domain_path %s %s", oy_domain, oy_domain_path) if(oy_domain_codeset) { if(oy_debug) WARNc2_S("bindtextdomain( %s, %s )", oy_domain, oy_domain_codeset ); bind_textdomain_codeset(oy_domain, oy_domain_codeset); } DBG_NUM2_S("oy_domain_codeset %s %s", oy_domain, oyNoEmptyString_m(oy_domain_codeset)) /* we use the posix setlocale interface; * the environmental LANG variable is flacky */ if(setlocale(LC_MESSAGES, 0)) { if(oy_lang_) oyDeAllocateFunc_(oy_lang_); temp = oyStringCopy_(setlocale(LC_MESSAGES, 0), oyAllocateFunc_); oy_lang_ = temp; } if(oy_lang_) { if(oyStrchr_(oy_lang_,'_')) { char * tmp = 0; int len = oyStrlen_(oy_lang_); oyAllocHelper_m_( tmp, char, len + 5, 0, DBG_PROG_ENDE; return ); oySprintf_( tmp, "%s", oyStrchr_(oy_lang_,'_')+1 ); if(oyStrlen_(tmp) > 2) tmp[2] = 0; oy_country_ = tmp; tmp = 0; /*oy_country_ = oyStringCopy_(oyStrchr_(oy_lang_,'_')+1, oyAllocateFunc_); if(!oy_country_) return;*/ tmp = oyStrchr_(oy_country_,'.'); if(tmp) tmp[0] = 0; tmp = 0; oyAllocHelper_m_( tmp, char, len + 5, 0, DBG_PROG_ENDE; return ); oySprintf_( tmp, "%s", oy_lang_ ); oy_language_ = tmp; tmp = 0; /*oy_language_ = oyStringCopy_(oy_lang_, oyAllocateFunc_); if(!oy_language_) return;*/ tmp = oyStrchr_(oy_language_,'_'); if(tmp) tmp[0] = 0; } else
/** * @internal * Function oyOption_GetValueText_ * @memberof oyOption_s * @brief get value as a text dump * * @param obj the option * @param allocateFunc user allocator * @return the text * * @version Oyranos: 0.1.9 * @since 2008/12/05 (Oyranos: 0.1.9) * @date 2009/08/17 */ char * oyOption_GetValueText_( oyOption_s_ * obj, oyAlloc_f allocateFunc ) { int error = !obj; char * erg = 0; oyValue_u * v = 0; oyStructList_s * oy_struct_list = 0; char * text = 0; char * save_locale = 0; if(error <= 0) v = obj->value; if(!allocateFunc) allocateFunc = oyAllocateFunc_; error = !v; save_locale = oyStringCopy_( setlocale(LC_NUMERIC, 0 ), oyAllocateFunc_ ); setlocale(LC_NUMERIC, "C"); if(error <= 0) { int n = 1, i = 0; char * tmp = oyAllocateFunc_(1024); const char * ct = 0; switch(obj->value_type) { case oyVAL_INT_LIST: n = v->int32_list[0]; break; case oyVAL_DOUBLE_LIST: n = (int)v->dbl_list[0]; break; case oyVAL_STRING_LIST: n = 0; while( v->string_list[n] ) ++n; break; case oyVAL_INT: case oyVAL_DOUBLE: case oyVAL_STRING: case oyVAL_STRUCT: n = 1; break; case oyVAL_NONE: case oyVAL_MAX: n = 0; break; } if(obj->value_type == oyVAL_STRUCT) { oy_struct_list = (oyStructList_s*) v->oy_struct; if(oy_struct_list) { if(oy_struct_list->type_ == oyOBJECT_STRUCT_LIST_S) n = oyStructList_Count( oy_struct_list ); } else WARNc2_S( "missed \"oy_struct\" member of \"%s\" [%d]", obj->registration, oyObject_GetId(obj->oy_) ); } for(i = 0; i < n; ++i) { if(obj->value_type == oyVAL_INT) oySprintf_(tmp, "%d", v->int32); if(obj->value_type == oyVAL_DOUBLE) oySprintf_(tmp, "%g", v->dbl); if(obj->value_type == oyVAL_INT_LIST) oySprintf_(tmp, "%d", v->int32_list[i+1]); if(obj->value_type == oyVAL_DOUBLE_LIST) oySprintf_(tmp, "%g", v->dbl_list[i+1]); if((obj->value_type == oyVAL_INT_LIST || obj->value_type == oyVAL_DOUBLE_LIST) && i) STRING_ADD( text, "," ); switch(obj->value_type) { case oyVAL_INT: case oyVAL_DOUBLE: case oyVAL_INT_LIST: case oyVAL_DOUBLE_LIST: STRING_ADD( text, tmp ); break; case oyVAL_STRING: STRING_ADD( text, v->string ); break; case oyVAL_STRING_LIST: STRING_ADD( text, v->string_list[i] ); break; case oyVAL_STRUCT: case oyVAL_NONE: case oyVAL_MAX: break; } if(obj->value_type == oyVAL_STRUCT) { oyStruct_s * oy_struct = 0; if(oy_struct_list && oy_struct_list->type_ == oyOBJECT_STRUCT_LIST_S) oy_struct = oyStructList_Get_( ( oyStructList_s_*)oy_struct_list, i ); else if(v->oy_struct) oy_struct = v->oy_struct; if(oy_struct) { ct = 0; /* get explicite name */ if(oy_struct->oy_) ct = oyObject_GetName( oy_struct->oy_, oyNAME_NICK ); if(!ct) /* fall back to oyCMMapi9_s object type lookup */ ct = oyStruct_GetText( oy_struct, oyNAME_NICK, 0 ); if(ct) STRING_ADD( text, ct ); if(!ct) /* fall back to plain struct type name, if known */ STRING_ADD ( text, oyStructTypeToText(oy_struct->type_) ); } } } if(text) erg = oyStringCopy_( text, allocateFunc ); oyFree_m_( tmp ); if(!text) { DBG_NUM2_S( "missed value in \"%s\" [%d]", obj->registration, oyObject_GetId(obj->oy_) ); } else oyFree_m_( text ); } setlocale(LC_NUMERIC, save_locale); oyFree_m_( save_locale ); return erg; }
/** Function oyFilterNode_Create * @memberof oyFilterNode_s * @brief Initialise a new filter node object properly * * @param registration the processing filter @ref registration string * @param filter the context filter * @param object the optional object * * @version Oyranos: 0.9.6 * @date 2014/07/01 * @since 2008/07/30 (Oyranos: 0.1.8) */ oyFilterNode_s * oyFilterNode_Create(const char * registration, oyFilterCore_s * filter, oyObject_s object ) { oyFilterNode_s_ * s = 0; int error = 0; oyAlloc_f allocateFunc_ = 0; oyFilterCore_s_ * filter_ = (oyFilterCore_s_*)filter; if(!filter) return (oyFilterNode_s*) s; s = (oyFilterNode_s_*) oyFilterNode_New( object ); error = !s; if(error <= 0) { allocateFunc_ = s->oy_->allocateFunc_; s->core = (oyFilterCore_s_*)oyFilterCore_Copy( filter, object ); if(!s->core) { WARNc2_S("Could not copy filter: %s %s", filter_->registration_, filter_->category_) error = 1; } if(error <= 0) s->api7_ = (oyCMMapi7_s_*) oyCMMsGetFilterApi_( registration, oyOBJECT_CMM_API7_S ); if(error <= 0 && !s->api7_) { WARNc2_S("Could not obtain filter api7 for: %s %s", filter_->registration_, filter_->category_) error = 1; } if(s->api7_) { s->plugs_n_ = s->api7_->plugs_n + s->api7_->plugs_last_add; if(s->api7_->plugs_last_add) --s->plugs_n_; s->sockets_n_ = s->api7_->sockets_n + s->api7_->sockets_last_add; if(s->api7_->sockets_last_add) --s->sockets_n_; } if(s->core) { int count = oyFilterNode_EdgeCount( (oyFilterNode_s*) s, 0, 0 ); size_t len; if(count < 0) count = 0; len = sizeof(oyFilterSocket_s*) * (count + 1); s->sockets = allocateFunc_( len ); memset( s->sockets, 0, len ); len = sizeof(oyFilterSocket_s*) * (oyFilterNode_EdgeCount( (oyFilterNode_s*) s, 1, 0 ) + 1); len = len?len:sizeof(oyFilterSocket_s*); s->plugs = allocateFunc_( len ); memset( s->plugs, 0, len ); s->relatives_ = allocateFunc_( oyStrlen_(filter_->category_) + 24 ); oySprintf_( s->relatives_, "%d: %s", oyObject_GetId(s->oy_), s->core->category_); } } if(error) oyFilterNode_Release( (oyFilterNode_s**) &s ); return (oyFilterNode_s*) s; }
/** Function: oyNamedColor_GetName * @memberof oyNamedColor_s * @brief get color channels * * @since Oyranos: version 0.1.8 * @date 22 december 2007 (API 0.1.8) */ const char * oyNamedColor_GetName( oyNamedColor_s * color, oyNAME_e type, uint32_t flags ) { const char * text = 0; oyNamedColor_s_ * s = (oyNamedColor_s_*) color; if(!s) return 0; if(!s->oy_) return 0; text = oyObject_GetName( s->oy_, type ); if(!text && flags) { const char * tmp = 0; char * txt = 0; double l[3]; int i; icSignature sig = oyProfile_GetSignature( s->profile_, oySIGNATURE_COLOR_SPACE ); oyAllocHelper_m_( txt, char, 1024, 0, return 0 ); oyNamedColor_GetColorStd( color, oyEDITING_LAB, l, oyDOUBLE, 0, 0 ); switch(type) { case oyNAME_DESCRIPTION: tmp = oyObject_GetName( s->oy_, oyNAME_NAME ); if(!tmp) tmp = oyObject_GetName( s->oy_, oyNAME_NICK ); if(tmp) oySprintf_(txt, "%s: CIE*Lab: ", tmp ); else oySprintf_(txt, "CIE*Lab: "); for(i = 0; i < 3; ++i) oySprintf_( &txt[ oyStrlen_(txt) ], "%.02f ", l[i] ); tmp = oyICCColorSpaceGetName( sig ); if(tmp) oySprintf_( &txt[ oyStrlen_(txt) ], "; %s:", tmp ); if( s->channels_ ) for(i = 0; i < oyICCColorSpaceGetChannelCount( sig ); ++i) oySprintf_( &txt[ oyStrlen_(txt) ], "%.02f ", s->channels_[i] ); break; default: break; } oyObject_SetName ( s->oy_, txt, type ); oyFree_m_( txt ); text = oyObject_GetName( s->oy_, type ); } if(!text && type > oyNAME_NICK) text = oyObject_GetName( s->oy_, type - 2 ); if(!text && type > oyNAME_NAME) text = oyObject_GetName( s->oy_, type - 1 ); if(!text && type < oyNAME_NICK ) text = oyObject_GetName( s->oy_, type + 2 ); if(!text && type < oyNAME_DESCRIPTION ) text = oyObject_GetName( s->oy_, type + 1 ); if(!text) text = _("----"); return text; }