Beispiel #1
0
void Cleanup(void)
{
  CloseLocale(Locale);
  if (ColorList) MUI_DeleteCustomClass(ColorList);
  if (LocaleBase) CloseLibrary(LocaleBase);
  if (MUIMasterBase) CloseLibrary(MUIMasterBase);
  if (IntuitionBase) CloseLibrary(IntuitionBase);
  if (GfxBase) CloseLibrary(GfxBase);
}
Beispiel #2
0
static int __init_timerbase(void)
{
    __timeport.mp_Node.ln_Type   = NT_MSGPORT;
    __timeport.mp_Node.ln_Pri    = 0;
    __timeport.mp_Node.ln_Name   = NULL;
    __timeport.mp_Flags          = PA_IGNORE;
    __timeport.mp_SigTask        = FindTask(NULL);
    __timeport.mp_SigBit         = 0;
    NEWLIST(&__timeport.mp_MsgList);

    __timereq.tr_node.io_Message.mn_Node.ln_Type    = NT_MESSAGE;
    __timereq.tr_node.io_Message.mn_Node.ln_Pri     = 0;
    __timereq.tr_node.io_Message.mn_Node.ln_Name    = NULL;
    __timereq.tr_node.io_Message.mn_ReplyPort       = &__timeport;
    __timereq.tr_node.io_Message.mn_Length          = sizeof (__timereq);

    struct Locale *locale = OpenLocale(NULL);
    if (locale)
    {
        __gmtoffset = locale->loc_GMTOffset;
        CloseLocale(locale);
    }
    else
        __gmtoffset = 0;

    if
    (
        OpenDevice
        (
            "timer.device",
            UNIT_VBLANK,
            (struct IORequest *)&__timereq,
            0
        )
        ==
        0
    )
    {
        TimerBase = (struct Device *)__timereq.tr_node.io_Device;
        return 1;
    }
    else
    {
        return 0;
    }
}
Beispiel #3
0
	int __stdc_gmtoffset (

/*  SYNOPSIS */
        void)

/*  FUNCTION

    INPUTS

    RESULT
        The offset to GMT in minutes

    NOTES
        Will return 0 when locale.library is not loaded into memory yet.

    EXAMPLE

    BUGS

    SEE ALSO

    INTERNALS
        Will always query the current locale through locale.library to
        get the GMT offset.

******************************************************************************/
{
    struct StdCIntBase *StdCBase =
        (struct StdCIntBase *)__aros_getbase_StdCBase();
    struct LocaleBase *LocaleBase;
    int gmtoffset = 0;

    if (__locale_available(StdCBase))
    {
        struct Locale *loc;
        LocaleBase = StdCBase->StdCLocaleBase;
        if ((loc = OpenLocale(NULL)))
        {
            gmtoffset = (int)loc->loc_GMTOffset;
            CloseLocale(loc);
        }
    }

    return gmtoffset;
}
Beispiel #4
0
// Free font data
void font_free(font_data *data)
{
	if (data)
	{
		// Close stuff
		font_close(data);

		// Free font
		if (data->font) CloseFont(data->font);

		// Free port
		DeleteMsgPort(data->appport);

		// Close locale stuff
		if (data->locale.li_Locale)
		{
			CloseLocale(data->locale.li_Locale);
			CloseCatalog(data->locale.li_Catalog);
		}

		// Free args
		FreeArgs(data->args);

		// Free labels
		FreeVec(data->size_labels);

		// Free data
		FreeVec(data);
	}

	// Close library
#ifdef __amigaos4__
	DropInterface((struct Interface *)IDOpus);
#endif
	CloseLibrary(DOpusBase);
}
Beispiel #5
0
void CleanupLocale(void)
{
    if (locale) CloseLocale(locale);
    if (catalog) CloseCatalog(catalog);
    if (LocaleBase) CloseLibrary((struct Library *)LocaleBase);
}
Beispiel #6
0
static void getSystemCodeset(struct LibraryHeader *lib)
{
  struct codeset *foundCodeset = NULL;

  ENTER();

  // before we go any query the system via locale.library (which
  // might not be so accurate) we try different other means of
  // finding the codeset/charset of the system
  #if defined(__amigaos4__)
  if(foundCodeset == NULL)
  {
    LONG default_charset = GetDiskFontCtrl(DFCTRL_CHARSET);
    char *charset = (char *)ObtainCharsetInfo(DFCS_NUMBER, default_charset, DFCS_MIMENAME);

    foundCodeset = codesetsFind(&lib->codesets, charset);

    D(DBF_STARTUP, "%s system default codeset: '%s' (diskfont)", foundCodeset ? "found" : "not found", charset);
  }
  #endif

  if(foundCodeset == NULL)
  {
    char codepage[40];

    codepage[0] = '\0';
    if(GetVar("CODEPAGE", codepage, sizeof(codepage), 0) > 0)
    {
      D(DBF_STARTUP, "trying ENV:CODEPAGE '%s'", codepage);
      foundCodeset = codesetsFind(&lib->codesets, codepage);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (ENV:CODEPAGE)", foundCodeset ? "found" : "did not find",
                                                                     foundCodeset ? foundCodeset->name : "?");
  }

  #if defined(__MORPHOS__)
  if(foundCodeset == NULL)
  {
    /* If CODEPAGE did not work (maybe user deleted it or something) we try a keymap instead. This only works
     * in MorphOS 2 and only if an old Amiga keymap is not used.
     */
    if(foundCodeset == NULL)
    {
      struct Library *KeymapBase;

      if((KeymapBase = OpenLibrary("keymap.library", 51)) != NULL)
      {
        /* Since we requested V51 it is either V51 or newer */
        if(KeymapBase->lib_Version > 51 || KeymapBase->lib_Revision >= 4)
        {
          CONST_STRPTR codepage;

          #ifndef GetKeyMapCodepage
          #define GetKeyMapCodepage(__p0) LP1(78, CONST_STRPTR , GetKeyMapCodepage, CONST struct KeyMap *, __p0, a0, , KEYMAP_BASE_NAME, 0, 0, 0, 0, 0, 0)
          #endif

          if((codepage = GetKeyMapCodepage(NULL)) != NULL)
          {
            foundCodeset = codesetsFind(&lib->codesets, codepage);

            D(DBF_STARTUP, "%s system default codeset: '%s' (keymap)", foundCodeset ? "found" : "did not find",
                                                                       foundCodeset ? foundCodeset->name : "?");
          }
        }

        CloseLibrary(KeymapBase);
      }
    }
  }
  #endif

  // if we still do not have our default charset we try to load
  // it from and environment variable ENVARC:CHARSET
  if(foundCodeset == NULL)
  {
    char charset[80];

    charset[0] = '\0';
    if(GetVar("CHARSET", charset, sizeof(charset), 0) > 0)
    {
      D(DBF_STARTUP, "trying ENV:CHARSET '%s'", charset);
      foundCodeset = codesetsFind(&lib->codesets, charset);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (ENV:CHARSET)", foundCodeset ? "found" : "did not find",
                                                                    foundCodeset ? foundCodeset->name : "?");
  }

  // try the country code next
  if(foundCodeset == NULL)
  {
    struct Locale *defaultLocale;

    if((defaultLocale = OpenLocale(NULL)) != NULL)
    {
      int i;
      const struct loc *curLoc = NULL;
      BOOL found = FALSE;

      for(i=0;;i++)
      {
        curLoc = &locs[i];
        if(curLoc == NULL || curLoc->name == NULL)
          break;

        if(defaultLocale->loc_CountryCode == curLoc->carPlateCode || defaultLocale->loc_CountryCode == curLoc->iso3166Code)
        {
          D(DBF_STARTUP, "found country code for '%s'", curLoc->name);
          found = TRUE;
          break;
        }
      }

      if(found == TRUE)
        foundCodeset = codesetsFind(&lib->codesets, curLoc->codesetName);

      CloseLocale(defaultLocale);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (locale/country)", foundCodeset ? "found" : "did not find",
                                                                       foundCodeset ? foundCodeset->name : "?");
  }

  // and if even the CHARSET environment variable didn't work
  // out we check the LANGUAGE env variable against our own
  // internal fallback list
  if(foundCodeset == NULL)
  {
    char language[80];

    language[0] = '\0';
    if(GetVar("LANGUAGE", language, sizeof(language), 0) > 0)
    {
      int i;
      const struct loc *curLoc = NULL;
      BOOL found = FALSE;

      for(i=0;;i++)
      {
        curLoc = &locs[i];
        if(curLoc == NULL || curLoc->name == NULL)
          break;

        if(Strnicmp(language, curLoc->name, curLoc->len) == 0)
        {
          D(DBF_STARTUP, "found language name for '%s'", curLoc->name);
          found = TRUE;
          break;
        }
      }

      if(found == TRUE)
        foundCodeset = codesetsFind(&lib->codesets, curLoc->codesetName);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (ENV:LANGUAGE)", foundCodeset ? "found" : "did not find",
                                                                     foundCodeset ? foundCodeset->name : "?");
  }

  // and the very last check we do to find out the system's charset is
  // to use locale.library.
  if(foundCodeset == NULL)
  {
    struct Locale *locale;

    if((locale = OpenLocale(NULL)) != NULL)
    {
      int i;
      char *language = locale->loc_LanguageName;
      const struct loc *curLoc = NULL;
      BOOL found = FALSE;

      for(i=0;;i++)
      {
        curLoc = &locs[i];
        if(curLoc == NULL || curLoc->name == NULL)
          break;

        if(Strnicmp(language, curLoc->name, curLoc->len) == 0)
        {
          found = TRUE;
          break;
        }
      }

      CloseLocale(locale);

      if(found == TRUE)
        foundCodeset = codesetsFind(&lib->codesets, curLoc->codesetName);
    }

    D(DBF_STARTUP, "%s system default codeset: '%s' (locale/language)", foundCodeset ? "found" : "did not find",
                                                                        foundCodeset ? foundCodeset->name : "?");
  }

  // and if even that very last test didn't work out we
  // can just take the ISO-8859-1 charset as the fallback default
  if(foundCodeset == NULL)
    lib->systemCodeset = codesetsFind(&lib->codesets, "ISO-8859-1");
  else
    lib->systemCodeset = foundCodeset;

  D(DBF_STARTUP, "final system default codeset: '%s'", lib->systemCodeset ? lib->systemCodeset->name : "?");

  LEAVE();
}