Coverage Report

Created: 2026-10-17 07:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/irssi/subprojects/glib-2.74.7/gio/giomodule-priv.c
Line
Count
Source
1
/* GIO - GLib Input, Output and Streaming Library
2
 *
3
 * Copyright (C) 2017 Collabora Inc.
4
 *
5
 * SPDX-License-Identifier: LGPL-2.1-or-later
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General
18
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * Author: Xavier Claessens <xavier.claessens@collabora.com>
21
 */
22
23
#include "config.h"
24
#include "giomodule.h"
25
#include "giomodule-priv.h"
26
27
#include <string.h>
28
29
/**
30
 * _g_io_module_extract_name:
31
 * @filename: filename of a GIOModule
32
 *
33
 * Extract the plugin name from its filename. It removes optional "lib" or
34
 * "libgio" prefix, and removes everything after the first dot. For example:
35
 * "libgiognutls.so" -> "gnutls".
36
 *
37
 * Returns: (transfer full): the module's name
38
 */
39
gchar *
40
_g_io_module_extract_name (const char *filename)
41
0
{
42
0
  gchar *bname, *name;
43
0
  const gchar *dot;
44
0
  gsize prefix_len, len;
45
0
  gsize i;
46
47
0
  bname = g_path_get_basename (filename);
48
0
  for (i = 0; bname[i]; ++i)
49
0
    {
50
0
      if (bname[i] == '-')
51
0
        bname[i] = '_';
52
0
    }
53
54
0
  if (g_str_has_prefix (bname, "libgio"))
55
0
    prefix_len = 6;
56
  /* DLLs built with MSVC generally do not have the 'lib' prefix */
57
0
  else if (g_str_has_prefix (bname, "lib") || g_str_has_prefix (bname, "gio"))
58
0
    prefix_len = 3;
59
0
  else
60
0
    prefix_len = 0; /* use whole name (minus suffix) as plugin name */
61
62
0
  dot = strchr (bname, '.');
63
0
  if (dot != NULL)
64
0
    len = dot - bname - prefix_len;
65
0
  else
66
0
    len = strlen (bname + prefix_len);
67
68
0
  name = g_strndup (bname + prefix_len, len);
69
0
  g_free (bname);
70
71
0
  return name;
72
0
}