当前位置: 首页>>代码示例>>C++>>正文


C++ writeInt函数代码示例

本文整理汇总了C++中writeInt函数的典型用法代码示例。如果您正苦于以下问题:C++ writeInt函数的具体用法?C++ writeInt怎么用?C++ writeInt使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了writeInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

void init(int max_sim_time) {
  
  #ifdef STANDALONE 
    printf(" Initializing TraCI...\n");
  #else
    LOG_N(OMG, " Initializing TraCI...\n");
  #endif
  char *objID = " ";
 // size_t size = strlen(objID);

  int noSubscribedVars = 2;
  writeUnsignedByte(0);
  writeInt(1 + 4 + 1 + 4 + 4 + 4 + (int) strlen(objID) + 1 + noSubscribedVars);
  writeUnsignedByte(CMD_SUBSCRIBE_SIM_VARIABLE); // command id
  writeInt(0); // begin time
  writeInt(max_sim_time*1000); // end time
  writeString(objID); // object id
  writeUnsignedByte(noSubscribedVars); // variable number
  writeUnsignedByte(VAR_DEPARTED_VEHICLES_IDS);
  writeUnsignedByte(VAR_ARRIVED_VEHICLES_IDS);

  // send request message
  sendExact(storageLength(storageStart));
  extractCommandStatus(receiveExact(), CMD_SUBSCRIBE_SIM_VARIABLE, description);
  if (departed == NULL) {
    departed = (string_list*) malloc(sizeof(string_list)); // departed MUST point to HEAD
    departed->string = NULL;
    departed->next = NULL;
  }
  if (arrived == NULL) {
    arrived = (string_list*) malloc(sizeof(string_list));  // arrived MUST point to HEAD
    arrived->string = NULL;
    arrived->next = NULL;
  } 
    
  processSubscriptions();

  reset();
}
开发者ID:mspublic,项目名称:openair4G-mirror,代码行数:39,代码来源:client_traci_OMG.c

示例2: gzgetc_cmd

static TACommandVerdict gzgetc_cmd(TAThread thread,TAInputStream stream)
{
    void* file;
    int res, errnum;

    file = readPointer(&stream);

    START_TARGET_OPERATION(thread);

    res = gzgetc(file);

    END_TARGET_OPERATION(thread);

    gzerror(file, &errnum);

    writeInt(thread, errnum);
    writeInt(thread, res);

    sendResponse(thread);

    return taDefaultVerdict;
}
开发者ID:levenkov,项目名称:olver,代码行数:22,代码来源:compress_agent.c

示例3: memorySnapshot

void memorySnapshot(){
  
  int userMemoryUsage = 0;
  int allocMemoryUsage = 0;
  long long unsigned lastUsedByte = (long long unsigned)memoryAdress;
  long long unsigned firstUsedByte = (long long unsigned)memoryAdress;
  long long unsigned firstBlockByte = (long long unsigned)memoryAdress;
  long long unsigned lastBlockByte = (long long unsigned)memoryAdress;
    
  struct ab* a = headAllocatedB;
  int fd = dataFile;

  while (a!=NULL){
    userMemoryUsage += a->size;
    firstBlockByte = (long long unsigned)a; 
    lastBlockByte = firstBlockByte + a->size + sizeof(struct ab);
    
    if ( firstBlockByte <= firstUsedByte ){
      firstUsedByte = firstUsedByte;
    }
    if ( lastUsedByte <= lastBlockByte ){
      lastUsedByte = lastBlockByte;
    }
    allocMemoryUsage = lastUsedByte - firstUsedByte;
    
    a = a->next;
  }

  writeInt(fd, instant);
  write(fd," ",1);
  writeInt(fd, userMemoryUsage);
  write(fd," ",1);
  writeInt(fd, allocMemoryUsage);
  write(fd,"\n",1);

  instant++;
  return ;

}
开发者ID:Xarfg,项目名称:2,代码行数:39,代码来源:memRoutines.c

示例4: wcsxfrm_cmd

static TACommandVerdict wcsxfrm_cmd(TAThread thread, TAInputStream stream)
{
    wchar_t* ws1;
    wchar_t* ws2;
    wchar_t* xxx = L"";
    size_t n;
    size_t res;
    int save_errno;
    int overflow = 0;
    int i;

    // Prepare
    ws2 = ta_wcsalign(readWString(&stream)); //align on copy
    n = readSize(&stream);
    ws1 = ta_alloc_memory((n + BUFFER_TAIL) * sizeof(wchar_t));
    for (i=0; i<BUFFER_TAIL; ++i)
        ws1[n + i] = (wchar_t)0xDDDDDDDD;

    START_TARGET_OPERATION(thread);

    // Execute
    errno = 0;
    res = wcsxfrm(ws1, ws2, n);
    save_errno = errno;

    END_TARGET_OPERATION(thread);

    for (i=0; i<BUFFER_TAIL; ++i)
        overflow |= (ws1[n + i] != (wchar_t)0xDDDDDDDD);

    if (overflow)
    {
        sendException(thread, "wcsxfrm.02 failed: writing outside of buffer limits occured!");
        return taDefaultVerdict;
    }

    // Response
    if (res >= n)
        writeWString(thread, xxx);
    else
        writeWString(thread, ws1);
    writeSize(thread, res);
    writeInt(thread, save_errno);

    sendResponse(thread);

    ta_dealloc_memory(ws1);
    ta_dealloc_memory(ws2);

    return taDefaultVerdict;
}
开发者ID:levenkov,项目名称:olver,代码行数:51,代码来源:wcollate_agent.c

示例5: main

int main()
{

    int n;
    n=readlong();
    int i,j;

    for(i=2; i<=100; i++)
    {
        number[0][i]=0;
    }

    for(i=1; i<=n; i++)
    {
        int a;
        a=readlong();
        for(j=1; j<=100; j++)
            number[i][j]=number[i-1][j];

        number[i][a]++;
    }

    int t;
    t=readlong();
    int l,r;
    long long MOD;
    while(t--)
    {
        l=readlong();
        r=readlong();
        MOD=readlong();


        long long ans=1;
        if(MOD==1)
            printf("%d\n",0);
        else
        {
            for(i=1; i<=100; i++)
            {
                if(number[r][i]-number[l-1][i])
                {
                    ans=ans*p(i,number[r][i]-number[l-1][i],MOD);
                    ans=ans%MOD;
                }
            }
            writeInt(ans);
        }
    }
    return 0;
}
开发者ID:pawan123kumar,项目名称:Competitive-Programming,代码行数:51,代码来源:CHMOD2.cpp

示例6: clientWalletBalance

/* Display the amount of money stored in the user's cloud provider account. */
int clientWalletBalance(BIO *conn) {
	//send the code which triggers the server to call serverWalletBalance()
	if(writeInt(conn, WALLET_BALANCE_CODE) == -1) return -1;

	//read the balance back from the server
	int balance = readInt(conn);
	if(balance == -1) {
		fprintf(stderr, "Failed to get balance.\n");
		return -1;
	}
	
	printf("You have %d cloud dollars in your cloud wallet.\n", balance);
	return 0;
}
开发者ID:10515255,项目名称:3231,代码行数:15,代码来源:cloudProtocol.c

示例7: getpriority_cmd

static TACommandVerdict getpriority_cmd(TAThread thread,TAInputStream stream)
{
   int which;
   int who  ;
   int res  ;

   // Prepare
   which = readInt( & stream );
   who   = readInt( & stream );
   errno = 0;

   // Execute
   START_TARGET_OPERATION(thread);
   res = getpriority( which, who );
   END_TARGET_OPERATION(thread);

   // Response
   writeInt( thread, res   );
   writeInt( thread, errno );
   sendResponse( thread );

   return taDefaultVerdict;
}
开发者ID:levenkov,项目名称:olver,代码行数:23,代码来源:nice_agent.c

示例8: handleInterrupt21

// interrupt service routine to manage interrupt vector table
void handleInterrupt21(int ax, int bx, int cx, int dx){
  if (ax==0){
    printString(bx);
  }
  else if (ax==1){
    readString(bx);
  }
  else if (ax==2){
    readSector(bx,cx);
  }
  else if (ax==3){
    readFile(bx,cx,dx);
  }
  else if (ax==4){
    runProgram(bx,cx);
  }
  else if (ax==5){
   stop();
  }
  else if (ax==6){
    writeSector(bx,cx);
  }
  else if (ax==7) {
    deleteFile(bx);
  }
  else if (ax==8){
    writeFile(bx,cx,dx);
  }
  else if (ax==11){
    interrupt(25,0,0,0,0);
  }
  else if (ax==12){
    clearScreen(bx,cx);
  }
  else if (ax==13){
    writeInt(bx);
  }
  else if (ax==14){
    ReadInt(bx);
  }
  else if (ax==15){
      error(bx);
  }
  else if (ax==66){
      printChar(bx);
  }
  else {
    printString("Incorrect service call\0");
  }
}
开发者ID:kjedreski,项目名称:OS_Project1,代码行数:51,代码来源:kernel.c

示例9: gzprintf_cmd

static TACommandVerdict gzprintf_cmd(TAThread thread,TAInputStream stream)
{
    void* file;
    char* s;
    int res, errnum;

    file = readPointer(&stream);
    s = readString(&stream);

    START_TARGET_OPERATION(thread);

    res = gzprintf(file, s);

    END_TARGET_OPERATION(thread);

    writeInt(thread, errnum);
    writeInt(thread, errno);
    writeInt(thread, res);

    sendResponse(thread);

    return taDefaultVerdict;
}
开发者ID:levenkov,项目名称:olver,代码行数:23,代码来源:compress_agent.c

示例10: nice_cmd

static TACommandVerdict nice_cmd(TAThread thread,TAInputStream stream)
{
   int incr;
   int res ;

   // ta_debug_printf( "[%3d]", nice( 0 ) );
   // Prepare
   incr = readInt( & stream );
   errno = 0;

   // Execute
   START_TARGET_OPERATION(thread);
   res = nice( incr );
   END_TARGET_OPERATION(thread);

   // ta_debug_printf( "[%3d|%3d|%3d|%3d|%3d|%3d]\n", res, incr, getuid(), geteuid(), getgid(), getegid() );
   // Response
   writeInt( thread, res   );
   writeInt( thread, errno );
   sendResponse( thread );

   return taDefaultVerdict;
}
开发者ID:levenkov,项目名称:olver,代码行数:23,代码来源:nice_agent.c

示例11: MQTTSPacket_send_regAck

int MQTTSPacket_send_regAck(Clients* client, int msgId, int topicId, char returnCode)
{
	MQTTS_RegAck packet;
	int rc = 0;
	char *buf, *ptr;
	int datalen = 5;

	FUNC_ENTRY;
	packet.header.len = 7;
	packet.header.type = MQTTS_REGACK;

	ptr = buf = malloc(datalen);
	writeInt(&ptr, topicId);
	writeInt(&ptr, msgId);
	writeChar(&ptr, returnCode);

	rc = MQTTSPacket_send(client, packet.header, buf, datalen);
	free(buf);

	Log(LOG_PROTOCOL, 52, NULL, client->socket, client->addr, client->clientID, msgId, topicId, returnCode, rc);
	FUNC_EXIT_RC(rc);
	return rc;
}
开发者ID:Frank-KunLi,项目名称:rsmb,代码行数:23,代码来源:MQTTSPacket.c

示例12: writeString

void writeString(char *s)
{
  int count=0;
  char* s_copy=s;

  for(; *s!='\0'; s++)
    count++;

  writeInt(count);

  for(; *s_copy!='\0'; s_copy++)
    writeChar(*s_copy);

}
开发者ID:awesome-security,项目名称:openairinterface5g,代码行数:14,代码来源:storage_traci_OMG.c

示例13: moveBytes

void BPlusTree::insert_in_leaf( TreeNode* L, int key, int rid) {

    BufferManager *bm = BufferManager::getInstance();

    if(key < L->getKey(1)) {
        cout<<"inif2"<<endl;
        //inserting the key-pointer pair at the start of the node
        moveBytes( L->getBuffPage(), 8, 16, (L->getTotalPairs())*8 );
        writeInt( L->getBuffPage(), 0, L->getTotalPairs() + 1 );
        cout<<readInt( L->getBuffPage(), 0)<<endl;
    }
    else {
        cout<<"inelse2"<<endl;
        int totPairs = L->getTotalPairs();
        int i = totPairs;

        //finding the location to insert
        while(key<L->getKey(i)){
            cout<<"inwhile\n";
            i--;
            if(key>L->getKey(i))
                break;
        }
        cout<<"outofwhile\n";
        i++;
        //inserting the key-pointer pair at the correct location
        cout<<i<<" "<<L->getTotalPairs()<<"\n";
        moveBytes( L->getBuffPage(), 16+8*i, 8+8*i, (L->getTotalPairs())-i );
        cout<<"moved\n";
        writeInt( L->getBuffPage(), 8+8*i, rid );
        cout<<"write\n";
        writeInt( L->getBuffPage(), 12+8*i, key );
        cout<<"write1\n";
        writeInt( L->getBuffPage(), 0, L->getTotalPairs() + 1 );
        cout<<"written all data";
    }
}
开发者ID:ankitsingh,项目名称:DBMS,代码行数:37,代码来源:bt.cpp

示例14: getgrent_cmd

static TACommandVerdict getgrent_cmd(TAThread thread,TAInputStream stream)
{
    struct group* result;
    int i=0;
    
    errno = 0;

    START_TARGET_OPERATION_WHICH_MAY_CONTAIN_CANCELPOINT(thread);
    result = getgrent();
    END_TARGET_OPERATION_WHICH_MAY_CONTAIN_CANCELPOINT(thread);
 

    writePointer(thread,(void*)result);
    
    if(result)
    {
        writeString(thread, result->gr_name);
        writeInt(thread, result->gr_gid);
        while ((result->gr_mem)[i]!=NULL)
        {
            i++;
        }
        writeInt(thread, i);
        i=0;
        while ((result->gr_mem)[i]!=NULL)
        {
            writeString(thread, (result->gr_mem)[i]);
            i++;
        }
    } 
    
    writeInt(thread,errno);
    sendResponse(thread);
    
    
    return taDefaultVerdict;
}
开发者ID:levenkov,项目名称:olver,代码行数:37,代码来源:group_agent.c

示例15: setkey_cmd

static TACommandVerdict setkey_cmd(TAThread thread,TAInputStream stream)

{

    char* key;

    int i;

   

    // Prepare

    key=(char*)readPointer(&stream);



    ta_debug_printf("setkey:\n");

    for(i=0;i<64;i++)

        ta_debug_printf("%d ", key[i]);

    ta_debug_printf("\n");



    START_TARGET_OPERATION(thread);

    errno=0;

    setkey(key);

    END_TARGET_OPERATION(thread);

    

    // Response

    writeInt(thread, errno);



    sendResponse(thread);

    

    return taDefaultVerdict;

}
开发者ID:levenkov,项目名称:olver,代码行数:49,代码来源:crypt_agent.c


注:本文中的writeInt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。