RTF compliance diagnostics

RTF compliance diagnostics — RTF recovery diagnostics and reporting limits

Functions

Types and Values

Description

A logger receives an issue valid for the duration of its callback. Description and remarks strings are static. A zero per-violation limit means unlimited reporting. Otherwise one truncation marker is emitted at the first suppressed issue; the reporting budget restarts for each conversion.

Functions

GMimeRtfComplianceLogger ()

void
(*GMimeRtfComplianceLogger) (const GMimeRtfComplianceIssue *issue,
                             gpointer user_data);

Receives an RTF compliance diagnostic.

Parameters

issue

a diagnostic valid only during this callback.

[transfer none]

user_data

callback data.

[closure][nullable]

g_mime_rtf_compliance_options_new ()

GMimeRtfComplianceOptions *
g_mime_rtf_compliance_options_new (void);

Returns

new diagnostic options.

[transfer full]


g_mime_rtf_compliance_options_ref ()

GMimeRtfComplianceOptions *
g_mime_rtf_compliance_options_ref (GMimeRtfComplianceOptions *options);

Parameters

options

diagnostic options

 

Returns

options with an additional reference.

[transfer full]


g_mime_rtf_compliance_options_unref ()

void
g_mime_rtf_compliance_options_unref (GMimeRtfComplianceOptions *options);

Releases one reference to options .

Parameters

options

diagnostic options to release.

[transfer full][nullable]

g_mime_rtf_compliance_options_clone ()

GMimeRtfComplianceOptions *
g_mime_rtf_compliance_options_clone (const GMimeRtfComplianceOptions *options);

Parameters

options

diagnostic options to copy

 

Returns

an independent copy of options .

[transfer full]


g_mime_rtf_compliance_options_get_max_issues_per_violation ()

guint
g_mime_rtf_compliance_options_get_max_issues_per_violation
                               (const GMimeRtfComplianceOptions *options);

Gets the reporting limit for each violation. The default is zero, meaning unlimited reporting.

Parameters

options

diagnostic options

 

Returns

the maximum number of reports per violation, or zero for no limit


g_mime_rtf_compliance_options_set_max_issues_per_violation ()

void
g_mime_rtf_compliance_options_set_max_issues_per_violation
                               (GMimeRtfComplianceOptions *options,
                                guint maximum);

Sets the reporting limit. A tokenizer emits one GMIME_RTF_COMPLIANCE_VIOLATION_TOO_MANY_COMPLIANCE_ISSUES diagnostic when reports are first suppressed. The limit is sampled when a conversion begins.

Parameters

options

diagnostic options

 

maximum

the maximum number of reports per violation, or zero for no limit

 

g_mime_rtf_compliance_violation_get_description ()

const char *
g_mime_rtf_compliance_violation_get_description
                               (GMimeRtfComplianceViolation violation);

Parameters

violation

an RTF compliance violation

 

Returns

the description for violation


g_mime_rtf_compliance_violation_get_remarks ()

const char *
g_mime_rtf_compliance_violation_get_remarks
                               (GMimeRtfComplianceViolation violation);

Parameters

violation

an RTF compliance violation

 

Returns

the remarks for violation


g_mime_rtf_compliance_violation_get_severity ()

GMimeComplianceSeverity
g_mime_rtf_compliance_violation_get_severity
                               (GMimeRtfComplianceViolation violation);

Parameters

violation

an RTF compliance violation

 

Returns

the severity for violation


g_mime_rtf_compliance_violation_get_categories ()

GMimeComplianceCategories
g_mime_rtf_compliance_violation_get_categories
                               (GMimeRtfComplianceViolation violation);

Parameters

violation

an RTF compliance violation

 

Returns

the categories for violation

Types and Values

GMimeRtfComplianceOptions

typedef struct _GMimeRtfComplianceOptions GMimeRtfComplianceOptions;

Reference-counted options controlling RTF diagnostic reporting limits.


enum GMimeRtfComplianceViolation

RTF reader and interpreter recovery diagnostics.

Members

GMIME_RTF_COMPLIANCE_VIOLATION_NONE

No violation.

 

GMIME_RTF_COMPLIANCE_VIOLATION_MISSING_RTF_HEADER

The document did not begin with the {\rtf header.

 

GMIME_RTF_COMPLIANCE_VIOLATION_UNBALANCED_GROUP_END

A group end did not match any group start.

 

GMIME_RTF_COMPLIANCE_VIOLATION_CONTENT_AFTER_DOCUMENT

Content followed the end of the outermost group.

 

GMIME_RTF_COMPLIANCE_VIOLATION_TRUNCATED_STREAM

The document ended before all of its groups were closed.

 

GMIME_RTF_COMPLIANCE_VIOLATION_KEYWORD_TOO_LONG

A control word was longer than 32 letters.

 

GMIME_RTF_COMPLIANCE_VIOLATION_INVALID_PARAMETER

A control word had a malformed or out-of-range numeric parameter.

 

GMIME_RTF_COMPLIANCE_VIOLATION_INVALID_HEX_ESCAPE

A \' escape was not followed by two hexadecimal digits.

 

GMIME_RTF_COMPLIANCE_VIOLATION_UNESCAPED_EIGHT_BIT_CHARACTER

The document contained a non-ASCII character that was not escaped.

 

GMIME_RTF_COMPLIANCE_VIOLATION_UNPAIRED_SURROGATE

A \uN control word specified one half of a UTF-16 surrogate pair without the other.

 

GMIME_RTF_COMPLIANCE_VIOLATION_UNSUPPORTED_CODE_PAGE

A code page specified by the document could not be resolved.

 

GMIME_RTF_COMPLIANCE_VIOLATION_UNDEFINED_FONT

A \fN control word referred to a font that was not defined in the font table.

 

GMIME_RTF_COMPLIANCE_VIOLATION_UNDEFINED_COLOR

A \cfN or \cbN control word referred to a color that was not defined in the color table.

 

GMIME_RTF_COMPLIANCE_VIOLATION_INVALID_FONT_SIZE

A \fsN control word specified a font size that was not positive or was too large.

 

GMIME_RTF_COMPLIANCE_VIOLATION_FIELD_INSTRUCTION_TOO_LONG

A field instruction was longer than the maximum length that is examined.

 

GMIME_RTF_COMPLIANCE_VIOLATION_FONT_TABLE_LIMIT_EXCEEDED

The font table contained more entries than the configured limit.

 

GMIME_RTF_COMPLIANCE_VIOLATION_COLOR_TABLE_LIMIT_EXCEEDED

The color table contained more entries than the configured limit.

 

GMIME_RTF_COMPLIANCE_VIOLATION_GROUP_DEPTH_LIMIT_EXCEEDED

Groups that change the formatting state were nested more deeply than the configured limit.

 

GMIME_RTF_COMPLIANCE_VIOLATION_TOO_MANY_COMPLIANCE_ISSUES

Too many compliance issues were detected and the remainder were suppressed.

 

GMimeRtfComplianceIssue

typedef struct {
	GMimeRtfComplianceViolation violation;
	GMimeComplianceSeverity severity;
	GMimeComplianceCategories categories;
	gint64 offset;
	int line_number, line_position, depth;
	const char *description;
} GMimeRtfComplianceIssue;

A diagnostic borrowed by a compliance callback. The structure is only valid for the duration of that callback.

Members

GMimeRtfComplianceViolation violation;

the reported violation

 

GMimeComplianceSeverity severity;

diagnostic severity

 

GMimeComplianceCategories categories;

diagnostic categories

 

gint64 offset;

zero-based input character offset (byte offset for default Latin-1 input)

 

int line_number;

one-based line number

 

int line_position;

one-based Unicode scalar column

 

int depth;

group depth at the diagnostic

 

const char *description;

a borrowed description.

[transfer none]