forked from richarddurbin/syng
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
67 lines (57 loc) · 2.47 KB
/
utils.h
File metadata and controls
67 lines (57 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* File: utils.h
* Author: Richard Durbin (rd@sanger.ac.uk)
* Copyright (C) Genome Research Limited, 2011
*-------------------------------------------------------------------
* Description: includes standard system headers and own headers
* Exported functions:
* HISTORY:
* Last edited: Mar 24 12:14 2026 (rd109)
* Created: Wed Jan 5 16:13:48 2011 (rd)
*-------------------------------------------------------------------
*/
#include <stdio.h> /* FILE etc. */
#include <stdlib.h> /* malloc(), free(), ... notation */
#include <inttypes.h> /* for standard size int types and their print macros */
#include <string.h> /* memset() */
#include <limits.h> /* INT_MAX etc. */
#include <stdbool.h> /* bool, true, false */
#include <assert.h>
#ifndef UTILS_DEFINED
#define UTILS_DEFINED
typedef int8_t I8 ;
const static I8 I8MAX = 0x7f ;
typedef int16_t I16 ;
const static I16 I16MAX = 0x7fff ;
typedef int32_t I32 ;
const static I32 I32MAX = 0x7fffffff ;
typedef long long I64 ;
const static I64 I64MAX = 0x7fffffffffffffff ;
typedef uint8_t U8 ;
const static U8 U8MAX = 0xff ;
typedef uint16_t U16 ;
const static U16 U16MAX = 0xffff ;
typedef uint32_t U32 ;
const static U32 U32MAX = 0xffffffff ;
typedef unsigned long long U64 ;
const static U64 U64MAX = 0xffffffffffffffff ;
#endif
void die (char *format, ...) ;
void warn (char *format, ...) ;
void *myalloc (size_t size) ;
void *mycalloc (size_t number, size_t size) ;
void *myresize (void* x, size_t nOld, size_t nNew, size_t size) ;
void myfree (void* x, size_t size) ;
#define new(n,type) (type*)myalloc((size_t)(n)*sizeof(type))
#define new0(n,type) (type*)mycalloc((size_t)(n),sizeof(type))
#define newResize(x,nOld,nNew,type) (type*) myresize((x),(size_t)(nOld),(size_t)(nNew),sizeof(type))
#define newDouble(x,n,type) myresize((x),(size_t)(n),(size_t)(2*(n)),sizeof(type)), (n)*=2
#define newFree(x,n,type) myfree((x),(size_t)((n)*sizeof(type)))
void storeCommandLine (int argc, char *argv[]) ;
char *getCommandLine (void) ;
char *fgetword (FILE *f) ; /* not threadsafe */
FILE *fzopen (const char* path, const char* mode) ; /* will open gzip files silently */
FILE *fopenTag (char* root, char* tag, char* mode) ;
char *fnameTag (char* root, char* tag) ; /* utility to return name as used by fopenTag() */
void timeUpdate (FILE *f) ; /* print time usage since last call to file */
void timeTotal (FILE *f) ; /* print full time usage since first call to timeUpdate */
/************************/