コード例 #1
0
ファイル: convert.c プロジェクト: SibusisoMthembu/davitpy
int ConvertReadInt(int fp,int32 *val) {
  unsigned char tmp[4];
  int s=0,o=0,l=4;
  while (o<4) {
    s=read(fp,tmp+o,l);
    o=o+s;
    l=l-s;
    if (s==0) return -1;
    if (s==-1) return -1;
  }
  ConvertToInt(tmp,val);
  return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Ngob/Zappy
int		main(int ac, char **av)
{
  int		c;
  std::string  	tn("");
  std::string	ip = "127.0.0.1";
  std::string	port("");
  while ((c = getopt(ac, av, "n:p:h:")) != -1 && c != EOF)
    {
      switch (c)
	{
	case 'n':
	  tn = optarg;
	  break;
	case 'p':
	  port = optarg;
	  break;
	case 'h':
	  ip = optarg;
	  break;
	}
    }
  if (tn == "" || port == "")
    {
      std::cout << "Usage : -n TeamName -p Port -h Hostname" << std::endl;
      return (0);
    }
  std::cout << tn;
  std::cout << std::endl << port << std::endl << ip << std::endl;
  try
    {
      Client		* cl = new Client(ip, ConvertToInt(port), tn);
      try
	{
	  Drone			dr(cl);
	  dr.launch();
	}
      catch (std::exception exept_read)
	{
	  std::cout << "Game End" << std::endl;
	  delete cl;
	}
    }
  catch (std::exception exept_connect)
    {
      std::cerr << "Erreur de connection" << std::endl;
      return (0);
    }
  return (0);
}
コード例 #3
0
ファイル: fit_read_inx.c プロジェクト: Shirling-VT/VTRST3.5
int fit_read_inx(struct fitfp *ptr,int32 *buffer,int recno) {
  int i,status=0;
  if (ptr->inxfp !=-1) {
     if (recno !=-1)  /* jump to this record */
       lseek(ptr->inxfp,(recno+1)*ptr->inx_recl,SEEK_SET);
     for (i=0;(i<4) && (status==0);i++) 
     status=ConvertReadInt(ptr->inxfp,&buffer[i]);
     return status;
  } else if (ptr->ibuf !=NULL) {
     if (recno !=-1)  ptr->iptr=(recno+1)*ptr->inx_recl;
     if ((ptr->istat.st_size-ptr->iptr)<(4*sizeof(int32))) return -1; 
     for (i=0;i<4;i++) 
        ConvertToInt(ptr->ibuf+ptr->iptr+sizeof(int32)*i,&buffer[i]);
     ptr->iptr+=sizeof(int32)*4;
     return 0;
  }
  return -1;
}
コード例 #4
0
ファイル: Probe_SILO.cpp プロジェクト: jdhare/hym_silo
//============================================================================//
//============================================================================//
void ReadArgs(int argc, char **argv, char *&silo_path, char *&probe_path,
              int &cycle, float &phi_rot) {
    // Count the initial command line arguments:
    if(!(argc == (1+4))) {
        char message[1001];
        sprintf(message,"  %s\n  %s",
                "An improper number of command line arguments was found.",
                stopmsg);
        StopExecution(message);
    }
        
    // Distribute the command line arguments
    silo_path = argv[1];
    probe_path = argv[2];
    VerifyPath(silo_path,stopmsg);
    VerifyPath(probe_path,stopmsg);
    ConvertToInt(argv[3],cycle,stopmsg);
    ConvertToFloat(argv[4],phi_rot,stopmsg);
}
コード例 #5
0
ファイル: timedctf.cpp プロジェクト: DWang5090/462Shootout
void TCTFHandler::Init( const char* commandLine )
{
  std::string parameter = commandLine;
  double timelimitparameter = ConvertToInt(parameter);

  if (timelimitparameter > 0)
	  tctf.timeLimit = timelimitparameter * 60;

  Register(bz_eCaptureEvent);
  Register(bz_ePlayerJoinEvent);
  Register(bz_ePlayerUpdateEvent);
  Register(bz_eTickEvent);
  bz_registerCustomSlashCommand("tctfstatus",&tctfcommands);
  bz_registerCustomSlashCommand("tctftime",&tctfcommands);
  bz_registerCustomSlashCommand("tctfon",&tctfcommands);
  bz_registerCustomSlashCommand("tctfoff",&tctfcommands);
  bz_registerCustomSlashCommand("fairctfon",&tctfcommands);
  bz_registerCustomSlashCommand("fairctfoff",&tctfcommands);
  bz_registerCustomSlashCommand("tctfsoundon",&tctfcommands);
  bz_registerCustomSlashCommand("tctfsoundoff",&tctfcommands);
}
コード例 #6
0
ファイル: timedctf.cpp プロジェクト: szakats/bzflag_mirror
BZF_PLUGIN_CALL int bz_Load(const char *commandLine)
{
  std::string parameter = commandLine;
  double timelimitparameter = ConvertToInt(parameter);

  if (timelimitparameter > 0)
    tctf.timeLimit = timelimitparameter * 60;

  bz_debugMessage(4, "timedctf plugin loaded");
  bz_registerEvent(bz_eCaptureEvent, &tctfflagcapped);
  bz_registerEvent(bz_ePlayerJoinEvent, &tctfplayerjoined);
  bz_registerEvent(bz_ePlayerUpdateEvent, &tctfplayerupdates);
  bz_registerEvent(bz_eTickEvent, &tctftickevents);
  bz_registerCustomSlashCommand("tctfstatus", &tctfcommands);
  bz_registerCustomSlashCommand("tctftime", &tctfcommands);
  bz_registerCustomSlashCommand("tctfon", &tctfcommands);
  bz_registerCustomSlashCommand("tctfoff", &tctfcommands);
  bz_registerCustomSlashCommand("fairctfon", &tctfcommands);
  bz_registerCustomSlashCommand("fairctfoff", &tctfcommands);
  bz_registerCustomSlashCommand("tctfsoundon", &tctfcommands);
  bz_registerCustomSlashCommand("tctfsoundoff", &tctfcommands);
  return 0;
}
コード例 #7
0
BOOL ImageRecordingPage::GetJPEG2KQuality( unsigned int* quality )
{
	CString qualityTxt;
	m_edit_jpg2kCompressionLevel.GetWindowText(qualityTxt);
	return (!(qualityTxt.IsEmpty()) && ConvertToInt(&qualityTxt, quality));
}
コード例 #8
0
ファイル: dmap.c プロジェクト: SDFrance/RSTLite
struct DataMap *DataMapDecodeBuffer(char *buf,int size) {
  int c,x,n,i,e;
  int32 sn,an;
  int32 code,sze;
  char *name;
  char *tmp;
  char type;
  unsigned int off=0;  
  int32 tsze;

  struct DataMap *ptr;
  struct DataMapScalar *s;
  struct DataMapArray *a;
  
  ptr=DataMapMake();
  if (ptr==NULL) return NULL;
  ConvertToInt(buf+off,&code);
  off+=sizeof(int32);
  ConvertToInt(buf+off,&sze);
  off+=sizeof(int32);
  ConvertToInt(buf+off,&sn);
  off+=sizeof(int32);
  ConvertToInt(buf+off,&an);
  off+=sizeof(int32);
  if (sn>0) {
    ptr->snum=sn;
    ptr->scl=malloc(sizeof(struct DataMapScalar *)*sn); 
    if (ptr->scl==NULL) {
      DataMapFree(ptr);
      return NULL;
    }
    for (c=0;c<sn;c++) ptr->scl[c]=NULL;
  }

  if (an>0) {
    ptr->anum=an;
    ptr->arr=malloc(sizeof(struct DataMapArray *)*an);
    if (ptr->arr==NULL) {
      DataMapFree(ptr);
      return NULL;
    }
    for (c=0;c<an;c++) ptr->arr[c]=NULL;
  }

  for (c=0;c<sn;c++) {
    e=0;
    n=0; 
    while ((buf[off+n] !=0) && (off+n<size)) n++;
    if (off+n>=size) break;
    name=malloc(n+1);
    if (name==NULL) break;
    memcpy(name,buf+off,n+1);
    off+=n+1;
    type=buf[off];
    off++;
    s=malloc(sizeof(struct DataMapScalar));
    if (s==NULL) {
      free(name);
      break;
    }

    s->name=name;
    s->mode=6;
    s->type=type;
    ptr->scl[c]=s;   

    switch (s->type) {
    case DATACHAR:
      s->data.vptr=malloc(sizeof(char));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      s->data.cptr[0]=buf[off];
      off++;
      break;
    case DATASHORT:
      s->data.vptr=malloc(sizeof(int16));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      ConvertToShort(buf+off,s->data.sptr);
      off+=sizeof(int16);
      break;
    case DATAINT:
      s->data.vptr=malloc(sizeof(int32));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      ConvertToInt(buf+off,s->data.iptr);
      off+=sizeof(int32); 
      break;
    case DATALONG:
      s->data.vptr=malloc(sizeof(int64));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      ConvertToLong(buf+off,s->data.lptr);
      off+=sizeof(int64);
      break;
    case DATAUCHAR:
      s->data.vptr=malloc(sizeof(unsigned char));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      s->data.ucptr[0]=buf[off];
      off++;
      break;
    case DATAUSHORT:
      s->data.vptr=malloc(sizeof(uint16));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      ConvertToUShort(buf+off,s->data.usptr);
      off+=sizeof(uint16);
      break;
    case DATAUINT:
      s->data.vptr=malloc(sizeof(uint32));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      ConvertToUInt(buf+off,s->data.uiptr);
      off+=sizeof(uint32);
      break;
    case DATAULONG:
      s->data.vptr=malloc(sizeof(uint64));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      ConvertToULong(buf+off,s->data.ulptr);
      off+=sizeof(uint64);
      break;
    case DATAFLOAT:
      s->data.vptr=malloc(sizeof(float));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      ConvertToFloat(buf+off,s->data.fptr);
      off+=sizeof(float);
      break;
    case DATADOUBLE:
      s->data.vptr=malloc(sizeof(double));
      if (s->data.vptr==NULL) {
  	e=1;
        break;
      }
      ConvertToDouble(buf+off,s->data.dptr);
      off+=sizeof(double);
      break;
    case DATASTRING:
      n=0;
      while ((buf[off+n] !=0) && (off+n<size)) n++;
      if (off+n>=size) {
        e=1;
        break;
      }
 
      s->data.vptr=malloc(sizeof(char *));
      if (s->data.vptr==NULL) {
        e=1;
        break;
      }
      if (n !=0) {
        tmp=malloc(n+1);
        if (tmp==NULL) {
          e=1;
          break;
	}
        memcpy(tmp,buf+off,n+1);
        off+=n+1;
        *( (char **) s->data.vptr)=tmp;
      } else {
        *( (char **) s->data.vptr)=NULL;
        off++;
      }
      break;
    default:

      s->data.vptr=malloc(sizeof(struct DataMap *));
      if (s->data.vptr==NULL) {
  	e=1;
        break;
      }
      ConvertToInt(buf+off,&tsze);
      off+=sizeof(int32); 
      if (tsze !=0) { 
        *s->data.mptr=DataMapDecodeBuffer(buf+off,tsze);
        off+=tsze;
      } else *s->data.mptr=NULL;
    }
    if (e==1) break;
  }

  if (c !=sn) {
    DataMapFree(ptr);
    return NULL;
  }
  for (c=0;c<an;c++) {
    e=0;
    n=0;
    while ((buf[off+n] !=0) && (off+n<size)) n++;
    if (off+n>=size) break;
    name=malloc(n+1);
    if (name==NULL) break;
    memcpy(name,buf+off,n+1);
    off+=n+1;
    type=buf[off];
    off++;
    a=malloc(sizeof(struct DataMapArray));
    if (a==NULL) {
      free(name);
      break;
    }
    a->name=name;
    a->mode=7;
    a->type=type;
    ptr->arr[c]=a;   
    ConvertToInt(buf+off,(int32 *) &(a->dim));
    off+=sizeof(int32);
    a->rng=malloc(a->dim*sizeof(int32));
    if (a->rng==NULL) break;
    for (x=0;x<a->dim;x++)  {
       ConvertToInt(buf+off,&a->rng[x]);
       off+=sizeof(int32);
    }
    if (x!=a->dim) break;
    n=1;
    for (x=0;x<a->dim;x++) n=a->rng[x]*n;
    switch (a->type) {
    case DATACHAR:
      a->data.vptr=malloc(sizeof(char)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      memcpy(a->data.cptr,buf+off,sizeof(char)*n);
      off+=sizeof(char)*n;
      break;
    case DATASHORT:
      a->data.vptr=malloc(sizeof(int16)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      for (x=0;x<n;x++) {
        ConvertToShort(buf+off,&a->data.sptr[x]);
        off+=sizeof(int16);
      }
      break;
    case DATAINT:
      a->data.vptr=malloc(sizeof(int32)*n);
      if (a->data.vptr==NULL) {
        break;
        e=1;
      }
      for (x=0;x<n;x++) {
        ConvertToInt(buf+off,&a->data.iptr[x]);
        off+=sizeof(int32);
      }
      break;
    case DATALONG:
      a->data.vptr=malloc(sizeof(int64)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      for (x=0;x<n;x++) {
        ConvertToLong(buf+off,&a->data.lptr[x]);
        off+=sizeof(int64);
      }
      break;

    case DATAUCHAR:
      a->data.vptr=malloc(sizeof(unsigned char)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      memcpy(a->data.cptr,buf+off,sizeof(unsigned char)*n);
      off+=sizeof(unsigned char)*n;
      break;
    case DATAUSHORT:
      a->data.vptr=malloc(sizeof(uint16)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      for (x=0;x<n;x++) {
        ConvertToUShort(buf+off,&a->data.usptr[x]);
        off+=sizeof(uint16);
      }
      break;
    case DATAUINT:
      a->data.vptr=malloc(sizeof(uint32)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      for (x=0;x<n;x++) {
        ConvertToUInt(buf+off,&a->data.uiptr[x]);
        off+=sizeof(uint32);
      }
      break;
    case DATAULONG:
      a->data.vptr=malloc(sizeof(uint64)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      for (x=0;x<n;x++) {
        ConvertToULong(buf+off,&a->data.ulptr[x]);
        off+=sizeof(uint64);
      }
      break;
    case DATAFLOAT:
      a->data.vptr=malloc(sizeof(float)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      for (x=0;x<n;x++) {
        ConvertToFloat(buf+off,&a->data.fptr[x]);
        off+=sizeof(float);
      }
      break;
    case DATADOUBLE:
      a->data.vptr=malloc(sizeof(double)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }
      for (x=0;x<n;x++) {
	ConvertToDouble(buf+off,&a->data.dptr[x]);
	off+=sizeof(double);
      }
      break;
    case DATASTRING:
      a->data.vptr=malloc(sizeof(char *)*n);
      if (a->data.vptr==NULL) {
        e=1;
        break;
      }  
      for (x=0;x<n;x++) {
         i=0;          
         while ((buf[off+i] !=0) && (off+i<size)) i++;
         if (off+i>=size) break;
         if (i !=0) {
           tmp=malloc(i+1);
           if (tmp==NULL) break;
           memcpy(tmp,buf+off,i+1); 
           ((char **) a->data.vptr)[x]=tmp;
	 } else ((char **) a->data.vptr)[x]=NULL;
         off+=i+1;
      }
      if (x !=n) e=1;
      break;
    default:
      a->data.mptr=malloc(sizeof(struct DataMap *)*n);
      if (a->data.vptr==NULL) {
	e=1;
        break;
      }
      for (x=0;x<n;x++) {
        ConvertToInt(buf+off,&tsze);
        off+=sizeof(int32);
        if (tsze !=0) {
          a->data.mptr[x]=DataMapDecodeBuffer(buf+off,tsze);
          off+=tsze;
	} else a->data.mptr[x]=0;      
      }
    }
    if (e==1) break;
  }

  if (c !=an) {
    DataMapFree(ptr);
    return NULL;
  }
 
  return ptr;
}
コード例 #9
0
ファイル: dmap.c プロジェクト: ajribeiro/VT_RST3
struct DataMap *DataMapDecodeBuffer(unsigned char *buf,int size) {
  int c,x,n,i;
  int32 sn,an;
  int32 code,sze;
  char *name;
  unsigned char *tmp;
  char type;
  unsigned int off=0;  

  struct DataMap *ptr;
  struct DataMapScalar *s;
  struct DataMapArray *a;
  
  ptr=DataMapMake();
  if (ptr==NULL) return NULL;
  ConvertToInt(buf+off,&code);
  off+=sizeof(int32);
  ConvertToInt(buf+off,&sze);
  off+=sizeof(int32);
  ConvertToInt(buf+off,&sn);
  off+=sizeof(int32);
  ConvertToInt(buf+off,&an);
  off+=sizeof(int32);
  if (sn>0) {
    ptr->snum=sn;
    ptr->scl=malloc(sizeof(struct DataMapScalar *)*sn); 
    if (ptr->scl==NULL) {
      DataMapFree(ptr);
      return NULL;
    }
    for (c=0;c<sn;c++) ptr->scl[c]=NULL;
  }

  if (an>0) {
    ptr->anum=an;
    ptr->arr=malloc(sizeof(struct DataMapArray *)*an);
    if (ptr->arr==NULL) {
      DataMapFree(ptr);
      return NULL;
    }
    for (c=0;c<an;c++) ptr->arr[c]=NULL;
  }

  for (c=0;c<sn;c++) {
    n=0;
    while ((buf[off+n] !=0) && (off+n<size)) n++;
    if (off+n>=size) break;
    name=malloc(n+1);
    if (name==NULL) break;
    memcpy(name,buf+off,n+1);
    off+=n+1;
    type=buf[off];
    off++;
    s=malloc(sizeof(struct DataMapScalar));
    if (s==NULL) {
      free(name);
      break;
    }

    s->name=name;
    s->mode=1;
    s->type=type;
    ptr->scl[c]=s;   

    switch (s->type) {
    case DATACHAR:
      s->data.vptr=malloc(sizeof(char));
      if (s->data.vptr==NULL) break;
      s->data.cptr[0]=buf[off];
      off++;
      break;
    case DATASHORT:
      s->data.vptr=malloc(sizeof(int16));
      if (s->data.vptr==NULL) break;
      ConvertToShort(buf+off,s->data.sptr);
      off+=sizeof(int16);
      break;
    case DATAINT:
      s->data.vptr=malloc(sizeof(int32));
      if (s->data.vptr==NULL) break;
      ConvertToInt(buf+off,s->data.iptr);
      off+=sizeof(int32); 
      break;
    case DATAFLOAT:
      s->data.vptr=malloc(sizeof(float));
      if (s->data.vptr==NULL) break;
      ConvertToFloat(buf+off,s->data.fptr);
      off+=sizeof(float);
      break;
    case DATADOUBLE:
      s->data.vptr=malloc(sizeof(double));
      if (s->data.vptr==NULL) break;
      ConvertToDouble(buf+off,s->data.dptr);
      off+=sizeof(double);
      break;
    default:
      n=0;
      while ((buf[off+n] !=0) && (off+n<size)) n++;
      if (off+n>=size) break;
      s->data.vptr=malloc(sizeof(char *));
      if (s->data.vptr==NULL) break;
      tmp=realloc(ptr->buf,ptr->sze+n+1);
      if (tmp==NULL) break;
      ptr->buf=tmp;
      memcpy(ptr->buf+ptr->sze,buf+off,n+1);
      off+=n+1;
      *(s->data.optr)=ptr->sze;
      ptr->sze+=n+1;
      break;
    }
  }

  if (c !=sn) {
    DataMapFree(ptr);
    return NULL;
  }
  for (c=0;c<an;c++) {
    n=0;
    while ((buf[off+n] !=0) && (off+n<size)) n++;
    if (off+n>=size) break;
    name=malloc(n+1);
    if (name==NULL) break;
    memcpy(name,buf+off,n+1);
    off+=n+1;
    type=buf[off];
    off++;
    a=malloc(sizeof(struct DataMapArray));
    if (a==NULL) {
      free(name);
      break;
    }
    a->name=name;
    a->mode=3;
    a->type=type;
    ptr->arr[c]=a;   
    ConvertToInt(buf+off,(int32 *) &(a->dim));
    off+=sizeof(int32);
    a->rng=malloc(a->dim*sizeof(int32));
    if (a->rng==NULL) break;
    for (x=0;x<a->dim;x++)  {
       ConvertToInt(buf+off,&a->rng[x]);
       off+=sizeof(int32);
    }
    if (x!=a->dim) break;
    n=1;
    for (x=0;x<a->dim;x++) n=a->rng[x]*n;
    switch (a->type) {
    case DATACHAR:
      a->data.vptr=malloc(sizeof(char)*n);
      if (a->data.vptr==NULL) break;
      memcpy(a->data.cptr,buf+off,sizeof(char)*n);
      off+=sizeof(char)*n;
      break;
    case DATASHORT:
      a->data.vptr=malloc(sizeof(int16)*n);
      if (a->data.vptr==NULL) break;
      for (x=0;x<n;x++) {
        ConvertToShort(buf+off,&a->data.sptr[x]);
        off+=sizeof(int16);
      }
      break;
    case DATAINT:
      a->data.vptr=malloc(sizeof(int32)*n);
      if (a->data.vptr==NULL) break;
      for (x=0;x<n;x++) {
        ConvertToInt(buf+off,&a->data.iptr[x]);
        off+=sizeof(int32);
      }
      break;
    case DATAFLOAT:
      a->data.vptr=malloc(sizeof(float)*n);
      if (a->data.vptr==NULL) break;
      for (x=0;x<n;x++) {
        ConvertToFloat(buf+off,&a->data.fptr[x]);
        off+=sizeof(float);
      }
      break;
    case DATADOUBLE:
      a->data.vptr=malloc(sizeof(double)*n);
      if (a->data.vptr==NULL) break;
      for (x=0;x<n;x++) {
	ConvertToDouble(buf+off,&a->data.dptr[x]);
	off+=sizeof(double);
      }
      break;
    default:
      a->data.vptr=malloc(sizeof(char *)*n);
      if (a->data.vptr==NULL) break;
          
      for (x=0;x<n;x++) {
         i=0;
          
         while ((buf[off+i] !=0) && (off+i<size)) i++;
         if (off+i>=size) break;
         tmp=realloc(ptr->buf,ptr->sze+i+1);
         if (tmp==NULL) break;
         ptr->buf=tmp;
         memcpy(ptr->buf+ptr->sze,buf+off,i+1); 
         a->data.optr[x]=ptr->sze;
         ptr->sze+=i+1;
         off+=i+1;
      }
      if (x !=n) break;
    }
  }

  if (c !=an) {
    DataMapFree(ptr);
    return NULL;
  }
  

  for (c=0;c<ptr->snum;c++) {
    if (ptr->scl[c]==NULL) continue;
    s=ptr->scl[c];
    if (s->type==DATASTRING) 
      *((char **) s->data.vptr)=(char *) (ptr->buf+*(s->data.optr));



  }
  
  for (c=0;c<ptr->anum;c++) {
    if (ptr->arr[c]==NULL) continue;
    a=ptr->arr[c];
    if (a->type==DATASTRING) {
      n=1;
      for (x=0;x<a->dim;x++) n=a->rng[x]*n;
      for (x=0;x<n;x++) 
	( (char **) a->data.vptr)[x]=(char *) (ptr->buf+a->data.optr[x]);
    }
  }
  return ptr;
}
コード例 #10
0
//----------------------------------------------------------------------------
// CCenRepAttributesNonMasked::UpdateContextL
//----------------------------------------------------------------------------
//
void CCenRepAttributesNonMasked::UpdateContextL( const TInt aKeyValue )
    {
    FUNC_LOG;

    TInt valueValue = 0;
    TPtrC value( KNullDesC );
    TPtrC key( KNullDesC );

    TPtrC conTypePtr ( KNullDesC );
    TPtrC conSourcePtr ( KNullDesC );
    TPtrC conValuePtr ( KNullDesC );

    for( TInt i = 0; i < iParamCount; i++ )
        {
        TBool publishOk( ETrue );
        const RKeyValueArray& paramAttr = iParamArray[i]->Attributes();
        TInt paramAttrCount = paramAttr.Count();
        for( TInt j = 0; j < paramAttrCount; j++ )
            {
            key.Set( paramAttr[j]->Key() );
            value.Set( paramAttr[j]->Value() );
            
            if ( value.Length() <= 0 )
                {
                publishOk = EFalse;
                }

            // Check Value
            if ( key.CompareF( KValue ) == KErrNone )
                {
                TInt err = ConvertToInt( value, valueValue );
                }

            // Check ContextSource
            else if ( key.CompareF( KContextSource ) == KErrNone )
                {
                conSourcePtr.Set( value );
                }

            // Check ContextType
            else if ( key.CompareF( KContextType ) == KErrNone )
                {
                conTypePtr.Set( value);
                }

            // Check ContextValue
            else if ( key.CompareF( KContextValue ) == KErrNone )
                {
                conValuePtr.Set( value );
                }
            }

        if ( aKeyValue == valueValue )
            {
            iContext->SetSourceL( conSourcePtr );
            iContext->SetTypeL( conTypePtr );
            iContext->SetValueL( conValuePtr );

            if ( publishOk )
                {
                PublishContext();
                }
            }
         }
    }
コード例 #11
0
int raw_read_current(struct rawfp *fp,struct rawdata *raw_data) { 

   /* read raw data block from file */


   int radar_parms_pat[]={1,2,2,17,4,2,2,14,4,4,2,4,0,0};
   int i;
   int16 range;
   int j;
   int16 prev_range;
   int xcf_data;
   unsigned int stat;
   int16 num_byte;
   int32 rec_num=0;
   unsigned char *inbuf;
   unsigned char *inbuf_ptr;

   xcf_data = 0;
   prev_range = -1;

   inbuf=malloc(sizeof(struct rawdata));

   /* zero out the raw data buffer */
   memset(raw_data,0,sizeof(struct rawdata));
   fp->rlen=0;
   do {
     if (ConvertReadShort(fp->rawfp,&num_byte) !=0) {
       free(inbuf);
       return -1;
     }
     fp->rlen+=num_byte;
     fp->ptr+=num_byte;
     num_byte = num_byte - 2;
     stat = read(fp->rawfp,inbuf,num_byte);
     if(stat != num_byte) {
       free(inbuf);
       return -1; 
     }
     inbuf_ptr=inbuf;
     ConvertToInt(inbuf_ptr,&rec_num);
   } while (rec_num==0); 
   inbuf_ptr = inbuf_ptr + 12;  /* skip rec_num + rawwrite */  
   num_byte = num_byte - 12;
  
   /* zero out the raw data buffer */

   /* copy radar_parms */   
   ConvertBlock(inbuf_ptr,radar_parms_pat);
   memcpy((void *) &(raw_data->PARMS),inbuf_ptr,sizeof(struct radar_parms)); 
   inbuf_ptr = inbuf_ptr + sizeof(struct radar_parms);
   num_byte = num_byte - sizeof(struct radar_parms);

   /* copy the pulse pattern */
  
   for (i=0;i<raw_data->PARMS.MPPUL;i++) {
      ConvertToShort(inbuf_ptr,&raw_data->PULSE_PATTERN[i]);
      inbuf_ptr+=sizeof(int16);
      num_byte-=sizeof(int16);
   }

   /* copy the lag table */

    for(j=0;j < 2; ++j)
      for(i=0; i < raw_data->PARMS.MPLGS; ++i) {
         ConvertToShort(inbuf_ptr,&raw_data->LAG_TABLE[j][i]);
         inbuf_ptr = inbuf_ptr + sizeof(int16);
         num_byte = num_byte - sizeof(int16);
      } 
	  
   /* copy comment buffer */
   memcpy(raw_data->COMBF,inbuf_ptr,ORIG_COMBF_SIZE);
   inbuf_ptr = inbuf_ptr + ORIG_COMBF_SIZE;
   num_byte = num_byte - ORIG_COMBF_SIZE;

   /* decompress and copy the lag-0 powers */
   for(i=0 ; i < raw_data->PARMS.NRANG ; ++i) {
      raw_data->pwr0[i] = dcmpr(inbuf_ptr);
      inbuf_ptr = inbuf_ptr + sizeof(int16);
      num_byte = num_byte - sizeof(int16);
   }

   /* decompress and copy acfs */
   while ( num_byte > 0 ) {
      ConvertToShort(inbuf_ptr,&range);
      --range;
      inbuf_ptr = inbuf_ptr + sizeof(int16);
      num_byte = num_byte - sizeof(int16);

      if((range <= prev_range) && (raw_data->PARMS.XCF))
		   xcf_data = 1;

      for(i = 0; i < raw_data->PARMS.MPLGS ; ++i) {   
         for(j=0 ; j < 2; ++j) {
	    if (xcf_data) raw_data->xcfd[range][i][j] = dcmpr(inbuf_ptr);
	    else raw_data->acfd[range][i][j] = dcmpr(inbuf_ptr);
            inbuf_ptr = inbuf_ptr + sizeof(int16);
            num_byte = num_byte - sizeof(int16);
         }
      }
		
      prev_range = range;

   } 
  fp->ctime=TimeYMDHMSToEpoch(raw_data->PARMS.YEAR,
			raw_data->PARMS.MONTH,
			raw_data->PARMS.DAY,
			raw_data->PARMS.HOUR,
			raw_data->PARMS.MINUT,
			raw_data->PARMS.SEC);
  free(inbuf);  
  return 0;
}
コード例 #12
0
enum Enum {
  Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
};

template<typename T> struct InstantiationAfterSpecialization {};
template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}}
template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}}

void *dlsym();
void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}

struct ConvertToInt {
  operator int();
};
int *ArraySizeConversion = new int[ConvertToInt()]; // expected-warning {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}

template<typename T> class ExternTemplate {};
extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}

long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
         -42LL; // expected-warning {{'long long' is incompatible with C++98}}
unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
                   42ULL; // expected-warning {{'long long' is incompatible with C++98}}

int k = 0b1001;
#ifdef CXX1Y
// expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++1y}}
#endif

void f(int n) { int a[n]; }
コード例 #13
0
ファイル: rawopen.c プロジェクト: jspaleta/VT_RST3
struct OldRawFp *OldRawOpenFd(int rawfd,int inxfd) {

  int radar_parms_pat[]={1,2,2,17,4,2,2,14,4,4,2,4,0,0};

  unsigned char *inbuf=NULL;
  int16 num_byte;
  int32 rec_num;
  int stat;
  struct radar_parms *prm;
  struct OldRawFp *ptr=NULL;
  int status=0;
  int j;

  inbuf=malloc(sizeof(struct rawdata));
  if (inbuf==NULL) return NULL;

  ptr=malloc(sizeof(struct OldRawFp));
  
  if (ptr==NULL) return NULL;

  ptr->rawfp=rawfd;
  ptr->stime=-1;
  ptr->ctime=-1;
  ptr->frec=0;
  ptr->rlen=0;
  ptr->ptr=0;

  fstat(ptr->rawfp,&ptr->rstat);

  if (ConvertReadShort(ptr->rawfp,&num_byte) !=0) {
    close(ptr->rawfp);
    free(ptr);
    free(inbuf);
    return NULL;
  }

  num_byte = num_byte - 2;
  stat = read(ptr->rawfp,inbuf,num_byte);
  if (stat != num_byte) {
    close(ptr->rawfp);
    free(ptr);
    free(inbuf);
    return NULL;
  }
  ConvertToInt(inbuf,&rec_num);

  ptr->frec=num_byte+2;
  ptr->rlen=num_byte+2;
  ptr->ptr=num_byte+2;

  if (rec_num==0) { /* decode header to get the threshold */
    char tmp[256];
    char *str;
    strcpy(tmp,(char *) (inbuf+sizeof(struct rawrechdr)-sizeof(int16)+1));
    ptr->thr=3;
    str=strtok(tmp," ");
    if (str==NULL) status=-1;
    if ((status==0) && (strcmp(str,"version") !=0)) status=-1;
    if (status==0) str=strtok(NULL," ");
    if (str==NULL) status=-1;
    for (j=0;str[j] !=0;j++) if (str[j]=='.') break;
    if (str[j]==0) {
      ptr->major_rev=atoi(str);
    } else {
      str[j]=0;
      ptr->major_rev=atoi(str);
      ptr->minor_rev=atoi(str+j+1);
    }
    if (status==0) str=strtok(NULL," ");
    if (str==NULL) status=-1;
    if ((status==0) && (strcmp(str,"threshold") !=0)) status=-1;
    if (status==0) str=strtok(NULL," ");
    if (str==NULL) status=-1;
    if (status==0) ptr->thr=atoi(str);
  }

  if (rec_num !=0) { /* not the header so rewind the file */
    lseek(ptr->rawfp,0L,SEEK_SET);
    ptr->rlen=0;
  }

  /* read the first record so that we can determine the start time of 
     the file */

  
 if (ConvertReadShort(ptr->rawfp,&num_byte) !=0) {
    close(ptr->rawfp);
    free(ptr);
    free(inbuf);
    return NULL;
  }

  num_byte = num_byte - 2;
  stat = read(ptr->rawfp,inbuf,num_byte);
  if (stat != num_byte) {
    close(ptr->rawfp);
    free(ptr);
    free(inbuf);
    return NULL;
  }

  ConvertToInt(inbuf,&rec_num);

  /* now decode the parameter block */

  ConvertBlock(inbuf+12,radar_parms_pat);
  prm=(struct radar_parms *) (inbuf+12);   

  ptr->stime=TimeYMDHMSToEpoch(prm->YEAR,prm->MONTH,prm->DAY,
	  prm->HOUR,prm->MINUT,prm->SEC);

  ptr->ctime=ptr->stime;

  /* rewind to the first record */

  lseek(ptr->rawfp,ptr->frec,SEEK_SET);

  ptr->rawread=OldRawReadCurrent;

  free(inbuf);
  return ptr;
}
コード例 #14
0
ファイル: raw_open.c プロジェクト: Shirling-VT/VTRST3.5
struct rawfp *raw_open(char *rawfile,char *inxfile) {

    int radar_parms_pat[]= {1,2,2,17,4,2,2,14,4,4,2,4,0,0};

    unsigned char *inbuf=NULL;
    int16 num_byte;
    int32 rec_num;
    int stat;
    struct radar_parms *prm;
    struct rawfp *ptr=NULL;

    inbuf=malloc(sizeof(struct rawdata));
    if (inbuf==NULL) return NULL;

    ptr=malloc(sizeof(struct rawfp));

    if (ptr==NULL) return NULL;

    ptr->rawfp=open(rawfile,O_RDONLY);
    ptr->stime=-1;
    ptr->ctime=-1;
    ptr->frec=0;
    ptr->rlen=0;
    ptr->ptr=0;
    if (ptr->rawfp==-1) {
        free(ptr);
        free(inbuf);
        return NULL;
    }
    fstat(ptr->rawfp,&ptr->rstat);

    if (ConvertReadShort(ptr->rawfp,&num_byte) !=0) {
        close(ptr->rawfp);
        free(ptr);
        free(inbuf);
        return NULL;
    }

    num_byte = num_byte - 2;
    stat = read(ptr->rawfp,inbuf,num_byte);
    if (stat != num_byte) {
        close(ptr->rawfp);
        free(ptr);
        free(inbuf);
        return NULL;
    }
    ConvertToInt(inbuf,&rec_num);

    ptr->frec=num_byte+2;
    ptr->rlen=num_byte+2;
    ptr->ptr=num_byte+2;

    if (rec_num !=0) { /* not the header so rewind the file */
        lseek(ptr->rawfp,0L,SEEK_SET);
        ptr->rlen=0;
    }

    /* read the first record so that we can determine the start time of
       the file */


    if (ConvertReadShort(ptr->rawfp,&num_byte) !=0) {
        close(ptr->rawfp);
        free(ptr);
        free(inbuf);
        return NULL;
    }

    num_byte = num_byte - 2;
    stat = read(ptr->rawfp,inbuf,num_byte);
    if (stat != num_byte) {
        close(ptr->rawfp);
        free(ptr);
        free(inbuf);
        return NULL;
    }

    ConvertToInt(inbuf,&rec_num);

    /* now decode the parameter block */

    ConvertBlock(inbuf+12,radar_parms_pat);
    prm=(struct radar_parms *) (inbuf+12);

    ptr->stime=TimeYMDHMSToEpoch(prm->YEAR,prm->MONTH,prm->DAY,
                                 prm->HOUR,prm->MINUT,prm->SEC);

    /* rewind to the first record */

    lseek(ptr->rawfp,ptr->frec,SEEK_SET);

    ptr->rawread=raw_read_current;

    free(inbuf);
    return ptr;
}
コード例 #15
0
int CFitRead(struct CFitfp *fptr,struct CFitdata *ptr) {
  float val;
  int i;
  
  if (fptr->fp !=-1) {
    if (ConvertReadDouble(fptr->fp,&ptr->time) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->stid) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->scan) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->cp) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->bmnum) !=0) return -1;
    if (ConvertReadFloat(fptr->fp,&ptr->bmazm) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->channel) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->intt.sc) !=0) return -1;
    if (ConvertReadInt(fptr->fp,&ptr->intt.us) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->frang) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->rsep) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->rxrise) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->tfreq) !=0) return -1;
    if (ConvertReadInt(fptr->fp,&ptr->noise) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->atten) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->nave) !=0) return -1;
    if (ConvertReadShort(fptr->fp,&ptr->nrang) !=0) return -1;
    
  } else {
    if ((fptr->fptr+sizeof(double)+7*sizeof(int16)+
         sizeof(int32)+sizeof(float))>fptr->fsze) return -1;
    ConvertToDouble(&fptr->fbuf[fptr->fptr],&ptr->time);
    fptr->fptr+=sizeof(double);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->stid);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->scan);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->cp);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->bmnum);
    fptr->fptr+=sizeof(int16);
    ConvertToFloat(fptr->fbuf+fptr->fptr,&ptr->bmazm);
    fptr->fptr+=sizeof(float);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->channel);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->intt.sc);
    fptr->fptr+=sizeof(int16);
    ConvertToInt(fptr->fbuf+fptr->fptr,&ptr->intt.us);
    fptr->fptr+=sizeof(int32);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->frang);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->rsep);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->rxrise);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->tfreq);
    fptr->fptr+=sizeof(int16);
    ConvertToInt(fptr->fbuf+fptr->fptr,&ptr->noise);
    fptr->fptr+=sizeof(int32);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->atten);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->nave);
    fptr->fptr+=sizeof(int16);
    ConvertToShort(fptr->fbuf+fptr->fptr,&ptr->nrang);
    fptr->fptr+=sizeof(int16);
  }
  fptr->ctime=ptr->time;

  if (fptr->fp !=-1) {
    if (read(fptr->fp,&ptr->num,1) !=1) return -1;
    if (read(fptr->fp,ptr->rng,ptr->num) !=ptr->num) return -1;
  } else {
    if (fptr->fptr>=fptr->fsze) return -1;
    ptr->num=fptr->fbuf[fptr->fptr];
    fptr->fptr+=1;
    if ((fptr->fptr+ptr->num)>=fptr->fsze) return -1;
    memcpy(ptr->rng,&fptr->fbuf[fptr->fptr],ptr->num);
    fptr->fptr+=ptr->num;
  }

  for (i=0;i<ptr->num;i++) {
    if (fptr->fp !=-1) {
      if (read(fptr->fp,&ptr->data[i].gsct,1) !=1) return -1;
      if (ptr->data[i].gsct==EOF) return -1; 
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].p_0=val;  
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].p_0_e=val;      
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].v=val;
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].p_l=val;
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].w_l=val;
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].v_e=val;
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].p_l_e=val;
      if (ConvertReadFloat(fptr->fp,&val) !=0) return -1;
      ptr->data[i].w_l_e=val;
    } else {
      if ((fptr->fptr+1+sizeof(float)*6)>=fptr->fsze) return -1;
      ptr->data[i].gsct=fptr->fbuf[fptr->fptr];
      fptr->fptr+=1;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].p_0=val;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].p_0_e=val;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].v=val;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].p_l=val;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].w_l=val;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].v_e=val;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].p_l_e=val;
      ConvertToFloat(fptr->fbuf+fptr->fptr,&val);
      fptr->fptr+=sizeof(float);
      ptr->data[i].w_l_e=val;
    }
  }
  
  return 0;
}
コード例 #16
0
ファイル: timedctf.cpp プロジェクト: szakats/bzflag_mirror
bool TCTFCommands::handle(int playerID, bz_ApiString _command, bz_ApiString _message, bz_APIStringList * /*_param*/ )
{
  std::string command = _command.c_str();
  std::string message = _message.c_str();

  bz_BasePlayerRecord *fromPlayer = bz_getPlayerByIndex(playerID);

  if (fromPlayer) {
    if (!fromPlayer->admin) {
      bz_sendTextMessage(BZ_SERVER, playerID,
			 "You must be admin to use the ctfcaptime commands.");
      bz_freePlayerRecord(fromPlayer);
      return true;
    }
    bz_freePlayerRecord(fromPlayer);
  }

  if (command == "tctfon") {
    tctf.enabled = true;
    if (!tctf.timerRunning)
      ResetTeamData();
    bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF is enabled.");
    return true;
  }

  if (command == "tctfoff") {
    tctf.enabled = false;
    tctf.timerRunning = false;
    bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF is disabled.");
    return true;
  }

  if (command == "fairctfon") {
    tctf.fairCTFEnabled = true;
    bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Fair CTF is enabled.");
    return true;
  }

  if (command == "fairctfoff") {
    tctf.fairCTFEnabled = false;
    bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Fair CTF is disabled.");
    if (!tctf.timerRunning)
      ResetTeamData();
    return true;
  }

  if (command == "tctfsoundon") {

    tctf.soundEnabled = true;
    bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF sound is enabled.");
    return true;
  }

  if (command == "tctfsoundoff") {

    tctf.soundEnabled = false;
    bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "Timed CTF sound is disabled.");
    return true;
  }

  if (command == "tctfstatus") {

    if (tctf.enabled && !tctf.timerRunning)
      bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF is currently enabled, but not running.");

    if (tctf.enabled && tctf.timerRunning)
      bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF is currently enabled, and running");

    if (!tctf.enabled)
      bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF is currently disabled.");

    if (!tctf.fairCTFEnabled)
      bz_sendTextMessagef(BZ_SERVER, playerID, "Fair CTF is currently disabled");

    if (tctf.fairCTFEnabled)
      bz_sendTextMessagef(BZ_SERVER, playerID, "Fair CTF is currently enabled");

    if (!tctf.soundEnabled)
      bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF sounds are currently disabled");

    if (tctf.soundEnabled)
      bz_sendTextMessagef(BZ_SERVER, playerID, "Timed CTF sounds are currently enabled");

    tctf.adjTime = (int) (tctf.timeLimit / 60 + 0.5);
    bz_sendTextMessagef(BZ_SERVER, playerID, "CTF capture time is currently set to: %i minutes", tctf.adjTime);
    return true;
  }
  // explicit time command handler:

  if (command == "tctftime") {
    double inputvalue = ConvertToInt(message);

    if (inputvalue > 0) {

      tctf.timeLimit = inputvalue * 60;
      tctf.adjTime = (int) (tctf.timeLimit / 60 + 0.5);
      bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "CTF capture time has been set to %i minutes.", tctf.adjTime);

      if (!tctf.enabled)
	bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "(Timed CTF is still disabled)");

      ResetTeamData();
      return true;
    } else {
      bz_sendTextMessagef(BZ_SERVER, playerID, "CTF capture time invalid: must be between 1 and 120 minutes.");
      return true;
    }

    return true;
  }

  return false;
}
コード例 #17
0
VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}}

; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}

enum Enum {
  Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
};

void *dlsym();
void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}

struct ConvertToInt {
  operator int();
};
int *ArraySizeConversion = new int[ConvertToInt()];
#ifdef CXX1Y2
// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}}
#else
// expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
#endif

template<typename T> class ExternTemplate {};
extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}

long long ll1 = // expected-warning {{'long long' is incompatible with C++98}}
         -42LL; // expected-warning {{'long long' is incompatible with C++98}}
unsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}}
                   42ULL; // expected-warning {{'long long' is incompatible with C++98}}

int k = 0b1001;