]> git.draconx.ca Git - scripts.git/blob - get_extension.zsh
Add script to convert "JWK"-format RSA keys to normal.
[scripts.git] / get_extension.zsh
1 #!/usr/bin/env zsh
2 #
3 # Copyright © 2010-2012 Nick Bowler
4 #
5 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
6 # This is free software: you are free to do what the fuck you want to.
7 # There is NO WARRANTY, to the extent permitted by law.
8 #
9 # A convenient script to download an OpenGL extension specification from the
10 # Khronos registry into the current working directory.
11
12 IFS=_ extension=(${=1})
13
14 case $extension[1] in
15 GL|GLX|WGL)
16         ;;
17 *)
18         extension=(GL $extension)
19         ;;
20 esac
21
22 api=$extension[1]
23 vendor=$extension[2]
24 name=${(j:_:)extension[3,-1]}
25 fullname=${(j:_:)extension}
26
27 if [[ -z $api || -z $vendor || -z $name ]]; then
28         printf 'usage: %s extension\n' $0 1>&2
29         exit 1
30 fi
31
32 urls=(
33         http://www.opengl.org/registry/specs/$vendor/$name.txt
34         http://www.opengl.org/registry/specs/$vendor/${api:l}_$name.txt
35 )
36
37 for url in $urls; do
38         if wget -O $fullname $url; then
39                 gzip -f $fullname || exit 1
40                 exit 0
41         fi
42
43         rm -f $fullname
44 done
45
46 exit 1