File: profile.c

package info (click to toggle)
reiser4progs 1.0.7-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,352 kB
  • ctags: 3,699
  • sloc: ansic: 33,483; sh: 8,489; makefile: 1,001
file content (60 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download | duplicates (8)
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
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   pprofile.c -- methods for working with reiser4 profile. */

#include <stdio.h>
#include <reiser4/libreiser4.h>

errno_t misc_profile_override(char *override) {
	while (1) {
		char *entry, *c;
		char name[256];
		char value[256];

		if (!(entry = aal_strsep(&override, ",")))
			break;
		
		if (!aal_strlen(entry))
			continue;

		if (!(c = aal_strchr(entry, '='))) {
			aal_error("Invalid profile override "
				  "entry detected %s.", entry);
			return -EINVAL;
		}

		aal_memset(name, 0, sizeof(name));
		aal_memset(value, 0, sizeof(value));
		
		aal_strncpy(name, entry, c - entry);

		if (c + 1 == '\0') {
			aal_error("Invalid profile override "
				  "entry detected %s.", entry);
			return -EINVAL;
		}
		
		aal_strncpy(value, c + 1, entry + aal_strlen(entry) - c);
		
		if (reiser4_profile_override(name, value))
			return -EINVAL;
	}

	return 0;
}

/* Prints default plugin profiles. */
void misc_profile_print(void) {
	aal_stream_t stream;

	aal_stream_init(&stream, stdout, &file_stream);
	
	aal_stream_format(&stream, "Default profile:\n");

	reiser4_profile_print(&stream);
	
	aal_stream_format(&stream, "\n");

	aal_stream_fini(&stream);
}