Difference between revisions of "MorphOS API and Its Organization"

From MorphOS Library

(Contents.)
(Contents++;)
Line 24: Line 24:
  
 
==How to Use a Library in an Application==
 
==How to Use a Library in an Application==
 +
 +
In typical cases it is pretty automatic. The only thing which has to be done is including the main library header file, which is ''<proto/[libname].h>'', for example ''<proto/exec.h>'', ''<proto/muimaster.h>'' and so on.
  
  

Revision as of 17:40, 23 October 2010

Grzegorz Kraszewski


An Application Programmer Interface of an operating system consists of thousands of functions usually. MorphOS is no exception here. Its kernel is not monolithic however. The API is functionally (and physically) divided into libraries. Only a few largest libraries contain more than 50 functions. A core set of most important libraries is contained in the system boot image. The rest is placed on the system partition in MOSSYS:Libs (libraries delivered with the system) and SYS:Libs (third party libraries) directories. Disk based libraries are loaded on demand. All these libraries are shared, it means all processes using a library execute the same code loaded to memory once.

Libraries Overview

MorphOS comes with over 100 different libraries. Not all of them are listed below, just the most common ones. Browse the system autodocs in the SDK for more.

  • exec.library, the master one. This is the system core, responsible for processes scheduling, control and creation, communication between processes, memory management, managing other libraries and overall system control. This is the only library which is always opened and cannot be closed.
  • dos.library, responsible for file and console input/output. Provides interface to advanced filesystem functions (like scanning directories for example). Cooperates with exec.library in process creation. Delivers basic system time services.
  • graphics.library, is responsible for low-level graphics functions like drawing pixels and other primitives, copying rectangular blocks of display, scrolling etc. Many programs do not use it directly.
  • intuition.library, delivers an intermediate level graphics interface objects like screens and windows. Interfaces to user input devices (mouse and keyboard to name a few). Provides very basic user controls (gadgets). Provides also BOOPSI (Basic Object Oriented System for Intuition), a language independent object oriented programming framework, used commonly by other components.
  • muimaster.library, the main interface to MUI (Magic User Interface), which is the MorphOS high level GUI toolkit. Provides complete, object oriented framework (based on BOOPSI) for GUI driven applications.
  • locale.library, is responsible for system and applications internationalization. This simple yet powerful subsystem allows for supporting multiple language versions of program with single executable, also provides localization data such as date format, local currency, timezone, number grouping and more.
  • bsdsocket.library is an interface for TCP/IP networking, compatible with BSD sockets. What is unusal with this library, it is neither built into kernel, nor placed on disk. The TCP/IP stack creates it in memory dynamically.


How to Use a Library in an Application

In typical cases it is pretty automatic. The only thing which has to be done is including the main library header file, which is <proto/[libname].h>, for example <proto/exec.h>, <proto/muimaster.h> and so on.


Manual Library Opening and Closing

Technical Insight