summaryrefslogtreecommitdiff
path: root/support/dktools/dk4appenc.ctr
blob: 99314a593082987a116a9ec309a00abab718fc55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
%%	options

copyright owner	=	Dirk Krause
copyright year	=	2015-xxxx
license		=	bsd



%%	module

#include "dk4app.h"

#ifndef DK4MEM_H_INCLUDED
#include "dk4mem.h"
#endif

#ifndef DK4ENC_H_INCLUDED
#include "dk4enc.h"
#endif

#ifndef DK4LOC_H_INCLUDED
#include "dk4loc.h"
#endif



$!trace-include



static
int
dk4app_get_encoding_without_app(int *dptr)
{
  dkChar	l[64];
  dkChar	r[64];
  return (
    dk4loc_get_settings(l,DK4_SIZEOF(l,dkChar),r,DK4_SIZEOF(r,dkChar),dptr,NULL)
  );
}




int
dk4app_get_encoding(dk4_app_t *app)
{
  int	back;
  if (NULL != app) {
    back = app->encoding;
  } else {
    if (0 == dk4app_get_encoding_without_app(&back)) {
      back = DK4_FILE_ENCODING_ASCII;
    }
  }
  return back;
}



int
dk4app_get_stdin_encoding(dk4_app_t *app)
{
  int	back;
  if (NULL != app) {
    back = app->enc_in_std;
  } else {
    if (0 == dk4app_get_encoding_without_app(&back)) {
      back = DK4_FILE_ENCODING_ASCII;
    }
  }
  return back;
}



int
dk4app_get_file_in_encoding(dk4_app_t *app)
{
  int	back;
  if (NULL != app) {
    back = app->enc_in_file;
  } else {
    if (0 == dk4app_get_encoding_without_app(&back)) {
      back = DK4_FILE_ENCODING_ASCII;
    }
  }
  return back;
}



int
dk4app_get_stdout_encoding(dk4_app_t *app)
{
  int	back;
  if (NULL != app) {
    back = app->enc_out_std;
  } else {
    if (0 == dk4app_get_encoding_without_app(&back)) {
      back = DK4_FILE_ENCODING_ASCII;
    }
  }
  return back;
}



int
dk4app_get_file_out_encoding(dk4_app_t *app)
{
  int	back;
  if (NULL != app) {
    back = app->enc_out_file;
  } else {
    if (0 == dk4app_get_encoding_without_app(&back)) {
      back = DK4_FILE_ENCODING_ASCII;
    }
  }
  return back;
}