@@ -67,7 +67,7 @@ class AMQPWriter
67
67
if ($ x <0 )
68
68
$ x = sprintf ("%u " , $ x );
69
69
}
70
-
70
+
71
71
$ res = array ();
72
72
for ($ i =0 ;$ i <$ bytes ;$ i ++)
73
73
{
@@ -79,7 +79,7 @@ class AMQPWriter
79
79
throw new Exception ("Value too big! " );
80
80
return $ res ;
81
81
}
82
-
82
+
83
83
private function flushbits ()
84
84
{
85
85
if (count ($ this ->bits ))
@@ -122,10 +122,10 @@ class AMQPWriter
122
122
$ last = 0 ;
123
123
else
124
124
$ last = array_pop ($ this ->bits );
125
-
125
+
126
126
$ last |= ($ b << $ shift );
127
127
array_push ($ this ->bits , $ last );
128
-
128
+
129
129
$ this ->bitcount += 1 ;
130
130
}
131
131
@@ -275,7 +275,7 @@ class AMQPReader
275
275
276
276
if (!function_exists ("bcmul " ))
277
277
throw new Exception ("'bc math' module required " );
278
-
278
+
279
279
$ this ->buffer_read_timeout = 5 ; // in seconds
280
280
}
281
281
@@ -290,14 +290,14 @@ class AMQPReader
290
290
$ this ->bitcount = $ this ->bits = 0 ;
291
291
return $ this ->rawread ($ n );
292
292
}
293
-
293
+
294
294
private function rawread ($ n )
295
295
{
296
296
if ($ this ->sock )
297
297
{
298
298
$ res = '' ;
299
299
$ read = 0 ;
300
-
300
+
301
301
$ start = time ();
302
302
while ($ read < $ n && !feof ($ this ->sock ->real_sock ()) &&
303
303
(false !== ($ buf = fread ($ this ->sock ->real_sock (), $ n - $ read ))))
@@ -307,8 +307,8 @@ class AMQPReader
307
307
usleep (100 );
308
308
}
309
309
else
310
- $ start = time ();
311
-
310
+ $ start = time ();
311
+
312
312
$ read += strlen ($ buf );
313
313
$ res .= $ buf ;
314
314
}
@@ -378,7 +378,7 @@ class AMQPReader
378
378
return $ res ;
379
379
}
380
380
}
381
-
381
+
382
382
// PHP does not have unsigned 32 bit int,
383
383
// so we return it as a string
384
384
public function read_long ()
@@ -410,7 +410,7 @@ class AMQPReader
410
410
// workaround signed/unsigned braindamage in php
411
411
$ hi = sprintf ( "%u " , $ hi [1 ] );
412
412
$ lo = sprintf ( "%u " , $ lo [1 ] );
413
-
413
+
414
414
return bcadd (bcmul ($ hi , "4294967296 " ), $ lo );
415
415
}
416
416
@@ -424,7 +424,7 @@ class AMQPReader
424
424
list (,$ slen ) = unpack ('C ' , $ this ->rawread (1 ));
425
425
return $ this ->rawread ($ slen );
426
426
}
427
-
427
+
428
428
/**
429
429
* Read a string that's up to 2**32 bytes, the encoding
430
430
* isn't specified in the AMQP spec, so just return it as
@@ -438,7 +438,7 @@ class AMQPReader
438
438
throw new Exception ("Strings longer than supported on this platform " );
439
439
return $ this ->rawread ($ slen );
440
440
}
441
-
441
+
442
442
/**
443
443
* Read and AMQP timestamp, which is a 64-bit integer representing
444
444
* seconds since the Unix epoch in 1-second resolution.
@@ -488,12 +488,12 @@ class AMQPReader
488
488
return $ result ;
489
489
}
490
490
491
-
491
+
492
492
protected function tell ()
493
493
{
494
494
return $ this ->offset ;
495
495
}
496
-
496
+
497
497
}
498
498
499
499
@@ -530,11 +530,11 @@ class GenericContent
530
530
{
531
531
if (array_key_exists ($ name ,$ this ->properties ))
532
532
return $ this ->properties [$ name ];
533
-
533
+
534
534
if (isset ($ this ->delivery_info ))
535
535
if (array_key_exists ($ name ,$ this ->delivery_info ))
536
536
return $ this ->delivery_info [$ name ];
537
-
537
+
538
538
throw new Exception ("No such property " );
539
539
}
540
540
@@ -603,7 +603,7 @@ class GenericContent
603
603
$ flag_bits = 0 ;
604
604
$ shift = 15 ;
605
605
}
606
-
606
+
607
607
$ flag_bits |= (1 << $ shift );
608
608
if ($ proptype != "bit " )
609
609
call_user_func (array ($ raw_bytes , "write_ " . $ proptype ),
@@ -616,7 +616,7 @@ class GenericContent
616
616
foreach ($ flags as $ flag_bits )
617
617
$ result ->write_short ($ flag_bits );
618
618
$ result ->write ($ raw_bytes ->getvalue ());
619
-
619
+
620
620
return $ result ->getvalue ();
621
621
}
622
622
}
@@ -629,14 +629,14 @@ class BufferedInput
629
629
630
630
$ this ->sock = $ sock ;
631
631
$ this ->reset ("" );
632
-
632
+
633
633
}
634
-
634
+
635
635
public function real_sock ()
636
636
{
637
637
return $ this ->sock ;
638
638
}
639
-
639
+
640
640
public function read ($ n )
641
641
{
642
642
if ($ this ->offset >= strlen ($ this ->buffer ))
@@ -648,13 +648,13 @@ class BufferedInput
648
648
}
649
649
return $ this ->read_buffer ($ n );
650
650
}
651
-
651
+
652
652
public function close ()
653
653
{
654
654
fclose ($ this ->sock );
655
655
$ this ->reset ("" );
656
656
}
657
-
657
+
658
658
private function read_buffer ($ n )
659
659
{
660
660
$ n = min ($ n , strlen ($ this ->buffer ) - $ this ->offset );
@@ -669,21 +669,21 @@ class BufferedInput
669
669
$ this ->offset += $ n ;
670
670
return $ block ;
671
671
}
672
-
672
+
673
673
private function reset ($ block )
674
674
{
675
675
$ this ->buffer = $ block ;
676
676
$ this ->offset = 0 ;
677
677
}
678
-
678
+
679
679
private function populate_buffer ()
680
680
{
681
681
if (feof ($ this ->sock ))
682
682
{
683
683
$ this ->reset ("" );
684
684
return FALSE ;
685
685
}
686
-
686
+
687
687
$ block = fread ($ this ->sock , $ this ->block_size );
688
688
if ($ block !== FALSE )
689
689
{
0 commit comments