/*
+ * $Id: file.c,v 1.12 2009-10-14 02:24:05 didg Exp $
+ *
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
-#include <sys/syslog.h>
+#include <atalk/logger.h>
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include "file.h"
-markline( pf, start, linelength, crlflength )
- char **start;
- int *linelength, *crlflength;
- struct papfile *pf;
+/*
+*/
+int markline( struct papfile *pf, char **start, int *linelength, int *crlflength )
{
char *p;
(p[*crlflength]=='\r' || p[*crlflength]=='\n')) {
(*crlflength)++;
}
+
+ if (!*crlflength) {
+ /* line is way too long, something fishy is going on, give up */
+ LOG(log_error, logtype_papd, "markline: no crlf in comment, give up" );
+ return( -2 );
+ }
- return *linelength;
+ /* success, return 1 */
+ return( 1 );
}
-morespace( pf, data, len )
- struct papfile *pf;
- char *data;
- int len;
+void morespace(struct papfile *pf, const char *data, int len)
{
char *nbuf;
int nsize;
nsize = (( pf->pf_bufsize + len ) / PF_MORESPACE +
(( pf->pf_bufsize + len ) % PF_MORESPACE != 0 )) * PF_MORESPACE;
if ( pf->pf_buf ) {
- if (( nbuf = (char *)realloc( pf->pf_buf, nsize )) == 0 ) {
+ if (( nbuf = (char *)realloc( pf->pf_buf, nsize )) == NULL ) {
exit( 1 );
}
} else {
- if (( nbuf = (char *)malloc( nsize )) == 0 ) {
+ if (( nbuf = (char *)malloc( nsize )) == NULL ) {
exit( 1 );
}
}
}
-append(pf, data, len)
- struct papfile *pf;
- char *data;
- int len;
+void append(struct papfile *pf, const char *data, int len)
{
if ((pf->pf_data + pf->pf_datalen + len) >
(pf->pf_buf + pf->pf_bufsize)) {
morespace(pf, data, len);
} else {
- bcopy(data, pf->pf_data + pf->pf_datalen, len);
+ memcpy(pf->pf_data + pf->pf_datalen, data, len);
pf->pf_datalen += len;
}
}
-spoolerror( out, str )
- struct papfile *out;
- char *str;
+void spoolerror(struct papfile *out, char *str)
{
char *pserr1 = "%%[ Error: ";
char *pserr2 = " ]%%\n";