X11 Work Bench Toolkit  1.0
conf_help.h
Go to the documentation of this file.
1 
2 // __ _ _ _ //
3 // ___ ___ _ __ / _| | |__ ___ | | _ __ | |__ //
4 // / __|/ _ \ | '_ \ | |_ | '_ \ / _ \| || '_ \ | '_ \ //
5 // | (__| (_) || | | || _| | | | || __/| || |_) |_| | | | //
6 // \___|\___/ |_| |_||_|_____|_| |_| \___||_|| .__/(_)_| |_| //
7 // |_____| |_| //
8 // //
9 // helper API for 'conf' files (global and per-user) //
10 // //
12 
13 /*****************************************************************************
14 
15  X11workbench - X11 programmer's 'work bench' application and toolkit
16  Copyright (c) 2010-2016 by Bob Frazier (aka 'Big Bad Bombastic Bob')
17  all rights reserved
18 
19  DISCLAIMER: The X11workbench application and toolkit software are supplied
20  'as-is', with no warranties, either implied or explicit.
21  Any claims to alleged functionality or features should be
22  considered 'preliminary', and might not function as advertised.
23 
24  BSD-like license:
25 
26  There is no restriction as to what you can do with this software, so long
27  as you include the above copyright notice and DISCLAIMER for any distributed
28  work that is equal to or derived from this one, along with this paragraph
29  that explains the terms of the license if the source is also being made
30  available. A "derived work" describes a work that uses a significant portion
31  of the source files or algorithms that are included with this one.
32  Specifically excluded from this are files that were generated by the software,
33  or anything that is included with the software that is part of another package
34  (such as files that were created or added during the 'configure' process).
35  Specifically included is the use of part or all of any of the X11 workbench
36  toolkit source or header files in your distributed application. If you do not
37  ship the source, the above copyright statement is still required to be placed
38  in a reasonably prominent place, such as documentation, splash screens, and/or
39  'about the application' dialog boxes.
40 
41  Use and distribution are in accordance with GPL, LGPL, and/or the above
42  BSD-like license. See COPYING and README files for more information.
43 
44 
45  Additional information at http://sourceforge.net/projects/X11workbench
46 
47 ******************************************************************************/
48 
49 
50 // conf file format:
51 // [section header]
52 // data identifier=data value
53 
79 #ifndef CONF_HELPER_H_INCLUDED
80 #define CONF_HELPER_H_INCLUDED
81 
82 #include "platform_helper.h" /* this also includes the X11 headers */
83 
84 #ifdef __cplusplus
85 extern "C" {
86 #endif // __cplusplus
87 
88 
89 #ifndef GLOBAL_PATH /* this can be defined by the config script */
90 #warning "GLOBAL_PATH not defined, assuming /usr/local/etc"
91 #define GLOBAL_PATH "/usr/local/etc"
92 #endif // GLOBAL_PATH
93 
94 #ifndef GLOBAL_XPATH /* this can be defined by the config script */
95 #warning "GLOBAL_XPATH not defined, assuming /usr/X11R6/etc"
96 #define GLOBAL_XPATH "/usr/X11R6/etc"
97 // NOTE: on some systems, like freebsd, /usr/X11R6 is a symlink matching GLOBAL_PATH
98 #endif // GLOBAL_XPATH
99 
100 #define LOCAL_PATH "~/"
101 #define LOCAL_CONF_NAME "settings" /* local conf name will be ~/.appname/settings.conf, or if that is not possible, ~/appname.conf */
102 
103 #define CH_OPEN_TIMEOUT 5000 /* wait up to 5000 milliseconds before timing out */
104 
105 
109 #define CH_FLAGS_DEFAULT 0
110 #define CH_FLAGS_GLOBAL 0x1
111 #define CH_FLAGS_WRITE 0x2
128 void CHRegisterArgs(int argc, char **argv); // call in 'main'
129 
137 void CHOnExit(void);
138 
148 const char * const *CHGetArgV(void);
149 
159 int CHGetArgC(void);
160 
175 int CHGetResourceString(Display *pDisplay,const char *szIdentifier, char *szData, int cbData);
176 
189 int CHGetResourceInt(Display *pDisplay,const char *szIdentifier);
190 
191 
192 
194 // configuration file management
196 
211 void * CHOpenConfFile(const char *szAppName, int iFlags);
212 
224 void CHCloseConfFile(void * hFile);
225 
236 void CHDestroyConfFile(void * hFile);
237 
254 int CHGetConfFileString(void * hFile, const char *szSection,
255  const char *szIdentifier, char *szData, int cbData);
256 
271 int CHWriteConfFileString(void * hFile, const char *szSection,
272  const char *szIdentifier, const char *szData);
273 
274 
290 int CHGetConfFileInt(void * hFile, const char *szSection, const char *szIdentifier);
291 
306 int CHWriteConfFileInt(void * hFile, const char *szSection, const char *szIdentifier, int iData);
307 
308 
309 
310 // XSETTINGS
311 
322 void CHSettingsRefresh(Display *pDisplay); // call this to re-read and re-build XSettings info
323 
324 // X11 settings collection
325 
330 {
334 };
335 
336 
361 typedef struct __XSETTINGS_DATA_COLOR__ // also used internally by XSettings
362 {
363  unsigned short sRed;
364  unsigned short sBlue;
365  unsigned short sGreen;
366  unsigned short sAlpha;
368 
369 
402 typedef struct _CHXSetting_
403 {
404  const char *szName;
405  int iType;
406  int iLen;
407  unsigned int uiSerial;
408  union
409  {
410  int iData;
412  XSETTINGS_DATA_COLOR clrData;
413  void *pData;
414  char *szData;
415  } uData;
417 
418 
444 typedef struct _CHXSettings_
445 {
446  Display *pDisplay;
447  int nSettings;
448  unsigned int uiSerial;
449  CHXSetting aData[1];
450 } CHXSettings;
451 
452 
462 const CHXSettings * CHGetXSettings(Display *pDisplay);
463 
475 const CHXSetting * CHGetXSetting(Display *pDisplay, const char *szSettingName);
476 
477 
488 int CHGetDoubleClickTime(Display *pDisplay);
489 
500 int CHGetDoubleClickDistance(Display *pDisplay);
501 
512 int CHGetDragThreshold(Display *pDisplay);
513 
524 int CHGetCursorBlink(Display *pDisplay);
525 
536 int CHGetCursorBlinkTime(Display *pDisplay);
537 
538 
539 
540 // XML help
541 
557 char *CHParseXMLTagContents(const char *pTagContents, int cbLength);
558 
570 const char *CHFindEndOfXMLTag(const char *pTagContents);
571 
572 
573 
574 // MIME type help
575 
587 char *CHGetFileMimeType(const char *szFileName);
588 
603 char *CHGetMimeDefaultApp(const char *szMimeType);
604 
617 char *CHGetDesktopFileInfo(const char *szDesktopFile, const char *szInfo);
618 
619 
620 
621 // debug
622 #ifndef NO_DEBUG
623 
631 void CHDumpConfig(void);
632 
633 #endif // NO_DEBUG
634 
635 #ifdef __cplusplus
636 };
637 #endif // __cplusplus
638 
639 
640 #endif // CONF_HELPER_H_INCLUDED
641