Some installer cleanup.
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / lib / libinstaller / functions.h
1 /*
2  * Copyright (c)2004 The DragonFly Project.  All rights reserved.
3  * 
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 
8  *   Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * 
11  *   Redistributions in binary form must reproduce the above copyright
12  *   notice, this list of conditions and the following disclaimer in
13  *   the documentation and/or other materials provided with the
14  *   distribution.
15  * 
16  *   Neither the name of the DragonFly Project nor the names of its
17  *   contributors may be used to endorse or promote products derived
18  *   from this software without specific prior written permission. 
19  * 
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31  * OF THE POSSIBILITY OF SUCH DAMAGE. 
32  */
33
34 /*
35  * functions.h
36  * $Id: functions.h,v 1.22 2005/02/06 21:05:18 cpressey Exp $
37  */
38
39 #ifndef __FUNCTIONS_H_
40 #define __FUNCTIONS_H_
41
42 #include <stdio.h>
43
44 #include "libaura/dict.h"
45 #include "libdfui/dfui.h"
46
47 #include "confed.h"
48
49 struct storage;
50
51 /*
52  * Installer function arguments.
53  */
54 struct i_fn_args {
55         struct dfui_connection *c;      /* DFUI connection to f/e */
56         struct storage *s;              /* description of system storage */
57         const char *os_root;            /* where livecd files live */
58         const char *cfg_root;           /* where target conf files live */
59         const char *tmp;                /* directory for temporary files */
60         const char *name;               /* overrides title of form */
61         const char *short_desc;         /* overrides short desc */
62         const char *long_desc;          /* overrides help text */
63         const char *cancel_desc;        /* overrides cancel button */
64         int result;                     /* result of function */
65         FILE *log;                      /* file to log to */
66         struct aura_dict *temp_files;   /* names of files to delete on exit */
67         struct config_vars *cmd_names;  /* names (and paths) of commands to use */
68         int booted_from_livecd;         /* system is running from livecd */
69         int upgrade_menu_toggle;        /* toggle the experimental upgrade option */
70 };
71
72 /*** PROTOTYPES ***/
73
74 /* Installer Context */
75
76 struct i_fn_args *i_fn_args_new(const char *, const char *, int, const char *);
77 void             i_fn_args_free(struct i_fn_args *);
78
79 void             i_log(struct i_fn_args *, const char *, ...);
80
81 /* General Utilities */
82
83 void             abort_backend(void);
84 int              assert_clean(struct dfui_connection *, const char *, const char *, const char *);
85 int              hex_to_int(const char *, int *);
86 int              first_non_space_char_is(const char *, char);
87 const char      *capacity_to_string(long);
88 int              string_to_capacity(const char *, long *);
89 unsigned long    next_power_of_two(unsigned long);
90 char            *filename_noext(const char *);
91
92 /* Temp Files */
93
94 int              temp_file_add(struct i_fn_args *, const char *);
95 int              temp_files_clean(struct i_fn_args *);
96
97 /* Command Names */
98
99 const char      *cmd_name(const struct i_fn_args *, const char *);
100
101 #endif /* !__FUNCTIONS_H_ */