int lib_locale_f_OpenLocale_2(emumsg_syscall_t *msg) { /* Make real syscall */ msg->arg[0]._aptr = OpenLocale(msg->arg[0]._strptr); return HOOK_DONE; }
int main(void) { IPTR args[ARG_COUNT] = {0}; struct RDArgs *read_args; struct AnchorPath *anchor; LONG error; LONG return_code = RETURN_WARN; TEXT *text, *spaces, *pattern = NULL, *path_buffer, *user_pattern = NULL, *p, ch, **from; BOOL found, success = TRUE, new_dir, print_names; UWORD indent = 0, pat_buf_length, cut_off, pat_length; UBYTE k, q; struct Locale *locale; /* Allocate buffers */ spaces = AllocMem(SPACES_SIZE, MEMF_CLEAR); anchor = AllocMem(sizeof(struct AnchorPath), MEMF_CLEAR); path_buffer = AllocMem(PATH_BUF_SIZE,MEMF_ANY); if(anchor && spaces && path_buffer) { locale = OpenLocale(NULL); for(text = spaces + SPACES_SIZE - 1; text > spaces; *(--text) = ' '); /* Parse arguments */ read_args = ReadArgs((STRPTR)template, args, NULL);
BOOL Setup(void) { if (!(GfxBase = OpenLibrary("graphics.library", 0))) return FALSE; if (!(IntuitionBase = OpenLibrary("intuition.library", 0))) return FALSE; if (!(MUIMasterBase = OpenLibrary("muimaster.library", 0))) return FALSE; if (!(LocaleBase = OpenLibrary("locale.library", 0))) return FALSE; if (!(ColorList = CreateColorListClass())) return FALSE; Locale = OpenLocale(NULL); if (FindPort("SysLog")) return FALSE; return TRUE; }
void InitLocale(STRPTR catname, ULONG version) { #ifdef __AROS__ LocaleBase = (struct LocaleBase *)OpenLibrary("locale.library", 39); #else LocaleBase = (struct Library *)OpenLibrary("locale.library", 39); #endif if (LocaleBase) { catalog = OpenCatalog(NULL, catname, OC_Version, version, TAG_DONE); locale = OpenLocale(NULL); } }
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; } }
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; }
int main(int argc,char **argv) { font_data *data; // Need dopus library if (!(DOpusBase=OpenLibrary("dopus5.library",LIB_VERSION))) if (!(DOpusBase=OpenLibrary("dopus5:libs/dopus5.library",55))) return(10); #ifdef __amigaos4__ if (!(IDOpus = (struct DOpusIFace *)GetInterface(DOpusBase, "main", 1, NULL))) { CloseLibrary(DOpusBase); return(10); } #endif // Allocate data if (!(data=AllocVec(sizeof(font_data),MEMF_CLEAR))) { font_free(0); return(5); } // Parse arguments data->args= ReadArgs( "FONT,SIZE/N,B=BOLD/S,I=ITALIC/S,U=ULINE/S,PUBSCREEN/K", (APTR)data->arg_array, NULL); // Default to topaz 8 #ifdef __AROS__ strcpy(data->font_name,"ttcourier.font"); #else strcpy(data->font_name,"topaz.font"); #endif data->font_size=8; // Got font name? if (data->arg_array[ARG_FONT]) font_get_name(data,(char *)data->arg_array[ARG_FONT]); // Got a font size? if (data->arg_array[ARG_SIZE] && *((long *)data->arg_array[ARG_SIZE])) { data->font_size=*((long *)data->arg_array[ARG_SIZE]); data->first=TRUE; } // Initialise locale init_locale_data(&data->locale); // Got locale library? if (LocaleBase) { BPTR lock; // Change PROGDIR: to dopus5: if ((lock=Lock("dopus5:",ACCESS_READ))) #ifdef __AROS__ // the lock returned here is the initial PROGDIR: which belongs to the system, // so it's not a very good idea to just UnLock it SetProgramDir(lock); #else UnLock(SetProgramDir(lock)); #endif // Initialise data->locale.li_LocaleBase=LocaleBase; data->locale.li_Catalog=OpenCatalogA(0,"viewfont.catalog",0); data->locale.li_Locale=OpenLocale(0); } // Create message port data->appport=CreateMsgPort(); // Open window if (!(font_open(data))) { font_free(data); return(5); } // Initial gadget settings if (data->arg_array[ARG_BOLD]) SetGadgetValue(data->list,GAD_FONT_BOLD,1); if (data->arg_array[ARG_ITALIC]) SetGadgetValue(data->list,GAD_FONT_ITALIC,1); if (data->arg_array[ARG_ULINE]) SetGadgetValue(data->list,GAD_FONT_ULINE,1); // Show font font_show_font(data,FALSE); // Initialise refresh hook data->refresh_hook.h_Entry=(ULONG (*)())font_refresh; data->refresh_hook.h_Data=data; // Event loop FOREVER { struct IntuiMessage *msg; BOOL quit_flag=FALSE; // AppWindow? if (data->appwindow) { struct AppMessage *amsg; // Get messages while ((amsg=(struct AppMessage *)GetMsg(data->appport))) { // Got file? if (amsg->am_NumArgs>0) { char buf[256]; // Get name DevNameFromLockDopus(amsg->am_ArgList[0].wa_Lock,buf,256); if (amsg->am_ArgList[0].wa_Name && *amsg->am_ArgList[0].wa_Name) AddPart(buf,amsg->am_ArgList[0].wa_Name,256); // Get font name font_get_name(data,buf); // Get new font font_get_font(data); font_show_font(data,FALSE); } // Reply to message ReplyMsg((struct Message *)amsg); } } // Requester? if (data->about) { // Handle requester if (SysReqHandler(data->about,0,0)>=0) { // Close requester FreeSysRequest(data->about); data->about=NULL; } } // Intuition messages if (data->window) { while ((msg=GetWindowMsg(data->window->UserPort))) { struct IntuiMessage msg_copy; UWORD id=0; // Copy message and reply msg_copy=*msg; ReplyWindowMsg(msg); // Get gadget ID if (msg_copy.Class==IDCMP_GADGETUP) id=((struct Gadget *)msg_copy.IAddress)->GadgetID; // Look at message switch (msg_copy.Class) { // Close window case IDCMP_CLOSEWINDOW: quit_flag=TRUE; break; // New size case IDCMP_NEWSIZE: // Redraw font font_show_font(data,FALSE); // Set flag to say we resized data->resized=TRUE; break; // Menu case IDCMP_MENUPICK: { struct MenuItem *item; // Get item if (!(item=ItemAddress(data->window->MenuStrip,msg_copy.Code))) break; // Get ID id=GTMENUITEM_USERDATA(item); // Fall through } // Gadget case IDCMP_GADGETUP: switch (id) { // Show requester case GAD_FONT_FONT_POPUP: case MENU_OPEN_FONT: // Ask for name font_ask_name(data); break; // Font name typed case GAD_FONT_FONT: // Get name font_get_name(data,(char *)GetGadgetValue(data->list,GAD_FONT_FONT)); // Get new font font_get_font(data); font_show_font(data,FALSE); break; // Font size up/down case GAD_FONT_UP: case GAD_FONT_DOWN: { short size; // Get next size size=font_get_size(data,(id==GAD_FONT_UP)?1:-1); // No change? if (size==data->font_size) break; // Use this size data->font_size=size; SetGadgetValue(data->list,GAD_FONT_SIZE,size); } // Font size given case GAD_FONT_CYCLE: // Check id if (id==GAD_FONT_CYCLE) { short size; // Get size if (!(size=atoi(data->size_labels[msg_copy.Code]))) break; // Refresh gadget data->font_size=size; SetGadgetValue(data->list,GAD_FONT_SIZE,data->font_size); } // Font size case GAD_FONT_SIZE: // Entered size if (id==GAD_FONT_SIZE) { // Bounds check gadget data->font_size= BoundsCheckGadget( data->list, GAD_FONT_SIZE, 4, 255); } // Get new font font_get_font(data); font_show_font(data,FALSE); break; // Styles changed case GAD_FONT_BOLD: case GAD_FONT_ITALIC: case GAD_FONT_ULINE: // Redraw font font_show_font(data,FALSE); break; // Save settings case MENU_SAVE_SETTINGS: font_save_settings(data); break; // Quit case MENU_QUIT: quit_flag=TRUE; break; // About case MENU_ABOUT: font_show_about(data); break; } break; // Rawkey case IDCMP_RAWKEY: // Help? if (msg_copy.Code==0x5f) font_show_about(data); // Key case IDCMP_VANILLAKEY: // Escape does quit if (msg_copy.Code==0x1b) quit_flag=TRUE; break; // Refresh case IDCMP_REFRESHWINDOW: // Have we just resized? if (data->resized) { // Don't need to refresh BeginRefresh(data->window); EndRefresh(data->window,TRUE); data->resized=FALSE; break; } // Refresh font display font_show_font(data,TRUE); break; } // Check window is still valid if (!data->window) break; } } if (quit_flag) break; // Wait for signal (ctrl-c breaks) if ((Wait(SIGBREAKF_CTRL_C| ((data->window)?(1<<data->window->UserPort->mp_SigBit):0)| ((data->about)?(1<<data->about->UserPort->mp_SigBit):0)| ((data->appwindow)?(1<<data->appport->mp_SigBit):0)))&SIGBREAKF_CTRL_C) break; } // Free stuff font_free(data); return(0); }
int main (void) { IPTR args[ARG_NUM] = { (IPTR) NULL, (IPTR) NULL, (IPTR) NULL, FALSE, FALSE}; struct RDArgs *rda; ULONG error = 0; locale = OpenLocale(NULL); if (!locale) { PutStr("Could not open locale!\n"); return -1; } rda = ReadArgs(TEMPLATE, args, NULL); if (rda) { BPTR lock_in; lock_in = Lock((STRPTR)args[ARG_FROM], ACCESS_READ); if (lock_in) { BPTR file_out = Open((STRPTR)args[ARG_TO], MODE_NEWFILE); if (NULL != file_out) { struct FileInfoBlock fib; UBYTE * data = NULL; BOOL success = Examine(lock_in, &fib); /* ** Read the input file into memory */ if (fib.fib_Size && DOSTRUE == success) data = AllocVec(fib.fib_Size, MEMF_ANY); if (data) { ULONG read = Read(lock_in, data, fib.fib_Size); if (-1 != read) { struct sorted_data * sd; sd = sort(data, fib.fib_Size, (STRPTR)args[ARG_COLSTART], (BOOL)args[ARG_CASE], (BOOL)args[ARG_NUMERIC]); error = write_data(sd, file_out); } FreeVec(data); }/* if (data) */ Close(file_out); } /* if (file_out) */ UnLock(lock_in); } /* if (lock_in) */ FreeArgs(rda); } else error=RETURN_FAIL; if (error) PrintFault(IoErr(), "Sort"); return error; }
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(); }