/* ** Folding is either of CF LWS, LF LWS, CRLF LWS */ PRIVATE int CSUserList_put_block (HTStream * me, const char * b, int l) { while (l > 0) { if (me->EOLstate == EOL_FCR) { if (*b == LF) /* CRLF */ me->EOLstate = EOL_FLF; else if (isspace((int) *b)) /* Folding: CR SP */ me->EOLstate = EOL_DOT; else { /* New line */ CSUserList_addLine(me); me->EOLstate = EOL_BEGIN; HTChunkClear(me->buffer); continue; } } else if (me->EOLstate == EOL_FLF) { if (isspace((int) *b)) /* Folding: LF SP or CR LF SP */ me->EOLstate = EOL_DOT; else { /* New line */ CSUserList_addLine(me); me->EOLstate = EOL_BEGIN; HTChunkClear(me->buffer); continue; } } else if (me->EOLstate == EOL_DOT) { if (isspace((int) *b)) { me->EOLstate = EOL_BEGIN; HTChunkPutc(me->buffer, ' '); } else { CSUserList_addLine(me); me->EOLstate = EOL_BEGIN; HTChunkClear(me->buffer); continue; } } else if (*b == CR) { me->EOLstate = EOL_FCR; } else if (*b == LF) { me->EOLstate = EOL_FLF; /* Line found */ } else HTChunkPutc(me->buffer, *b); l--; b++; } if (HTChunk_size(me->buffer)) CSUserList_addLine(me); return HT_OK; }
int BuildCommand( HTChunk *cmd, char *controlstring, char *TmpFileName, char *params ) { int result = 0; size_t TmpFileLen = strlen( TmpFileName ); char *from; char *next; char *name, *value; int prefixed = 0; int escaped = 0; from = controlstring; for ( ; from[0]; from++ ) { if ( escaped ) { escaped = 0; HTChunkPutc( cmd, from[0] ); } else if ( from[0] == '\\' ) escaped = 1; else if ( prefixed ) { prefixed = 0; switch ( from[0] ) { case '%': HTChunkPutc( cmd, from[0] ); break; case 'F': case 'n': if ( WWW_TraceFlag && ( WWW_TraceMask & 8 ) ) { fprintf( TraceFP( ), "BuildCommand: Bad mailcap \"test\" clause: %s\n", controlstring ); } break; case 't': value = LYGetContentType( 0, params ); if ( value ) { HTChunkPuts( cmd, value ); if ( value ) { free( value ); value = 0; } } break; case 's': if ( TmpFileLen && TmpFileName ) HTChunkPuts( cmd, TmpFileName ); break; case '{': next = strchr( from, '}' ); if ( next ) { if ( params ) { from++; name = 0; HTSprintf0( &name, "%.*s", next - from, from ); value = LYGetContentType( name, params ); if ( value ) { HTChunkPuts( cmd, value ); if ( value ) { free( value ); value = 0; } } else { if ( strcmp( name, "charset" ) == 0 ) HTChunkPuts( cmd, "ISO-8859-1" ); else if ( WWW_TraceFlag && ( WWW_TraceMask & 8 ) ) { fprintf( TraceFP( ), "BuildCommand no value for %s\n", name ); } } if ( name ) { free( name ); name = 0; } } else result = -1; from = next; } else default: if ( WWW_TraceFlag && ( WWW_TraceMask & 8 ) ) { fprintf( TraceFP( ), "BuildCommand: Ignoring unrecognized format code in mailcap file '%%%c'.\n", from[0] ); } break; } } else if ( from[0] == '%' ) prefixed = 1; else HTChunkPutc( cmd, from[0] ); // from++; } HTChunkTerminate( cmd ); return result; }