Esempio n. 1
0
static bool get_value(term_t t, clingo_symbol_t *val, int minus) {
    switch (PL_term_type(t)) {
    case PL_INTEGER: {
        int i;

        if (PL_get_integer(t, &i)) {
            clingo_symbol_create_number(i, val);
            return true;
        }
        return false;
    }
    case PL_ATOM: {
        char *s;
        size_t len;

        if (PL_get_nchars(t, &len, &s, CVT_ATOM | REP_UTF8 | CVT_EXCEPTION)) {
            return clingo_symbol_create_id(s, !minus, val); /* no sign */
        }
        return false;
    }
    case PL_STRING: {
        char *s;
        size_t len;

        if (PL_get_nchars(t, &len, &s, CVT_STRING | REP_UTF8 | CVT_EXCEPTION)) {
            return clingo_symbol_create_string(s, val);
        }
        return false;
    }
    case PL_TERM: {
        bool rc;
        term_t arg;
        atom_t name;
        size_t arity; /* TBD: -atom, #const */
        clingo_symbol_t *values = NULL;

        if (!(rc = get_name_arity(t, &name, &arity))) {
            clingo_set_error(clingo_error_runtime, "prolog error");
            goto out_term;
        }
        arg = PL_new_term_ref();

        if (name == ATOM_minus && arity == 1) {
            if (!(rc = get_value(arg, val, TRUE))) {
                goto out_term;
            }
        } else if (name == ATOM_hash && arity == 1) {
            atom_t a;

            _PL_get_arg(1, t, arg);
            if (!(rc = PL_get_atom_ex(arg, &a))) {
                clingo_set_error(clingo_error_runtime, "prolog error");
                goto out_term;
            }

            if (a == ATOM_inf) {
                clingo_symbol_create_infimum(val);
            } else if (a == ATOM_sup) {
                clingo_symbol_create_supremum(val);
            } else {
                rc = false;
                clingo_set_error(clingo_error_runtime, "bad value");
                goto out_term;
            }
        } else {
            const char *id = PL_atom_chars(name); /* TBD: errors */
            size_t i;

            if (!(values = malloc(sizeof(*values) * arity))) {
                rc = false;
                clingo_set_error(clingo_error_bad_alloc, "memory");
                goto out_term;
            }

            for (i = 0; i < arity; i++) {
                _PL_get_arg(i + 1, t, arg);
                if (!(rc = get_value(arg, &values[i], FALSE))) {
                    goto out_term;
                }
            }
            PL_reset_term_refs(arg);

            if (!(rc = clingo_symbol_create_function(id, values, arity, !minus,
                                                     val))) {
                goto out_term;
            }
        }
    out_term:
        if (values) {
            free(values);
        }
        return rc;
    }
    default:
        clingo_set_error(clingo_error_runtime, "bad value");
        return false;
    }
}
Esempio n. 2
0
int PitchScale::handle_event()
{
	plugin->config.scale = get_value();
	plugin->send_configure_change();
	return 1;
}
Esempio n. 3
0
static void sec_sysfs_cmd(struct synaptics_drv_data *data,
                          const char *str)
{
    int cmd = 0, cnt = 0;
    int buf_size = 0, i = 0;
    int ret = 0;
    int irq = gpio_to_irq(data->gpio);
    u8 *buf, *buf2, *buf3;
    u8 *tmp_str[7];
    u16 temp = 0;
    u32 param[2] = {0,};

    buf = kzalloc(strlen(str), GFP_KERNEL);
    buf2 = kzalloc(8, GFP_KERNEL);
    buf3 = kzalloc(8, GFP_KERNEL);
    memset(data->cmd_result, 0x0, sizeof(data->cmd_result));

    sscanf(str, "%s", buf);
    cmd = sec_sysfs_check_cmd(buf, param);

    tmp_str[cnt++] = buf;
    tmp_str[cnt++] = ":";

    printk(KERN_DEBUG
           "[TSP] %s : %u, %u\n",
           __func__,
           param[0], param[1]);

    if (CMD_STATUS_WAITING == data->cmd_status)
        data->cmd_status = CMD_STATUS_RUNNING;
    else
        data->cmd_status = CMD_STATUS_WAITING;

    disable_irq(irq);

    switch (cmd) {
    case CMD_LIST_FW_UPDATE:
        ret = sec_fw_cmd(data, param[0]);
        if (ret)
            tmp_str[cnt++] = "FAIL";
        else
            tmp_str[cnt++] = "PASS";
        break;

    case CMD_LIST_FW_VER_BIN:
        synaptics_fw_phone(data, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_FW_VER_IC:
        synaptics_fw_panel(data, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_CONFIG_VER:
        synaptics_fw_config(data, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_GET_THRESHOLD:
        temp = synaptics_get_threshold(data);
        sec_sysfs_numstr(temp, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_POWER_OFF:
        ret = data->pdata->set_power(false);
        if (ret)
            tmp_str[cnt++] = "FAIL";
        else
            tmp_str[cnt++] = "PASS";
        break;

    case CMD_LIST_POWER_ON:
        ret = data->pdata->set_power(true);
        if (ret)
            tmp_str[cnt++] = "FAIL";
        else
            tmp_str[cnt++] = "PASS";
        break;

    case CMD_LIST_VENDOR:
        tmp_str[cnt++] = "Synaptics";
        break;

    case CMD_LIST_IC_NAME:
        tmp_str[cnt++] = "S7301";
        break;

    case CMD_LIST_X_SIZE:
        sec_sysfs_numstr(data->x_line, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_Y_SIZE:
        sec_sysfs_numstr(data->y_line, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_READ_REF:
        synaptics_ts_write_data(data,
                                0xf0, 0x01);
        data->cmd_report_type = REPORT_TYPE_RAW_CAP;
        check_diagnostics_mode(data);
        synaptics_ts_write_data(data,
                                0xf0, 0x00);
        sec_sysfs_numstr(data->refer_min, buf2);
        tmp_str[cnt++] = buf2;
        tmp_str[cnt++] = ",";
        sec_sysfs_numstr(data->refer_max, buf3);
        tmp_str[cnt++] = buf3;
        break;

    case CMD_LIST_READ_RX:
        data->cmd_report_type = REPORT_TYPE_RX_TO_RX;
        check_diagnostics_mode(data);
        break;

    case CMD_LIST_READ_TX:
        data->cmd_report_type = REPORT_TYPE_TX_TO_TX;
        check_diagnostics_mode(data);
        break;

    case CMD_LIST_READ_TXG:
        data->cmd_report_type = REPORT_TYPE_TX_TO_GND;
        check_diagnostics_mode(data);
        break;

    case CMD_LIST_GET_REF:
        temp = get_value(data, param[0], param[1]);
        sec_sysfs_numstr(temp, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_GET_RX:
        temp = get_value(data, param[0], param[1]);
        sec_sysfs_numstr(temp, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_GET_TX:
        temp = get_value(data, param[0], param[1]);
        sec_sysfs_numstr(temp, buf2);
        tmp_str[cnt++] = buf2;
        break;

    case CMD_LIST_GET_TXG:
        temp = get_value(data, param[0], param[1]);
        sec_sysfs_numstr(temp, buf2);
        tmp_str[cnt++] = buf2;
        break;

    default:
        printk(KERN_DEBUG
               "[TSP] unkown mode : %s\n", buf);
        break;
    }

    enable_irq(irq);

    for (i = 0; i < cnt; i++) {
        if (buf_size < MAX_CMD_SIZE) {
            memcpy(&data->cmd_result[buf_size],
                   tmp_str[i], strlen(tmp_str[i]));
            buf_size += strlen(tmp_str[i]);
        } else
            break;
    }

    if (cmd == CMD_LIST_MAX)
        data->cmd_status = CMD_STATUS_FAIL;
    else
        data->cmd_status = CMD_STATUS_OK;

    kfree(buf);
    kfree(buf2);
    kfree(buf3);
}
Esempio n. 4
0
 operator T () const
 {
   return get_value();
 }
Esempio n. 5
0
int show$address(int mask) {
#ifdef __i386__
  int retlen;
  $DESCRIPTOR(p, "p1");
  char c[80];
  struct dsc$descriptor o;
  o.dsc$a_pointer=c;
  o.dsc$w_length=80;
  memset (c, 0, 80);
  int sts = cli$present(&p);
  if (sts&1) {
    sts = cli$get_value(&p, &o, &retlen);
    o.dsc$w_length=retlen;
  }

  long addr = strtol (c, 0, 16);
  long isnot_addr = addr;
  if (addr == 0) 
    sts = sda_find_addr (c, &addr);
  if ((sts&1)==0)
    return sts;
  long size = sizeof(long);
  struct _pcb * pcb;
  struct mm_struct mm;
  long page = addr & PAGE_MASK;
  pgd_t *pgd = 0, *pgd_k;
  pud_t *pud = 0, *pud_k;
  pmd_t *pmd = 0, *pmd_k;
  pte_t *pte = 0, *pte_k;
  long phys = 0;
  sda$getmemlong(ctl$gl_pcb, &pcb);
  sda$getmem(pcb->mm, &mm, sizeof (mm));
  pgd_k = pgd_offset (&mm, page);
  sda$getmemlong(pgd_k, &pgd);
  if (pgd_none_or_clear_bad(pgd))
    goto out;
  pud_k = pud_offset(pgd, page);
  sda$getmemlong(pud_k, &pud);
  if (pud_none_or_clear_bad(pud))
    goto out;
  pmd_k = pmd_offset(pud, page);
  sda$getmemlong(pmd_k, &pmd);
  if (pmd_none_or_clear_bad(pmd))
    goto out;
  pte_k = pte_offset(pmd, page);
  sda$getmemlong(pte_k, &pte);
  if (pte_none/*_or_clear_bad*/(*pte))
    goto out;
  phys = *(long *)pte & PAGE_MASK;
 out:
  printf("\t%lx is an xx address\n\n");
  printf("\tMapped by Level-4 PTE at: %lx : %lx\n", pte_k, *pte);
  printf("\tMapped by Level-3 PTE at: %lx : %lx\n", pmd_k, *pmd);
  printf("\tMapped by Level-2 PTE at: %lx : %lx\n", pud_k, *pud);
  printf("\tMapped by Level-1 PTE at: %lx : %lx\n", pgd_k, *pgd);
  printf("\tMapped by Level-0 PGD at: %lx\n", mm.pgd);

  // printf("\tAlso mapped in SPT window at: %lx\n\n", 0);

  printf("\tMapped to physical address %lx\n\n", phys);
#endif
}
void ConfigFmThs :: set_hybrd_list
(
    UINT fd
)
{
    signed char ret = FM_SUCCESS;
    char **keys = NULL;
    char **keys_cpy = NULL;
    char *key_value = NULL;
    char *freqs = NULL;
    unsigned int *freqs_array = NULL;
    signed char *sinrs_array = NULL;
    char *sinrs = NULL;
    int value;
    unsigned int freq_cnt = 0;
    unsigned int sinr_cnt = 0;
    FmPerformanceParams perf_params;
    struct NAME_MAP *found;

    ALOGE("Inside hybrid srch list\n");
    if(keyfile != NULL) {
       keys_cpy = keys = get_keys(keyfile, GRPS_MAP[2].name);
       if(keys != NULL) {
          while(*keys != NULL) {
              found = (NAME_MAP *)bsearch(*keys, HYBRD_SRCH_MAP,
                           MAX_HYBRID_SRCH_PARAMS, sizeof(NAME_MAP), compare_name);
              if(found != NULL) {
                 key_value = get_value(keyfile, GRPS_MAP[1].name, found->name);
                 if((key_value != NULL) && strcmp(key_value, "")) {
                     switch(found->num) {
                     case FREQ_LIST:
                          freqs = key_value;
                          break;
                     case SINR_LIST:
                          sinrs = key_value;
                          break;
                     default:
                          free(key_value);
                          break;
                     }
                 }
              }
              keys++;
          }
          free_strs(keys_cpy);
       }else {
          ALOGE("No of keys found is zero\n");
       }
    }else {
       ALOGE("key file is null\n");
    }

    freq_cnt = extract_comma_sep_freqs(freqs, &freqs_array, ",");
    sinr_cnt = extract_comma_sep_sinrs(sinrs, &sinrs_array, ",");

    if((freq_cnt == sinr_cnt) && (sinr_cnt > 0)) {
       perf_params.SetHybridSrchList(fd, freqs_array, sinrs_array, freq_cnt);
    }

    free(freqs);
    free(sinrs);
    free(freqs_array);
    free(sinrs_array);
}
void tpassword_box::set_value(const std::string& text) {
	ttext_box::set_value(text);
	real_value_ = get_value();
	ttext_box::set_value(std::string(get_text_length(real_value_), '*'));
}
Esempio n. 8
0
 void cGtkmmScrollBar::ScrollDown()
 {
   set_value(get_value() + step);
 }
Esempio n. 9
0
 void cGtkmmScrollBar::PageUp()
 {
   set_value(get_value() - page);
 }
Esempio n. 10
0
int SwapFramesOn::handle_event()
{
	plugin->config.on = get_value();
	plugin->send_configure_change();
	return 1;
}
Esempio n. 11
0
 void cGtkmmScrollBar::ScrollUp()
 {
   set_value(get_value() - step);
 }
Esempio n. 12
0
bool	is_error()	const throw()
{   return get_value() == NOT_FOUND
           || get_value() == BOGUS_REQUEST
           || get_value() == INTERNAL_ERROR;
}
Esempio n. 13
0
void apply_layout_parameters(   layout_attributes_t&     data,
                                const dictionary_t&      parameters)
{
    ADOBE_ONCE_INSTANCE(adobe_eve_evaluate);

    get_value(parameters, key_indent, data.indent_m);

    if (parameters.count(key_horizontal))
    {
        (*alignment_table_g)(   get_value(parameters, key_horizontal).cast<name_t>(),
                                data.slice_m[extents_slices_t::horizontal].alignment_m);
    }

    if (parameters.count(key_vertical))
    {
        (*alignment_table_g)(   get_value(parameters, key_vertical).cast<name_t>(),
                                data.slice_m[extents_slices_t::vertical].alignment_m);
    }
    
    // REVISIT (sparent) If we had named guides then named guide suppression would go here.
    
    if (parameters.count(key_guide_mask)) // an empty array would allow baselines out.
    {
        // Turn on all guides - then selectively suppress
        data.slice_m[extents_slices_t::vertical].suppress_m      = false;
        data.slice_m[extents_slices_t::horizontal].suppress_m    = false;
    
        array_t guide_mask(get_value(parameters, key_guide_mask).cast<array_t>());

        for (array_t::const_iterator iter(guide_mask.begin()), last(guide_mask.end());
                iter != last; ++iter)
        {
            if (iter->cast<name_t>() == key_guide_baseline)   data.slice_m[extents_slices_t::vertical].suppress_m = true;
            if (iter->cast<name_t>() == key_guide_label)      data.slice_m[extents_slices_t::horizontal].suppress_m = true;
        }
    }
    
    // REVISIT (sparent) : If we had named guides then named guide balancing would go here...
    
    /*
        Balanced guides must be supressed to avoid having them attach to outside guides which could
        overconstrain the system.
    */
    
    if (parameters.count(key_guide_balance))
    {
        data.slice_m[extents_slices_t::vertical].balance_m       = false;
        data.slice_m[extents_slices_t::horizontal].balance_m     = false;
    
        array_t guide_balance(get_value(parameters, key_guide_balance).cast<array_t>());

        for (array_t::const_iterator iter(guide_balance.begin()), last(guide_balance.end());
                iter != last; ++iter)
        {
            if (iter->cast<name_t>() == key_guide_baseline)
            {
                data.slice_m[extents_slices_t::vertical].balance_m = true;
                data.slice_m[extents_slices_t::vertical].suppress_m = true;
            }
            if (iter->cast<name_t>() == key_guide_label)
            {
                data.slice_m[extents_slices_t::horizontal].balance_m = true;
                data.slice_m[extents_slices_t::horizontal].suppress_m = true;
            }
        }
    }
    

    // REVISIT (sparent) : I'm seeing a pattern here - with three cases this could be factored

    {
    dictionary_t::const_iterator iter (parameters.find(key_placement));
    
    if (iter != parameters.end())
    {
        (*placement_table_g)(iter->second.cast<name_t>(), data.placement_m);
    }

    // Adjust defaults
    
    // Specifying a row from the parameters implies enabling baselines unless otherwise specified.
    
    if (iter != parameters.end() && data.placement_m == layout_attributes_placement_t::place_row && !parameters.count(key_guide_mask))
    {
        data.slice_m[extents_slices_t::vertical].suppress_m = false;
    }
    
    }
    
    {
    dictionary_t::const_iterator iter (parameters.find(key_child_horizontal));
    
    if (iter != parameters.end())
    {
        (*alignment_table_g)(   iter->second.cast<name_t>(),
                                data.slice_m[extents_slices_t::horizontal].child_alignment_m);
    }
    }

    {
    dictionary_t::const_iterator iter (parameters.find(key_child_vertical));
    
    if (iter != parameters.end())
    {
        (*alignment_table_g)(   iter->second.cast<name_t>(),
                                data.slice_m[extents_slices_t::vertical].child_alignment_m);
    }
    }
    
    // spacing
    {
    dictionary_t::const_iterator iter (parameters.find(key_spacing));
    if (iter != parameters.end())
    {
        if (iter->second.type_info() == type_info<array_t>())
        {
            const array_t& spacing_array = iter->second.cast<array_t>();
            data.spacing_m.resize(spacing_array.size() + 1);
            
            layout_attributes_t::spacing_t::iterator dest_iter(data.spacing_m.begin() + 1);
            
            for (array_t::const_iterator iter(spacing_array.begin()); iter != spacing_array.end();
                    ++iter)
            {
                *dest_iter = iter->cast<long>();
                ++dest_iter;
            }
        }
        else
        {
            double tmp(data.spacing_m[1]);
            iter->second.cast(tmp); // Try getting as number
            data.spacing_m[1] = long(tmp);
        }
    }
    }
    
    // margin
    {
    dictionary_t::const_iterator iter(parameters.find(key_margin));
    if (iter != parameters.end())
    {
        if (iter->second.type_info() == type_info<array_t>())
        {
            const array_t& margin_array = iter->second.cast<array_t>();

            data.vertical().margin_m.first    = margin_array[0].cast<long>();
            data.horizontal().margin_m.first  = margin_array[1].cast<long>();
            data.vertical().margin_m.second   = margin_array[2].cast<long>();
            data.horizontal().margin_m.second = margin_array[3].cast<long>();
        }
        else
        {
            long margin = iter->second.cast<long>();

            data.vertical().margin_m.first    = margin;
            data.horizontal().margin_m.first  = margin;
            data.vertical().margin_m.second   = margin;
            data.horizontal().margin_m.second = margin;
        }
    }
    }
}
Esempio n. 14
0
parse_vms_args(int *argc, char **argv[])
{
        static char command[S_LENGTH], value_template[S_LENGTH];
        static char qual_template[S_LENGTH];
        char verb[] = "VARG ";
        char *vms_arg[MAX_ARGS];
        char *unix_arg[MAX_ARGS];
        char *unix_narg[MAX_ARGS];
        char *vms_key[MAX_ARGS];
        char *unix_key[MAX_ARGS];
        char *separator[MAX_ARGS];
        char *pattern[MAX_ARGS];
        char *outverb, *arg_symbol, *image_name;
        char foreign_image[S_LENGTH];
        int flags[MAX_ARGS], action_flags;
        int  nvargs, u_length, l_element, index;
        char arg_string[S_LENGTH], arg_element[S_LENGTH];
        static char value[S_LENGTH];
        char *special_chars;
        char default_special[] = "[email protected]#^&()=+\'\"/?,";
        $DESCRIPTOR(command_desc, command);
        $DESCRIPTOR(qual_desc, "");
        $DESCRIPTOR(value_desc, value);
        int i, length, status, i_length, arg_count, q_length;
        static char command_args[S_LENGTH];
        $DESCRIPTOR(command_arg_desc, command_args);
        extern VARG_CLD;
        static	char *newargv[MAX_ARGS];
        int affirm_flag, negative_flag, keywords_flag, separator_flag;
        int date_flag, append_flag, present, more_flag, multivalue, help_flag;
        int vmsarg_mapping();

        /*	Get the VMS -> Unix mapping definitions from the routine generated
        	by the GEN_MAPPING utility.
        */

        vmsarg_mapping(&nvargs, vms_arg, unix_arg, unix_narg, vms_key, unix_key,
                       separator, flags, pattern, &outverb, &action_flags,
                       &arg_symbol, &image_name );

        /*	Get the original command line from the foreign command utility.
        */

        length = 0;					/* RTL only writes word */
        lib$get_foreign(&command_arg_desc, 0, &length);
        command_args[length] = 0;			/* add NULL terminator */

        /*	Check to see if any of the exising arguments start with a "-"
        	character.  if so, assume he's already using Unix style arguments so
        	we don't have to do anything.  Only do this if the Unix_Arg bit is
        	set in the action flags.
        */

        if ((action_flags & VARGACT_M_UNIXARG)) {
                for (i = 1; i <= *argc - 1; i++)
                        if ((*argv) [i][0] == '-') {
                                /* He's using Unix style args. */
                                if ((action_flags & VARGACT_M_RETURN)) {
                                        return 1;		/* back out quietly	*/
                                } else {
                                        status = varg_do_exit(action_flags, arg_symbol, command_args,
                                                          image_name, outverb);
                                        sys$exit(status);	/* exit with DCL stuff done  */
                                }
                        }
        }

        /*	Catenate verb and arguments into the command string for DCL
        	to parse.
        */

        strcpy(command, verb);
        strcat(command, command_args);
        command_desc.dsc$w_length = strlen(verb) + strlen(command_args);

        /*	Pass it to the DCL parser for its approval.
        */

        status = cli$dcl_parse(&command_desc, &VARG_CLD);
        if ((status & 1) != 1) sys$exit (status);

        /*	Now that DCL is happy, we go through all the defined VMS qualifiers
        	and parameters to check if they are present or defaulted.
        */

        arg_count = 0;		/* so far so good */

        for (i = 1; i <= nvargs; i++) {

                /*	Set The various flags for this qualifier.
                */

                affirm_flag = (VARG_M_AFFIRM & flags[i]) != 0;
                negative_flag = (VARG_M_NEGATIVE & flags[i]) != 0;
                keywords_flag = (VARG_M_KEYWORDS & flags[i]) != 0;
                separator_flag = (VARG_M_SEPARATOR & flags[i]) != 0;
                date_flag = (VARG_M_DATE & flags[i]) != 0;
                append_flag = (VARG_M_APPEND & flags[i]) != 0;
                help_flag = (VARG_M_HELP & flags[i]) != 0;

                /*	Check if the qualifier or parameter is present
                */

                qual_desc.dsc$w_length = strlen(vms_arg[i]);
                qual_desc.dsc$a_pointer = vms_arg[i];
                present = cli$present(&qual_desc) & 1;

                /*	if the qualifier is present, and there is a positive translation,
                	then replace the VMS qualifier by its Unix equivalent.  Note that
                	if the Unix equivalent starts with a '$', then it is a parameter and
                	we omit the qualifier name, only putting in the value.
                */

                qual_template[0] = 0;			/* zero string initially */

                if (present && affirm_flag) {
                        if (unix_arg[i][0] != '$') strcpy(qual_template, unix_arg[i]);
                }

                if (!(present & 1) && negative_flag)		/* NOT present AND
						   negative_flag */
                {
                        strcpy(qual_template, unix_narg[i]);
                }

                /*	Get the first value (if any).  We may have to catenate this with the
                	qualifier keyword, or build up multiple values in a single argv
                	element.
                */

                if (present) {
                        value_desc.dsc$w_length = QUAL_LENGTH;
                        status = cli$get_value(&qual_desc, &value_desc, &length);
                        if ((status & 1) != 1) length = 0;
                        value[length] = 0;			/* NULL terminator */
                        more_flag = status == CLI$_COMMA;
                } else {
                        length = 0;
                }

                /*	if the /APPEND qualifier was used, then the qualifier and its value
                	are in the same argv element.
                */

                if (append_flag) {
                        strcpy(value_template, qual_template);
                } else {
                        /*	Allocate a fresh argv element and load the Unix keyword into it.
                        */
                        q_length = strlen(qual_template);

                        if (q_length != 0) {
                                Increment(arg_count);
                                newargv[arg_count] = malloc(q_length + 1);
                                if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM);
                                strcpy(newargv[arg_count], qual_template);
                        }
                }

                multivalue = more_flag;

                /*	Get all the various values and either append them with appropriate
                	separators to the current template, or load them in successive argv
                	elements.
                */

                while (affirm_flag && (length != 0)) {

                        /*	if a keyword list is involved, get the corresponding field from the
                        	Unix equivalent.
                        */

                        if (keywords_flag) {
                                index = varg_get_index(value, vms_key[i]);
                                varg_set_index(value, unix_key[i], index);
                        }

                        /*	if the /DATE qualifier was present, we interpret the value as a
                        	VMS date/time specification, and convert it to the equivalent Unix
                        	type string.
                        */

                        if (date_flag) varg_convert_date(value, pattern[i]);

                        /*	Add the current value to the template so far.  Add a separator
                        	character if we need one.
                        */

                        strcat(value_template, value);

                        if (separator_flag) {
                                if (more_flag)
                                        strcat(value_template, separator[i]);
                        } else {

                                /*	Each value should have its own argv element.
                                */

                                Increment(arg_count);
                                newargv[arg_count] = malloc(strlen(value_template) + 1);
                                if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM);
                                strcpy(newargv[arg_count], value_template);
                                value_template[0] = 0;
                        }

                        /*	Get the next value from the DCL parser.
                        */

                        value_desc.dsc$w_length = QUAL_LENGTH;		/* reset string */
                        status = cli$get_value(&qual_desc, &value_desc, &length);
                        if ((status & 1) != 1) length = 0;
                        value[length] = 0;
                        more_flag = status == CLI$_COMMA;
                }

                /*	All the values are in for this qualifier - if there were being stacked
                	up then load them all into an argv element.
                */

                if (separator_flag & multivalue) {
                        Increment(arg_count);
                        newargv[arg_count] = malloc(strlen(value_template) + 1);
                        if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM);
                        strcpy(newargv[arg_count], value_template);
                        value_template[0] = 0;
                }

                /*	Check to see if this is a HELP directive.  if so, then the help
                	library name is stored in pattern[i] and the initial help string
                	in unix_arg[i]
                */

                if ((present &1) && help_flag) {
                        varg_do_help(pattern[i], unix_arg[i]);
                }

                /*	And around for the next qualifier.
                */

        }

        /*	We've built the argument vector.  Now lets find out what we're
        	supposed to do with it.
        */

        if ((action_flags & VARGACT_M_RETURN)) {

                /*	We should return the result to the caller. Set the corresponding argc
                	& argv variables in the caller to point at these.  Make sure the new
                	argv contains the same [0] element as the old one (program name).
                */

                *argc = arg_count + 1;
                newargv[0] = (*argv)[0];
                *argv = newargv;
                return 1;
        }

        /*	We must convert the argv elements into an arg string.
        */

        arg_string[0] = 0;
        special_chars = default_special;

        for (i = 1; i <= arg_count; i++) {
                varg_protect_string(newargv[i], arg_element, action_flags,
                                special_chars);
                strcat(arg_string, arg_element);
                if (i != arg_count) strcat(arg_string, " ");
        }

        status = varg_do_exit(action_flags, arg_symbol, arg_string, image_name, outverb);

        /*	if we got this far then exit to DCL.
        */

        sys$exit(status);
}
void ConfigFmThs :: set_af_ths
(
   UINT fd
)
{
    signed char ret = FM_SUCCESS;
    char **keys;
    char **keys_cpy;
    char *key_value;
    int value;
    FmPerformanceParams perf_params;
    struct NAME_MAP *found;

    if(keyfile != NULL) {
       keys_cpy = keys = get_keys(keyfile, GRPS_MAP[0].name);
       if(keys != NULL) {
          while(*keys != NULL) {
              ALOGE("key found is: %s\n", *keys);
              found = (NAME_MAP *)bsearch(*keys, AF_PARAMS_MAP,
                          MAX_AF_PARAMS, sizeof(NAME_MAP), compare_name);
              if(found != NULL) {
                 key_value = get_value(keyfile,
                                     GRPS_MAP[0].name, found->name);
                 if((key_value != NULL) && strcmp(key_value, "")) {
                    value = atoi(key_value);
                    switch(found->num) {
                    case AF_RMSSI_TH:
                         if((value >= AF_RMSSI_TH_MIN)
                             && (value <= AF_RMSSI_TH_MAX)) {
                             ALOGE("Set af rmssi th: %d\n", value);
                             ret = perf_params.SetAfRmssiTh(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting Af Rmssi th\n");
                                break;
                             }
                             unsigned short th;
                             ret = perf_params.GetAfRmssiTh(fd, th);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read af rmssith: %hd\n", th);
                             }else {
                                ALOGE("Error in reading Af Rmssi th\n");
                             }
                         }
                         break;
                    case AF_RMSSI_SAMPLES:
                         if((value >= AF_RMSSI_SAMPLES_MIN)
                             && (value <= AF_RMSSI_SAMPLES_MAX)) {
                             ALOGE("Set af rmssi samples cnt: %d\n", value);
                             ret = perf_params.SetAfRmssiSamplesCnt(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting af rmssi samples\n");
                                break;
                             }
                             unsigned char cnt;
                             ret = perf_params.GetAfRmssiSamplesCnt(fd, cnt);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read af rmssi samples cnt: %hhd\n", cnt);
                             }else {
                                 ALOGE("Error in reading rmssi samples\n");
                             }
                         }
                         break;
                    case GOOD_CH_RMSSI_TH:
                         if((value >= GOOD_CH_RMSSI_TH_MIN)
                             && (value <= GOOD_CH_RMSSI_TH_MAX)) {
                             ALOGE("Set Good channle rmssi th: %d\n", value);
                             ret = perf_params.SetGoodChannelRmssiTh(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting Good channle rmssi th\n");
                                break;
                             }
                             signed char th;
                             ret = perf_params.GetGoodChannelRmssiTh(fd, th);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read good channel rmssi th: %d\n", th);
                             }else {
                                ALOGE("Error in reading Good channle rmssi th\n");
                             }
                         }
                         break;
                   }
                 }else {
                   ALOGE("key_val for key: %s is empty\n",
                             *keys);
                 }
                 free(key_value);
              }
              keys++;
          }
       }else {
          ALOGE("No of keys found is zero\n");
       }
       free_strs(keys_cpy);
    }else {
       ALOGE("key file is null\n");
    }
}
Esempio n. 16
0
 void cGtkmmScrollBar::PageDown()
 {
   set_value(get_value() + page);
 }
void ConfigFmThs :: set_srch_ths
(
    UINT fd
)
{
    signed char ret = FM_SUCCESS;
    char **keys = NULL;
    char **keys_cpy = NULL;
    char *key_value = NULL;
    int value;
    FmPerformanceParams perf_params;
    struct NAME_MAP *found = NULL;

    if(keyfile != NULL) {
       keys_cpy = keys = get_keys(keyfile, GRPS_MAP[3].name);
       if(keys != NULL) {
          while(*keys != NULL) {
              found = (NAME_MAP *)bsearch(*keys, SEACH_PARAMS_MAP,
                           MAX_SRCH_PARAMS, sizeof(NAME_MAP), compare_name);
              if(found != NULL) {
                 key_value = get_value(keyfile, GRPS_MAP[2].name, found->name);
                 ALOGE("found srch ths: %s: %s\n", found->name, key_value);
                 if((key_value != NULL) && strcmp(key_value, "")) {
                    value = atoi(key_value);
                    switch(found->num) {
                    case SINR_FIRST_STAGE:
                         if((value >= SINR_FIRST_STAGE_MIN)
                             && (value <= SINR_FIRST_STAGE_MAX)) {
                             ALOGE("Set sinr first stage: %d\n", value);
                             ret = perf_params.SetSinrFirstStage(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting sinr first stage\n");
                                break;
                             }
                             signed char th;
                             ret = perf_params.GetSinrFirstStage(fd, th);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read sinr first stage: %d\n", th);
                             }else {
                                ALOGE("Error in reading sinr first stage\n");
                             }
                         }
                         break;
                    case RMSSI_FIRST_STAGE:
                         if((value >= RMSSI_FIRST_STAGE_MIN)
                             && (value <= RMSSI_FIRST_STAGE_MAX)) {
                             ALOGE("Set rmssi first stage: %d\n", value);
                             ret = perf_params.SetRmssiFirstStage(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting rmssi first stage\n");
                                break;
                             }
                             signed char th;
                             ret = perf_params.GetRmssiFirstStage(fd, th);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read rmssi first stage: %d\n", th);
                             }else {
                                ALOGE("Error in reading rmssi first stage\n");
                             }
                         }
                         break;
                    case INTF_LOW_TH:
                         if((value >= INTF_LOW_TH_MIN)
                             && (value <= INTF_LOW_TH_MAX)) {
                            ALOGE("Set intf low th: %d\n", value);
                            ret = perf_params.SetIntfLowTh(fd, value);
                            if(ret == FM_FAILURE) {
                                ALOGE("Error in setting intf low th\n");
                                break;
                            }
                            unsigned char th;
                            ret = perf_params.GetIntfLowTh(fd, th);
                            if(ret == FM_SUCCESS) {
                               ALOGE("Read intf low th: %u\n", th);
                            }else {
                               ALOGE("Error in reading intf low th\n");
                            }
                         }
                         break;
                    case INTF_HIGH_TH:
                         if((value >= INTF_HIGH_TH_MIN)
                             && (value <= INTF_HIGH_TH_MAX)) {
                            ALOGE("Set intf high th: %d\n", value);
                            ret = perf_params.SetIntfHighTh(fd, value);
                            if(ret == FM_FAILURE) {
                                ALOGE("Error in setting intf high th\n");
                                break;
                            }
                            unsigned char th;
                            ret = perf_params.GetIntfHighTh(fd, th);
                            if(ret == FM_SUCCESS) {
                               ALOGE("Read intf high th: %u\n", th);
                            }else {
                               ALOGE("Error in reading intf high th\n");
                            }
                         }
                         break;
                    case CF0_TH:
                         ALOGE("Set cf0 th: %d\n", value);
                         ret = perf_params.SetCf0Th12(fd, value);
                         if(ret == FM_FAILURE) {
                            ALOGE("Error in setting cf0 th\n");
                            break;
                         }
                         int th;
                         ret = perf_params.GetCf0Th12(fd, th);
                         if(ret == FM_SUCCESS) {
                            ALOGE("Read CF012 th: %d\n", th);
                         }else {
                            ALOGE("Error in reading cf0 th\n");
                         }
                         break;
                    case SRCH_ALGO_TYPE:
                         if((value >= SRCH_ALGO_TYPE_MIN)
                             && (value <= SRCH_ALGO_TYPE_MAX)) {
                             ALOGE("Set search algo type: %d\n", value);
                             ret = perf_params.SetSrchAlgoType(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting search algo type\n");
                                break;
                             }
                             unsigned char algo;
                             ret = perf_params.GetSrchAlgoType(fd, algo);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read algo type: %u\n", algo);
                             }else {
                                ALOGE("Error in reading search algo type\n");
                             }
                         }
                         break;
                    case SINR_SAMPLES:
                         if((value >= SINR_SAMPLES_CNT_MIN)
                             && (value <= SINR_SAMPLES_CNT_MAX)) {
                             ALOGE("Set sinr samples count: %d\n", value);
                             ret = perf_params.SetSinrSamplesCnt(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting sinr samples count\n");
                                break;
                             }
                             unsigned char cnt;
                             ret = perf_params.GetSinrSamplesCnt(fd, cnt);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read sinr samples cnt: %u\n", cnt);
                             }else {
                                ALOGE("Error in reading sinr samples count\n");
                             }
                         }
                         break;
                    case SINR:
                         if((value >= SINR_FINAL_STAGE_MIN)
                             && (value <= SINR_FINAL_STAGE_MAX)) {
                             ALOGE("Set final stage sinr: %d\n", value);
                             ret = perf_params.SetSinrFinalStage(fd, value);
                             if(ret == FM_FAILURE) {
                                ALOGE("Error in setting final stage sinr\n");
                                break;
                             }
                             signed char th;
                             ret = perf_params.GetSinrFinalStage(fd, th);
                             if(ret == FM_SUCCESS) {
                                ALOGE("Read final stage sinr: %d\n", th);
                             }else {
                                ALOGE("Error in reading final stage sinr\n");
                             }
                         }
                         break;
                    }
                 }else {
                    ALOGE("key_value for key: %s is empty\n",
                                  *keys);
                 }
                 free(key_value);
              }
              keys++;
          }
       }else {
          ALOGE("No of keys found is zero\n");
       }
       free_strs(keys_cpy);
    }else {
       ALOGE("key file is null\n");
    }
}
Esempio n. 18
0
void Options::slider_rotation_z_changed()
{
	rotation_z.set_degrees(get_value(slider_rotation_z, 0.0f, max_angle_value));
	update_quaternion();
}
void ConfigFmThs :: set_band_cfgs
(
   UINT fd
)
{
    signed char ret = FM_SUCCESS;
    char **keys;
    char **keys_cpy;
    char *key_value;
    int value;
    FmPerformanceParams perf_params;
    struct NAME_MAP *found;

    if(keyfile != NULL) {
       keys_cpy = keys = get_keys(keyfile, GRPS_MAP[1].name);
       if(keys != NULL) {
          while(*keys != NULL) {
              ALOGE("key found is: %s\n", *keys);
              found = (NAME_MAP *)bsearch(*keys, BAND_CFG_MAP,
                          MAX_BAND_PARAMS, sizeof(NAME_MAP), compare_name);
              if(found != NULL) {
                 key_value = get_value(keyfile,
                                     GRPS_MAP[1].name, found->name);
                 if((key_value != NULL) && strcmp(key_value, "")) {
                    value = atoi(key_value);
                    switch(found->num) {
                    case RADIO_BAND:
                         ALOGE("RADIO_BAND\n");
                         if((value >= BAND_87500_108000)
                             && (value <= BAND_76000_90000)) {
                             ALOGE("%s:Set band as: %d\n",__func__, value);
                             ret = perf_params.SetBand(fd, value);
                             if(ret == FM_FAILURE)
                                ALOGE("Error in setting band\n");
                         }
                         break;
                    case EMPHASIS:
                         ALOGE("EMPHASIS\n");
                         if((value >= DE_EMP75)
                             && (value <= DE_EMP50)) {
                             ALOGE("%s:Set Emphasis as: %d\n",__func__, value);
                             ret = perf_params.SetEmphsis(fd, value);
                             if(ret == FM_FAILURE)
                                ALOGE("Error in setting Emphasis\n");
                         }
                         break;
                    case CHANNEL_SPACING:
                         ALOGE("CHANNEL_SPACING\n");
                         if((value >= CHAN_SPACE_200)
                             && (value <= CHAN_SPACE_50)) {
                             ALOGE("%s:Set CH space as: %d\n",__func__, value);
                             ret = perf_params.SetChannelSpacing(fd, value);
                             if(ret == FM_FAILURE)
                                ALOGE("Error in setting channel spacing\n");
                         }
                         break;
                   }
                 }else {
                   ALOGE("key_val for key: %s is empty\n",
                             *keys);
                 }
                 free(key_value);
              }
              keys++;
          }
       }else {
          ALOGE("No of keys found is zero\n");
       }
       free_strs(keys_cpy);
    }else {
       ALOGE("key file is null\n");
    }
}
Esempio n. 20
0
void Options::slider_target_z_changed()
{
	target_z.set_degrees(get_value(slider_target_z, 0.0f, max_angle_value));
	update_all_slider_text();
}
Esempio n. 21
0
 T get() const
 {
   return get_value();
 }
Esempio n. 22
0
/* Constructor reads symbol table entries beginning at entry 'i'. We can't pass an array of COFFSymbolEntry_disk structs
 * because the disk size is 18 bytes, which is not properly aligned according to the C standard. Therefore we pass the actual
 * section and table index. The symbol occupies the specified table slot and st_num_aux_entries additional slots. */
void
SgAsmCoffSymbol::ctor(SgAsmPEFileHeader *fhdr, SgAsmGenericSection *symtab, SgAsmGenericSection *strtab, size_t idx)
{
    static const bool debug = false;
    COFFSymbol_disk disk;
    symtab->read_content_local(idx * COFFSymbol_disk_size, &disk, COFFSymbol_disk_size);
    if (disk.st_zero == 0) {
        p_st_name_offset = ByteOrder::le_to_host(disk.st_offset);
        if (p_st_name_offset < 4) throw FormatError("name collides with size field");
        std::string s = strtab->read_content_local_str(p_st_name_offset);
        set_name(new SgAsmBasicString(s));
    } else {
        char temp[9];
        memcpy(temp, disk.st_name, 8);
        temp[8] = '\0';
        set_name(new SgAsmBasicString(temp));
        p_st_name_offset = 0;
    }

    p_st_name            = get_name()->get_string();
    p_st_section_num     = ByteOrder::le_to_host(disk.st_section_num);
    p_st_type            = ByteOrder::le_to_host(disk.st_type);
    p_st_storage_class   = ByteOrder::le_to_host(disk.st_storage_class);
    p_st_num_aux_entries = ByteOrder::le_to_host(disk.st_num_aux_entries);

    /* Bind to section number. We can do this now because we've already parsed the PE Section Table */
    ROSE_ASSERT(fhdr->get_section_table()!=NULL);
    if (p_st_section_num > 0) {
        p_bound = fhdr->get_file()->get_section_by_id(p_st_section_num);
        ROSE_ASSERT(p_bound != NULL);
    }
    
    /* Make initial guesses for storage class, type, and definition state. We'll adjust them after reading aux entries. */
    p_value = ByteOrder::le_to_host(disk.st_value);
    p_def_state = SYM_DEFINED;
    switch (p_st_storage_class) {
      case 0:    p_binding = SYM_NO_BINDING; break; /*none*/
      case 1:    p_binding = SYM_LOCAL;      break; /*stack*/
      case 2:    p_binding = SYM_GLOBAL;     break; /*extern*/
      case 3:    p_binding = SYM_GLOBAL;     break; /*static*/
      case 4:    p_binding = SYM_LOCAL;      break; /*register*/
      case 5:    p_binding = SYM_GLOBAL;     break; /*extern def*/
      case 6:    p_binding = SYM_LOCAL;      break; /*label*/
      case 7:    p_binding = SYM_LOCAL;      break; /*label(undef)*/
      case 8:    p_binding = SYM_LOCAL;      break; /*struct member*/
      case 9:    p_binding = SYM_LOCAL;      break; /*formal arg*/
      case 10:   p_binding = SYM_LOCAL;      break; /*struct tag*/
      case 11:   p_binding = SYM_LOCAL;      break; /*union member*/
      case 12:   p_binding = SYM_GLOBAL;     break; /*union tag*/
      case 13:   p_binding = SYM_GLOBAL;     break; /*typedef*/
      case 14:   p_binding = SYM_GLOBAL;     break; /*static(undef)*/
      case 15:   p_binding = SYM_GLOBAL;     break; /*enum tag*/
      case 16:   p_binding = SYM_LOCAL;      break; /*enum member*/
      case 17:   p_binding = SYM_GLOBAL;     break; /*register param*/
      case 18:   p_binding = SYM_LOCAL;      break; /*bit field*/
      case 100:  p_binding = SYM_GLOBAL;     break; /*block(bb or eb)*/
      case 101:  p_binding = SYM_GLOBAL;     break; /*function*/
      case 102:  p_binding = SYM_LOCAL;      break; /*struct end*/
      case 103:  p_binding = SYM_GLOBAL;     break; /*file*/
      case 104:  p_binding = SYM_GLOBAL;     break; /*section*/
      case 105:  p_binding = SYM_WEAK;       break; /*weak extern*/
      case 107:  p_binding = SYM_LOCAL;      break; /*CLR token*/
      case 0xff: p_binding = SYM_GLOBAL;     break; /*end of function*/
    }
    switch (p_st_type & 0xf0) {
      case 0x00: p_type = SYM_NO_TYPE; break;     /*none*/
      case 0x10: p_type = SYM_DATA;    break;     /*ptr*/
      case 0x20: p_type = SYM_FUNC;    break;     /*function*/
      case 0x30: p_type = SYM_ARRAY;   break;     /*array*/
    }
    
    /* Read additional aux entries. We keep this as 'char' to avoid alignment problems. */
    if (p_st_num_aux_entries > 0) {
        p_aux_data = symtab->read_content_local_ucl((idx+1)*COFFSymbol_disk_size, p_st_num_aux_entries * COFFSymbol_disk_size);

        if (get_type() == SYM_FUNC && p_st_section_num > 0) {
            /* Function */
            unsigned bf_idx      = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[0]));
            unsigned size        = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[4]));
            unsigned lnum_ptr    = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[8]));
            unsigned next_fn_idx = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[12]));
            unsigned res1        = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[16]));
            set_size(size);
            if (debug) {
                fprintf(stderr, "COFF aux func %s: bf_idx=%u, size=%u, lnum_ptr=%u, next_fn_idx=%u, res1=%u\n", 
                        escapeString(p_st_name).c_str(), bf_idx, size, lnum_ptr, next_fn_idx, res1);
            }
            
        } else if (p_st_storage_class == 101 /*function*/ && (0 == p_st_name.compare(".bf") || 0 == p_st_name.compare(".ef"))) {
            /* Beginning/End of function */
            unsigned res1        = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[0]));
            unsigned lnum        = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[4])); /*line num within source file*/
            unsigned res2        = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[6]));
            unsigned res3        = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[8]));
            unsigned next_bf     = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[12])); /*only for .bf; reserved in .ef*/
            unsigned res4        = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[16]));
            if (debug) {
                fprintf(stderr, "COFF aux %s: res1=%u, lnum=%u, res2=%u, res3=%u, next_bf=%u, res4=%u\n", 
                        escapeString(p_st_name).c_str(), res1, lnum, res2, res3, next_bf, res4);
            }
            
        } else if (p_st_storage_class == 2/*external*/ && p_st_section_num == 0/*undef*/ && get_value()==0) {
            /* Weak External */
            unsigned sym2_idx    = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[0]));
            unsigned flags       = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[4]));
            unsigned res1        = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[8]));
            unsigned res2        = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[12]));
            unsigned res3        = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[16]));
            if (debug) {
                fprintf(stderr, "COFF aux weak %s: sym2_idx=%u, flags=%u, res1=%u, res2=%u, res3=%u\n",
                        escapeString(p_st_name).c_str(), sym2_idx, flags, res1, res2, res3);
            }
            
        } else if (p_st_storage_class == 103/*file*/ && 0 == p_st_name.compare(".file")) {
            /* This symbol is a file. The file name is stored in the aux data as either the name itself or an offset
             * into the string table. Replace the fake ".file" with the real file name. */
            const COFFSymbol_disk *d = (const COFFSymbol_disk*) &(p_aux_data[0]);
            if (0 == d->st_zero) {
                rose_addr_t fname_offset = ByteOrder::le_to_host(d->st_offset);
                if (fname_offset < 4) throw FormatError("name collides with size field");
                set_name(new SgAsmBasicString(strtab->read_content_local_str(fname_offset)));
                if (debug) {
                    fprintf(stderr, "COFF aux file: offset=%"PRIu64", name=\"%s\"\n",
                            fname_offset, get_name()->get_string(true).c_str());
                }
            } else {
                /* Aux data contains a NUL-padded name; the NULs (if any) are not part of the name. */
                ROSE_ASSERT(p_st_num_aux_entries == 1);
                char fname[COFFSymbol_disk_size+1];
                memcpy(fname, &(p_aux_data[0]), COFFSymbol_disk_size);
                fname[COFFSymbol_disk_size] = '\0';
                set_name(new SgAsmBasicString(fname));
                if (debug)
                    fprintf(stderr, "COFF aux file: inline-name=\"%s\"\n", get_name()->get_string(true).c_str());
            }
            set_type(SYM_FILE);

        } else if (p_st_storage_class == 3/*static*/ && NULL != fhdr->get_file()->get_section_by_name(p_st_name, '$')) {
            /* Section */
            unsigned size         = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[0])); /*same as section header SizeOfRawData */
            unsigned nrel         = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[4])); /*number of relocations*/
            unsigned nln_ents     = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[6])); /*number of line number entries */
            unsigned cksum        = ByteOrder::le_to_host(*(uint32_t*)&(p_aux_data[8]));
            unsigned sect_id      = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[12])); /*1-base index into section table*/
            unsigned comdat       = p_aux_data[14]; /*comdat selection number if section is a COMDAT section*/
            unsigned res1         = p_aux_data[15];
            unsigned res2         = ByteOrder::le_to_host(*(uint16_t*)&(p_aux_data[16]));
            set_size(size);
            set_type(SYM_SECTION);
            if (debug) {
                fprintf(stderr, 
                        "COFF aux section: size=%u, nrel=%u, nln_ents=%u, cksum=%u, sect_id=%u, comdat=%u, res1=%u, res2=%u\n", 
                        size, nrel, nln_ents, cksum, sect_id, comdat, res1, res2);
            }
            
        } else if (p_st_storage_class==3/*static*/ && (p_st_type & 0xf)==0/*null*/ &&
                   get_value()==0 && NULL!=fhdr->get_file()->get_section_by_name(p_st_name)) {
            /* COMDAT section */
            /*FIXME: not implemented yet*/
            fprintf(stderr, "COFF aux comdat %s: (FIXME) not implemented yet\n", escapeString(p_st_name).c_str());
            hexdump(stderr, (rose_addr_t) symtab->get_offset()+(idx+1)*COFFSymbol_disk_size, "    ", p_aux_data);

        } else {
            fprintf(stderr, "COFF aux unknown %s: (FIXME) st_storage_class=%u, st_type=0x%02x, st_section_num=%d\n", 
                    escapeString(p_st_name).c_str(), p_st_storage_class, p_st_type, p_st_section_num);
            hexdump(stderr, symtab->get_offset()+(idx+1)*COFFSymbol_disk_size, "    ", p_aux_data);
        }
    }

}
Esempio n. 23
0
// resolves collisions between bodies, returning new body count
int collide(int n, body bodies[]) {
  // initialize disjoint set and bodies to include
  set* bsets[n];
  int include[n];
  for (int i = 0; i < n; i++) {
    bsets[i] = make_set(i);
    include[i] = 1;
  }

  // find largest object
  double maxrad = RADIUS(bodies[0].m);
  for (int i = 0; i < n; i++) {
    double rad = RADIUS(bodies[i].m);
    if (rad > maxrad)
      maxrad = rad;
  }

  // form mesh for collision detection
  mesh* m = mesh_new(maxrad * 2);
  for (int i = 0; i < n; i++)
    mesh_put(m, bodies[i].pos, i);

  // find collisions
  for (int i = 0; i < n; i++) {
    vector ipos = bodies[i].pos;
    double irad = RADIUS(bodies[i].m);

    // which bodies are in contact with this one?
    // look up position in mesh
    body_list* next = mesh_get(m, ipos, 1);
    for (body_list* cur = next; cur; cur = next) {
      // get candidate collider
      int j = cur->index;
      vector jpos = bodies[j].pos;
      double jrad = RADIUS(bodies[j].m);

      // merge sets of colliding objects
      if (dist(ipos, jpos) < (irad + jrad) * (irad + jrad))
        merge(bsets[i], bsets[j]);

      // traverse and free
      next = cur->next;
      free(cur);
    }
  }

  // free the mesh
  mesh_free(m);

  // merge objects
  for (int i = 0; i < n; i++) {
    int rootidx = get_value(find(bsets[i]));
    if (rootidx != i) {
      include[i] = 0;
      bodies[rootidx] = body_merge(bodies[rootidx], bodies[i]);
    }
  }

  // free sets
  for (int i = 0; i < n; i++)
    free(bsets[i]);

  // copy down
  int j = 0;
  for (int i = 0; i < n; i++) {
    if (include[i])
      bodies[j++] = bodies[i];
  }

  return j;
}
Esempio n. 24
0
ConstExpr decltype(auto) apply_tuple_to_function(std::integral_constant<int, index> selected_index, int_list<I...>, fn_t<F, T1>&& f, T2&& t) {
   using boxtype = std::decay_t<decltype(std::get<index>(std::forward<T2>(t)))>;
   return isabox<boxtype>::box_map(std::get<index>(std::forward<T2>(t)), f(get_value(selective_get(std::integral_constant<int, I>(), selected_index, std::forward<T2>(t)))...));
}
Esempio n. 25
0
set_security(int argc, char**argv)
{
    $DESCRIPTOR(p, "p1");
    $DESCRIPTOR(acl, "acl");

    char aclstr[80];
    struct dsc$descriptor aclval;
    aclval.dsc$a_pointer=aclstr;
    aclval.dsc$w_length=80;

    char nastr[80];
    struct dsc$descriptor naval;
    naval.dsc$a_pointer=nastr;
    naval.dsc$w_length=80;

    char prstr[80];
    struct dsc$descriptor prval;
    prval.dsc$a_pointer=prstr;
    prval.dsc$w_length=80;

    int sts, aclsts, nasts, prsts;
    int retlen;

    sts = cli$present(&p);
#if 0
    if (0)
        sts = cli$get_value(&p, &o, &retlen);
#endif

    aclsts = cli$present(&acl);

    int pid = 0;

    if (aclsts & 1)
    {
#if 0
        aclsts = cli$get_value(&acl, &aclval, &retlen);
#endif

        int id;
        int ace_access = 0;
        int ace_id = 0;
        int retlen;
#if 0
        $DESCRIPTOR(qacl, "acl");
#endif
        char d[80];
        struct dsc$descriptor q;
        q.dsc$a_pointer=d;
        q.dsc$w_length=80;
        memset (d, 0, 80);
#if 0
        int sts = cli$present(&qacl);
        if ((sts&1)==0)
            return 0;
#else
        int sts;
#endif
#if 0
        $DESCRIPTOR(acc, "ACCESS");
        while (cli$get_value(&acc, &q, &retlen)&1)
        {
            q.dsc$w_length=retlen;
            d[retlen]=0;
            printf("text %s\n",d);
        }
        return;
#endif
        if (/*cli$get_value(&qacl, &q, &retlen)&*/1)
        {
#if 0
            q.dsc$w_length=retlen;
            d[retlen]=0;
            printf("ac %s\n",d);
            struct dsc$descriptor q1 = q;
#endif
#if 0
            char * eq = strchr(q1.dsc$a_pointer, '=');
            if (eq == 0)
                break;
            q1.dsc$w_length = ((long)eq) - ((long)q1.dsc$a_pointer);
#endif
#if 0
            int acl = acl_find_type(&q1);
            acl=1;
            printf("acl %x\n", acl);
#endif
            if (/*acl ==*/ 1)
            {
#if 0
                struct dsc$descriptor q2;
                q2.dsc$a_pointer = eq + 1;
                q2.dsc$w_length = ((long)q.dsc$a_pointer) + q.dsc$w_length - ((long)q2.dsc$a_pointer);
                int id = atoi(eq+1);
                printf("id %x %s\n",id,eq+1);
                if (cli$get_value(&qacl, &q, &retlen)&1)
                {
                    q.dsc$w_length=retlen;
                    struct dsc$descriptor q1 = q;
                    char * eq = strchr(q1.dsc$a_pointer, '=');
                    if (eq == 0)
                        break;
                    q1.dsc$w_length = ((long)eq) - ((long)q1.dsc$a_pointer);
                    if (0==strncmp("ACCESS", q1.dsc$a_pointer, q1.dsc$w_length))
                    {
                        struct dsc$descriptor q2;
                        q2.dsc$a_pointer = eq + 1;
                        q2.dsc$w_length = ((long)q.dsc$a_pointer) + q.dsc$w_length - ((long)q2.dsc$a_pointer);
                        ace_access = access_types_values [acl_find_access_type(&q2)];
                    }
                }
#endif
                $DESCRIPTOR(ident, "IDENTIFIER");
                $DESCRIPTOR(access, "ACCESS");
                if (cli$get_value(&ident, &q, &retlen)&1)
                {
                    d[retlen] = 0;
                    int id = atoi(d);
                    ace_id = id;
                    printf("id = %x\n",id);
                }
                else
                    printf("noid\n");
                while (cli$get_value(&access, &q, &retlen)&1)
                {
                    q.dsc$w_length = retlen;
                    d[retlen] = 0;
                    ace_access |= access_types_values [acl_find_access_type(&q)];
                    printf("access = %s %x\n",d,ace_access);
                }/* else
	    printf("noac\n");*/
            }
        }
        printf("access %x\n", ace_access);
#if 0
        return 1;
#endif

        char rsa[80];

        $DESCRIPTOR(file, "FILE");
        struct dsc$descriptor filename;
        filename.dsc$a_pointer = rsa;
        filename.dsc$w_length = 80;

        sts = cli$present(&p);
        printf("sec %x\n", sts);
        if (sts&1)
        {
            sts = cli$get_value(&p, &filename, &retlen);
            filename.dsc$w_length=retlen;
        }
        else return 0;

        struct _ile3 itmlst[2];
        memset (itmlst, 0, 2 * sizeof(struct _ile3));
        retlen = 0;
        char buf[512];
        struct _acedef * ace = buf;
        ace -> ace$b_size = 16; // should be 12?
        ace -> ace$b_type = ACE$C_KEYID;
        ace -> ace$l_access = ace_access;
        ace -> ace$l_key = ace_id;
        itmlst[0].ile3$w_length = 512;
        itmlst[0].ile3$w_code = OSS$_ACL_ADD_ENTRY;
        itmlst[0].ile3$ps_bufaddr = buf;
        itmlst[0].ile3$ps_retlen_addr = &retlen;
        sts = sys$set_security(&file, &filename, 0, 0, &itmlst, 0, 0);
    }

    return SS$_NORMAL;
}
Esempio n. 26
0
ConstExpr decltype(auto) apply_tuple_to_function(std::integral_constant<int, -1>, int_list<I...>, fn_t<F, T1>&& f, T2&& t) {
   return f(get_value(std::get<I>(std::forward<T2>(t)))...);
}
Esempio n. 27
0
int PluginDialogSingle::handle_event()
{
	dialog->thread->single_standalone = get_value();
	return 1;
}
Esempio n. 28
0
static VALUE get_value(const char* buffer, int* position, int type) {
    VALUE value;
    switch (type) {
    case 1:
        {
            double d;
            memcpy(&d, buffer + *position, 8);
            value = rb_float_new(d);
            *position += 8;
            break;
        }
    case 2:
    case 13:
        {
            int value_length;
            *position += 4;
            value_length = strlen(buffer + *position);
            value = STR_NEW(buffer + *position, value_length);
            *position += value_length + 1;
            break;
        }
    case 3:
        {
            int size;
            memcpy(&size, buffer + *position, 4);
            if (strcmp(buffer + *position + 5, "$ref") == 0) { // DBRef
                int offset = *position + 14;
                VALUE argv[2];
                int collection_length = strlen(buffer + offset);
                char id_type;

                argv[0] = STR_NEW(buffer + offset, collection_length);
                offset += collection_length + 1;
                id_type = buffer[offset];
                offset += 5;
                argv[1] = get_value(buffer, &offset, (int)id_type);
                value = rb_class_new_instance(2, argv, DBRef);
            } else {
                value = elements_to_hash(buffer + *position + 4, size - 5);
            }
            *position += size;
            break;
        }
    case 4:
        {
            int size, end;
            memcpy(&size, buffer + *position, 4);
            end = *position + size - 1;
            *position += 4;

            value = rb_ary_new();
            while (*position < end) {
                int type = (int)buffer[(*position)++];
                int key_size = strlen(buffer + *position);
                VALUE to_append;

                *position += key_size + 1; // just skip the key, they're in order.
                to_append = get_value(buffer, position, type);
                rb_ary_push(value, to_append);
            }
            (*position)++;
            break;
        }
    case 5:
        {
            int length, subtype;
            VALUE data, st;
            VALUE argv[2];
            memcpy(&length, buffer + *position, 4);
            subtype = (unsigned char)buffer[*position + 4];
            if (subtype == 2) {
                data = rb_str_new(buffer + *position + 9, length - 4);
            } else {
                data = rb_str_new(buffer + *position + 5, length);
            }
            st = INT2FIX(subtype);
            argv[0] = data;
            argv[1] = st;
            value = rb_class_new_instance(2, argv, Binary);
            *position += length + 5;
            break;
        }
    case 6:
        {
            value = Qnil;
            break;
        }
    case 7:
        {
            VALUE str = rb_str_new(buffer + *position, 12);
            VALUE oid = rb_funcall(str, rb_intern("unpack"), 1, rb_str_new2("C*"));
            value = rb_class_new_instance(1, &oid, ObjectID);
            *position += 12;
            break;
        }
    case 8:
        {
            value = buffer[(*position)++] ? Qtrue : Qfalse;
            break;
        }
    case 9:
        {
            long long millis;
            VALUE seconds, microseconds;
            memcpy(&millis, buffer + *position, 8);
            seconds = LL2NUM(millis / 1000);
            microseconds = INT2NUM((millis % 1000) * 1000);

            value = rb_funcall(Time, rb_intern("at"), 2, seconds, microseconds);
            value = rb_funcall(value, rb_intern("utc"), 0);
            *position += 8;
            break;
        }
    case 10:
        {
            value = Qnil;
            break;
        }
    case 11:
        {
            int pattern_length = strlen(buffer + *position);
            VALUE pattern = STR_NEW(buffer + *position, pattern_length);
            int flags_length, flags = 0, i = 0;
            char extra[10];
            VALUE argv[3];
            *position += pattern_length + 1;

            flags_length = strlen(buffer + *position);
            extra[0] = 0;
            for (i = 0; i < flags_length; i++) {
                char flag = buffer[*position + i];
                if (flag == 'i') {
                    flags |= IGNORECASE;
                }
                else if (flag == 'm') {
                    flags |= MULTILINE;
                }
                else if (flag == 'x') {
                    flags |= EXTENDED;
                }
                else if (strlen(extra) < 9) {
                    strncat(extra, &flag, 1);
                }
            }
            argv[0] = pattern;
            argv[1] = INT2FIX(flags);
            argv[2] = rb_str_new2(extra);
            value = rb_class_new_instance(3, argv, RegexpOfHolding);
            *position += flags_length + 1;
            break;
        }
    case 12:
        {
            int collection_length;
            VALUE collection, str, oid, id, argv[2];
            *position += 4;
            collection_length = strlen(buffer + *position);
            collection = STR_NEW(buffer + *position, collection_length);
            *position += collection_length + 1;

            str = rb_str_new(buffer + *position, 12);
            oid = rb_funcall(str, rb_intern("unpack"), 1, rb_str_new2("C*"));
            id = rb_class_new_instance(1, &oid, ObjectID);
            *position += 12;

            argv[0] = collection;
            argv[1] = id;
            value = rb_class_new_instance(2, argv, DBRef);
            break;
        }
    case 14:
        {
            int value_length;
            memcpy(&value_length, buffer + *position, 4);
            value = ID2SYM(rb_intern(buffer + *position + 4));
            *position += value_length + 4;
            break;
        }
    case 15:
        {
            int code_length, scope_size;
            VALUE code, scope, argv[2];
            *position += 8;
            code_length = strlen(buffer + *position);
            code = STR_NEW(buffer + *position, code_length);
            *position += code_length + 1;

            memcpy(&scope_size, buffer + *position, 4);
            scope = elements_to_hash(buffer + *position + 4, scope_size - 5);
            *position += scope_size;

            argv[0] = code;
            argv[1] = scope;
            value = rb_class_new_instance(2, argv, Code);
            break;
        }
    case 16:
        {
            int i;
            memcpy(&i, buffer + *position, 4);
            value = LL2NUM(i);
            *position += 4;
            break;
        }
    case 17:
        {
            int i;
            int j;
            memcpy(&i, buffer + *position, 4);
            memcpy(&j, buffer + *position + 4, 4);
            value = rb_ary_new3(2, LL2NUM(i), LL2NUM(j));
            *position += 8;
            break;
        }
    case 18:
        {
            long long ll;
            memcpy(&ll, buffer + *position, 8);
            value = LL2NUM(ll);
            *position += 8;
            break;
        }
    default:
        {
            rb_raise(rb_eTypeError, "no c decoder for this type yet (%d)", type);
            break;
        }
    }
    return value;
}
Esempio n. 29
0
int main(void)
{
	int len;
	char *lenstr,poststr[512];
	char *player_id, *server_id, *pay_id;
	int n_pay_id;
	int n_pay_times;
	int can_share = 1;
	uint64_t effect = 0;
	MYSQL_RES *res = NULL;
	MYSQL_ROW row;	
	char sql[256];
/*
	len = 10;
	for (;;) {
		if (len != 10)
			break;
		sleep(2);
	}
*/
	
	init_db((char *)"127.0.0.1", 3306, (char *)"pay", (char *)"root", (char *)"123456");

	printf("Content-Type:text/html\n\n");
	lenstr=getenv("CONTENT_LENGTH");
	if(lenstr == NULL) {
		printf("<DIV STYLE=\"COLOR:RED\">Errorarameters should be entered!</DIV>\n");
		return (0);
	}
	len=atoi(lenstr) + 1;
	if (len >= 512)
		return (0);
	
	fgets(poststr,len,stdin);
	parse_post_data(poststr, len);
	server_id = get_value((char *)"server_id");
	player_id = get_value((char *)"player_id");
	pay_id = get_value((char *)"pay_id");	
	if (!server_id || !player_id || !pay_id)
		return (0);	


	sprintf(sql, "select share_times, pay_times from share where server_id = %s and player_id = %s", server_id, player_id);
	res = query(sql, 1, NULL);
	if (!res) {
		send_fail();
		goto done;
	}
	row = fetch_row(res);
	if (!row) {
		send_fail();
		goto done;
	}

	n_pay_id = atoi(pay_id);
	if (!check_can_get_share_pay(row, n_pay_id)) {
		send_fail();
		goto done;
	}

	n_pay_times = atoi(row[1]);
	n_pay_times |= (1 << n_pay_id);

	free_query(res);
	res = NULL;
	
	sprintf(sql, "update `share` set `pay_times` = %d where `server_id` = %s and `player_id` = %s",
		n_pay_times, server_id, player_id);
	
	query(sql, 1, &effect);

	if (effect != 1) {
		send_fail();
		goto done;
	}
	
	send_success(n_pay_id);
	send_charge_gold_req(atoi(player_id), get_gold[n_pay_id], 0, (char *)"share reward", (char *)"127.0.0.1", (char *)"3008");
	
done:
	if (res)
		free_query(res);
	fflush(stdout);
	close_db();		
	return 0;
}
Esempio n. 30
0
/**
 * Try to replace instructions that produce a constant result with simple moves
 *
 * The hope is that a following copy propagation pass will eliminate the
 * unnecessary move instructions.
 */
GLboolean
_mesa_constant_fold(struct gl_program *prog)
{
   bool progress = false;
   unsigned i;

   for (i = 0; i < prog->NumInstructions; i++) {
      struct prog_instruction *const inst = &prog->Instructions[i];

      switch (inst->Opcode) {
      case OPCODE_ADD:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = a[0] + b[0];
	    result[1] = a[1] + b[1];
	    result[2] = a[2] + b[2];
	    result[3] = a[3] + b[3];

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_CMP:
	 /* FINISHME: We could also optimize CMP instructions where the first
	  * FINISHME: source is a constant that is either all < 0.0 or all
	  * FINISHME: >= 0.0.
	  */
	 if (src_regs_are_constant(inst, 3)) {
	    float a[4];
	    float b[4];
	    float c[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);
	    get_value(prog, &inst->SrcReg[2], c);

            result[0] = a[0] < 0.0f ? b[0] : c[0];
            result[1] = a[1] < 0.0f ? b[1] : c[1];
            result[2] = a[2] < 0.0f ? b[2] : c[2];
            result[3] = a[3] < 0.0f ? b[3] : c[3];

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;
	    inst->SrcReg[2].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[2].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_DP2:
      case OPCODE_DP3:
      case OPCODE_DP4:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result;

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result = (a[0] * b[0]) + (a[1] * b[1]);

	    if (inst->Opcode >= OPCODE_DP3)
	       result += a[2] * b[2];

	    if (inst->Opcode == OPCODE_DP4)
	       result += a[3] * b[3];

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_float(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_MUL:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = a[0] * b[0];
	    result[1] = a[1] * b[1];
	    result[2] = a[2] * b[2];
	    result[3] = a[3] * b[3];

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_SEQ:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = (a[0] == b[0]) ? 1.0f : 0.0f;
	    result[1] = (a[1] == b[1]) ? 1.0f : 0.0f;
	    result[2] = (a[2] == b[2]) ? 1.0f : 0.0f;
	    result[3] = (a[3] == b[3]) ? 1.0f : 0.0f;

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_float(prog, 1.0f);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_SGE:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = (a[0] >= b[0]) ? 1.0f : 0.0f;
	    result[1] = (a[1] >= b[1]) ? 1.0f : 0.0f;
	    result[2] = (a[2] >= b[2]) ? 1.0f : 0.0f;
	    result[3] = (a[3] >= b[3]) ? 1.0f : 0.0f;

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_float(prog, 1.0f);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_SGT:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = (a[0] > b[0]) ? 1.0f : 0.0f;
	    result[1] = (a[1] > b[1]) ? 1.0f : 0.0f;
	    result[2] = (a[2] > b[2]) ? 1.0f : 0.0f;
	    result[3] = (a[3] > b[3]) ? 1.0f : 0.0f;

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_float(prog, 0.0f);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_SLE:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = (a[0] <= b[0]) ? 1.0f : 0.0f;
	    result[1] = (a[1] <= b[1]) ? 1.0f : 0.0f;
	    result[2] = (a[2] <= b[2]) ? 1.0f : 0.0f;
	    result[3] = (a[3] <= b[3]) ? 1.0f : 0.0f;

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_float(prog, 1.0f);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_SLT:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = (a[0] < b[0]) ? 1.0f : 0.0f;
	    result[1] = (a[1] < b[1]) ? 1.0f : 0.0f;
	    result[2] = (a[2] < b[2]) ? 1.0f : 0.0f;
	    result[3] = (a[3] < b[3]) ? 1.0f : 0.0f;

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_float(prog, 0.0f);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      case OPCODE_SNE:
	 if (src_regs_are_constant(inst, 2)) {
	    float a[4];
	    float b[4];
	    float result[4];

	    get_value(prog, &inst->SrcReg[0], a);
	    get_value(prog, &inst->SrcReg[1], b);

	    result[0] = (a[0] != b[0]) ? 1.0f : 0.0f;
	    result[1] = (a[1] != b[1]) ? 1.0f : 0.0f;
	    result[2] = (a[2] != b[2]) ? 1.0f : 0.0f;
	    result[3] = (a[3] != b[3]) ? 1.0f : 0.0f;

	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_vec4(prog, result);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 } else if (src_regs_are_same(&inst->SrcReg[0], &inst->SrcReg[1])) {
	    inst->Opcode = OPCODE_MOV;
	    inst->SrcReg[0] = src_reg_for_float(prog, 0.0f);

	    inst->SrcReg[1].File = PROGRAM_UNDEFINED;
	    inst->SrcReg[1].Swizzle = SWIZZLE_NOOP;

	    progress = true;
	 }
	 break;

      default:
	 break;
      }
   }

   return progress;
}