~ubuntu-branches/debian/lenny/netatalk/lenny

« back to all changes in this revision

Viewing changes to etc/papd/ppd.c

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2005-10-07 13:46:11 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20051007134611-r07qa2g67xwkp2if
Tags: 2.0.3-1ubuntu1
* debian/netatalk.init
  - run cnid_metad if CNID_METAD_RUN=yes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: ppd.c,v 1.9 2002/09/29 23:29:14 sibaz Exp $
 
2
 * $Id: ppd.c,v 1.9.8.1.2.2 2005/02/06 10:16:02 didg Exp $
3
3
 *
4
4
 * Copyright (c) 1995 Regents of The University of Michigan.
5
5
 * All Rights Reserved.  See COPYRIGHT.
27
27
struct ppd_feature      ppd_features[] = {
28
28
    { "*LanguageLevel", 0 },
29
29
    { "*PSVersion",     0 },
 
30
#ifdef HAVE_CUPS
 
31
    { "*FreeVM",        "33554432" },
 
32
#else
30
33
    { "*FreeVM",        0 },
 
34
#endif
31
35
    { "*Product",       0 },
32
36
    { "*PCFileName",    0 },
33
37
    { "*ModelName",     0 },
59
63
}
60
64
#endif /* SHOWPPD */
61
65
 
 
66
 
 
67
/* quick and ugly hack to be able to read
 
68
   ppd files with Mac line ending */
 
69
static char* my_fgets(buf, bufsize, stream) 
 
70
    char   *buf;
 
71
    size_t bufsize;
 
72
    FILE   *stream;
 
73
{
 
74
    int p;           /* uninitialized, OK 310105 */
 
75
    size_t count = 0;
 
76
 
 
77
    while (count < bufsize && EOF != (p=fgetc(stream))) {
 
78
        buf[count] = p;
 
79
        count++;
 
80
        if ( p == '\r' || p == '\n')
 
81
           break;
 
82
    }
 
83
 
 
84
    if (p == EOF && count == 0)
 
85
        return NULL;
 
86
 
 
87
    /* translate line endings */
 
88
    if ( buf[count - 1] == '\r')
 
89
        buf[count - 1] = '\n';
 
90
 
 
91
    buf[count] = 0;
 
92
    return buf;
 
93
}
 
94
 
62
95
struct ppdent *getppdent( stream )
63
96
    FILE        *stream;
64
97
{
69
102
    ppdent.pe_main = ppdent.pe_option = ppdent.pe_translation =
70
103
            ppdent.pe_value = NULL;
71
104
 
72
 
    while (( p = fgets( buf, sizeof( buf ), stream )) != NULL ) {
 
105
    while (( p = my_fgets( buf, sizeof( buf ), stream )) != NULL ) {
73
106
        if ( *p != '*' ) {      /* main key word */
74
107
            continue;
75
108
        }
76
 
        if ( p[ strlen( p ) - 1 ] != '\n' ) {
 
109
        if ( p[ strlen( p ) - 1 ] != '\n' && p[ strlen( p ) - 1 ] != '\r') {
77
110
            LOG(log_error, logtype_papd, "getppdent: line too long" );
78
111
            continue;
79
112
        }
204
237
                break;
205
238
            }
206
239
        }
207
 
        if ( pfe->pd_name && (pfe->pd_value == NULL) ) {
 
240
        if ( pfe->pd_name ) { /*&& (pfe->pd_value == NULL) ) { */
208
241
            if (( pfe->pd_value =
209
242
                    (char *)malloc( strlen( pe->pe_value ) + 1 )) == NULL ) {
210
243
                LOG(log_error, logtype_papd, "malloc: %m" );