Doxygen Source Code Documentation
        
Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search   
ckconfig.c
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 #define HAVE_STDDEF_H           
00036 #ifdef HAVE_STDDEF_H            
00037 #include <stddef.h>
00038 #endif
00039 
00040 #define HAVE_STDLIB_H           
00041 #ifdef HAVE_STDLIB_H
00042 #include <stdlib.h>
00043 #endif
00044 
00045 #include <stdio.h>              
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 #undef NEED_BSD_STRINGS
00054 
00055 #ifdef NEED_BSD_STRINGS
00056 #include <strings.h>
00057 #else
00058 #include <string.h>
00059 #endif
00060 
00061 
00062 
00063 
00064 
00065 
00066 #undef NEED_SYS_TYPES_H         
00067 #ifdef NEED_SYS_TYPES_H
00068 #include <sys/types.h>
00069 #endif
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 #undef NEED_SPECIAL_INCLUDE     
00085 
00086 #ifdef NEED_SPECIAL_INCLUDE
00087 #include <someincludefile.h>
00088 #endif
00089 
00090 typedef size_t my_size_t;       
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 #define HAVE_PROTOTYPES
00101 
00102 #ifdef HAVE_PROTOTYPES
00103 int testfunction (int arg1, int * arg2); 
00104 
00105 struct methods_struct {         
00106   int (*error_exit) (char *msgtext);
00107   int (*trace_message) (char *msgtext);
00108   int (*another_method) (void);
00109 };
00110 
00111 int testfunction (int arg1, int * arg2) 
00112 {
00113   return arg2[arg1];
00114 }
00115 
00116 int test2function (void)        
00117 {
00118   return 0;
00119 }
00120 #endif
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 #define HAVE_UNSIGNED_CHAR
00129 
00130 #ifdef HAVE_UNSIGNED_CHAR
00131 unsigned char un_char;
00132 #endif
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 #define HAVE_UNSIGNED_SHORT
00141 
00142 #ifdef HAVE_UNSIGNED_SHORT
00143 unsigned short un_short;
00144 #endif
00145 
00146 
00147 
00148 
00149 
00150 
00151 #define HAVE_VOID
00152 
00153 #ifdef HAVE_VOID
00154 
00155 typedef void * void_ptr;        
00156 #ifdef HAVE_PROTOTYPES          
00157 typedef void (*void_func) (int a, int b);
00158 #else
00159 typedef void (*void_func) ();
00160 #endif
00161 
00162 #ifdef HAVE_PROTOTYPES          
00163 void test3function (void_ptr arg1, void_func arg2)
00164 #else
00165 void test3function (arg1, arg2)
00166      void_ptr arg1;
00167      void_func arg2;
00168 #endif
00169 {
00170   char * locptr = (char *) arg1; 
00171   arg1 = (void *) locptr;
00172   (*arg2) (1, 2);               
00173 }
00174 #endif
00175 
00176 
00177 
00178 
00179 
00180 
00181 #define HAVE_CONST
00182 
00183 #ifdef HAVE_CONST
00184 static const int carray[3] = {1, 2, 3};
00185 
00186 #ifdef HAVE_PROTOTYPES
00187 int test4function (const int arg1)
00188 #else
00189 int test4function (arg1)
00190      const int arg1;
00191 #endif
00192 {
00193   return carray[arg1];
00194 }
00195 #endif
00196 
00197 
00198 
00199 
00200 
00201 
00202 #undef INCOMPLETE_TYPES_BROKEN
00203 
00204 #ifndef INCOMPLETE_TYPES_BROKEN
00205 typedef struct undefined_structure * undef_struct_ptr;
00206 #endif
00207 
00208 
00209 
00210 
00211 
00212 
00213 #undef NEED_SHORT_EXTERNAL_NAMES
00214 
00215 #ifndef NEED_SHORT_EXTERNAL_NAMES
00216 
00217 int possibly_duplicate_function ()
00218 {
00219   return 0;
00220 }
00221 
00222 int possibly_dupli_function ()
00223 {
00224   return 1;
00225 }
00226 
00227 #endif
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00242 #ifdef HAVE_PROTOTYPES
00243 int is_char_signed (int arg)
00244 #else
00245 int is_char_signed (arg)
00246      int arg;
00247 #endif
00248 {
00249   if (arg == 189) {             
00250     return 0;                   
00251   }
00252   else if (arg != -67) {        
00253     printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
00254     printf("I fear the JPEG software will not work at all.\n\n");
00255   }
00256   return 1;                     
00257 }
00258 
00259 
00260 #ifdef HAVE_PROTOTYPES
00261 int is_shifting_signed (long arg)
00262 #else
00263 int is_shifting_signed (arg)
00264      long arg;
00265 #endif
00266 
00267 {
00268   long res = arg >> 4;
00269 
00270   if (res == -0x7F7E80CL) {     
00271     return 1;                   
00272   }
00273   
00274   
00275   res |= (~0L) << (32-4);
00276   if (res == -0x7F7E80CL) {     
00277     return 0;                   
00278   }
00279   printf("Right shift isn't acting as I expect it to.\n");
00280   printf("I fear the JPEG software will not work at all.\n\n");
00281   return 0;                     
00282 }
00283 
00284 
00285 #ifdef HAVE_PROTOTYPES
00286 int main (int argc, char ** argv)
00287 #else
00288 int main (argc, argv)
00289      int argc;
00290      char ** argv;
00291 #endif
00292 {
00293   char signed_char_check = (char) (-67);
00294   FILE *outfile;
00295 
00296   
00297   if ((outfile = fopen("jconfig.h", "w")) == NULL) {
00298     printf("Failed to write jconfig.h\n");
00299     return 1;
00300   }
00301 
00302   
00303   fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n");
00304   fprintf(outfile, "/* see jconfig.doc for explanations */\n\n");
00305 #ifdef HAVE_PROTOTYPES
00306   fprintf(outfile, "#define HAVE_PROTOTYPES\n");
00307 #else
00308   fprintf(outfile, "#undef HAVE_PROTOTYPES\n");
00309 #endif
00310 #ifdef HAVE_UNSIGNED_CHAR
00311   fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n");
00312 #else
00313   fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n");
00314 #endif
00315 #ifdef HAVE_UNSIGNED_SHORT
00316   fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n");
00317 #else
00318   fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n");
00319 #endif
00320 #ifdef HAVE_VOID
00321   fprintf(outfile, "/* #define void char */\n");
00322 #else
00323   fprintf(outfile, "#define void char\n");
00324 #endif
00325 #ifdef HAVE_CONST
00326   fprintf(outfile, "/* #define const */\n");
00327 #else
00328   fprintf(outfile, "#define const\n");
00329 #endif
00330   if (is_char_signed((int) signed_char_check))
00331     fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n");
00332   else
00333     fprintf(outfile, "#define CHAR_IS_UNSIGNED\n");
00334 #ifdef HAVE_STDDEF_H
00335   fprintf(outfile, "#define HAVE_STDDEF_H\n");
00336 #else
00337   fprintf(outfile, "#undef HAVE_STDDEF_H\n");
00338 #endif
00339 #ifdef HAVE_STDLIB_H
00340   fprintf(outfile, "#define HAVE_STDLIB_H\n");
00341 #else
00342   fprintf(outfile, "#undef HAVE_STDLIB_H\n");
00343 #endif
00344 #ifdef NEED_BSD_STRINGS
00345   fprintf(outfile, "#define NEED_BSD_STRINGS\n");
00346 #else
00347   fprintf(outfile, "#undef NEED_BSD_STRINGS\n");
00348 #endif
00349 #ifdef NEED_SYS_TYPES_H
00350   fprintf(outfile, "#define NEED_SYS_TYPES_H\n");
00351 #else
00352   fprintf(outfile, "#undef NEED_SYS_TYPES_H\n");
00353 #endif
00354   fprintf(outfile, "#undef NEED_FAR_POINTERS\n");
00355 #ifdef NEED_SHORT_EXTERNAL_NAMES
00356   fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n");
00357 #else
00358   fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n");
00359 #endif
00360 #ifdef INCOMPLETE_TYPES_BROKEN
00361   fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n");
00362 #else
00363   fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n");
00364 #endif
00365   fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n");
00366   if (is_shifting_signed(-0x7F7E80B1L))
00367     fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n");
00368   else
00369     fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n");
00370   fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n");
00371   fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n");
00372   fprintf(outfile, "#define BMP_SUPPORTED               /* BMP image file format */\n");
00373   fprintf(outfile, "#define GIF_SUPPORTED               /* GIF image file format */\n");
00374   fprintf(outfile, "#define PPM_SUPPORTED               /* PBMPLUS PPM/PGM image file format */\n");
00375   fprintf(outfile, "#undef RLE_SUPPORTED                /* Utah RLE image file format */\n");
00376   fprintf(outfile, "#define TARGA_SUPPORTED             /* Targa image file format */\n\n");
00377   fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n");
00378   fprintf(outfile, "#undef NEED_SIGNAL_CATCHER  /* Define this if you use jmemname.c */\n");
00379   fprintf(outfile, "#undef DONT_USE_B_MODE\n");
00380   fprintf(outfile, "/* #define PROGRESS_REPORT */       /* optional */\n");
00381   fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n");
00382 
00383   
00384   fclose(outfile);
00385 
00386   
00387   printf("Configuration check for Independent JPEG Group's software done.\n");
00388   printf("\nI have written the jconfig.h file for you.\n\n");
00389 #ifdef HAVE_PROTOTYPES
00390   printf("You should use makefile.ansi as the starting point for your Makefile.\n");
00391 #else
00392   printf("You should use makefile.unix as the starting point for your Makefile.\n");
00393 #endif
00394 
00395 #ifdef NEED_SPECIAL_INCLUDE
00396   printf("\nYou'll need to change jconfig.h to include the system include file\n");
00397   printf("that you found type size_t in, or add a direct definition of type\n");
00398   printf("size_t if that's what you used.  Just add it to the end.\n");
00399 #endif
00400 
00401   return 0;
00402 }