File: util.h

package info (click to toggle)
librnd 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,812 kB
  • sloc: ansic: 126,990; sh: 2,602; makefile: 2,145; awk: 7
file content (41 lines) | stat: -rw-r--r-- 1,961 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
/*
    puplug - portable micro plugin framework
    Copyright (C) 2020 Tibor 'Igor2' Palinkas

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 31 Milk Street, # 960789 Boston, MA 02196 USA.
*/

#ifndef PUPLUG_UTIL_H
#define PUPLUG_UTIL_H

typedef struct pup_list_parse_pup_s pup_list_parse_pup_t;

struct pup_list_parse_pup_s {

	/* user functions to do the actual processing; any of these may be NULL */
	int (*open)(pup_list_parse_pup_t *ctx, const char *path, const char *basename);  /* called before opening a .pup file (path is full path, basename is the file name only). Return non-zero to skip file */
	void (*close)(pup_list_parse_pup_t *ctx, const char *path); /* called after closing a .pup file (path) */
	int (*line_raw)(pup_list_parse_pup_t *ctx, const char *path, char *line); /* called for each line loaded from the file, leading and trailing whitespace removed, before parsing the line */
	int (*line_split)(pup_list_parse_pup_t *ctx, const char *path, char *cmd, char *args); /* called for each line loaded from the file; first field is passed in cmd, rest in args */

	/* fields used by the caller */
	void *user_data;
};

/* List all .pup files in all directories listed in paths, parse them and
   call ctx callbacks */
void pup_list_parse_pups(pup_list_parse_pup_t *ctx, const char **paths);

#endif