2 * $Id: comment.c,v 1.10 2009-10-13 22:55:37 didg Exp $
4 * Copyright (c) 1990,1994 Regents of The University of Michigan.
5 * All Rights Reserved. See COPYRIGHT.
10 #endif /* HAVE_CONFIG_H */
12 #include <atalk/logger.h>
13 #include <sys/param.h>
21 struct comstate *comstate;
23 char *comcont = "%%+";
30 comstate = cs->cs_prev;
34 void compush(struct papd_comment *comment)
38 if (( cs = (struct comstate *)malloc( sizeof( struct comstate ))) ==
40 LOG(log_error, logtype_papd, "malloc: %s", strerror(errno) );
44 cs->cs_comment = comment;
45 cs->cs_prev = comstate;
50 int comswitch(struct papd_comment *comments, int (*handler)())
52 struct papd_comment *c, *comment = NULL;
54 for ( c = comments; c->c_begin; c++ ) {
55 if ( c->c_handler == handler ) {
59 if ( comment == NULL || comment->c_handler != handler ) {
60 LOG(log_error, logtype_papd, "comswitch: can't find handler!" );
68 int comcmp( char *start, char *stop, char *str,int how)
75 if ( (cc == len) && (strncmp( str, start, cc ) == 0) ) {
79 if ( (cc <= len) && (strncmp( str, start, cc ) == 0) ) {
87 struct papd_comment *commatch( char *start, char *stop, struct papd_comment comments[])
89 struct papd_comment *comment;
91 for ( comment = comments; comment->c_begin; comment++ ) {
92 if ( comcmp( start, stop, comment->c_begin, comment->c_flags ) == 0 ) {
96 if ( comment->c_begin ) {
103 char *comtoken( char *start, char *stop, char *pos, char *delim)
105 if ( pos < start || pos > stop ) {
109 for ( ; pos < stop; pos++ ) {
110 if ( index( delim, *pos )) {
114 if ( ++pos < stop ) {