1.4 Understanding the Structure of the LibC SDK

By default, the executable installs the LibC SDK in the following directories:

The c:\novell\ndk\libc directory has the following subdirectories:

1.4.1 Imports Directory

This directory contains the prelude object files (which need to be linked in your application) along with several import files. The prelude file is especially designed for use with the header files in this release. You should never use a prelude file from one version of the LibC with header files from either an earlier or later version.

The files and their purposes are listed in the following table.

Table 1-2 The Files in the Import Directory

File

Compiler

Description

libcpre.o

Metrowerks CodeWarrior

Prelude object file with NetWare semantics

posixpre.o

Metrowerks CodeWarrior

Prelude object file with POSIX semantics

libcpre.gcc.o

GNU C/C++

Prelude object file with NetWare semantics

posixpre.gcc.o

GNU C/C++

Prelude object file with POSIX semantics

libcpre.obj

Watcom

Prelude object file with NetWare semantics

posixpre.obj

Watcom

Prelude object file with POSIX semantics

libc.imp

Metrowerks CodeWarrior and GNU C/C++

Import file

netware.imp

Metrowerks CodeWarrior and GNU C/C++

Import file

ws2nlm.imp

Metrowerks CodeWarrior and GNU C/C++

Import file

libc.ali

Watcom

Import file

libc.wmp

Watcom

Import file

libcclib.imp

All compilers

Additional import file if your NLM makes calls into another NLM that references CLib

nwsnut.imp

All compilers

Import file for the NLM User Interface Developer Components.

Selecting A Prelude File

LibC provides two prelude files, a traditional libcpre file that supports NetWare semantics and a posixpre file that supports POSIX semantics. These files support the following features:

Table 1-3 Prelude File Comparison

Feature

libcpre

posixpre

Path and filenames

NetWare semantics. For example:

  sys:\system\nlm
  

POSIX semantics. For example:

  /sys/system/nlm
  

For more information, see Section 13.2, POSIX Path Semantics

Multiple NLMs loaded in the same address space, even in ring 3.

Supported

Partial support. When a POSIX NLM is loaded in ring 3, only one NLM containing a function named main can be loaded in a specified address space. Additional NLMs can be loaded into this address space if they meet the following conditions:

  • Are linked with posixpre and do not contain a main function.

  • Are linked with libcpre, are library-type NLMs, and do not contain a main function.

  • Are linked with libcpre, are library-type NLMs, and do contain a main function. This is for backwards compatibility with legacy libraries that were written with a main function which initializes a few variables or structures and then sleeps.

Signal support

Basic support, including SIGTERM and SIGABRT.

Extended support, including support for

  • pthread_kill
  • pthread_sigmask

TZ (time zone) environment variable

Not supported

Supported.

Link flag (LD_WANT_ POSIX_SEMANTICS)

Supported. Causes the NLM to be a POSIX NLM while allowing multiple NLMs to be loaded into the same protected address space.

Supported. Causes the linker flag LD_WANT_POSIX_SEMANTICS to be set even when not set with the FLAG_ON linker directive.

TMPDIR (temporary directory) environment variable

Not supported

Supported.

CWD (current working directory) environment variable

Not supported.

Supported.

alarm function

Not supported.

Supported

system function

Legacy semantics, which allow you to use a console command as the value for the command parameter.

Extended support, which allows you to use the system function to load another NLM or to issue a console command.

rename function

NetWare semantics, which includes wildcards for reanming multiple files and failure when the new name is the name of an existing file.

POSIX semantics which allow you to rename the file to the name of an existing file.

Consoles

NetWare behavior.

More POSIX-like behavior, which enables such things as ^C and ^Z. This feature also requires nwtermio.nlm.

The LD_WANT_POSIX_SEMANTICS linker flag enables all of the POSIX features except for the single address space. If your NLM does not require the single address space, you can select to use the licpre prelude file with the POSIX semantics linker flag. For more information about this flag, see Section 1.6, Using a Linker Definition File.

POSIX Prelude File

The POSIX prelude file contains new start up functions:

  • POSIX_Start replaces _LibCPrelude. _NonAppStart is not recommended for a POSIX application.

  • POSIX_Stop replaces _LibCPostlude. _NonAppStop is not recommended for a POSIX application.

  • POSIX_CheckUnload replaces _LibCCheckUnload. NonApp_CheckUnload is not recommended for a POSIX application.

This prelude permits the use of two new symbols, init and fini, whose absence from earlier versions of LibC will prevent your NLM from loading on those systems. This is by design since older versions of LibC do not contain the functionality and NLM linking this new prelude is looking for.

An NLM compiled with this prelude file runs best on the LibC version included in this NDK or on the version that ships with NetWare 6.5 SP3 and NetWare 5.1 SP8. It also must be loaded into protected address space to take advantage of the new features.

For more information about using this feature to write a library, including coverage of the _init and _fini functions, see AppNote: Writing NetWare Loadable Modules (NLMs) as Shared Libraries.

1.4.2 Include Directory

This directory contains the C header files for all compilers. It has five subdirectories. Because some of the filenames are duplicated in the subdirectories, your include statements must contain both the directory and filename. For example:

  # include <nks/netware.h>
  

The include directory has the following subdirectories.

Directory

Description

arpa

Contains a BSD header for Internet services.

linux

Contains headers specific to Linux.

netinet

Contains a BSD header for Internet services.

nks

Contains the header files for Novell Kernel Services.

sys

Contains the header files for some POSIX interfaces.

winsock

Contains the header files for WinSock 2.

1.4.3 Lib Directory

This directory contains two versions of the libraries: normal and debug. Because the NDK is updated more frequently than NetWare, you must copy these libraries to your server to use them. In a default NetWare installation, you should copy them to the c:\nwserver directory. For more complete installation information, see Section 1.7, Installing the LibC Files on a NetWare Server.

1.4.4 Tables Directory

This directory contains several XML locale files and code page tables. Because the NDK is updated more frequently than NetWare, you must copy these files to your server to use any new or updated files. In a default NetWare installation, you should copy them to the c:\nwserver\nls directory.