Use read rather than fread

2001-04-24  Bradford Hovinen  <hovinen@ximian.com>

	* location.c (location_store): Use read rather than fread

2001-04-23  Bradford Hovinen  <hovinen@ximian.com>

	* location.c (location_store): Block SIGPIPE
	(location_store): Fix off-by-one bug

	* archive.c (archive_get_current_location_id): Store a full
	snapshot of the system after the default location is created

	* location.c (run_backend_proc): Added parameter do_get to allow
	control of whether pipe is opened to read or write
	(store_snapshot_cb): Implement. Invokes the given backend with
	--get and stores the XML data
	(location_store_full_snapshot): Implement. Stores a complete
	snapshot with all backend data
	(subtract_xml_node): Assume all nodes are the same
	(location_store): Add string termination character
	(location_store): Only store data if any data were actually read

2001-04-22  Bradford Hovinen  <hovinen@ximian.com>

	* config-log.c (config_log_iterate): Use the correct data pointer
	to pass to the callback

	* location.c (location_new): Save the metadata for the newly
	created location right away

	* util.h: Defined DEBUG_MSG macro for debugging messages

	* archive.c (archive_unregister_location): Don't remove the
	location from the tree if the object is marked destroyed

2001-04-21  Bradford Hovinen  <hovinen@ximian.com>

	* archive.c (archive_destroy): Return if the archive was already
	destroyed

	* location.c (location_delete): Unregister the location before
	destroying it

	* config-log.c (config_log_delete): Set deleted flag
	(config_log_destroy): Only dump the log if the log is not marked
	deleted

	* location.c (location_delete): Check return value of rmdir

	* config-log.c (io_buffer_destroy): Call g_io_channel_close to
	close the GIOChannel
	(disconnect_socket): Force the removal of the source id from the
	main loop
	(config_log_destroy): Disconnect the socket after unloading, not
	before

	* location.c (location_delete): Remember to have a NULL at the end
	of arguments to g_strconcat ()

2001-04-22  Bradford Hovinen  <hovinen@ximian.com>

	* location-list.[ch]: Change to inherit GtkObject

	* location-manager-dialog.c (location_manager_dialog_destroy):
	Implement. Close and destroy all aggregated objects.
	(close_cb): Call gtk_object_destroy

2001-04-21  Bradford Hovinen  <hovinen@ximian.com>

	* location-manager-dialog.c (delete_location_cb): Don't let the
	user delete the default location
	(delete_ok_cb): Add some sanity checks to make sure the current
	location is set to something new if we delete it

	* location-list.c (location_list_select): Implement. Selectes the
	given location in the location list

	* location-manager-dialog.c (delete_ok_cb): Use correct semantics
	for callback
This commit is contained in:
Bradford Hovinen 2001-04-25 00:57:59 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent fda9cc2357
commit b38b466dc0
8 changed files with 192 additions and 59 deletions

View file

@ -83,6 +83,7 @@ struct _ConfigLogPrivate
IOBuffer *file_buffer;
char *filename;
gboolean deleted;
GList *log_data;
GList *first_old;
@ -287,8 +288,8 @@ config_log_destroy (GtkObject *object)
config_log = CONFIG_LOG (object);
do_unload (config_log, !config_log->p->deleted);
disconnect_socket (config_log);
do_unload (config_log, TRUE);
GTK_OBJECT_CLASS (parent_class)->destroy (GTK_OBJECT (config_log));
}
@ -351,6 +352,7 @@ config_log_delete (ConfigLog *config_log)
if (config_log->p->filename != NULL)
unlink (config_log->p->filename);
config_log->p->deleted = TRUE;
gtk_object_destroy (GTK_OBJECT (config_log));
}
@ -530,7 +532,7 @@ config_log_iterate (ConfigLog *config_log, ConfigLogIteratorCB callback,
while (node != NULL) {
entry = (ConfigLogEntry *) node->data;
if (callback (config_log, entry->id, entry->backend_id,
entry->date, node->data)) break;
entry->date, data)) break;
if (node->next == NULL)
node = load_log_entry (config_log, FALSE,
@ -957,8 +959,7 @@ write_log (IOBuffer *output, ConfigLogEntry *entry)
entry->date->tm_mon + 1, entry->date->tm_mday,
entry->date->tm_hour, entry->date->tm_min,
entry->date->tm_sec, entry->backend_id);
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
"%s (pid %d): Writing %s", __FUNCTION__, getpid (), str);
DEBUG_MSG ("Writing %s", str);
io_buffer_write (output, str);
g_free (str);
}
@ -971,6 +972,8 @@ dump_log (ConfigLog *config_log)
int out_fd;
IOBuffer *output;
DEBUG_MSG ("Enter");
g_return_if_fail (config_log != NULL);
g_return_if_fail (IS_CONFIG_LOG (config_log));
g_return_if_fail (config_log->p->location != NULL);
@ -1005,6 +1008,8 @@ dump_log (ConfigLog *config_log)
if (config_log->p->filename)
rename (filename_out, config_log->p->filename);
DEBUG_MSG ("Exit");
}
static gboolean
@ -1037,9 +1042,7 @@ connect_socket (ConfigLog *config_log)
(GIOFunc) socket_connect_cb,
config_log);
} else {
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
"%s (pid %d): Adding watch to listen for data\n",
__FUNCTION__, getpid ());
DEBUG_MSG ("Adding watch to listen for data");
config_log->p->input_id =
g_io_add_watch (config_log->p->socket_buffer->channel,
@ -1116,8 +1119,7 @@ bind_socket (ConfigLog *config_log, int fd, gboolean do_connect)
}
if (do_connect && !config_log->p->socket_owner) {
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
"Trying to connect to socket (pid %d)", getpid ());
DEBUG_MSG ("Trying to connect to socket");
if (!connect (fd, (struct sockaddr *) &name, SUN_LEN (&name)))
return TRUE;
@ -1154,6 +1156,8 @@ disconnect_socket (ConfigLog *config_log)
g_list_foreach (config_log->p->slaves,
(GFunc) slave_destroy, NULL);
g_source_remove (config_log->p->input_id);
if (config_log->p->socket_buffer != NULL)
io_buffer_destroy (config_log->p->socket_buffer);
}
@ -1166,8 +1170,7 @@ socket_connect_cb (GIOChannel *channel, GIOCondition condition,
struct sockaddr_un addr;
socklen_t len;
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Enter %s (pid %d)",
__FUNCTION__, getpid ());
DEBUG_MSG ("Enter");
g_return_val_if_fail (config_log != NULL, FALSE);
g_return_val_if_fail (IS_CONFIG_LOG (config_log), FALSE);
@ -1188,8 +1191,7 @@ socket_connect_cb (GIOChannel *channel, GIOCondition condition,
slave_new (config_log, fd));
}
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Exit %s (pid %d)",
__FUNCTION__, getpid ());
DEBUG_MSG ("Exit");
return TRUE;
}
@ -1204,8 +1206,7 @@ socket_data_cb (GIOChannel *channel, GIOCondition condition,
g_return_val_if_fail (config_log != NULL, FALSE);
g_return_val_if_fail (IS_CONFIG_LOG (config_log), FALSE);
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Enter %s (pid %d)",
__FUNCTION__, getpid ());
DEBUG_MSG ("Enter");
if (condition == G_IO_IN) {
load_log_entry (config_log, TRUE,
@ -1217,8 +1218,7 @@ socket_data_cb (GIOChannel *channel, GIOCondition condition,
return FALSE;
}
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Exit %s (pid %d)",
__FUNCTION__, getpid ());
DEBUG_MSG ("Exit");
return TRUE;
}
@ -1270,8 +1270,7 @@ static gboolean
slave_data_cb (GIOChannel *channel, GIOCondition condition,
Slave *slave)
{
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Enter %s (pid %d)",
__FUNCTION__, getpid ());
DEBUG_MSG ("Enter");
g_return_val_if_fail (slave != NULL, FALSE);
g_return_val_if_fail (slave->config_log != NULL, FALSE);
@ -1287,7 +1286,7 @@ slave_data_cb (GIOChannel *channel, GIOCondition condition,
slave_broadcast_data (slave, slave->config_log);
}
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Exit %s", __FUNCTION__);
DEBUG_MSG ("Exit");
return TRUE;
}
@ -1348,11 +1347,8 @@ io_buffer_new (GIOChannel *channel, gboolean from_socket)
static void
io_buffer_destroy (IOBuffer *buffer)
{
int fd;
fd = g_io_channel_unix_get_fd (buffer->channel);
g_io_channel_close (buffer->channel);
g_io_channel_unref (buffer->channel);
close (fd);
g_free (buffer);
}
@ -1426,9 +1422,8 @@ io_buffer_read_line (IOBuffer *buffer) {
start_ptr = buffer->read_ptr;
buffer->read_ptr = end_ptr + 1;
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
"%s (pid %d): Line read was %s; from_socket = %d",
__FUNCTION__, getpid (), start_ptr, buffer->from_socket);
DEBUG_MSG ("Line read was %s; from_socket = %d",
start_ptr, buffer->from_socket);
return start_ptr;
}