Exemplo n.º 1
0
static int setdevname_pppoatm(const char *cp, const char **argv, int doit)
{
	struct sockaddr_atmpvc addr;
	extern struct stat devstat;
	if (device_got_set)
		return 0;
	//infolog("PPPoATM setdevname_pppoatm: '%s'", cp);
	memset(&addr, 0, sizeof addr);
	if (text2atm(cp, (struct sockaddr *) &addr, sizeof(addr),
	    T2A_PVC | T2A_NAME) < 0) {
               if(doit)
                   infolog("atm does not recognize: %s", cp);
		return 0;
           }
	if (!doit) return 1;
	//if (!dev_set_ok()) return -1;
	memcpy(&pvcaddr, &addr, sizeof pvcaddr);
	strlcpy(devnam, cp, sizeof devnam);
	devstat.st_mode = S_IFSOCK;
	if (the_channel != &pppoa_channel) {
		the_channel = &pppoa_channel;
		lcp_wantoptions[0].neg_accompression = 0;
		lcp_allowoptions[0].neg_accompression = 0;
		lcp_wantoptions[0].neg_asyncmap = 0;
		lcp_allowoptions[0].neg_asyncmap = 0;
		lcp_wantoptions[0].neg_pcompression = 0;
	}
	infolog("PPPoATM setdevname_pppoatm - SUCCESS:%s", cp);
	device_got_set = 1;
	return 1;
}
Exemplo n.º 2
0
GlShader::GlShader(const resources::ShaderSource &src)
	: GlSimpleObject([] (GLuint handle) { glDeleteShader(handle); } )
	, type(gl_shdr_type.get(src.get_stage()))
{
	if (src.get_lang() != resources::shader_lang_t::glsl) {
		throw Error(MSG(err) << "Unsupported shader language passed to OpenGL renderer.");
	}

	// allocate shader in opengl
	GLuint handle = glCreateShader(this->type);
	this->handle = handle;

	// load shader source
	const char* data = src.get_source().c_str();
	glShaderSource(handle, 1, &data, 0);

	// compile shader source
	glCompileShader(handle);

	// check compiliation result
	GLint status;
	glGetShaderiv(handle, GL_COMPILE_STATUS, &status);

	if (status != GL_TRUE) {
		GLint loglen;
		glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &loglen);

		std::vector<char> infolog(loglen);
		glGetShaderInfoLog(handle, loglen, 0, infolog.data());

		throw Error(MSG(err) << "Failed to compiler shader:\n" << infolog.data() );
	}
}
Exemplo n.º 3
0
void plugin_init(void)
{
#if defined(__linux__)
	extern int new_style_driver;	/* From sys-linux.c */
	if (!ppp_available() && !new_style_driver)
		fatallog("Kernel doesn't support ppp_generic - "
		    "needed for PPPoATM");
#else
	fatallog("No PPPoATM support on this OS");
#endif
	infolog("PPPoATM plugin_init");
	add_options(pppoa_options);
}
Exemplo n.º 4
0
std::string 
program::log() const
{
  GLint log_len;
  glGetProgramiv(id_, GL_INFO_LOG_LENGTH, &log_len);

  GLint size;
  char* buf = new char[log_len];

  glGetProgramInfoLog(id_, log_len, &size, buf);

  std::string infolog(buf);
  delete[] buf;

  return infolog;
}
Exemplo n.º 5
0
/**********************************************************************
* %FUNCTION: plugin_init
* %ARGUMENTS:
*  None
* %RETURNS:
*  Nothing
* %DESCRIPTION:
*  Initializes radattr plugin.
***********************************************************************/
void
plugin_init(void)
{
    radius_attributes_hook = print_attributes;

#if 0
    /* calling cleanup() on link down is problematic because print_attributes()
       is called only after PAP or CHAP authentication, but not when the link
       should go up again for any other reason */
    add_notifier(&link_down_notifier, cleanup, NULL);
#endif

    /* Just in case... */
    add_notifier(&exitnotify, cleanup, NULL);
    infolog("RADATTR plugin initialized.");
}
Exemplo n.º 6
0
	void attachShader(std::string& src, unsigned int type) {
		std::stringstream log;
		// create shader object
		GLuint s = glCreateShader(type);
		if (s == 0) {
			log << "Failed to create shader of type " << type << std::endl;
			THROW_EXCEPTION(log.str());
		}

		// set source code and compile
		const GLchar* src_list[1] = { src.c_str() };
		glShaderSource(s, 1, src_list, NULL);
		glCompileShader(s);

		// check for errors
		GLint compile_status;
		glGetShaderiv(s, GL_COMPILE_STATUS, &compile_status);
		if (compile_status != GL_TRUE) {
			// compilation failed
			log << "Compilation failed!" << std::endl;
			log << "--- source code ---" << std::endl;
			std::istringstream src_ss(src);
			std::string line;
			unsigned int i=0;
			while (std::getline(src_ss, line))
				log << std::setw(4) << std::setfill('0') << ++i << line << std::endl;

			GLint logsize;
			glGetShaderiv(s, GL_INFO_LOG_LENGTH, &logsize);
			if (logsize > 0) {
				std::vector<GLchar> infolog(logsize + 1);
				glGetShaderInfoLog(s, logsize, NULL, &infolog[0]);

				log << "--- error log ---" << std::endl;
				log << std::string(infolog.begin(), infolog.end()) << std::endl;
			}
			else {
				log << "--- empty log message ---" << std::endl;
			}
			THROW_EXCEPTION(log.str());
		}
		
		glAttachShader(name, s);
	}
Exemplo n.º 7
0
bool C_ShaderManager::M_CheckResult(GLuint id, GLuint status)
{
	GLint result = GL_FALSE;
	int infologlength=0;

	glGetShaderiv(id, status, &result);
	glGetShaderiv(id, GL_INFO_LOG_LENGTH, &infologlength);
	if(infologlength>1)
	{
		std::string infolog(infologlength, ' ');
		glGetShaderInfoLog(id, infologlength, NULL, &infolog[0]);
		std::cout << "FAILED! Info log length: " << infologlength << " characters." << std::endl;
		std::cout << "==== INFOLOG ====" << std::endl;
		std::cout << infolog << std::endl;
		return false;
	}
	std::cout << "OK!" << std::endl;
	return true;
}
Exemplo n.º 8
0
	void link() {
		std::stringstream log;
		glLinkProgram(name);

		// check for errors
		GLint linkstatus;
		glGetProgramiv(name, GL_LINK_STATUS, &linkstatus);
		if (linkstatus != GL_TRUE) {
			log << "Linking failed!" << std::endl;

			GLint logsize;
			glGetProgramiv(name, GL_INFO_LOG_LENGTH, &logsize);

			if (logsize > 0) {
				std::vector < GLchar > infolog(logsize + 1);
				glGetProgramInfoLog(name, logsize, NULL, &infolog[0]);
				log << "--- error log ---" << std::endl;
				log << std::string(infolog.begin(), infolog.end()) << std::endl;
			} else {
				log << "--- empty log message ---" << std::endl;
			}
			THROW_EXCEPTION(log.str());
		}
	}
Exemplo n.º 9
0
int main(int argc, char* argv[])
#endif
{
    setlocale(LC_NUMERIC, "C");

    std::stringstream dummy;
    PATHMANAGER::Init(dummy, dummy);

    ///  open Log file
    //----------------------------------------------------------------
    std::string logfilename = PATHMANAGER::GetLogDir() + "/log.txt";
    std::ofstream logfile(logfilename.c_str());
    if (!logfile)
    {
        std::cerr << "Couldn't open log file: " << logfilename << std::endl;
        return EXIT_FAILURE;
    }

    //  set up logging arrangement
    logging::splitterstreambuf infosplitter(std::cout, logfile);
    std::ostream infosplitterstream(&infosplitter);
    logging::splitterstreambuf errorsplitter(std::cerr, logfile);
    std::ostream errorsplitterstream(&errorsplitter);
    logging::logstreambuf infolog("INFO: ", infosplitterstream);	//logstreambuf infolog("INFO: ", logfile);
    logging::logstreambuf errorlog("ERROR: ", errorsplitterstream);

    //  primary logging ostreams
    std::ostream info_output(&infolog);
    std::ostream error_output(&errorlog);/**/


    ///  Load Settings
    //----------------------------------------------------------------
    SETTINGS* settings = new SETTINGS();
    std::string setFile = PATHMANAGER::GetSettingsFile();

    if (!PATHMANAGER::FileExists(setFile))
    {
        info_output << "Settings not found - loading defaults." << std::endl;
        LoadDefaultSet(settings,setFile);
    }
    settings->Load(setFile);  // LOAD
    if (settings->version != SET_VER)  // loaded older, use default
    {
        info_output << "Settings found, but older version - loading defaults." << std::endl;
        LoadDefaultSet(settings,setFile);
        settings->Load(setFile);  // LOAD
    }

    // HACK: we initialize paths a second time now that we have the output streams
    PATHMANAGER::Init(info_output, error_output);


    ///  Game start
    //----------------------------------------------------------------
    GAME* pGame = new GAME(info_output, error_output, settings);
    std::list <std::string> args;//(argv, argv + argc);
    pGame->Start(args);  //game.End();

    App* pApp = new App();
    pApp->pSet = settings;
    pApp->pGame = pGame;
    pGame->pOgreGame = pApp;

    try
    {
        if (settings->multi_thr > 0)
            boost::thread t(VprThread, pApp);

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        pApp->Run( settings->ogre_dialog || lpCmdLine[0]!=0 );  //Release change-
#else
        pApp->Run( settings->ogre_dialog);
#endif
    }
    catch (Ogre::Exception& e)
    {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBoxA( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl;
#endif
    }

    info_output << "Exiting" << std::endl;
    delete pApp;
    delete pGame;
    delete settings;
    return 0;
}
Exemplo n.º 10
0
/**********************************************************************
*%FUNCTION: openInterface
*%ARGUMENTS:
* ifname -- name of interface
* type -- Ethernet frame type (0 for any frame type)
* hwaddr -- if non-NULL, set to the hardware address
*%RETURNS:
* A file descriptor for talking with the Ethernet card.  Exits on error.
* Note that the Linux version of this routine returns a socket instead.
*%DESCRIPTION:
* Opens a BPF on an interface for all PPPoE traffic (discovery and
* session).  If 'type' is 0, uses promiscuous mode to watch any PPPoE
* traffic on this network.
***********************************************************************/
int
openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr)
{
    static int fd = -1;
    char bpfName[32];
    u_int optval;
    struct bpf_version bpf_ver;
    struct ifreq ifr;
    int sock;
    int i;

    /* BSD only opens one socket for both Discovery and Session packets */
    if (fd >= 0) {
	return fd;
    }

    /* Find a free BPF device */
    for (i = 0; i < 256; i++) {
	sprintf(bpfName, "/dev/bpf%d", i);
	if (((fd = open(bpfName, O_RDWR, 0)) >= 0) ||
	    (errno != EBUSY)) {
	    break;
	}
    }
    if (fd < 0) {
	switch (errno) {
	case EACCES:		/* permission denied */
	    {
		fatallog("Cannot open %s -- pppoe must be run as root.", bpfName);
	    }
	    break;
	case EBUSY:
	case ENOENT:		/* no such file */
	    if (i == 0) {
		fatallog("No /dev/bpf* devices (check your kernel configuration for BPF support)");
	    } else {
		fatallog("All /dev/bpf* devices are in use");
	    }
	    break;
	}
	fatallog("%s: %m", bpfName);
    }

    if ((sock = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
	fatallog("socket: %m");
    }

    /* Check that the interface is up */
    strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
    if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
	fatallog("ioctl(SIOCGIFFLAGS): %m");
    }
    if ((ifr.ifr_flags & IFF_UP) == 0) {
	fatallog("Interface %s is not up", ifname);
    }

    /* Fill in hardware address and initialize the packet filter rules */
    if (hwaddr == NULL) {
	fatallog("openInterface: no hwaddr arg.");
    }
    getHWaddr(sock, ifname, hwaddr);
    initFilter(fd, type, hwaddr);

    /* Sanity check on MTU -- apparently does not work on OpenBSD */
#if !defined(__OpenBSD__)
    strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
    if (ioctl(sock, SIOCGIFMTU, &ifr) < 0) {
	fatallog("ioctl(SIOCGIFMTU): %m");
    }
    if (ifr.ifr_mtu < ETH_DATA_LEN) {
	errorlog("Interface %s has MTU of %d -- should be %d." 
		"  You may have serious connection problems.",
		ifname, ifr.ifr_mtu, ETH_DATA_LEN);
    }
#endif

    /* done with the socket */
    if (close(sock) < 0) {
	fatallog("close: %m");
    }

    /* Check the BPF version number */
    if (ioctl(fd, BIOCVERSION, &bpf_ver) < 0) {
	fatallog("ioctl(BIOCVERSION): %m");
    }
    if ((bpf_ver.bv_major != BPF_MAJOR_VERSION) ||
        (bpf_ver.bv_minor < BPF_MINOR_VERSION)) {
	fatallog("Unsupported BPF version: %d.%d (kernel: %d.%d)",
			BPF_MAJOR_VERSION, BPF_MINOR_VERSION,
			bpf_ver.bv_major, bpf_ver.bv_minor);
    }

    /* allocate a receive packet buffer */
    if (ioctl(fd, BIOCGBLEN, &bpfLength) < 0) {
	fatallog("ioctl(BIOCGBLEN): %m");
    }
    if (!(bpfBuffer = (unsigned char *) malloc(bpfLength))) {
	fatallog("malloc");
    }

    /* reads should return as soon as there is a packet available */
    optval = 1;
    if (ioctl(fd, BIOCIMMEDIATE, &optval) < 0) {
	fatallog("ioctl(BIOCIMMEDIATE): %m");
    }

    /* Bind the interface to the filter */
    strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
    if (ioctl(fd, BIOCSETIF, &ifr) < 0) {
	fatallog("ioctl(BIOCSETIF) can't select interface %s: %m", ifname);
    }

    infolog("Interface=%s HWaddr=%02X:%02X:%02X:%02X:%02X:%02X Device=%s Buffer size=%d",
	   ifname, 
	   hwaddr[0], hwaddr[1], hwaddr[2],
	   hwaddr[3], hwaddr[4], hwaddr[5],
	   bpfName, bpfLength);
    return fd;
}
Exemplo n.º 11
0
void Object3D::setShaderProgram(const char *vertexShader, const char *fragmentShader){
	GLuint vsSource, fsSource;
	vsSource = glCreateShader(GL_VERTEX_SHADER);
	fsSource = glCreateShader(GL_FRAGMENT_SHADER);

	glShaderSource(fsSource, 1, &fragmentShader, 0);
	glShaderSource(vsSource, 1, &vertexShader, 0);

	glCompileShader(vsSource);
	glCompileShader(fsSource);

	GLint success = 0;

	glGetShaderiv(fsSource, GL_COMPILE_STATUS, &success);
	if (!success){
		GLint maxLength = 0;
		glGetShaderiv(fsSource, GL_INFO_LOG_LENGTH, &maxLength);

		std::vector<GLchar> infolog(maxLength);
		glGetShaderInfoLog(fsSource, maxLength, &maxLength, &infolog[0]);
		std::cout << infolog.data() << std::endl;

		return;
	}

	success = 0;
	glGetShaderiv(vsSource, GL_COMPILE_STATUS, &success);
	if (!success){
		GLint maxLength = 0;
		glGetShaderiv(vsSource, GL_INFO_LOG_LENGTH, &maxLength);

		std::vector<GLchar> infolog(maxLength);
		glGetShaderInfoLog(vsSource, maxLength, &maxLength, &infolog[0]);
		std::cout << infolog.data() << std::endl;

		return;
	}

	shaderProgram = glCreateProgram();
	glAttachShader(shaderProgram, vsSource);
	glAttachShader(shaderProgram, fsSource);

	glLinkProgram(shaderProgram);
	glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
	if (success == GL_FALSE){
		GLint maxLength = 0;
		glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &maxLength);

		std::vector<GLchar> infolog(maxLength);
		glGetProgramInfoLog(shaderProgram, maxLength, &maxLength, &infolog[0]);
		std::cout << infolog.data() << std::endl;
		return;
	}

	glDetachShader(shaderProgram, vsSource);
	glDetachShader(shaderProgram, fsSource);


	attributeUV = glGetAttribLocation(shaderProgram, "vertexUV");
	attributeTex = glGetUniformLocation(shaderProgram, "textureSampler");

	hasShaderProgram = true;
	if (attributeUV == -1){
		std::cout << "UV not bound. " << std::endl;
		hasShaderProgram = false;
	}
	if (attributeTex == -1){
		std::cout << "Texture not bound. " << std::endl;
		hasShaderProgram = false;
	}
}