// sender uses the function
int send_file(int sock, struct sockaddr_in *recv_adr, char *filename, akh_disconn_response *disconn_response)
{
    uint32_t seg_size = disconn_response->segment_size;
    uint32_t req_num = disconn_response->segment_num;
    uint32_t *seg_list = disconn_response->segment_list;
    uint32_t seg_num;

    akh_pdu_header header;
    char buf[MAX_BUFFER_SIZE];
    packet pac;
    size_t buf_len, pac_len;

    int i;
    for(i = 0; i < req_num; i++) {
        seg_num = seg_list[i];
        header = createHeader(SS, seg_num);
        buf_len = read_segment(buf, seg_size, seg_num, filename);
        pac_len = createPacket(&pac, &header, buf, buf_len);
        sendto(sock, pac, pac_len, 0, (struct sockaddr *)recv_adr, sizeof(*recv_adr));

        deletePacket(pac);

        puts("< send file segment >");
        displayHeader(header);
    }
    return 0;
}
void HomeScreen::display() {
  lcd.clear();
  lcd.noBlink();
  lcd.noCursor();
  displayHeader();
  displayDateTime();
  displayTemp();
}
Exemple #3
0
FABRIC_NPAPI_EXPORT NPError OSCALL NP_Initialize(NPNetscapeFuncs* browser_functions)
{
  displayHeader();
  llvmInitialize();
  extern void InitializeBrowserFunctions(NPNetscapeFuncs* browser_functions);
  InitializeBrowserFunctions(browser_functions);
  return NPERR_NO_ERROR;
}
Exemple #4
0
FABRIC_NPAPI_EXPORT NPError OSCALL NP_Initialize(NPNetscapeFuncs* browser_functions)
{
  displayHeader();
  FABRIC_DEBUG_LOG( "Debug with: gdb --pid=%d", getpid() );
  llvmInitialize();
  extern void InitializeBrowserFunctions(NPNetscapeFuncs* browser_functions);
  InitializeBrowserFunctions(browser_functions);
  return NPERR_NO_ERROR;
}
Exemple #5
0
// "loadHeader()": load header info into member variable
void niftiManager::loadHeader( const std::string& imageFilename, bool display )
{
    m_header = readHeader( imageFilename );
    if( display )
    {
        displayHeader();
    }
    return;
}// end niftiManager::loadHeader() -----------------------------------------------------------------
Exemple #6
0
FABRIC_NPAPI_EXPORT NPError OSCALL NP_Initialize(NPNetscapeFuncs* browser_functions,
                      NPPluginFuncs* plugin_functions)
{
  displayHeader();
  FABRIC_DEBUG_LOG( "Debug with: gdb --pid=%d", getpid() );
  llvmInitialize();
  extern void InitializeBrowserFunctions(NPNetscapeFuncs* browser_functions);
  InitializeBrowserFunctions(browser_functions);
  NPError np_err = NP_GetEntryPoints(plugin_functions);
  return np_err;
}
void uw_htmloutput(FILE *outP, GAME_AREA *ga, char ** inv, int inc, int is_interactive, int has_table, int init)
{
	if((trxFp = fopen(TRAXSKELFILE, "r")) == NULL)
		exit(4);

	if (is_interactive)
		fprintf(outP, "Content-Type: text/html\n\n");

	writeSkeleton(outP);
	displayTitle(outP, init);
	writeSkeleton(outP);
	displayHeader(outP, init);
	writeSkeleton(outP);
	displayMoves(outP, inv, inc, has_table, init);
	writeSkeleton(outP);
	displayBoard(outP, ga, has_table);
	writeSkeleton(outP);
	displayForm(outP, inv, inc, has_table, init);
	writeSkeleton(outP);

	fclose(trxFp);
	trxFp = NULL;
}
Exemple #8
0
AbstractQgarError::AbstractQgarError(const char* anErrorKind,
				     const char* aFileName,
				     int aLineNb,
				     const char* aFuncProfile,
				     const string aDiagnostic)
{
  if(msgFlag_)
    {
      displayHeader(anErrorKind);
      cerr << "Line "
	   << aLineNb
	   << " in file: "
	   << aFileName
	   << endl
	   << "Function: "
	   << aFuncProfile
	   << endl
	   << ">>> "
	   << aDiagnostic
	   << endl
	   << endl;
    }
}
Exemple #9
0
/*
  main function
*/
int main(int argc, char * argv[])
{
  
  // stime and utime are always displayed
  int state_flag = 0;
  int utime_flag = 1;
  int stime_flag = 1;
  int size_flag = 0;
  int cmdline_flag = 1;

  
  // check if pid prsent
  if ( (argc > 1) && (!strcmp(argv[1], "-p"))){
    
    // set pid as given pid number
    char *pid;
    pid = (char*) malloc(10* sizeof(char));
    strcpy(pid, argv[2]);
    
    system("ls /proc >> tmp_proc");

    
    // Open the file for reading
    FILE *fd;
    int pid_flag;
    char str[100];    
    fd = fopen ("tmp_proc", "r");
    // Read till end of file list and check if pid exists
    pid_flag = 0;
    while( fscanf(fd, "%s", str) != EOF)
      if (!strcmp(pid, str))
	pid_flag = 1;

    // close & delete temporary files
    fclose(fd);
    system("rm tmp_proc");

    // check if any flags are present
    if (pid_flag == 1){
      if (argc > 3){
	int x = 3;
	while (x < argc){
	  if (!strcmp(argv[x], "-s"))
	    state_flag = 1;

	  else if (!strcmp(argv[x], "-v"))
	    size_flag = 1;
	  x++;
	}

	// display information and header
	displayHeader(state_flag, utime_flag, stime_flag, size_flag, cmdline_flag);
	displayInfo(pid, state_flag, utime_flag, stime_flag, size_flag, cmdline_flag);
      
      }

      // no flags -- only show utime, stime and cmdline
      else{
	displayHeader(state_flag, utime_flag, stime_flag, size_flag, cmdline_flag);
	displayInfo(pid, state_flag, utime_flag, stime_flag, size_flag, cmdline_flag);
      

      }
    }
  }

  // display all process id's
  else{

    // get current user's id
    char curUid[15];
    sprintf(curUid, "%d", getuid());

    
    //set flags if there are any that are present
    if (argc > 1){
      int x = 1;
      while (x < argc){
	if (!strcmp(argv[x], "-s"))
	  state_flag = 1;

	else if (!strcmp(argv[x], "-v"))
	  size_flag = 1;
	x++;
      }
      }

    displayHeader(state_flag, utime_flag, stime_flag, size_flag, cmdline_flag);

    // open proc directory
    DIR * dir;
    struct dirent *  entry;
    char str2[100];
    int is_userproc = 0;
    if ( (dir = opendir("/proc")) != NULL){
      while ( (entry = readdir(dir)) != NULL){
	strcpy(str2, entry-> d_name);
	// display only numerical titles that belong to user
	if (('0' <= str2[0]) && (str2[0] <= '9')){
	  // check if pid is user's
	  is_userproc = checkUserProc(str2, curUid); 
	  if ( is_userproc == 1 ){
	    displayInfo(str2, state_flag, utime_flag, stime_flag, size_flag, cmdline_flag);

	  }
	}
      }
    }

  }

  return 0;
}
Exemple #10
0
void displayManagement(MsgHeader *header, MsgManagement *manage)
{
  Integer16 i;
  
  switch(manage->managementMessageKey)
  {
  case PTP_MM_CLOCK_IDENTITY:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (PTP_MM_CLOCK_IDENTITY)\n", manage->managementMessageKey);
    printf("  clockCommunicationTechnology %hhu\n", manage->payload.clockIdentity.clockCommunicationTechnology);
    printf("  clockUuidField %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      manage->payload.clockIdentity.clockUuidField[0], manage->payload.clockIdentity.clockUuidField[1],
      manage->payload.clockIdentity.clockUuidField[2], manage->payload.clockIdentity.clockUuidField[3],
      manage->payload.clockIdentity.clockUuidField[4], manage->payload.clockIdentity.clockUuidField[5]);
    printf("  clockPortField %hu\n", manage->payload.clockIdentity.clockPortField);
    printf("  manufacturerIdentity ");
    for(i = 0; i < MANUFACTURER_ID_LENGTH && manage->payload.clockIdentity.manufacturerIdentity[i]; ++i)
      putchar(manage->payload.clockIdentity.manufacturerIdentity[i]);
    putchar('\n');
    break;
    
  case PTP_MM_DEFAULT_DATA_SET:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (PTP_MM_DEFAULT_DATA_SET)\n", manage->managementMessageKey);
    printf("  clockCommunicationTechnology %hhu\n", manage->payload.defaultData.clockCommunicationTechnology);
    printf("  clockUuidField %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      manage->payload.defaultData.clockUuidField[0], manage->payload.defaultData.clockUuidField[1],
      manage->payload.defaultData.clockUuidField[2], manage->payload.defaultData.clockUuidField[3],
      manage->payload.defaultData.clockUuidField[4], manage->payload.defaultData.clockUuidField[5]);
    printf("  clockPortField %hu\n", manage->payload.defaultData.clockPortField);
    printf("  clockStratum %hhu\n", manage->payload.defaultData.clockStratum);
    printf("  clockIdentifier ");
    for(i = 0; i < PTP_CODE_STRING_LENGTH && manage->payload.defaultData.clockIdentifier[i]; ++i)
      putchar(manage->payload.defaultData.clockIdentifier[i]);
    putchar('\n');
    printf("  clockVariance %hd\n", manage->payload.defaultData.clockVariance);
    printf("  clockFollowupCapable %hhu\n", manage->payload.defaultData.clockFollowupCapable);
    printf("  preferred %hhu\n", manage->payload.defaultData.preferred);
    printf("  initializable %hhu\n", manage->payload.defaultData.initializable);
    printf("  externalTiming %hhu\n", manage->payload.defaultData.externalTiming);
    printf("  isBoundaryClock %hhu\n", manage->payload.defaultData.isBoundaryClock);
    printf("  syncInterval %hhd\n", manage->payload.defaultData.syncInterval);
    printf("  subdomainName ");
    for(i = 0; i < PTP_SUBDOMAIN_NAME_LENGTH && manage->payload.defaultData.subdomainName[i]; ++i)
      putchar(manage->payload.defaultData.subdomainName[i]);
    putchar('\n');
    printf("  numberPorts %hu\n", manage->payload.defaultData.numberPorts);
    printf("  numberForeignRecords %hu\n", manage->payload.defaultData.numberForeignRecords);
    break;
    
  case PTP_MM_CURRENT_DATA_SET:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (PTP_MM_CURRENT_DATA_SET)\n", manage->managementMessageKey);
    printf("  stepsRemoved %hu\n", manage->payload.current.stepsRemoved);
    printf("  offsetFromMaster %s%u.%09d\n",
      manage->payload.current.offsetFromMaster.nanoseconds & 0x80000000 ? "-" : "",
      manage->payload.current.offsetFromMaster.seconds,
      manage->payload.current.offsetFromMaster.nanoseconds & ~0x80000000);
    printf("  oneWayDelay %s%u.%09d\n",
      manage->payload.current.oneWayDelay.nanoseconds & 0x80000000 ? "-" : "",
      manage->payload.current.oneWayDelay.seconds,
      manage->payload.current.oneWayDelay.nanoseconds & ~0x80000000);
    break;
    
  case PTP_MM_PARENT_DATA_SET:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (PTP_MM_PARENT_DATA_SET)\n", manage->managementMessageKey);
    printf("  parentCommunicationTechnology %hhu\n", manage->payload.parent.parentCommunicationTechnology);
    printf("  parentUuid %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      manage->payload.parent.parentUuid[0], manage->payload.parent.parentUuid[1],
      manage->payload.parent.parentUuid[2], manage->payload.parent.parentUuid[3],
      manage->payload.parent.parentUuid[4], manage->payload.parent.parentUuid[5]);
    printf("  parentPortId %hu\n", manage->payload.parent.parentPortId);
    printf("  parentLastSyncSequenceNumber %hu\n", manage->payload.parent.parentLastSyncSequenceNumber);
    printf("  parentFollowupCapable %hhu\n", manage->payload.parent.parentFollowupCapable);
    printf("  parentExternalTiming %hhu\n", manage->payload.parent.parentExternalTiming);
    printf("  parentVariance %hd\n", manage->payload.parent.parentVariance);
    printf("  parentStats %hhu\n", manage->payload.parent.parentStats);
    printf("  observedVariance %hd\n", manage->payload.parent.observedVariance);
    printf("  observedDrift %d\n", manage->payload.parent.observedDrift);
    printf("  utcReasonable %hhu\n", manage->payload.parent.utcReasonable);
    printf("  grandmasterCommunicationTechnology %hhu\n", manage->payload.parent.grandmasterCommunicationTechnology);
    printf("  grandmasterUuidField %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      manage->payload.parent.grandmasterUuidField[0], manage->payload.parent.grandmasterUuidField[1],
      manage->payload.parent.grandmasterUuidField[2], manage->payload.parent.grandmasterUuidField[3],
      manage->payload.parent.grandmasterUuidField[4], manage->payload.parent.grandmasterUuidField[5]);
    printf("  grandmasterPortIdField %hu\n", manage->payload.parent.grandmasterPortIdField);
    printf("  grandmasterStratum %hhu\n", manage->payload.parent.grandmasterStratum);
    printf("  grandmasterIdentifier ");
    for(i = 0; i < PTP_CODE_STRING_LENGTH && manage->payload.parent.grandmasterIdentifier[i]; ++i)
      putchar(manage->payload.parent.grandmasterIdentifier[i]);
    putchar('\n');
    printf("  grandmasterVariance %hd\n", manage->payload.parent.grandmasterVariance);
    printf("  grandmasterPreferred %hhu\n", manage->payload.parent.grandmasterPreferred);
    printf("  grandmasterIsBoundaryClock %hhu\n", manage->payload.parent.grandmasterIsBoundaryClock);
    printf("  grandmasterSequenceNumber %hu\n", manage->payload.parent.grandmasterSequenceNumber);
    break;
    
  case PTP_MM_PORT_DATA_SET:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (PTP_MM_PORT_DATA_SET)\n", manage->managementMessageKey);
    printf("  returnedPortNumber %hu\n", manage->payload.port.returnedPortNumber);
    printf("  portState %hhu\n", manage->payload.port.portState);
    printf("  lastSyncEventSequenceNumber %hu\n", manage->payload.port.lastSyncEventSequenceNumber);
    printf("  lastGeneralEventSequenceNumber %hu\n", manage->payload.port.lastGeneralEventSequenceNumber);
    printf("  portCommunicationTechnology %hhu\n", manage->payload.port.portCommunicationTechnology);
    printf("  portUuidField %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      manage->payload.port.portUuidField[0], manage->payload.port.portUuidField[1],
      manage->payload.port.portUuidField[2], manage->payload.port.portUuidField[3],
      manage->payload.port.portUuidField[4], manage->payload.port.portUuidField[5]);
    printf("  portIdField %hu\n", manage->payload.port.portIdField);
    printf("  burstEnabled %hhu\n", manage->payload.port.burstEnabled);
    printf("  subdomainAddressOctets %hhu\n", manage->payload.port.subdomainAddressOctets);
    printf("  eventPortAddressOctets %hhu\n", manage->payload.port.eventPortAddressOctets);
    printf("  generalPortAddressOctets %hhu\n", manage->payload.port.generalPortAddressOctets);
    printf("  subdomainAddress ");
    printf("%hhu", manage->payload.port.subdomainAddress[0]);
    for(i = 1; i < SUBDOMAIN_ADDRESS_LENGTH; ++i)
      printf(".%hhu", manage->payload.port.subdomainAddress[i]);
    putchar('\n');
    printf("  eventPortAddress %hu\n", *(UInteger16*)manage->payload.port.eventPortAddress);
    printf("  generalPortAddress %hu\n", *(UInteger16*)manage->payload.port.generalPortAddress);
    break;
  
  case PTP_MM_GLOBAL_TIME_DATA_SET:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (PTP_MM_GLOBAL_TIME_DATA_SET)\n", manage->managementMessageKey);
    printf("  localTime %s%u.%09d\n",
      manage->payload.globalTime.localTime.nanoseconds & 0x80000000 ? "-" : "",
      manage->payload.globalTime.localTime.seconds,
      manage->payload.globalTime.localTime.nanoseconds & ~0x80000000);
    printf("  currentUtcOffset %hd\n", manage->payload.globalTime.currentUtcOffset);
    printf("  leap59 %hhu\n", manage->payload.globalTime.leap59);
    printf("  leap61 %hhu\n", manage->payload.globalTime.leap61);
    printf("  epochNumber %hu\n", manage->payload.globalTime.epochNumber);
    break;
    
    
  case PTP_MM_FOREIGN_DATA_SET:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (PTP_MM_FOREIGN_DATA_SET)\n", manage->managementMessageKey);
    printf("  returnedPortNumber %hu\n", manage->payload.foreign.returnedPortNumber);
    printf("  returnedRecordNumber %hu\n", manage->payload.foreign.returnedRecordNumber);
    printf("  foreignMasterCommunicationTechnology %hu\n", manage->payload.foreign.foreignMasterCommunicationTechnology);
    printf("  foreignMasterUuid %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      manage->payload.foreign.foreignMasterUuid[0], manage->payload.foreign.foreignMasterUuid[1],
      manage->payload.foreign.foreignMasterUuid[2], manage->payload.foreign.foreignMasterUuid[3],
      manage->payload.foreign.foreignMasterUuid[4], manage->payload.foreign.foreignMasterUuid[5]);
    
    printf("  foreignMasterPortId %hu\n", manage->payload.foreign.foreignMasterPortId);
    printf("  foreignMasterSyncs %hu\n", manage->payload.foreign.foreignMasterSyncs);
    break;
    
  case PTP_MM_NULL:
    printf("\n");
    displayHeader(header);
    printf("  managementMessageKey %hhu (NULL)\n", manage->managementMessageKey);
    break;
    
  default:
    break;
  }
  
  return;
}
Exemple #11
0
int main(int argc, char** argv) {
   options.setOptions(argc, argv);
   checkOptions(options);

   displayHeader(cout);
   if (fileQ) {
      displayHeader(outputfile);
   }

   KeyboardInput keyboard;     // for typing comments into output file
   char keych;                 // character from keyboard
   MidiMessage message;
   int lastTime = -1;

   midi.open();
   while (1) {
      while (midi.getCount() > 0) {
         message = midi.extract();
         if (echoQ) {
            midi.send(message);
         }

         if ((!activeSensingQ) && (message.p0() == 0xfe)) {
            // don't display incoming active-sensing messages
            continue;
         }

         // filter any specified message types
         if (suppressOffQ && ((message.p0() & 0xf0) == 0x90) &&
               (message.p2() == 0)) {      
            continue;
         } else if (filter[(message.p0() >> 4) - 8]) {
            continue;
         } else if (cfilter[message.p0() & 0x0f]) {
            continue;
         }

         // adjust message time to delta time if necessary
         if (!absoluteQ) {
            if (lastTime == -1) {
               lastTime = message.time;
               message.time = 0;
            } else {
               int temp = message.time;
               message.time = message.time - lastTime;
               lastTime = temp;
            }
         }

         displayMessage(cout, message, style);
         if (fileQ) {
            displayMessage(outputfile, message, style);
         }
      }

      if (keyboardQ && keyboard.hit()) {
         keych = keyboard.getch();
         switch (keych) {
            case 27:                   // escape key 
               if (fileQ && bufferIndex != 0 && bufferIndex < MAX_KEY_BUFF) {
                  inputBuffer[bufferIndex] = '\0';
                  outputfile << inputBuffer;
               }
               keyboard.deinitialize();
               exit(0);      
               break;
            case 0x08:                 // backspace key
            case 0x7f:                 // delete key
               if (bufferIndex > 0) {
                  cout << "\b \b" << flush;
                  bufferIndex--;
               }
               break;
            case 0x0a:                 // enter key only
               #ifdef VISUAL
                  break;
               #endif
            case 13:                   // line feed
               cout << endl;
               if (bufferIndex < MAX_KEY_BUFF) {
                  inputBuffer[bufferIndex] = '\0';
                  if (fileQ) {
                     outputfile << inputBuffer << '\n';
                  }
                  examineInputForCommand(inputBuffer);
               }
               bufferIndex = 0;
               break;
            case 0x0c:                 // ^L key (redraw input)
               cout << endl;
               if (bufferIndex < MAX_KEY_BUFF) {
                  inputBuffer[bufferIndex] = '\0';
                  cout << inputBuffer << flush;
               }
               break;
            default:                   // normal key
               cout << keych << flush;
               if (bufferIndex < MAX_KEY_BUFF) {
                  inputBuffer[bufferIndex++] = keych;
               } else { 
                  // buffer is WAY to long: kill it
                  bufferIndex = 0;
               }
         }
      }

      millisleep(1);   // sleep for 1 millisec for multi-tasking courtesy

   }