aboutsummaryrefslogtreecommitdiffstats
path: root/splashy_funcs.c
blob: 17f5a8edd0741e2a62c9e35a897d1105b797286d (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * splashy.c
 *
 * Splashy (userspace splash) splash method support
 *
 * Copyright (C) 2006 Tim Dijkstra <tim@famdijkstra.org>
 *
 * This file is released under the GPLv2.
 *
 */

#include "config.h"

#ifdef CONFIG_SPLASHY
#include <string.h>
#include <stdio.h>
#include <splashy.h>

#include "splash.h"
#include "encrypt.h"
#include "splashy_funcs.h"

int splashy_open(int mode)
{
	int ret;
	if ((ret = splashy_init (NULL,(mode==SPL_RESUME?"resume":"suspend"))) < 0)
	{
		fprintf(stderr,"splashy_init: error %d",ret);
		return -1;
	}
	
	if ((ret = splashy_start_splash ()) < 0) {
		fprintf(stderr,"splashy_start_splash: error %d",ret);
		return -2;
	}
	
	return 0;
}


inline int splashy_finish(void)
{

	splashy_stop_splash();

	return 0;
}

inline int splashy_progress(int p)
{

	splashy_update_progressbar (p);
    
	return 0;
}

void splashy_read_password(char *buf, int vrfy)
{
#if CONFIG_ENCRYPT
        char *vrfy_buf = vrfy ? buf + PASS_SIZE : buf;

        do {
            while (splashy_get_password(buf,PASS_SIZE, 
                        "Passphrase please (must be non-empty): ") <= 0);
            
            if (vrfy)
                while (splashy_get_password(vrfy_buf,PASS_SIZE,
                            "Verify passphrase: ") <= 0);
            
    	} while (vrfy && strncmp(buf, vrfy_buf, PASS_SIZE));
#endif
}

int splashy_dialog(const char *prompt) 
{
	splashy_printline(prompt);
	return splashy_getchar();
}

#endif