• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

/home/dko/Projects/mobilec/src/agent_task.c

Go to the documentation of this file.
00001 /* SVN FILE INFO
00002  * $Revision: 517 $ : Last Committed Revision
00003  * $Date: 2010-06-11 12:06:47 -0700 (Fri, 11 Jun 2010) $ : 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 #ifndef _WIN32
00036 #include "config.h"
00037 #else
00038 #include "winconfig.h"
00039 #endif
00040 
00041 #include <stdio.h>
00042 #include <stdlib.h>
00043 #include <string.h>
00044 #include "include/agent_task.h"
00045 #include "include/mc_error.h"
00046 
00047 agent_task_p
00048 agent_task_New(void)
00049 {
00050   agent_task_p task;
00051   task = (agent_task_p)malloc(sizeof(agent_task_t));
00052   if(task == NULL) {
00053     fprintf(stderr, "Memory Error. %s:%d\n", __FILE__, __LINE__);
00054   } else {
00055     memset(task, 0, sizeof(agent_task_t)); 
00056   }
00057   task->agent_variable_list = agent_variable_list_New();
00058 
00059   task->saved_variables = NULL;
00060   task->num_saved_variables = 0;
00061 
00062   return task;
00063 }
00064 
00065 agent_task_p 
00066 agent_task_Copy(agent_task_p task)
00067 {
00068         int i;
00069         interpreter_variable_data_t* interp_data;
00070         agent_task_p cp_task;
00071         cp_task = (agent_task_p)malloc(sizeof(agent_task_t));
00072 
00073         cp_task->number_of_elements = task->number_of_elements;
00074         cp_task->size_of_element_array = task->size_of_element_array;
00075         cp_task->persistent = task->persistent;
00076         cp_task->init_agent_status = task->init_agent_status;
00077 
00078         cp_task->var_name = (char*)malloc
00079                 (
00080                  sizeof(char) * 
00081                  (strlen(task->var_name) + 1)
00082                 );
00083         strcpy(cp_task->var_name, task->var_name);
00084 
00085         cp_task->server_name = (char*)malloc
00086                 (
00087                  sizeof(char) * 
00088                  (strlen(task->server_name) + 1)
00089                 );
00090         strcpy(cp_task->server_name, task->server_name);
00091 
00092         if (task->code_id != NULL) {
00093                 cp_task->code_id = (char*)malloc
00094                         (
00095                          sizeof(char) * 
00096                          (strlen(task->code_id) + 1)
00097                         );
00098                 strcpy(cp_task->code_id, task->code_id);
00099         } else {
00100                 cp_task->code_id = NULL;
00101         }
00102 
00103         if(task->agent_return_data != NULL) {
00104                 cp_task->agent_return_data = interpreter_variable_data_Copy(task->agent_return_data);
00105         }
00106 
00107         /* Copy the agent variable list */
00108         cp_task->agent_variable_list = agent_variable_list_New();
00109         for(i = 0; i < task->agent_variable_list->size; i++) {
00110                 interp_data = (interpreter_variable_data_t*)ListSearch(
00111                                 (list_p)task->agent_variable_list,
00112                                 i );
00113                 if (interp_data == NULL) { continue; }
00114                 interp_data = interpreter_variable_data_Copy(interp_data);
00115                 ListAdd(
00116                                 (list_p)cp_task->agent_variable_list,
00117                                 interp_data
00118                                 );
00119         }
00120 
00121         cp_task->saved_variables = (char**)malloc(sizeof(char*) * (task->num_saved_variables+1));
00122         for(i = 0; i < task->num_saved_variables; i++) {
00123                 cp_task->saved_variables[i] = strdup(task->s;]wq{	yM]"]޼Uܛw~^ߗ/w|_)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