File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / scripts / id2sql.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:20:15 2021 UTC (3 years, 6 months ago) by misho
Branches: strongswan, MAIN
CVS tags: v5_9_2p0, HEAD
strongswan 5.9.2

    1: /*
    2:  * Copyright (C) 2008 Martin Willi
    3:  * HSR Hochschule fuer Technik Rapperswil
    4:  *
    5:  * This program is free software; you can redistribute it and/or modify it
    6:  * under the terms of the GNU General Public License as published by the
    7:  * Free Software Foundation; either version 2 of the License, or (at your
    8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
    9:  *
   10:  * This program is distributed in the hope that it will be useful, but
   11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13:  * for more details.
   14:  */
   15: 
   16: #include <stdio.h>
   17: 
   18: #include <library.h>
   19: #include <utils/identification.h>
   20: 
   21: /**
   22:  * convert an identity to type and encoding
   23:  */
   24: int main(int argc, char *argv[])
   25: {
   26: 	identification_t *id;
   27: 	chunk_t enc;
   28: 	int i;
   29: 
   30: 	library_init(NULL, "id2sql");
   31: 	atexit(library_deinit);
   32: 
   33: 	if (argc < 2)
   34: 	{
   35: 		return -1;
   36: 	}
   37: 
   38: 	id = identification_create_from_string(argv[1]);
   39: 	if (!id)
   40: 	{
   41: 		return -2;
   42: 	}
   43: 	printf("type\tencoding\n");
   44: 	printf("%d,\t", id->get_type(id));
   45: 	enc = id->get_encoding(id);
   46: 
   47: 	printf("X'");
   48: 	for (i = 0; i < enc.len; i++)
   49: 	{
   50: 		printf("%02x", (unsigned int)enc.ptr[i]);
   51: 	}
   52: 	printf("'\n");
   53: 	id->destroy(id);
   54: 	return 0;
   55: }
   56: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>