Exemplo n.º 1
0
int isPlacaValida(char* placa){
	int i;
	//printf("%d %s\n",strlen(placa),placa);
	if (strlen(placa)==7 ){
		int char3=isnumber(placa[3]);
		int char4=isnumber(placa[4]);
		//printf("chars: %d %d\n",char3,char4);
		if ( (!char3&&char4) || (!char4&&char3) )
			return 0;
		//printf("teste\n");
		if (char3&&char4){
			for (i=2;i>=0;i--)
				if (placa[i]>='A' && placa[i]<='Z')
					return 1;
		}else{
		//	printf("%s",placa);
			for (i=4;i>=0;i--)
				if (  (placa[i]=='A' ) || (placa[i]=='C' ) || (placa[i]=='M' ) || (placa[i]=='I' )||  (placa[i]=='P') ||(placa[i]<'A')||(placa[i]>'Z')){
					//printf("a");
					return 0;
				}
			return 1;	//}
		}
	}
	return 0;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	int i, j;
	char *str;
	FILE *fp;
	BinSTreeNode rootNode;
	for(i = 1; i < argc; i++){
		if(argv[i][0] != '-' && argv[i][0] != '/' && !(isnumber(argv[i][0]))){
			fp = fopen(argv[i], "r");
			if(fp == NULL) exit(1);
			add_from_file(fp, rootNode);
			fclose(fp);
		}
	}
	//	if(rootNode->word == NULL){
	//	while(1){
	//		fgets(str, N, stdin);
	//		add_from_line(str);
	//	}
	//	if(argc == 1) printTree(0);
	for(i = 1; i < argc; i++){
		if(argv[i][0] == '-' || argv[i][0] == '/' || isnumber(argv[i][0])){
			if(strcmp(argv[i], "-p") == 0 && i+1 < argc){
				if(isdigit(argv[i+1][0])){
					printf("printTree, %d\n", atoi((const char*)argv[i+1]));
					i++;
				}else{
					printf("printTree, 0\n");
				}
			}
			if(strcmp(argv[i], "-r") == 0){
				if(i+1 == argc || argv[i+1][0] != '/') exit(1);
				for(i++, j = 1; j < strlen(argv[i]); j++){
						if(argv[i][j] == '/'){
							str = cutstr(argv[i], 1, j-1);
							if(argv[i][j+1] == '0') printf("remove %s all\n", str);
							else printf("remove %s onece\n", str);
							break;
						}
				}
			}
			if(strcmp(argv[i], "-s") == 0){
				if(i+1 == argc || argv[i+1][0] != '/') exit(1);
				for(i++, j = 1; j < strlen(argv[i]); j++){
						if(argv[i][j] == '/'){
							char *str2 = cutstr(argv[i], j+1, strlen(argv[i])-2);
							str = cutstr(argv[i], 1, j-1);
							printf("substitute %s %s\n", str, str2);
							break;
						}
				}
				i++;
			}
		}
	}
		return 0;
}
Exemplo n.º 3
0
bool cPluginRadio::ProcessArgs(int argc, char *argv[])
{
    // Implement command line argument processing here if applicable.

    static struct option long_options[] = {
            { "files",      required_argument, NULL, 'f' },
            { "data",       required_argument, NULL, 'd' },
            { "live",       required_argument, NULL, 'l' },
            { "replay",     required_argument, NULL, 'r' },
            { "encrypted",  required_argument, NULL, 'e' },
            { "verbose",    required_argument, NULL, 'v' },
            { NULL }
    };
    
    int c;
    while ((c = getopt_long(argc, argv, "f:d:l:r:e:v:", long_options, NULL)) != -1) {
    switch (c) {
        case 'f':
                printf("vdr-radio: arg files-dir = %s\n", optarg);
                ConfigDir = strdup(optarg);
                ConfigDirParam = true;
                break;
        case 'd':
                printf("vdr-radio: arg data-dir = %s\n", optarg);
                DataDir = strdup(optarg);
                DataDirParam = true;
                break;
        case 'l':
                printf("vdr-radio: arg live-mpeg = %s\n", optarg);
                LiveFile = strdup(optarg);
                LiveFileParam = true;
                break;
        case 'r':
                printf("vdr-radio: arg replay-mpeg = %s\n", optarg);
                ReplayFile = strdup(optarg);
                ReplayFileParam = true;
                break;
        case 'v':
                printf("vdr-radio: arg verbose = %s\n", optarg);
                if (isnumber(optarg))
                    S_Verbose = atoi(optarg);
                break;
        case 'e':
                printf("vdr-radio: arg encrypted = %s\n", optarg);
                if (isnumber(optarg))
                    S_Encrypted = atoi(optarg);
                break;
        default:
                printf("vdr-radio: arg char = %c\n", c);
                return false;
        }
    }

    return true;
}
Exemplo n.º 4
0
int main(int argc, int argv) {
	if (argc != 4)
		return 1;
	if (!isnumber(argv[1]) || !isnumber(argv[2]) || !isnumber(argv[3]))
		return 2;
	long A = strtol(argv[1],0,10);
	if (A == 0) return 3;
	long B = strtol(argv[2],0,10);
	long Yi = strtol(argv[3],0,10);
	printf("El resultado es %f\n", (Yi - B)/ (float) A);
	return 0
}
Exemplo n.º 5
0
Token *Tokenizer::makeTokenInteger()
{
    if( isnumber(*m_nextc) ){
        m_remaindString = m_nextc;
        int value = 0;
        string::const_iterator start = m_nextc;
        while( isnumber(*m_nextc) ){
            value *= 10;
            value += *m_nextc - '0';
            m_nextc++;
        }
        return new TokenInteger(string( start, m_nextc ),value);
    }
    return 0;
}
Exemplo n.º 6
0
bool ToolBox::isdigit(std::string str, bool deci)
{
	bool point = false;
	bool expo = false;
	bool in = false;

	for (std::string::iterator it=str.begin(); it!=str.end(); ++it)
	{
		//std::cout << str.size() ;
		if (in == false && isnumber(it))
		{
			in = true;
		}
		if (!(isexpo(str, it, expo) || (isvirg(str, it, point, in) && deci) || issign(str, it, in) || isnumber(it)))
		{
			//std::cout << "return " << *it  <<"|"<< std::endl;
			return false;
		}
		//if (!((*it >= '0' && *it <= '9') || (*it == '.' && !point && deci == true && it!=str.end() - 1)
		//	|| (*it == '-' && in == false) || (*it == '+' && in == false) ))
		//	return false;
		//point = (*it == '.') ? true : point;
	}
	if (!in)
		return false;
	return true;
}
eDynamicDeviceReturnCode cDynamicDevice::SetIdle(const char *DevPath, bool Idle)
{
  if (!DevPath)
     return ddrcNotSupported;

  cMutexLock lock(&arrayMutex);
  int freeIndex = -1;
  int index = -1;
  if (isnumber(DevPath))
     index = strtol(DevPath, NULL, 10) - 1;
  else
     index = IndexOf(DevPath, freeIndex, -1);

  if ((index < 0) || (index >= numDynamicDevices))
     return ddrcNotFound;

  isyslog("dynamite: set device %s to %s", DevPath, (Idle ? "idle" : "not idle"));
  if (idleHook && !Idle)
     CallIdleHook(**idleHook, dynamicdevice[index]->GetDevPath(), Idle);
  if (((cDevice*)dynamicdevice[index])->SetIdle(Idle)) {
     if (idleHook && Idle)
        CallIdleHook(**idleHook, dynamicdevice[index]->GetDevPath(), Idle);
     }
  else if (idleHook && !Idle)
     CallIdleHook(**idleHook, dynamicdevice[index]->GetDevPath(), Idle);
  if (Idle) {
     dynamicdevice[index]->idleSince = time(NULL);
     dynamicdevice[index]->lastCloseDvr = dynamicdevice[index]->idleSince;
     }
  else {
     dynamicdevice[index]->idleSince = 0;
     dynamicdevice[index]->lastCloseDvr = time(NULL);
     }
  return ddrcSuccess;
}
Exemplo n.º 8
0
static int
add_to_form(const char *name, size_t nlen,
	    const char *value, size_t len,
	    void *closure)
{ term_t head = PL_new_term_ref();
  term_t tail = (term_t) closure;
  term_t val  = PL_new_term_ref();
  int rc;
  atom_t aname = 0;

  if ( isnumber(value, len) )
  { rc = unify_number(val, value, len);
  } else
  { rc = PL_unify_chars(val, PL_ATOM|REP_UTF8, len, value);
  }

  rc = ( rc &&
	 PL_unify_list(tail, head, tail) &&
	 (aname = PL_new_atom_nchars(nlen, name)) &&
	 PL_unify_term(head,
		       PL_FUNCTOR, PL_new_functor(aname, 1),
		       PL_TERM, val) );

  if ( aname )
    PL_unregister_atom(aname);

  return rc;
}
Exemplo n.º 9
0
 NestedInteger deserialize(string s) {
     function<bool(char)> isnumber = [](char c){ return (c == '-') || isdigit(c); };
     
     stack<NestedInteger> stk;
     stk.push(NestedInteger());
     
     for (auto it = s.begin(); it != s.end();) {
         const char & c = (*it);
         if (isnumber(c)) {
             auto it2 = find_if_not(it, s.end(), isnumber);
             int val = stoi(string(it, it2));
             stk.top().add(NestedInteger(val));
             it = it2;
         }
         else {
             if (c == '[') {
                 stk.push(NestedInteger());
             }
             else if (c == ']') {
                 NestedInteger ni = stk.top();
                 stk.pop();
                 stk.top().add(ni);
             }
             ++it;
         }
     }
     
     NestedInteger result = stk.top().getList().front();
     return result;
 }
Exemplo n.º 10
0
long int strtoi(char *s,int base,char **scan_end)
{
    int sign,value,overflow = 0;
    long int result = 0,oldresult;
    /* Evaluate sign */
    if (*s == '-') {
	sign = -1;
	s++;
    } else if (*s == '+') {
	sign = 1;
	s++;
    }
    else sign = 1;
    /* Skip trailing zeros */
    while (*s == '0') s++;
    /* Convert number */
    while (isnumber(*s,base)) {
	value = tonumber(*s++);
	if (value > base || value < 0) return(0);
	oldresult = result;
	result *= base;
	result += value;
	/* Detect overflow */
	if (oldresult > result) overflow = 1;
    }
    if (scan_end != 0L) *scan_end = s;
    if (overflow) result = INT_MAX;
    result *= sign;
    return(result);
}
Exemplo n.º 11
0
sniff(Biobuf *b)
{
	read first line of file into p;

	nf = getfields(p, f, nelem(f), ":");
	if(nf < 4)
		return nil;

	if(isnumber(f[0]) && !isnumber(f[2]))
		return _plan9;

	if(!isnumber(f[0]) && isnumber(f[2]))
		return _unix;

	return nil;
}
Exemplo n.º 12
0
/* psymbol - parse a symbol name */
LOCAL LVAL psymbol(LVAL fptr)
{
    int escflag;
    LVAL val;
    pname(fptr,&escflag);
    return (escflag || !isnumber(buf,&val) ? xlenter(buf) : val);
}
Exemplo n.º 13
0
static void
new_property(targ_scf_t *h,
	    tgt_node_t *n)
{
	scf_transaction_entry_t *e = NULL;
	scf_value_t *v = NULL;
	scf_type_t type;

	assert(n != NULL);

	e = scf_entry_create(h->t_handle);
	v = scf_value_create(h->t_handle);

	if (strcmp(n->x_value, "true") == 0 ||
	    strcmp(n->x_value, "false") == 0) {
		type = SCF_TYPE_BOOLEAN;
	} else if (strcmp(n->x_name, "main") == 0 ||
	    strcmp(n->x_name, "radius") == 0) {
		type = SCF_TYPE_ASTRING;
	} else if (strncmp(n->x_name, "I_", 2) == 0) {
		type = SCF_TYPE_ASTRING;
	} else if (strcmp(n->x_name, XML_ELEMENT_VERS) == 0) {
		type = SCF_TYPE_ASTRING;
	} else if (isnumber(n->x_value)) {
		type = SCF_TYPE_COUNT;
	} else {
		type = SCF_TYPE_ASTRING;
	}
	scf_transaction_property_new(h->t_trans, e, n->x_name, type);
	scf_value_set_from_string(v, type, n->x_value);
	scf_entry_add_value(e, v);
}
Exemplo n.º 14
0
float RPN_utility::calc(float x)
{
    std::stack<float> stack;
    //std::stringstream ss(rpn_formula);

    for (auto token : rpn_formula)
    {

        if ( isnumber(token) )
            stack.push(std::stof(token.toStdString()));
        else if ( token.length() == 1 && std::isalpha( token[0].toLatin1() ) )
            stack.push( x );

        else if (token.length() > 1) {

        float a = stack.top();
        stack.pop();



        stack.push ( COMMON_FUNCTION[token](a) ) ;

     } else if ( isoperator(token ) ) {
            float b = stack.top();
            stack.pop();
            float a = stack.top();
            stack.pop();

            stack.push ( OPERATION[ token[0].toLatin1() ](a,b) );
        }

    }

    return stack.top();
}
Exemplo n.º 15
0
void CMVArray::Set(int row,int col,const CMString& str)
{
	if (row>=0 && row<_nrows && col>=0 && col<_ncols) {
		size_t index = row*_ncols + col;
		if (isnumber(str.c_str())) {
			double d = _wtof(str.c_str());
			array[index].e = NULL;
			array[index].dVal = d;
		}
		else {
			CMExpression* e = new CMExpression(str.c_str());
			if (e->IsPolynomial()) arraystate |= containsPolynomials;
			if (e->Fail()) {
				SetState(vsFailed, 1);
				ReportError(XBadVardef, e->GetString());
			}
			array[index].e = e;
		}
		/*
		CMExpression* e = new CMExpression(str.c_str());
		if (e->IsPolynomial()) arraystate |= containsPolynomials;
		if (e->Fail()) {
  		 	SetState(vsFailed,1);
   			ReportError(XBadVardef,e->GetString());
	   }
	   array.AddAt((long)row*ncols+col,e);
	   */
	}
}
Exemplo n.º 16
0
static void read_number_token(ChessPgnTokenizer* tokenizer)
{
    int c;
    while ((c = tokenizer_getc(tokenizer)) != EOF && isnumber(c))
        chess_buffer_append_char(&tokenizer->buffer, c);
    tokenizer_ungetc(tokenizer);
}
Exemplo n.º 17
0
inline int strtoi(int *out, const char *str_in){
    if(str_in && out && isnumber(str_in)){
        *out = atoi(str_in);
        return (int) 0;
    }
    return (int) -1;
}
Exemplo n.º 18
0
/* This mount implements custom next and hasNext functions to ensure that only
 * the record that is iterated over is stored in memory. */
corto_iter onRequest(corto_object mount, corto_request *request) {
    corto_iter result;

    /* Create context data for the iterator */
    struct iterData *ctx = corto_calloc(sizeof(struct iterData));

    /* Support queries for a single number or starting from an offset */
    if (isnumber(request->expr)) ctx->current = atoi(request->expr);
    else ctx->current = request->offset;

    /* Preset id and value to reusable buffers in the iterData structure */
    ctx->result.id = ctx->id;

    /* Set values that will be the same for every result */
    ctx->result.parent = ".";
    ctx->result.type = "uint64";
    ctx->result.leaf = TRUE;
    result.udata = ctx;

    /* Set iterator callbacks */
    result.hasNext = hasNext;
    result.next = next;
    result.release = release;

    return result;
}
Exemplo n.º 19
0
int main(int argc, char *argv[])
{
	int c;

	if(argc < 3) {
		printf("usage: chown uid file ...\n");
		exit(4);
	}
	if(isnumber(argv[1])) {
		uid = atoi(argv[1]);
		goto cho;
	}
	if((pwd=getpwnam(argv[1])) == NULL) {
		printf("unknown user id: %s\n",argv[1]);
		exit(4);
	}
	uid = pwd->pw_uid;

cho:
	for(c=2; c<argc; c++) {
		stat(argv[c], &stbuf);
		if(chown(argv[c], uid, stbuf.st_gid) < 0) {
			perror(argv[c]);
			status = 1;
		}
	}
	exit(status);
}
Exemplo n.º 20
0
const cChannel* cServerConnection::ChannelFromString(const char *String, int *Apid, int *Dpid) {
	const cChannel *channel = NULL;
	char *string = strdup(String);
	char *ptr, *end;
	int apididx = 0;
	
	if ((ptr = strrchr(string, '+')) != NULL) {
		*(ptr++) = '\0';
		apididx = strtoul(ptr, &end, 10);
		Dprintf("found apididx: %d\n", apididx);
	}

	if (isnumber(string)) {
		int temp = strtol(String, NULL, 10);
		if (temp >= 1 && temp <= Channels.MaxNumber())
			channel = Channels.GetByNumber(temp);
	} else {
		channel = Channels.GetByChannelID(tChannelID::FromString(string));

		if (channel == NULL) {
			int i = 1;
			while ((channel = Channels.GetByNumber(i, 1)) != NULL) {
				if (String == channel->Name())
					break;

				i = channel->Number() + 1;
			}
		}
	}

	if (channel != NULL && apididx > 0) {
		int apid = 0, dpid = 0;
		int index = 1;

		for (int i = 0; channel->Apid(i) != 0; ++i, ++index) {
			if (index == apididx) {
				apid = channel->Apid(i);
				break;
			}
		}

		if (apid == 0) {
			for (int i = 0; channel->Dpid(i) != 0; ++i, ++index) {
				if (index == apididx) {
					dpid = channel->Dpid(i);
					break;
				}
			}
		}

		if (Apid != NULL) 
			*Apid = apid;
		if (Dpid != NULL) 
			*Dpid = dpid;
	}

	free(string);
	return channel;
}
Exemplo n.º 21
0
getrec(uchar *buf)	/* get next input record from whatever source */
{   /* note: tests whether buf == record */
    int c;
    static int firsttime = 1;

    if (firsttime) {
        firsttime = 0;
        initgetrec();
    }
    dprintf( ("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n",
              *RS, *FS, *ARGC, *FILENAME) );
    donefld = 0;
    donerec = 1;
    buf[0] = 0;
    while (argno < *ARGC || infile == stdin) {
        dprintf( ("argno=%d, file=|%s|\n", argno, file) );
        if (infile == NULL) {	/* have to open a new file */
            file = getargv(argno);
            if (*file == '\0') {	/* it's been zapped */
                argno++;
                continue;
            }
            if (isclvar(file)) {	/* a var=value arg */
                setclvar(file);
                argno++;
                continue;
            }
            *FILENAME = file;
            dprintf( ("opening file %s\n", file) );
            if (*file == '-' && *(file+1) == '\0')
                infile = stdin;
            else if ((infile = fopen((char *)file, "r")) == NULL)
                ERROR "can't open file %s", file FATAL;
            setfval(fnrloc, 0.0);
        }
        c = readrec(buf, recsize, infile);
        if (c != 0 || buf[0] != '\0') {	/* normal record */
            if (buf == record) {
                if (!(recloc->tval & DONTFREE))
                    xfree(recloc->sval);
                recloc->sval = record;
                recloc->tval = REC | STR | DONTFREE;
                if (isnumber(recloc->sval)) {
                    recloc->fval = atof(recloc->sval);
                    recloc->tval |= NUM;
                }
            }
            setfval(nrloc, nrloc->fval+1);
            setfval(fnrloc, fnrloc->fval+1);
            return 1;
        }
        /* EOF arrived on this file; set up next */
        if (infile != stdin)
            fclose(infile);
        infile = NULL;
        argno++;
    }
    return 0;	/* true end of file */
}
Exemplo n.º 22
0
Token tok(std::istream& in) {
  char c;

restart:
  c = in.get();

  if(c == '(') {
    return Token::open();
  }

  if(c == ')') {
    return Token::close();
  }

  if(isnumber(c)) {
    int val = (int)(c - 48);

    c = in.get();

    while(isnumber(c)) {
      val *= 10;
      val += (int)(c - 48);
      c = in.get();
    }

    in.putback(c);

    return Token::number(val);
  }

  if(!isspace(c) && isprint(c)) {
    std::ostringstream ss;

    while(!isspace(c) && isprint(c) && c != '(' && c != ')') {
      ss.put(c);
      c = in.get();
    }

    in.putback(c);
    return Token::sym(ss.str().c_str());
  }

  if(isspace(c)) goto restart;

  return Token::fin();
}
Exemplo n.º 23
0
bool Object::isIntFormat()
{
    for (int i=0; i<value.length(); i++)
    {
        if (!isnumber(int(value[i]))) return false;
    }
    return true;
}
Exemplo n.º 24
0
cxBool cxConstCharsIsNumber(cxConstChars s)
{
    CX_RETURN(s == NULL, false);
    for(cxInt i = 0; i < strlen(s); i++){
        if(!isnumber(s[i])){
            return false;
        }
    }
    return true;
}
Exemplo n.º 25
0
int isNumber(char *str){
	int i = 0;
	while(str[i] != 0){
		if(isnumber(str[i])){
			return 1;
		}
		i++;
	}
	return 0;
}
Exemplo n.º 26
0
int32_t compiler::to_literal(const std::string& s)
{
  if ( isnumber(s.c_str()) )
    return atoi(s.c_str());

  if ( ischar(s) )
    return to_ord(s);

  return -1;
}
Exemplo n.º 27
0
int main(){
		char* placa1=malloc(7*sizeof(char));
		char* placa2=malloc(7*sizeof(char));
		int numConfidencia;
		int pl1_tipoplaca;
 		int pl2_tipoplaca;
		long s1toNum=0;
		long s2toNum=0;

		scanf("%s",placa1);
		scanf("%s",placa2);
		scanf("%d",&numConfidencia);	
		int k=1;	
		while (((placa1[0]!='*')	 && (placa2[0]!='*') ) ){
			if ((isPlacaValida(placa2))){ //,&letter,&number)) ){
		//		printf("entrou\n");
				pl2_tipoplaca=2;
				pl1_tipoplaca=2;
				if (isnumber(placa2[3]))
					pl2_tipoplaca=1;
				if (isnumber(placa1[3]))
					pl1_tipoplaca=1;			
				s1toNum=placa2num(placa1,pl1_tipoplaca);
				s2toNum=placa2num(placa2,pl2_tipoplaca);
			//	printf("soma:%lu %lu\n",s1toNum,s2toNum);
				if (s2toNum>s1toNum)	{	
					if (s1toNum+numConfidencia>=s2toNum)
						printf("Y\n");
					if (s1toNum+numConfidencia<s2toNum || numConfidencia<1 || numConfidencia>1000000000)
						printf("N\n");	
				}else
					printf("N\n");											
			}else
				printf("N\n");						
			scanf("%s",placa1);
			scanf("%s",placa2);
			scanf("%d",&numConfidencia);		
			k++;
		}
		return 0;
}
Exemplo n.º 28
0
void interpret(Task_Data *IData)
{
	char *ptr;
	int *link;
	
	if (!word(IData))
		return;
	
	link = find(IData);
	
	ptr = (char*) (link + 1);
	if (link)
	{
		int len = (int)*ptr;
		ptr = ptr + RFLAGS(len) + 1 + ((int)(RFLAGS(len) + 1) % 2);
		
		if (IData->state == 0 || len & IMMED_FLAG)
		{
			IData->xt = (void (*)())(*(TOIP(ptr)) & 0xffff);
			
			
			IData->xt(&ptr,IData);
			
			//xt();
		} else
		{
			
			compile(TOIP(ptr),IData);
		}
	} else
	{
		
		if (isnumber(IData))
		{
			if (IData->state == 0)
			{
				
				DSPUSH(number(IData),IData->dsp);
				
			} else
			{
				ptr = (char*)find_a("LITERAL",Global_Dict->latest);
				compile(TOIP(get_exec_ptr(ptr)),IData);
				compile(TOIP(number(IData)),IData);
			}
		} else
		{
			EMITERRS("Error: Unrecognized command\n");
			//stacks_reset(); have to fix this
		}
	}
	
}
Exemplo n.º 29
0
bool Object::isDoubleFormat()
{
    //if (value[value.length()-1]=='.') value+="0"; //should I keep this?
    if (value[value.length()-1]=='.') return false; //or keep this?
    if (count(value.begin(), value.end(), '.')>1) return false; //too many decimal points
    
    for (int i=0; i<value.length(); i++)
    {
        if (!isnumber(int(value[i])) && value[i]!='.') return false;
    }
    return true;
}
Exemplo n.º 30
0
static void
lexnumber(fz_stream *f, unsigned char *s, int n)
{
	while (n > 1)
	{
		if (!isnumber(fz_peekbyte(f)))
			break;
		*s++ = fz_readbyte(f);
		n--;
	}
	*s = '\0';
}