Enlightenment CVS committal Author : chaos Project : e17 Module : apps/evfs
Dir : e17/apps/evfs/src/lib Modified Files: Makefile.am evfs_commands.c libevfs.c Log Message: Phase 1 of EvfsIO rewrite/cleanup: * evfs_filereference -> EvfsFilereference * evfs_event -> EvfsEvent/hierarchy * Simplified IO model for EET comms client<->server * More sane accessor functions for command files * More logical concatenation of structs to serve multiple purposes * Speed improvements =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/lib/Makefile.am,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- Makefile.am 16 Jul 2007 13:25:22 -0000 1.21 +++ Makefile.am 16 Aug 2007 11:31:17 -0000 1.22 @@ -34,6 +34,7 @@ $(top_srcdir)/src/common/evfs_vfolder.c \ $(top_srcdir)/src/common/evfs_misc.c \ $(top_srcdir)/src/common/evfs_common.c \ + $(top_srcdir)/src/common/evfs_command.c \ $(top_srcdir)/src/bin/evfs_metadata.c \ $(top_srcdir)/src/bin/evfs_metadata_db.c \ $(top_srcdir)/src/common/evfs_server.c \ =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/lib/evfs_commands.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -3 -r1.39 -r1.40 --- evfs_commands.c 13 Aug 2007 03:05:21 -0000 1.39 +++ evfs_commands.c 16 Aug 2007 11:31:17 -0000 1.40 @@ -1,7 +1,7 @@ #include "evfs.h" long -evfs_monitor_add(evfs_connection * conn, evfs_filereference * ref) +evfs_monitor_add(evfs_connection * conn, EvfsFilereference * ref) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; @@ -9,13 +9,11 @@ /*printf("Adding a monitor on: '%s' using '%s'\n", ref->path, ref->plugin_uri); */ command->type = EVFS_CMD_STARTMON_FILE; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *)); - command->file_command.files[0] = ref; + command->file_command->files = evas_list_append( command->file_command->files, ref); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; @@ -23,152 +21,132 @@ } long -evfs_monitor_remove(evfs_connection * conn, evfs_filereference * ref) +evfs_monitor_remove(evfs_connection * conn, EvfsFilereference * ref) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_STOPMON_FILE; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *)); - command->file_command.files[0] = ref; - + command->file_command->files = evas_list_append( command->file_command->files, ref); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_file_remove(evfs_connection * conn, evfs_filereference * ref) +evfs_client_file_remove(evfs_connection * conn, EvfsFilereference * ref) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_REMOVE_FILE; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *)); - command->file_command.files[0] = ref; + command->file_command->files = evas_list_append( command->file_command->files, ref); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_file_rename(evfs_connection * conn, evfs_filereference * from, - evfs_filereference * to) +evfs_client_file_rename(evfs_connection * conn, EvfsFilereference * from, + EvfsFilereference * to) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_RENAME_FILE; - command->file_command.num_files = 2; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 2); - command->file_command.files[0] = from; - command->file_command.files[1] = to; + command->file_command->num_files = 2; + command->file_command->files = evas_list_append( command->file_command->files, from); + command->file_command->files = evas_list_append( command->file_command->files, to); evfs_write_command(conn, command); - free(command->file_command.files); - + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_file_stat(evfs_connection * conn, evfs_filereference * file) +evfs_client_file_stat(evfs_connection * conn, EvfsFilereference * file) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_FILE_STAT; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; + command->file_command->files = evas_list_append( command->file_command->files, file); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_dir_list(evfs_connection * conn, evfs_filereference * file) +evfs_client_dir_list(evfs_connection * conn, EvfsFilereference * file) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_LIST_DIR; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; - + command->file_command->files = evas_list_append( command->file_command->files, file); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_file_copy(evfs_connection * conn, evfs_filereference * from, - evfs_filereference * to) +evfs_client_file_copy(evfs_connection * conn, EvfsFilereference * from, + EvfsFilereference * to) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_FILE_COPY; - command->file_command.num_files = 2; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 2); - command->file_command.files[0] = from; - command->file_command.files[1] = to; - + command->file_command->files = evas_list_append( command->file_command->files, from); + command->file_command->files = evas_list_append( command->file_command->files, to); + evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_multi_file_command(evfs_connection * conn, Ecore_List* files, evfs_filereference* to, int type) +evfs_client_multi_file_command(evfs_connection * conn, Ecore_List* files, EvfsFilereference* to, int type) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; long count = 0; long cfile = 0; - evfs_filereference* ref; + EvfsFilereference* ref; count = ecore_list_count(files); command->type = type; - command->file_command.num_files = count+1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * (count+1)); ecore_list_first_goto(files); while ((ref = ecore_list_next(files))) { - command->file_command.files[cfile] = ref; - cfile++; + command->file_command->files = evas_list_append( command->file_command->files, ref); } - if (to) - command->file_command.files[cfile] = to; - else - command->file_command.num_files -= 1; + if (to) command->file_command->files = evas_list_append( command->file_command->files, to); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; @@ -178,14 +156,14 @@ long evfs_client_file_copy_multi(evfs_connection * conn, Ecore_List* files, - evfs_filereference* to) + EvfsFilereference* to) { return evfs_client_multi_file_command(conn,files,to, EVFS_CMD_FILE_COPY); } long evfs_client_file_move_multi(evfs_connection * conn, Ecore_List* files, - evfs_filereference* to) + EvfsFilereference* to) { return evfs_client_multi_file_command(conn,files,to, EVFS_CMD_FILE_MOVE); } @@ -197,48 +175,45 @@ } long -evfs_client_file_move(evfs_connection * conn, evfs_filereference * from, - evfs_filereference * to) +evfs_client_file_move(evfs_connection * conn, EvfsFilereference * from, + EvfsFilereference * to) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_FILE_MOVE; - command->file_command.num_files = 2; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 2); - command->file_command.files[0] = from; - command->file_command.files[1] = to; + command->file_command->files = evas_list_append( command->file_command->files, from); + command->file_command->files = evas_list_append( command->file_command->files, to); + evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_file_open(evfs_connection * conn, evfs_filereference * file) +evfs_client_file_open(evfs_connection * conn, EvfsFilereference * file) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_FILE_OPEN; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; + command->file_command->files = evas_list_append( command->file_command->files, file); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_file_read(evfs_connection * conn, evfs_filereference * file, +evfs_client_file_read(evfs_connection * conn, EvfsFilereference * file, int read_size) { evfs_command *command = evfs_client_command_new(); @@ -247,14 +222,12 @@ //printf("Reading a file..\n"); command->type = EVFS_CMD_FILE_READ; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; - command->file_command.extra = read_size; + command->file_command->files = evas_list_append( command->file_command->files, file); + command->file_command->extra = read_size; evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); @@ -263,7 +236,7 @@ long -evfs_client_directory_create(evfs_connection * conn, evfs_filereference * file) +evfs_client_directory_create(evfs_connection * conn, EvfsFilereference * file) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; @@ -271,13 +244,11 @@ //printf("Reading a file..\n"); command->type = EVFS_CMD_DIRECTORY_CREATE; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; + command->file_command->files = evas_list_append( command->file_command->files, file); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); @@ -311,21 +282,18 @@ long -evfs_client_metadata_retrieve(evfs_connection * conn, evfs_filereference* file ) +evfs_client_metadata_retrieve(evfs_connection * conn, EvfsFilereference* file ) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_METADATA_RETRIEVE; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; - + command->file_command->files = evas_list_append( command->file_command->files, file); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); @@ -335,23 +303,21 @@ long -evfs_client_metadata_string_file_set(evfs_connection * conn, evfs_filereference* file, char* key,char* value ) +evfs_client_metadata_string_file_set(evfs_connection * conn, EvfsFilereference* file, char* key,char* value ) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_METADATA_FILE_SET; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; - command->file_command.ref = key; - command->file_command.ref2 = value; + command->file_command->files = evas_list_append( command->file_command->files, file); + command->file_command->ref = key; + command->file_command->ref2 = value; evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); @@ -360,22 +326,20 @@ } long -evfs_client_metadata_string_file_get(evfs_connection * conn, evfs_filereference* file, char* key ) +evfs_client_metadata_string_file_get(evfs_connection * conn, EvfsFilereference* file, char* key ) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_METADATA_FILE_GET; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = file; - command->file_command.ref = key; + command->file_command->files = evas_list_append( command->file_command->files, file); + command->file_command->ref = key; evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); @@ -400,21 +364,19 @@ } long -evfs_client_metadata_group_file_add(evfs_connection * conn, evfs_filereference* ref, char* group) +evfs_client_metadata_group_file_add(evfs_connection * conn, EvfsFilereference* ref, char* group) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_METADATA_FILE_GROUP_ADD; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = ref; - command->file_command.ref = group; + command->file_command->files = evas_list_append( command->file_command->files, ref); + command->file_command->ref = group; evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; @@ -422,42 +384,38 @@ } long -evfs_client_metadata_group_file_remove(evfs_connection * conn, evfs_filereference* ref, char* group) +evfs_client_metadata_group_file_remove(evfs_connection * conn, EvfsFilereference* ref, char* group) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_METADATA_FILE_GROUP_REMOVE; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = ref; - command->file_command.ref = group; + command->file_command->files = evas_list_append( command->file_command->files, ref); + command->file_command->ref = group; evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); return id; } long -evfs_client_auth_send(evfs_connection* conn, evfs_filereference* ref, char* user, char* password) +evfs_client_auth_send(evfs_connection* conn, EvfsFilereference* ref, char* user, char* password) { evfs_command *command = evfs_client_command_new(); long id = command->client_identifier; command->type = EVFS_CMD_AUTH_RESPONSE; - command->file_command.num_files = 1; - command->file_command.files = malloc(sizeof(evfs_filereference *) * 1); - command->file_command.files[0] = ref; - command->file_command.files[0]->username = user; - command->file_command.files[0]->password = password; + ref->username = user; + ref->password = password; + command->file_command->files = evas_list_append( command->file_command->files, ref); evfs_write_command(conn, command); - free(command->file_command.files); + evas_list_free(command->file_command->files); free(command); =================================================================== RCS file: /cvs/e/e17/apps/evfs/src/lib/libevfs.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -3 -r1.53 -r1.54 --- libevfs.c 11 Aug 2007 10:39:03 -0000 1.53 +++ libevfs.c 16 Aug 2007 11:31:17 -0000 1.54 @@ -17,6 +17,7 @@ evfs_command* evfs_client_command_new() { evfs_command* command = NEW(evfs_command); + command->file_command = NEW(evfs_command_file); command->client_identifier = libevfs_next_command_id_get(); return command; @@ -68,7 +69,7 @@ { memcpy(&client->id, e->data, sizeof(unsigned long)); - /*printf("Assigned ID: %d\n", client->id);*/ + printf("Assigned ID: %d\n", client->id); } else { @@ -89,6 +90,7 @@ */ evfs_connection *conn = evfs_get_connection_for_id(e->ref); + EvfsEvent* event; if (conn) { @@ -97,26 +99,15 @@ e->ref_to, e->response, e->data, e->size); - if (conn->prog_event == NULL) - { - /*We haven't started an event yet - make a new one */ - conn->prog_event = NEW(evfs_event); - } - /*printf("Got client message: %d %d %d %d %d\n", e->major, e->minor, e->ref, e->ref_to, e->response);*/ - if (evfs_read_event(conn->prog_event, msg)) + if ( (event = evfs_read_event(msg))) { - /*True return == Event fully read */ - /*Execute callback if registered.. */ if (conn->callback_func) { - - evfs_event *ev = conn->prog_event; - - (*conn->callback_func) (ev, conn->obj); + (*conn->callback_func) (event, conn->obj); } else { @@ -125,7 +116,7 @@ } /*Now cleanup the event we send back */ - evfs_cleanup_event(conn->prog_event); + evfs_cleanup_event(event); conn->prog_event = NULL; /*Detach this event from the conn. Client is responsible for it now */ } @@ -167,7 +158,7 @@ } evfs_connection * -evfs_connect(void (*callback_func) (evfs_event *, void *), void *obj) +evfs_connect(void (*callback_func) (EvfsEvent *, void *), void *obj) { ecore_init(); ecore_ipc_init(); @@ -459,11 +450,11 @@ evfs_parse_uri(char* uri) { evfs_file_uri_path* path = NEW(evfs_file_uri_path); - evfs_filereference* ref; + EvfsFilereference* ref; ref = evfs_parse_uri_single(uri); if (ref) { - path->files = calloc(1, sizeof(evfs_filereference*)); + path->files = calloc(1, sizeof(EvfsFilereference*)); path->files[0] = ref; path->num_files = 1; } @@ -474,11 +465,11 @@ /*Function to parse a uri*/ /*We should rewrite this,use a proper parser*/ -evfs_filereference * +EvfsFilereference * evfs_parse_uri_single(char *uri) { evfs_uri_token *token; - evfs_filereference *ref = NULL, *new_ref = NULL, *root_ref = + EvfsFilereference *ref = NULL, *new_ref = NULL, *root_ref = NULL, *bottom_ref = NULL; Ecore_DList *tokens; @@ -496,7 +487,7 @@ start_uri_section: - new_ref = NEW(evfs_filereference); + new_ref = NEW(EvfsFilereference); if (!ref) { new_ref->parent = NULL; @@ -594,12 +585,12 @@ } char * -evfs_filereference_to_string(evfs_filereference * ref) +EvfsFilereference_to_string(EvfsFilereference * ref) { int length = 0; char *uri; Ecore_List *parent_list = ecore_list_new(); - evfs_filereference *parent; + EvfsFilereference *parent; ecore_list_prepend(parent_list, ref); length += strlen(ref->plugin_uri) + strlen("://"); ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs