Beispiel #1
0
static void test_recreate_world(CuTest * tc)
{
  test_cleanup();
  CuAssertPtrEquals(tc, 0, get_locale("de"));
  CuAssertPtrEquals(tc, 0, (void *)rt_find("horse"));
  CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE));
  CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA));
  CuAssertPtrNotNull(tc, get_resourcetype(R_AURA));
  CuAssertPtrNotNull(tc, (void *)rt_find("money"));

  test_create_world();
  CuAssertPtrEquals(tc, default_locale, get_locale("de"));
  CuAssertPtrNotNull(tc, default_locale);
  CuAssertPtrNotNull(tc, findregion(0, 0));
  CuAssertPtrNotNull(tc, (void *)rt_find("horse"));
  CuAssertPtrNotNull(tc, get_resourcetype(R_HORSE));
  CuAssertPtrNotNull(tc, (void *)rt_find("money"));
  CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE));
  CuAssertPtrNotNull(tc, get_resourcetype(R_SILVER));
  CuAssertPtrNotNull(tc, get_resourcetype(R_AURA));
  CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA));
  CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT));
  CuAssertPtrNotNull(tc, get_resourcetype(R_UNIT));

  test_cleanup();
  CuAssertPtrEquals(tc, 0, get_locale("de"));
  CuAssertPtrEquals(tc, 0, (void*)rt_find("horse"));
  CuAssertPtrEquals(tc, 0, (void*)get_resourcetype(R_HORSE));
  CuAssertPtrNotNull(tc, (void *)rt_find("money"));
  CuAssertPtrNotNull(tc, get_resourcetype(R_LIFE));
  CuAssertPtrNotNull(tc, get_resourcetype(R_SILVER));
  CuAssertPtrNotNull(tc, get_resourcetype(R_AURA));
  CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA));
  CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT));
  CuAssertPtrNotNull(tc, get_resourcetype(R_UNIT));
  CuAssertPtrEquals(tc, 0, findregion(0, 0));
}
Beispiel #2
0
void test_finditemtype(CuTest * tc)
{
    const item_type *itype;
    const resource_type *rtype;
    struct locale * lang;

    test_cleanup();
    test_create_world();

    lang = get_locale("de");
    locale_setstring(lang, "horse", "Pferd");
    rtype = get_resourcetype(R_HORSE);
    itype = finditemtype("Pferd", lang);
    CuAssertPtrNotNull(tc, itype);
    CuAssertPtrEquals(tc, (void*)rtype->itype, (void*)itype);
}
Beispiel #3
0
static void guardian_faction(plane * pl, int id)
{
    region *r;
    faction *f = findfaction(id);

    if (!f) {
        f = calloc(1, sizeof(faction));
        f->banner = _strdup("Sie dienen dem großen Wyrm");
        f->passw = _strdup(itoa36(rng_int()));
        set_email(&f->email, "*****@*****.**");
        f->name = _strdup("Igjarjuks Kundschafter");
        f->race = get_race(RC_ILLUSION);
        f->age = turn;
        f->locale = get_locale("de");
        f->options =
            want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN) |
            want(O_DEBUG);

        f->no = id;
        addlist(&factions, f);
        fhash(f);
    }
    if (f->race != get_race(RC_ILLUSION)) {
        assert(!"guardian id vergeben");
        exit(0);
    }
    f->lastorders = turn;
    f->alive = true;
    for (r = regions; r; r = r->next)
        if (getplane(r) == pl && rterrain(r) != T_FIREWALL) {
            unit *u;
            freset(r, RF_ENCOUNTER);
            for (u = r->units; u; u = u->next) {
                if (u->faction == f)
                    break;
            }
            if (u)
                continue;
            u = create_unit(r, f, 1, get_race(RC_GOBLIN), 0, NULL, NULL);
            set_string(&u->name, "Igjarjuks Auge");
            i_change(&u->items, it_find("roi"), 1);
            set_order(&u->thisorder, NULL);
            fset(u, UFL_ANON_FACTION);
            set_money(u, 1000);
        }
}
Beispiel #4
0
static int tolua_faction_create(lua_State * L)
{
    const char *email = tolua_tostring(L, 1, 0);
    const char *racename = tolua_tostring(L, 2, 0);
    const char *lang = tolua_tostring(L, 3, 0);
    struct locale *loc = get_locale(lang);
    faction *f = NULL;
    const struct race *frace = rc_find(racename);
    if (frace != NULL) {
        f = addfaction(email, NULL, frace, loc, 0);
    }
    if (!f) {
        log_error("faction.create(%s, %s, %s)\n", email, racename, lang);
    }
    tolua_pushusertype(L, f, TOLUA_CAST "faction");
    return 1;
}
Beispiel #5
0
/*
 * Function used when reading tags : we check if the string is valid UTF-8 (else
 *   it may cause problem in EasyTAG)
 *
 * Examples :
 *   - some Ogg Vorbis tags contain ISO-8859-1 characters instead of UTF-8).
 *   - some Flac tags may be probably encoded to ISO-8859-15 (by using for example
 *     "metaflac --no-utf8-convert …") so we convert it from ISO-8859-1 to UTF-8.
 *
 * If not valid UTF-8, we try some conversion to try to get the correct string
 *  - conversion OK : returns the UTF-8 string (new allocated)
 *  - conversion KO : tries others encodings else returns an 'escaped' string
 */
gchar *Try_To_Validate_Utf8_String (const gchar *string)
{
    gchar *ret = NULL;
    GError *error = NULL;

    g_return_val_if_fail (string != NULL, NULL);

    if (g_utf8_validate(string, -1, NULL))
    {
        // String already in UTF-8
        ret = g_strdup(string);
    }else
    {
        const gchar *char_encoding;

        // Get encoding associated to the locale without using UTF-8 (ex , if LANG=fr_FR.UTF-8 it will return ISO-8859-1)
        char_encoding = get_encoding_from_locale(get_locale());
        if (char_encoding)
        {
            //g_print("> char_encoding: %s\n",char_encoding);
            error = NULL;
            ret = g_convert(string, -1, "UTF-8", char_encoding, NULL, NULL, &error);
        }

        if (!ret)
        {
            // Failing that, try ISO-8859-1
            error = NULL;
            ret = g_convert(string, -1, "UTF-8", "ISO-8859-1", NULL, NULL, &error);
        }

        if (!ret)
        {
            gchar *escaped_str = g_strescape(string, NULL);
            Log_Print(LOG_ERROR,_("The string '%s' couldn't be converted into UTF-8 (%s)."),
                        escaped_str, error && error->message ? error->message : _("Invalid UTF-8"));
            g_clear_error(&error);

            ret = escaped_str;
        }
    }

    return ret;
}
Beispiel #6
0
void test_findresourcetype(CuTest * tc)
{
    const resource_type *rtype, *rresult;
    struct locale * lang;

    test_cleanup();
    test_create_world();

    lang = get_locale("de");
    locale_setstring(lang, "horse", "Pferd");
    locale_setstring(lang, "peasant", "Bauer");

    rtype = get_resourcetype(R_HORSE);
    rresult = findresourcetype("Pferd", lang);
    CuAssertPtrNotNull(tc, rresult);
    CuAssertPtrEquals(tc, (void*)rtype, (void*)rresult);

    CuAssertPtrNotNull(tc, findresourcetype("Bauer", lang));
}
Beispiel #7
0
YBUTIL_DECL const std::string str2std(const String &s, const std::string &enc_name)
{
#if defined(YB_USE_WX)
    if (enc_name.empty())
        return std::string(s.mb_str(wxConvUTF8));
    wxCSConv conv(wxString(enc_name.c_str(), wxConvUTF8).GetData());
    return std::string(s.mb_str(conv));
#elif defined(YB_USE_QT)
    if (enc_name.empty())
        return std::string(s.toLocal8Bit().constData());
    QTextCodec *codec = QTextCodec::codecForName(enc_name.c_str());
    return std::string(codec->fromUnicode(s).constData());
#elif defined(YB_USE_UNICODE)
    std::locale loc(get_locale(enc_name).c_str());
    return do_narrow(s, loc);
#else
    return s;
#endif
}
Beispiel #8
0
YBUTIL_DECL const String std2str(const std::string &s, const std::string &enc_name)
{
#if defined(YB_USE_WX)
    if (enc_name.empty())
        return wxString(s.c_str(), wxConvUTF8);
    wxCSConv conv(wxString(enc_name.c_str(), wxConvUTF8).GetData());
    return wxString(s.c_str(), conv);
#elif defined(YB_USE_QT)
    if (enc_name.empty())
        return QString::fromLocal8Bit(s.c_str());
    QTextCodec *codec = QTextCodec::codecForName(enc_name.c_str());
    return codec->toUnicode(s.c_str());
#elif defined(YB_USE_UNICODE)
    std::locale loc(get_locale(enc_name).c_str());
    return do_widen(s, loc);
#else
    return s;
#endif
}
Beispiel #9
0
int get_catalog_file(struct domainbinding *binding, I18N_STRING catalog_file)
{
	int rc = I18N_SUCCESS;
	I18N_STRING locale;

	get_locale(locale);
	char *separator = get_separator();

	safe_strncpy(catalog_file, I18N_STRING_LEN, binding->path, I18N_STRING_LEN);

	safe_strncat(catalog_file, I18N_STRING_LEN, separator, I18N_STRING_LEN);

	safe_strncat(catalog_file, I18N_STRING_LEN, "lang", I18N_STRING_LEN);

	safe_strncat(catalog_file, I18N_STRING_LEN, separator, I18N_STRING_LEN);

	safe_strncat(catalog_file, I18N_STRING_LEN, locale, safe_strnlen(locale, I18N_STRING_LEN));

	safe_strncat(catalog_file, I18N_STRING_LEN, ".mo", I18N_STRING_LEN);

	return rc;
}
Beispiel #10
0
/*********************************************************************
 * wcsrtombs_l (INTERNAL)
 */
static MSVCRT_size_t CDECL MSVCRT_wcsrtombs_l(char *mbstr, const MSVCRT_wchar_t **wcstr,
        MSVCRT_size_t count, MSVCRT__locale_t locale)
{
    char default_char = '\0';
    MSVCRT_size_t tmp = 0;
    BOOL used_default;

    if(!locale)
        locale = get_locale();

    if(!mbstr)
        return WideCharToMultiByte(locale->locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
                                   *wcstr, -1, NULL, 0, &default_char, &used_default)-1;

    while(**wcstr) {
        char buf[3];
        MSVCRT_size_t i, size;

        size = WideCharToMultiByte(locale->locinfo->lc_codepage, WC_NO_BEST_FIT_CHARS,
                                   *wcstr, 1, buf, 3, &default_char, &used_default);
        if(used_default)
            return -1;
        if(tmp+size > count)
            return tmp;

        for(i=0; i<size; i++)
            mbstr[tmp++] = buf[i];
        (*wcstr)++;
    }

    if(tmp < count) {
        mbstr[tmp] = '\0';
        *wcstr = NULL;
    }
    return tmp;
}
Beispiel #11
0
void TranslationServer::load_translations() {

	String locale = get_locale();
	bool found = _load_translations("locale/translations"); //all
	if (_load_translations("locale/translations_"+locale.substr(0,2)))
		found=true;
	if ( locale.substr(0,2) != locale ) {
		if (_load_translations("locale/translations_"+locale))
			found=true;
	}


	if (!found && fallback!="") { //none found anywhere, use fallback

		_load_translations("locale/translations_"+fallback.substr(0,2));
		if ( fallback.substr(0,2) != fallback ) {
			_load_translations("locale/translations_"+fallback);
		}

		this->locale=fallback;

	}

}
Beispiel #12
0
/*********************************************************************
 * _wcstod_l - not exported in native msvcrt
 */
double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
                              MSVCRT__locale_t locale)
{
    unsigned __int64 d=0, hlp;
    unsigned fpcontrol;
    int exp=0, sign=1;
    const MSVCRT_wchar_t *p;
    double ret;
    BOOL found_digit = FALSE;

    if (!MSVCRT_CHECK_PMT(str != NULL)) {
        *MSVCRT__errno() = MSVCRT_EINVAL;
        return 0;
    }

    if(!locale)
        locale = get_locale();

    p = str;
    while(isspaceW(*p))
        p++;

    if(*p == '-') {
        sign = -1;
        p++;
    } else  if(*p == '+')
        p++;

    while(isdigitW(*p)) {
        found_digit = TRUE;
        hlp = d*10+*(p++)-'0';
        if(d>MSVCRT_UI64_MAX/10 || hlp<d) {
            exp++;
            break;
        } else
            d = hlp;
    }
    while(isdigitW(*p)) {
        exp++;
        p++;
    }
    if(*p == *locale->locinfo->lconv->decimal_point)
        p++;

    while(isdigitW(*p)) {
        found_digit = TRUE;
        hlp = d*10+*(p++)-'0';
        if(d>MSVCRT_UI64_MAX/10 || hlp<d)
            break;

        d = hlp;
        exp--;
    }
    while(isdigitW(*p))
        p++;

    if(!found_digit) {
        if(end)
            *end = (MSVCRT_wchar_t*)str;
        return 0.0;
    }

    if(*p=='e' || *p=='E' || *p=='d' || *p=='D') {
        int e=0, s=1;

        p++;
        if(*p == '-') {
            s = -1;
            p++;
        } else if(*p == '+')
            p++;

        if(isdigitW(*p)) {
            while(isdigitW(*p)) {
                if(e>INT_MAX/10 || (e=e*10+*p-'0')<0)
                    e = INT_MAX;
                p++;
            }
            e *= s;

            if(exp<0 && e<0 && exp+e>=0) exp = INT_MIN;
            else if(exp>0 && e>0 && exp+e<0) exp = INT_MAX;
            else exp += e;
        } else {
            if(*p=='-' || *p=='+')
                p--;
            p--;
        }
    }

    fpcontrol = _control87(0, 0);
    _control87(MSVCRT__EM_DENORMAL|MSVCRT__EM_INVALID|MSVCRT__EM_ZERODIVIDE
               |MSVCRT__EM_OVERFLOW|MSVCRT__EM_UNDERFLOW|MSVCRT__EM_INEXACT, 0xffffffff);

    if(exp>0)
        ret = (double)sign*d*pow(10, exp);
    else
        ret = (double)sign*d/pow(10, -exp);

    _control87(fpcontrol, 0xffffffff);

    if((d && ret==0.0) || isinf(ret))
        *MSVCRT__errno() = MSVCRT_ERANGE;

    if(end)
        *end = (MSVCRT_wchar_t*)p;

    return ret;
}
Beispiel #13
0
YBUTIL_DECL const std::wstring str_widen(
        const std::string &narrow, const std::string &enc_name)
{
    std::locale loc(get_locale(enc_name).c_str());
    return do_widen(narrow, loc);
}
Beispiel #14
0
YBUTIL_DECL const std::string str_narrow(
        const std::wstring &wide, const std::string &enc_name)
{
    std::locale loc(get_locale(enc_name).c_str());
    return do_narrow(wide, loc);
}
Beispiel #15
0
newfaction *read_newfactions(const char *filename)
{
    newfaction *newfactions = NULL;
    FILE *F = fopen(filename, "r");
    char buf[1024];

    if (F == NULL)
        return NULL;
    for (;;) {
        faction *f;
        char race[20], email[64], lang[8], password[16];
        newfaction *nf, **nfi;
        int bonus = 0, subscription = 0;
        int alliance = 0;

        if (fgets(buf, sizeof(buf), F) == NULL)
            break;

        email[0] = '\0';
        password[0] = '\0';

        if (sscanf(buf, "%54s %20s %8s %d %d %16s %d", email, race, lang, &bonus,
            &subscription, password, &alliance) < 3)
            break;
        if (email[0] == '\0')
            break;
        if (password[0] == '\0') {
            size_t sz;
            sz = strlcpy(password, itoa36(rng_int()), sizeof(password));
            sz += strlcat(password, itoa36(rng_int()), sizeof(password));
        }
        for (f = factions; f; f = f->next) {
            if (strcmp(f->email, email) == 0 && f->subscription
                && f->age < MINAGE_MULTI)
                break;
        }
        if (f && f->units)
            continue;                 /* skip the ones we've already got */
        for (nf = newfactions; nf; nf = nf->next) {
            if (strcmp(nf->email, email) == 0)
                break;
        }
        if (nf)
            continue;
        nf = calloc(sizeof(newfaction), 1);
        if (set_email(&nf->email, email) != 0) {
            log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email);
            continue;
        }
        nf->password = _strdup(password);
        nf->race = rc_find(race);
        nf->subscription = subscription;
        if (alliances != NULL) {
            struct alliance *al = findalliance(alliance);
            if (al == NULL) {
                char zText[64];
                sprintf(zText, "Allianz %d", alliance);
                al = makealliance(alliance, zText);
            }
            nf->allies = al;
        }
        else {
            nf->allies = NULL;
        }
        if (nf->race == NULL) {
            /* if the script didn't supply the race as a token, then it gives us a
             * race in the default locale (which means that itis a UTF8 string) */
            nf->race = findrace(race, default_locale);
            if (nf->race == NULL) {
                char buffer[32];
                size_t outbytes = sizeof(buffer) - 1;
                size_t inbytes = strlen(race);
                unicode_latin1_to_utf8(buffer, &outbytes, race, &inbytes);
                buffer[outbytes] = 0;
                nf->race = findrace(buffer, default_locale);
                if (nf->race == NULL) {
                    log_error("new faction has unknown race '%s'.\n", race);
                    free(nf);
                    continue;
                }
            }
        }
        nf->lang = get_locale(lang);
        nf->bonus = bonus;
        assert(nf->race && nf->email && nf->lang);
        nfi = &newfactions;
        while (*nfi) {
            if ((*nfi)->race == nf->race)
                break;
            nfi = &(*nfi)->next;
        }
        nf->next = *nfi;
        *nfi = nf;
    }
    fclose(F);
    return newfactions;
}
Beispiel #16
0
/*
 * Convert a string from UTF-8 to the filename system encoding.
 *  - conversion OK : returns the string in filename system encoding (new allocated)
 *  - conversion KO : display error message + returns nothing!
 */
gchar *filename_from_display (const gchar *string)
{
    GError *error = NULL;
    gchar *ret = NULL;
    const gchar *char_encoding = NULL;
    //const gchar *filename_encoding = NULL;

    g_return_val_if_fail (string != NULL, NULL);

    // Get system encoding from LANG if found (ex : fr_FR.UTF-8 => UTF-8)
    if (get_locale())
        char_encoding = strchr(get_locale(), '.');

    if (char_encoding)
        char_encoding = char_encoding+1; // Skip the '.'
    if (char_encoding)
    {
        error = NULL;

        if (FILENAME_CHARACTER_SET_OTHER)
        {
            ret = g_convert(string, -1, char_encoding, "UTF-8", NULL, NULL, &error);

        }else if (FILENAME_CHARACTER_SET_APPROXIMATE)
        {
            // iconv_open (3):
            // When the string "//TRANSLIT" is appended to tocode, transliteration
            // is activated. This means that when a character cannot be represented
            // in the target character set, it can be approximated through one or
            // several similarly looking characters.
            gchar *enc = g_strconcat(char_encoding, "//TRANSLIT", NULL);
            ret = g_convert(string, -1, enc, "UTF-8", NULL, NULL, &error);
            g_free(enc);

        }else if (FILENAME_CHARACTER_SET_DISCARD)
        {
            // iconv_open (3):
            // When the string "//IGNORE" is appended to tocode, characters that
            // cannot be represented in the target character set will be silently
            // discarded.
            gchar *enc = g_strconcat(char_encoding, "//IGNORE", NULL);
            ret = g_convert(string, -1, enc, "UTF-8", NULL, NULL, &error);
            g_free(enc);
        }
    }

    if (!ret)
    {
        // Get system encoding from locale in LANG if found (ex : fr_FR.UTF-8 => fr_FR => ISO-8859-1)
        char_encoding = get_encoding_from_locale(get_locale());
        if (char_encoding)
        {
            //g_print("> char_encoding: %s\n",char_encoding);
            error = NULL;
            ret = g_convert(string, -1, char_encoding, "UTF-8", NULL, NULL, &error);
        }
    }

    if (!ret)
    {
        // Failing that, try ISO-8859-1
        error = NULL;
        ret = g_convert(string, -1, "ISO-8859-1", "UTF-8", NULL, NULL, &error);
    }

    if (!ret)
    {
        if (g_utf8_validate(string, -1, NULL))
        {
            // String already in UTF-8
            ret = g_strdup(string);
        }
    }

    if (!ret)
    {
        // Conversion KO!
        gchar *escaped_str = g_strescape(string, NULL);
        Log_Print(LOG_ERROR,_("The UTF-8 string '%s' couldn't be converted into filename encoding (%s)."),
                    escaped_str, error && error->message ? error->message : _("Invalid UTF-8"));
        g_clear_error(&error);

        ret = escaped_str;
    }

#ifdef G_OS_WIN32
    //ET_Win32_Path_Replace_Backslashes (ret);
#endif /* G_OS_WIN32 */

    return ret; // We need to catch errors (e.g. temp=NULL) in the real code
}
/**
 * parse_encoding_profile:
 * @in: a #GKeyFile
 * @parentprofilename: the parent profile name (including 'profile-' or 'streamprofile-' header)
 * @profilename: the profile name group to parse
 * @nbgroups: the number of top-level groups
 * @groups: the top-level groups
 */
static GstEncodingProfile *
parse_encoding_profile (GKeyFile * in, gchar * parentprofilename,
    gchar * profilename, gsize nbgroups, gchar ** groups)
{
  GstEncodingProfile *sprof = NULL;
  gchar **parent;
  gchar *proftype, *format, *preset, *restriction, *pname, *description,
      *locale;
  GstCaps *formatcaps = NULL;
  GstCaps *restrictioncaps = NULL;
  gboolean variableframerate;
  gint pass, presence;
  gsize i, nbencprofiles;

  GST_DEBUG ("parentprofilename : %s , profilename : %s",
      parentprofilename, profilename);

  if (parentprofilename) {
    gboolean found = FALSE;

    parent =
        g_key_file_get_string_list (in, profilename, "parent",
        &nbencprofiles, NULL);
    if (!parent || !nbencprofiles) {
      return NULL;
    }

    /* Check if this streamprofile is used in <profilename> */
    for (i = 0; i < nbencprofiles; i++) {
      if (!g_strcmp0 (parent[i], parentprofilename)) {
        found = TRUE;
        break;
      }
    }
    g_strfreev (parent);

    if (!found) {
      GST_DEBUG ("Stream profile '%s' isn't used in profile '%s'",
          profilename, parentprofilename);
      return NULL;
    }
  }

  pname = g_key_file_get_value (in, profilename, "name", NULL);

  locale = get_locale ();
  /* will try to fall back to untranslated string if no translation found */
  description = g_key_file_get_locale_string (in, profilename,
      "description", locale, NULL);
  g_free (locale);

  /* Note: a missing description is normal for non-container profiles */
  if (description == NULL) {
    GST_LOG ("Missing 'description' field for streamprofile %s", profilename);
  }

  /* Parse the remaining fields */
  proftype = g_key_file_get_value (in, profilename, "type", NULL);
  if (!proftype) {
    GST_WARNING ("Missing 'type' field for streamprofile %s", profilename);
    return NULL;
  }

  format = g_key_file_get_value (in, profilename, "format", NULL);
  if (format) {
    formatcaps = gst_caps_from_string (format);
    g_free (format);
  }

  preset = g_key_file_get_value (in, profilename, "preset", NULL);

  restriction = g_key_file_get_value (in, profilename, "restriction", NULL);
  if (restriction) {
    restrictioncaps = gst_caps_from_string (restriction);
    g_free (restriction);
  }

  presence = g_key_file_get_integer (in, profilename, "presence", NULL);
  pass = g_key_file_get_integer (in, profilename, "pass", NULL);
  variableframerate =
      g_key_file_get_boolean (in, profilename, "variableframerate", NULL);

  /* Build the streamprofile ! */
  if (!g_strcmp0 (proftype, "container")) {
    GstEncodingProfile *pprof;

    sprof =
        (GstEncodingProfile *) gst_encoding_container_profile_new (pname,
        description, formatcaps, preset);
    /* Now look for the stream profiles */
    for (i = 0; i < nbgroups; i++) {
      if (!g_ascii_strncasecmp (groups[i], "streamprofile-", 13)) {
        pprof = parse_encoding_profile (in, pname, groups[i], nbgroups, groups);
        if (pprof) {
          gst_encoding_container_profile_add_profile (
              (GstEncodingContainerProfile *) sprof, pprof);
        }
      }
    }
  } else if (!g_strcmp0 (proftype, "video")) {
    sprof =
        (GstEncodingProfile *) gst_encoding_video_profile_new (formatcaps,
        preset, restrictioncaps, presence);
    gst_encoding_video_profile_set_variableframerate ((GstEncodingVideoProfile
            *) sprof, variableframerate);
    gst_encoding_video_profile_set_pass ((GstEncodingVideoProfile *) sprof,
        pass);
    gst_encoding_profile_set_name (sprof, pname);
    gst_encoding_profile_set_description (sprof, description);
  } else if (!g_strcmp0 (proftype, "audio")) {
    sprof =
        (GstEncodingProfile *) gst_encoding_audio_profile_new (formatcaps,
        preset, restrictioncaps, presence);
    gst_encoding_profile_set_name (sprof, pname);
    gst_encoding_profile_set_description (sprof, description);
  } else
    GST_ERROR ("Unknown profile format '%s'", proftype);

  if (restrictioncaps)
    gst_caps_unref (restrictioncaps);
  if (formatcaps)
    gst_caps_unref (formatcaps);

  g_free (pname);
  g_free (description);
  g_free (preset);
  g_free (proftype);

  return sprof;
}
Beispiel #18
0
void locale_set(const char *lang, const char *key, const char *str) {
    struct locale *loc = get_locale(lang);
    if (loc) {
        locale_setstring(loc, key, str);
    }
}