Programming AmigaOS in C

26. Unix Emulation

Unix emulation is possible in Amiga OS with libraries such as ixemul.library and ixnet.library and support from compilers such as SAS/C and GCC to include them in programs. Unix emulation allows unix type programs to be easily migrated to Amiga OS with minimal changes. There is also support for X Windows via the Amiwin system for classic Amigas or AmiCygnix for AmigaOS 4 systems.

a) IXEmul library SDK

To use ixemul.library you will need the library files installed to LIBS: on the AmigaOS system and then install the ixemul sdk files for your compiler. To avoid overwriting your AmigaOS include files, place the include files in a seperate subdirectory of your INCLUDE folder.

stdio.h - functions for input and output including to shell window (stdin, stdout) or to files e.g fopen(), fclose(), fgets(), fputs(), scanf(), printf() and so on.

stdlib.h - miscellaneous functions for memory allocation malloc(), free(). Enviorment variables with putenv(), setenv(). Sorting - heapsort(), mergesort(), radixsort(). Random numbers rand() and type conversions.

string.h - String functions such as strcpy(), strcmp(), strcar(), strncpy() etc.

math.h - Advanced math functions e.g. cos(), sing, tan(), exp(), pow(), sqrt().

sys/socket.h - Network socket library for internet communication e.g. accept(), bind(), connect(), recv(), send() etc.

b) Example code - binsplit

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char **argv)
FILE *in,*out;
int size;
int bytes;
char buf[256];
char *ptr;

if (argc != 4)

printf("Usage: %s <source> <blocksize> <destination>\n"
" - blocksize means the number of bytes per block\n"
" - source is the name of the file to split (read)\n"
" - destination is the name of the file(s) to create\n"
"\ndestination files were numbered <name>.0, <name>.1, ...\n\n
return 1; /* error */
size = atoi(argv[2]);
in = fopen(argv[1],"r");
if (in==0) return 2;
printf("Blocksize is: %ld\n\n",size);
bytes = 0;
if (ptr = malloc(size))
int block=0;

while (!feof(in))
if (out=fopen(buf,"w"))
printf("Reading from \"%s\" %ld bytes\n",argv[1],size);
bytes = fread(ptr,1,size,in);
printf("Writing to \"%s\" %ld bytes\n",buf,bytes);
if (ferror(in)) { printf("input file error!\n");break;}
if (ferror(out)) { printf("output file error!\n");break;}



return 0;

Introduction to MUI