File: logtofile_guc.c

package info (click to toggle)
pgauditlogtofile 1.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 288 kB
  • sloc: ansic: 1,211; makefile: 21; sql: 11; sh: 7
file content (64 lines) | stat: -rw-r--r-- 1,483 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*-------------------------------------------------------------------------
 *
 * logtofile_guc.c
 *      GUC variables for logtofile
 *
 * Copyright (c) 2020-2025, Francisco Miguel Biete Banon
 *
 * This code is released under the PostgreSQL licence, as given at
 *  http://www.postgresql.org/about/licence/
 *-------------------------------------------------------------------------
 */
#include "logtofile_guc.h"

#include <datatype/timestamp.h>
#include <port.h>

#include "logtofile_shmem.h"
#include "logtofile_vars.h"

/**
 * @brief GUC Callback pgaudit.log_directory check path
 * @param newval: new value
 * @param extra: extra
 * @param source: source
 * @return bool: true if path is valid
 */
bool guc_check_directory(char **newval, void **extra, GucSource source)
{
  /*
   * Since canonicalize_path never enlarges the string, we can just modify
   * newval in-place.
   */
  canonicalize_path(*newval);
  return true;
}

/**
 * @brief GUC Callback pgaudit.log_format check value (csv or json)
 * @param newval: new value
 * @param extra: extra
 * @param source: source
 * @return bool: true if value is csv or json
 */
bool guc_check_log_format(char **newval, void **extra, GucSource source)
{
  char *rawstring;

  rawstring = pstrdup(*newval);

  if (pg_strcasecmp(rawstring, "csv") == 0)
  {
    pfree(rawstring);
    return true;
  }

  if (pg_strcasecmp(rawstring, "json") == 0)
  {
    pfree(rawstring);
    return true;
  }

  pfree(rawstring);
  return false;
}