Example #1
0
/*
Name:   processmsg_throw
Desc:   handle a THRW msg received from server
Args:
    playerid:   id of current player
    val1:       first thrown value
    val2:       second thrown value
Returns:
    0 on success, nonzero on failure
Globals:appname,scores,runningscore,activeplayer
*/
int processmsg_throw(const char *playerid, const char *val1, const char *val2) {
    long int iplayerid, ival1, ival2;
    const char *errstr = "%s: protocol error\n";

    /* sanity checks + string to int conversions */
    if(strtoint(playerid, &iplayerid) != 0 || iplayerid > 2 || iplayerid < 0) {
        (void)fprintf(stderr, errstr, appname);
        return(-1);
    }
    if(strtoint(val1, &ival1) != 0 || ival1 > 6 || ival1 < 0) {
        (void)fprintf(stderr, errstr, appname);
        return(-1);
    }
    if(strtoint(val2, &ival2) != 0 || ival2 > 6 || ival2 < 0) {
        (void)fprintf(stderr, errstr, appname);
        return(-1);
    }

    /* switch active player */
    if(activeplayer != iplayerid) {
        activeplayer = iplayerid;
        runningscore = 0;
    }

    /* process thrown values */
    if(ival1 == ival2) {
        scores[iplayerid] -= runningscore;
        runningscore = 0;
    } else {
        scores[iplayerid ] += ival1 + ival2;
        runningscore += ival1 + ival2;
    }

    return(0);
}
Example #2
0
//Создание нового таба
void MainWindow::on_new_2_triggered()
{
    QStringList lst;
    lst << tr("C++") << tr("Pascal") << tr("Appendix");
    bool ok;
    QString item = QInputDialog::getItem(this, tr("Выбор языка"),tr("Выбор языка"), lst, 0, false, &ok);
    if (ok && !item.isEmpty())
    {
        if (item=="C++")
            cur_lang=CPP;
        if (item=="Pascal")
            cur_lang=PAS;
        if (item=="Appendix")
            cur_lang=APX;
        //-----------------
        tabs.push_back(new Editor(0,cur_lang));
        QString format;
        switch (tabs[n]->getLang())
        {
        case CPP:
            format = ".cpp";
            break;
        case PAS:
            format = ".pas";
            break;
        case APX:
            format = ".apx";
            break;
        }
        ui->tabWidget->addTab(tabs.back(),QString("Tab")+QString(strtoint(n)+format));
        n++;
        tabs.back()->filename=QString("@@@/Tab")+QString(strtoint(n));
    }
}
Example #3
0
int main (int argc, char *argv[])
{
	int opt, rows, cols;
	char buf[10];
	if(argc < 3) {
		perror("not enough arguments usage: coder rows cols [-r][-d]");
		exit(EXIT_FAILURE);
	}	
	errno = 0;
	rows = strtoint(argv[1]);
	cols = strtoint(argv[2]);
	if(rows == -1 || cols == -1){
		perror("arguments are not in valid format. should be int");
		exit(EXIT_FAILURE);
	}
	while ((opt = getopt(argc, argv, "de")) != -1) {
		switch(opt) {
		case 'd':
			encrypt(rows, cols);	
			break;
		case 'e':
			encrypt(rows, cols);
			break;
		default:
			
			break;
		}
	}
	return 0;
}
void tokenizeConfig(char *config, char *delim)
{
    char *storage [30];
    char *token;
    char *value;
    char str[1024];
    int pos = 0, i = 0, tokNum = 0;
    
    /* get the first token */
    token = strtok(config, delim);
    
    /* walk through other tokens */
    while( token != NULL ){
        storage[pos] = token;
        //        printf( "tokens %s\n", token );//commented out printf checker
        pos++;
        tokNum++;
        token = strtok(NULL, delim);
    }
    storage[pos] = NULL;
    
    for (i=0; i<tokNum; i++) {
        //        printf("\n%s %s %s", storage[i],storage[i+1],storage[i+2]);
        if (strcmp(storage[i], "filename") == 0) {
            strcpy(filename,storage[i+1]);
            i++;
        }else if (strcmp(storage[i], "windowsize") == 0) {
            strcpy(windowsize,storage[i+1]);
            i++;
        }else if (strcmp(storage[i], "chunksize") == 0) {
            strcpy(chunksize,storage[i+1]);
            i++;
        }else if (strcmp(storage[i], "isn") == 0) {
            strcpy(isn,storage[i+1]);
            i++;
        }else if (strcmp(storage[i], "timeout") == 0) {
            strcpy(timeout,storage[i+1]);
            i++;
        }else{
            strcpy(addr,storage[i+1]);
            strcpy(port,storage[i+2]);
            i = i+2;
        }
        
    }
    
    windowsizeInt = strtoint(windowsize);
    chunksizeInt = strtoint(chunksize);
    isnInt = strtoint(isn);
    timeoutInt = strtoint(timeout);
    
    printf(" FILENAME: %s", filename);
    printf("\n CHUNK SIZE: %d", chunksizeInt);
    printf("\n WINDOW SIZE: %d", windowsizeInt);
    printf("\n INITIAL SEQ NUM: %d", isnInt);
    printf("\n TIMEOUT: %d", timeoutInt);
    printf("\n ADDRESS: %s", addr);
    printf("\n PORT: %s \n", port);
    
}
Example #5
0
 void imoptmen_buta(Widget iw_temp, void * data, void * call_data)
 {

 /* names_height: pixel height of the filename */
 if( (names   = XmToggleButtonGadgetGetState(iw_names)) )
     names_height = 12; 
 else
     names_height = 0;
 
 keepxy  = XmToggleButtonGadgetGetState(iw_keepxy);
 newline = XmToggleButtonGadgetGetState(iw_newline);
 nuscrn  = XmToggleButtonGadgetGetState(iw_nuscrn);
 listfi  = XmToggleButtonGadgetGetState(iw_listfi);
 movie   = XmToggleButtonGadgetGetState(iw_movieo);

 if (strtoint(iw_marlef,"left margin",&marlef) == FALSE) return;

 if (strtoint(iw_martop,"top margin", &martop) == FALSE) return;

 if (strtoint(iw_marx,  "x margin",   &marx)   == FALSE) return;

 if (strtoint(iw_mary,  "y margin",   &mary)   == FALSE) return;

 if (strtoint(iw_iskip, "reduction",  &iskip)  == FALSE) return;

 XtUnmanageChild(iw_imoptmen);
 }
Example #6
0
uint process_condition(DeviceInfo info, long long int compare_value, int value_type, int condition)
{
	long long int actual_value = 0;

	switch (value_type)
	{
		case 0:
			if (info.curr_val == "U")
				return 0;
			actual_value = strtoint(info.curr_val);
			break;

		case 1: 
			if (info.delta_val == "U")
				return 0;
			actual_value = strtoint(info.delta_val);
			break;

		case 2: 
			if (info.rate_val == "U")
				return 0;
			actual_value = strtoint(info.rate_val);
			break;
		
		case 3:
			if (info.last_val == "U")
				return 0;
			actual_value = strtoint(info.last_val);
			break;
	}

	switch (condition)
	{
		case 0:	if (actual_value < compare_value)
				return 1;
			break;

		case 1: if (actual_value == compare_value)
				return 1;
			break;

		case 2: if (actual_value > compare_value)
				return 1;
			break;

		case 3: if (actual_value <= compare_value)
				return 1;
			break;

		case 4: if (actual_value != compare_value)
				return 1;
			break;

		case 5: if (actual_value >= compare_value)
				return 1;
			break;
	}

	return 0;
} // end process_condition()
Example #7
0
File: ack.c Project: shiift/CSE4095
int main(int argc, char* argv[])
{
    if(argc != 3){
        printf("You must enter two inputs.\n");
        return 0;
    }
    int m, n;
    m = strtoint(argv[1]);
    n = strtoint(argv[2]);
    printf("Ack(%d,%d) = %d\n", m, n, ackermann(m, n));
}
Example #8
0
void doWrite(char** argv, char argc)
{
	if(argc == 3)
	{
		unsigned char addr = strtoint(argv[1]);
		unsigned char val  = strtoint(argv[2]);
		_SFR_IO8(addr) = val;
		printf("OK\n");
	}
	else
		printf("err: addr value\n");
}
Example #9
0
void doI2CWrite(char** argv, char argc)
{
	if(argc == 3)
	{
		i2c_start();
		i2c_write(0x98);
		i2c_write(strtoint(argv[1]));
		i2c_write(strtoint(argv[2]));
		i2c_stop();
		printf("OK\n");
	}
	else
		printf("err: addr1 val1 addr2 val2\n");
}
Example #10
0
static int cmd_fputc(int argc, char *argv[])
{
	char tempstr[1024];
	if(argc > 3)
	{
		my_errno = TOO_MANY_ARGUMENTS;
		return 1;
	}
	if(argc < 3 )
	{
		my_errno = TOO_FEW_ARGUMENTS;
		return 1;
	}
	int fd = strtoint(argv[1]);
	if(fd >= 0)
	{
		char buff = argv[2][0];
		int bytesread = svc_write(fd,buff);
		if(bytesread == 1)
		{
			sprintf(tempstr,"%c written\r\n",buff);uprintf(tempstr);
			return 0;
		}
	}
	sprintf(tempstr,"could not write file\r\n");uprintf(tempstr);
	return 1;
}
Example #11
0
static int cmd_fgetc(int argc, char *argv[])
{
	char tempstr[1024];
	if(argc > 2)
	{
		my_errno = TOO_MANY_ARGUMENTS;
		return 1;
	}
	if(argc < 2 )
	{
		my_errno = TOO_FEW_ARGUMENTS;
		return 1;
	}
	int fd = strtoint(argv[1]);
	if(fd >= 0)
	{
		char buff;
		int bytesread = svc_read(fd,&buff);
		if(bytesread == 1)
		{
			sprintf(tempstr,"%c\r\n",buff);uprintf(tempstr);
			return 0;
		}
	}
	sprintf(tempstr,"could not read file\r\n");uprintf(tempstr);
	return 1;
}
bool client_handler::read_message(handler *h, buffer &buf) {
    int plen = buf.length();

    Log::d("read_message1");
    if (serv->read_chunk(h, &buf)) {
        Log::d("fd(" + inttostr(h->fd.get_fd()) + ") asked for disconnection");
        disconnect();
        return false;
    }
    Log::d("read_message2");
    if (message_type == NOT_EVALUATED) {
        // recalc message len
        int lb = find_double_line_break(buf.string_data(), plen);
        if (lb != -1) {
            //Log::d("plen is " + inttostr(plen) + ", lb is " + inttostr(lb) + " in \n\"" + buf.string_data() + "\"");

            std::string content_length_str;
            int len;
            if (extract_header(buf.string_data(), lb, "Content-Length", content_length_str)) {
                len = strtoint(content_length_str);
                message_type = VIA_CONTENT_LENGTH;
            } else {
                len = 0;
                message_type = extract_header(buf.string_data(), lb, "Transfer-Encoding", content_length_str)
                               ? VIA_TRANSFER_ENCODING : WITHOUT_BODY;
            }
            message_len = len + lb;
        }
    }

    if (message_type != HTTPS_MODE) {
        Log::d("read_message(" + inttostr(buf.length()) + ", " + inttostr(message_len) + ")");
    }

    if (message_type == NOT_EVALUATED) {
        return false;
    }

    if (message_type == VIA_TRANSFER_ENCODING) {
        while (buf.length() > message_len) {
            /*Log::d("kek is  " + inttostr((int) buf.string_data()[message_len - 1]) + " " +
                   inttostr((int) buf.string_data()[message_len]) + " " +
                   inttostr((int) buf.string_data()[message_len + 1]));*/
            if (buf.string_data()[message_len] == '0') {
                return true;
            }
            size_t linebreak = buf.string_data().find("\r\n", (size_t) message_len);
            if (linebreak != std::string::npos) {
                std::string chunklen = buf.string_data().substr((size_t) message_len, linebreak - message_len);
                Log::d("Next chunk len is " + chunklen);
                message_len += chunklen.length() + hextoint(chunklen) + 4;
            } else {
                break;
            }
        }
        return false;
    } else {
        return buf.length() == message_len;
    }
}
Example #13
0
/**
 * Recipe value of the entire contents of a container.
 *
 * This appears to just generate a hash value, which I guess for now
 * works ok, but the possibility of duplicate hashes is certainly
 * possible.
 * @param op Container for which to generate a hash.
 * @return Hash value. */
static int content_recipe_value(object *op)
{
	char name[MAX_BUF];
	object *tmp = op->inv;
	int tval = 0, formula = 0;

	while (tmp)
	{
		tval = 0;
		strcpy(name, tmp->name);

		if (tmp->title)
		{
			snprintf(name, sizeof(name), "%s %s", tmp->name, tmp->title);
		}

		tval = (strtoint(name) * (tmp->nrof ? tmp->nrof : 1));

#ifdef ALCHEMY_DEBUG
		LOG(llevDebug, "DEBUG: Got ingredient %d %s(%d)\n", tmp->nrof ? tmp->nrof : 1, name, tval);
#endif

		formula += tval;
		tmp = tmp->below;
	}

#ifdef ALCHEMY_DEBUG
	LOG(llevDebug, "DEBUG: Formula value=%d\n", formula);
#endif

	return formula;
}
Example #14
0
int main()
{   
	printf("%d\n", strtoint("49"));
	printf("%f\n", strtodouble("49.958"));
    system("pause");
    return 0;
}
static ssize_t NFC_enable_write(struct file *filp,
                                       const char *buff,
                                       size_t len,
                                       loff_t *off)
{
    char bbuf[128];
    int retlen;
    retlen=copy_from_user(bbuf,buff,len);
    bbuf[len]=0;
//    printk("\n NFC_enable write -- Str=%s\n",bbuf);
    
    if(strtoint(bbuf))
    {
        printk("set NFC Enable.\n");
	gpio_set_value(NFC_ENABLE, 1);			//fa33 reverse this part

	msleep(50);

	gpio_set_value(NFC_ENABLE, 0);

	msleep(50);

	gpio_set_value(NFC_ENABLE, 1);
    }
    else
    {
        printk("set NFC Disable.\n");
	gpio_set_value(NFC_ENABLE, 1);	
    }
	
    return len;
}
Example #16
0
void process_responses(DeviceInfo info, MYSQL *mysql)
{
	MYSQL_RES	*mysql_res;
	MYSQL_ROW	mysql_row;
	int			notification_res;

	string query = 	string("SELECT	notifications.command, responses.parameters, responses.id ") 	+
			string("FROM	responses, notifications ")			+
			string("WHERE	responses.event_id=") + inttostr(info.event_id) + " " +
			string("AND	responses.notification_id=notifications.id AND notifications.disabled = 0");

	mysql_res = db_query(mysql, &info, query);

	for (uint i = 0; i < mysql_num_rows(mysql_res); i++)
	{
		mysql_row = mysql_fetch_row(mysql_res);
		info.response_id = strtoint(mysql_row[2]);
		string command = string(mysql_row[0]) + " " + string(mysql_row[1]);
		command = expand_parameters(info, command);
		if (command[0] != '/')
			command = get_setting(setPathLibexec) + "/" + command;
		debuglogger(DEBUG_RESPONSE, LEVEL_INFO, &info, "Running Response: " + command);
		notification_res = system(command.c_str());
	}

} // end process_responses()
Example #17
0
void doGet(char** argv, char argc)
{
	if(argc == 2)
	{
		unsigned int light = strtoint(argv[1]);
		unsigned int xmin;
		unsigned int xmax;
		unsigned int ymin;
		unsigned int ymax;
		unsigned int shift;
		AMBILIGHT_LIGHT = light;
		AMBILIGHT_COMPONENT = 0;
		asm("nop");
		xmin = AMBILIGHT_DATA;
		AMBILIGHT_COMPONENT = 1;
		asm("nop");
		xmax = AMBILIGHT_DATA;
		AMBILIGHT_COMPONENT = 2;
		asm("nop");
		ymin = AMBILIGHT_DATA;
		AMBILIGHT_COMPONENT = 3;
		asm("nop");
		ymax = AMBILIGHT_DATA;
		AMBILIGHT_COMPONENT = 4;
		asm("nop");
		shift = AMBILIGHT_DATA;
		printf("%d: %d %d %d %d %d\n", light, xmin, xmax, ymin, ymax, shift);
	}
	else
		printf("err: light\n");
}
Example #18
0
int main(int argc, char *argv[])
{
  int sockfd,n;
  
  if (argc<2)
  {
    printf("Pas assez de parametres.\n");
    exit(0);
  }
  else
    printf("Connexion au port %s ...\n",argv[1]);


  sockfd=tutti_connect("192.168.0.106",strtoint(argv[1]));
  n=0;
  while (n++<20)
  {
    sleep(1);
    tutti_send_msg(sockfd,"0");
  }

  
  printf("Fin de la discussion");
 

  tutti_deconnect(sockfd);
  
  return 0;
}
Example #19
0
 void fillmen_buta(Widget iw_temp, XtPointer data, XtPointer call_data)
 {
 char *         string;
 char           filtertype[2];

 if (strtoint(iw_ixseed,"X seed",&ixseed) == FALSE) return;

 if (strtoint(iw_iyseed,"Y seed", &iyseed) == FALSE) return;

 if (ixseed  < 1 || ixseed  > nsamold) 
    {
    spout("*** X seed range is: 1...nsam"); 
    return;
    }

 if (iyseed < 1 || iyseed > nrowold) 
    {
    spout("*** Y seed range is: 1...nrow"); 
    return;
    }

 if (strtoint(iw_fillconnect,"Connectivity",&fillconnect) == FALSE) return;
 if (fillconnect != 4 && fillconnect != 8) 
    {
    spout("*** Connectivity must be 4 or 8!"); 
    return;
    }

 /* find threshold */
 string = XmTextGetString(iw_thresh);
 sscanf(string,"%f",&threshval);
 if (threshval > fmaxold) threshval = fmaxold;
 if (threshval < fminold) threshval = fminold;
 if (string) free(string);

 /* find fillval */
 string = XmTextGetString(iw_fillval);
 sscanf(string,"%f",&fillval);
 if (string) free(string);

 XtUnmanageChild(iw_fillmen);

 filtertype[0] = 'x';
 filtertype[1] = '\0';
 filter_but(iw_temp, (XtPointer) filtertype, call_data);
 }
Example #20
0
uint process_event(DeviceInfo info, MYSQL *mysql, int trigger_type, int last_status, int situation, long int last_triggered, string name)
{
	MYSQL_RES	*mysql_res;
	MYSQL_ROW	mysql_row;
	uint		status = 0;

	string query = "SELECT `value`, `value_type`, `condition`, `logic_condition` FROM `conditions` WHERE `event_id` = '" + inttostr(info.event_id) + "' ORDER BY `id`";
	mysql_res = db_query(mysql, &info, query);

	for (uint i = 0; i < mysql_num_rows(mysql_res); i++)
	{
		mysql_row = mysql_fetch_row(mysql_res);

		if (i == 0)
		{
			status = process_condition(info, strtoint(mysql_row[0]), strtoint(mysql_row[1]), strtoint(mysql_row[2]));
		}
		else
		{
			switch (strtoint(mysql_row[3]))
			{
				case 0:	status = status && process_condition(info, strtoint(mysql_row[0]), strtoint(mysql_row[1]), strtoint(mysql_row[2]));
					break;
				case 1:	status = status || process_condition(info, strtoint(mysql_row[0]), strtoint(mysql_row[1]), strtoint(mysql_row[2]));
					break;
			}
		}
	}

	mysql_free_result(mysql_res);

	if (status == 0)
	{
		debuglogger(DEBUG_EVENT, LEVEL_INFO, &info, "Not Triggered.");
		db_update(mysql, &info, "UPDATE events SET last_status=0 WHERE id=" + inttostr(info.event_id));
		return 0;
	}
	else
	{
		debuglogger(DEBUG_EVENT, LEVEL_INFO, &info, "Triggered.");
		
		// setup parameters for the response to use.
		info.parameters.push_front(ValuePair("event_name", name));
		info.parameters.push_front(ValuePair("situation", situations[situation]));

		if ((uint) last_status != status)
		{
			db_update(mysql, &info, "UPDATE events SET last_triggered=UNIX_TIMESTAMP(NOW()), last_status=1 WHERE id=" + inttostr(info.event_id));
			db_update(mysql, &info, "INSERT INTO event_log SET date=UNIX_TIMESTAMP(NOW()), time_since_last_change=UNIX_TIMESTAMP(NOW())-" + inttostr(last_triggered) + ", event_id=" + inttostr(info.event_id));

			process_responses(info, mysql);
		}

		return 1;
	}
} // end process_event()
int main(int argc, char const *argv[]) {
  printf("%x\n", (unsigned)~0 );
  printf("%x\n", ~0 );
  printf("%x\n", 1 );
  printf("%x\n", 0 );
  char str[] = "-123";
  printf("%d\n", strtoint( str ) );
  return 0;
}
Example #22
0
/**
 * "Danger" level will determine how bad the backfire could be if the
 * user fails to concoct a recipe properly. Factors include the number of
 * ingredients, the length of the name of each ingredient, the user's
 * effective level, the user's Int and the enchantment on the mixing
 * device (aka "cauldron"). Higher values of 'danger' indicate more
 * danger. Note that we assume that we have had the caster ready the
 * alchemy skill *before *this routine is called (no longer auto-readies
 * that skill).
 * @param caster Who is trying alchemy.
 * @param cauldron Container used.
 * @return Danger value. */
static int calc_alch_danger(object *caster, object *cauldron)
{
	object *item;
	char name[MAX_BUF];
	int danger = 0, nrofi = 0;

	/* Knowing alchemy skill reduces yer risk */
	if (caster->chosen_skill && caster->chosen_skill->stats.sp == SK_ALCHEMY)
	{
		danger -= SK_level(caster);
	}

	/* Better cauldrons reduce risk */
	danger -= cauldron->magic;

	/* Higher Int, lower the risk */
	danger -= 3 * (caster->stats.Int - 15);

	/* Ingredients. Longer names usually mean rarer stuff. Thus the
	 * backfire is worse. Also, more ingredients means we are attempting
	 * a more powerful potion, and thus the backfire will be worse. */
	for (item = cauldron->inv; item; item = item->below)
	{
		strcpy(name, item->name);

		if (item->title)
		{
			snprintf(name, sizeof(name), "%s %s", item->name, item->title);
		}

		danger += (strtoint(name) / 1000) + 3;
		nrofi++;
	}

	if (nrofi > 1)
	{
		danger *= nrofi;
	}

	/* Using a bad device is *very* stupid */
	if (QUERY_FLAG(cauldron, FLAG_CURSED))
	{
		danger += 80;
	}

	if (QUERY_FLAG(cauldron, FLAG_DAMNED))
	{
		danger += 200;
	}

#ifdef ALCHEMY_DEBUG
	LOG(llevDebug, "DEBUG: calc_alch_danger() returned danger=%d\n", danger);
#endif

	return danger;
}
Example #23
0
/*
Name:   parseargs
Desc:   parses and processes cli args
Args:
    argc:   argument count
    argv:   arguments
Returns:
    0 on success, nonzero on failure
Globals:appname,config
*/
int parseargs(int argc, char **argv) {
    int opt, arg_l, arg_n, arg_p;

    arg_l = arg_n = arg_p = 0;
    while((opt = getopt(argc, argv, "l:n:p:h")) > -1) {
        switch(opt) {
            case 'n':
                if(optarg == NULL) {
                    (void)fprintf(stderr, "%s: option %c requires an argument\n", appname, opt);
                    return(1);
                }
                arg_n++;
                config.name = optarg;
                break;
            case 'p':
                if(optarg == NULL) {
                    (void)fprintf(stderr, "%s: option %c requires an argument\n", appname, opt);
                    return(1);
                }
                arg_p++;
                config.port = optarg; 
                break;
            case 'l':
                if(strtoint(optarg, &config.limit) != 0) {
                    (void)fprintf(stderr, "%s: option %c requires an argument\n", appname, opt);
                    return(1);
                }
                arg_l++;
                break;
            case 'h':
            case '?':
                usage();
                return(-1);
            default:
                assert(0);
        }
    }

    /* n MUST be specified while l and p may be specified */
    if(arg_l > 1 ||
       arg_p > 1 ||
       arg_n != 1) {
        usage();
        return(1);
    }

    /* only one host may be specified */
    if(optind != argc - 1) {
        usage();
        return(1);
    } else {
        config.host = argv[optind]; 
    }

    return(0);
}
Example #24
0
 void wid_posiz_buta(Widget iw_temp, XtPointer data, XtPointer call_data)

 { 
 /* Recover values from the text boxes */
 if (iw_ix    > (Widget)0 && strtoint(iw_ix,   "x position",&ix_posiz)    
             == FALSE) return;
 if (iw_iy    > (Widget)0 && strtoint(iw_iy,   "y position",&iy_posiz)    
             == FALSE) return;
 if (iw_icols > (Widget)0 && strtoint(iw_icols,"columns",   &icols_posiz)
             == FALSE) return;
 if (iw_irows > (Widget)0 && strtoint(iw_irows,"rows",      &irows_posiz)
             == FALSE) return;

 /* Unmanage wid_posiz widget */
 XtUnmanageChild(iw_posizt);

 /* call routine passed in data */
 (*(void (*)(void)) data)(); 
 }
Example #25
0
void doResult(char** argv, char argc)
{
	unsigned int light;
	unsigned int repeat;
	unsigned int i;

	if(argc == 2)
	{
		light = strtoint(argv[1]);
		repeat = 1;
	}
	else if(argc == 3)
	{
		light = strtoint(argv[1]);
		repeat = strtoint(argv[2]);
	}
	else
	{
		printf("err: light\n");
		return;
	}

	for(i = 0; i < repeat; ++i)
	{
		unsigned int cr;
		unsigned int cb;
		unsigned int y;
		AMBILIGHT_LIGHT = light;
		AMBILIGHT_COMPONENT = 15;
		asm("nop");
		do { cr = AMBILIGHT_DATA; } while((cr & 1) == 0);
		AMBILIGHT_COMPONENT = 8;
		asm("nop");
		cr = AMBILIGHT_DATA;
		AMBILIGHT_COMPONENT = 9;
		asm("nop");
		cb = AMBILIGHT_DATA;
		AMBILIGHT_COMPONENT = 10;
		asm("nop");
		y = AMBILIGHT_DATA;
		printf("%d: %d %d %d\n", light, cr, cb, y);
	}
}
Example #26
0
void doRead(char** argv, char argc)
{
	if(argc == 2)
	{
		unsigned char addr = strtoint(argv[1]);
		unsigned char val = _SFR_IO8(addr);
		printf("%d=%d\n", (int)addr, (int)val);
	}
	else
		printf("err: addr\n");
}
static ssize_t barcode_enable_write(struct file *filp, const char *buff, size_t len, loff_t *off) {
    char bbuf[128];
    int retlen = copy_from_user(bbuf,buff,len);
    bbuf[len] = 0;
    if (strtoint(bbuf)) {
        printk("set Barcode Power Enable.\n");
    } else {
        printk("set Barcode Power Disable.\n");
    }
    return len;
}
Example #28
0
void TLevelLink::parseLinkStr(const std::vector<CString>& pLink)
{
	unsigned int offset = 0;

	// Find the whole level name.
	newLevel = pLink[0];
	if (pLink.size() > 7)
	{
		offset = pLink.size() - 7;
		for (unsigned int i = 0; i < offset; ++i)
			newLevel << " " << pLink[1 + i];
	}

	x = strtoint(pLink[1 + offset]);
	y = strtoint(pLink[2 + offset]);
	width = strtoint(pLink[3 + offset]);
	height = strtoint(pLink[4 + offset]);
	newX = pLink[5 + offset];
	newY = pLink[6 + offset];
}
Example #29
0
int main(int argc, char** argv) {
    socksserver srv;
    static const char defaultip[] = "127.0.0.1";
    op_state opt_storage, *opt = &opt_storage;
    op_init(opt, argc, argv);
    SPDECLAREC(o_port, op_get(opt, SPL("port")));
    SPDECLAREC(o_listenip, op_get(opt, SPL("listenip")));

    int log;
    if(CONFIG_LOG) {
        SPDECLAREC(o_log, op_get(opt, SPL("log")));
        log = o_log->size ? strtoint(o_log->ptr, o_log->size) : 1;
    } else log = 0;

    int uid, gid;
    if(CONFIG_IDSWITCH) {
        SPDECLAREC(o_uid, op_get(opt, SPL("uid")));
        SPDECLAREC(o_gid, op_get(opt, SPL("gid")));
        uid = o_uid->size ? strtoint(o_uid->ptr, o_uid->size) : -1;
        gid = o_gid->size ? strtoint(o_gid->ptr, o_gid->size) : -1;
    } else {
        uid = -1;
        gid = -1;
    }
    SPDECLAREC(o_user, op_get(opt, SPL("user")));
    SPDECLAREC(o_pass, op_get(opt, SPL("pass")));

    char* ip = o_listenip->size ? o_listenip->ptr : (char*) defaultip;
    int port = o_port->size ? strtoint(o_port->ptr, o_port->size) : 1080;

    if(CONFIG_LOG && op_hasflag(opt, SPLITERAL("-help"))) syntax(opt);

    if((o_user->size && (!o_pass->size || o_user->size > 255)) || (o_pass->size && (!o_user->size || o_pass->size > 255))) {
        LOGPUTS(1, SPL("fatal: username or password exceeding 255 chars, or only one of both set\n"));
        return 1;
    }
    if(CONFIG_DAEMONIZE && op_hasflag(opt, SPL("d"))) daemonize();
    socksserver_init(&srv, ip, port, log, o_user, o_pass, uid, gid);

    return 0;
}
Example #30
0
LOCAL int ICACHE_FLASH_ATTR setChart(const char *value, uint valueLen)
{
	if (!value || !*value || !valueLen)
		return ERROR;

	uint chart = strtoint(value);
	if (chart < 0 || chart > 3)
		return ERROR;

	config.chart = chart;
	return OK;
}