aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifup-bnep
blob: 5aff27771021dec8be05d1ec57b3214faa28ac41 (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
#! /bin/bash

. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. ./network-functions

[ -f ../network ] && . ../network

CONFIG=${1}

source_config

# On hotplug events, just bring the virtual device up as if it's normal Ethernet
if [ -n "$IN_HOTPLUG" ]; then
	exec sh -x /etc/sysconfig/network-scripts/ifup-eth ${CONFIG} $2 
fi

start_panu()
{
	PANDARGS="--persist --pidfile=/var/run/pand-${DEVICE}.pid --ethernet=${DEVICE} --autozap"
	[ "${CACHE}" != "no" -a "${CACHE}" != "NO" ] && PANDARGS="${PANDARGS} --cache"
	if [ "${REMOTEBDADDR}" = "" ]; then
		PANDARGS="${PANDARGS} --search"
	else
		PANDARGS="${PANDARGS} --connect ${REMOTEBDADDR}"
	fi
	/usr/bin/pand ${PANDARGS}
}

start_nap()
{
	:
}

start_gn()
{
	:
}

case "$ROLE" in
	PANU)
		start_panu
		;;
	NAP)
		start_nap
		;;
	GN)
		start_gn
		;;
	*)
		echo Unknown BNEP mode :$ROLE
		;;
esac

#n39'>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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
/*
 * Guillaume Cottenceau (gc@mandrakesoft.com)
 *
 * Copyright 2000 Mandrakesoft
 *
 * This software may be freely redistributed under the terms of the GNU
 * public license.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*
 * mar - The Mandrake Archiver
 *
 * An archiver that supports compression (through zlib).
 *
 */

/*
 * This code should suffice for stage1 on-the-fly uncompression of kernel modules.
 * (and it DOES perform tests and return values, blaaaah..)
 */

#include "mar-extract-only.h"
#include "mar.h"

#ifdef _STANDALONE_
void
zerr(BZFILE * f) /* decrease code size */
{
	fprintf(stderr, BZ2_bzerror(f, &z_errnum));
}

inline void
log_perror(char *msg)
{
	perror(msg);
}
void
log_message(char *msg)
{
	fprintf(stderr, msg);
}
#else /* _STANDALONE_ */
#include "../log.h"
void
zerr(BZFILE * f) /* decrease code size */
{
	log_message(BZ2_bzerror(f, &z_errnum));
}
#endif /* _STANDALONE_ */


static int
mar_open_file(char *filename, struct mar_stream *s)
{
	int end_filetable = 0;
	struct mar_element * previous_element = NULL;

	/* mar_zfile */
	s->mar_zfile = BZ2_bzopen(filename, "rb");
	if (!s->mar_zfile)
	{
		log_perror(filename);
		return -1;
	}

	while (end_filetable == 0)
	{
		char buf[512];
		int ptr = 0;
		/* read filename */
		do
		{
			if (BZ2_bzread(s->mar_zfile, &(buf[ptr]), sizeof(char)) != sizeof(char))
			{
				zerr(s->mar_zfile);
				return -1;
			}
			ptr++;
		} while ((buf[ptr-1] != 0) && (ptr < 512));
		/* ptr == 1 when we arrive on the "char 0" of the end of the filetable */
		if (ptr > 1)
		{
			struct mar_element * e = (struct mar_element *) malloc(sizeof(struct mar_element));
			e->filename = strdup(buf);
			/* read file_length */
			if (BZ2_bzread(s->mar_zfile, &(e->file_length), sizeof(int)) != sizeof(int))
			{
				zerr(s->mar_zfile);
				return -1;
			}
			/* read data_offset */
			if (BZ2_bzread(s->mar_zfile, &(e->data_offset), sizeof(int)) != sizeof(int))
			{
				zerr(s->mar_zfile);
				return -1;
			}
			/* write down chaining */
			if (previous_element)
				previous_element->next_element = e;
			else
				s->first_element = e;
			previous_element = e;
		}
		else
			end_filetable = 1;

	}
	/* chaining for last element */
	previous_element->next_element = NULL;

	return 0;
}


char **
mar_list_contents(char * mar_filename)
{
	struct mar_stream s;
	struct mar_element * elem;
	char * tmp_contents[500];
	char ** answ;
	int i = 0;

	if (mar_open_file(mar_filename, &s))
		return NULL;

	elem = s.first_element;
	while (elem)
	{
		tmp_contents[i++] = strdup(elem->filename);
		elem = elem->next_element;
	}
	tmp_contents[i++] = NULL;
	answ = (char **) malloc(sizeof(char *) * i);
	memcpy(answ, tmp_contents, sizeof(char *) * i);
	return answ;
}


int
mar_extract_file(char *mar_filename, char *filename_to_extract, char *dest_dir)
{
	struct mar_stream s;
	struct mar_element * elem;

	if (mar_open_file(mar_filename, &s))