void TXslTransform::Transform(TInputStream* src, TOutputStream* dest, const TXslParams& p) {
    TBufferOutput srcbuf;
    TransferData(src, &srcbuf);
    TBuffer result;
    Transform(TDataRegion(~srcbuf.Buffer(), +srcbuf.Buffer()), result, p);
    dest->Write(~result, +result);
}
Beispiel #2
0
static inline void Append(TOutputStream& w, const Stroka& fname, const Stroka& rname) {
    TMappedFileInput in(fname);

    if (!Quiet)
        Cerr << "--> " << rname << Endl;

    TransferData((TInputStream*)&in, &w);
}
Beispiel #3
0
static inline TBlob ConstructFromStream(TInputStream& in) {
    TBuffer buf;

    {
        TBufferOutput out(buf);

        TransferData(&in, &out);
    }

    return ConstructFromBuffer<TCounter>(buf);
}
void TCostTypeDialog::SetupWindow()
{
  TDialog::SetupWindow();

  // INSERT>> Your code here.
  EnableTransfer();
  TransferData(tdSetData);
  //SetInputsState();
  //SetLiteralsState();
  //SetTermsState();
}
Beispiel #5
0
static void UnpackArchive(const Stroka& archive) {
    TBlob blob = TBlob::FromFileContentSingleThreaded(~archive);
    TArchiveReader reader(blob);
    const size_t count = reader.Count();
    for (size_t i = 0; i < count; ++i) {
        const Stroka key = reader.KeyByIndex(i);
        const Stroka fileName = cutFirstSlash(key);
        if (!Quiet)
            Cerr << archive << " --> " << fileName << Endl;
        TAutoPtr<TInputStream> in = reader.ObjectByKey(key);
        TBufferedFileOutput out("./" + fileName);
        TransferData(in.Get(), &out);
        out.Finish();
    }
}
Beispiel #6
0
        inline void Add(const Stroka& key, TInputStream* src) {
            if (Dict_.find(key) != Dict_.end()) {
                ythrow yexception() << "key " <<  ~key << " already stored";
            }

            TLengthCalc out(Out_);
            TZLibCompress compress(&out);

            TransferData(src, &compress);
            compress.Finish();

            TArchiveRecordDescriptorRef descr(new TArchiveRecordDescriptor(Off_, out.Length(), key));

            Dict_[key] = descr;
            Off_ += out.Length();
        }
 xmlNodePtr ConcatTaskToNode(const TXmlConcatTask& task) {
     const xmlChar* nodeName = reinterpret_cast<const xmlChar*>(task.Element.empty() ? "node" : ~task.Element);
     TxmlNodeHolder taskNode(xmlNewNode(NULL, nodeName));
     for (const TSharedPtr<TInputStream>& stream : task.Streams) {
         TBufferOutput out;
         TransferData(stream.Get(), &out);
         TxmlDocHolder document(xmlParseMemory(out.Buffer().Data(), out.Buffer().Size()));
         xmlNodePtr docRoot = xmlDocGetRootElement(document.Get());
         // nobody owns docRoot
         xmlUnlinkNode(docRoot);
         // taskNode owns docRoot
         xmlAddChild(taskNode.Get(), docRoot);
     }
     for (const TXmlConcatTask& childTask : task.Children) {
         xmlNodePtr child = ConcatTaskToNode(childTask);
         xmlAddChild(taskNode.Get(), child);
     }
     return taskNode.Release();
 }
Beispiel #8
0
void main(int argc, char* argv[])
{
 
	char data[256];
	int lRet=0;
	
	char *vbIDEClassName = "ThunderFormDC" ;
	char *vbEXEClassName = "ThunderRT6FormDC" ;
	char *vbWindowCaption = "VB - C InterProcess Communications Using WM_COPYDATA" ;

	if(argc < 2){
		printf("Usage: wmcopy message\n\n");
		return;
	}

	//hServer = (HWND)atoi(argv[1]);
	strcpy(data,argv[1]);
	
	hServer = FindWindowA( vbIDEClassName, vbWindowCaption );

	if(hServer==0){
		hServer = FindWindowA( vbEXEClassName, vbWindowCaption );
	}


	if( IsWindow(hServer) == 0){
		printf("Could not find Window HServer= %x\n",hServer);
		printf("Press any key to continue");
		getch();
		return;
	} 
		
	lRet = TransferData( data , strlen(data) );
	
	printf("Found VB Server Window HWND: %d\n",hServer);
	printf("Message Sent Result: %d\n", lRet);
	printf("Press any key to continue");
	getch();

	return ;

}
Beispiel #9
0
bool RingBuffer::Resize(int newsize)
{
	assert(newsize > 0);
	int oldsize = TotalBufferLen();
	int transfer;

	if (m_bUseOutsideBuf)
		return false;
	if (newsize == oldsize)
		return true;
	else if (newsize < oldsize)
	{
		if (ReadableBufferLen() > newsize)
			return false;
	}

	this->SaveIndexState();

	try
	{
		RingBuffer temp(newsize);
		int u = ReadableBufferLen();
		transfer = TransferData(&temp, u);
		if (transfer == u)
		{
			operator=(std::move(temp));
			return true;
		}
		else
		{
			this->RestoreIndexState();
			return false;
		}
	}
	catch (...)
	{
		this->RestoreIndexState();
	}
	return false;
}
Beispiel #10
0
unsigned int ShmemClientNode(void)
{

    volatile unsigned int *remoteMapAddr1;
    volatile unsigned int *remoteMapAddr2;
    printf("here?\n");

    
    /* Create a segmentId */
    remoteSegmentId1 = 1;//(remoteNodeId1 << 16) | localNodeId1;

    /* Connect to remote segment */

    printf("Connect to remote segment ....  \n");
    printf("segid = %d  node %d \n",remoteSegmentId1, remoteNodeId1 );

     do { 
      SCIConnectSegment(sdOne,
			&remoteSegmentOne,
			remoteNodeId1,
			remoteSegmentId1,
			localAdapterNo,
			NO_CALLBACK,
			NULL,
			SCI_INFINITE_TIMEOUT,
			NO_FLAGS,
			&error);
      
        } while (error != SCI_ERR_OK);


    printf("connected\n");
    
    // remoteSegmentId2 = (remoteNodeId2 << 16) | localNodeId2;
    //  printf("segid = %d\n",remoteSegmentId2 );
    printf("segid = %d  node %d \n",remoteSegmentId1, remoteNodeId1 );
    do { 
      SCIConnectSegment(sdTwo,
			&remoteSegmentTwo,
			remoteNodeId2,
			remoteSegmentId1,
			standbyAdapterNo,
			NO_CALLBACK,
			NULL,
			SCI_INFINITE_TIMEOUT,
			NO_FLAGS,
			&error);
      
    } while (error != SCI_ERR_OK);
    
   

    printf("connected 3\n");
    printf("Remote segment (id=0x%x) is connected.\n", remoteSegmentId2);


	/* Map remote segment to user space */
    remoteMapAddr1 = (unsigned int*)SCIMapRemoteSegment(remoteSegmentOne,&remoteMapOne,offset,segmentSize,NULL,NO_FLAGS,&error);
    if (error == SCI_ERR_OK) {
        printf("Remote segment (id=0x%x) is mapped to user space @ 0x%x. \n", remoteSegmentId1, remoteMapAddr1);         
    } else {
        fprintf(stderr,"SCIMapRemoteSegment failed - Error code 0x%x\n",error);
        return 0;
    } 

    remoteMapAddr2 = (unsigned int *)SCIMapRemoteSegment(remoteSegmentTwo,&remoteMapTwo,offset,segmentSize,NULL,NO_FLAGS,&error);
    if (error == SCI_ERR_OK) {
      printf("Remote segment (id=0x%x) is mapped to user space @ 0x%x. \n", remoteSegmentId2, remoteMapAddr2);         
    } else {
        fprintf(stderr,"SCIMapRemoteSegment failed - Error code 0x%x\n",error);
        return 0;
    } 

        
    /* Start data transfer and error checking */
    error = (sci_error_t)TransferData(remoteMapOne,remoteMapAddr1, remoteMapAddr2,segmentSize);
    if (error == SCI_ERR_OK) {
        printf("Data transfer done!\n\n");
    } else {
        fprintf(stderr,"Data transfer failed - Error code 0x%x\n\n",error);
        return 0;
    }

    /* Send an interrupt to remote node telling that the data transfer is ready */
    error = SendInterrupt(sdOne,localAdapterNo,localNodeId1,remoteNodeId1, DATA_TRANSFER_READY);
    if (error == SCI_ERR_OK) {
        printf("\nInterrupt message sent to remote node\n");
    } else {
        printf("\nInterrupt synchronization failed\n");
        return 0;
    }
    
    PrintClientData();

    /* Unmap remote segment */
    SCIUnmapSegment(remoteMapOne,NO_FLAGS,&error);
    if (error == SCI_ERR_OK) {
       	printf("The remote segment is unmapped\n"); 
    } else {
        fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error);
        return 0;
    }
    
    SCIUnmapSegment(remoteMapTwo,NO_FLAGS,&error);
    if (error == SCI_ERR_OK) {
      printf("The remote segment is unmapped\n"); 
    } else {
      fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error);
      return 0;
    }
    /* Disconnect segment */
    SCIDisconnectSegment(remoteSegmentOne,NO_FLAGS,&error);
    if (error == SCI_ERR_OK) {
       	printf("The segment is disconnected\n"); 
    } else {
        fprintf(stderr,"SCIDisconnectSegment failed - Error code 0x%x\n",error);
        return 0;
    } 
    
    SCIDisconnectSegment(remoteSegmentTwo,NO_FLAGS,&error);
    if (error == SCI_ERR_OK) {
       	printf("The segment is disconnected\n"); 
    } else {
        fprintf(stderr,"SCIDisconnectSegment failed - Error code 0x%x\n",error);
        return 0;
    } 


    return 1;
}
Beispiel #11
0
unsigned SendFax(char *name) {
	int             first;
	char            mbuf[4];
	unsigned	    count;
	B3_PROTO_FAXG3  B3conf;
	FILE	    *f;

	first = 1;
	reason = reason_b3 = 0;
	if (!strcmp(name, "-"))
		f = stdin;
	else
		f = fopen(name, "rb");
	if (!f) {
		perror(name);
		exit(errno);
	}
	fread(mbuf, 4, 1, f);

	InitQueue();
	SetupB3Config(&B3conf,
		(strncmp(mbuf, "Sfff", 4)) ? FAX_ASCII_FORMAT:FAX_SFF_FORMAT);
	if (Slot != INVALID_CONNECTION_ID) {
		fprintf(stderr, "Connection is already in use\n");
		fclose(f);
		return 0xFFFF;
	}
	Connect(&Slot, CalledPartyNumber, CallingPartyNumber, SPEECH,
		B1PROTOCOL, B2PROTOCOL, B3PROTOCOL, (unsigned char *)&B3conf);
	do {
		Handle_CAPI_Msg();
		if (Slot == INVALID_CONNECTION_ID) {
			fclose(f);
			return 2;
		}
	} while (GetState(Slot) != Connected);
	FileTransfer = TRUE;
	while (!feof(f)) {
		if (Queue.Fill < 7) {
			/* max. 7 outstanding blocks supported by CAPI */
			if (first) {
				memcpy(&(Queue.Element[Queue.Head].DATA[0]), mbuf, 4);
				count = fread(&(Queue.Element[Queue.Head].DATA[4]), 1,
					SendBlockSize - 4, f);
			} else
				count = fread(&(Queue.Element[Queue.Head].DATA[0]), 1,
					SendBlockSize, f);
			if (count > 0) {
				if (first)
					count += 4;
				Queue.Element[Queue.Head].DATA_LENGTH = (unsigned short)count;
				if (++Queue.Head >= QueueSize)
					Queue.Head = 0;
				Queue.Fill++;
			}
			first = 0;
		}
		if (GetState(Slot) != Connected)
			break;
		TransferData();
		Handle_CAPI_Msg();
	}
	Disconnect_h(Slot);
	while ((Slot != INVALID_CONNECTION_ID) &&
		(GetState(Slot) != Disconnected))
		Handle_CAPI_Msg();
	FileTransfer = FALSE;
	fclose(f);
	switch (reason) {
		case 0x3490: /* Normal call clearing */
		case 0x349f: /* Normal, unspecified */
			return reason_b3;
		default:
			return reason;
	}
	return 0;
}
Beispiel #12
0
void TSetupDialog::CloseWindow()
{
  TransferData();
  TDialog::CloseWindow();
}
Beispiel #13
0
 inline void FlushImpl() {
     if (Out_.Avail()) {
         TransferData(CheckedCast<IZeroCopyInput*>(&Out_), Slave_);
         Out_.Reset(0, 0);
     }
 }
Beispiel #14
0
ServerPanel::ServerPanel(QObject* cParent) : QObject(cParent), mOk(true) {
    // Load the configuration
    this->mConfig = new QSettings(":/ServerPanel.ini", QSettings::IniFormat);
    // Setup the databae
    this->mDbc    = QSqlDatabase::addDatabase("QSQLITE");
    // Set the database
    this->mDbc.setDatabaseName("/Users/trbrown/Documents/ServerPanel/ServerPanelClient/ServerPanelClient.sp");
    // Try to open the database
    if (!this->mDbc.open()) {
        // Dispatch a message
        this->DispatchMessageBox(this->mDbc.lastError().text(), Error);
    }
    // Create the client
    this->mClient = new QTcpSocket(this);
    // Setup the connectors
    this->connect(this->mClient, SIGNAL(connected()),                         this, SLOT(TransferData()));
    this->connect(this->mClient, SIGNAL(disconnected()),                      this, SLOT(ProcessResponse()));
    this->connect(this->mClient, SIGNAL(readyRead()),                         this, SLOT(ReadResponse()));
    this->connect(this->mClient, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(SocketError(QAbstractSocket::SocketError)));
}