File:  [Apple XNU] / GNUtools / cc / rtf2ascii.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:45:38 2018 UTC (8 years, 2 months ago) by root
Branches: MAIN, Apple
CVS tags: HEAD, GNUtools33
GNU tools for NeXTSTEP 3.3


// rtf2ascii.h

#import <string.h>
#import <streams/streams.h>

#define RTF_HEADER     "{\\rtf0\\ansi"
#define RTF_HEADER_LEN 11


// A predicate to quickly check a region of possibly-rich memory (starting
// at rtfText and going for length len) to see if it is convertible by the
// following routines.

static inline int isRTFText(const char * rtfText, int len) 
{
   return (rtfText 
	   && (len > RTF_HEADER_LEN) 
	   && !strncmp(rtfText, RTF_HEADER, RTF_HEADER_LEN));
}


// A memory-buffer-based conversion that reads one buffer pointed to by 
// rtfTextPtr and converts, for length rtfTextLen, RTF to ASCII.  A pointer
// to a newly allocated buffer of memory is returned (caller owns this 
// memory).  Additionally, asciiTextLen is set to the length of the
// null-terminated ascii character buffer.

extern const char * rtfToAscii( const char *rtfTextPtr, 
				int rtfTextLen, 
				int * asciiTextLen );


// A streams-based converter which takes an NXStream and either returns back 
// a new memory stream that has been converted to straight ASCII (the caller
// should free this with NXCloseMemory()).

extern NXStream * rtfToAsciiStream(NXStream * possiblyRichStream);


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.