General Paranoyaxc CELIB DLL
CELIB DLL
celib.dll is a library providing standard crt, stdio, unix and win32
ansi functions for wince development. It might be helpful for
porting unix and windows software to the wince environment, as the
wince libraries lack fundamental functions.
For console io, celib.dll uses objects from my simple console
implementation.
I have used celib.dll to port emacs, perl, xfree, apache, tex and other
programs to wince.
News
Sat Sep 01 2001: Build 3.02 fixes pipe-problems in Emacs.
Mon Sep 24 2001: Build 3.04 fixes space-in-filename problem in Emacs.
Supports select() on terminal fds and has some termios support.
Sat Oct 06 2001: Build 3.05 fixes io error problem in pipe_write.
Fri Jan 04 2002: Build 3.06 contains minor fixes for tcl/tk (registry)
and support for PSPC/WCE201 and SH4/HPC/WCE211.
Fri Feb 01 2002: Fix of GetCharWidth(), GetCharABCWidths() and
BuildCommDCB(). BuildCommDCB() only supports the old 9600,n,8,1[,xp]
syntax.
Mon Feb 25 2002: Build 3.09 contains changes in xceselect(), strftime,
pipes.
Fri Apr 26 2002: Build 3.10 contains some bug fixes and some new
functions for Kaffe and VIM.
Fri May 10 2002: Build 3.11 contains minor fixes. CELIBSTDLOGDIR can
now be set to a directory for stdin/stdout/stderr files.
When not set, / is used.
Features and Limitations
Builds for all platforms, even wince200.
Pipe implementation using shared memory and events.
Select() is possible on terminal.
Implementation
The library uses an environment from the registry, which is loaded at
startup.
All file functions are wrappers that use an internally maintained
current directory.
An fd table is maintained that knows about the type of files.
Different read/write/stat functions are called for sockets, files and
console.
File open functions handle special names like /dev/tty,
/dev/null, nul and con.
The stdio implementation is built upon the underlying fd io, so
fdopen of sockets etc is possible.
Most unicode functions of the ce api have ansi wrappers that
convert the arguments on entry/exit.
Some unsupported win32 api functions are implemented.
(i.e. XCEStretchDIBits)
Some global Variables are stored in thread local storage
(errno).
Pipes are emulated using shared memory and events.
For a list of functions, see celib
funcs. This list is not up-to-date.
Compiling the library
Pre-build libraries are now distributed with the sources.
Get the source archive and extract on your pc.
For console io, you need the console sources also.
Fix paths for your development environment in the
makefile. Specify TARGET in the makefile.
Run 'nmake -f makefile.ce'.
Compiling programs
You need Microsoft Embedded Visual Tools 3.0 or VC60
and the plugin for WinCE (which I haven't used
for a long time).
The header celib.h must be included in every source file.
It redefines many functions to xce-functions. You might
get lots of warnings for macro redefinitions.
The program must be linked with celib.lib
The console file wmain.obj must be linked to programs
using the console. It contains the wWinMain function.
When you do not use it, you must provide your own
wWinMain, which must call xceinit(lpcmdlinew).
You must define some macro symbols in CFLAGS.
See the makefile.ce from console for
examples.
You must define -D _DLL and -D _MT. For WINCE200,
other flags must be used.
To use the socket functions that operate on fds, you must include
cesocket2.h and cesocket2_defs.h.
Registry
The library reads the environment from the key HKLM\Environment,
which does not exist by default.
All entries must be string values.
The follwing variables are frequently used:
| UNIXROOTDIR | Directory containing standard Unix
files/directories, like 'etc', 'dev'.
|
| PATH | Searchpath for the process creating functions. Paths
are seperated by semicolon.
|
| HOME | Home diretory.
|
| ROWS/COLS | Rows and columns for console window. Must be string values.
|
| CONSOLEFONTSIZE | Fontsize for console.
|
| PWD | Used for passing the parent pwd to child processes. Very bad.
|
| TMP/TEMP/TEMPDIR | Direcory for temp files.
|
| TERM | Terminal type.
|
| XCE_TRACE | When set enables tracing of function calls. 255 traces all
calls.
|
| XCE_TRACE_FILE | When set, enables trace to a file. Else tracing is via
OutputDebugString().
|
Problems
The pipe-protocol seems to have problems. Caml gets io errors
when run using pipes.
Passing PWD via the environment is bad.
Some of the ansi wrappers for unicode functions do not handle all
cases, especially in message releated functions.
Some Unix programs define BOOL or BOOLEAN or other types. You might
put conditionals in your system headers to prevent this type of error.
Some Unix code declares functions or variables explicitly as
extern (extern int errno). This does not work when there is a
definition in the celib headers that declares them as import or,
in the case of errno, is a member of structure and used via a pointer.
You have to exclude these declarations by conditionals.
On WINCE200, you need msvcrt.dll to run programs using celib.dll.
This dll can be dwonloaded from my site.
Future
Acknowledgements
Thanks to BSD for their library sources. Parts of them are used.
Downloads
Sources
All files
See also
Console
Home