Remove channel keys and hamcs after LEAVE command.
[silc.git] / lib / silccore / silcid.c
index 027cf6eadd676915845e6de6784b6661a9c92b5a..cfdc6f66ecb8665ae07e8093a312bf31522ea9fa 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  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
@@ -69,7 +69,7 @@ SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
     goto err;
 
   ret = silc_buffer_unformat(&buffer,
-                            SILC_STR_UI_XNSTRING_ALLOC(&newp->id, newp->len),
+                            SILC_STR_DATA_ALLOC(&newp->id, newp->len),
                             SILC_STR_END);
   if (ret == -1)
     goto err;
@@ -113,7 +113,7 @@ SilcBool silc_id_payload_parse_id(const unsigned char *data, SilcUInt32 len,
     goto err;
 
   ret = silc_buffer_unformat(&buffer,
-                            SILC_STR_UI_XNSTRING(&id_data, idlen),
+                            SILC_STR_DATA(&id_data, idlen),
                             SILC_STR_END);
   if (ret == -1)
     goto err;
@@ -167,7 +167,7 @@ SilcBuffer silc_id_payload_encode_data(const unsigned char *id,
   silc_buffer_format(buffer,
                     SILC_STR_UI_SHORT(type),
                     SILC_STR_UI_SHORT(id_len),
-                    SILC_STR_UI_XNSTRING(id, id_len),
+                    SILC_STR_DATA(id, id_len),
                     SILC_STR_END);
   return buffer;
 }
@@ -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)