fix(review): address PR #94 reviewer comments
Blockers: - SPDX/CProof copyright headers (7 files) - stanza-id non-uniqueness: warn-only, don't skip (matches SQLite) - fopen → open(O_EXCL|O_NOFOLLOW, 0600) + fdopen in export Medium: - log_info → log_warning for SQLite fallback - remove prefs_save() auto-save from backend switch - vtable null → log_warning in 4 dispatch functions - log_debug → log_warning + null error handling in export - rename failure → cons_show_error to user - remove unused total_skipped variable - LMC respects PREF_CORRECTION_ALLOW Low nits: - man page .SS fix + jabber.space URL - profrc.example simplified - show flatfile path on /logging flatfile - EXPORT_PROGRESS_INTERVAL constant (magic 500) - FF_META_PREFIX_ID/AID constants + FF_INDEX_STEP comment - buffer overflow guard on close[1]/close[2] - for-loop → memchr for JID resource scan - BOM check extracted to ff_skip_bom() (DRY) - index building extracted to _ff_maybe_index_line() - O_APPEND+O_EXCL comment rewritten - Makefile.am spaces → tabs
This commit is contained in:
@@ -1,24 +1,12 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
//
|
||||
// This file is part of CProof.
|
||||
// See LICENSE for the full GPLv3 text and the special OpenSSL linking exception.
|
||||
|
||||
/*
|
||||
* database_flatfile.h
|
||||
* vim: expandtab:ts=4:sts=4:sw=4
|
||||
*
|
||||
* Copyright (C) 2026 Profanity Contributors
|
||||
*
|
||||
* This file is part of Profanity.
|
||||
*
|
||||
* Profanity is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Profanity is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Internal header shared between database_flatfile*.c modules.
|
||||
* Not part of the public API — do not include from outside the flatfile backend.
|
||||
*/
|
||||
@@ -69,8 +57,16 @@ typedef struct
|
||||
|
||||
// --- Sparse index for single-file lookup ---
|
||||
|
||||
// Sample every N-th log line for the sparse index.
|
||||
// 500 lines ≈ one index entry per ~50 KB of log data, so a 100K-message
|
||||
// contact requires only ~200 entries (~3 KB) for O(log n) time-range lookup.
|
||||
#define FF_INDEX_STEP 500
|
||||
|
||||
// --- Metadata field prefixes (used in _ff_cache_line_ids and ff_parse_line) ---
|
||||
|
||||
#define FF_META_PREFIX_ID "id:"
|
||||
#define FF_META_PREFIX_AID "aid:"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
off_t byte_offset;
|
||||
@@ -127,6 +123,9 @@ char* ff_unescape_meta_value(const char* val);
|
||||
|
||||
// --- I/O ---
|
||||
|
||||
// Skip UTF-8 BOM if present; returns 3 if skipped, 0 otherwise.
|
||||
int ff_skip_bom(FILE* fp);
|
||||
|
||||
char* ff_readline(FILE* fp, gboolean* truncated);
|
||||
void ff_write_line(FILE* fp, const char* timestamp, const char* type, const char* enc,
|
||||
const char* stanza_id, const char* archive_id, const char* replace_id,
|
||||
|
||||
Reference in New Issue
Block a user