aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c350
1 files changed, 175 insertions, 175 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c b/libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c
index 03fa146..4e27da2 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c
+++ b/libraries/irrlicht-1.8/source/Irrlicht/bzip2/dlltest.c
@@ -1,175 +1,175 @@
1/* 1/*
2 minibz2 2 minibz2
3 libbz2.dll test program. 3 libbz2.dll test program.
4 by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) 4 by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
5 This file is Public Domain. Welcome any email to me. 5 This file is Public Domain. Welcome any email to me.
6 6
7 usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] 7 usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]
8*/ 8*/
9 9
10#define BZ_IMPORT 10#define BZ_IMPORT
11#include <stdio.h> 11#include <stdio.h>
12#include <stdlib.h> 12#include <stdlib.h>
13#include "bzlib.h" 13#include "bzlib.h"
14#ifdef _WIN32 14#ifdef _WIN32
15#include <io.h> 15#include <io.h>
16#endif 16#endif
17 17
18 18
19#ifdef _WIN32 19#ifdef _WIN32
20 20
21#define BZ2_LIBNAME "libbz2-1.0.2.DLL" 21#define BZ2_LIBNAME "libbz2-1.0.2.DLL"
22 22
23#include <windows.h> 23#include <windows.h>
24static int BZ2DLLLoaded = 0; 24static int BZ2DLLLoaded = 0;
25static HINSTANCE BZ2DLLhLib; 25static HINSTANCE BZ2DLLhLib;
26int BZ2DLLLoadLibrary(void) 26int BZ2DLLLoadLibrary(void)
27{ 27{
28 HINSTANCE hLib; 28 HINSTANCE hLib;
29 29
30 if(BZ2DLLLoaded==1){return 0;} 30 if(BZ2DLLLoaded==1){return 0;}
31 hLib=LoadLibrary(BZ2_LIBNAME); 31 hLib=LoadLibrary(BZ2_LIBNAME);
32 if(hLib == NULL){ 32 if(hLib == NULL){
33 fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME); 33 fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME);
34 return -1; 34 return -1;
35 } 35 }
36 BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion"); 36 BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion");
37 BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen"); 37 BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen");
38 BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen"); 38 BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen");
39 BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread"); 39 BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread");
40 BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite"); 40 BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite");
41 BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush"); 41 BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush");
42 BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose"); 42 BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose");
43 BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror"); 43 BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror");
44 44
45 if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen 45 if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen
46 || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush 46 || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush
47 || !BZ2_bzclose || !BZ2_bzerror) { 47 || !BZ2_bzclose || !BZ2_bzerror) {
48 fprintf(stderr,"GetProcAddress failed.\n"); 48 fprintf(stderr,"GetProcAddress failed.\n");
49 return -1; 49 return -1;
50 } 50 }
51 BZ2DLLLoaded=1; 51 BZ2DLLLoaded=1;
52 BZ2DLLhLib=hLib; 52 BZ2DLLhLib=hLib;
53 return 0; 53 return 0;
54 54
55} 55}
56int BZ2DLLFreeLibrary(void) 56int BZ2DLLFreeLibrary(void)
57{ 57{
58 if(BZ2DLLLoaded==0){return 0;} 58 if(BZ2DLLLoaded==0){return 0;}
59 FreeLibrary(BZ2DLLhLib); 59 FreeLibrary(BZ2DLLhLib);
60 BZ2DLLLoaded=0; 60 BZ2DLLLoaded=0;
61} 61}
62#endif /* WIN32 */ 62#endif /* WIN32 */
63 63
64void usage(void) 64void usage(void)
65{ 65{
66 puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]"); 66 puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]");
67} 67}
68 68
69int main(int argc,char *argv[]) 69int main(int argc,char *argv[])
70{ 70{
71 int decompress = 0; 71 int decompress = 0;
72 int level = 9; 72 int level = 9;
73 char *fn_r = NULL; 73 char *fn_r = NULL;
74 char *fn_w = NULL; 74 char *fn_w = NULL;
75 75
76#ifdef _WIN32 76#ifdef _WIN32
77 if(BZ2DLLLoadLibrary()<0){ 77 if(BZ2DLLLoadLibrary()<0){
78 fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME); 78 fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME);
79 exit(1); 79 exit(1);
80 } 80 }
81 printf("Loading of %s succeeded. Library version is %s.\n", 81 printf("Loading of %s succeeded. Library version is %s.\n",
82 BZ2_LIBNAME, BZ2_bzlibVersion() ); 82 BZ2_LIBNAME, BZ2_bzlibVersion() );
83#endif 83#endif
84 while(++argv,--argc){ 84 while(++argv,--argc){
85 if(**argv =='-' || **argv=='/'){ 85 if(**argv =='-' || **argv=='/'){
86 char *p; 86 char *p;
87 87
88 for(p=*argv+1;*p;p++){ 88 for(p=*argv+1;*p;p++){
89 if(*p=='d'){ 89 if(*p=='d'){
90 decompress = 1; 90 decompress = 1;
91 }else if('1'<=*p && *p<='9'){ 91 }else if('1'<=*p && *p<='9'){
92 level = *p - '0'; 92 level = *p - '0';
93 }else{ 93 }else{
94 usage(); 94 usage();
95 exit(1); 95 exit(1);
96 } 96 }
97 } 97 }
98 }else{ 98 }else{
99 break; 99 break;
100 } 100 }
101 } 101 }
102 if(argc>=1){ 102 if(argc>=1){
103 fn_r = *argv; 103 fn_r = *argv;
104 argc--;argv++; 104 argc--;argv++;
105 }else{ 105 }else{
106 fn_r = NULL; 106 fn_r = NULL;
107 } 107 }
108 if(argc>=1){ 108 if(argc>=1){
109 fn_w = *argv; 109 fn_w = *argv;
110 argc--;argv++; 110 argc--;argv++;
111 }else{ 111 }else{
112 fn_w = NULL; 112 fn_w = NULL;
113 } 113 }
114 { 114 {
115 int len; 115 int len;
116 char buff[0x1000]; 116 char buff[0x1000];
117 char mode[10]; 117 char mode[10];
118 118
119 if(decompress){ 119 if(decompress){
120 BZFILE *BZ2fp_r = NULL; 120 BZFILE *BZ2fp_r = NULL;
121 FILE *fp_w = NULL; 121 FILE *fp_w = NULL;
122 122
123 if(fn_w){ 123 if(fn_w){
124 if((fp_w = fopen(fn_w,"wb"))==NULL){ 124 if((fp_w = fopen(fn_w,"wb"))==NULL){
125 printf("can't open [%s]\n",fn_w); 125 printf("can't open [%s]\n",fn_w);
126 perror("reason:"); 126 perror("reason:");
127 exit(1); 127 exit(1);
128 } 128 }
129 }else{ 129 }else{
130 fp_w = stdout; 130 fp_w = stdout;
131 } 131 }
132 if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL) 132 if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL)
133 || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){ 133 || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){
134 printf("can't bz2openstream\n"); 134 printf("can't bz2openstream\n");
135 exit(1); 135 exit(1);
136 } 136 }
137 while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){ 137 while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){
138 fwrite(buff,1,len,fp_w); 138 fwrite(buff,1,len,fp_w);
139 } 139 }
140 BZ2_bzclose(BZ2fp_r); 140 BZ2_bzclose(BZ2fp_r);
141 if(fp_w != stdout) fclose(fp_w); 141 if(fp_w != stdout) fclose(fp_w);
142 }else{ 142 }else{
143 BZFILE *BZ2fp_w = NULL; 143 BZFILE *BZ2fp_w = NULL;
144 FILE *fp_r = NULL; 144 FILE *fp_r = NULL;
145 145
146 if(fn_r){ 146 if(fn_r){
147 if((fp_r = fopen(fn_r,"rb"))==NULL){ 147 if((fp_r = fopen(fn_r,"rb"))==NULL){
148 printf("can't open [%s]\n",fn_r); 148 printf("can't open [%s]\n",fn_r);
149 perror("reason:"); 149 perror("reason:");
150 exit(1); 150 exit(1);
151 } 151 }
152 }else{ 152 }else{
153 fp_r = stdin; 153 fp_r = stdin;
154 } 154 }
155 mode[0]='w'; 155 mode[0]='w';
156 mode[1] = '0' + level; 156 mode[1] = '0' + level;
157 mode[2] = '\0'; 157 mode[2] = '\0';
158 158
159 if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL) 159 if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL)
160 || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){ 160 || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){
161 printf("can't bz2openstream\n"); 161 printf("can't bz2openstream\n");
162 exit(1); 162 exit(1);
163 } 163 }
164 while((len=fread(buff,1,0x1000,fp_r))>0){ 164 while((len=fread(buff,1,0x1000,fp_r))>0){
165 BZ2_bzwrite(BZ2fp_w,buff,len); 165 BZ2_bzwrite(BZ2fp_w,buff,len);
166 } 166 }
167 BZ2_bzclose(BZ2fp_w); 167 BZ2_bzclose(BZ2fp_w);
168 if(fp_r!=stdin)fclose(fp_r); 168 if(fp_r!=stdin)fclose(fp_r);
169 } 169 }
170 } 170 }
171#ifdef _WIN32 171#ifdef _WIN32
172 BZ2DLLFreeLibrary(); 172 BZ2DLLFreeLibrary();
173#endif 173#endif
174 return 0; 174 return 0;
175} 175}