[dahdi-commits] tzafrir: branch tools/2.5 r10512 - /tools/branches/2.5/xpp/

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Mar 15 16:21:09 CDT 2012


Author: tzafrir
Date: Thu Mar 15 16:21:06 2012
New Revision: 10512

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10512
Log:
xpp: Customizable license markers

* License strings markers (BEGIN.../END...) can be customized
* By default, generate a "generic" license markers
* We accept any (paired) markers from the valid list

Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10502

Added:
    tools/branches/2.5/xpp/astribank_license.c
      - copied, changed from r10510, tools/branches/2.5/xpp/astribank_allow.c
    tools/branches/2.5/xpp/astribank_license.h   (with props)
Modified:
    tools/branches/2.5/xpp/Makefile
    tools/branches/2.5/xpp/astribank_allow.8
    tools/branches/2.5/xpp/astribank_allow.c

Modified: tools/branches/2.5/xpp/Makefile
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/Makefile?view=diff&rev=10512&r1=10511&r2=10512
==============================================================================
--- tools/branches/2.5/xpp/Makefile (original)
+++ tools/branches/2.5/xpp/Makefile Thu Mar 15 16:21:06 2012
@@ -74,7 +74,7 @@
 
 ABHEXLOAD_OBJS		= astribank_hexload.o hexfile.o pic_loader.o $(ECHO_LOADER) $(ASTRIBANK_OBJS) $(OCT_HERE_OBJS)
 ABTOOL_OBJS		= astribank_tool.o $(ASTRIBANK_OBJS)
-ABALLOW_OBJS		= astribank_allow.o $(ASTRIBANK_OBJS)
+ABALLOW_OBJS		= astribank_allow.o astribank_license.o $(ASTRIBANK_OBJS)
 
 TARGETS	= .perlcheck astribank_is_starting
 PROG_INSTALL	= astribank_is_starting

Modified: tools/branches/2.5/xpp/astribank_allow.8
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/astribank_allow.8?view=diff&rev=10512&r1=10511&r2=10512
==============================================================================
--- tools/branches/2.5/xpp/astribank_allow.8 (original)
+++ tools/branches/2.5/xpp/astribank_allow.8 Thu Mar 15 16:21:06 2012
@@ -48,6 +48,16 @@
 License filename (stdin/stdout if not specified)
 .RE
 
+.B \-m \fInum\fR
+.RS
+Choose the numeric code of license markers to generate.
+This code select the type of \fIBEGIN\fR.../\fIEND\fR... strings
+that delimit the license body.
+
+Valid marker codes are listed with the \fB-h\fR option.
+The default (and first) code is \fB1\fR. Zero is illegal value.
+.RE
+
 .B \-v
 .RS
 Increase verbosity. May be used multiple times.

Modified: tools/branches/2.5/xpp/astribank_allow.c
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/astribank_allow.c?view=diff&rev=10512&r1=10511&r2=10512
==============================================================================
--- tools/branches/2.5/xpp/astribank_allow.c (original)
+++ tools/branches/2.5/xpp/astribank_allow.c Thu Mar 15 16:21:06 2012
@@ -34,6 +34,7 @@
 #include "mpp.h"
 #include "mpptalk.h"
 #include <debug.h>
+#include "astribank_license.h"
 
 static const char rcsid[] = "$Id$";
 
@@ -49,6 +50,8 @@
 	fprintf(stderr, "\t\t[-d mask]          # Debug mask (0xFF for everything)\n");
 	fprintf(stderr, "\t\t[-w]               # Write capabilities to EEPROM, otherwise read capabilities\n");
 	fprintf(stderr, "\t\t[-f filename]      # License filename (stdin/stdout if not specified)\n\n");
+	fprintf(stderr, "\t\t[-m num]           # Numeric code of License markers to generate\n");
+	license_markers_help("\t", stderr);
 	exit(1);
 }
 
@@ -70,216 +73,6 @@
 	return 0;
 }
 
-static int bin_to_file(void *buf, int len, FILE *f)
-{
-	static int bytes_on_line;
-	unsigned char *p = buf;
-	if (buf == NULL) {
-		if (bytes_on_line != 0) {
-			if (fprintf(f, "\n") != 1)
-				return -1;
-			bytes_on_line = 0;
-		}
-		return 0;
-	}
-	int i;
-	for (i = 0; i < len; i++) {
-		if (fprintf(f, "%02x", *p++) != 2)
-			return -1;
-		bytes_on_line++;
-		if (bytes_on_line >= 16) {
-			if (fprintf(f, "\n") != 1)
-				return -1;
-			bytes_on_line = 0;
-		}
-	}
-	return 0;
-}
-
-static int write_to_file(struct eeprom_table *eeprom_table, struct capabilities *caps, struct capkey *key, FILE *f)
-{
-	fprintf(f, "-----BEGIN XORCOM LICENSE BLOCK-----\n");
-	fprintf(f, "Version: 1.0\n");
-	fprintf(f, "Timestamp: %u\n", caps->timestamp);
-	fprintf(f, "Serial: %.*s\n", LABEL_SIZE, eeprom_table->label);
-	fprintf(f, "Capabilities.Port.FXS: %d\n", caps->ports_fxs);
-	fprintf(f, "Capabilities.Port.FXO: %d\n", caps->ports_fxo);
-	fprintf(f, "Capabilities.Port.BRI: %d\n", caps->ports_bri);
-	fprintf(f, "Capabilities.Port.PRI: %d\n", caps->ports_pri);
-	fprintf(f, "Capabilities.Port.ECHO: %d\n", caps->ports_echo);
-	fprintf(f, "Capabilities.Twinstar: %d\n", CAP_EXTRA_TWINSTAR(caps));
-	fprintf(f, "Data:\n");
-	bin_to_file(eeprom_table, sizeof(*eeprom_table), f);
-	bin_to_file(caps, sizeof(*caps), f);
-	bin_to_file(key, sizeof(*key), f);
-	bin_to_file(NULL, 0, f);
-	fprintf(f, "-----END XORCOM LICENSE BLOCK-----\n");
-	return 0;
-}
-
-/*
- * Removes whitespace on both sizes of the string.
- * Returns a pointer to the first non-space char. The string
- * is modified in place to trim trailing whitespace.
- * If the whole string is whitespace, returns NULL.
- */
-char *trim(char *s)
-{
-	int len = strlen(s);
-	while (len > 0 && isspace(s[len-1])) {
-		len--;
-	}
-	if (len == 0)
-		return NULL;
-	s[len] = '\0';
-	while (isspace(*s))
-		s++;
-	/* *s is not a space, since in this case we'd return NULL above */
-	return s;
-}
-
-int get_key_value(char *line, char **key, char **value)
-{
-	char *p = strchr(line, ':');
-	if (p == NULL)
-		return -1;
-	*p = '\0';
-	*key = trim(line);
-	*value = trim(p + 1);
-	return 0;
-}
-
-static int hex_digit_to_int(char c)
-{
-	if (c >= '0' && c <= '9')
-		return c - '0';
-	else if (c >= 'a' && c <= 'f')
-		return c - 'a' + 10;
-	else
-		return -1;
-}
-
-static int str_to_bin(char *line, void *buf, int maxlen)
-{
-	static int offset;
-	unsigned char *p = buf;
-	if (strlen(line) % 2 != 0)
-		return -1;
-	while (offset < maxlen && *line) {
-		uint8_t value;
-		char c = hex_digit_to_int(*line++);
-		if (c < 0 || *line == '\0')
-			return -1;
-		value = c << 4;
-		c = hex_digit_to_int(*line++);
-		if (c < 0)
-			return -1;
-		value |= c;
-		p[offset++] = value;
-	}
-	if (offset == maxlen && *line)
-		return -1;
-	return offset;
-}
-
-static int read_from_file(struct eeprom_table *eeprom_table, struct capabilities *caps, struct capkey *capkey, FILE *f)
-{
-	char buf[256];
-	char *line, *key, *value;
-	int state = 0;
-	int lineno = 0;
-	struct table {
-		struct eeprom_table eeprom_table;
-		struct capabilities capabilities;
-		struct capkey capkey;
-	} PACKED table;
-
-	memset(&table, 0, sizeof(struct table));
-	/*
-	 * states:
-	 * 0: start - before BEGIN_LICENSE_BLOCK line. on BEGIN_LICENSE_BLOCK line goto 1.
-	 * 1: read Version, goto 2. if not version line then error.
-	 * 2: after BEGIN line. split line into key:value. if line is Data:, goto 3.
-	 * 3: read binary data. if line is END_LICENSE_BLOCK goto 4.
-	 * 4: END_LICENSE_BLOCK - ignore lines.
-	 */
-	while (fgets(buf, 256, f) != NULL) {
-		lineno++;
-		int len = strlen(buf);
-		if (len > 0 && buf[len-1] != '\n') {
-			ERR("Line %d: Line too long\n", lineno);
-			return -1;
-		}
-		line = trim(buf);
-		if (line == NULL) {
- 			if (state > 0 && state < 4) {
-				ERR("Line %d: Empty line\n", lineno);
-				return -1;
-			}
-			else
-				continue;
-		}
-		switch (state) {
-			case 0:
-				if (strcmp(line, "-----BEGIN XORCOM LICENSE BLOCK-----") == 0)
-					state = 1;
-				else {
-					ERR("Line %d: Invalid license begin block\n", lineno);
-					return -1;
-				}
-				break;
-			case 1:
-				if (get_key_value(line, &key, &value) < 0) {
-					ERR("Line %d: Can't parse line\n", lineno);
-					return -1;
-				}
-				if (strcmp(key, "Version") == 0) {
-					if (strcmp(value, "1.0") == 0) {
-						state = 2;
-					} else {
-						ERR("Line %d: Unknown license file version '%s', need version '1.0'\n", lineno, value);
-						return -1;
-					}
-				} else {
-					ERR("Line %d: No license file version\n", lineno);
-					return -1;
-				}
-				break;
-			case 2:
-				if (get_key_value(line, &key, &value) < 0) {
-					ERR("Line %d: Can't parse line\n", lineno);
-					return -1;
-				}
-				if (strcmp(key, "Data") == 0) {
-					state = 3;
-					break;
-				}
-				break;
-			case 3:
-				if (strcmp(line, "-----END XORCOM LICENSE BLOCK-----") == 0) {
-					state = 4;
-					break;
-				}
-				if (str_to_bin(line, &table, sizeof(table)) < 0) {
-					ERR("Line %d: Error in data block\n", lineno);
-					return -1;
-				}
-				break;
-			case 4:
-				break;
-
-		}
-	}
-	if (state != 4) {
-		ERR("Invalid license file\n");
-		return -1;
-	}
-	memcpy(eeprom_table, &table.eeprom_table, sizeof(*eeprom_table));
-	memcpy(caps, &table.capabilities, sizeof(*caps));
-	memcpy(capkey, &table.capkey, sizeof(*capkey));
-	return 0;
-}
-
 int main(int argc, char *argv[])
 {
 	char			*devpath = NULL;
@@ -287,8 +80,9 @@
 	struct eeprom_table	eeprom_table;
 	struct capabilities	caps;
 	struct capkey		key;
-	const char		options[] = "vd:D:wf:";
+	const char		options[] = "vd:D:wf:m:";
 	int			do_write = 0;
+	unsigned int		marker = LICENSE_MARKER_GENERIC;
 	FILE			*file;
 	char			*filename = NULL;
 	int			ret;
@@ -317,6 +111,11 @@
 			case 'f':
 				filename = optarg;
 				break;
+			case 'm':
+				marker = strtoul(optarg, NULL, 0);
+				if (!license_marker_valid(marker))
+					usage();
+				break;
 			case 'h':
 			default:
 				ERR("Unknown option '%c'\n", c);
@@ -343,6 +142,7 @@
 		return 1;
 	}
 	if (do_write) {
+		int used_marker;
 		/* update capabilities based on input file */
 		file = stdin;
 		if (filename) {
@@ -352,7 +152,7 @@
 				return 1;
 			}
 		}
-		ret = read_from_file(&eeprom_table, &caps, &key, file);
+		ret = read_from_file(&eeprom_table, &caps, &key, &used_marker, file);
 		if (ret < 0) {
 			ERR("Failed to read capabilities from file: %d\n", ret);
 			return 1;
@@ -372,7 +172,7 @@
 				return 1;
 			}
 		}
-		ret = write_to_file(&eeprom_table, &caps, &key, file);
+		ret = write_to_file(&eeprom_table, &caps, &key, marker, file);
 		if (ret < 0) {
 			ERR("Failed to write capabilities to file: %d\n", ret);
 			return 1;

Copied: tools/branches/2.5/xpp/astribank_license.c (from r10510, tools/branches/2.5/xpp/astribank_allow.c)
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/astribank_license.c?view=diff&rev=10512&p1=tools/branches/2.5/xpp/astribank_allow.c&r1=10510&p2=tools/branches/2.5/xpp/astribank_license.c&r2=10512
==============================================================================
--- tools/branches/2.5/xpp/astribank_allow.c (original)
+++ tools/branches/2.5/xpp/astribank_license.c Thu Mar 15 16:21:06 2012
@@ -1,7 +1,6 @@
 /*
- * Written by Oron Peled <oron at actcom.co.il> and
- *            Alex Landau <alex.landau at xorcom.com>
- * Copyright (C) 2008, Xorcom
+ * Written by Oron Peled <oron at actcom.co.il>
+ * Copyright (C) 2012, Xorcom
  *
  * All rights reserved.
  *
@@ -21,52 +20,86 @@
  *
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <assert.h>
-#include <getopt.h>
-#include <time.h>
-#include <sys/types.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-#include "mpp.h"
-#include "mpptalk.h"
 #include <debug.h>
-
-static const char rcsid[] = "$Id$";
-
-#define	DBG_MASK	0x80
-
-static char	*progname;
-
-static void usage()
-{
-	fprintf(stderr, "Usage: %s [options...] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev> options\n", progname);
-	fprintf(stderr, "\tOptions:\n");
-	fprintf(stderr, "\t\t[-v]               # Increase verbosity\n");
-	fprintf(stderr, "\t\t[-d mask]          # Debug mask (0xFF for everything)\n");
-	fprintf(stderr, "\t\t[-w]               # Write capabilities to EEPROM, otherwise read capabilities\n");
-	fprintf(stderr, "\t\t[-f filename]      # License filename (stdin/stdout if not specified)\n\n");
-	exit(1);
-}
-
-static int capabilities_burn(
-		struct astribank_device *astribank,
-		struct eeprom_table *eeprom_table,
-		struct capabilities *capabilities,
-		struct capkey *key)
-{
-	int	ret;
-
-	INFO("Burning capabilities\n");
-	ret = mpp_caps_set(astribank, eeprom_table, capabilities, key);
-	if(ret < 0) {
-		ERR("Capabilities burning failed: %d\n", ret);
-		return ret;
-	}
-	INFO("Done\n");
+#include "astribank_license.h"
+
+#define	ARRAY_SIZE(a)	(sizeof(a)/sizeof((a)[0]))
+
+static const struct boundary {
+	const char *name;
+	const char *markers[2];
+} boundaries[] = {
+	[LICENSE_MARKER_NONE] = {	/* Skip 0 */
+	},
+	[LICENSE_MARKER_XORCOM] = {
+		"Xorcom",
+		{
+			"-----BEGIN XORCOM LICENSE BLOCK-----",
+			"-----END XORCOM LICENSE BLOCK-----",
+		},
+	},
+	[LICENSE_MARKER_GENERIC] = {
+		"Generic",
+		{
+			"-----BEGIN TELEPHONY DEVICE LICENSE BLOCK-----",
+			"-----END TELEPHONY DEVICE LICENSE BLOCK-----",
+		}
+	},
+};
+
+void license_markers_help(const char *prefix, FILE *fp)
+{
+	int i;
+
+	fprintf(fp, "%sValid license markers:\n", prefix);
+	for (i = LICENSE_MARKER_NONE + 1; i < ARRAY_SIZE(boundaries); i++) {
+		const struct boundary *b = &boundaries[i];
+		if (b->markers[0] != 0)
+			fprintf(fp, "%s\t%d - %s\n", prefix, i, b->name);
+	}
+}
+
+int license_marker_valid(unsigned int which)
+{
+	if (which >= ARRAY_SIZE(boundaries))
+		return 0;
+	if (boundaries[which].markers[0] == NULL)
+		return 0;
+	return 1;
+}
+
+static const char *marker_string(unsigned int which, int end_marker)
+{
+	int selector = (end_marker) ? 1 : 0;
+
+	if (license_marker_valid(which)) {
+		return boundaries[which].markers[selector];
+	}
+	ERR("gen_marker: invalid marker %d\n", which);
+	return NULL;
+}
+
+static int marker_find(const char *str, int end_marker)
+{
+	int selector = (end_marker) ? 1 : 0;
+	int i;
+
+	for (i = LICENSE_MARKER_NONE + 1; i < ARRAY_SIZE(boundaries); i++) {
+		const struct boundary *b = &boundaries[i];
+		const char *marker_str = b->markers[selector];
+
+#if 0
+		DBG("marker_find(%s,%d)[%d]: %s\n",
+			str, end_marker, i, marker_str);
+#endif
+		if (!marker_str)
+			continue;
+		if (strcmp(str, marker_str) == 0)
+			return i;
+	}
 	return 0;
 }
 
@@ -96,9 +129,14 @@
 	return 0;
 }
 
-static int write_to_file(struct eeprom_table *eeprom_table, struct capabilities *caps, struct capkey *key, FILE *f)
-{
-	fprintf(f, "-----BEGIN XORCOM LICENSE BLOCK-----\n");
+int write_to_file(
+	struct eeprom_table *eeprom_table,
+	struct capabilities *caps,
+	struct capkey *key,
+	unsigned int marker,
+	FILE *f)
+{
+	fprintf(f, "%s\n", marker_string(marker, 0));
 	fprintf(f, "Version: 1.0\n");
 	fprintf(f, "Timestamp: %u\n", caps->timestamp);
 	fprintf(f, "Serial: %.*s\n", LABEL_SIZE, eeprom_table->label);
@@ -113,7 +151,7 @@
 	bin_to_file(caps, sizeof(*caps), f);
 	bin_to_file(key, sizeof(*key), f);
 	bin_to_file(NULL, 0, f);
-	fprintf(f, "-----END XORCOM LICENSE BLOCK-----\n");
+	fprintf(f, "%s\n", marker_string(marker, 1));
 	return 0;
 }
 
@@ -123,7 +161,7 @@
  * is modified in place to trim trailing whitespace.
  * If the whole string is whitespace, returns NULL.
  */
-char *trim(char *s)
+static char *trim(char *s)
 {
 	int len = strlen(s);
 	while (len > 0 && isspace(s[len-1])) {
@@ -138,7 +176,7 @@
 	return s;
 }
 
-int get_key_value(char *line, char **key, char **value)
+static int get_key_value(char *line, char **key, char **value)
 {
 	char *p = strchr(line, ':');
 	if (p == NULL)
@@ -182,17 +220,30 @@
 	return offset;
 }
 
-static int read_from_file(struct eeprom_table *eeprom_table, struct capabilities *caps, struct capkey *capkey, FILE *f)
+int read_from_file(
+	struct eeprom_table *eeprom_table,
+	struct capabilities *caps,
+	struct capkey *capkey,
+	unsigned int *used_marker,
+	FILE *f)
 {
 	char buf[256];
 	char *line, *key, *value;
-	int state = 0;
 	int lineno = 0;
+	unsigned int license_marker_begin;
+	unsigned int license_marker_end;
 	struct table {
 		struct eeprom_table eeprom_table;
 		struct capabilities capabilities;
 		struct capkey capkey;
 	} PACKED table;
+	enum PARSE_STATES {
+		STATE_BEFORE_LICENSE = 0,
+		STATE_EXPECT_VERSION = 1,
+		STATE_EXPECT_DATA = 2,
+		STATE_READ_DATA = 3,
+		STATE_AFTER_LICENSE = 4,
+	} state = STATE_BEFORE_LICENSE;
 
 	memset(&table, 0, sizeof(struct table));
 	/*
@@ -212,7 +263,7 @@
 		}
 		line = trim(buf);
 		if (line == NULL) {
- 			if (state > 0 && state < 4) {
+			if (state > STATE_BEFORE_LICENSE && state < STATE_AFTER_LICENSE) {
 				ERR("Line %d: Empty line\n", lineno);
 				return -1;
 			}
@@ -220,22 +271,23 @@
 				continue;
 		}
 		switch (state) {
-			case 0:
-				if (strcmp(line, "-----BEGIN XORCOM LICENSE BLOCK-----") == 0)
-					state = 1;
+			case STATE_BEFORE_LICENSE:
+				license_marker_begin = marker_find(line, 0);
+				if (license_marker_begin)
+					state = STATE_EXPECT_VERSION;
 				else {
 					ERR("Line %d: Invalid license begin block\n", lineno);
 					return -1;
 				}
 				break;
-			case 1:
+			case STATE_EXPECT_VERSION:
 				if (get_key_value(line, &key, &value) < 0) {
 					ERR("Line %d: Can't parse line\n", lineno);
 					return -1;
 				}
 				if (strcmp(key, "Version") == 0) {
 					if (strcmp(value, "1.0") == 0) {
-						state = 2;
+						state = STATE_EXPECT_DATA;
 					} else {
 						ERR("Line %d: Unknown license file version '%s', need version '1.0'\n", lineno, value);
 						return -1;
@@ -245,19 +297,25 @@
 					return -1;
 				}
 				break;
-			case 2:
+			case STATE_EXPECT_DATA:
 				if (get_key_value(line, &key, &value) < 0) {
 					ERR("Line %d: Can't parse line\n", lineno);
 					return -1;
 				}
 				if (strcmp(key, "Data") == 0) {
-					state = 3;
+					state = STATE_READ_DATA;
 					break;
 				}
 				break;
-			case 3:
-				if (strcmp(line, "-----END XORCOM LICENSE BLOCK-----") == 0) {
-					state = 4;
+			case STATE_READ_DATA:
+				license_marker_end = marker_find(line, 1);
+				if (license_marker_end) {
+					printf("DEBUG: end=%d begin=%d\n", license_marker_end, license_marker_begin);
+					if (license_marker_end != license_marker_begin) {
+						ERR("Line %d: End marker != Begin marker\n", lineno);
+						return -1;
+					}
+					state = STATE_AFTER_LICENSE;
 					break;
 				}
 				if (str_to_bin(line, &table, sizeof(table)) < 0) {
@@ -265,12 +323,12 @@
 					return -1;
 				}
 				break;
-			case 4:
-				break;
-
-		}
-	}
-	if (state != 4) {
+			case STATE_AFTER_LICENSE:
+				break;
+
+		}
+	}
+	if (state != STATE_AFTER_LICENSE) {
 		ERR("Invalid license file\n");
 		return -1;
 	}
@@ -280,106 +338,3 @@
 	return 0;
 }
 
-int main(int argc, char *argv[])
-{
-	char			*devpath = NULL;
-	struct astribank_device *astribank;
-	struct eeprom_table	eeprom_table;
-	struct capabilities	caps;
-	struct capkey		key;
-	const char		options[] = "vd:D:wf:";
-	int			do_write = 0;
-	FILE			*file;
-	char			*filename = NULL;
-	int			ret;
-
-	progname = argv[0];
-	while (1) {
-		int	c;
-
-		c = getopt (argc, argv, options);
-		if (c == -1)
-			break;
-
-		switch (c) {
-			case 'D':
-				devpath = optarg;
-				break;
-			case 'v':
-				verbose++;
-				break;
-			case 'd':
-				debug_mask = strtoul(optarg, NULL, 0);
-				break;
-			case 'w':
-				do_write = 1;
-				break;
-			case 'f':
-				filename = optarg;
-				break;
-			case 'h':
-			default:
-				ERR("Unknown option '%c'\n", c);
-				usage();
-		}
-	}
-	if(!devpath) {
-		ERR("Missing device path\n");
-		usage();
-	}
-	DBG("Startup %s\n", devpath);
-	if((astribank = mpp_init(devpath, 1)) == NULL) {
-		ERR("Failed initializing MPP\n");
-		return 1;
-	}
-	if(astribank->eeprom_type != EEPROM_TYPE_LARGE) {
-		ERR("Cannot use this program with astribank EEPROM type %d (need %d)\n",
-			astribank->eeprom_type, EEPROM_TYPE_LARGE);
-		return 1;
-	}
-	ret = mpp_caps_get(astribank, &eeprom_table, &caps, &key);
-	if(ret < 0) {
-		ERR("Failed to get original capabilities: %d\n", ret);
-		return 1;
-	}
-	if (do_write) {
-		/* update capabilities based on input file */
-		file = stdin;
-		if (filename) {
-			file = fopen(filename, "r");
-			if (file == NULL) {
-				ERR("Can't open file '%s'\n", filename);
-				return 1;
-			}
-		}
-		ret = read_from_file(&eeprom_table, &caps, &key, file);
-		if (ret < 0) {
-			ERR("Failed to read capabilities from file: %d\n", ret);
-			return 1;
-		}
-		show_capabilities(&caps, stderr);
-		if (capabilities_burn(astribank, &eeprom_table, &caps, &key) < 0)
-			return 1;
-		if (file != stdin)
-			fclose(file);
-	} else {
-		/* print capabilities to stdout */
-		file = stdout;
-		if (filename) {
-			file = fopen(filename, "w");
-			if (file == NULL) {
-				ERR("Can't create file '%s'\n", filename);
-				return 1;
-			}
-		}
-		ret = write_to_file(&eeprom_table, &caps, &key, file);
-		if (ret < 0) {
-			ERR("Failed to write capabilities to file: %d\n", ret);
-			return 1;
-		}
-		if (file != stdout)
-			fclose(file);
-	}
-	mpp_exit(astribank);
-	return 0;
-}

Added: tools/branches/2.5/xpp/astribank_license.h
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/astribank_license.h?view=auto&rev=10512
==============================================================================
--- tools/branches/2.5/xpp/astribank_license.h (added)
+++ tools/branches/2.5/xpp/astribank_license.h Thu Mar 15 16:21:06 2012
@@ -1,0 +1,29 @@
+#ifndef	ASTRIBANK_ALLOW_H
+#define	ASTRIBANK_ALLOW_H
+
+#include "mpp.h"
+
+enum license_markers {
+	LICENSE_MARKER_NONE = 0,
+	LICENSE_MARKER_XORCOM = 1,
+	LICENSE_MARKER_GENERIC = 2,
+};
+
+int license_marker_valid(unsigned int which);
+void license_markers_help(const char *prefix, FILE *fp);
+
+int write_to_file(
+	struct eeprom_table *eeprom_table,
+	struct capabilities *caps,
+	struct capkey *key,
+	unsigned int marker,
+	FILE *f);
+
+int read_from_file(
+	struct eeprom_table *eeprom_table,
+	struct capabilities *caps,
+	struct capkey *capkey,
+	unsigned int *used_marker,
+	FILE *f);
+
+#endif	/* ASTRIBANK_ALLOW_H */

Propchange: tools/branches/2.5/xpp/astribank_license.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/branches/2.5/xpp/astribank_license.h
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Propchange: tools/branches/2.5/xpp/astribank_license.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the dahdi-commits mailing list