~ubuntu-branches/ubuntu/maverick/ncbi-tools6/maverick

« back to all changes in this revision

Viewing changes to api/ffprint.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*
30
30
* Version Creation Date:   7/15/95
31
31
*
32
 
* $Revision: 6.6 $
 
32
* $Revision: 6.8 $
33
33
*
34
34
* File Description: 
35
35
*
36
36
* Modifications:  
37
37
* --------------------------------------------------------------------------
38
38
 * $Log: ffprint.c,v $
 
39
 * Revision 6.8  2003/07/15 14:35:56  dondosha
 
40
 * Added #defines for substitutes to fprintf and fflush, needed for gzip compression of Web BLAST results
 
41
 *
 
42
 * Revision 6.7  2002/08/26 22:06:57  kans
 
43
 * ff_RecalculateLinks (MS) to fix hotlink artifact
 
44
 *
39
45
 * Revision 6.6  1999/10/07 19:22:21  bazhin
40
46
 * Changed Int2 to Int4 for one variable. To prevent coredump.
41
47
 *
122
128
#include <ffprint.h>
123
129
#include <ncbithr.h>
124
130
 
 
131
int (*ff_fprintf)(FILE*, const char *, ...) = fprintf;
 
132
int (*ff_fflush)(FILE*) = fflush;
 
133
 
 
134
#define fprintf ff_fprintf
 
135
#define fflush ff_fflush
125
136
 
126
137
static TNlmTls ffprint_tls = NULL;
127
138
 
562
573
        Int2            increment_string=0;
563
574
        Int4            l;
564
575
        CharPtr PNTR buf_links;
565
 
        Int2 PNTR       buf_pos;
 
576
        Int4 PNTR       buf_pos;
566
577
        BuffStructPtr bfp;
567
578
 
568
579
        bfp = GetBuffStruct();
585
596
                bfp->links = buf_links;
586
597
                bfp->buf_n_links += LINKS;
587
598
        }
588
 
        bfp->pos_links[bfp->n_links] = (Int2)(buffer - bfp->buffer + l);
 
599
        bfp->pos_links[bfp->n_links] = (buffer - bfp->buffer + l);
589
600
        bfp->links[bfp->n_links] = StringSave(str);
590
601
        bfp->n_links++;
591
602
        return;
597
608
        Int2            increment_string=0;
598
609
        Int4            l;
599
610
        CharPtr PNTR buf_links;
600
 
        Int2 PNTR       buf_pos;
 
611
        Int4 PNTR       buf_pos;
601
612
        BuffStructPtr bfp;
602
613
 
603
614
        bfp = GetBuffStruct();
733
744
 
734
745
}       /* ChangeStringWithTildes */
735
746
        
 
747
NLM_EXTERN void LIBCALL ff_RecalculateLinks(Int4 indent) {
 
748
    BuffStructPtr bfp = GetBuffStruct();
 
749
    Int4 len = (bfp->byte_sp == NULL) ? 0 : BSLen(bfp->byte_sp);
 
750
    Int2 i;
 
751
 
 
752
    for ( i = bfp->n_links - 1; i >= 0; --i ) {
 
753
        if ( bfp->pos_links[i] + 1 >= len ) { 
 
754
            bfp->pos_links[i] += indent;
 
755
        } else {
 
756
            break;
 
757
        }
 
758
    }
 
759
}
 
760
 
736
761
NLM_EXTERN CharPtr LIBCALL CheckBufferState(Int2Ptr increment_string, Char next_char)
737
762
 
738
763
{
744
769
        Int2 length, cont_indent, indent_space; 
745
770
        Int2 line_max, line_index;
746
771
        BuffStructPtr bfp;
 
772
    Int2 IndentSize = 0;
747
773
 
748
774
        bfp = GetBuffStruct();
749
775
        cont_indent = bfp->cont_indent;
839
865
                                }
840
866
                                buf_ptr_start[0] = '\0';
841
867
                        }
842
 
 
 
868
            
 
869
            
843
870
                        FlushBuffer();
844
871
                        if (line_prefix != NULL) {
845
872
                                *buffer = *line_prefix;
852
879
                        if (indent_space > 0)
853
880
                                MemSet((VoidPtr) buffer, ' ', indent_space);
854
881
                        buffer += indent_space;
 
882
            IndentSize = buffer - bfp->buffer + 1;
855
883
                        temp_ptr = temp_ptr_start;
856
884
                        while((*buffer = *temp_ptr) != '\0') {
857
885
                                temp_ptr++;
858
886
                                buffer++;
859
887
                        }
860
 
                
 
888
                    
 
889
            ff_RecalculateLinks(IndentSize);
861
890
                        return buffer;
862
891
                } else if (next_char == ' ') {
863
892
                        FlushBuffer();
871
900
                        }
872
901
                        if (indent_space-1 > 0) {
873
902
                                MemSet((VoidPtr) buffer, ' ', indent_space-1);
 
903
                ff_RecalculateLinks(buffer+indent_space-1 - bfp->buffer);
874
904
                                return buffer+indent_space-1;
875
905
                        } else if (indent_space-1 == 0) {
876
906
                        /* if there is one space indentation! */
 
907
                ff_RecalculateLinks(buffer - bfp->buffer);
877
908
                                return buffer;
878
909
                        } else if (indent_space-1 < 0) {
879
910
                        /* if there is zero space indentation! */
880
911
                                *increment_string = 1;
 
912
                ff_RecalculateLinks(buffer - bfp->buffer);
881
913
                                return buffer;
882
914
                        }
883
915
                } else { 
893
925
                        if (indent_space > 0) {
894
926
                                MemSet((VoidPtr) buffer, ' ', indent_space);
895
927
                        }
 
928
            ff_RecalculateLinks(buffer +indent_space - bfp->buffer);
896
929
                        return buffer+indent_space;
897
930
                }
898
931
        }