Exemple #1
0
static char *microdvd_load_tags(struct microdvd_tag *tags, char *s)
{
    s = check_for_italic_slash_marker(tags, s);

    while (*s == '{') {
        char *start = s;
        char tag_char = *(s + 1);
        struct microdvd_tag tag = {0};

        if (!tag_char || *(s + 2) != ':')
            break;
        s += 3;

        switch (tag_char) {

        /* Style */
        case 'Y':
            tag.persistent = MICRODVD_PERSISTENT_ON;
        case 'y':
            while (*s && *s != '}') {
                int style_index = indexof(MICRODVD_STYLES, *s);

                if (style_index >= 0)
                    tag.data1 |= (1 << style_index);
                s++;
            }
            if (*s != '}')
                break;
            /* We must distinguish persistent and non-persistent styles
             * to handle this kind of style tags: {y:ib}{Y:us} */
            tag.key = tag_char;
            break;

        /* Color */
        case 'C':
            tag.persistent = MICRODVD_PERSISTENT_ON;
        case 'c':
            while (*s == '$' || *s == '#')
                s++;
            tag.data1 = strtol(s, &s, 16) & 0x00ffffff;
            if (*s != '}')
                break;
            tag.key = 'c';
            break;

        /* Font name */
        case 'F':
            tag.persistent = MICRODVD_PERSISTENT_ON;
        case 'f': {
            int len = indexof(s, '}');
            if (len < 0)
                break;
            tag.data_string = s;
            tag.data_string_len = len;
            s += len;
            tag.key = 'f';
            break;
        }

        /* Font size */
        case 'S':
            tag.persistent = MICRODVD_PERSISTENT_ON;
        case 's':
            tag.data1 = strtol(s, &s, 10);
            if (*s != '}')
                break;
            tag.key = 's';
            break;

        /* Charset */
        case 'H': {
            //TODO: not yet handled, just parsed.
            int len = indexof(s, '}');
            if (len < 0)
                break;
            tag.data_string = s;
            tag.data_string_len = len;
            s += len;
            tag.key = 'h';
            break;
        }

        /* Position */
        case 'P':
            if (!*s)
                break;
            tag.persistent = MICRODVD_PERSISTENT_ON;
            tag.data1 = (*s++ == '1');
            if (*s != '}')
                break;
            tag.key = 'p';
            break;

        /* Coordinates */
        case 'o':
            tag.persistent = MICRODVD_PERSISTENT_ON;
            tag.data1 = strtol(s, &s, 10);
            if (*s != ',')
                break;
            s++;
            tag.data2 = strtol(s, &s, 10);
            if (*s != '}')
                break;
            tag.key = 'o';
            break;

        default:    /* Unknown tag, we consider it's text */
            break;
        }

        if (tag.key == 0)
            return start;

        microdvd_set_tag(tags, tag);
        s++;
    }
    return check_for_italic_slash_marker(tags, s);
}
Exemple #2
0
void Chunk::doWork(){

    double maxChange = 0.0;
    double * temp;

    iterations++;
    if((iterations == ITER)&&(CkMyPe()==0))
        numFinished++;
    //if (thisIndex == 0)  
    //  CkPrintf("Iteration: %d\n",iterations);

    for (int i=0; i<WORK; ++i) {
    resetBoundary();

    if((thisIndex !=0)&&(thisIndex != total-1))
        for (int i=1; i<myxdim+1; i++)
            for (int j=1; j<myydim-1; j++) {
                B[indexof(i,j,myydim)] = 
                    (0.2)*(A[indexof(i,  j,  myydim)] +
                            A[indexof(i,  j+1,myydim)] +
                            A[indexof(i,  j-1,myydim)] +
                            A[indexof(i+1,j,  myydim)] +
                            A[indexof(i-1,j,  myydim)]);

                double change =  B[indexof(i,j,myydim)] - A[indexof(i,j,myydim)];
                if (change < 0) change = - change;
                if (change > maxChange) maxChange = change;
            }

    if(thisIndex == 0)
        for (int i=1; i<myxdim; i++)
            for (int j=1; j<myydim-1; j++) {
                B[indexof(i,j,myydim)] = 
                    (0.2)*(A[indexof(i,  j,  myydim)] +
                            A[indexof(i,  j+1,myydim)] +
                            A[indexof(i,  j-1,myydim)] +
                            A[indexof(i+1,j,  myydim)] +
                            A[indexof(i-1,j,  myydim)]);

                double change =  B[indexof(i,j,myydim)] - A[indexof(i,j,myydim)];
                if (change < 0) change = - change;
                if (change > maxChange) maxChange = change;
            }

    if(thisIndex == total-1) {
        for (int i=1; i<myxdim; i++)
            for (int j=1; j<myydim-1; j++) {
                B[indexof(i,j,myydim)] = 
                    (0.2)*(A[indexof(i,  j,  myydim)] +
                            A[indexof(i,  j+1,myydim)] +
                            A[indexof(i,  j-1,myydim)] +
                            A[indexof(i+1,j,  myydim)] +
                            A[indexof(i-1,j,  myydim)]);

                double change =  B[indexof(i,j,myydim)] - A[indexof(i,j,myydim)];
                if (change < 0) change = - change;
                if (change > maxChange) maxChange = change;
            }
    }

    temp = A;
    A =B;	
    B=temp;  
    }

}
Exemple #3
0
#include "j.h"

static F2(jtcanta);

static A jtcants(J jt,A a,A w,A z){A a1,q,y;B*b,*c;I*u,wr,zr;P*wp,*zp;
 RZ(a&&w&&z);
 RZ(a=grade1(a));
 wr=AR(w); wp=PAV(w); a1=SPA(wp,a);
 zr=AR(z); zp=PAV(z);
 ASSERT(wr==zr,EVNONCE);
 RZ(b=bfi(wr,a1,1));
 GA(q,B01,wr,1,0); c=BAV(q); u=AV(a); DO(wr, c[i]=b[u[i]];);
 SPB(zp,a,ifb(wr,c));
 SPB(zp,e,ca(SPA(wp,e)));
 RZ(y=fromr(grade1(indexof(a,a1)),SPA(wp,i)));
 RZ(q=grade1(y));
 SPB(zp,i,from(q,y));
 SPB(zp,x,from(q,canta(over(zero,increm(grade1(less(a,a1)))),SPA(wp,x))));
 R z;
}    /* w is sparse */

#define CANTA(T,exp)  \
 {T*u=(T*)zv,*v=(T*)wv;                                                  \
  DO(zn, exp; j=r-1; ++tv[j]; d+=mv[j];                                  \
  while(j&&sv[j]==tv[j]){d+=mv[j-1]-mv[j]*sv[j]; tv[j]=0; ++tv[--j];});  \
 }

static F2(jtcanta){A m,s,t,z;B b;C*wv,*zv;I*av,c,d,j,k,*mv,r,*sv,*tv,wf,wr,*ws,zn,zr;
 RZ(a&&w);
 av=AV(a); ws=AS(w); wr=AR(w); r=jt->rank?jt->rank[1]:wr; jt->rank=0;
Exemple #4
0
int generate_key (char ** const result, const unsigned char qflag, const unsigned char rflag, const unsigned char eflag, const unsigned char uflag, const unsigned char sflag, const char * dvalue, const char * ovalue, const char * tvalue, const char * pvalue, const char * kvalue) {

  int ret = 0;
  
  int i = 0;
  unsigned char tvalue_uchar = 0;
  if (tvalue==0) {
    tvalue_uchar=0;
  }
  else {
    tvalue_uchar=(unsigned char)(atoi(tvalue));
  }
  if (uflag==1) {
    publen = 65;
  }
  result[0] = (char *)malloc(200);
  result[1] = (char *)malloc(100);
  strcpy(result[0],"");
  strcpy(result[1],"");

  if (rflag == 1) {
    if (eflag != 1) {
      strcpy(result[0],"A private key is needed to decrypt\n");
      return(1);
    }
    unsigned char * privkey = malloc(privlen);
    int randomData = open("/dev/random", O_RDONLY);
    size_t randomDataLen = 0;
    while (randomDataLen < privlen) {
      ssize_t res = read(randomData, privkey + randomDataLen, privlen - randomDataLen);
      if (res < 0) {
	strcpy(result[0],"Cannot read /dev/random\n");
	return(1);
      }
      randomDataLen += res;
    }
    close(randomData);

    /* Get the address twice and compare */
    char ** bc_address = (char **)malloc(sizeof(char *)*2);
    char ** pubkey_bc = (char **)malloc(sizeof(char *)*2);
    for (i=0; i<2; i++) {
      unsigned char * pubkey = malloc(publen);
      ret = priv_to_pub(pubkey,publen,privkey,privlen);
      pubkey_bc[i] = malloc(35);
      ret = pubkey_to_bc_format(pubkey_bc[i],pubkey,publen,tvalue_uchar);
      if (ret==-1) {
	strcpy(result[0],"Cannot convert public key to address\n");
	return(1);
      }
      bc_address[i] = pubkey_bc[i] + ret;
      free(pubkey);
    }
    i = 0;
    do {
      if (bc_address[0][i] != bc_address[1][i]) {
        strcpy(result[0],"Address generations inconsistent\n");
        return(1);
      }
      i++;
    } while (bc_address[0][i] != '\0');
    strcpy(result[0],bc_address[0]);

    if (pvalue != 0) {
      
      int passlen = strlen(pvalue);
      if (passlen > 42) {
	strcpy(result[0],"The passphrase cannot be longer than 42 characters\n");
	return(1);
      }
      if (passlen==0) {
	strcpy(result[0],"The passphrase cannot be empty\n");
	return(1);
      }
      for (i=0;i<passlen;i++) {
	if (indexof(pvalue[i],b64chars)==-1) {
	  strcpy(result[0],"The passphrase may only contain letters, numbers, spaces, and hyphens\n");
	  return(1);
	}
      }
      if (pvalue[0] == ' ') {
	strcpy(result[0],"The first character of the passphrase cannot be the space character\n");
	return(1);
      }

      unsigned char * password_uchar = (unsigned char *)malloc(privlen+1);
      ret = b64_to_uchar(password_uchar,privlen,pvalue,strlen(pvalue),1);
      if (ret < 0) {
	strcpy(result[0],"Cannot parse passphrase\n");
	return(1);
      }

      unsigned char * privkey_encrypted= (unsigned char *)malloc(privlen);
      ret = add_uchars(privkey_encrypted,privkey,password_uchar,privlen);

      unsigned char * privkey_decrypted = (unsigned char *)malloc(privlen);
      ret = subtract_uchars(privkey_decrypted,privkey_encrypted,password_uchar,privlen);

      for (i=0;i<privlen;i++) {
	if (privkey_decrypted[i] != privkey[i]) {
	  strcpy(result[0],"Cannot encrypt private key\n");
	  return(1);
	}
      }
      free(privkey_decrypted);
      free(password_uchar);
      free(privkey);
      privkey = privkey_encrypted;
    }

    /* Get the private key twice and compare */
    char ** bc_privkey = (char **)malloc(sizeof(char *)*2);
    char ** privkey_bc = (char **)malloc(sizeof(char *)*2);
    for (i=0; i<2; i++) {
      privkey_bc[i] = (char *)malloc(53);
      ret = privkey_to_bc_format(privkey_bc[i],privkey,privlen,0,0);
      if (ret==-1) {
	strcpy(result[0],"Cannot convert private key to the Bitcoin format\n");
	return(1);
      }
      else if (ret==-2) {
	strcpy(result[0],"Private key does not match public key\n");
	return(1);
      }
      bc_privkey[i] = privkey_bc[i] + ret;
    }    i = 0;
    do {
      if (bc_privkey[0][i] != bc_privkey[1][i]) {
        strcpy(result[0],"Private key generations inconsistent\n");
        return(1);
      }
      i++;
    } while (bc_privkey[0][i] != '\0');
    strcpy(result[1],bc_privkey[0]);

    if (qflag == 1) {
      ret = qrencode(bc_address[0],bc_privkey[0],dvalue,ovalue,pvalue,eflag,sflag);
      if (ret!=0) {
	strcpy(result[0],"Cannot qr-encode\n");
	return(1);
      }
    }

    free(privkey);
    free(pubkey_bc[0]);
    free(pubkey_bc[1]);
    free(pubkey_bc);
    free(privkey_bc[0]);
    free(privkey_bc[1]);
    free(privkey_bc);
    free(bc_address);
    free(bc_privkey);
  }

  else if (kvalue != 0) {
    
    unsigned char * privkey_1_full = malloc(privlen+7);
    int privkey_offset = b58_to_uchar(privkey_1_full,privlen+6,kvalue,strlen(kvalue),1);
    if (privkey_offset < 0) {
      strcpy(result[0],"Cannot parse private key\n");
      return(1);
    }
    unsigned char * privkey_1 = privkey_1_full + privkey_offset;

    unsigned char * hash1 = malloc(32);
    SHA256(privkey_1,privlen+1+1-privkey_offset,hash1);
    unsigned char * hash2 = malloc(32);
    SHA256(hash1,32,hash2);
    privkey_1 += 1;
    unsigned char * privkey_1_hash = privkey_1+privlen+1-privkey_offset;
    for (i=0;i<4;i++) {
      if (privkey_1_hash[i]!=hash2[i]) {
	strcpy(result[0],"Invalid private key\n");
	return(1);
      }
    }

    unsigned char * privkey_2 = (unsigned char *)malloc(privlen);

    if (pvalue == 0) {
      memcpy(privkey_2,privkey_1,privlen);
      for (i=0; i<privlen; i++) {
	if (privkey_2[i] != privkey_1[i]) {
	  strcpy(result[0],"Cannot copy private key\n");
	  return(1);
	}
      }
    }
    else {

      int passlen = strlen(pvalue);
      if (passlen > 42) {
        strcpy(result[0],"The passphrase cannot be longer than 42 characters\n");
        return(1);
      }
      if (passlen==0) {
        strcpy(result[0],"The passphrase cannot be empty\n");
        return(1);
      }
      for (i=0;i<passlen;i++) {
        if (indexof(pvalue[i],b64chars)==-1) {
          strcpy(result[0],"The passphrase may only contain letters, numbers, spaces, and hyphens\n");
          return(1);
        }
      }
      if (pvalue[0] == ' ') {
        strcpy(result[0],"The first character of the passphrase cannot be a space\n");
        return(1);
      }

      unsigned char * password_uchar = (unsigned char *)malloc(privlen+1);
      ret = b64_to_uchar(password_uchar,privlen,pvalue,strlen(pvalue),1);
      if (ret < 0) {
	strcpy(result[0],"Cannot parse passphrase\n");
        return(1);
      }
      unsigned char * privkey_1_check = (unsigned char *)malloc(privlen);
      if (eflag == 1) {
	ret = add_uchars(privkey_2,privkey_1,password_uchar,privlen);
	ret = subtract_uchars(privkey_1_check,privkey_2,password_uchar,privlen);
	for (i=0; i<privlen; i++) {
	  if (privkey_1[i] != privkey_1_check[i]) {
	    strcpy(result[0],"Cannot add passphrase to private key\n");
	    return(1);
	  }
	}
      }
      else {
	ret = subtract_uchars(privkey_2,privkey_1,password_uchar,privlen);
	ret = add_uchars(privkey_1_check,privkey_2,password_uchar,privlen);
	for (i=0; i<privlen; i++) {
          if (privkey_1[i] != privkey_1_check[i]) {
            strcpy(result[0],"Cannot subtract passphrase from private key\n");
            return(1);
          }
        }
      }
      free(privkey_1_check);
      free(password_uchar);
    }

    if (privkey_offset == 1) {
      publen = 65;
    }
    else {
      publen = 33;
    }

    /* Get the address twice and compare */
    char ** bc_address = (char **)malloc(sizeof(char *)*2);
    char ** pubkey_bc = (char **)malloc(sizeof(char *)*2);
    for (i=0; i<2; i++) {
      unsigned char * pubkey = malloc(publen);
      if (eflag == 1) {
	ret = priv_to_pub(pubkey,publen,privkey_1,privlen);
      }
      else {
	ret = priv_to_pub(pubkey,publen,privkey_2,privlen);
      }
      pubkey_bc[i] = malloc(35);
      ret = pubkey_to_bc_format(pubkey_bc[i],pubkey,publen,tvalue_uchar);
      if (ret==-1) {
	strcpy(result[0],"Cannot convert public key to address\n");
	return(1);
      }
      bc_address[i] = pubkey_bc[i] + ret;
      free(pubkey);
    }
    i = 0;
    do {
      if (bc_address[0][i] != bc_address[1][i]) {
	strcpy(result[0],"Address generations inconsistent\n");
	return(1);
      }
      i++;
    } while (bc_address[0][i] != '\0');
    strcpy(result[0],bc_address[0]);

    /* Get the private key twice and compare */
    char ** bc_privkey = (char **)malloc(sizeof(char *)*2);
    char ** privkey_bc = (char **)malloc(sizeof(char *)*2);
    for (i=0; i<2; i++) {
      privkey_bc[i] = (char *)malloc(53);
      ret = privkey_to_bc_format(privkey_bc[i],privkey_2,privlen,0,0);
      if (ret==-1) {
	strcpy(result[0],"Cannot convert private key to the Bitcoin format\n");
	return(1);
      }
      else if (ret==-2) {
	strcpy(result[0],"Private key does not match public key\n");
	return(1);
      }
      bc_privkey[i] = privkey_bc[i] + ret;
    }
    do {
      if (bc_privkey[0][i] != bc_privkey[1][i]) {
        strcpy(result[0],"Private key generations inconsistent\n");
        return(1);
      }
      i++;
    } while (bc_privkey[0][i] != '\0');
    strcpy(result[1],bc_privkey[0]);

    if (qflag == 1) {
      ret = qrencode(bc_address[0],bc_privkey[0],dvalue,ovalue,pvalue,eflag,sflag);
      if (ret!=0) {
        strcpy(result[0],"Cannot qr-encode\n");
        return(1);
      }
    }

    free(privkey_1_full);
    free(privkey_2);
    free(hash1);
    free(hash2);
    free(pubkey_bc[0]);
    free(pubkey_bc[1]);
    free(pubkey_bc);
    free(privkey_bc[0]);
    free(privkey_bc[1]);
    free(privkey_bc);
    free(bc_address);
    free(bc_privkey);
  }
  
  return(0);
}
Exemple #5
0
int b64_to_uchar (unsigned char * const result, const size_t m, const char * b64, const size_t n, const unsigned char check_reverse) {

  BIGNUM * tot_bn = 0;
  BN_dec2bn(&tot_bn,"0");
  BIGNUM * pow64 = 0;
  BN_dec2bn(&pow64,"1");
  BIGNUM * one64 = 0;
  BN_dec2bn(&one64,"64");

  int i = 0;
  const unsigned char * input_it = b64 + n - 1;
  for (i=0; i<n; i++) {
    BIGNUM * input_bn = 0;
    char * input_str = malloc(4);
    sprintf(input_str,"%d",indexof(*input_it,b64chars));
    BN_dec2bn(&input_bn,input_str);
    BN_CTX * ctx = BN_CTX_new();
    BN_mul(input_bn, pow64, input_bn, ctx);
    BN_add(tot_bn,tot_bn,input_bn);
    BN_mul(pow64, pow64, one64, ctx);
    BN_free(input_bn);
    if (input_str != 0) {
      free(input_str);
    }
    BN_CTX_free(ctx);
    input_it--;
  }

  unsigned char * output_it = result + m;
  *output_it = '\0';
  output_it--;

  BIGNUM * one256 = 0;
  BN_dec2bn(&one256,"256");

  int offset = m;
  while (BN_cmp(tot_bn,one256) >= 0) {
    BN_CTX * ctx = BN_CTX_new();
    BIGNUM * tot_mod_256 = BN_new();
    BN_div(tot_bn, tot_mod_256, tot_bn, one256, ctx);
    char * tot_mod_256_str = BN_bn2dec(tot_mod_256);
    *output_it = atoi(tot_mod_256_str);
    BN_free(tot_mod_256);
    BN_CTX_free(ctx);
    free(tot_mod_256_str);
    output_it--;
    offset--;
  }
  char * tot_str = BN_bn2dec(tot_bn);
  *output_it = atoi(tot_str);
  offset--;

  input_it = b64;
  for (i=1; i<n; i++) {
    if ((*input_it == b64chars[0]) && (offset > 0)) {
      output_it--;
      *output_it = 0;
      offset--;
      input_it++;
    }
    else {
      break;
    }
  }

  if (check_reverse == 1) {
    unsigned char * result_b64 = (char *)malloc(n+1);
    int ret = uchar_to_b64(result_b64,n,result+offset,m-offset,0);
    if (ret < 0) {
      return(-1);
    }
    input_it = b64;
    const char * input_chk = result_b64 + ret;
    for (i=0; i<n; i++) {
      if (*input_chk != *input_it) {
        return(-1);
      }
      input_it++;
      input_chk++;
    }
    free(result_b64);
  }

  int offset_saved = offset;
  while (offset > 0) {
    output_it--;
    *output_it = 0;
    offset--;
  }

  BN_free(tot_bn);
  BN_free(pow64);
  BN_free(one256);
  BN_free(one64);
  free(tot_str);

  return(offset_saved);
}
Exemple #6
0
static void parse_rtsp_response(const struct iphdr *iph, const struct tcphdr *tcph, const char *buffer, int len)
{
	const char *line = buffer;
	int i;
	struct ip_port_pair spair, *ppair;
	unsigned long dport;

	spair.dstip = iph->saddr;
	spair.srcip = iph->daddr;
	spair.dstport = ntohs(tcph->source);
	spair.srcport = ntohs(tcph->dest);

	if(!ht_contains(preparing_pairs, &spair)) {
		return;
	}

	dport = (unsigned long)ht_get(preparing_pairs, &spair);
	ppair = (struct ip_port_pair*)ht_get_key(preparing_pairs, &spair);

	ht_remove(preparing_pairs, ppair);
	free(ppair);

	while(len > 0) {
		i = 0;
		while((line[i] != '\r' || line[i+1] != '\n') && len > 1) {
			i++;
			len--;
		}

		// According to RFC of RTSP, I know SETUP command contains
		// ports used by RTP. Here is the response:
		// RTSP/1.0 200 OK
		// CSeq: 3
		// Transport: RTP/AVP;some params;client_port=32423;server_port=34543;other params
		// Session: 12345678
		if(i >= 10 && 0 == strncmp(line, "Transport:", 10)) {
			int index = indexof(line, i, "server_port=", 12);
			if(index > 0) {
				unsigned long sport = atoi(line+index+12);
				struct ip_port_pair *pair = (struct ip_port_pair*)malloc(sizeof(struct ip_port_pair));
				struct rtp_connect_data *data = (struct rtp_connect_data*)malloc(sizeof(struct rtp_connect_data));
				pair->srcip = iph->saddr;
				pair->dstip = iph->daddr;
				pair->srcport = sport;
				pair->dstport = dport;
				pair->timestamp = timestamp();

				if(verbose) {
					printf("RTSP SETUP REPLY [");
					dump_ip_port_pair(&spair, (print_func)fprintf, stdout);
					printf("] client_port=%lu, server_port=%lu\n", dport, sport);
					printf("RTP connection[");
					dump_ip_port_pair(pair, (print_func)fprintf, stdout);
					printf("]\n");
				}

				data->inited = false;
				data->conn = pair;
				if(ht_put(sending_pairs, pair, data)) {
					free(pair);
					free(data);
				}
			}
		}

		line += i+2;
		len -= 2;
	}
}
Exemple #7
0
int main(void)
{
	printf("%d %d\n", indexof('o'), indexof('z'));
	return 0;
}
Exemple #8
0
static void paste(GeanyDocument * doc, const gchar * website)
{
    SoupSession *session;
    SoupMessage *msg = NULL;

    gchar *f_content;
    gchar const *f_type;
    gchar *f_title;
    gchar *p_url;
    gchar *formdata = NULL;
    gchar *user_agent = NULL;
    gchar **tokens_array;

    const gchar *langs_supported_codepad[] =
    {
        "C", "C++", "D", "Haskell",
        "Lua", "OCaml", "PHP", "Perl", "Plain Text",
        "Python", "Ruby", "Scheme", "Tcl"
    };

    const gchar *langs_supported_dpaste[] =
    {
        "Bash", "C", "CSS", "Diff",
        "Django/Jinja", "HTML", "IRC logs", "JavaScript", "PHP",
        "Python console session", "Python Traceback", "Python",
        "Python3", "Restructured Text", "SQL", "Text only"
    };

    gint occ_position;
    gint i;
    guint status;
    gsize f_length;

    g_return_if_fail(doc && doc->is_valid);

    f_type = doc->file_type->name;

    if (doc->file_name == NULL)
        f_title = document_get_basename_for_display(doc, -1);
    else
        f_title = g_path_get_basename(doc->file_name);

    load_settings();
    
    f_content = get_paste_text(doc, &f_length);
    if (f_content == NULL || f_content[0] == '\0')
    {
        dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Refusing to create blank paste"));
        return;
    }

    switch (website_selected)
    {

    case CODEPAD_ORG:

        for (i = 0; i < G_N_ELEMENTS(langs_supported_codepad); i++)
        {
            if (g_strcmp0(f_type, langs_supported_codepad[i]) == 0)
                break;
            else
                f_type = DEFAULT_TYPE_CODEPAD;
        }

        msg = soup_message_new("POST", website);
        formdata = soup_form_encode("lang", f_type,
                                    "code", f_content,
                                    "submit", "Submit",
                                    NULL);

        break;

    case TINYPASTE_COM:

        msg = soup_message_new("POST", website);
        formdata = soup_form_encode("paste", f_content, 
                                    "title", f_title,
                                    "is_code", g_strcmp0(f_type, "None") == 0 ? "0" : "1",
                                    NULL);

        break;


    case DPASTE_DE:

        for (i = 0; i < G_N_ELEMENTS(langs_supported_dpaste); i++)
        {
            if (g_strcmp0(f_type, langs_supported_dpaste[i]) == 0)
                break;
            else
                f_type = DEFAULT_TYPE_DPASTE;
        }

        msg = soup_message_new("POST", website);
        /* apparently dpaste.de detects automatically the syntax of the
         * pasted code so 'lexer' should be unneeded
         */
        formdata = soup_form_encode("content", f_content,
                                    "title", f_title,
                                    "lexer", f_type,
                                    NULL);

        break;

    case SPRUNGE_US:

        msg = soup_message_new("POST", website);
        formdata = soup_form_encode("sprunge", f_content, NULL);

        break;

    case PASTEBIN_GEANY_ORG:

        msg = soup_message_new("POST", website);
        formdata = soup_form_encode("content", f_content,
                                    "author", author_name,
                                    "title", f_title,
                                    "lexer", f_type,
                                    NULL);

        break;

    }

    g_free(f_content);

    user_agent = g_strconcat(PLUGIN_NAME, " ", PLUGIN_VERSION, " / Geany ", GEANY_VERSION, NULL);
    session = soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT, user_agent, NULL);
    g_free(user_agent);

    soup_message_set_request(msg, "application/x-www-form-urlencoded",
                             SOUP_MEMORY_TAKE, formdata, strlen(formdata));

    status = soup_session_send_message(session, msg);
    p_url = g_strdup(msg->response_body->data);

    g_object_unref(session);
    g_object_unref(msg);

    if(status == SOUP_STATUS_OK)
    {

        /*
         * codepad.org doesn't return only the url of the new snippet pasted
         * but an html page. This minimal parser will get the bare url.
         */

        if (website_selected == CODEPAD_ORG)
        {
            tokens_array = g_strsplit(p_url, "<a href=\"", 0);

            /* cuts the string when it finds the first occurrence of '/'
             * It shoud work even if codepad would change its url.
             */

            SETPTR(p_url, g_strdup(tokens_array[5]));
            occ_position = indexof(tokens_array[5], '\"');

            g_strfreev(tokens_array);

            if(occ_position != -1)
            {
                p_url[occ_position] = '\0';
            }
            else
            {
                dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Unable to paste the code on codepad.org\n"
                                    "Retry or select another pastebin."));
                g_free(p_url);
                return;
            }

        }
        else if(website_selected == TINYPASTE_COM)
        {
            /* tinypaste.com returns a XML response which looks
             * like this:
             * 
             * <?xml version="1.0" encoding="utf-8"?>
             * <result>
             *      <response>xxxxx</response>
             * </result>
             */
            tokens_array = g_strsplit_set(p_url, "<>", 0);
            
            SETPTR(p_url, g_strdup_printf("http://%s/%s", websites[TINYPASTE_COM], tokens_array[6]));
            
            g_strfreev(tokens_array);
        }
            
        else if(website_selected == DPASTE_DE)
        {
            SETPTR(p_url, g_strndup(p_url + 1, strlen(p_url) - 2));

        }
        else if(website_selected == SPRUNGE_US)
        {

            /* in order to enable the syntax highlightning on sprunge.us
             * it is necessary to append at the returned url a question
             * mark '?' followed by the file type.
             *
             * e.g. sprunge.us/xxxx?c
             */
            gchar *ft_tmp = g_ascii_strdown(f_type, -1);
            g_strstrip(p_url);
            SETPTR(p_url, g_strdup_printf("%s?%s", p_url, ft_tmp));
            g_free(ft_tmp);
        }

        if (check_button_is_checked)
        {
            utils_open_browser(p_url);
        }
        else
        {
            GtkWidget *dlg = gtk_message_dialog_new(GTK_WINDOW(geany->main_widgets->window),
                GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
                _("Paste Successful"));
            gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dlg),
                _("Your paste can be found here:\n<a href=\"%s\" "
                "title=\"Click to open the paste in your browser\">%s</a>"), p_url, p_url);
            gtk_dialog_run(GTK_DIALOG(dlg));
            gtk_widget_destroy(dlg);
        }
    }
    else
    {
        dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Unable to paste the code. Check your connection and retry.\n"
                            "Error code: %d\n"), status);
    }

    g_free(p_url);
}
Exemple #9
0
int main() {
    fin = fopen(_P ".in", "r"); assert(fin);
    fout = fopen(_P ".out", "w"); assert(fout);
    
    // read input
    ret = fscanf(fin, "%d %d", &rmax, &cmax);
    assert(ret == 2);
    
    readpos(fin, &king);

    nknight = 0;
    while (readpos(fin, &knights[nknight])) {
        nknight++;
    }

    /*
    printpos(&king);
    for (int i = 0; i < nknight; i++) {
        printpos(&knights[i]);
    }
    */
    fclose(fin);

    // compute the min map
    computeAll();
    
    int mintotal = -1;
    int rking = king.r;
    int cking = king.c;

    for (int rgath = 0; rgath < rmax; rgath++) {
        for (int cgath = 0; cgath < cmax; cgath++) {
            int minkdelta = imax(iabs(rking - rgath), 
                    iabs(cking - cgath));
            int indgath = indexof(rgath, cgath);
            int total = 0;
            bool unreachable = false;
            
            for (int k = 0; k < nknight; k++) {
                int indknight = indexof(&knights[k]);
                int ms = minsteps(indgath, indknight);
                if (ms < 0) {
                    unreachable = true;
                    break;
                }
                knights[k].d = minsteps(indgath, indknight);
                total += knights[k].d;
            }

            if (unreachable) continue; // knight unreachable
            
            memset(touched, 0, sizeof(bool) * MAXIND);
            int head = 0;
            int tail = 1;
            trace[0].r = rking; trace[0].c = cking;
            trace[0].d = 0;
            
            while (head < tail) {
                int dthis = trace[head].d;
                if (dthis >= minkdelta) break;
                int rthis = trace[head].r;
                int cthis = trace[head].c;
                
                int indpick = indexof(rthis, cthis);
                int deltabase = minsteps(indgath, indpick);
                if (deltabase >= 0) { // reachable
                    int mindel = 1000;
                    for (int k = 0; k < nknight; k++) {
                        int indknight = indexof(&knights[k]);
                        int ms = minsteps(indpick, indknight);
                        if (ms < 0) continue;
                        int delta = deltabase + ms;
                        assert(delta >= knights[k].d);
                        delta -= knights[k].d;
                        if (delta < mindel) {
                            mindel = delta;
                        }
                        if (mindel == 0) break; // drive by already
                    }

                    if (nknight > 0) { // have knights
                        int dmin = dthis + mindel;
                        if (dmin < minkdelta) {
                            minkdelta = dmin;
                        }
                    }
                }

                for (int i = 0; i < 8; i++) {
                    int rthat = rthis + ksteps[i].r;
                    int cthat = cthis + ksteps[i].c;
                    if (rthat < 0 || rthat >= rmax) continue;
                    if (cthat < 0 || cthat >= cmax) continue;

                    int ind = indexof(rthat, cthat);
                    if (touched[ind]) continue;
                    int dthat = dthis + 1;
                    touched[ind] = true;
                    trace[tail].r = rthat;
                    trace[tail].c = cthat;
                    trace[tail].d = dthat;
                    tail++;
                }
                head++;
            }

            total += minkdelta;

            if (mintotal < 0 || total < mintotal) {
                mintotal = total;
            }
        }
    }

    assert(mintotal >= 0);
    fprintf(fout, "%d\n", mintotal);

    return 0;
}
Exemple #10
0
players_t LIBCOD_CALL *server_getstatus( server_t *server ) {
    string tmp = server_private_rcon_sz( server, "status", 8192 );
    
    if ( strcmp( tmp, "" ) == 0 ||
         strstr( tmp, "disconnect" ) != NULL ||
         strstr( tmp, "Bad rconpassword" ) != NULL ||
         strstr( tmp, "No rconpassword set on the server" ) != NULL ) {
        xfree( tmp );
        return NULL;
    }
    
    int guid = 0;
    if ( server->version >= COD_1_3 )
        guid = 1;
        
    int n = 1, k = 0;
    for ( ; tmp[ k ]; k++ ) {
        if ( tmp[ k ] == '\n' )
            n++;
    }

    string *data = xmalloc( ( 128 * n ) );
    string p = strtok( tmp, "\n" );
    for ( k = 0; k < n; k++ ) {
        data[ k ] = p;
        p = strtok( NULL, "\n" );
    }

    players_t *ply = xmalloc( sizeof( players_t ) );
    ply->players = xmalloc( ( sizeof( player_t ) * ( ( n - 2 ) ? n - 2 : 1 ) ) );
    int i = 0, playercount = 0;
    string d;

    for ( i = 3; i < n; i++ ) {
        d = data[ i ];
        trim( d );
        trimwhitespace( d  );
        
        // count the total number of spaces
        int c = 1, j = 0;
        for ( ; d[ j ]; j++ ) {
            if ( d[ j ] == ' ' )
                c++;
        }
        
        if ( c < 7 + guid )
            continue;
            
        //ply->players = xrealloc( ply->players, ( sizeof( player_t ) * ( playercount + 1 ) ) );
        
        // malloc an array for use later
        string *arr = xmalloc( ( 32 * c ) );
        string pch2 = strtok( d, " " );
        for ( j = 0; j < c; j++ ) {
            arr[ j ] = pch2;
            pch2 = strtok( NULL, " " );
        }
        j = 0;
        
        // client number / score
        ply->players[ playercount ].clientnumber = (byte) atoi( arr[ j++ ] );
        ply->players[ playercount ].score = atoi( arr[ j++ ] );
        
        // ping
        string ping = arr[ j++ ];
        if ( strcmp( ping, "CNCT" ) == 0 || strcmp( ping, "ZMBI" ) == 0 )
            ply->players[ playercount ].ping = 999;
        else
            ply->players[ playercount ].ping = (unsigned short) atoi( ping );
            
        if ( guid )
            strcpy( ply->players[ playercount ].guid, arr[ j++ ] );
        
        // name :>
        if ( c < 8 + guid ) 
            strcpy( ply->players[ playercount ].name, "" );
        else if ( c == 8 + guid )
            strcpy( ply->players[ playercount ].name, arr[ j++ ] );
        else {
            string tmpname = xmalloc( 34 );
            strcpy( tmpname, " " );
            for ( ; j < c - 4; j++ ) {
                strcat( tmpname, arr[ j ] );
                strcat( tmpname, " " );
            }
            trim( tmpname );
            
            strcpy( ply->players[ playercount ].name, tmpname );
            xfree( tmpname );
        }
        
        // last msg
        ply->players[ playercount ].lastmsg = atoi( arr[ j++ ] );
        
        // address / port
        string a = arr[ j++ ];
        if ( indexof( a, ':', 0 ) > -1 ) {
            string address = substring( a, 0, indexof( a, ':', 0 ) );
            string sport = substring( a, indexof( a, ':', 0 ), strlen( a ) );
            int port = atoi( sport );
            
            strcpy( ply->players[ playercount ].ipaddress, address );
            ply->players[ playercount ].port = port;
            
            xfree( address );
            xfree( sport );
        }
        else {
            strcpy( ply->players[ playercount ].ipaddress, a );
            ply->players[ playercount ].port = -1;
        }
        
        // qport / rate
        ply->players[ playercount ].qport = atoi( arr[ j++ ] );
        ply->players[ playercount ].rate = atoi( arr[ j++ ] );

        xfree( arr );
        playercount++;
    }
   
    xfree( data );
    xfree( tmp );
    
    ply->playercount = playercount;
    return ply;
}
Exemple #11
0
void LIBCOD_CALL server_detectversion( server_t *server ) {
    string buff = xmalloc( 1024 );

    int err = server_raw_socket( server, "\xff\xff\xff\xffgetinfo xxx", buff, 1024 );
    
    if ( err > 0 || indexof( buff, '\\', 0 ) < 0 ) {
        xfree( buff );
        spawn_error( "Error while running server_detectversion", false );
        return;
    }
        
    string infostring = substring( buff, indexof( buff, '\\', 0 ), strlen( buff ) );
    xfree( buff );
    
    string val = Info_ValueForKey( infostring, "protocol" );
    int gameversion = UNKNOWN;
    
    if ( strcmp( val, "" ) == 0 )
        return;
        
    int protocol = atoi( val );
    
    switch ( protocol ) {
        // Call of Duty
        case 1:     gameversion = COD_1_1;              break;
        case 2:     gameversion = COD_1_2;              break;
        case 4:     gameversion = COD_1_3;              break;
        case 5:     gameversion = COD_1_4;              break;
        case 6:     gameversion = COD_1_5;              break;

        // Call of Duty: United Offensive
        case 21:    gameversion = CODUO_1_41;           break;
        case 22:    gameversion = CODUO_1_51;           break;

        // Call of Duty 2
        case 115:   gameversion = COD2_1_0;             break;
        case 116:   gameversion = COD2_1_01;            break;
        case 117:   gameversion = COD2_1_2;             break;
        case 118:   gameversion = COD2_1_3;             break;

        // Call of Duty: World at War
        case 93:    gameversion = CODWAW_1_0;           break;
        case 94:    gameversion = CODWAW_1_0_1017;      break;
        case 95:    gameversion = CODWAW_1_1;           break;
        case 96:    gameversion = CODWAW_1_2;           break;
        case 97:    gameversion = CODWAW_1_3;           break;
        case 98:    gameversion = CODWAW_1_4;           break;
        case 99:    gameversion = CODWAW_1_5;           break;
        case 100:   gameversion = CODWAW_1_6;           break;
        case 101:   gameversion = CODWAW_1_7;           break;

        default:    break;
    }
    
    if ( gameversion == UNKNOWN ) {
        string voice = Info_ValueForKey( infostring, "voice" );
        if ( strcmp( voice, "" ) != 0 ) {    
            switch ( protocol ) {
                // Call of Duty 4
                case 0:     gameversion = COD4_1_1;             break;
                case 1:     gameversion = COD4_1_2;             break;
                case 2:     gameversion = COD4_1_3;             break;
                case 3:     gameversion = COD4_1_4;             break;
                case 4:     gameversion = COD4_1_5;             break;
                case 5:     gameversion = COD4_1_6;             break;
                case 6:     gameversion = COD4_1_7;             break;
                default:                                        break;
            }
        }
    }
    
    xfree( infostring );
    
    server->version = gameversion;
    server->versionstring = versionstring( gameversion );
}
int domain_runnable(int domid)
{
    return new_qos->domain_info[indexof(domid)].runnable;
}
Exemple #13
0
static long get_units(DBADDR *paddr, char *units)
{
    if(dbGetFieldIndex(paddr) == indexof(HIGH))
        strcpy(units, "s");
    return(0);
}
Exemple #14
0
int smith_waterman(char *q, const int q_len, char *db, const int db_len,
        char g_init, char g_ext) {

    char H[q_len+1][db_len+1];
    char E[q_len+1][db_len+1];
    char F[q_len+1][db_len+1];
    char prev[q_len+1][db_len+1][2];
    char q_out[q_len+db_len];
    char db_out[q_len+db_len];

    char max1,max2,idxi,idxj,deW;

    int i, j, k, l, m, n;
    int maxi,maxj;
    int maxval = 0;

    for (i = 0; i <= q_len; i++) {
        H[i][0] = 0;
        E[i][0] = 0;
        F[i][0] = 0;
        prev[i][0][1] = 0;
        if (i==0)prev[i][0][0] = 0;
        else prev[i][0][0] = -1;
    }

    for (j = 0; j <= db_len; j++) {
        H[0][j] = 0;
        E[0][j] = 0;
        F[0][j] = 0;
        prev[0][j][0] = 0;
        if (i==0)prev[0][j][1] = 0;
        else prev[0][j][1] = -1;
    }

    for (i = 1; i <= q_len; i++) {
        for (j = 1; j <= db_len; j++) {
            E[i][j] = MAX((E[i][j-1]-g_ext),(H[i][j-1]-g_init));
            F[i][j] = MAX((F[i-1][j]-g_ext),(H[i-1][j]-g_init));
	    idxi = indexof(*(q+i-1));
	    idxj = indexof(*(db+j-1));
	    if ((idxi == -1) || (idxj == -1)){
		deW = (strncmp(q+i-1, db+j-1, 1) == 0) ? MATCH : MISMATCH;
	    } else {
		deW = W[idxi][idxj];
	    }
	    
            max1 = MAX(0,E[i][j]);
            max2 = MAX(F[i][j],H[i-1][j-1]+deW);
            H[i][j] = MAX(max1,max2);
            if (H[i][j]>maxval) {
                maxval = H[i][j];
                maxi = i; maxj = j;
            } 
            if (H[i][j] == H[i-1][j-1]+deW) {prev[i][j][0] = -1; prev[i][j][1] = -1;}
            else if (H[i][j] == E[i][j])  {prev[i][j][0] = 0; prev[i][j][1] = -1; }
            else if (H[i][j] == F[i][j])  {prev[i][j][0] = -1; prev[i][j][1] = 0; }
            else {prev[i][j][0] = 0; prev[i][j][1] = 0;  }
        }
    }

	
    printf("Alignment Matrix\n");
    for (i = 1; i <= q_len; i++) {
        for (j = 1; j <= db_len; j++) {
            printf("%d\t",H[i][j]);
        }
        printf("\n");
    }
    printf("Max Score:%d\n",H[maxi][maxj]);

    i = maxi;
    j = maxj;
    k = 0;
    while(!( ((i==0) && (j==0)) || (H[i][j] == 0))) {
        if((prev[i][j][0] == -1) && (prev[i][j][1] == -1)){
            q_out[k] = *(q+i-1);
            db_out[k] = *(db+j-1);
        } else if ((prev[i][j][0] == 0) && (prev[i][j][1] == -1)){
            q_out[k] = 45;
            db_out[k] = *(db+j-1);
        } else if ((prev[i][j][0] == -1) && (prev[i][j][1] == 0)){
            q_out[k] = *(q+i-1);
            db_out[k] = 45;
        } else {
            q_out[k] = 45;
            db_out[k] = 45;
        }

        m = i + prev[i][j][0];
        n = j + prev[i][j][1];
        i = m;
        j = n;
        k++;
    }


    for (i=0; i<n-m; i++) printf(" ");
    for (i=0; i<m; i++) printf("%c",q[i]);
    for (i=k-1; i>=0; i--) printf("%c",q_out[i]);
    for (i=maxi; i<=q_len; i++) printf("%c",q[i]);
    printf("\n");
    for (i=0; i<n-m; i++) printf(" ");
    for (i=0; i<m; i++) printf(" ");
    for (i=k-1; i>=0; i--) {if (q_out[i] == db_out[i]) printf(":"); else printf(".");}
    printf("\n");
    for (i=0; i<m-n; i++) printf(" ");
    for (i=0; i<n; i++) printf("%c",db[i]);
    for (i=k-1; i>=0; i--) printf("%c",db_out[i]);
    for (i=maxj; i<=db_len; i++) printf("%c",db[i]);
    printf("\n");
    return 0;
}
/******************************************************************************
 * FunctionName : user_platform_timer_first_start
 * Description  : calculate the wait time of each timer
 * Parameters   : count -- The number of timers given by server
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_platform_timer_first_start(uint16 count)
{
    int i = 0;
    struct esp_platform_wait_timer_param timer_wait_param[100] = {0};

    ESP_DBG("current timestamp= %ds\n", timestamp);

    timestamp = timestamp + min_wait_second;

    for (i = 0 ; i < count ; i++) {
        char *str = timer_splits[i];

        if (indexof(str, "f", 0) == 0) {
            char *fixed_wait[2];

            ESP_DBG("timer is fixed mode\n");

            split(str, "=", fixed_wait);
            os_memcpy(timer_wait_param[i].wait_time_param, fixed_wait[0] + 1, os_strlen(fixed_wait[0]) - 1);
            os_memcpy(timer_wait_param[i].wait_action, fixed_wait[1], os_strlen(fixed_wait[1]));
            timer_wait_param[i].wait_time_second = atoi(timer_wait_param[i].wait_time_param) - timestamp;
            os_free(fixed_wait[0]);
            os_free(fixed_wait[1]);
        }

        else if (indexof(str, "l", 0) == 0) {
            char *loop_wait[2];

            ESP_DBG("timer is loop mode\n");

            split(str, "=", loop_wait);
            os_memcpy(timer_wait_param[i].wait_time_param, loop_wait[0] + 1, os_strlen(loop_wait[0]) - 1);
            os_memcpy(timer_wait_param[i].wait_action, loop_wait[1], os_strlen(loop_wait[1]));
            timer_wait_param[i].wait_time_second = atoi(timer_wait_param[i].wait_time_param) - (timestamp % atoi(timer_wait_param[i].wait_time_param));
            os_free(loop_wait[0]);
            os_free(loop_wait[1]);
        } else if (indexof(str, "w", 0) == 0) {
            char *week_wait[2];
            int monday_wait_time = 0;

            ESP_DBG("timer is weekend mode\n");

            split(str, "=", week_wait);
            os_memcpy(timer_wait_param[i].wait_time_param, week_wait[0] + 1, os_strlen(week_wait[0]) - 1);
            os_memcpy(timer_wait_param[i].wait_action, week_wait[1], os_strlen(week_wait[1]));
            monday_wait_time = (timestamp - 1388937600) % (7 * 24 * 3600);

            ESP_DBG("monday_wait_time == %d", monday_wait_time);

            if (atoi(timer_wait_param[i].wait_time_param) > monday_wait_time) {
                timer_wait_param[i].wait_time_second = atoi(timer_wait_param[i].wait_time_param) - monday_wait_time;
            } else {
                timer_wait_param[i].wait_time_second = 7 * 24 * 3600 - monday_wait_time + atoi(timer_wait_param[i].wait_time_param);
            }

            os_free(week_wait[0]);
            os_free(week_wait[1]);
        }
    }

    esp_platform_find_min_time(timer_wait_param, count);
    if(min_wait_second == 0) {
        return;
    }

    esp_platform_timer_action(timer_wait_param, count);
}
Exemple #16
0
inline int indexof(Coord * p) {
    return indexof(p->r, p->c);
}
Exemple #17
0
	bool readvalue(const bsreq* hint_type, bool create) {
		bool need_identifier = false;
		buffer[0] = 0;
		value = 0;
		value_type = 0;
		value_object = 0;
		if(p[0] == '-' || (p[0] >= '0' && p[0] <= '9')) {
			value = sz2num(p, &p);
			value_type = number_type;
		} else if(p[0] == '\'') {
			p++;
			readstring('\'');
			value_type = text_type;
			need_identifier = true;
		} else if(p[0] == '\"') {
			p++;
			readstring('\"');
			value_type = text_type;
		} else if(readidentifier()) {
			value_type = text_type;
			need_identifier = true;
		} else
			return false; // Not found value tag
		if(need_identifier) {
			auto value_data = bsdata::find(hint_type);
			if(!value_data) {
				for(value_data = bsdata::first; value_data; value_data = value_data->next) {
					auto f = value_data->fields->getkey();
					if(!f)
						continue;
					value_object = value_data->find(f, buffer);
					if(value_object)
						break;
				}
			} else
				value_object = value_data->find(value_data->fields->getkey(), buffer);
			// If not find create this
			if(!value_object && value_data && create) {
				auto f = value_data->fields->getkey();
				if(f) {
					value_object = value_data->add();
					f->set(f->ptr(value_object), (int)szdup(buffer));
				}
			}
			if(value_data)
				value_type = value_data->fields;
			else
				value_type = number_type;
			if(value_object && value_data)
				value = value_data->indexof(value_object);
			if(!value_object)
				warning(ErrorNotFoundIdentifier1p, buffer);
		} else if(create && hint_type && value_type == number_type) {
			auto value_data = bsdata::find(hint_type);
			value_type = hint_type;
			if(value_data) {
				if(value < (int)value_data->getmaxcount()) {
					if(value >= (int)value_data->getcount())
						value_data->setcount(value + 1);
					value_object = value_data->get(value);
				}
			}
		}
		skipws();
		return true;
	}
Exemple #18
0
static long get_graphic_double(DBADDR *paddr,struct dbr_grDouble *pgd)
{
    aoRecord	*prec=(aoRecord *)paddr->precord;

    switch (dbGetFieldIndex(paddr)) {
        case indexof(VAL):
        case indexof(OVAL):
        case indexof(PVAL):
        case indexof(HIHI):
        case indexof(HIGH):
        case indexof(LOW):
        case indexof(LOLO):
        case indexof(LALM):
        case indexof(ALST):
        case indexof(MLST):
        case indexof(IVOV):
            pgd->upper_disp_limit = prec->hopr;
            pgd->lower_disp_limit = prec->lopr;
            break;
        default:
            recGblGetGraphicDouble(paddr,pgd);
    }
    return(0);
}