From: Pekka Riikonen Date: Sun, 22 Apr 2007 18:22:42 +0000 (+0000) Subject: Added silc_id_str2id2 X-Git-Tag: silc.toolkit.1.1.beta1~41 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=ca4f8ec5c7e4217cbf880823f2a792c26186d195 Added silc_id_str2id2 --- diff --git a/lib/silccore/silcid.c b/lib/silccore/silcid.c index 3f7e8b1f..cfdc6f66 100644 --- a/lib/silccore/silcid.c +++ b/lib/silccore/silcid.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2006 Pekka Riikonen + Copyright (C) 1997 - 2007 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -340,6 +340,36 @@ SilcBool silc_id_str2id(const unsigned char *id, SilcUInt32 id_len, return FALSE; } +/* Converts string to ID */ + +SilcBool silc_id_str2id2(const unsigned char *id, SilcUInt32 id_len, + SilcIdType type, SilcID *ret_id) +{ + if (!ret_id) + return FALSE; + + ret_id->type = type; + + switch (type) { + case SILC_ID_CLIENT: + return silc_id_str2id(id, id_len, type, &ret_id->u.client_id, + sizeof(ret_id->u.client_id)); + break; + + case SILC_ID_SERVER: + return silc_id_str2id(id, id_len, type, &ret_id->u.server_id, + sizeof(ret_id->u.server_id)); + break; + + case SILC_ID_CHANNEL: + return silc_id_str2id(id, id_len, type, &ret_id->u.channel_id, + sizeof(ret_id->u.channel_id)); + break; + } + + return FALSE; +} + /* Returns length of the ID */ SilcUInt32 silc_id_get_len(const void *id, SilcIdType type) diff --git a/lib/silccore/silcid.h b/lib/silccore/silcid.h index 216e29a1..25cca444 100644 --- a/lib/silccore/silcid.h +++ b/lib/silccore/silcid.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2006 Pekka Riikonen + Copyright (C) 1997 - 2007 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -492,6 +492,22 @@ SilcBool silc_id_id2str(const void *id, SilcIdType type, SilcBool silc_id_str2id(const unsigned char *id, SilcUInt32 id_len, SilcIdType type, void *ret_id, SilcUInt32 ret_id_size); +/****f* silccore/SilcIDAPI/silc_id_str2id2 + * + * SYNOPSIS + * + * SilcBool silc_id_str2id2(const unsigned char *id, SilcUInt32 id_len, + * SilcIdType type, SilcID *ret_id); + * + * DESCRIPTION + * + * Same as silc_id_str2id but returns the ID into SilcID structure in + * `ret_id' pointer. This does not allocate any memory. + * + ***/ +SilcBool silc_id_str2id2(const unsigned char *id, SilcUInt32 id_len, + SilcIdType type, SilcID *ret_id); + /****f* silccore/SilcIDAPI/silc_id_get_len * * SYNOPSIS