Oyranos  git-devel
Oyranos is a full featured Color Management System
Macros | Enumerations | Functions
oyjl_args.c File Reference

Oyjl argument handling. More...

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <wchar.h>
#include <stdarg.h>
#include <math.h>
#include <stdint.h>
#include <sys/stat.h>
#include <errno.h>
#include <sys/types.h>
#include <time.h>

Macros

#define OYJL_ARGS_C
 
#define OYJL_VERSION_A   1
 

Enumerations

enum  oyjlOBJECT_e { ,
  oyjlOBJECT_OPTION = 1769433455, oyjlOBJECT_OPTION_GROUP = 1735879023, oyjlOBJECT_OPTIONS = 1937205615, oyjlOBJECT_UI_HEADER_SECTION = 1936222575,
  oyjlOBJECT_UI = 1769302383, oyjlOBJECT_TR = 1920231791, oyjlOBJECT_JSON = 1397385583
}
 
enum  oyjlOPTIONTYPE_e { , oyjlOPTIONTYPE_CHOICE, oyjlOPTIONTYPE_FUNCTION, oyjlOPTIONTYPE_DOUBLE, oyjlOPTIONTYPE_NONE }
 
enum  oyjlVARIABLETYPE_e { , oyjlNONE, oyjlSTRING, oyjlDOUBLE, oyjlINT }
 
enum  oyjlOPTIONSTATE_e { ,
  oyjlOPTION_NONE, oyjlOPTION_USER_CHANGED, oyjlOPTION_MISSING_VALUE, oyjlOPTION_UNEXPECTED_VALUE,
  oyjlOPTION_NOT_SUPPORTED, oyjlOPTION_DOUBLE_OCCURENCE, oyjlOPTIONS_MISSING, oyjlOPTION_NO_GROUP_FOUND,
  oyjlOPTION_SUBCOMMAND, oyjlOPTION_NOT_ALLOWED_AS_SUBCOMMAND
}
 
enum  oyjlMSG_e { ,
  oyjlMSG_INFO = 400, oyjlMSG_CLIENT_CANCELED, oyjlMSG_INSUFFICIENT_DATA, oyjlMSG_ERROR,
  oyjlMSG_PROGRAM_ERROR, oyjlMSG_SECURITY_ALERT
}
 
enum  oyjlTEXTMARK_e { ,
  oyjlNO_MARK = 1, oyjlRED, oyjlGREEN, oyjlBLUE,
  oyjlBOLD, oyjlITALIC, oyjlUNDERLINE
}
 
enum  oyjlARGS_EXPORT_e { ,
  oyjlARGS_EXPORT_HELP, oyjlARGS_EXPORT_JSON, oyjlARGS_EXPORT_MAN, oyjlARGS_EXPORT_MARKDOWN,
  oyjlARGS_EXPORT_EXPORT
}
 

Functions

const char * oyjlTermColor (oyjlTEXTMARK_e rgb, const char *text)
 text formating for terminals More...
 
char * oyjlReadCommandF (int *size, const char *mode, void *(*alloc)(size_t), const char *format,...)
 Read a stream from shell command. More...
 
void oyjlTranslation_Release (oyjlTranslation_s **context_)
 get flags More...
 
oyjlTranslation_s * oyjlTranslation_New (const char *loc, const char *domain, oyjl_val *catalog, oyjlTranslate_f translator, void *user_data, void(*deAlloc)(void *), int flags)
 create i18n context More...
 
const char * oyjlTranslation_GetDomain (oyjlTranslation_s *context)
 get domain More...
 
const char * oyjlTranslation_GetLang (oyjlTranslation_s *context)
 get catalog lang More...
 
void oyjlTranslation_SetFlags (oyjlTranslation_s *context, int flags)
 change flags More...
 
oyjlTranslation_s * oyjlTranslation_Get (const char *domain)
 get message translation context More...
 
void oyjlLibRelease ()
 Reset and free all resources. More...
 
void oyjlTreeFree (oyjl_val v)
 
void oyjlTranslation_SetLocale (oyjlTranslation_s *context, const char *loc)
 change language More...
 
const char * oyjlLang (const char *loc)
 change language More...
 
int oyjlTermColorInit (int flags)
 setup formating for terminals More...
 
const char * oyjlTermColorF (oyjlTEXTMARK_e rgb, const char *format,...)
 variable text formating for terminals More...
 
const char * oyjlTermColorFPtr (oyjlTEXTMARK_e rgb, char **color_text, const char *format,...)
 variable text formating for terminals More...
 
const char * oyjlTermColorFromHtml (const char *text, int flags)
 convert a subset of HTML to terminal colors More...
 
const char * oyjlTermColorToHtml (const char *text, int flags)
 convert internal used terminal colors to HTML More...
 

Detailed Description

Oyjl argument handling.

oyjl - UI helpers

Copyright:
2018-2023 (C) Kai-Uwe Behrmann
Author
Kai-Uwe Behrmann ku.b@.nosp@m.gmx..nosp@m.de
License:
MIT http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2018-2022 Kai-Uwe Behrmann ku.b@.nosp@m.gmx..nosp@m.de

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Macro Definition Documentation

◆ OYJL_ARGS_C

#define OYJL_ARGS_C

This file can be included alone without any other file from the project. Then it provides init, i18n, i/o and cli parsing capabilities. With the OYJL_ARGS_BASE macro set, it omits init and i18n for smaller code. That might be helpful, in case init and i18n are provided by other means. The functionality fits then the oyjl_args_base.h header file and the libOyjlArgsBase shared library.

◆ OYJL_VERSION_A

#define OYJL_VERSION_A   1

version variable

Enumeration Type Documentation

◆ oyjlMSG_e

enum oyjlMSG_e
Enumerator
oyjlMSG_INFO 

informational, for debugging

oyjlMSG_CLIENT_CANCELED 

user side requested stop

oyjlMSG_INSUFFICIENT_DATA 

missing or insufficient data

oyjlMSG_ERROR 

usage error

oyjlMSG_PROGRAM_ERROR 

program error

oyjlMSG_SECURITY_ALERT 

chanceld by security policy

◆ oyjlOBJECT_e

Enumerator
oyjlOBJECT_OPTION 

oyjlOption_s

oyjlOBJECT_OPTION_GROUP 

oyjlOptionGroup_s

oyjlOBJECT_OPTIONS 

oyjlOptions_s

oyjlOBJECT_UI_HEADER_SECTION 

oyjlUiHeaderSection_s

oyjlOBJECT_UI 

oyjlUi_s

oyjlOBJECT_TR 

oyjlTranslation_s

oyjlOBJECT_JSON 

oyjlNodes_s

◆ oyjlOPTIONSTATE_e

Enumerator
oyjlOPTION_NONE 

untouched

oyjlOPTION_USER_CHANGED 

passed in by user

oyjlOPTION_MISSING_VALUE 

user error

oyjlOPTION_UNEXPECTED_VALUE 

user error

oyjlOPTION_NOT_SUPPORTED 

user error

oyjlOPTION_DOUBLE_OCCURENCE 

user error; except '@' is specified

oyjlOPTIONS_MISSING 

user error; except '#' is specified

oyjlOPTION_NO_GROUP_FOUND 

user error

oyjlOPTION_SUBCOMMAND 

category

oyjlOPTION_NOT_ALLOWED_AS_SUBCOMMAND 

user error

◆ oyjlOPTIONTYPE_e

Enumerator
oyjlOPTIONTYPE_CHOICE 

list of choices

oyjlOPTIONTYPE_FUNCTION 

computed list of choices

oyjlOPTIONTYPE_DOUBLE 

IEEE floating point number with double precission

oyjlOPTIONTYPE_NONE 

no value possible - the option is a flag like -v/–verbose

◆ oyjlTEXTMARK_e

Enumerator
oyjlNO_MARK 

plain

oyjlRED 

red color

oyjlGREEN 

green color

oyjlBLUE 

blue color

oyjlBOLD 

bold

oyjlITALIC 

italic

oyjlUNDERLINE 

<u>underline</u>

◆ oyjlVARIABLETYPE_e

Enumerator
oyjlNONE 

no variable given, will be asked later with oyjlOptions_GetResult()

oyjlSTRING 

pointer to a array of char

oyjlDOUBLE 

IEEE floating point number with double precission

oyjlINT 

integer number declared as int

Function Documentation

◆ oyjlLang()

const char * oyjlLang ( const char *  loc)

change language

Call after oyjlTr().

Parameters
loclocale name as from setlocale("")
  • NULL: reset
  • "": get existing without change
  • "something": set lang to "something"
Returns
current locale
Version
Oyjl: 1.0.0
Date
2021/10/24
Since
2020/07/28 (Oyjl: 1.0.0)

References oyjlBT(), and oyjlTranslation_GetDomain().

◆ oyjlReadCommandF()

char * oyjlReadCommandF ( int *  size,
const char *  mode,
void *(*)(size_t)  alloc,
const char *  format,
  ... 
)

Read a stream from shell command.

References OYJL_CREATE_VA_STRING.

◆ oyjlTranslation_Get()

oyjlTranslation_s * oyjlTranslation_Get ( const char *  domain)

get message translation context

Parameters
domainselect domain of library or application
Returns
context for domain
Version
Oyjl: 1.0.0
Date
2021/10/26
Since
2021/10/26 (Oyjl: 1.0.0)

◆ oyjlTranslation_GetDomain()

const char * oyjlTranslation_GetDomain ( oyjlTranslation_s *  context)

get domain

Version
Oyjl: 1.0.0
Date
2021/10/26
Since
2021/10/26 (Oyjl: 1.0.0)

Referenced by oyjlLang().

◆ oyjlTranslation_GetLang()

const char * oyjlTranslation_GetLang ( oyjlTranslation_s *  context)

get catalog lang

Fall back to loc from oyjlTranslation_New() otherwise NULL.

Version
Oyjl: 1.0.0
Date
2021/10/24
Since
2021/10/24 (Oyjl: 1.0.0)

◆ oyjlTranslation_New()

oyjlTranslation_s * oyjlTranslation_New ( const char *  loc,
const char *  domain,
oyjl_val catalog,
oyjlTranslate_f  translator,
void *  user_data,
void(*)(void *)  deAlloc,
int  flags 
)

create i18n context

The passed in catalog shall contain its translations in the "org/freedesktop/oyjl/translations/loc" path.

Parameters
loclocale name as from setlocale(0,""), the special locale "back" will inverse the translation; optional
translatorthe function; optional
catalogthe parsed catalog as tree; optional
user_dataoptional
deAllocfree user_data on oyjlTranslation_Release(); optional
[in]flagssupported:
Returns
context
Version
Oyjl: 1.0.0
Date
2021/10/26
Since
2021/10/24 (Oyjl: 1.0.0)

◆ oyjlTranslation_Release()

void oyjlTranslation_Release ( oyjlTranslation_s **  context_)

get flags

Version
Oyjl: 1.0.0
Date
2021/10/24
Since
2021/10/24 (Oyjl: 1.0.0)

Referenced by oyjlLibRelease().

◆ oyjlTranslation_SetFlags()

void oyjlTranslation_SetFlags ( oyjlTranslation_s *  context,
int  flags 
)

change flags

Parameters
contextthe translation context
flagstranslation flags
Version
Oyjl: 1.0.0
Date
2021/10/24
Since
2021/10/24 (Oyjl: 1.0.0)

◆ oyjlTranslation_SetLocale()

void oyjlTranslation_SetLocale ( oyjlTranslation_s *  context,
const char *  loc 
)

change language

Parameters
contextthe translation context
loclocale name as from setlocale("")
  • "something": set lang to "something"
Version
Oyjl: 1.0.0
Date
2021/10/24
Since
2021/10/24 (Oyjl: 1.0.0)

◆ oyjlTreeFree()

OYJL_API void oyjlTreeFree ( oyjl_val  v)

Free a parse tree returned by oyjlTreeParse().

Parameters
vPointer to a JSON value returned by oyjlTreeParse(). Passing NULL is valid and results in a no-op.
Examples:
tutorial_json_options.c.