Exemplo n.º 1
0
static void prog_main_setparams(qc_program_t *prog) {
    size_t i;
    qcany_t *arg;

    for (i = 0; i < vec_size(main_params); ++i) {
        arg = GetGlobal(OFS_PARM0 + 3*i);
        arg->vector[0] = 0;
        arg->vector[1] = 0;
        arg->vector[2] = 0;
        switch (main_params[i].vtype) {
            case TYPE_VECTOR:
                (void)util_sscanf(main_params[i].value, " %f %f %f ",
                                       &arg->vector[0],
                                       &arg->vector[1],
                                       &arg->vector[2]);
                break;
            case TYPE_FLOAT:
                arg->_float = atof(main_params[i].value);
                break;
            case TYPE_STRING:
                arg->string = prog_tempstring(prog, main_params[i].value);
                break;
            default:
                fprintf(stderr, "error: unhandled parameter type: %i\n", main_params[i].vtype);
                break;
        }
    }
}
Exemplo n.º 2
0
static int qc_vtos(qc_program_t *prog) {
    char buffer[512];
    qcany_t *num;
    qcany_t str;
    CheckArgs(1);
    num = GetArg(0);
    util_snprintf(buffer, sizeof(buffer), "'%g %g %g'", num->vector[0], num->vector[1], num->vector[2]);
    str.string = prog_tempstring(prog, buffer);
    Return(str);
    return 0;
}
Exemplo n.º 3
0
static int qc_etos(qc_program_t *prog) {
    char buffer[512];
    qcany_t *num;
    qcany_t str;
    CheckArgs(1);
    num = GetArg(0);
    util_snprintf(buffer, sizeof(buffer), "%i", num->_int);
    str.string = prog_tempstring(prog, buffer);
    Return(str);
    return 0;
}
Exemplo n.º 4
0
static int qc_ftos(qc_program *prog)
{
    char buffer[512];
    qcany *num;
    qcany str;
    CheckArgs(1);
    num = GetArg(0);
    snprintf(buffer, sizeof(buffer), "%g", num->_float);
    str.string = prog_tempstring(prog, buffer);
    Return(str);
    return 0;
}
Exemplo n.º 5
0
static int qc_strcat(qc_program_t *prog) {
    char  *buffer;
    size_t len1,   len2;
    qcany_t *str1,  *str2;
    qcany_t  out;

    const char *cstr1;
    const char *cstr2;

    CheckArgs(2);
    str1 = GetArg(0);
    str2 = GetArg(1);
    cstr1 = prog_getstring(prog, str1->string);
    cstr2 = prog_getstring(prog, str2->string);
    len1 = strlen(cstr1);
    len2 = strlen(cstr2);
    buffer = (char*)mem_a(len1 + len2 + 1);
    memcpy(buffer, cstr1, len1);
    memcpy(buffer+len1, cstr2, len2+1);
    out.string = prog_tempstring(prog, buffer);
    mem_d(buffer);
    Return(out);
    return 0;
}