Subversion Repositories svn1

Rev

Rev 203 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 203 Rev 380
Line 17... Line 17...
17
 * revision date        by      reason
17
 * revision date        by      reason
18
 *  00.0    27/01/95    DDP     Tidies up the program and formatted the file
18
 *  00.0    27/01/95    DDP     Tidies up the program and formatted the file
19
 *
19
 *
20
 **************************************************************************/
20
 **************************************************************************/
21
#include <QString>
21
#include <QString>
-
 
22
#include  <QDir>
-
 
23
#include <QProcessEnvironment>
22
#include    <stdio.h>
24
#include    <stdio.h>
23
#include    <time.h>
25
#include    <time.h>
24
#include    <stdarg.h>
26
#include    <stdarg.h>
25
#include    "mainwindow.h"
27
#include    "mainwindow.h"
26
 
28
 
-
 
29
 
27
#include    "consts.h"
30
#include    "consts.h"
28
#include    "structs.h"
31
#include    "structs.h"
29
#include    "proto.h"
32
#include    "proto.h"
30
 
33
 
31
FILE       *pfile;                               /* Fd of the printer channel */
34
FILE       *pfile;                               /* Fd of the printer channel */
Line 36... Line 39...
36
int         print_line = 0;                      /* Current print line */
39
int         print_line = 0;                      /* Current print line */
37
int         print_underline_start;               /* Start of underline */
40
int         print_underline_start;               /* Start of underline */
38
int         print_underline_end;                 /* End of underline */
41
int         print_underline_end;                 /* End of underline */
39
long        print_current_colour;                /* Current printing colour */
42
long        print_current_colour;                /* Current printing colour */
40
QString     printFileName;                       /* Last printer file opened */
43
QString     printFileName;                       /* Last printer file opened */
-
 
44
char        print_href[200];                     /* Current HREF string */
41
 
45
 
42
/*========================================================================
46
/*========================================================================
43
 *
47
 *
44
 *  Open the printer
48
 *  Open the printer
45
 *
49
 *
Line 102... Line 106...
102
 *
106
 *
103
 *
107
 *
104
 *  Note: Use an "htm" file extension as DOS cannot handle 4 letter extensions
108
 *  Note: Use an "htm" file extension as DOS cannot handle 4 letter extensions
105
----------------------------------------------------------------------------*/
109
----------------------------------------------------------------------------*/
106
 
110
 
107
bool open_printer_name( const char *pname, int width, report_type html, const char *title )
111
bool open_printer_name( const char *pname, int width, report_type htmltype, const char *title )
108
{
112
{
109
    printFileName = filepath;
113
    printFileName = filepath;
-
 
114
    switch (htmltype)
-
 
115
    {
-
 
116
    case printed: printFileName.append("webtxt/");  break;
-
 
117
    case html: printFileName.append("web/");  break;
-
 
118
    default: printFileName.append("text/");  break;
-
 
119
    }
-
 
120
 
-
 
121
    /*
-
 
122
    ** Ensure that the directory exists
-
 
123
    */
-
 
124
    {
-
 
125
        QDir dir(filepath);
-
 
126
        dir.mkpath(printFileName);
-
 
127
    }
-
 
128
 
-
 
129
    /*
-
 
130
    ** Append the filename to the directory
-
 
131
    */
110
    printFileName.append(pname);
132
    printFileName.append(pname);
111
 
133
 
112
    print_width = width ? width : 80;
134
    print_width = width ? width : 80;
113
    print_col = 0;
135
    print_col = 0;
114
    print_line = 0;
136
    print_line = 0;
Line 118... Line 140...
118
 
140
 
119
    /*
141
    /*
120
    **  Open the printer
142
    **  Open the printer
121
    **  Ensure that it is opened in text mode
143
    **  Ensure that it is opened in text mode
122
    */
144
    */
-
 
145
    //qDebug() << "Opening File: " << qPrintable(printFileName);
123
    if( ( pfile = fopen( qPrintable(printFileName), "wt" ) ) != NULL )
146
    if( ( pfile = fopen( qPrintable(printFileName), "wt" ) ) != NULL )
124
    {
147
    {
125
        time( &pri_time );                       /* Latch the time */
148
        time( &pri_time );                       /* Latch the time */
126
 
149
 
127
        /*
150
        /*
128
        **  Print out the HTML file header
151
        **  Print out the HTML file header
129
        */
152
        */
130
        if ( html )
153
        if ( htmltype )
131
        {
154
        {
132
            print( "<HTML>\n" );
155
            print( "<HTML>\n" );
133
            print( "<HEAD>\n" );
156
            print( "<HEAD>\n" );
134
            print( "<TITLE>%s - %s</TITLE>\n", config.event_name, title );
157
            print( "<TITLE>%s - %s</TITLE>\n", config.event_name, title );
135
//            print( "<LINK rel=\"stylesheet\" href=\"brmr.css\" type=\"text/css\">\n");
158
//            print( "<LINK rel=\"stylesheet\" href=\"brmr.css\" type=\"text/css\">\n");
136
            print( "</HEAD>\n" );
159
            print( "</HEAD>\n" );
137
            print( "<BODY LANG=\"en-US\">\n" );
160
            print( "<BODY LANG=\"en-US\">\n" );
-
 
161
            print ("<div style=\"width: fit-content;\">");
138
            print( "<PRE>" );
162
            print( "<PRE>" );
139
            print_html = html;
163
            print_html = html;
140
        }
164
        }
141
 
165
 
142
        /*
166
        /*
Line 175... Line 199...
175
bool close_printer(void)
199
bool close_printer(void)
176
{
200
{
177
    if ( print_html )
201
    if ( print_html )
178
    {
202
    {
179
        print_html = text;
203
        print_html = text;
180
        print( "</PRE>\n" );
204
        print( "</div>\n" );
181
        print( "</BODY>\n" );
205
        print( "</BODY>\n" );
-
 
206
        print( "</PRE>\n" );
182
        print( "</HTML>\n" );
207
        print( "</HTML>\n" );
183
    }
208
    }
184
    else
209
    else
185
    {
210
    {
186
        print( "\014" );
211
        print( "\014" );
Line 243... Line 268...
243
 
268
 
244
    va_start( ap, format );
269
    va_start( ap, format );
245
    len = vsprintf( pp, format, ap );
270
    len = vsprintf( pp, format, ap );
246
    va_end( ap );
271
    va_end( ap );
247
 
272
 
-
 
273
 
248
    /*
274
    /*
249
    **  Detect the end of a line and flag for later processing
275
    **  Detect the end of a line and flag for later processing
250
    */
276
    */
251
    if ( len > 0 && pp[len - 1] == '\n' )
277
    if ( len > 0 && pp[len - 1] == '\n' )
252
    {
278
    {
253
        len--;
279
        len--;
254
        eol = TRUE;
280
        eol = TRUE;
255
    }
281
    }
256
 
282
 
-
 
283
    //  Insert pre-set HTML HREF into the string
-
 
284
    if (print_html && *print_href) {
-
 
285
        int iStart = 0;
-
 
286
        int iEnd = len;
-
 
287
        char *debugPtr = pp;
-
 
288
 
-
 
289
        for (int ii = 0; ii < len; ii++) {
-
 
290
            if (pp[ii] != ' ') {
-
 
291
                iStart = ii;
-
 
292
                break;
-
 
293
            }
-
 
294
        }
-
 
295
 
-
 
296
        for (int ii = len-1; ii >= iStart; ii--) {
-
 
297
            if (pp[ii] != ' ') {
-
 
298
                iEnd = ii + 1;
-
 
299
                break;
-
 
300
            }
-
 
301
        }
-
 
302
 debugPtr = print_href;
-
 
303
 
-
 
304
        strncat(print_href, &pp[iStart], iEnd - iStart);
-
 
305
        strcat(print_href, "</A>");
-
 
306
        strncat(print_href, &pp[iEnd], len - iEnd );
-
 
307
        strcpy(&pp[iStart], print_href);
-
 
308
        len = strlen(pp);
-
 
309
 
-
 
310
    }
-
 
311
    *print_href = 0;
-
 
312
 
-
 
313
 
257
    if ( len )
314
    if ( len )
258
    {
315
    {
259
        fwrite( pp, 1, len, pfile );
316
        fwrite( pp, 1, len, pfile );
260
        print_col += len;
317
        print_col += len;
261
    }
318
    }
Line 571... Line 628...
571
        print( "%s", title );
628
        print( "%s", title );
572
 
629
 
573
    s = print_width - print_col - 24 - 4;
630
    s = print_width - print_col - 24 - 4;
574
    print( "%*s", s , "" );
631
    print( "%*s", s , "" );
575
 
632
 
-
 
633
    /*
-
 
634
     ** Debug support - dummy the print time
-
 
635
     */
-
 
636
    QString dbgDate = QProcessEnvironment::systemEnvironment().value("MARA_REPORT_DATE", "") ;
-
 
637
    if (dbgDate.length() > 1) {
-
 
638
         print( "%.24s", qPrintable(dbgDate) );
-
 
639
     } else {
576
    print( "%.24s", ctime( &pri_time ) );
640
        print( "%.24s", ctime( &pri_time ) );
-
 
641
    }
577
    print( "\n" );
642
    print( "\n" );
578
    print( "\n" );
643
    print( "\n" );
579
}
644
}
580
 
645
 
581
 
646
 
Line 700... Line 765...
700
    va_end( ap );
765
    va_end( ap );
701
 
766
 
702
    return ( pp );
767
    return ( pp );
703
}
768
}
704
 
769
 
-
 
770
/*========================================================================
-
 
771
 *
-
 
772
 *  Set HTML HREF to be used in the next print
-
 
773
 *
-
 
774
 *  Purpose:
-
 
775
 *      Create and save a printf like string so that it will be used
-
 
776
 *      to create an HTML HREF
-
 
777
 *
-
 
778
 *      Down-side. Can only have one at a time
-
 
779
 *                 Only valid for the next print
-
 
780
 *                 Strings have a limited length
-
 
781
 *
-
 
782
 *  Parameters:
-
 
783
 *      Standard printf type parameters
-
 
784
 *
-
 
785
 *  Returns:
-
 
786
 *      TRUE : Operation was succesful
-
 
787
 *
-
 
788
 *========================================================================*/
-
 
789
 
-
 
790
char *setHref( const char *format, ... )
-
 
791
{
-
 
792
    va_list     ap;
-
 
793
 
-
 
794
    *print_href = 0;
-
 
795
 
-
 
796
    va_start( ap, format );
-
 
797
    vsprintf( print_href, format, ap );
-
 
798
    va_end( ap );
-
 
799
 
-
 
800
    return ( print_href );
-
 
801
}
-
 
802
 
-
 
803
 
705
/*----------------------------------------------------------------------------
804
/*----------------------------------------------------------------------------
706
** FUNCTION           : to_hex
805
** FUNCTION           : to_hex
707
**
806
**
708
** DESCRIPTION        : Converts an integer value to its hex character
807
** DESCRIPTION        : Converts an integer value to its hex character
709
**
808
**