Example #1
0
U0 StreamPutS(U8 *buf)
//Inss text into the stream of
//characters being compiled.Called
//from withing #exe{} block.
{
  CLex *lx=Fs->last_lex;
  CStreamBlk *tempe=lx->last_stream_blk;
  if (tempe!=&lx->next_stream_blk)
    tempe->body=StrAdd(tempe->body,buf);
  else
    PrintFErr("No exe{} blk\n");
}
Example #2
0
unsigned int
UpdateCfgItem(char *FileName,char *SectionName,char *VarWanted,
              void *DataPtr, enum CfgVarTypes DataType, unsigned int HowMany)
/*
** Update an item in a .ini / .cfg file.
** Returns 0 on failure, else the number of items written.
*/
{
 char *Str;

if (HowMany==0) return 0; /* Got to have something to write. */
Str=(char*)malloc(1);*Str='\0';

if (DataType==Cfg_String)
  {
   Str=StrAdd(Str,(char*)DataPtr);
   /* Need to do max len */
  }
else
  {char TStr[45];
   unsigned int NumItems=HowMany;
   while (NumItems--)
     {TStr[0]='\0';
      switch (DataType)
        {
         case Cfg_Integer:
              sprintf(TStr,"%d",*((int*)DataPtr));
              DataPtr=((char*)DataPtr)+sizeof(int);
              break;
         case Cfg_UInteger:
              sprintf(TStr,"%u",*((unsigned int*)DataPtr));
              DataPtr=((char*)DataPtr)+sizeof(unsigned int);
              break;
         case Cfg_SInteger:
              sprintf(TStr,"%hd",*((short int*)DataPtr));
              DataPtr=((char*)DataPtr)+sizeof(short int);
              DataPtr=((char*)DataPtr)+sizeof(int);
              break;
         case Cfg_USInteger:
              sprintf(TStr,"%hu",*((unsigned short int*)DataPtr));
              DataPtr=((char*)DataPtr)+sizeof(unsigned short int);
              break;
         case Cfg_LInteger:
              sprintf(TStr,"%ld",*((long int*)DataPtr));
              DataPtr=((char*)DataPtr)+sizeof(long int);
              break;
         case Cfg_ULInteger:
              sprintf(TStr,"%lu",*((unsigned long int*)DataPtr));
              DataPtr=((char*)DataPtr)+sizeof(unsigned long int);
              break;
         case Cfg_Boolean:
              strcpy(TStr,"False");
              if (*((int*)DataPtr)) strcpy(TStr,"True");
              DataPtr=((char*)DataPtr)+sizeof(int);
              break;
         case Cfg_Bytes:
              sprintf(TStr,"%u",*((unsigned char*)DataPtr));
              DataPtr=((char*)DataPtr)+sizeof(unsigned char);
              break;
         default: free(Str);return 0;
        }
      Str=StrAdd(Str,TStr);
      if (NumItems) Str=StrAdd(Str,", ");
     }
  }

if (Str==NULL) return 0;
else
  {int x;
   x=UpdateCfgStr(FileName,SectionName,VarWanted,Str);
   free(Str);
   if (!x) return 0;
   else return HowMany;
  }
}