TUM-Logo

libRASCH

 

Home
 

General

About libRASCH/News
Design
Screen shots
Sample programs (with source code)
License
 

Download

libRASCH
Tools
 

Documentation

User
Developer
 

Resources

Mailing list
Supported Formats
Plugins
Status
Links
 
Contact
About this site
 
Last updated
Tue Mar 27 23:03:52 2007
libRASCH: eval_internal.c Source File

eval_internal.c

Go to the documentation of this file.
00001 
00010 /*----------------------------------------------------------------------------
00011  *
00012  * Copyright (C) 2004-2005, Raphael Schneider
00013  * See the file COPYING for information on usage and redistribution.
00014  *
00015  * $Id:  $
00016  *
00017  *--------------------------------------------------------------------------*/
00018 
00019 
00020 #include <string.h>
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 
00024 #define _LIBRASCH_BUILD
00025 #include <ra_eval.h>
00026 #include <ra_linked_list.h>
00027 
00028 
00029 int
00030 load_eval(meas_handle mh, const char *eval_file)
00031 {
00032         return 0;
00033 } /* load_eval() */
00034 
00035 
00044 int
00045 get_eval_file(meas_handle mh, char *f)
00046 {
00047         long dir = 0;
00048         value_handle vh;
00049         rec_handle rh;
00050 
00051         rh = ra_rec_get_first(mh, 0);
00052         vh = ra_value_malloc();
00053         if (ra_info_get(rh, RA_INFO_REC_GEN_DIR_L, vh) != 0)
00054         {
00055                 ra_value_free(vh);
00056                 return -1;
00057         }
00058         dir = ra_value_get_long(vh);
00059 
00060         if (ra_info_get(rh, RA_INFO_REC_GEN_PATH_C, vh) != 0)
00061         {
00062                 ra_value_free(vh);
00063                 return -1;
00064         }
00065 
00066         if (dir)
00067                 sprintf(f, "%s%ceval_ra.lre", ra_value_get_string(vh), SEPERATOR);
00068         else
00069                 sprintf(f, "%s.lre", ra_value_get_string(vh));
00070 
00071         ra_value_free(vh);
00072 
00073         return 0;
00074 } /* get_eval_file() */
00075 
00076 
00077 int
00078 eval_get_info(any_handle h, int info_id, value_handle vh)
00079 {
00080         int ret = 0;
00081         char a[MAX_ATTRIB_LEN];
00082         int get_attrib = 0;
00083         /* cast handle to all possible eval-structures; the function
00084            calling this function had done already a check that the info-id
00085            and the handle type fit */
00086         struct eval *e = (struct eval *)h;
00087         struct eval_class *c = (struct eval_class *)h;
00088         struct eval_property *p = (struct eval_property *)h;
00089         struct eval_summary *s = (struct eval_summary *)h;
00090         long number = ra_value_get_number(vh);
00091 
00092         switch (info_id)
00093         {
00094         case RA_INFO_EVAL_NAME_C:
00095         case RA_INFO_CLASS_NAME_C:
00096         case RA_INFO_PROP_NAME_C:
00097         case RA_INFO_SUM_NAME_C:
00098                 strncpy(a, "name", MAX_ATTRIB_LEN);
00099                 get_attrib = 1;
00100                 break;
00101         case RA_INFO_EVAL_DESC_C:
00102         case RA_INFO_CLASS_DESC_C:
00103         case RA_INFO_PROP_DESC_C:
00104         case RA_INFO_SUM_DESC_C:
00105                 strncpy(a, "description", MAX_ATTRIB_LEN);
00106                 get_attrib = 1;
00107                 break;
00108         case RA_INFO_EVAL_ADD_TS_C:
00109                 strncpy(a, "add-timestamp", MAX_ATTRIB_LEN);
00110                 get_attrib = 1;
00111                 break;
00112         case RA_INFO_EVAL_MODIFY_TS_C:
00113                 strncpy(a, "modify-timestamp", MAX_ATTRIB_LEN);
00114                 get_attrib = 1;
00115                 break;
00116         case RA_INFO_EVAL_USER_C:
00117                 strncpy(a, "add-user", MAX_ATTRIB_LEN);
00118                 get_attrib = 1;
00119                 break;
00120         case RA_INFO_EVAL_HOST_C:
00121                 strncpy(a, "add-host", MAX_ATTRIB_LEN);
00122                 get_attrib = 1;
00123                 break;
00124         case RA_INFO_EVAL_PROG_C:
00125                 strncpy(a, "add-program", MAX_ATTRIB_LEN);
00126                 get_attrib = 1;
00127                 break;
00128         case RA_INFO_EVAL_ORIGINAL_L:
00129                 if (e->original)
00130                         ra_value_set_long(vh, 1);
00131                 else
00132                         ra_value_set_long(vh, 0);
00133                 break;
00134         case RA_INFO_EVAL_DEFAULT_L:
00135                 if (e->def)
00136                         ra_value_set_long(vh, 1);
00137                 else
00138                         ra_value_set_long(vh, 0);
00139                 break;
00140         case RA_INFO_CLASS_ASCII_ID_C:
00141                 ra_value_set_string(vh, c->ascii_id);
00142                 break;
00143         case RA_INFO_CLASS_EV_NUM_L:
00144                 ra_value_set_long(vh, c->num_event);
00145                 break;
00146         case RA_INFO_PROP_ASCII_ID_C:
00147                 ra_value_set_string(vh, p->ascii_id);
00148                 break;
00149         case RA_INFO_PROP_VALTYPE_L:
00150                 ra_value_set_long(vh, p->value_type);
00151                 break;
00152         case RA_INFO_PROP_UNIT_C:
00153                 strncpy(a, "unit", MAX_ATTRIB_LEN);
00154                 get_attrib = 1;
00155                 break;
00156         case RA_INFO_PROP_HAS_MINMAX_L:
00157                 strncpy(a, "use-minmax", MAX_ATTRIB_LEN);
00158                 get_attrib = 1;
00159                 break;
00160         case RA_INFO_PROP_MIN_D:
00161                 strncpy(a, "min-value", MAX_ATTRIB_LEN);
00162                 get_attrib = 1;
00163                 break;
00164         case RA_INFO_PROP_MAX_D:
00165                 strncpy(a, "max-value", MAX_ATTRIB_LEN);
00166                 get_attrib = 1;
00167                 break;
00168         case RA_INFO_SUM_ASCII_ID_C:
00169                 ra_value_set_string(vh, s->ascii_id);
00170                 break;
00171         case RA_INFO_SUM_NUM_CH_L:
00172                 ra_value_set_long(vh, s->num_ch);
00173                 break;
00174         case RA_INFO_SUM_CH_NUM_L:
00175                 ra_value_set_long(vh, s->ch_desc[number].ch);
00176                 break;
00177         case RA_INFO_SUM_CH_FIDUCIAL_L:
00178                 ra_value_set_long(vh, s->ch_desc[number].fiducial_offset);
00179                 break;
00180         case RA_INFO_SUM_CH_NUM_DIM_L:
00181                 ra_value_set_long(vh, s->ch_desc[number].num_dim);
00182                 break;
00183         case RA_INFO_SUM_CH_DIM_UNIT_CA:
00184                 ra_value_set_string_array(vh, (const char **)s->ch_desc[number].unit, s->ch_desc[number].num_dim);
00185                 break;
00186         case RA_INFO_SUM_CH_DIM_NAME_CA:
00187                 ra_value_set_string_array(vh, (const char **)s->ch_desc[number].name, s->ch_desc[number].num_dim);
00188                 break;
00189                 break;
00190         default:
00191                 _ra_set_error(h, RA_ERR_UNKNOWN_INFO, "libRASCH");
00192                 ret = -1;
00193                 break;
00194         }
00195 
00196         if (get_attrib)
00197                 ret = ra_eval_attribute_get(h, a, vh);
00198 
00199         return ret;
00200 } /* eval_get_info() */
00201 
00202 
00203 int
00204 free_eval_infos(struct eval_info *ei)
00205 {
00206         struct eval_attribute *a;
00207         struct eval *e;
00208 
00209         a = ei->attribute;
00210         while (a)
00211         {
00212                 if (a->value)
00213                         ra_value_free(a->value);
00214                 ra_list_del((void **)&(ei->attribute), a);
00215                 a = ei->attribute;
00216         }
00217 
00218         while ((e = ei->evaluations))
00219         {
00220                 ra_eval_delete(e);
00221         }
00222 
00223         return 0;
00224 } /* free_eval_infos() */

Generated on Fri May 27 11:32:38 2005 for libRASCH by  doxygen 1.4.2