comparison src/md5.c @ 259:11cf20601dec r20-5b28

Import from CVS: tag r20-5b28
author cvs
date Mon, 13 Aug 2007 10:23:02 +0200
parents 83b3d10dcba9
children 727739f917cb
comparison
equal deleted inserted replaced
258:58424f6abf56 259:11cf20601dec
30 #include "lisp.h" 30 #include "lisp.h"
31 31
32 #include "buffer.h" 32 #include "buffer.h"
33 #include "insdel.h" 33 #include "insdel.h"
34 #include "lstream.h" 34 #include "lstream.h"
35 #ifdef MULE 35 #ifdef FILE_CODING
36 #include "mule-coding.h" 36 #include "file-coding.h"
37 #endif 37 #endif
38 38
39 typedef unsigned char *POINTER;/* POINTER defines a generic pointer type */ 39 typedef unsigned char *POINTER;/* POINTER defines a generic pointer type */
40 typedef unsigned short int UINT2;/* UINT2 defines a two byte word */ 40 typedef unsigned short int UINT2;/* UINT2 defines a two byte word */
41 typedef unsigned int UINT4;/* UINT4 defines a four byte word */ 41 typedef unsigned int UINT4;/* UINT4 defines a four byte word */
388 Lisp_Object instream, outstream; 388 Lisp_Object instream, outstream;
389 Lstream *istr, *ostr; 389 Lstream *istr, *ostr;
390 static Extbyte_dynarr *conversion_out_dynarr; 390 static Extbyte_dynarr *conversion_out_dynarr;
391 char tempbuf[1024]; /* some random amount */ 391 char tempbuf[1024]; /* some random amount */
392 struct gcpro gcpro1, gcpro2; 392 struct gcpro gcpro1, gcpro2;
393 #ifdef MULE 393 #ifdef FILE_CODING
394 Lisp_Object conv_out_stream, coding_system; 394 Lisp_Object conv_out_stream, coding_system;
395 Lstream *costr; 395 Lstream *costr;
396 struct gcpro gcpro3; 396 struct gcpro gcpro3;
397 #endif 397 #endif
398 398
419 GB_HISTORICAL_STRING_BEHAVIOR); 419 GB_HISTORICAL_STRING_BEHAVIOR);
420 instream = make_lisp_string_input_stream (object, bstart, bend); 420 instream = make_lisp_string_input_stream (object, bstart, bend);
421 } 421 }
422 istr = XLSTREAM (instream); 422 istr = XLSTREAM (instream);
423 423
424 #ifdef MULE 424 #ifdef FILE_CODING
425 /* Find out what format the buffer will be saved in, so we can make 425 /* Find out what format the buffer will be saved in, so we can make
426 the digest based on what it will look like on disk */ 426 the digest based on what it will look like on disk */
427 if (NILP(coding)) 427 if (NILP(coding))
428 { 428 {
429 if (BUFFERP(object)) 429 if (BUFFERP(object))
455 signal_simple_error("No such coding system", coding); 455 signal_simple_error("No such coding system", coding);
456 else 456 else
457 coding_system = Fget_coding_system(Qbinary); /* default to binary */ 457 coding_system = Fget_coding_system(Qbinary); /* default to binary */
458 } 458 }
459 #endif 459 #endif
460 460
461 /* setup the out stream */ 461 /* setup the out stream */
462 outstream = make_dynarr_output_stream((unsigned_char_dynarr *)conversion_out_dynarr); 462 outstream = make_dynarr_output_stream((unsigned_char_dynarr *)conversion_out_dynarr);
463 ostr = XLSTREAM (outstream); 463 ostr = XLSTREAM (outstream);
464 #ifdef MULE 464 #ifdef FILE_CODING
465 /* setup the conversion stream */ 465 /* setup the conversion stream */
466 conv_out_stream = make_encoding_output_stream (ostr, coding_system); 466 conv_out_stream = make_encoding_output_stream (ostr, coding_system);
467 costr = XLSTREAM (conv_out_stream); 467 costr = XLSTREAM (conv_out_stream);
468 GCPRO3 (instream, outstream, conv_out_stream); 468 GCPRO3 (instream, outstream, conv_out_stream);
469 #else 469 #else
474 while (1) { 474 while (1) {
475 int size_in_bytes = Lstream_read (istr, tempbuf, sizeof (tempbuf)); 475 int size_in_bytes = Lstream_read (istr, tempbuf, sizeof (tempbuf));
476 if (!size_in_bytes) 476 if (!size_in_bytes)
477 break; 477 break;
478 /* It does seem the flushes are necessary... */ 478 /* It does seem the flushes are necessary... */
479 #ifdef MULE 479 #ifdef FILE_CODING
480 Lstream_write (costr, tempbuf, size_in_bytes); 480 Lstream_write (costr, tempbuf, size_in_bytes);
481 Lstream_flush (costr); 481 Lstream_flush (costr);
482 #else 482 #else
483 Lstream_write (ostr, tempbuf, size_in_bytes); 483 Lstream_write (ostr, tempbuf, size_in_bytes);
484 #endif 484 #endif
490 Dynarr_length(conversion_out_dynarr)); 490 Dynarr_length(conversion_out_dynarr));
491 /* reset the dynarr */ 491 /* reset the dynarr */
492 Lstream_rewind(ostr); 492 Lstream_rewind(ostr);
493 } 493 }
494 Lstream_close (istr); 494 Lstream_close (istr);
495 #ifdef MULE 495 #ifdef FILE_CODING
496 Lstream_close (costr); 496 Lstream_close (costr);
497 #endif 497 #endif
498 Lstream_close (ostr); 498 Lstream_close (ostr);
499 499
500 UNGCPRO; 500 UNGCPRO;
501 Lstream_delete (istr); 501 Lstream_delete (istr);
502 Lstream_delete (ostr); 502 Lstream_delete (ostr);
503 #ifdef MULE 503 #ifdef FILE_CODING
504 Lstream_delete (costr); 504 Lstream_delete (costr);
505 #endif 505 #endif
506 } 506 }
507 507
508 MDFinal (digest, &context); 508 MDFinal (digest, &context);