︙ | | |
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
+
+
|
* Sets the device into blocking or nonblocking mode.
* Can call Tcl_SetChannelError.
*
*-------------------------------------------------------------------
*/
static int DigestBlockModeProc(ClientData clientData, int mode) {
DigestState *statePtr = (DigestState *) clientData;
dprintf("Called");
if (mode == TCL_MODE_NONBLOCKING) {
statePtr->flags |= TLS_TCL_ASYNC;
} else {
statePtr->flags &= ~(TLS_TCL_ASYNC);
}
return 0;
|
︙ | | |
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
+
+
|
* Side effects:
* Deletes stored state data.
*
*-------------------------------------------------------------------
*/
int DigestCloseProc(ClientData clientData, Tcl_Interp *interp) {
DigestState *statePtr = (DigestState *) clientData;
dprintf("Called");
/* Cancel active timer, if any */
if (statePtr->timer != (Tcl_TimerToken) NULL) {
Tcl_DeleteTimerHandler(statePtr->timer);
statePtr->timer = (Tcl_TimerToken) NULL;
}
|
︙ | | |
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
|
+
+
|
return 0;
}
/*
* Same as DigestCloseProc but with individual read and write close control
*/
static int DigestClose2Proc(ClientData instanceData, Tcl_Interp *interp, int flags) {
dprintf("Called");
if ((flags & (TCL_CLOSE_READ | TCL_CLOSE_WRITE)) == 0) {
return DigestCloseProc(instanceData, interp);
}
return EINVAL;
}
|
︙ | | |
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
|
+
+
|
*----------------------------------------------------------------------
*/
int DigestInputProc(ClientData clientData, char *buf, int toRead, int *errorCodePtr) {
DigestState *statePtr = (DigestState *) clientData;
Tcl_Channel parent;
Tcl_Size read;
*errorCodePtr = 0;
dprintf("Called");
/* Abort if nothing to process */
if (toRead <= 0 || statePtr->self == (Tcl_Channel) NULL) {
return 0;
}
/* Get bytes from underlying channel */
|
︙ | | |
526
527
528
529
530
531
532
533
534
535
536
537
538
539
|
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
+
+
|
* Get data from buf and update digest
*
*----------------------------------------------------------------------
*/
int DigestOutputProc(ClientData clientData, const char *buf, int toWrite, int *errorCodePtr) {
DigestState *statePtr = (DigestState *) clientData;
*errorCodePtr = 0;
dprintf("Called");
/* Abort if nothing to process */
if (toWrite <= 0 || statePtr->self == (Tcl_Channel) NULL) {
return 0;
}
/* Update hash function */
|
︙ | | |
562
563
564
565
566
567
568
569
570
571
572
573
574
575
|
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
|
+
+
|
*----------------------------------------------------------------------
*/
static int DigestSetOptionProc(ClientData clientData, Tcl_Interp *interp, const char *optionName,
const char *optionValue) {
DigestState *statePtr = (DigestState *) clientData;
Tcl_Channel parent;
Tcl_DriverSetOptionProc *setOptionProc;
dprintf("Called");
/* Abort if no channel */
if (statePtr->self == (Tcl_Channel) NULL) {
return TCL_ERROR;
}
/* Delegate options downstream */
|
︙ | | |
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
|
+
+
|
*----------------------------------------------------------------------
*/
static int DigestGetOptionProc(ClientData clientData, Tcl_Interp *interp, const char *optionName,
Tcl_DString *optionValue) {
DigestState *statePtr = (DigestState *) clientData;
Tcl_Channel parent;
Tcl_DriverGetOptionProc *getOptionProc;
dprintf("Called");
/* Abort if no channel */
if (statePtr->self == (Tcl_Channel) NULL) {
return TCL_ERROR;
}
/* Delegate options downstream */
|
︙ | | |
637
638
639
640
641
642
643
644
645
646
647
648
649
650
|
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
|
+
+
|
* Side effects:
* May call Tcl_NotifyChannel
*
*----------------------------------------------------------------------
*/
static void DigestTimerHandler(ClientData clientData) {
DigestState *statePtr = (DigestState *) clientData;
dprintf("Called");
/* Abort if no channel */
if (statePtr->self == (Tcl_Channel) NULL) {
return;
}
/* Clear timer token */
|
︙ | | |
671
672
673
674
675
676
677
678
679
680
681
682
683
684
|
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
|
+
+
|
*
*----------------------------------------------------------------------
*/
void DigestWatchProc(ClientData clientData, int mask) {
DigestState *statePtr = (DigestState *) clientData;
Tcl_Channel parent;
Tcl_DriverWatchProc *watchProc;
dprintf("Called");
/* Abort if no channel */
if (statePtr->self == (Tcl_Channel) NULL) {
return;
}
/* Store OR-ed combination of TCL_READABLE, TCL_WRITABLE and TCL_EXCEPTION */
|
︙ | | |
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
|
+
+
|
* None
*
*----------------------------------------------------------------------
*/
int DigestGetHandleProc(ClientData clientData, int direction, ClientData *handlePtr) {
DigestState *statePtr = (DigestState *) clientData;
Tcl_Channel parent;
dprintf("Called");
/* Abort if no channel */
if (statePtr->self == (Tcl_Channel) NULL) {
return TCL_ERROR;
}
parent = Tcl_GetStackedChannel(statePtr->self);
|
︙ | | |
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
|
+
+
|
* Side effects:
* Cancels any pending timer.
*
*----------------------------------------------------------------------
*/
int DigestNotifyProc(ClientData clientData, int interestMask) {
DigestState *statePtr = (DigestState *) clientData;
dprintf("Called");
/* Skip timer event as redundant */
if (statePtr->timer != (Tcl_TimerToken) NULL) {
Tcl_DeleteTimerHandler(statePtr->timer);
statePtr->timer = (Tcl_TimerToken) NULL;
}
return interestMask;
|
︙ | | |
980
981
982
983
984
985
986
987
988
989
990
991
992
993
|
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
|
+
+
|
* Side effects:
* Destroys state info structure
*
*-------------------------------------------------------------------
*/
void DigestCommandDeleteHandler(ClientData clientData) {
DigestState *statePtr = (DigestState *) clientData;
dprintf("Called");
/* Clean-up */
DigestStateFree(statePtr);
}
/*
*-------------------------------------------------------------------
|
︙ | | |