ReactOS  0.4.14-dev-49-gfb4591c
module.h File Reference
#include "ntifs.h"
#include "linux/types.h"
Include dependency graph for module.h:

Go to the source code of this file.

Classes

struct  _spinlock_t
 
struct  nls_table
 

Macros

#define __init
 
#define __exit
 
#define try_inc_mod_count(x)   TRUE
 
#define __MOD_DEC_USE_COUNT(x)   do {} while(FALSE);
 
#define EXPORT_SYMBOL(x)
 
#define THIS_MODULE   NULL
 
#define module_init(X)   int __init module_##X() {return X();}
 
#define module_exit(X)   void __exit module_##X() {X();}
 
#define MODULE_LICENSE(x)
 
#define inline   __inline
 
#define DECLARE_INIT(X)   extern int __init module_##X(void)
 
#define DECLARE_EXIT(X)   extern void __exit module_##X(void)
 
#define LOAD_NLS(X)
 
#define UNLOAD_NLS(X)   do { module_##X(); } while(0)
 
#define spin_lock_init(lock)   KeInitializeSpinLock(&((lock)->SpinLock))
 
#define spin_lock(lock)   KeAcquireSpinLock(&((lock)->SpinLock), &((lock)->Irql))
 
#define spin_unlock(lock)   KeReleaseSpinLock(&((lock)->SpinLock), (lock)->Irql)
 
#define NLS_MAX_CHARSET_SIZE   6 /* for UTF-8 */
 

Typedefs

typedef struct _spinlock_t spinlock_t
 

Functions

int register_nls (struct nls_table *)
 
int unregister_nls (struct nls_table *)
 
struct nls_tableload_nls (char *)
 
void unload_nls (struct nls_table *)
 
struct nls_tableload_nls_default (void)
 
int utf8_mbtowc (wchar_t *, const __u8 *, int)
 
int utf8_mbstowcs (wchar_t *, const __u8 *, int)
 
int utf8_wctomb (__u8 *, wchar_t, int)
 
int utf8_wcstombs (__u8 *, const wchar_t *, int)
 

Macro Definition Documentation

◆ __exit

#define __exit

Definition at line 26 of file module.h.

◆ __init

#define __init

Definition at line 25 of file module.h.

◆ __MOD_DEC_USE_COUNT

#define __MOD_DEC_USE_COUNT (   x)    do {} while(FALSE);

Definition at line 29 of file module.h.

◆ DECLARE_EXIT

#define DECLARE_EXIT (   X)    extern void __exit module_##X(void)

Definition at line 41 of file module.h.

◆ DECLARE_INIT

#define DECLARE_INIT (   X)    extern int __init module_##X(void)

Definition at line 40 of file module.h.

◆ EXPORT_SYMBOL

#define EXPORT_SYMBOL (   x)

Definition at line 30 of file module.h.

◆ inline

#define inline   __inline

Definition at line 38 of file module.h.

◆ LOAD_NLS

#define LOAD_NLS (   X)
Value:
do { rc = module_##X(); \
if (rc != 0) { \
goto errorout; \
} \
} while(0)
#define X(b, s)

Definition at line 43 of file module.h.

◆ module_exit

#define module_exit (   X)    void __exit module_##X() {X();}

Definition at line 34 of file module.h.

◆ module_init

#define module_init (   X)    int __init module_##X() {return X();}

Definition at line 33 of file module.h.

◆ MODULE_LICENSE

#define MODULE_LICENSE (   x)

Definition at line 36 of file module.h.

◆ NLS_MAX_CHARSET_SIZE

#define NLS_MAX_CHARSET_SIZE   6 /* for UTF-8 */

Definition at line 83 of file module.h.

◆ spin_lock

#define spin_lock (   lock)    KeAcquireSpinLock(&((lock)->SpinLock), &((lock)->Irql))

Definition at line 63 of file module.h.

◆ spin_lock_init

#define spin_lock_init (   lock)    KeInitializeSpinLock(&((lock)->SpinLock))

Definition at line 62 of file module.h.

◆ spin_unlock

#define spin_unlock (   lock)    KeReleaseSpinLock(&((lock)->SpinLock), (lock)->Irql)

Definition at line 64 of file module.h.

◆ THIS_MODULE

#define THIS_MODULE   NULL

Definition at line 31 of file module.h.

◆ try_inc_mod_count

#define try_inc_mod_count (   x)    TRUE

Definition at line 28 of file module.h.

◆ UNLOAD_NLS

#define UNLOAD_NLS (   X)    do { module_##X(); } while(0)

Definition at line 50 of file module.h.

Typedef Documentation

◆ spinlock_t

Function Documentation

◆ load_nls()

struct nls_table* load_nls ( char )

Definition at line 218 of file nls_base.c.

219 {
220  struct nls_table *nls;
221 #ifdef CONFIG_KMOD
222  int ret;
223 #endif
224 
225  nls = find_nls(charset);
226  if (nls)
227  return nls;
228 
229 #ifdef CONFIG_KMOD
230  ret = request_module("nls_%s", charset);
231  if (ret != 0) {
232  printk("Unable to load NLS charset %s\n", charset);
233  return NULL;
234  }
235  nls = find_nls(charset);
236 #endif
237  return nls;
238 }
CFF_Charset charset
Definition: cffcmap.c:138
#define nls
Definition: kernel32.h:13
smooth NULL
Definition: ftsmooth.c:416
asmlinkage int printk(const char *fmt,...)
Definition: output.c:76
static struct nls_table * find_nls(char *charset)
Definition: nls_base.c:202
int ret

◆ load_nls_default()

struct nls_table* load_nls_default ( void  )

◆ register_nls()

int register_nls ( struct nls_table )

Definition at line 162 of file nls_base.c.

163 {
164  struct nls_table ** tmp = &tables;
165 
166  if (!nls)
167  return -EINVAL;
168  if (nls->next)
169  return -EBUSY;
170 
172  while (*tmp) {
173  if (nls == *tmp) {
175  return -EBUSY;
176  }
177  tmp = &(*tmp)->next;
178  }
179  nls->next = tables;
180  tables = nls;
182  return 0;
183 }
struct nls_table * next
Definition: module.h:1040
Definition: arc.h:39
Definition: arc.h:37
#define spin_lock(sl)
Definition: module.h:304
#define nls
Definition: kernel32.h:13
spinlock_t nls_lock
Definition: nls_base.c:23
#define spin_unlock(sl)
Definition: module.h:305
struct define * next
Definition: wpp.c:35
struct nls_table * tables
Definition: nls_base.c:22

◆ unload_nls()

void unload_nls ( struct nls_table )

Definition at line 240 of file nls_base.c.

241 {
242  module_put(nls->owner);
243 }
#define nls
Definition: kernel32.h:13
#define module_put(x)
Definition: module.h:274

◆ unregister_nls()

int unregister_nls ( struct nls_table )

Definition at line 185 of file nls_base.c.

186 {
187  struct nls_table ** tmp = &tables;
188 
190  while (*tmp) {
191  if (nls == *tmp) {
192  *tmp = nls->next;
194  return 0;
195  }
196  tmp = &(*tmp)->next;
197  }
199  return -EINVAL;
200 }
struct nls_table * next
Definition: module.h:1040
Definition: arc.h:39
#define spin_lock(sl)
Definition: module.h:304
#define nls
Definition: kernel32.h:13
spinlock_t nls_lock
Definition: nls_base.c:23
#define spin_unlock(sl)
Definition: module.h:305
struct define * next
Definition: wpp.c:35
struct nls_table * tables
Definition: nls_base.c:22

◆ utf8_mbstowcs()

int utf8_mbstowcs ( wchar_t ,
const __u8 ,
int   
)

Definition at line 79 of file nls_base.c.

80 {
81  __u16 *op;
82  const __u8 *ip;
83  int size;
84 
85  op = pwcs;
86  ip = s;
87  while (*ip && n > 0) {
88  if (*ip & 0x80) {
89  size = utf8_mbtowc(op, ip, n);
90  if (size == -1) {
91  /* Ignore character and move on */
92  ip++;
93  n--;
94  } else {
95  op++;
96  ip += size;
97  n -= size;
98  }
99  } else {
100  *op++ = *ip++;
101  n--;
102  }
103  }
104  return (int)(op - pwcs);
105 }
unsigned char __u8
Definition: compat.h:88
GLdouble n
Definition: glext.h:7729
int utf8_mbtowc(wchar_t *p, const __u8 *s, int n)
Definition: nls_base.c:49
int ip[4]
Definition: rtl.c:1176
GLsizeiptr size
Definition: glext.h:5919
unsigned short __u16
Definition: compat.h:89
Definition: dhcpd.h:61
GLdouble s
Definition: gl.h:2039
UINT op
Definition: effect.c:223

◆ utf8_mbtowc()

int utf8_mbtowc ( wchar_t ,
const __u8 ,
int   
)

Definition at line 49 of file nls_base.c.

50 {
51  long l;
52  int c0, c, nc;
53  struct utf8_table *t;
54 
55  nc = 0;
56  c0 = *s;
57  l = c0;
58  for (t = utf8_table; t->cmask; t++) {
59  nc++;
60  if ((c0 & t->cmask) == t->cval) {
61  l &= t->lmask;
62  if (l < t->lval)
63  return -1;
64  *p = (wchar_t)l;
65  return nc;
66  }
67  if (n <= nc)
68  return -1;
69  s++;
70  c = (*s ^ 0x80) & 0xFF;
71  if (c & 0xC0)
72  return -1;
73  l = (l << 6) | c;
74  }
75  return -1;
76 }
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
r l[0]
Definition: byte_order.h:167
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
int cmask
Definition: nls_base.c:30
#define c
Definition: ke_i.h:80
#define wchar_t
Definition: wchar.h:102
GLfloat GLfloat p
Definition: glext.h:8902
long lval
Definition: nls_base.c:34

Referenced by utf8_mbstowcs().

◆ utf8_wcstombs()

int utf8_wcstombs ( __u8 ,
const wchar_t ,
int   
)

Definition at line 136 of file nls_base.c.

137 {
138  const __u16 *ip;
139  __u8 *op;
140  int size;
141 
142  op = s;
143  ip = pwcs;
144  while (*ip && maxlen > 0) {
145  if (*ip > 0x7f) {
146  size = utf8_wctomb(op, *ip, maxlen);
147  if (size == -1) {
148  /* Ignore character and move on */
149  maxlen--;
150  } else {
151  op += size;
152  maxlen -= size;
153  }
154  } else {
155  *op++ = (__u8) *ip;
156  }
157  ip++;
158  }
159  return (int)(op - s);
160 }
unsigned char __u8
Definition: compat.h:88
int utf8_wctomb(__u8 *s, wchar_t wc, int maxlen)
Definition: nls_base.c:108
int ip[4]
Definition: rtl.c:1176
GLsizeiptr size
Definition: glext.h:5919
unsigned short __u16
Definition: compat.h:89
Definition: dhcpd.h:61
GLdouble s
Definition: gl.h:2039
UINT op
Definition: effect.c:223

◆ utf8_wctomb()

int utf8_wctomb ( __u8 ,
wchar_t  ,
int   
)

Definition at line 108 of file nls_base.c.

109 {
110  long l;
111  int c, nc;
112  struct utf8_table *t;
113 
114  if (s == 0)
115  return 0;
116 
117  l = wc;
118  nc = 0;
119  for (t = utf8_table; t->cmask && maxlen; t++, maxlen--) {
120  nc++;
121  if (l <= t->lmask) {
122  c = t->shift;
123  *s = (__u8)(t->cval | (l >> c));
124  while (c > 0) {
125  c -= 6;
126  s++;
127  *s = 0x80 | (__u8)((l >> c) & 0x3F);
128  }
129  return nc;
130  }
131  }
132  return -1;
133 }
unsigned char __u8
Definition: compat.h:88
GLdouble GLdouble t
Definition: gl.h:2047
long lmask
Definition: nls_base.c:33
r l[0]
Definition: byte_order.h:167
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
int cmask
Definition: nls_base.c:30
#define c
Definition: ke_i.h:80

Referenced by utf8_wcstombs().