SDL  2.0
testlocale.c File Reference
#include <stdio.h>
#include "SDL.h"
+ Include dependency graph for testlocale.c:

Go to the source code of this file.

Functions

static void log_locales (void)
 
int main (int argc, char **argv)
 

Function Documentation

◆ log_locales()

static void log_locales ( void  )
static

Definition at line 17 of file testlocale.c.

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 }
#define SDL_GetError
#define SDL_free
#define SDL_GetPreferredLocales
#define SDL_Log
const GLubyte * c
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

References l, NULL, SDL_free, SDL_GetError, SDL_GetPreferredLocales, and SDL_Log.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 36 of file testlocale.c.

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 }
#define SDL_INIT_VIDEO
Definition: SDL.h:82
#define SDL_PollEvent
#define SDL_LogSetPriority
#define SDL_strcmp
#define SDL_Delay
#define SDL_Quit
#define SDL_Init
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
SDL_bool
Definition: SDL_stdinc.h:168
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169
static void log_locales(void)
Definition: testlocale.c:17
General event structure.
Definition: SDL_events.h:592

References e, log_locales(), SDL_Delay, SDL_FALSE, SDL_Init, SDL_INIT_VIDEO, SDL_LOCALECHANGED, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, SDL_LogSetPriority, SDL_PollEvent, SDL_QUIT, SDL_Quit, SDL_strcmp, and SDL_TRUE.