示例#1
0
//
//	Deserializando strings. Devemos sempre ler o tamanho da string antes 
//	e depois a propria string se for o caso, colocando-se o '\0' ao final.
//
boolean 
RPC::Deserializa ( unsigned char **Obj, unsigned char *Buff )
{
	long TamString;

	Deserializa(&TamString, Buff);
	Buff += SizeOf(TamString);
	if ( TamString == MARCA_NULL ) {	// nao temos string
		*Obj = NULL;
		return TRUE;
	}

	*Obj = (unsigned char *) new char[TamString + 1];
	if ( !*Obj )
		return(FALSE);

	memcpy( *Obj, Buff, TamString);
	(*Obj)[TamString] = '\0';	// fecha a string

	return TRUE;
}
示例#2
0
long
RPC::SizeOf( TSRIn_OpenBase Obj )
{
	long lTam=0;
	
	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf( Obj.szBaseName );

	lTam += SizeOf( Obj.szBasePassword );

	lTam += SizeOf(Obj.bExclusive);
	
	lTam += SizeOf(Obj.bReadOnly);
	
	lTam += SizeOf(Obj.bMaintenance);
	
	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#3
0
long
RPC::SizeOf( TSRIn_Import Obj )
{
	long lTam=0;
	
	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf( Obj.szNewOwnerName );

	lTam += SizeOf( Obj.szNewBasePassword );

	lTam += SizeOf( Obj.szNewMaintenanceBasePassword );

	lTam += SizeOf( Obj.szImportPsw );

	lTam += SizeOf( Obj.szFullImportFileName );

	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#4
0
long
RPC::SizeOf( TSRIn_What Obj )
{
	long lTam=0;
	
	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf( Obj.szUserName );

	lTam += SizeOf( Obj.szDataBaseName );

	lTam += SizeOf( Obj.szUDB );

	lTam += SizeOf( Obj.lFilterLevel );

	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#5
0
long
RPC::SizeOf( TSRIn_GetGroups Obj )
{
	long lTam=0;
	
	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf(Obj.szUserName);

	lTam += SizeOf(Obj.szUserPswd);

	lTam += SizeOf(Obj.szUDBName);

	lTam += SizeOf(Obj.bMem);

	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#6
0
static void s_PrintFirewallPorts(char* buf, size_t bufsize,
                                 const SConnNetInfo* net_info)
{
    EFWMode mode = net_info ? (EFWMode) net_info->firewall : eFWMode_Legacy;
    size_t  len, n;
    unsigned int m;

    assert(buf  &&  bufsize > 1);
    switch (mode) {
    case eFWMode_Legacy:
        *buf = '\0';
        return;
    case eFWMode_Firewall:
        memcpy(buf, "0", 2);
        return;
    default:
        break;
    }
    len = 0;
    for (n = m = 0; n < SizeOf(s_FWPorts); n++, m += sizeof(s_FWPorts[0])<<3) {
        unsigned short p;
        TNCBI_BigCount mask = s_FWPorts[n];
        for (p = m;  mask;  p++, mask >>= 1) {
            if (mask & 1) {
                char port[10];
                int  k = sprintf(port, " %hu" + !len, p);
                if (len + k < bufsize) {
                    memcpy(buf + len, port, k);
                    len += k;
                }
                if (!p)
                    break;
            }
        }
    }
    buf[len] = '\0';
}
示例#7
0
void ImplicitTreap::Split(Node* v, int x, Node* &L, Node* &R) {
    
    if(!v) {
        L = nullptr;
        R = nullptr;
        return;
    }
    
    Push(v);
    int curIndex = SizeOf(v->left) + 1;
    if (curIndex > x)
    {
        R = v;
        Split(v->left, x, L, R->left);
    }
    else
    {
        L = v;
        Split(v->right, x - curIndex, L->right, R);
    }
    
    Recalc(L);
    Recalc(R);
}
示例#8
0
long
RPC::SizeOf( TSRIn_DeleteUDB Obj )
{
	long lTam=0;

	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf( Obj.szPassword, PASSWORDSIZE + 1 );

	lTam += SizeOf( Obj.szBaseName );

	lTam += SizeOf(Obj.bForce);
	
	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#9
0
long
RPC::SizeOf( TSRIn_UpdateUserAddress Obj )
{
	long lTam=0;
	
	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf( Obj.szUDBName );

	lTam += SizeOf( Obj.szUserName );

	lTam += SizeOf( Obj.szNewAddr );

	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#10
0
long
RPC::SizeOf( TSRIn_AddDelGroupUser Obj )
{
	long lTam=0;
	
	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf( Obj.szUDBName );

	lTam += SizeOf( Obj.szUserName );

	lTam += SizeOf( Obj.szGroups );

	lTam += SizeOf(Obj.lTam);

	lTam += Obj.lTam;

	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#11
0
long
RPC::SizeOf( TSRIn_MGetPutFieldRep Obj )
{
	long lTam=0;

	lTam += SizeOf(Obj.lBaseObj);

	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf(Obj.lNumFieldIds);

	lTam += SizeOf(Obj.pFieldIds, Obj.lNumFieldIds);

	lTam += SizeOf(Obj.lTamBuff);

	lTam += Obj.lTamBuff;

	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#12
0
void 
RPC::Serializa( TSRIn_DeleteUDB Obj, unsigned char *Buff ) 
{
	Serializa( Obj.lSessionObj, Buff ); 
	Buff += SizeOf( Obj.lSessionObj );

	Serializa( Obj.sTicket, Buff ); 
	Buff += SizeOf( Obj.sTicket );

	Serializa( Obj.szPassword, Buff, PASSWORDSIZE + 1 ); // nao eh um string; 
	Buff += SizeOf( Obj.szPassword, PASSWORDSIZE + 1 );

	Serializa( Obj.szBaseName, Buff ); // eh um string; 
	Buff += SizeOf( Obj.szBaseName );

	Serializa( Obj.bForce, Buff);
	Buff += SizeOf(Obj.bForce);
	
	Serializa( Obj.sCtrlInfo, Buff);
	Buff += SizeOf(Obj.sCtrlInfo);
}
示例#13
0
void 
RPC::Serializa( TSRIn_UpdateUserAddress Obj, unsigned char *Buff ) 
{
	Serializa( Obj.lSessionObj, Buff);
	Buff += SizeOf(Obj.lSessionObj);
	
	Serializa( Obj.sTicket, Buff); 
	Buff += SizeOf(Obj.sTicket);

	Serializa( Obj.szUDBName, Buff ); // eh um string; 
	Buff += SizeOf( Obj.szUDBName );

	Serializa( Obj.szUserName, Buff ); // eh um string; 
	Buff += SizeOf( Obj.szUserName );

	Serializa( Obj.szNewAddr, Buff ); // eh um string; 
	Buff += SizeOf( Obj.szNewAddr );

	Serializa( Obj.sCtrlInfo, Buff);
	Buff += SizeOf(Obj.sCtrlInfo);
}
示例#14
0
void SP_Pop (const Type* T)
/* Adjust the stackpointer for a pop of an argument of the given type */
{
    StackPtr += SizeOf (T);
}
示例#15
0
long 
RPC::SizeOf( TSRTicket Obj ) 
{
	return ( SizeOf(Obj.lTickLen) + Obj.lTickLen );
}
示例#16
0
//
//	Serializa para um array
//
void 
RPC::Serializa ( TSRField *Obj, unsigned char *Buff, long TamBuff)
{
	memcpy( Buff, Obj, SizeOf(Obj, TamBuff ));
}
示例#17
0
long
RPC::SizeOf( TSRIn_CreateCloseDelete Obj )
{
	long lTam=0;
	
	lTam += SizeOf(Obj.lSessionObj);
	
	lTam += SizeOf(Obj.sTicket);

	lTam += SizeOf(Obj.lBaseObj);

	lTam += SizeOf(Obj.szBaseName);

	lTam += SizeOf(Obj.szLongBaseName);

	lTam += SizeOf(Obj.szBasePassword);

	lTam += SizeOf(Obj.szMaintenancePassword);

	lTam += SizeOf(Obj.bBaseType);

	lTam += SizeOf(Obj.bIsCrypto);

	lTam += SizeOf(Obj.szUserBaseName);

	lTam += SizeOf(Obj.lTam);

	lTam += Obj.lTam;
	
	lTam += SizeOf(Obj.lSlotNum);

	lTam += SizeOf(Obj.lCountNum);

	lTam += SizeOf(Obj.lMaxKeySize);

	lTam += SizeOf(Obj.szFileName);

	lTam += SizeOf(Obj.sCtrlInfo);

	return lTam;
}
示例#18
0
void SP_Push (const Type* T)
/* Adjust the stackpointer for a push of an argument of the given type */
{
    StackPtr -= SizeOf (T);
}
示例#19
0
// Generate an accessor struct, builder structs & function for a table.
static void GenTable(const Parser &parser, StructDef &struct_def,
                     const GeneratorOptions &opts, std::string *code_ptr) {
  if (struct_def.generated) return;
  std::string &code = *code_ptr;

  // Generate an accessor struct, with methods of the form:
  // type name() const { return GetField<type>(offset, defaultval); }
  GenComment(struct_def.doc_comment, code_ptr);
  code += "struct " + struct_def.name;
  code += " FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table";
  code += " {\n";
  for (auto it = struct_def.fields.vec.begin();
       it != struct_def.fields.vec.end();
       ++it) {
    auto &field = **it;
    if (!field.deprecated) {  // Deprecated fields won't be accessible.
      GenComment(field.doc_comment, code_ptr, "  ");
      code += "  " + GenTypeGet(parser, field.value.type, " ", "const ", " *",
                                true);
      code += field.name + "() const { return ";
      // Call a different accessor for pointers, that indirects.
      std::string call = IsScalar(field.value.type.base_type)
        ? "GetField<"
        : (IsStruct(field.value.type) ? "GetStruct<" : "GetPointer<");
      call += GenTypeGet(parser, field.value.type, "", "const ", " *", false);
      call += ">(" + NumToString(field.value.offset);
      // Default value as second arg for non-pointer types.
      if (IsScalar(field.value.type.base_type))
        call += ", " + field.value.constant;
      call += ")";
      code += GenUnderlyingCast(parser, field, true, call);
      code += "; }\n";
      auto nested = field.attributes.Lookup("nested_flatbuffer");
      if (nested) {
        auto nested_root = parser.structs_.Lookup(nested->constant);
        assert(nested_root);  // Guaranteed to exist by parser.
        code += "  const " + nested_root->name + " *" + field.name;
        code += "_nested_root() const { return flatbuffers::GetRoot<";
        code += nested_root->name + ">(" + field.name + "()->Data()); }\n";
      }
      // Generate a comparison function for this field if it is a key.
      if (field.key) {
        code += "  bool KeyCompareLessThan(const " + struct_def.name;
        code += " *o) const { return ";
        if (field.value.type.base_type == BASE_TYPE_STRING) code += "*";
        code += field.name + "() < ";
        if (field.value.type.base_type == BASE_TYPE_STRING) code += "*";
        code += "o->" + field.name + "(); }\n";
        code += "  int KeyCompareWithValue(";
        if (field.value.type.base_type == BASE_TYPE_STRING) {
          code += "const char *val) const { return strcmp(" + field.name;
          code += "()->c_str(), val); }\n";
        } else {
          code += GenTypeBasic(parser, field.value.type, false);
          code += " val) const { return " + field.name + "() < val ? -1 : ";
          code += field.name + "() > val; }\n";
        }
      }
    }
  }
  // Generate a verifier function that can check a buffer from an untrusted
  // source will never cause reads outside the buffer.
  code += "  bool Verify(flatbuffers::Verifier &verifier) const {\n";
  code += "    return VerifyTableStart(verifier)";
  std::string prefix = " &&\n           ";
  for (auto it = struct_def.fields.vec.begin();
       it != struct_def.fields.vec.end();
       ++it) {
    auto &field = **it;
    if (!field.deprecated) {
      code += prefix + "VerifyField";
      if (field.required) code += "Required";
      code += "<" + GenTypeSize(parser, field.value.type);
      code += ">(verifier, " + NumToString(field.value.offset);
      code += " /* " + field.name + " */)";
      switch (field.value.type.base_type) {
        case BASE_TYPE_UNION:
          code += prefix + "Verify" + field.value.type.enum_def->name;
          code += "(verifier, " + field.name + "(), " + field.name + "_type())";
          break;
        case BASE_TYPE_STRUCT:
          if (!field.value.type.struct_def->fixed) {
            code += prefix + "verifier.VerifyTable(" + field.name;
            code += "())";
          }
          break;
        case BASE_TYPE_STRING:
          code += prefix + "verifier.Verify(" + field.name + "())";
          break;
        case BASE_TYPE_VECTOR:
          code += prefix + "verifier.Verify(" + field.name + "())";
          switch (field.value.type.element) {
            case BASE_TYPE_STRING: {
              code += prefix + "verifier.VerifyVectorOfStrings(" + field.name;
              code += "())";
              break;
            }
            case BASE_TYPE_STRUCT: {
              if (!field.value.type.struct_def->fixed) {
                code += prefix + "verifier.VerifyVectorOfTables(" + field.name;
                code += "())";
              }
              break;
            }
            default:
              break;
          }
          break;
        default:
          break;
      }
    }
  }
  code += prefix + "verifier.EndTable()";
  code += ";\n  }\n";
  code += "};\n\n";

  // Generate a builder struct, with methods of the form:
  // void add_name(type name) { fbb_.AddElement<type>(offset, name, default); }
  code += "struct " + struct_def.name;
  code += "Builder {\n  flatbuffers::FlatBufferBuilder &fbb_;\n";
  code += "  flatbuffers::uoffset_t start_;\n";
  for (auto it = struct_def.fields.vec.begin();
       it != struct_def.fields.vec.end();
       ++it) {
    auto &field = **it;
    if (!field.deprecated) {
      code += "  void add_" + field.name + "(";
      code += GenTypeWire(parser, field.value.type, " ", true) + field.name;
      code += ") { fbb_.Add";
      if (IsScalar(field.value.type.base_type)) {
        code += "Element<" + GenTypeWire(parser, field.value.type, "", false);
        code += ">";
      } else if (IsStruct(field.value.type)) {
        code += "Struct";
      } else {
        code += "Offset";
      }
      code += "(" + NumToString(field.value.offset) + ", ";
      code += GenUnderlyingCast(parser, field, false, field.name);
      if (IsScalar(field.value.type.base_type))
        code += ", " + field.value.constant;
      code += "); }\n";
    }
  }
  code += "  " + struct_def.name;
  code += "Builder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) ";
  code += "{ start_ = fbb_.StartTable(); }\n";
  code += "  " + struct_def.name + "Builder &operator=(const ";
  code += struct_def.name + "Builder &);\n";
  code += "  flatbuffers::Offset<" + struct_def.name;
  code += "> Finish() {\n    auto o = flatbuffers::Offset<" + struct_def.name;
  code += ">(fbb_.EndTable(start_, ";
  code += NumToString(struct_def.fields.vec.size()) + "));\n";
  for (auto it = struct_def.fields.vec.begin();
       it != struct_def.fields.vec.end();
       ++it) {
    auto &field = **it;
    if (!field.deprecated && field.required) {
      code += "    fbb_.Required(o, " + NumToString(field.value.offset);
      code += ");  // " + field.name + "\n";
    }
  }
  code += "    return o;\n  }\n};\n\n";

  // Generate a convenient CreateX function that uses the above builder
  // to create a table in one go.
  code += "inline flatbuffers::Offset<" + struct_def.name + "> Create";
  code += struct_def.name;
  code += "(flatbuffers::FlatBufferBuilder &_fbb";
  for (auto it = struct_def.fields.vec.begin();
       it != struct_def.fields.vec.end();
       ++it) {
    auto &field = **it;
    if (!field.deprecated) {
      code += ",\n   " + GenTypeWire(parser, field.value.type, " ", true);
      code += field.name + " = ";
      if (field.value.type.enum_def && IsScalar(field.value.type.base_type)) {
        auto ev = field.value.type.enum_def->ReverseLookup(
           static_cast<int>(StringToInt(field.value.constant.c_str())), false);
        if (ev) {
          code += WrapInNameSpace(parser,
                                  field.value.type.enum_def->defined_namespace,
                                  GenEnumVal(*field.value.type.enum_def, *ev,
                                             opts));
        } else {
          code += GenUnderlyingCast(parser, field, true, field.value.constant);
        }
      } else {
        code += field.value.constant;
      }
    }
  }
  code += ") {\n  " + struct_def.name + "Builder builder_(_fbb);\n";
  for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1;
       size;
       size /= 2) {
    for (auto it = struct_def.fields.vec.rbegin();
         it != struct_def.fields.vec.rend();
         ++it) {
      auto &field = **it;
      if (!field.deprecated &&
          (!struct_def.sortbysize ||
           size == SizeOf(field.value.type.base_type))) {
        code += "  builder_.add_" + field.name + "(" + field.name + ");\n";
      }
    }
  }
  code += "  return builder_.Finish();\n}\n\n";
}
示例#20
0
//
//	Estrutura sem ponteiros; serializacao trivial.
//
void 
RPC::Serializa( TSRField Obj, unsigned char *Buff ) 
{
	long TamBuff = SizeOf(Obj);
	memcpy( Buff, &Obj, TamBuff);
}
示例#21
0
RValue Inst::SizeOf(CodeContext& context, NExpression* exp)
{
	return SizeOf(context, exp->genValue(context).stype());
}
示例#22
0
short ResolveReferences(void)
{
   Stack Ref;
   Instruction I,j;
   int Labelref;

   Ref = AllocateStack (200);

   for (I = 1; I <= SizeOf (Labels); I++) 
   {
      if (LabelOf(I) != UndefinedString)
         if (Element(Ref,LabelOf(I)) == UndefinedString)
            Assign(Ref,LabelOf(I),I);
         else 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"DUPLICATE INSTRUCTION WITH LABEL ");
    	    fprintf(output," %d **",LabelOf(I));
    	    WriteString(output,LabelOf(I));
            fprintf(output,"**: LINE %1d \n",I);
            return(false);
         }
   }

   for (I = 1; I <= SizeOf(Labels); I++) 
   {
      if (OpCodeOf(I) == GOTOOP || OpCodeOf(I) == CONDOP ||
                                   OpCodeOf(I) == CODEOP) 
      {
         Labelref = Element(Ref,Operand1Of(I));
         if (Labelref == 0) 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"NO INSTRUCTION WITH LABEL ");
    	    fprintf(TraceFile," %d ",Operand1Of(I));
            fprintf(output,"': LINE %1d \n",I);
            return(false);
         }
         
         Assign ( Ref, Operand1Of(I), 1000000+Labelref );
         Assign ( Operand1, I, Labelref % 1000000);
      }

      if (OpCodeOf(I) == CONDOP) 
      {
         Labelref = Element(Ref,Operand2Of(I));
         if (Labelref == 0) 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"NO INSTRUCTION WITH LABEL ");
    	    fprintf(output," %d ",Operand2Of(I));
            fprintf(output,"': LINE %1d \n",I);
            return(false);
         }
         Assign (Ref, Operand2Of(I), 1000000+Labelref );
         Assign (Operand2, I, Labelref % 1000000);
      }

      if (OpCodeOf(I) == LITOP || OpCodeOf(I) ==  LLVOP
            || OpCodeOf(I) ==  LGVOP  || OpCodeOf(I) == SLVOP
            || OpCodeOf(I) ==  SGVOP  || OpCodeOf(I) == LLIVOP
            || OpCodeOf(I) ==  LGIVOP || OpCodeOf(I) == SLIVOP
            || OpCodeOf(I) ==  SGIVOP || OpCodeOf(I) == LLAOP
            || OpCodeOf(I) ==  LGAOP  || OpCodeOf(I) == LUVOP
            || OpCodeOf(I) ==  SUVOP  || OpCodeOf(I) == POPOP
            || OpCodeOf(I) ==  CALLOP || OpCodeOf(I) == RTNOP)
          Assign (Operand1,I,StringToInteger(Operand1Of(I)));

       if (OpCodeOf(I) == LUVOP || OpCodeOf(I) == SUVOP )
          Assign(Operand2,I,StringToInteger(Operand2Of(I)));
   }

   for (I =1; I <= TextSize(); I++ ) 
   {
      if (Element(Ref,I) != 0)
         if (Element(Ref,I) < 1000000) 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"NO REFERENCE TO INSTRUCTION WITH LABEL ");
	    fprintf(output,"%d ", I);
            fprintf(output,": LINE %1d \n",I);
            fprintf(output,"Element(Ref)= %d\n",Element(Ref,I));
            PrintAllStrings(stdout);
            return(false);
	 }
   }

   return(true);
}
示例#23
0
boolean 
RPC::Deserializa( TSRIn_CreateCloseDelete *Obj, unsigned char *Buff ) 
{
	Deserializa( &Obj->lSessionObj, Buff);
	Buff += SizeOf(Obj->lSessionObj);
	
	if ( !Deserializa( &Obj->sTicket, Buff) ) 
		return FALSE;
	Buff += SizeOf(Obj->sTicket);

	Deserializa( &Obj->lBaseObj, Buff) ;
	Buff += SizeOf(Obj->lBaseObj);

	if ( !Deserializa( &Obj->szBaseName, Buff ) ) // eh um string; 
		return FALSE;
	Buff += SizeOf(Obj->szBaseName);

	if ( !Deserializa( &Obj->szLongBaseName, Buff ) ) // eh um string; 
		return FALSE;
	Buff += SizeOf(Obj->szLongBaseName);

	if ( !Deserializa( &Obj->szBasePassword, Buff ) ) // eh um string; 
		return FALSE;
	Buff += SizeOf(Obj->szBasePassword);

	if ( !Deserializa( &Obj->szMaintenancePassword, Buff ) ) // eh um string; 
		return FALSE;
	Buff += SizeOf(Obj->szMaintenancePassword);

	Deserializa( &Obj->bBaseType, Buff ); 
	Buff += SizeOf(Obj->bBaseType);

	Deserializa( &Obj->bIsCrypto, Buff ); 
	Buff += SizeOf(Obj->bIsCrypto);

	if ( !Deserializa( &Obj->szUserBaseName, Buff ) ) // eh um string; 
		return FALSE;
	Buff += SizeOf(Obj->szUserBaseName);

	Deserializa( &Obj->lTam, Buff ); 
	Buff += SizeOf(Obj->lTam);

	if ( !Deserializa( &Obj->szBuffer, Buff, Obj->lTam) ) // nao eh um string; 
		return FALSE;
	Buff += Obj->lTam;
	
	Deserializa( &Obj->lSlotNum, Buff ); 
	Buff += SizeOf(Obj->lSlotNum);

	Deserializa( &Obj->lCountNum, Buff ); 
	Buff += SizeOf(Obj->lCountNum);

	Deserializa( &Obj->lMaxKeySize, Buff ); 
	Buff += SizeOf(Obj->lMaxKeySize);

	if ( !Deserializa( &Obj->szFileName, Buff ) ) // eh um string
		return FALSE;
	Buff += SizeOf(Obj->szFileName);

	Deserializa( &Obj->sCtrlInfo, Buff);
	Buff += SizeOf(Obj->sCtrlInfo);
	
	return(TRUE);
}
示例#24
0
void 
RPC::Serializa( TSRIn_CreateCloseDelete Obj, unsigned char *Buff ) 
{
	Serializa( Obj.lSessionObj, Buff);
	Buff += SizeOf(Obj.lSessionObj);
	
	Serializa( Obj.sTicket, Buff); 
	Buff += SizeOf(Obj.sTicket);

	Serializa( Obj.lBaseObj, Buff) ;
	Buff += SizeOf(Obj.lBaseObj);

	Serializa( Obj.szBaseName, Buff ); // eh um string; 
	Buff += SizeOf(Obj.szBaseName);

	Serializa( Obj.szLongBaseName, Buff ); // eh um string; 
	Buff += SizeOf(Obj.szLongBaseName);

	Serializa( Obj.szBasePassword, Buff ); // eh um string; 
	Buff += SizeOf(Obj.szBasePassword);

	Serializa( Obj.szMaintenancePassword, Buff ); // eh um string; 
	Buff += SizeOf(Obj.szMaintenancePassword);

	Serializa( Obj.bBaseType, Buff ); 
	Buff += SizeOf(Obj.bBaseType);

	Serializa( Obj.bIsCrypto, Buff ); 
	Buff += SizeOf(Obj.bIsCrypto);

	Serializa( Obj.szUserBaseName, Buff ); // eh um string; 
	Buff += SizeOf(Obj.szUserBaseName);

	Serializa( Obj.lTam, Buff ); 
	Buff += SizeOf(Obj.lTam);

	Serializa( Obj.szBuffer, Buff, Obj.lTam); // nao eh um string; 
	Buff += Obj.lTam;
	
	Serializa( Obj.lSlotNum, Buff ); 
	Buff += SizeOf(Obj.lSlotNum);

	Serializa( Obj.lCountNum, Buff ); 
	Buff += SizeOf(Obj.lCountNum);

	Serializa( Obj.lMaxKeySize, Buff ); 
	Buff += SizeOf(Obj.lMaxKeySize);

	Serializa( Obj.szFileName, Buff ); // eh um string
	Buff += SizeOf(Obj.szFileName);

	Serializa( Obj.sCtrlInfo, Buff);
	Buff += SizeOf(Obj.sCtrlInfo);
}
示例#25
0
int DataType::sizeInBytes() const
{
	return componentCount() * SizeOf(m_PrimitiveDataType);
}
示例#26
0
void 
RPC::Serializa ( long *Obj, unsigned char *Buff, long lNumElem)
{
	long lTam = SizeOf( Obj, lNumElem);
	memcpy( Buff, Obj, lTam );
}
示例#27
0
        ATI_OPTION_SWCURSOR,
        "sw_cursor",
        OPTV_BOOLEAN,
        {0, },
        FALSE,
    },
    {
        -1,
        NULL,
        OPTV_NONE,
        {0, },
        FALSE
    }
};

const unsigned long ATIPublicOptionSize = SizeOf(ATIPublicOptions);

/*
 * ATIAvailableOptions --
 *
 * Return recognised options that are intended for public consumption.
 */
const OptionInfoRec *
ATIAvailableOptions
(
    int ChipId,
    int BusId
)
{
    const OptionInfoRec *pOptions;
示例#28
0
//
//	Estrutura sem ponteiros; serializacao trivial.
//
void 
RPC::Serializa ( TSRGenericObj Obj, unsigned char *Buff )
{
	memcpy(Buff, &Obj, SizeOf(Obj));
}
示例#29
0
void SwitchStatement (void)
/* Handle a switch statement for chars with a cmp cascade for the selector */
{
    ExprDesc    SwitchExpr;     /* Switch statement expression */
    CodeMark    CaseCodeStart;  /* Start of code marker */
    CodeMark    SwitchCodeStart;/* Start of switch code */
    CodeMark    SwitchCodeEnd;  /* End of switch code */
    unsigned    ExitLabel;      /* Exit label */
    unsigned    SwitchCodeLabel;/* Label for the switch code */
    int         HaveBreak = 0;  /* True if the last statement had a break */
    int         RCurlyBrace;    /* True if last token is right curly brace */
    SwitchCtrl* OldSwitch;      /* Pointer to old switch control data */
    SwitchCtrl  SwitchData;     /* New switch data */


    /* Eat the "switch" token */
    NextToken ();

    /* Read the switch expression and load it into the primary. It must have
     * integer type.
     */
    ConsumeLParen ();
    Expression0 (&SwitchExpr);
    if (!IsClassInt (SwitchExpr.Type))  {
        Error ("Switch quantity is not an integer");
        /* To avoid any compiler errors, make the expression a valid int */
        ED_MakeConstAbsInt (&SwitchExpr, 1);
    }
    ConsumeRParen ();

    /* Add a jump to the switch code. This jump is usually unnecessary,
     * because the switch code will moved up just behind the switch
     * expression. However, in rare cases, there's a label at the end of
     * the switch expression. This label will not get moved, so the code
     * jumps around the switch code, and after moving the switch code,
     * things look really weird. If we add a jump here, we will never have
     * a label attached to the current code position, and the jump itself
     * will get removed by the optimizer if it is unnecessary.
     */
    SwitchCodeLabel = GetLocalLabel ();
    g_jump (SwitchCodeLabel);

    /* Remember the current code position. We will move the switch code
     * to this position later.
     */
    GetCodePos (&CaseCodeStart);

    /* Setup the control structure, save the old and activate the new one */
    SwitchData.Nodes        = NewCollection ();
    SwitchData.ExprType     = UnqualifiedType (SwitchExpr.Type[0].C);
    SwitchData.Depth        = SizeOf (SwitchExpr.Type);
    SwitchData.DefaultLabel = 0;
    OldSwitch = Switch;
    Switch = &SwitchData;

    /* Get the exit label for the switch statement */
    ExitLabel = GetLocalLabel ();

    /* Create a loop so we may use break. */
    AddLoop (ExitLabel, 0);

    /* Make sure a curly brace follows */
    if (CurTok.Tok != TOK_LCURLY) {
        Error ("`{' expected");
    }

    /* Parse the following statement, which will actually be a compound
     * statement because of the curly brace at the current input position
     */
    HaveBreak = Statement (&RCurlyBrace);

    /* Check if we had any labels */
    if (CollCount (SwitchData.Nodes) == 0 && SwitchData.DefaultLabel == 0) {
        Warning ("No case labels");
    }

    /* If the last statement did not have a break, we may have an open
     * label (maybe from an if or similar). Emitting code and then moving
     * this code to the top will also move the label to the top which is
     * wrong. So if the last statement did not have a break (which would
     * carry the label), add a jump to the exit. If it is useless, the
     * optimizer will remove it later.
     */
    if (!HaveBreak) {
        g_jump (ExitLabel);
    }

    /* Remember the current position */
    GetCodePos (&SwitchCodeStart);

    /* Output the switch code label */
    g_defcodelabel (SwitchCodeLabel);

    /* Generate code */
    if (SwitchData.DefaultLabel == 0) {
        /* No default label, use switch exit */
        SwitchData.DefaultLabel = ExitLabel;
    }
    g_switch (SwitchData.Nodes, SwitchData.DefaultLabel, SwitchData.Depth);

    /* Move the code to the front */
    GetCodePos (&SwitchCodeEnd);
    MoveCode (&SwitchCodeStart, &SwitchCodeEnd, &CaseCodeStart);

    /* Define the exit label */
    g_defcodelabel (ExitLabel);

    /* Exit the loop */
    DelLoop ();

    /* Switch back to the enclosing switch statement if any */
    Switch = OldSwitch;

    /* Free the case value tree */
    FreeCaseNodeColl (SwitchData.Nodes);

    /* If the case statement was (correctly) terminated by a closing curly
     * brace, skip it now.
     */
    if (RCurlyBrace) {
        NextToken ();
    }
}
示例#30
0
//
//	Estrutura sem ponteiros; serializacao trivial.
//
void 
RPC::Serializa ( TSRControlInfo Obj, unsigned char *Buff )
{
	memcpy(Buff, &Obj, SizeOf(Obj));
}