コード例 #1
0
ファイル: slstd.c プロジェクト: ebichu/dd-wrt
int SLang_run_hooks (SLFUTURE_CONST char *hook, unsigned int num_args, ...)
{
   unsigned int i;
   va_list ap;

   if (SLang_get_error ())
     return -1;

   if (0 == SLang_is_defined (hook))
     return 0;

   (void) SLang_start_arg_list ();
   va_start (ap, num_args);
   for (i = 0; i < num_args; i++)
     {
	char *arg;

	arg = va_arg (ap, char *);
	if (-1 == SLang_push_string (arg))
	  break;
     }
   va_end (ap);
   (void) SLang_end_arg_list ();

   if (_pSLang_Error) return -1;
   return SLang_execute_function (hook);
}
コード例 #2
0
static int apply_line_modifier (Model_t *m, Model_Info_Type *info, DB_line_t *line, double *emis) /*{{{*/
{
   Plasma_State_Type lm_state;

   lm_state.temperature = m->temperature;
   lm_state.ndensity = m->density;

   SLang_start_arg_list ();
   SLang_push_array (info->line_emis_modifier_params, 0);
   SLang_push_int (line->indx);
   if (-1 == SLang_push_cstruct ((VOID_STAR)&lm_state, Plasma_State_Layout))
     return -1;
   SLang_push_double (*emis);
   if (info->line_emis_modifier_args != NULL)
     isis_push_args (info->line_emis_modifier_args);

   if (info->line_emis_modifier_qualifiers == NULL)
     {
        SLang_end_arg_list ();

        if (-1 == SLexecute_function (info->line_emis_modifier))
          return -1;
     }
   else
     {
        if ((-1 == SLang_push_function (info->line_emis_modifier))
            || (-1 == SLang_push_struct (info->line_emis_modifier_qualifiers)))
          return -1;

        SLang_end_arg_list ();

        if (-1 == SLang_execute_function ("_isis->do_eval_with_qualifiers"))
          return -1;
     }

   if (-1 == SLang_pop_double (emis))
     return -1;

   return 0;
}
コード例 #3
0
ファイル: slopt.c プロジェクト: hankem/ISIS
static int slfe_set_options (Isis_Fit_Engine_Type *e, Isis_Option_Type *opts) /*{{{*/
{
   SLang_Array_Type *sl_opts;
   SLindex_Type i, n;

   if (opts == NULL)
     return -1;

   n = opts->num_options;
   if (n == 0)
     return 0;

   if (NULL == (sl_opts = SLang_create_array (SLANG_STRING_TYPE, 1, NULL, &n, 1)))
     return -1;

   for (i = 0; i < n; i++)
     {
        int have_value = (opts->option_values[i] != 0);
        char *s;

        if (have_value)
          {
             s = isis_mkstrcat (opts->option_names[i], "=",
                                opts->option_values[i], NULL);
          }
        else s = opts->option_names[i];

        if ((s == NULL)
            || (-1 == SLang_set_array_element (sl_opts, &i, &s)))
          {
             SLang_free_array (sl_opts);
             if (have_value) ISIS_FREE(s);
          }

        if (have_value) ISIS_FREE(s);
     }

   SLang_start_arg_list();
   (void) SLang_push_array (sl_opts, 1);
   SLang_end_arg_list();

   /* converts options array to a struct */
   SLang_execute_function ("_isis->options_to_struct");

   /* this function then pops the struct off the stack */
   if (-1 == SLexecute_function (e->sl_set_options))
     {
        isis_vmesg (FAIL, I_FAILED, __FILE__, __LINE__,
                    "setting options for fit method '%s'",
                    e->engine_name);
        return -1;
     }

   if (SLang_get_error ())
     {
        isis_vmesg (FAIL, I_FAILED, __FILE__, __LINE__,
                    "S-Lang error while setting options for fit method '%s'",
                    e->engine_name);
        return -1;
     }

   return 0;
}
コード例 #4
0
static int call_ionpop_modifier (Model_t *m, Model_Info_Type *info, float *ionpop_new) /*{{{*/
{
   Plasma_State_Type s;
   SLang_Array_Type *sl_ionpop = NULL;
   int Z, q, status = -1;
   int n = ISIS_MAX_PROTON_NUMBER;

   s.temperature = m->temperature;
   s.ndensity = m->density;

   /* Float_Type[n,n] = ionpop_modifier (params, state, last_ionpop, [,args]) */
   SLang_start_arg_list ();
   SLang_push_array (info->ionpop_params, 0);
   if (-1 == SLang_push_cstruct ((VOID_STAR)&s, Plasma_State_Layout))
     {
        SLang_end_arg_list ();
        return -1;
     }
   SLang_push_array (m->last_ionpop, 0);
   if (info->ionpop_args != NULL)
     isis_push_args (info->ionpop_args);

   if (info->ionpop_qualifiers == NULL)
     {
        SLang_end_arg_list ();

        if (-1 == SLexecute_function (info->ionpop_modifier))
          return -1;
     }
   else
     {
        if ((-1 == SLang_push_function (info->ionpop_modifier))
            || (-1 == SLang_push_struct (info->ionpop_qualifiers)))
          return -1;

        SLang_end_arg_list ();

        if (-1 == SLang_execute_function ("_isis->do_eval_with_qualifiers"))
          return -1;
     }

   if (-1 == SLang_pop_array_of_type (&sl_ionpop, SLANG_FLOAT_TYPE))
     return -1;

   if ((sl_ionpop == NULL)
       || (sl_ionpop->num_dims != 2)
       || ((sl_ionpop->dims[0] != n+1) || (sl_ionpop->dims[1] != n+1)))
     {
        isis_vmesg (FAIL, I_ERROR, __FILE__, __LINE__,
                    "ionpop_modifier: invalid return value, expecting: Float_Type[n,n] with n=%d", n+1);
        goto return_status;
     }

   for (Z = 1; Z <= n; Z++)
     {
        for (q = 0; q <= Z; q++)
          {
             int i[2];
             i[0] = Z;  i[1] = q;
             if (-1 == SLang_get_array_element (sl_ionpop, i, &ionpop_new[Z*(n+1)+q]))
               goto return_status;
          }
     }

   SLang_free_array (m->last_ionpop);
   m->last_ionpop = sl_ionpop;

   status = 0;
return_status:
   if (status != 0)
     {
       SLang_free_array (sl_ionpop);
     }

   return status;
}