]> arthur.barton.de Git - netatalk.git/blob - etc/papd/headers.c
dfeea498f48d7e3b4a1abb88dcb3133f12a76d8f
[netatalk.git] / etc / papd / headers.c
1 /*
2  * $Id: headers.c,v 1.7 2001-06-19 18:04:40 rufustfirefly Exp $
3  *
4  * Copyright (c) 1990,1994 Regents of The University of Michigan.
5  * All Rights Reserved.  See COPYRIGHT.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h" 
10 #endif /* HAVE_CONFIG_H */
11
12 #include <sys/syslog.h>
13 #include <sys/param.h>
14 #include <stdio.h>
15
16 #include <netatalk/at.h>
17
18 #include "file.h"
19 #include "comment.h"
20 #include "lp.h"
21
22 int ch_title( struct papfile *, struct papfile * );
23
24 int ch_title( in, out )
25     struct papfile      *in, *out;
26 {
27     char                *start, *stop, *p, *q, c;
28     int                 linelength, crlflength;
29
30     switch ( markline( in, &start, &linelength, &crlflength )) {
31     case 0 :
32         return( 0 );
33
34     case -1 :
35         return( CH_MORE );
36     }
37
38     stop = start + linelength;
39     for ( p = start; p < stop; p++ ) {
40         if ( *p == ':' ) {
41             break;
42         }
43     }
44
45     for ( ; p < stop; p++ ) {
46         if ( *p == '(' ) {
47             break;
48         }
49     }
50
51     for ( q = p; q < stop; q++ ) {
52         if ( *q == ')' ) {
53             break;
54         }
55     }
56
57     if ( q < stop && p < stop ) {
58         p++;
59         c = *q;
60         *q = '\0';
61         lp_job( p );
62         *q = c;
63     }
64
65     lp_write( start, linelength + crlflength );
66     compop();
67     CONSUME( in, linelength + crlflength );
68     return( CH_DONE );
69 }
70
71 /*
72  * "Header" comments.
73  */
74 struct papd_comment     headers[] = {
75     { "%%Title:",                       0,              ch_title,       0 },
76     { 0 },
77 };