This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddem
executable file
·105 lines (96 loc) · 2.99 KB
/
addem
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# addem: add driver files and edit cfitsio files to set up emscripten driver
# error handler: send to stderr (which will go to stdout for CGI)
error() {
echo "ERROR: $*" >&2
exit 1
}
# which version of cfitsio
CFITSIO="cfitsio-4.0.0"
if [ x"$1" != x ]; then
CFITSIO="$1"
fi
if [ ! -r $CFITSIO ]; then
error "$CFITSIO directory or link is missing"
fi
echo "adding drvrem files to $CFITSIO ..."
# copy our driver files
cp -p drvrem.c drvrem.h $CFITSIO/.
# go into cfitsio to edit existing files
cd $CFITSIO || error "cannot cd to $CFITSIO"
# add driver to Makefile
if [ -r Makefile.in-orig ]; then
mv Makefile.in-orig Makefile.in
fi
sed -i -orig 's/drvrnet\.c/drvrnet.c drvrem.c/' Makefile.in
# add driver include file
if [ -r fitsio2.h-orig ]; then
mv fitsio2.h-orig fitsio2.h
fi
sed -i -orig '/hack for nonunix machines, which lack strcasecmp and strncasecmp/i\
#if __EMSCRIPTEN__\
/* prototypes for emscripten driver I/O routines */\
#include "drvrem.h"\
#endif\
\
' fitsio2.h
# add driver registration calls
if [ -r cfileio.c-orig ]; then
mv cfileio.c-orig cfileio.c
fi
sed -i -orig 's/#define MAX_DRIVERS 31/#define MAX_DRIVERS 33/;/Any other threads will now not need to call this routine/i\
#if __EMSCRIPTEN__\
\ /* 32------------ output emscripten https file driver ----------------*/\
\ status = fits_register_driver("@https://",\
\ em_init,\
\ em_shutdown,\
\ em_setoptions,\
\ em_getoptions, \
\ em_getversion,\
\ NULL, /* checkfile not required */\
\ em_open_https,\
\ NULL, /* create function not required */\
\ NULL, /* truncate function not required */\
\ em_close,\
\ NULL, /* remove function not required */\
\ em_size,\
\ NULL, /* flush function not required */\
\ em_seek,\
\ em_read,\
\ em_write);\
\
\ if (status)\
\ {\
\ ffpmsg("failed to register the @https:// driver (init_cfitsio)");\
\ FFUNLOCK;\
\ return(status);\
\ }\
\
\ /* 33------------ output emscripten http file driver ----------------*/\
\ status = fits_register_driver("@http://",\
\ em_init,\
\ em_shutdown,\
\ em_setoptions,\
\ em_getoptions, \
\ em_getversion,\
\ NULL, /* checkfile not required */\
\ em_open_http,\
\ NULL, /* create function not required */\
\ NULL, /* truncate function not required */\
\ em_close,\
\ NULL, /* remove function not required */\
\ em_size,\
\ NULL, /* flush function not required */\
\ em_seek,\
\ em_read,\
\ em_write);\
\
\ if (status)\
\ {\
\ ffpmsg("failed to register the @http:// driver (init_cfitsio)");\
\ FFUNLOCK;\
\ return(status);\
\ }\
\#endif\
\
' cfileio.c