/* J. Stolfi's miscellaneous general-purpose definitions */ /****************************************************************************/ /* (C) Copyright 1993 Universidade Estadual de Campinas (UNICAMP) */ /* Campinas, SP, Brazil */ /* */ /* This file can be freely distributed, modified, and used for any */ /* non-commercial purpose, provided that this copyright and authorship */ /* notice be included in any copy or derived version of this file. */ /* */ /* DISCLAIMER: This software is offered ``as is'', without any guarantee */ /* as to fitness for any particular purpose. Neither the copyright */ /* holder nor the authors or their employers can be held responsible for */ /* any damages that may result from its use. */ /****************************************************************************/ #ifndef JS_H #define JS_H #include #include #include typedef void * MemP; /* Pointer to memory area */ typedef int MemSize; /* Size in bytes of memory area */ void error (char *msg); /* Prints string $*msg$ to $stderr$ and stops */ void assert(int test, char *msg); /* If test is false, prints $*msg$ and stops. */ char *txtcat (char *a, char *b); /* Returns a new string that is the concatenation of $*a$ and $*b$. */ char *today(void); /* Returns today's date in the format "yy-mm-dd hh:mm:ss" */ double now(void); /* Returns the current user time in microseconds. */ FILE *open_write(char *name); FILE *open_read(char *name); /* Opens file for output or input, bombs in case of failure. */ char *read_line(FILE *f); /* Reads the next line from file f, until '\n', NUL, or EOF. Returns it as a NUL-terminated string, without the final '\n'. Replaces TABs by single spaces. Allocates space for it with malloc(). Returns NULL iff the file is already at EOF. */ float frandom(void); double drandom(void); /* Returns a uniform random number in [0.0 __ 1.0). */ /* Missing system prototypes:*/ void srandom(int); int random(void); #endif