Exemple #1
0
static char *find_program_ext(const char *pgm, const char *dir, char **pathext)
{
    char *result;
    int i;

    if (result = check_program(pgm, dir, ""), result)
	return result;

    for (i = 0; pathext[i]; i++) {
	const char *ext = pathext[i];
	if (result = check_program(pgm, dir, ext), result)
	    return result;
    }

    return NULL;
}
Exemple #2
0
void Shader::LoadShader(const char* vertex_file_path,const char* fragment_file_path){
    GLuint VertexShaderID=glCreateShader(GL_VERTEX_SHADER);
    GLuint FragmentShaderID=glCreateShader(GL_FRAGMENT_SHADER);

    std::string VertexShaderCode;
    read_shader(VertexShaderCode,vertex_file_path);

    std::string FragmentShaderCode;
    read_shader(FragmentShaderCode,fragment_file_path);

    GLint Result=GL_FALSE;
    int InfoLogLength;
    // Compile Vertex Shader
    compile_shader(VertexShaderID,VertexShaderCode);
    check_shader(VertexShaderID,Result,InfoLogLength);// Check Vertex Shader
    // Compile Fragment Shader
    compile_shader(FragmentShaderID,FragmentShaderCode);
    check_shader(FragmentShaderID,Result,InfoLogLength);

    // Link the program
    GLuint ProgramID=glCreateProgram();
    glAttachShader(ProgramID,VertexShaderID);
    glAttachShader(ProgramID,FragmentShaderID);
    glLinkProgram(ProgramID);

    // Check the program
    glGetProgramiv(ProgramID,GL_LINK_STATUS,&Result);
    glGetProgramiv(ProgramID,GL_INFO_LOG_LENGTH,&InfoLogLength);
    check_program(ProgramID,InfoLogLength);

    glDeleteShader(VertexShaderID);
    glDeleteShader(FragmentShaderID);

    programID=ProgramID;
}
Exemple #3
0
GLuint Shader::create_program(std::vector<GLuint> &shaders) {
    GLuint ProgramID=glCreateProgram();
    for(unsigned i=0; i<shaders.size(); i++) {
        glAttachShader(ProgramID,shaders.at(i));
    }
    glLinkProgram(ProgramID);
    check_program(ProgramID);
    return ProgramID;
}
Exemple #4
0
int 
main(int argc, char **argv)
{
    int     i;

    if (argc != 3) {
	fprintf(stderr, "Must be called in form 'extract <filename> <dbref>'\n");
	exit(1);
    }
    if ((input_file = fopen(argv[1], "r")) == NULL) {
	fprintf(stderr, "Could not open file '%d'\n", argv[1]);
	exit(1);
    }
    me = atoi(argv[2]);

    db_free();
    db_read(input_file);

    fprintf(stderr, "dbtop = %d\n", db_top);

    printf("MUCK 2.2fb extract for dbref #%d\n", me);

    for (i = 0; i < db_top; i++) {
	if (OWNER(i) != me)
	    continue;

	if (!(i % 256))
            fprintf(stderr, "Checking object %d..\n", i);
	check_common(i);
	switch (db[i].flags & TYPE_MASK) {
	    case TYPE_ROOM:
		check_room(i);
		break;
	    case TYPE_THING:
		check_thing(i);
		break;
	    case TYPE_EXIT:
		check_exit(i);
		break;
	    case TYPE_PLAYER:
		check_player(i);
		break;
	    case TYPE_PROGRAM:
		check_program(i);
		break;
	    case TYPE_GARBAGE:
		break;
	    default:
		break;
	}
    }
    fclose(input_file);
    fprintf(stderr, "Completed extract normally.\n");
    return 0;
}
void check_program(node *root){

  if(strcmp(root->str_type,"FuncDeclaration") == 0){
    check_funcdeclaration(root);
  }
  else if(strcmp(root->str_type,"FuncDefinition") == 0){
    check_funcdefinition(root);
  }
  else{
    check_declaration(root,"Global",1);
  }

  if(root->brother)
    check_program(root->brother);
}
int simulate_seconds(pState state, int seconds){
	if (state == NULL){
		return 1;
	}	
	if (  (seconds < 10 ) || (seconds > 8000)  ){
		return 1;
	}
	for (int i=0;i<seconds;++i){
		if (state->power == ON){
			if (state->heater == ON){
				state->currentTemp = (double)state->currentTemp + 1;
				if ((double)state->currentTemp > ((double)state->setTemp + 5) ){
					state->heater = OFF;
				}
			} else {
				if ((double)state->currentTemp > (double)state->ambientTemp){

					state->currentTemp = ((double)state->currentTemp - 0.25);
				}
				if (state->currentTemp < ((double)state->setTemp - 5)){
					state->heater = ON;
				}
			}
		}else {
			if (state->currentTemp > (double)state->ambientTemp){
				state->currentTemp = (double)state->currentTemp - 0.25;
			}
		}
		update_sensors(state);
//		only run program if there is a program.
		if (state->currentStep > -1){		
			check_program(state);
			if (state->finished){
				return 2;		
			}			
		}
		if (state->currentTime%60 == 0){
			add_history(state);
		}

		state->currentTime = state->currentTime + 1;
	}

	//end simulate seconds
	return 0;
}
Exemple #7
0
static gboolean
gnm_nlsolve_prepare (GnmSolver *sol, WorkbookControl *wbc, GError **err,
                     GnmNlsolve *nl)
{
    gboolean ok;

    g_return_val_if_fail (sol->status == GNM_SOLVER_STATUS_READY, FALSE);

    gnm_solver_set_status (sol, GNM_SOLVER_STATUS_PREPARING);

    ok = check_program (sol, err);
    if (ok)
        ok = gnm_iter_solver_get_initial_solution (nl->isol, err);

    if (ok) {
        gnm_solver_set_status (sol, GNM_SOLVER_STATUS_PREPARED);
    } else {
        gnm_solver_set_status (sol, GNM_SOLVER_STATUS_ERROR);
    }

    return ok;
}
Exemple #8
0
int on_check(char *v, void *k)
{
	return check_program();
}