IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

NetWare Loadable Module Programming HOWTO

Search Howtos :Match :
Next Previous Contents

3. First Step: Hello world

As usual, we will start with the famous "Hello world" program. The source code for hello.nlm is available in the nlm-samples package. You can download it from ftp://ftp.penguin.cz/pub/users/mhi/nlm/.

3.1 hello.c - Source File


#define N_PLAT_NLM                                /* Define dest. platform */

#include <nwconio.h>                              /* ConsolePrintf */

int
main (int argc, char **argv)
{
  int i;

  ConsolePrintf ("\rHello world!\n\n");           /* print on system console */

  ConsolePrintf("Arguments:\n");                  /* all arguments */
  for (i=0;i<argc;i++)
   ConsolePrintf("argv[%u]=\"%s\"\n",i, argv[i]);

  return 0;                                       /* exit NLM */
}

3.2 hello.def - NLM header file


#
# hello.def - NLM Header definition file for nlmconv(1)
# Copyright (c) 2000 Martin Hinner <martin at hinner.info>
#

# define startup object files
INPUT   hello.o
INPUT   /usr/nwsdk/lib/prelude.o            # clib startup code

# all imported functions and import lists
IMPORT  at /usr/nwsdk/imports/clib.imp         # Functions in CLIB.NLM
IMPORT  at /usr/nwsdk/imports/threads.imp      # Functions in THREADS.NLM

# NLM header...
OUTPUT  hello.nlm                           # output file
TYPE 0                                      # Ordinary NLM
VERSION 1,0,0                               # Version 1.0
COPYRIGHT "Copyright (c) 2000 Martin Hinner <martin at hinner.info>" # (c) ...
DESCRIPTION "Simple 'Hello world' NLM module." # title of nlm
SCREENNAME "System Console"                 # Default screen name

MODULE CLIB,THREADS                         # req'd modules

3.3 Makefile


# makefile for "hello world" NLM

CC = gcc
CFLAGS = -Wall -O2 -g -I/usr/nwsdk/include/ -nostdinc -fno-builtin -fpack-struct

hello.nlm:      hello.o hello.def
        nlmconv --output-target=nlm32-i386 -T hello.def

hello.o:        hello.c
        $(CC) $(CFLAGS) -c hello.c

3.4 GCC problems

You must pass these arguments to the gcc:

  • -fno-builtin: GCC's fast builtin functions sometimes cause server to abend, so we don't want to use them.
  • -nostdinc: Only include files in /usr/nwsdk/include are valid for NLMs (don't forget to use also -I/usr/nwsdk/include).
  • -fpack-struct: GCC's struct packing method is not valid for Novell NetWare, so we won't use it. Thanks to Gabor Keresztvalvi for this information.
  • -fno-canary-all-functions: If you have Immunix StackGuard GCC, we don't want to use it. StackGuard doesn't work under NetWare.

3.5 Testing the Module

Copy hello.nlm to the SYS:\SYSTEM directory on your NetWare server. Then, on the system console, type "load hello.nlm". If everything went fine, you should see NLM version information, a copyright message and "Hello world".


Next Previous Contents
Search Howtos :Match :
My Money 2.0.53
Personal financial software
Deluge 1.2.2
Bittorrent client written in Python and GTK+
DbVisualizer 7.0.5
The Universal Database Tool
Linux Kernel 2.6 2.6.34-rc2
Linux Kernel
Postfix 2.6.6
Alternative to the Sendmail program
ImageMagick 6.6.0-7
ImageMagick image processing studio
Phorum 5.2.15
Web based discussion software written in PHP.
Gnucash 2.3.13
A full-featured application to keep track of your finances.
Wine 1.1.41
Free implementation of Windows on Unix
NVidia driver 195.36.15
Linux unified nVidia driver
Free IT Magazines, White Papers, eBooks, and more !
Oracle Magazine

Contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more.

Vulnerability Management for Dummies

Get all the Facts and See How to Implement a Successful Vulnerability Management Program.

Website Magazine

Has tapped premier talent in the Internet industry for our content and each and every issue will contain practical advice and insights for website owners.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info