/home/dko/projects/mobilec/trunk/src/agent_task.c

Go to the documentation of this file.
00001 /* SVN FILE INFO
00002  * $Revision: 174 $ : Last Committed Revision
00003  * $Date: 2008年06月24日 10:50:29 -0700 (2008年6月24日) $ : Last Committed Date */
00004 /*[
00005  * Copyright (c) 2007 Integration Engineering Laboratory
00006  University of California, Davis
00007  *
00008  * Permission to use, copy, and distribute this software and its
00009  * documentation for any purpose with or without fee is hereby granted,
00010  * provided that the above copyright notice appear in all copies and
00011  * that both that copyright notice and this permission notice appear
00012  * in supporting documentation.
00013  *
00014  * Permission to modify the software is granted, but not the right to
00015  * distribute the complete modified source code. Modifications are to
00016  * be distributed as patches to the released version. Permission to
00017  * distribute binaries produced by compiling modified sources is granted,
00018  * provided you
00019  * 1. distribute the corresponding source modifications from the
00020  * released version in the form of a patch file along with the binaries,
00021  * 2. add special version identification to distinguish your version
00022  * in addition to the base release version number,
00023  * 3. provide your name and address as the primary contact for the
00024  * support of your modified version, and
00025  * 4. retain our contact information in regard to use of the base
00026  * software.
00027  * Permission to distribute the released version of the source code along
00028  * with corresponding source modifications in the form of a patch file is
00029  * granted with same provisions 2 through 4 for binary distributions.
00030  *
00031  * This software is provided "as is" without express or implied warranty
00032  * to the extent permitted by applicable law.
00033 ]*/
00034 
00035 #include <stdio.h>
00036 #include <stdlib.h>
00037 #include <string.h>
00038 #include "include/agent_task.h"
00039 #include "include/mc_error.h"
00040 
00041 agent_task_p
00042 agent_task_New(void)
00043 {
00044 agent_task_p task;
00045 task = (agent_task_p)malloc(sizeof(agent_task_t));
00046 if(task == NULL) {
00047 fprintf(stderr, "Memory Error. %s:%d\n", __FILE__, __LINE__);
00048 } else {
00049 memset(task, 0, sizeof(agent_task_t)); 
00050 }
00051 task->agent_variable_list = agent_variable_list_New();
00052 
00053 task->saved_variables = NULL;
00054 task->num_saved_variables = 0;
00055 
00056 return task;
00057 }
00058 
00059 agent_task_p 
00060 agent_task_Copy(agent_task_p task)
00061 {
00062 agent_task_p cp_task;
00063 cp_task = (agent_task_p)malloc(sizeof(agent_task_t));
00064 
00065 cp_task->task_completed = task->task_completed;
00066 cp_task->number_of_elements = task->number_of_elements;
00067 cp_task->size_of_element_array = task->size_of_element_array;
00068 cp_task->persistent = task->persistent;
00069 cp_task->init_agent_status = task->init_agent_status;
00070 
00071 cp_task->var_name = malloc
00072 (
00073 sizeof(char) * 
00074 (strlen(task->var_name) + 1)
00075 );
00076 strcpy(cp_task->var_name, task->var_name);
00077 
00078 cp_task->server_name = malloc
00079 (
00080 sizeof(char) * 
00081 (strlen(task->server_name) + 1)
00082 );
00083 strcpy(cp_task->server_name, task->server_name);
00084 
00085 if (task->code_id != NULL) {
00086 cp_task->code_id = malloc
00087 (
00088 sizeof(char) * 
00089 (strlen(task->code_id) + 1)
00090 );
00091 strcpy(cp_task->code_id, task->code_id);
00092 } else {
00093 cp_task->code_id = NULL;
00094 }
00095 
00096 cp_task->agent_return_data = NULL;
00097 
00098 return cp_task;
00099 }
00100 
00101 int
00102 agent_task_Destroy( agent_task_p agent_task )
00103 {
00104 int i;
00105 if(agent_task == NULL) {
00106 return MC_SUCCESS;
00107 }
00108 if (agent_task->var_name != NULL) {
00109 free(agent_task->var_name);
00110 }
00111 if (agent_task->server_name != NULL) {
00112 free(agent_task->server_name);
00113 }
00114 if (agent_task->code_id != NULL) {
00115 free(agent_task->code_id);
00116 }
00117 
00118 agent_variable_list_Destroy(agent_task->agent_variable_list);
00119 
00120 if(agent_task->saved_variables != NULL) {
00121 for(i = 0; agent_task->saved_variables[i] != NULL; i++) {
00122 free(agent_task->saved_variables[i]);
00123 }
00124 free(agent_task->saved_variables);
00125 }
00126 
00127 interpreter_variable_data_Destroy(agent_task->agent_return_data);
00128 
00129 free(agent_task);
00130 
00131 return MC_SUCCESS;
00132 }
00133 

Generated on Tue Oct 28 17:03:22 2008 for Mobile-C by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /