SDL  2.0
testlocale.c
Go to the documentation of this file.
1 /*
2  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
3 
4  This software is provided 'as-is', without any express or implied
5  warranty. In no event will the authors be held liable for any damages
6  arising from the use of this software.
7 
8  Permission is granted to anyone to use this software for any purpose,
9  including commercial applications, and to alter it and redistribute it
10  freely.
11 */
12 #include <stdio.h>
13 #include "SDL.h"
14 
15 /* !!! FIXME: move this to the test framework */
16 
17 static void log_locales(void)
18 {
20  if (locales == NULL) {
21  SDL_Log("Couldn't determine locales: %s", SDL_GetError());
22  } else {
23  SDL_Locale *l;
24  unsigned int total = 0;
25  SDL_Log("Locales, in order of preference:");
26  for (l = locales; l->language; l++) {
27  const char *c = l->country;
28  SDL_Log(" - %s%s%s", l->language, c ? "_" : "", c ? c : "");
29  total++;
30  }
31  SDL_Log("%u locales seen.", total);
32  SDL_free(locales);
33  }
34 }
35 
36 int main(int argc, char **argv)
37 {
38  /* Enable standard application logging */
40 
41  /* Print locales and languages */
42  if (SDL_Init(SDL_INIT_VIDEO) != -1) {
43  log_locales();
44 
45  if ((argc == 2) && (SDL_strcmp(argv[1], "--listen") == 0)) {
46  SDL_bool keep_going = SDL_TRUE;
47  while (keep_going) {
48  SDL_Event e;
49  while (SDL_PollEvent(&e)) {
50  if (e.type == SDL_QUIT) {
51  keep_going = SDL_FALSE;
52  } else if (e.type == SDL_LOCALECHANGED) {
53  SDL_Log("Saw SDL_LOCALECHANGED event!");
54  log_locales();
55  }
56  }
57  SDL_Delay(10);
58  }
59  }
60 
61  SDL_Quit();
62  }
63 
64  return 0;
65 }
66 
67 /* vi: set ts=4 sw=4 expandtab: */
#define SDL_INIT_VIDEO
Definition: SDL.h:82
#define SDL_GetError
#define SDL_PollEvent
#define SDL_LogSetPriority
#define SDL_free
#define SDL_strcmp
#define SDL_Delay
#define SDL_GetPreferredLocales
#define SDL_Quit
#define SDL_Init
#define SDL_Log
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 * e
@ SDL_QUIT
Definition: SDL_events.h:60
@ SDL_LOCALECHANGED
Definition: SDL_events.h:88
@ SDL_LOG_PRIORITY_INFO
Definition: SDL_log.h:106
@ SDL_LOG_CATEGORY_APPLICATION
Definition: SDL_log.h:66
const GLubyte * c
SDL_bool
Definition: SDL_stdinc.h:168
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int int return Display Window Cursor return Display Window return Display Drawable GC int int unsigned int unsigned int return Display Drawable GC int int _Xconst char int return Display Drawable GC int int unsigned int unsigned int return Display return Display Cursor return Display GC return XModifierKeymap return char Display Window int return Display return Display int int int return Display long XVisualInfo int return Display Window Atom long long Bool Atom Atom int unsigned long unsigned long unsigned char * l)
Definition: SDL_x11sym.h:80
#define NULL
Definition: begin_code.h:163
int main(int argc, char **argv)
Definition: testlocale.c:36
static void log_locales(void)
Definition: testlocale.c:17
General event structure.
Definition: SDL_events.h:592