Exemplo n.º 1
0
bool callback(void *p,void* ud)
{
	if((long)ud==EXIT)
		{
			wc->LFSTK_clearWindow();
			setVars();
			wc->globalLib->LFSTK_saveVarsToFile("-",wmPrefs);
			printf("\n");
			mainloop=false;
			return(false);
		}

	switch((long)ud)
		{
		case PRINT:
			wc->LFSTK_clearWindow();
			setVars();
			wc->globalLib->LFSTK_saveVarsToFile("-",wmPrefs);
			printf("\n");
			break;

		case APPLY:
			wc->LFSTK_clearWindow();
			setVars();
			wc->globalLib->LFSTK_saveVarsToFile(env,wmPrefs);
			system("killall lfswmanager");
			sleep(1);
			system("lfswmanager &");
			break;
			break;
		}
	return(true);
}
Exemplo n.º 2
0
bool callback(void *p,void* ud)
{
	char *env;

	switch((long)ud)
		{
			case EXIT:
				setVars();
				wc->globalLib->LFSTK_saveVarsToFile("-",wc->globalLib->LFSTK_getTKArgs());
				printf("\n");
				mainloop=false;
				return(false);
				break;
				case PRINT:
				setVars();
				wc->globalLib->LFSTK_saveVarsToFile("-",wc->globalLib->LFSTK_getTKArgs());
				printf("\n");
				break;
			case APPLY:
				setVars();
				asprintf(&env,"%s/.config/LFS/lfstoolkit.rc",getenv("HOME"));
				wc->globalLib->LFSTK_saveVarsToFile(env,wc->globalLib->LFSTK_getTKArgs());
				free(env);
				break;
		}
	return(true);
}
Exemplo n.º 3
0
// New Interface!!!
bool openLogin::getUser(string & rId)
{
  bool bRet = false;
  
    // Check to see if a real user is here
#ifdef LOGIN_LITE_SECURITY
      sql = "Select u.id,u.first,u.last," // 0,1,2
            "u.login,u.password,u.phone,u.email," //
            "u.group_id, coalesce(g.site_admin,0) " // 3,4,5,6,7
            " from users u ";
      sql += " left join groups g on g.id=u.group_id where u.id = ";
#else
      sql = "Select u.id,u.group_id,u.first,u.last,"
            "u.login,u.password,u.phone_number,u.email,g.site_admin "
            " from users u inner join groups g on g.id=u.group_id where u.id = ";
#endif
  sql += rId;

  if( rs.open(sql) )
  {
    // set the data vars
    setVars();

    bRet = true;
    rs.close();
  } // end if query returned data
  else
  {
    lastError += "Could not fetch user!\n";
    lastError += "<!--";
    lastError += sql;
    lastError += "-->";
  }
  return bRet;
}
Exemplo n.º 4
0
/** Read GNode by parsing a file */
void GNode::read(MLParser & parser)
{
  parser.args(&attribList_,false);
  setVars();

  int tag = parser.tag(nodeTagTable);
  while (tag == TOK_NODE) {
    GNode *node = this->newNode();
    node->read(parser);
    childLink(node);
    tag = parser.tag(nodeTagTable);
  }
  if (tag != -TOK_NODE) {
    qDebug("Warning: /node missing\n");
  }
}
Exemplo n.º 5
0
palette::palette(const palette&other,Project*prj){
	this->prj=prj;
	rgbPal=0;
	setVars(prj->gameSystem);
	memcpy(rgbPal,other.rgbPal,std::min((colorCnt+colorCntalt)*(4+esize),(other.colorCnt+other.colorCntalt)*(4+other.esize)));
}
Exemplo n.º 6
0
palette::palette(Project*prj){
	this->prj=prj;
	rgbPal=0;
	setVars(prj->gameSystem);
	memset(rgbPal,0,(colorCnt+colorCntalt)*(4+esize));
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
    printf("HTCPCP/1.0 server starting\n");

    //ignore conf file if it doesn't exist
    if(access( "/etc/htcpcp.conf", F_OK ) != -1)
    {
        //read fom conf file
        FILE* confile = fopen("/etc/htcpcp.conf", "r");
        char tmp[255];
        while(fgets(tmp, sizeof(tmp), confile) != NULL)
        {
            //ignore comments
            if(tmp[0] == '#')
            {
                continue;
            }
            else
            {
                char* var;
                char* val;
                char* token;
                //get the variable being set
                token = strtok(tmp, "=");
                var = token;
                //get the value it's being set to
                token = strtok(NULL, "=");
                val = token;
                //set it
                setVars(var, val);
            }
        }
        fclose(confile);
    }
    
    sleep(30); //dirty hack to make sure WiFi is on before the program starts when using Systemd unit file
    potinfo.ready = 1;
    potinfo.lastbrew = time(NULL);
    
    int newsockfd;
    socklen_t clilen;
    char buffer[256];
    struct sockaddr_in serv_addr, cli_addr;
    int n;
    if(argc > 2)
    {
        //if the port is specified via command line, override default and conf file
        port = atoi(argv[1]);
    }
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
    {
        error("ERROR opening socket");
    }
    bzero((char *) &serv_addr, sizeof(serv_addr));

    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(port);
    if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
    {
        error("ERROR on binding");
    }

    signal(SIGINT, sig_handler);
    signal(SIGQUIT, sig_handler);
    signal(SIGTERM, sig_handler);
    //setup the GPIO pins 
    wiringPiSetup();
    pinMode (relay_pin, OUTPUT);
    pinMode (button_pin, INPUT);
    pinMode (led_pin, OUTPUT);
    digitalWrite(led_pin, HIGH);  //turn on the indicator LED
    
    //daemonize process
    daemon(1, 0);
    pthread_create(&HWThread, NULL, hardwareHandler, NULL);
    
    for(;;)  //listen for connections
    {
        listen(sockfd, 5);
        clilen = sizeof(cli_addr);
        newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
        if (newsockfd < 0)
        {
            error("ERROR on accept");
        }
        bzero(buffer,256);
        n = read(newsockfd,buffer,255);
        if (n < 0)
        {
            error("ERROR reading from socket");
        }
        char* returnHead = handleHeaders(buffer);
        n = write(newsockfd, returnHead, strlen(returnHead));
        if (n < 0) 
        {
            error("ERROR writing to socket");
        }
        close(newsockfd);
    }
    close(sockfd);
    digitalWrite(led_pin, LOW);
    digitalWrite(button_pin, LOW);
    return 0;
}
Exemplo n.º 8
0
DevFindDialog::DevFindDialog(QTextEdit *e)
 : QDialog(e), edit(e)
{
	setWindowTitle("Find text");
	
	connect(this, SIGNAL( accepted() ),
			this, SLOT  ( setVars() ) );
	
	QLabel *lbl;
	QGroupBox *g;
	QVBoxLayout *b;
	QGridLayout *l = new QGridLayout;
	
	text = new QLineEdit;
	lbl = new QLabel("Text to Find");
	l->addWidget(lbl, 0, 0, 1, 1);
	l->addWidget(text, 0, 1, 1, 3);
	
	g = new QGroupBox("Options");
	b = new QVBoxLayout;
	
	sensitive = new QCheckBox("Case &sensitive");
	b->addWidget(sensitive);
	
	bound = new QCheckBox("&Whole words only");
	b->addWidget(bound);
	
	g->setLayout(b);
	l->addWidget(g, 1, 0, 3, 2);
	
	g = new QGroupBox("Direction");
	b = new QVBoxLayout;
	
	forward = new QRadioButton("Forward");
	forward->toggle();
	b->addWidget(forward);
	
	backward = new QRadioButton("Backward");
	b->addWidget(backward);
	
	g->setLayout(b);
	l->addWidget(g, 1, 2, 3, 2);
	
	g = new QGroupBox("Scope");
	b = new QVBoxLayout;
	
	global = new QRadioButton("Global");
	global->toggle();
	b->addWidget(global);
	
	selection = new QRadioButton("Selected only");
	b->addWidget(selection);
	
	g->setLayout(b);
	l->addWidget(g, 4, 0, 3, 2);
	
	g = new QGroupBox("Origin");
	b = new QVBoxLayout;
	
	cursor = new QRadioButton("Cursor");
	cursor->toggle();
	b->addWidget(cursor);
	
	whole = new QRadioButton("Entire scope");
	b->addWidget(whole);
	
	g->setLayout(b);
	l->addWidget(g, 4, 2, 3, 2);
	
	b_accept = new QPushButton("&Find");
	connect(b_accept, SIGNAL( clicked() ),
			this	, SLOT  ( accept() ) );
	l->addWidget(b_accept, 7, 0, 1, 1);
	
	b_cancel = new QPushButton("&Cancel");
	connect(b_cancel, SIGNAL( clicked() ),
			this	, SLOT  ( reject() ) );
	l->addWidget(b_cancel, 7, 3, 1, 1);
	
	setLayout(l);
}
Exemplo n.º 9
0
bool openLogin::checkUser( const char * user, const char * password )
{
  // be pessimistic about the return code
  bool bRet = false;
  // be pessimistic about the error string
  lastError = "Bad Login / Password combination: ";
  // establish cookies
  cgiCookie cookie;
  // cookies valid for entire site
  cookie.setPath("/");

  if( user && password && strlen(user) && strlen(password) )
  {
    // check validity of user & password
#ifdef LOGIN_LITE_SECURITY
      sql = "Select u.id, u.first, u.last," // 0,1,2
            "u.login, u.password, u.phone, u.email, " // 3,4,5,6
            "u.group_id, coalesce(g.site_admin,0) " // 7,8
            " from users u left join groups g on g.id = u.group_id ";
      sql += " where u.login = '******' and u.password = '******'";
#else
    sql = "Select u.id,u.group_id,u.first,u.last," // 0,1,2,3
          "u.login,u.password,u.phone_number,u.email,g.site_admin " // 4,5,6,7,8
          " from users u inner join groups g on g.id = u.group_id ";
    sql += " where u.login = '******' and u.password = '******'";
#endif
    // DBG cerr << sql << endl;
    if( rs.open(sql) )
    {
      // set the data vars
      setVars();

      // set sesson cookies
      setCookieValue( cookie, token, id );

      // error? what error?
      lastError = "";
      // return true
      bRet = true;
      rs.close();
    } // end if query returned data
    else
    {
      lastError += rs.getErrors();
      lastError += sql;
      lastError += " no such user on this site, please try again. ";
    }
  } // end if user and password
  else
  {
    lastError += " both the login and password must be entered. ";
  }
  
  setCookieValue( cookie, "lastError", lastError );
  return bRet;
}