warnings on 64-bit systems (received on amd64).
Fixes problem when the primary router goes down. Affected files
silcd/server.c, silcd/server_backup.c
+Thu Feb 12 20:09:59 EET 2004 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added SILC_[32|64]_TO_PTR and SILC_PTR_TO_[32|64] macros.
+ Fixed various compilation warnings when type casting ints
+ to pointers or vice versa, of different size. Updates around
+ the source free.
+
Tue Feb 3 23:25:17 EET 2004 Pekka Riikonen <priikone@silcnet.org>
* Surrogates not allowed in UTF-8 strings, updated decoder.
$(silc_sources)
all-local:
- for dir in $(perl_dirs); do \
+ for dir in "$(perl_dirs)"; do \
cd $$dir && \
if [ ! -f Makefile ]; then \
$(perlpath) Makefile.PL $(PERL_MM_PARAMS); \
sock->ip));
/* Listenning port */
- if (!server->sockets[(SilcUInt32)proto_ctx->context]) {
+ if (!server->sockets[SILC_PTR_TO_32(proto_ctx->context)]) {
silc_server_disconnect_remote(server, sock,
SILC_STATUS_ERR_RESOURCE_LIMIT,
"Connection refused");
silc_free(proto_ctx);
return;
}
- port = server->sockets[(SilcUInt32)proto_ctx->context]->port;
+ port = server->sockets[SILC_PTR_TO_32(proto_ctx->context)]->port;
/* Check whether this connection is denied to connect to us. */
deny = silc_server_config_find_denied(server, sock->ip);
is accepted further. */
proto_ctx = silc_calloc(1, sizeof(*proto_ctx));
proto_ctx->server = server;
- proto_ctx->context = (void *)fd;
+ proto_ctx->context = SILC_32_TO_PTR(fd);
silc_socket_host_lookup(newsocket, TRUE,
silc_server_accept_new_connection_lookup,
(void *)proto_ctx, server->schedule);
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2003 Pekka Riikonen
+ Copyright (C) 1997 - 2004 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
silc_free(ctx);
/* Notify application of failure */
- client->internal->ops->connected(client, conn,
+ client->internal->ops->connected(client, conn,
SILC_CLIENT_CONN_ERROR_TIMEOUT);
}
return;
/* Notify application */
client->internal->ops->failure(client, sock->user_data, sock->protocol,
- (void *)failure);
+ SILC_32_TO_PTR(failure));
}
}
/*
- client_attrs.c
+ client_attrs.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2002 Pekka Riikonen
+ Copyright (C) 2002 - 2004 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
static void silc_client_attributes_process_foreach(void *key, void *context,
void *user_context)
{
- SilcAttribute attribute = (SilcAttribute)(SilcUInt32)key;
+ SilcAttribute attribute = (SilcAttribute)SILC_PTR_TO_32(key);
SilcAttributePayload attr = context;
SilcAttrForeach *f = user_context;
const unsigned char *data;
continue;
silc_hash_table_find_foreach(conn->internal->attrs,
- (void *)(SilcUInt32)attribute,
+ SILC_32_TO_PTR(attribute),
silc_client_attributes_process_foreach,
&f);
}
NULL, silc_client_attribute_destruct,
NULL, TRUE);
silc_hash_table_add(conn->internal->attrs,
- (void *)(SilcUInt32)attribute, attr);
+ SILC_32_TO_PTR(attribute), attr);
return attr;
}
return;
attribute = silc_attribute_get_attribute(attr);
silc_hash_table_del_by_context(conn->internal->attrs,
- (void *)(SilcUInt32)attribute, attr);
+ SILC_32_TO_PTR(attribute), attr);
}
/* Delete one attribute */
if (attr) {
attribute = silc_attribute_get_attribute(attr);
ret = silc_hash_table_del_by_context(conn->internal->attrs,
- (void *)(SilcUInt32)attribute, attr);
+ SILC_32_TO_PTR(attribute), attr);
} else if (attribute) {
silc_hash_table_find_foreach(conn->internal->attrs,
- (void *)(SilcUInt32)attribute,
+ SILC_32_TO_PTR(attribute),
silc_client_attribute_del_foreach, conn);
ret = TRUE;
} else{
Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
- Copyright (C) 2000 - 2001 Pekka Riikonen
+ Copyright (C) 2000 - 2004 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
if (!cache)
return NULL;
cache->id_table = silc_hash_table_alloc(count, silc_hash_id,
- (void *)(SilcUInt32)id_type,
+ SILC_32_TO_PTR(id_type),
silc_hash_id_compare,
- (void *)(SilcUInt32)id_type,
+ SILC_32_TO_PTR(id_type),
silc_idcache_destructor, NULL, TRUE);
cache->name_table = silc_hash_table_alloc(count, silc_hash_string, NULL,
silc_hash_string_compare, NULL,
/*
- sftp_fs_memory.c
+ sftp_fs_memory.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 Pekka Riikonen
+ Copyright (C) 2001 - 2004 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
int i;
/* Must be both write and exec permissions */
- if (check_perm &&
- !((dir->perm & SILC_SFTP_FS_PERM_WRITE) &&
+ if (check_perm &&
+ !((dir->perm & SILC_SFTP_FS_PERM_WRITE) &&
(dir->perm & SILC_SFTP_FS_PERM_EXEC)))
return FALSE;
return TRUE;
}
-/* Finds first occurence of entry named `name' under the directory `dir'.
+/* Finds first occurence of entry named `name' under the directory `dir'.
This does not check subdirectories recursively. */
static MemFSEntry mem_find_entry(MemFSEntry dir, const char *name,
if (!filename)
return FALSE;
- return mem_del_entry_name(dir ? dir : memfs->root, filename,
+ return mem_del_entry_name(dir ? dir : memfs->root, filename,
strlen(filename), FALSE);
}
return data;
}
-void mem_open(void *context, SilcSFTP sftp,
+void mem_open(void *context, SilcSFTP sftp,
const char *filename,
SilcSFTPFileOperation pflags,
SilcSFTPAttributes attrs,
if (entry->directory || !entry->data) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
/* Check for reading */
- if ((pflags & SILC_SFTP_FXF_READ) &&
+ if ((pflags & SILC_SFTP_FXF_READ) &&
!(entry->perm & SILC_SFTP_FS_PERM_READ)) {
- (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
callback_context);
return;
- }
+ }
/* Check for writing */
- if (((pflags & SILC_SFTP_FXF_WRITE) || (pflags & SILC_SFTP_FXF_APPEND)) &&
+ if (((pflags & SILC_SFTP_FXF_WRITE) || (pflags & SILC_SFTP_FXF_APPEND)) &&
!(entry->perm & SILC_SFTP_FS_PERM_WRITE)) {
- (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
callback_context);
return;
}
flags |= O_APPEND;
/* Attempt to open the file for real. */
- fd = silc_file_open_mode(entry->data + 7, flags,
+ fd = silc_file_open_mode(entry->data + 7, flags,
(attrs->flags & SILC_SFTP_ATTR_PERMISSIONS ?
attrs->permissions : 0600));
if (fd == -1) {
/* File opened, return handle */
handle = mem_create_handle(fs, fd, entry);
if (handle)
- (*callback)(sftp, SILC_SFTP_STATUS_OK, (SilcSFTPHandle)handle,
+ (*callback)(sftp, SILC_SFTP_STATUS_OK, (SilcSFTPHandle)handle,
callback_context);
else
- (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
callback_context);
}
if (h->fd != -1) {
ret = silc_file_close(h->fd);
if (ret == -1) {
- (*callback)(sftp, silc_sftp_map_errno(errno), NULL, NULL,
+ (*callback)(sftp, silc_sftp_map_errno(errno), NULL, NULL,
callback_context);
return;
}
void mem_read(void *context, SilcSFTP sftp,
SilcSFTPHandle handle,
- SilcUInt64 offset,
+ SilcUInt64 offset,
SilcUInt32 len,
SilcSFTPDataCallback callback,
void *callback_context)
}
/* Return data */
- (*callback)(sftp, SILC_SFTP_STATUS_OK, (const unsigned char *)data,
+ (*callback)(sftp, SILC_SFTP_STATUS_OK, (const unsigned char *)data,
ret, callback_context);
silc_free(data);
/* Attempt to write */
ret = silc_file_write(h->fd, data, data_len);
if (ret <= 0) {
- (*callback)(sftp, silc_sftp_map_errno(errno), NULL, NULL,
+ (*callback)(sftp, silc_sftp_map_errno(errno), NULL, NULL,
callback_context);
return;
}
void *callback_context)
{
/* Remove is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
callback_context);
}
void *callback_context)
{
/* Rename is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
callback_context);
}
void *callback_context)
{
/* Mkdir is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
callback_context);
}
void *callback_context)
{
/* Rmdir is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
callback_context);
}
if (!entry->directory) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
/* Must be read permissions to open a directory */
if (!(entry->perm & SILC_SFTP_FS_PERM_READ)) {
- (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
callback_context);
return;
}
/* Directory opened, return handle */
handle = mem_create_handle(fs, 0, entry);
if (handle)
- (*callback)(sftp, SILC_SFTP_STATUS_OK, (SilcSFTPHandle)handle,
+ (*callback)(sftp, SILC_SFTP_STATUS_OK, (SilcSFTPHandle)handle,
callback_context);
else
- (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_PERMISSION_DENIED, NULL,
callback_context);
}
((entry->perm & SILC_SFTP_FS_PERM_WRITE) ? 'w' : '-'),
((entry->perm & SILC_SFTP_FS_PERM_EXEC) ? 'x' : '-'),
(entry->directory ? (int)entry->entry_count : 1),
- filesize, date, entry->name,
- (entry->directory ? "/" :
+ (unsigned long long)filesize, date, entry->name,
+ (entry->directory ? "/" :
((entry->perm & SILC_SFTP_FS_PERM_EXEC) ? "*" : "")));
/* Add attributes */
if (entry->directory || !entry->data) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
/* Get real stat */
ret = stat(entry->data + 7, &stats);
if (!attrs) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
attrs->flags = (SILC_SFTP_ATTR_SIZE |
SILC_SFTP_ATTR_UIDGID |
SILC_SFTP_ATTR_ACMODTIME);
attrs->mtime = stats.st_mtime;
/* Return attributes */
- (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
+ (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
callback_context);
silc_sftp_attr_free(attrs);
if (entry->directory || !entry->data) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
/* Get real stat */
#ifndef SILC_WIN32
if (!attrs) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
attrs->flags = (SILC_SFTP_ATTR_SIZE |
SILC_SFTP_ATTR_UIDGID |
SILC_SFTP_ATTR_ACMODTIME);
attrs->mtime = stats.st_mtime;
/* Return attributes */
- (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
+ (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
callback_context);
silc_sftp_attr_free(attrs);
if (h->entry->directory || !h->entry->data) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
/* Get real stat */
ret = fstat(h->fd, &stats);
if (!attrs) {
(*callback)(sftp, SILC_SFTP_STATUS_FAILURE, NULL, callback_context);
return;
- }
+ }
attrs->flags = (SILC_SFTP_ATTR_SIZE |
SILC_SFTP_ATTR_UIDGID |
SILC_SFTP_ATTR_ACMODTIME);
attrs->mtime = stats.st_mtime;
/* Return attributes */
- (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
+ (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPAttributes)attrs,
callback_context);
silc_sftp_attr_free(attrs);
}
-
+
void mem_setstat(void *context, SilcSFTP sftp,
const char *path,
SilcSFTPAttributes attrs,
void *callback_context)
{
/* Setstat is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
callback_context);
}
void *callback_context)
{
/* Fsetstat is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
callback_context);
}
void *callback_context)
{
/* Symlink is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, NULL,
callback_context);
}
goto fail;
name->count = 1;
- (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPName)name,
+ (*callback)(sftp, SILC_SFTP_STATUS_OK, (const SilcSFTPName)name,
callback_context);
silc_sftp_name_free(name);
void *callback_context)
{
/* Extended is not supported */
- (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, 0,
+ (*callback)(sftp, SILC_SFTP_STATUS_OP_UNSUPPORTED, NULL, 0,
callback_context);
}
/*
- sftp_server.c
+ sftp_server.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 Pekka Riikonen
+ Copyright (C) 2001 - 2004 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
/* General routine to send SFTP packet to the SFTP client. */
static void silc_sftp_send_packet(SilcSFTPServer sftp,
- SilcSFTPPacket type,
+ SilcSFTPPacket type,
SilcUInt32 len, ...)
{
SilcBuffer tmp;
return;
sftp->packet = tmp;
- SILC_LOG_HEXDUMP(("SFTP packet to client"), sftp->packet->data,
+ SILC_LOG_HEXDUMP(("SFTP packet to client"), sftp->packet->data,
sftp->packet->len);
/* Send the packet */
void *context)
{
SilcSFTPServer server = (SilcSFTPServer)sftp;
- SilcUInt32 id = (SilcUInt32)context;
+ SilcUInt32 id = SILC_PTR_TO_32(context);
int mlen, llen;
SILC_LOG_DEBUG(("Status callback"));
SILC_LOG_DEBUG(("Request ID: %d", id));
-
+
if (!message)
message = "";
if (!language_tag)
void *context)
{
SilcSFTPServer server = (SilcSFTPServer)sftp;
- SilcUInt32 id = (SilcUInt32)context;
+ SilcUInt32 id = SILC_PTR_TO_32(context);
unsigned char *hdata;
SilcUInt32 hdata_len;
void *context)
{
SilcSFTPServer server = (SilcSFTPServer)sftp;
- SilcUInt32 id = (SilcUInt32)context;
+ SilcUInt32 id = SILC_PTR_TO_32(context);
SILC_LOG_DEBUG(("Data callback"));
SILC_LOG_DEBUG(("Request ID: %d", id));
void *context)
{
SilcSFTPServer server = (SilcSFTPServer)sftp;
- SilcUInt32 id = (SilcUInt32)context;
+ SilcUInt32 id = SILC_PTR_TO_32(context);
SilcBuffer namebuf;
SILC_LOG_DEBUG(("Name callback"));
void *context)
{
SilcSFTPServer server = (SilcSFTPServer)sftp;
- SilcUInt32 id = (SilcUInt32)context;
+ SilcUInt32 id = SILC_PTR_TO_32(context);
SilcBuffer attr_buf;
SILC_LOG_DEBUG(("Attr callback"));
void *context)
{
SilcSFTPServer server = (SilcSFTPServer)sftp;
- SilcUInt32 id = (SilcUInt32)context;
+ SilcUInt32 id = SILC_PTR_TO_32(context);
SILC_LOG_DEBUG(("Extended callback"));
SILC_LOG_DEBUG(("Request ID: %d", id));
void silc_sftp_server_set_monitor(SilcSFTP sftp,
SilcSFTPMonitors monitors,
- SilcSFTPMonitor monitor,
+ SilcSFTPMonitor monitor,
void *context)
{
SilcSFTPServer server = (SilcSFTPServer)sftp;
SILC_LOG_DEBUG(("Start"));
/* Parse the packet */
- type = silc_sftp_packet_decode(packet->buffer, (unsigned char **)&payload,
+ type = silc_sftp_packet_decode(packet->buffer, (unsigned char **)&payload,
&payload_len);
if (!type)
return;
SILC_STR_UI_INT(&id),
SILC_STR_UI32_STRING_ALLOC(&filename),
SILC_STR_UI_INT(&pflags),
- SILC_STR_UI32_NSTRING(&attr_buf,
+ SILC_STR_UI32_NSTRING(&attr_buf,
&attr_len),
SILC_STR_END);
if (ret < 0)
/* Open operation */
server->fs->fs->sftp_open(server->fs->fs_context, sftp, filename, pflags,
- attrs, silc_sftp_server_handle, (void *)id);
+ attrs, silc_sftp_server_handle,
+ SILC_32_TO_PTR(id));
silc_free(filename);
silc_sftp_attr_free(attrs);
ret = silc_buffer_unformat(&buf,
SILC_STR_UI_INT(&id),
- SILC_STR_UI32_NSTRING(&hdata,
+ SILC_STR_UI32_NSTRING(&hdata,
&hdata_len),
SILC_STR_END);
if (ret < 0)
/* Close operation */
server->fs->fs->sftp_close(server->fs->fs_context, sftp, handle,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
+
}
break;
ret = silc_buffer_unformat(&buf,
SILC_STR_UI_INT(&id),
- SILC_STR_UI32_NSTRING(&hdata,
+ SILC_STR_UI32_NSTRING(&hdata,
&hdata_len),
SILC_STR_UI_INT64(&offset),
SILC_STR_UI_INT(&len),
}
/* Read operation */
- server->fs->fs->sftp_read(server->fs->fs_context, sftp,
+ server->fs->fs->sftp_read(server->fs->fs_context, sftp,
handle, offset, len,
- silc_sftp_server_data, (void *)id);
+ silc_sftp_server_data, SILC_32_TO_PTR(id));
}
break;
ret = silc_buffer_unformat(&buf,
SILC_STR_UI_INT(&id),
- SILC_STR_UI32_NSTRING(&hdata,
+ SILC_STR_UI32_NSTRING(&hdata,
&hdata_len),
SILC_STR_UI_INT64(&offset),
- SILC_STR_UI32_NSTRING(&data,
+ SILC_STR_UI32_NSTRING(&data,
&data_len),
SILC_STR_END);
if (ret < 0)
}
/* Write operation */
- server->fs->fs->sftp_write(server->fs->fs_context, sftp, handle, offset,
+ server->fs->fs->sftp_write(server->fs->fs_context, sftp, handle, offset,
(const unsigned char *)data, data_len,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
}
break;
/* Remove operation */
server->fs->fs->sftp_remove(server->fs->fs_context, sftp, filename,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
silc_free(filename);
}
}
/* Rename operation */
- server->fs->fs->sftp_rename(server->fs->fs_context, sftp,
+ server->fs->fs->sftp_rename(server->fs->fs_context, sftp,
filename, newname,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
silc_free(filename);
silc_free(newname);
/* Mkdir operation */
server->fs->fs->sftp_mkdir(server->fs->fs_context, sftp, path, attrs,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
silc_sftp_attr_free(attrs);
silc_free(path);
/* Rmdir operation */
server->fs->fs->sftp_rmdir(server->fs->fs_context, sftp, path,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
silc_free(path);
}
/* Opendir operation */
server->fs->fs->sftp_opendir(server->fs->fs_context, sftp, path,
- silc_sftp_server_handle, (void *)id);
+ silc_sftp_server_handle, SILC_32_TO_PTR(id));
silc_free(path);
}
ret = silc_buffer_unformat(&buf,
SILC_STR_UI_INT(&id),
- SILC_STR_UI32_NSTRING(&hdata,
+ SILC_STR_UI32_NSTRING(&hdata,
&hdata_len),
SILC_STR_END);
if (ret < 0)
/* Readdir operation */
server->fs->fs->sftp_readdir(server->fs->fs_context, sftp, handle,
- silc_sftp_server_name, (void *)id);
+ silc_sftp_server_name, SILC_32_TO_PTR(id));
}
break;
/* Stat operation */
server->fs->fs->sftp_stat(server->fs->fs_context, sftp, path,
- silc_sftp_server_attr, (void *)id);
+ silc_sftp_server_attr, SILC_32_TO_PTR(id));
silc_free(path);
}
/* Lstat operation */
server->fs->fs->sftp_lstat(server->fs->fs_context, sftp, path,
- silc_sftp_server_attr, (void *)id);
+ silc_sftp_server_attr, SILC_32_TO_PTR(id));
silc_free(path);
}
ret = silc_buffer_unformat(&buf,
SILC_STR_UI_INT(&id),
- SILC_STR_UI32_NSTRING(&hdata,
+ SILC_STR_UI32_NSTRING(&hdata,
&hdata_len),
SILC_STR_END);
if (ret < 0)
/* Fstat operation */
server->fs->fs->sftp_fstat(server->fs->fs_context, sftp, handle,
- silc_sftp_server_attr, (void *)id);
+ silc_sftp_server_attr, SILC_32_TO_PTR(id));
}
break;
/* Setstat operation */
server->fs->fs->sftp_setstat(server->fs->fs_context, sftp, path, attrs,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
silc_sftp_attr_free(attrs);
silc_free(path);
ret = silc_buffer_unformat(&buf,
SILC_STR_UI_INT(&id),
- SILC_STR_UI32_NSTRING(&hdata,
+ SILC_STR_UI32_NSTRING(&hdata,
&hdata_len),
SILC_STR_UI32_NSTRING(&attr_buf,
&attr_len),
}
/* Fsetstat operation */
- server->fs->fs->sftp_fsetstat(server->fs->fs_context, sftp,
+ server->fs->fs->sftp_fsetstat(server->fs->fs_context, sftp,
handle, attrs,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status,
+ SILC_32_TO_PTR(id));
silc_sftp_attr_free(attrs);
}
/* Readlink operation */
server->fs->fs->sftp_readlink(server->fs->fs_context, sftp, path,
- silc_sftp_server_name, (void *)id);
+ silc_sftp_server_name, SILC_32_TO_PTR(id));
silc_free(path);
}
/* Symlink operation */
server->fs->fs->sftp_symlink(server->fs->fs_context, sftp, path, target,
- silc_sftp_server_status, (void *)id);
+ silc_sftp_server_status, SILC_32_TO_PTR(id));
silc_free(path);
silc_free(target);
/* Realpath operation */
server->fs->fs->sftp_realpath(server->fs->fs_context, sftp, path,
- silc_sftp_server_name, (void *)id);
+ silc_sftp_server_name, SILC_32_TO_PTR(id));
silc_free(path);
}
}
/* Extended operation */
- server->fs->fs->sftp_extended(server->fs->fs_context, sftp,
+ server->fs->fs->sftp_extended(server->fs->fs_context, sftp,
request, data, data_len,
- silc_sftp_server_extended, (void *)id);
+ silc_sftp_server_extended,
+ SILC_32_TO_PTR(id));
silc_free(request);
}
Author: Giovanni Giacobbi <giovanni@giacobbi.net>
- Copyright (C) 1997 - 2002 Pekka Riikonen
+ Copyright (C) 1997 - 2004 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
/* It's too big */
fprintf(log->fp, "[%s] [%s] Cycling log file, over max "
"logsize (%lu kilobytes)\n",
- silc_get_time(0), log->typename, log->maxsize / 1024);
+ silc_get_time(0), log->typename, (unsigned long)log->maxsize / 1024);
fflush(log->fp);
fclose(log->fp);
memset(newname, 0, sizeof(newname));
if (silc_log_scheduled)
return TRUE;
- /* Add schedule hook with a short delay to make sure we'll use
+ /* Add schedule hook with a short delay to make sure we'll use
right delay */
silc_schedule_task_add(scheduler, 0, silc_log_fflush_callback,
(void *) scheduler, 10, 0,
/*
- silctypes.h
+ silctypes.h
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2002 Pekka Riikonen
+ Copyright (C) 2002 - 2004 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
(((SilcUInt32)(l) & (SilcUInt32)0xFF000000UL) >> 24))
/***/
+/****d* silcutil/SILCTypes/SILC_PTR_TO_32
+ *
+ * NAME
+ *
+ * #define SILC_PTR_TO_32 ...
+ *
+ * DESCRIPTION
+ *
+ * Type casts a pointer's value into a 32-bit integer. Use this to
+ * avoid compiler warnings when type casting pointers to integers
+ * of different size.
+ *
+ * SOURCE
+ */
+#if SILC_SIZEOF_VOID_P < 8
+#define SILC_PTR_TO_32(_ptr__) ((SilcUInt32)(_ptr__))
+#else
+#define SILC_PTR_TO_32(_ptr__) \
+ ((SilcUInt32)((SilcUInt64)(_ptr__) & (SilcUInt32)0xFFFFFFFFUL))
+#endif
+/***/
+
+/****d* silcutil/SILCTypes/SILC_PTR_TO_64
+ *
+ * NAME
+ *
+ * #define SILC_PTR_TO_64 ...
+ *
+ * DESCRIPTION
+ *
+ * Type casts a pointer's value into a 64-bit integer. Use this to
+ * avoid compiler warnings when type casting pointers to integers
+ * of different size.
+ *
+ * SOURCE
+ */
+#if SILC_SIZEOF_VOID_P < 8
+#define SILC_PTR_TO_64(_ptr__) ((SilcUInt64)((SilcUInt32)(_ptr__)))
+#else
+#define SILC_PTR_TO_64(_ptr__) \
+ ((SilcUInt64)((SilcUInt64)(_ptr__) & (SilcUInt32)0xFFFFFFFFUL))
+#endif
+/***/
+
+/****d* silcutil/SILCTypes/SILC_32_TO_PTR
+ *
+ * NAME
+ *
+ * #define SILC_PTR_TO_32 ...
+ *
+ * DESCRIPTION
+ *
+ * Type casts a 32-bit integer value into a pointer. Use this to
+ * avoid compiler warnings when type casting integers to pointers of
+ * different size.
+ *
+ * SOURCE
+ */
+#if SILC_SIZEOF_VOID_P < 8
+#define SILC_32_TO_PTR(_ival__) ((void *)((SilcUInt32)(_ival__)))
+#else
+#define SILC_32_TO_PTR(_ival__) ((void *)((SilcUInt64)(_ival__)))
+#endif
+/***/
+
+/****d* silcutil/SILCTypes/SILC_64_TO_PTR
+ *
+ * NAME
+ *
+ * #define SILC_PTR_TO_64 ...
+ *
+ * DESCRIPTION
+ *
+ * Type casts a 64-bit integer value into a pointer. Use this to
+ * avoid compiler warnings when type casting integers to pointers of
+ * different size.
+ *
+ * SOURCE
+ */
+#if SILC_SIZEOF_VOID_P < 8
+#define SILC_64_TO_PTR(_ival__) \
+ ((void *)((SilcUInt32)((SilcUInt64)(_ival__) & (SilcUInt32)0xFFFFFFFFUL)))
+#else
+#define SILC_64_TO_PTR(_ival__) ((void *)((SilcUInt64)(_ival__)))
+#endif
+/***/
+
#endif /* SILCTYPES_H */
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2003 Pekka Riikonen
+ Copyright (C) 1997 - 2004 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
SilcUInt32 silc_hash_ptr(void *key, void *user_context)
{
- return (SilcUInt32)key;
+ return SILC_PTR_TO_32(key);
}
/* Hash a ID. The `user_context' is the ID type. */
SilcUInt32 silc_hash_id(void *key, void *user_context)
{
- SilcIdType id_type = (SilcIdType)(SilcUInt32)user_context;
+ SilcIdType id_type = (SilcIdType)SILC_PTR_TO_32(user_context);
SilcUInt32 h = 0;
int i;
SilcUInt32 silc_hash_data(void *key, void *user_context)
{
- SilcUInt32 len = (SilcUInt32)user_context, h = 0;
+ SilcUInt32 len = SILC_PTR_TO_32(user_context), h = 0;
unsigned char *data = (unsigned char *)key;
int i;
SilcPublicKey pk = (SilcPublicKey)key;
return (pk->len + silc_hash_string(pk->name, NULL) +
silc_hash_string(pk->identifier, NULL) +
- silc_hash_data(pk->pk, (void *)pk->pk_len));
+ silc_hash_data(pk->pk, SILC_32_TO_PTR(pk->pk_len)));
}
/* Compares two strings. It may be used as SilcHashTable comparison
bool silc_hash_id_compare(void *key1, void *key2, void *user_context)
{
- SilcIdType id_type = (SilcIdType)(SilcUInt32)user_context;
+ SilcIdType id_type = (SilcIdType)SILC_PTR_TO_32(user_context);
return (id_type == SILC_ID_CLIENT ?
SILC_ID_COMPARE_HASH((SilcClientID *)key1, (SilcClientID *)key2) :
SILC_ID_COMPARE_TYPE(key1, key2, id_type));
bool silc_hash_data_compare(void *key1, void *key2, void *user_context)
{
- SilcUInt32 len = (SilcUInt32)user_context;
+ SilcUInt32 len = SILC_PTR_TO_32(user_context);
return !memcmp(key1, key2, len);
}