mirror of
https://github.com/depp/syncfiles.git
synced 2024-11-22 03:30:57 +00:00
b1bcae531b
Previously, various error handling functions were defined, but not all of them were even used. The new error handling functions handle the most common cases: - Assertions. These can be handled with `ASSERT()`, which gives the error location for debugging. - Errors we don't know how to handle, like GetNewWindow returning NULL. These can be handled with `EXIT_INTERNAL()`, which gives the error location for debugging. - Out of memory conditions. These can be handled with `ShowMemError()`. - System errors in response to user operations. These can be handled with `ShowError()`.
47 lines
1.7 KiB
C
47 lines
1.7 KiB
C
// Copyright 2022-2023 Dietrich Epp.
|
||
// This file is part of SyncFiles. SyncFiles is licensed under the terms of the
|
||
// Mozilla Public License, version 2.0. See LICENSE.txt for details.
|
||
#ifndef MACOS_PSTRBUILDER_H
|
||
#define MACOS_PSTRBUILDER_H
|
||
|
||
#include "lib/defs.h"
|
||
|
||
/*
|
||
Pascal String Builder
|
||
=====================
|
||
|
||
These functions operate on the Pascal-style Str255 string type, which consists
|
||
of a length byte, followed by 0-255 characters of text. Pascal string literals
|
||
can be written by putting \p at the beginning of the literal (this is a C
|
||
extension), and have an unsigned char type. C-style strings (null-terminated,
|
||
char type) are not used.
|
||
|
||
The functions here construct strings for human consumption only, not
|
||
machine-readable strings. Strings which overflow the destination buffer are
|
||
silently truncated, with an ellipsis added to the end of the buffer to show that
|
||
it’s been truncated.
|
||
*/
|
||
|
||
// A PStrBuilder is a buffer for writing a string. This should be initialized by
|
||
// setting data[0] to 0 and truncated to false.
|
||
struct PStrBuilder {
|
||
unsigned char data[256];
|
||
Boolean truncated;
|
||
};
|
||
|
||
// PStrInit initializes a string buffer.
|
||
void PStrInit(struct PStrBuilder *buf);
|
||
|
||
// PStrAppendChar appends a single character to the buffer.
|
||
void PStrAppendChar(struct PStrBuilder *buf, unsigned char c);
|
||
|
||
// PStrAppend appends a string to the buffer.
|
||
void PStrAppend(struct PStrBuilder *buf, const unsigned char *src);
|
||
|
||
// PStrAppendSubstitute appends a Pascal string to another string, expanding any
|
||
// ^N substitutions, where N is a positive digit, 1-9.
|
||
void PStrAppendSubstitute(struct PStrBuilder *buf, const unsigned char *src,
|
||
int paramcount, const unsigned char *const *params);
|
||
|
||
#endif
|