]> git.donarmstrong.com Git - biopieces.git/blob - code_c/Maasha/src/inc/common.h
320f0a99acafcd89bc676aae87b1e465399d0355
[biopieces.git] / code_c / Maasha / src / inc / common.h
1 /* Including standard libraries */
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <stdarg.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <ctype.h>
8 #include <math.h>
9 #include <assert.h>
10 #include <errno.h>
11
12 /* Define a shorthand for unsigned int */
13 #define uint unsigned int
14
15 /* Define a boolean type */
16 #define bool char
17 #define TRUE 1
18 #define FALSE 0
19
20 /* Macros for determining min or max of two given values. */
21 #define MAX( a, b ) a < b ? b : a
22 #define MIN( a, b ) a > b ? b : a
23
24 /* Macros for abs and int functions. */
25 #define ABS( x ) ( ( x ) < 0 ) ? -( x ) : ( x )
26 #define INT( x ) ( int ) x
27
28
29 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> STRUCTURE DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
30
31
32 // At some point test if typdef struct list list will allow us to move all this stuff to list.h and list.c
33
34
35 /* Singly linked list with a pointer to the next element and a pointer to a value. */
36 struct list
37 {
38     struct list *next;
39     void        *val;
40 };
41
42 /* Singly linked list with a pointer to the next element and an integer value. */
43 struct list_int
44 {
45     struct list *next;
46     int          val;
47 };
48
49
50 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR HANDLING <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
51
52
53 /* Print error message to stderr and exit. */
54 void die( char *error_msg );
55
56 /* Print warning message to stderr. */
57 void warn( char *warn_msg );
58
59
60 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ARRAYS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
61
62
63 /* Binary search an array of integers for an integer value. */
64 bool binary_search_array( int *array, int array_size, int val );
65
66
67 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> MISC <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
68
69
70 /* Split a given line and a delimiter return the split result as a list. */
71 void  split( char *string, char delimit, struct list **fields );
72     
73 /* Mockup version of Perl substr. */
74 char *substr( char *string, int offset, int len );
75
76 /* Return a binary number as a string of 1's and 0's. */
77 char *bits2string( uint bin );
78
79
80 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
81
82