installer - Use bit 'flags' for additional options
[dragonfly.git] / usr.sbin / installer / 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  * Function argument flags
53  */
54 #define I_BOOTED_LIVECD         0x1
55 #define I_UPGRADE_TOOGLE        0x2
56
57 /*
58  * Installer function arguments.
59  */
60 struct i_fn_args {
61         struct dfui_connection *c;      /* DFUI connection to f/e */
62         struct storage *s;              /* description of system storage */
63         const char *os_root;            /* where livecd files live */
64         const char *cfg_root;           /* where target conf files live */
65         const char *tmp;                /* directory for temporary files */
66         const char *name;               /* overrides title of form */
67         const char *short_desc;         /* overrides short desc */
68         const char *long_desc;          /* overrides help text */
69         const char *cancel_desc;        /* overrides cancel button */
70         int result;                     /* result of function */
71         FILE *log;                      /* file to log to */
72         struct aura_dict *temp_files;   /* names of files to delete on exit */
73         struct config_vars *cmd_names;  /* names (and paths) of commands to use */
74         int flags;                      /* Option flags */
75 };
76
77 /*** PROTOTYPES ***/
78
79 /* Installer Context */
80
81 struct i_fn_args *i_fn_args_new(const char *, const char *, int, const char *);
82 void             i_fn_args_free(struct i_fn_args *);
83
84 void             i_log(struct i_fn_args *, const char *, ...)
85                      __printflike(2, 3);
86
87 /* General Utilities */
88
89 void             abort_backend(void);
90 int              assert_clean(struct dfui_connection *, const char *, const char *, const char *);
91 int              hex_to_int(const char *, int *);
92 int              first_non_space_char_is(const char *, char);
93 const char      *capacity_to_string(long);
94 int              string_to_capacity(const char *, long *);
95 unsigned long    next_power_of_two(unsigned long);
96 char            *filename_noext(const char *);
97
98 /* Temp Files */
99
100 int              temp_file_add(struct i_fn_args *, const char *);
101 int              temp_files_clean(struct i_fn_args *);
102
103 /* Command Names */
104
105 const char      *cmd_name(const struct i_fn_args *, const char *);
106
107 #endif /* !__FUNCTIONS_H_ */