Common routines

Overview

zcom.h is a C header file for common routines needed in simulations. These routines include

The name stands for zipped common routines.

Usage

The quickest usage is the following. where we used the function fexists() to check if there is a file ex1.c. Download the code ex1.c.

  #include "zcom.h"

  int main(void) {
    return fexists("ex1.c");
  }

A recommended usage is demonstrated below, where we used the function sysrun() defined in the module osys. The program calls the system command ls and captures the output (for Windows, change ls to dir). The advantage of defining ZCOM_PICK before #include "zcom.h" is that we can select needed modules, and avoids possible name conflicts. Usually, there is no need to worry about the internal dependence among modules. Download the code ex2.c.

  #define ZCOM_PICK
  #define ZCOM_OSYS
  #include "zcom.h"

  int main(void) {
    char *out = sysrun("ls", NULL, 0);
    puts(out);
    return 0;
  }

Downloads

Program Description Language
zcom.h A self-contained C header file for inclusion.
A user only needs this.
C
zcom.zip Individual modules in zcom.h (for developers), zcom.h is assembled by a python script.
It needs Python 2.7 (probably works with 2.5 and 2.6 too).
Linux environment is recommended since symbolic links are extensively used.
C, Python