GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/****************************************************************************1**2*W utils.c XGAP Source Frank Celler3**4**5*Y Copyright 1995-1997, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany6*Y Copyright 1997, Frank Celler, Huerth, Germany7**8** This file contains the utility functions and macros used in XGAP,9** basically the list functions ('ELM', 'LEN', 'AddList', and 'List') and10** the debug macro ('DEBUG'). This file also includes all the necessary11** system and X11 include files and defines the following data types:12**13** Boolean "True" or "False" (defined by X11)14** Char a "Char" will be able to hold one character15** Int a 32-bit signed integer16** Long an integer able to hold a pointer17** Pointer a generic pointer18** Short a 16-bit signed integer19** String an array of chars20** UChar unsigned version of "Char"21** UInt a 32-bit unsigned integer22** ULong unsigned version of "Long"23** UShort a 16-bit unsigned integer24**25** List( <len> )26** -------------27** 'List' creates a new list able to hold <len> pointers of type 'Pointer'.28**29** AddList( <lst>, <elm> )30** -----------------------31** 'AddList' appends the new element <elm> of type 'Pointer' to <lst>,32** enlarging the list if necessary.33**34** ELM( <lst>, <i> )35** -----------------36** 'ELM' returns the <i>.th element of <lst>.37**38** LEN( <lst> )39** ------------40** 'LEN' returns the length of <lst>.41**42** DEBUG( <type>, ( <debug-text>, ... ) )43** --------------------------------------44** 'DEBUG' uses 'printf' to print the <debug-text> in case that 'Debug' &&45** <type> is true. The text is preceded by the line number and the source46** file name. The following types are available: D_LIST, D_XCMD, D_COMM.47*/48#include "utils.h"495051/****************************************************************************52**5354*V Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . debug on/off55*/56Int Debug = 0;575859/****************************************************************************60**61*F List( <len> ) . . . . . . . . . . . . . . . . . . . create a new list62*/63#ifdef DEBUG_ON64TypeList LIST ( file, line, len )65String file;66Int line;67UInt len;68#else69TypeList List ( len )70UInt len;71#endif72{73TypeList list;7475/* get memory for new list */76list = (TypeList) XtMalloc( sizeof( struct _list ) );77list->len = len;78list->size = len+10;79list->ptr = (Pointer) XtMalloc( list->size * sizeof(Pointer) );8081/* give some debug information */82#ifdef DEBUG_ON83if ( Debug & D_LIST )84printf( "%04d:%s: List(%d)=%p\n", line, file, len, (void*)list );85#endif8687/* return the new list */88return list;89}909192/****************************************************************************93**94*F AddList( <lst>, <elm> ) . . . . . . . . add list element <elm> to <list>95*/96#ifdef DEBUG_ON97void ADD_LIST ( file, line, lst, elm )98String file;99Int line;100TypeList lst;101Pointer elm;102#else103void AddList ( lst, elm )104TypeList lst;105Pointer elm;106#endif107{108/* give some debug information */109#ifdef DEBUG_ON110if ( Debug & D_LIST )111printf( "%04d:%s: AddList( %p, %p )\n", line, file, (void*)lst,112(void*)elm );113#endif114115/* resize <lst> if necessary */116if ( lst->len == lst->size )117{118lst->size = lst->size*4/3 + 5;119lst->ptr = (Pointer) XtRealloc( (char*) lst->ptr,120lst->size * sizeof(Pointer) );121}122123/* and add list element */124lst->ptr[lst->len++] = elm;125}126127128/****************************************************************************129**130131*E utils.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here132*/133134135