pem2[i] = pem[j++];
}
+ silc_free(pem);
return pem2;
}
case SILC_ID_SERVER:
{
SilcServerID *server_id = (SilcServerID *)id;
- strcat(rid, inet_ntoa(server_id->ip));
+ struct in_addr ipv4;
+
+ if (server_id->ip.data_len > 4) {
+
+ } else {
+ SILC_GET32_MSB(ipv4.s_addr, server_id->ip.data);
+ strcat(rid, inet_ntoa(ipv4));
+ }
+
memset(tmp, 0, sizeof(tmp));
snprintf(tmp, sizeof(tmp), ",%d,", ntohs(server_id->port));
strcat(rid, tmp);
case SILC_ID_CLIENT:
{
SilcClientID *client_id = (SilcClientID *)id;
- strcat(rid, inet_ntoa(client_id->ip));
+ struct in_addr ipv4;
+
+ if (client_id->ip.data_len > 4) {
+
+ } else {
+ SILC_GET32_MSB(ipv4.s_addr, client_id->ip.data);
+ strcat(rid, inet_ntoa(ipv4));
+ }
+
memset(tmp, 0, sizeof(tmp));
snprintf(tmp, sizeof(tmp), ",%02x,", client_id->rnd);
strcat(rid, tmp);
case SILC_ID_CHANNEL:
{
SilcChannelID *channel_id = (SilcChannelID *)id;
- strcat(rid, inet_ntoa(channel_id->ip));
+ struct in_addr ipv4;
+
+ if (channel_id->ip.data_len > 4) {
+
+ } else {
+ SILC_GET32_MSB(ipv4.s_addr, channel_id->ip.data);
+ strcat(rid, inet_ntoa(ipv4));
+ }
+
memset(tmp, 0, sizeof(tmp));
snprintf(tmp, sizeof(tmp), ",%d,", ntohs(channel_id->port));
strcat(rid, tmp);
tmpstr2 = silc_calloc(slen2 + 1, sizeof(char));
memcpy(tmpstr2, string2, slen2);
- for (i = 0; i < slen2; i++) {
+ for (i = 0; i < slen1; i++) {
/* * wildcard. Only one * wildcard is possible. */
if (tmpstr1[i] == '*')
if (!(slen1 < slen2))
tmpstr2[i] = '?';
}
-#if 0
- } else {
- if (strncmp(tmpstr1, tmpstr2, i))
- strncpy(tmpstr2, string2, slen2);
-#endif
}
}
{
char *logname = NULL;
+ if (!getenv("LOGNAME")) {
+ fprintf(stderr, "Error: environment variable $LOGNAME not set\n");
+ return NULL;
+ }
+
logname = strdup(getenv("LOGNAME"));
if (!logname) {
logname = getlogin();
return realname;
}
+
+/* Basic has function to hash strings. May be used with the SilcHashTable. */
+
+uint32 silc_hash_string(void *key)
+{
+ char *s = (char *)key;
+ uint32 h = 0, g;
+
+ while (*s != '\0') {
+ h = (h << 4) + toupper(*s);
+ if ((g = h & 0xf0000000)) {
+ h = h ^ (g >> 24);
+ h = h ^ g;
+ }
+ s++;
+ }
+
+ return h;
+}
+
+/* Basic hash function to hash integers. May be used with the SilcHashTable. */
+
+uint32 silc_hash_uint(void *key)
+{
+ return *(uint32 *)key;
+}
+
+/* Basic hash funtion to hash pointers. May be used with the SilcHashTable. */
+
+uint32 silc_hash_ptr(void *key)
+{
+ return (uint32)key;
+}
+
+/* Hash a Server ID. */
+
+uint32 silc_hash_server_id(void *key)
+{
+ SilcServerID *id = (SilcServerID *)key;
+ int i;
+ uint32 h;
+
+ h = id->port * id->rnd;
+ for (i = 0; i < id->ip.data_len; i++)
+ h ^= id->ip.data[i];
+
+ return h;
+}
+
+/* Hash a Client ID. */
+
+uint32 silc_hash_client_id(void *key)
+{
+ SilcClientID *id = (SilcClientID *)key;
+ int i;
+ uint32 h;
+
+ h = id->rnd;
+ for (i = 0; i < sizeof(id->hash); i++)
+ h ^= id->hash[i];
+ for (i = 0; i < id->ip.data_len; i++)
+ h ^= id->ip.data[i];
+
+ return h;
+}
+
+/* Hash a Channel ID. */
+
+uint32 silc_hash_channel_id(void *key)
+{
+ SilcChannelID *id = (SilcChannelID *)key;
+ int i;
+ uint32 h;
+
+ h = id->port * id->rnd;
+ for (i = 0; i < id->ip.data_len; i++)
+ h ^= id->ip.data[i];
+
+ return h;
+}