コード例 #1
0
ファイル: entry.cpp プロジェクト: KDE/kiten
/* Prepares Readings for output as HTML */
inline QString Entry::HTMLReadings() const
{
  QStringList list;
  foreach( const QString &it, Readings )
  {
    list += makeLink( it );
  }
コード例 #2
0
ファイル: Playbackd.c プロジェクト: sylarcp/anitaFlightSoft
void encodeAndWriteEvent(AnitaEventHeader_t *hdPtr,
			 PedSubbedEventBody_t *psbPtr,
			 int pri)
{
    memset(outputBuffer,0,MAX_WAVE_BUFFER);
    EncodeControlStruct_t telemEncCntl;
    int surf,chan;
    int retVal,numBytes;
    for(surf=0;surf<ACTIVE_SURFS;surf++) {
	for(chan=0;chan<CHANNELS_PER_SURF;chan++) {
	    telemEncCntl.encTypes[surf][chan]=ENCODE_LOSSLESS_BINFIB_COMBO;
	    if(chan==8)
		telemEncCntl.encTypes[surf][chan]=ENCODE_LOSSY_MULAW_6BIT;
	}
    }
    	    
    retVal=packPedSubbedEvent(psbPtr,&telemEncCntl,outputBuffer,&numBytes);
    printf("retVal %d, numBytes %d\n",retVal,numBytes);
    char headName[FILENAME_MAX];
    char bodyName[FILENAME_MAX];
    sprintf(bodyName,"%s/ev_%u.dat",eventTelemDirs[pri],hdPtr->eventNumber);
    sprintf(headName,"%s/hd_%u.dat",eventTelemDirs[pri],hdPtr->eventNumber);
    retVal=normalSingleWrite((unsigned char*)outputBuffer,bodyName,numBytes);
    if(retVal<0) {
	printf("Something wrong while writing %s\n",bodyName);
    }
    else {
      writeStruct(hdPtr,headName,sizeof(AnitaEventHeader_t));
      makeLink(headName,eventTelemLinkDirs[pri]);
      fprintf(stderr,"Think I did it\n");
    } 
}
コード例 #3
0
ファイル: fileWriterUtil.c プロジェクト: clark2668/AraRoot
int newWriterFile(ARAWriterStruct_t* writer){
  struct timeval timeStruct;
  if( writer->currentFilePtr ){
    gzclose(writer->currentFilePtr);
    if( writer->linkDir)
      makeLink(writer->currentFileName,writer->linkDir);
  }
  if(writer->fileCount >= writer->maxFiles ){
    int retVal = newWriterSubDir(writer);
    if( retVal ){
      fprintf(stderr,"Failed to make new sub directory needed for new file");
      return retVal;
    }
    writer->fileCount = 0;
  }
//ARA_LOG_MESSAGE(LOG_INFO,"Hello 1 -- %s",writer->filePrefix);
  gettimeofday(&timeStruct,NULL);
  (writer->startTime).tv_sec  = timeStruct.tv_sec;
  (writer->startTime).tv_usec = timeStruct.tv_usec;
//ARA_LOG_MESSAGE(LOG_INFO,"Hello 2 -- %s",writer->filePrefix);
  sprintf(writer->currentFileName,"%s/%s_%u.%06u.run%6.6d.dat",
	  writer->currentSubDirName,writer->filePrefix,
	  (unsigned int) writer->startTime.tv_sec,(unsigned int) writer->startTime.tv_usec,
	  writer->currentRunNumber
	  );
//ARA_LOG_MESSAGE(LOG_INFO,"Hello 3 -- %s",writer->filePrefix);
  writer->currentFilePtr = gzopen(writer->currentFileName,writer->compressionLevel);
  if( !writer->currentFilePtr ){
    fprintf(stderr,"Failed to open file %s:\t%s",writer->currentFileName,strerror(errno));
    return errno;
  }
  writer->fileCount++;
//ARA_LOG_MESSAGE(LOG_INFO,"Hello 4 -- %s",writer->filePrefix);
  return 0;
}
コード例 #4
0
ファイル: sharePtr2.cpp プロジェクト: dimpleok/sample4c-11
int main()
{
    std::vector<std::string> v;
    v.push_back("hello");
    v.push_back("world");
    v.push_back("man");
    std::shared_ptr<Node<std::string>> head = makeLink(v);
    std::cout << head->next->value << std::endl;
    return 0;
}
コード例 #5
0
ファイル: fileWriterUtil.c プロジェクト: clark2668/AraRoot
void closeWriter(ARAWriterStruct_t* writer){
  if( writer->currentFilePtr ){
    gzflush(writer->currentFilePtr,Z_FINISH);
    gzclose(writer->currentFilePtr);
    if( writer->linkDir )
      makeLink(writer->currentFileName,writer->linkDir);
    // This forces new file if writer is used again
    writer->writeCount = writer->maxEvents;
    writer->currentFilePtr = 0;
  }
}
コード例 #6
0
void vgPrepImage(char *sourceDir, char *thumbDir, char *fullDir, char *fileName)
/* vgPrepImage - Create thumbnail and image pyramid scheme for image, 
 * also link in full sized image. */
{
char source[PATH_LEN], thumb[PATH_LEN], full[PATH_LEN], pyramid[PATH_LEN];
char outFullDir[PATH_LEN],  outFullRoot[PATH_LEN]; 
int nWidth, nHeight;
int quality[7];
boolean makeFullSize = FALSE;
unsigned char *(*readScanline)() = NULL;

/* Figure out full paths. */
safef(source, sizeof(source), "%s/%s", sourceDir, fileName);
safef(thumb, sizeof(thumb), "%s/%s", thumbDir, fileName);
safef(full, sizeof(full), "%s/%s", fullDir, fileName);
splitPath(full, outFullDir, outFullRoot, NULL);
outFullDir[strlen(outFullDir)-1]=0;  /* knock off trailing slash */
strcpy(pyramid,full);
chopSuffix(pyramid);

makeDirForFile(thumb);
makeDirForFile(full);
makeDir(pyramid);

if (endsWith(source,".jp2"))
    {
    thumb[strlen(thumb)-1]='g';  /* convert the extension */
    noLink = TRUE;   /* for jp2, symlink to source automatically suppressed */
    makeFullSize = TRUE;  /* instead we'll have the tile-maker make a fullsize jpg for us */
    quality[0] = 50;
    quality[1] = 60;
    quality[2] = 70;
    quality[3] = 80;
    quality[4] = 85;
    quality[5] = 85;
    quality[6] = 85;
    jp2DecInit(source, &nWidth, &nHeight);
    readScanline = &jp2ReadScanline;
    jpgTiles(nWidth, nHeight, outFullDir, outFullRoot, thumb, readScanline, quality, makeFullSize);
    jp2Destroy();
    }
else if (endsWith(source,".jpg"))
    {
    jpgDecInit(source, &nWidth, &nHeight);
    readScanline = &jpgReadScanline;
    jpgTiles(nWidth, nHeight, outFullDir, outFullRoot, thumb, readScanline, NULL, makeFullSize);
	/* NULL quality will default to 75 for all */
    jpgDestroy();
    }

if (!noLink)
    makeLink(source, full);
}
コード例 #7
0
ファイル: CDirContent.cpp プロジェクト: metopa/HTTP_Server
void CDirContent::load() {
	int rc;
	DIR * dir;
	dirent entry;
	dirent * result;
	Log.ger<>( DEBUG_REQUEST, "Directory:", realPath_m, userPath_m );
	vector<CHTMLGenerator> files_m;

	if ( !( dir = opendir( realPath_m.c_str() ) ) ) {
		int errNo = errno;

		switch ( errNo ) {
			case EACCES:
				throw PermissionDeniedException( userPath_m );
			case ENOENT:
				throw FileNotFoundException( userPath_m );
			default:
				throw FileErrorException( userPath_m );
		}
	}

	while ( !( rc = readdir_r( dir, &entry, &result ) ) ) {
		if ( result == nullptr )
			break;
		files_m.push_back( CHTMLGenerator( result->d_name ) );
		Log.ger<>( DEBUG_REQUEST, "Directory", result->d_name, (int)result->d_type );
		if ( result->d_type == DT_DIR || result->d_type == DT_REG )
			files_m.back().makeHyperlink( makeLink( result->d_name ) );
		files_m.back().enlarge();
		if ( !strcmp( result->d_name, ".." ) )
			files_m.back().setPriority( -2 );
		else if ( !strcmp( result->d_name, "." ) )
			files_m.back().setPriority( -1 );
	}

	stable_sort( files_m.begin(), files_m.end() );

	CHTMLGenerator table( string( "Index of " ) + userPath_m );
	table.enlarge( 2 ).makeTable( files_m );
	if ( rc )
		table.append( "\nAn error occured while reading directory content. Try to refresh page\n" );
	string rawHTML = table.wrap( string( "Index of " ) + userPath_m.c_str() );
	data_m.insert( data_m.begin(), rawHTML.begin(), rawHTML.end() );

	closedir( dir );

	size_m = data_m.size();

	modificationTime();
	creationTime();
}
コード例 #8
0
void Topology::createLinks()
{
  // Find maximum switchID

  SwitchID max_switch_id = 0;
  for (int i=0; i<m_links_src_vector.size(); i++) {
    max_switch_id = max(max_switch_id, m_links_src_vector[i]);
    max_switch_id = max(max_switch_id, m_links_dest_vector[i]);
  }

  // Initialize weight vector
  Matrix topology_weights;
  Matrix topology_bw_multis;
  int num_switches = max_switch_id+1;
  topology_weights.setSize(num_switches);
  topology_bw_multis.setSize(num_switches);
  for(int i=0; i<topology_weights.size(); i++) {
    topology_weights[i].setSize(num_switches);
    topology_bw_multis[i].setSize(num_switches);
    for(int j=0; j<topology_weights[i].size(); j++) {
      topology_weights[i][j] = INFINITE_LATENCY;
      topology_bw_multis[i][j] = -1;  // initialize to an invalid value
    }
  }

  // Set identity weights to zero
  for(int i=0; i<topology_weights.size(); i++) {
    topology_weights[i][i] = 0;
  }

  // Fill in the topology weights and bandwidth multipliers
  for (int i=0; i<m_links_src_vector.size(); i++) {
    topology_weights[m_links_src_vector[i]][m_links_dest_vector[i]] = m_links_latency_vector[i];
    topology_bw_multis[m_links_src_vector[i]][m_links_dest_vector[i]] = m_bw_multiplier_vector[i];
  }

  // Walk topology and hookup the links
  Matrix dist = shortest_path(topology_weights);
  for(int i=0; i<topology_weights.size(); i++) {
    for(int j=0; j<topology_weights[i].size(); j++) {
      int weight = topology_weights[i][j];
      if (weight > 0 && weight != INFINITE_LATENCY) {
        int bw_multiplier = topology_bw_multis[i][j];
        assert(bw_multiplier > 0);
        NetDest destination_set = shortest_path_to_node(i, j, topology_weights, dist, m_nodes);
        makeLink(i, j, destination_set, weight, bw_multiplier);
      }
    }
  }
}
コード例 #9
0
ファイル: entryedict.cpp プロジェクト: KDE/kiten
/**
 * Makes a link out of each kanji in @param inString
 */
QString EntryEdict::kanjiLinkify( const QString &inString ) const
{
  QString outString;

  for( int i = 0; i < inString.length(); i++ )
  {
    if( isKanji( inString.at( i ) ) )
    {
      outString += makeLink( QString( inString.at( i ) ) );
    }
    else
    {
      outString += inString.at( i );
    }
  }

  return outString;
}
コード例 #10
0
void writeEventAndMakeLink(const char *theEventDir, const char *theLinkDir, AnitaEventFull_t *theEventPtr)
{
    char theFilename[FILENAME_MAX];
    //   int retVal;
    AnitaEventHeader_t *theHeader=&(theEventPtr->header);
    AnitaEventBody_t *theBody=&(theEventPtr->body);


    sprintf(theFilename,"%s/ev_%d.dat",theEventDir,
	    theEventPtr->header.eventNumber);
    writeStruct(theBody,theFilename,sizeof(AnitaEventBody_t));  
      
    sprintf(theFilename,"%s/hd_%d.dat",theEventDir,
	    theEventPtr->header.eventNumber);
    writeStruct(theHeader,theFilename,sizeof(AnitaEventHeader_t));

    /* Make links, not sure what to do with return value here */
    makeLink(theFilename,theLinkDir);
}
コード例 #11
0
ファイル: Calibd.c プロジェクト: sylarcp/anitaFlightSoft
void writeStatus()
/*
  Write the current calibration state
*/
{
    // int retVal;
    char filename[FILENAME_MAX];
    CalibStruct_t theStatus;
    time_t unixTime;
    time(&unixTime);
    theStatus.unixTime=unixTime;
    theStatus.status=0;

    if(stateAmplite1) 
	theStatus.status|=AMPLITE1_MASK;
    if(stateAmplite2) 
	theStatus.status|=AMPLITE2_MASK;
    if(stateBZAmpa1) 
	theStatus.status|=BZAMPA1_MASK;
    if(stateBZAmpa2) 
	theStatus.status|=BZAMPA2_MASK;
    if(stateNTUAmpa) 
	theStatus.status|=NTUAMPA_MASK;
    if(stateSB) 
      theStatus.status|=SB_MASK;
    if(stateNTUSSD5V) 
      theStatus.status|=NTU_SSD_5V_MASK;
    if(stateNTUSSD12V) 
      theStatus.status|=NTU_SSD_12V_MASK;
    if(stateNTUSSDShutdown) 
      theStatus.status|=NTU_SSD_SHUTDOWN_MASK;
    
    
    sprintf(filename,"%s/calib_%u.dat",CALIBD_STATUS_DIR,theStatus.unixTime);
    writeStruct(&theStatus,filename,sizeof(CalibStruct_t));
    makeLink(filename,CALIBD_STATUS_LINK_DIR);

    cleverHkWrite((unsigned char*)&theStatus,sizeof(CalibStruct_t),
		  theStatus.unixTime,&calibWriter);
    
}
コード例 #12
0
int writeFileAndLink(GpuPhiSectorPowerSpectrumStruct_t* payloadPowSpec, int phi) {
    char theFilename[FILENAME_MAX];
    int retVal=0;
    
    fillGenericHeader(payloadPowSpec,PACKET_GPU_AVE_POW_SPEC,sizeof(GpuPhiSectorPowerSpectrumStruct_t));
    
    sprintf(theFilename,"%s/gpuPowSpec_%u_phi%d.dat",
	    GPU_TELEM_DIR,payloadPowSpec->unixTimeFirstEvent,phi);
    retVal=writeStruct(payloadPowSpec,theFilename,sizeof(GpuPhiSectorPowerSpectrumStruct_t));
    retVal=makeLink(theFilename,GPU_TELEM_LINK_DIR);

    retVal=cleverHkWrite((unsigned char*)payloadPowSpec,sizeof(GpuPhiSectorPowerSpectrumStruct_t),
			 payloadPowSpec->unixTimeFirstEvent,&gpuWriter);
    printf("cleverHkWrite for fileName %s returned %d\n", theFilename, retVal);

    if(retVal<0) {
	//Had an error
    }
    
    return retVal;
}
コード例 #13
0
ファイル: maxheap.c プロジェクト: ptcte/allinone
void insert(Heap* hp,char* data)
{
  Link* t = makeLink(data);
  int i;
  if (isEmpty(hp))
  {
    hp->f = t;
    hp->r = t;
  }
  else
  {
    hp->r->a = t;
    t->b = hp->r;
    hp->r = t;
  }
  (hp->c)++;
  i = hp->c;
  while ((i > 1) && (strcmp() < 0)) {
    
  }
  
}
コード例 #14
0
ファイル: AEL.c プロジェクト: elfprince13/Scanline-Rendering
void stepEdges(ActiveEdgeList *ael, const rb_red_blk_tree* activePrims){
	static int scanLine;
	const static Comparator leftToRight = {(CompareF)(&leftToRightF), &scanLine};
	LinkN **aelHead = &(ael->activeEdges);
	scanLine = ++(ael->scanLine);
	{
		LinkN *i, *p, *nextP;
		for(p = NULL, i = ael->activeEdges; i; (p = i),(i = nextP)){
			const EdgeListEntry *const entry = i->data;
			Point **const edge = entry->edge;
			const float ys = edge[START]->y,
			ye = edge[END]->y,
			edgeEnd = max(ys, ye);
			nextP = i->tail;
			if(edgeEnd < scanLine){
#ifndef NDEBUG
				{
					const char* msg = "Deactivating %s with y-span: %f -> %f with x-span: %f -> %f(true: %f -> %f)\n",
					*color = fmtColor(entry->owner->color);
					const float lowEnd = min(ys, ye),
					mnX = getMinXForLine(entry, scanLine), mxX = getMaxXForLine(entry, scanLine),
					sX = edge[START]->x, eX = edge[END]->x;
					dPrintf((msg, color, lowEnd, edgeEnd, mnX, mxX, sX, eX));
				}
#endif
				/* Entries don't own the primitives they point to,
				 * so we can get away with a simple free  */
				freeLink(removeLink(aelHead, i, p), &free);
				i = p; /* We don't want to advance p into garbage data */
			}
		}
	}
	{
		const rb_red_blk_node *i;
		for(i = activePrims->first; i != activePrims->sentinel; i = TreeSuccessor(activePrims, i)){
			Primitive *const prim = i->key;
			const size_t jMax = prim->arity;
			size_t j;
			for(j = 0; j < jMax; ++j){
				Point **const e = prim->boundary + j;
				const float sy = e[START]->y,
				ey = e[END]->y,
				mnY = min(sy, ey),
				mxY = max(sy, ey);
				const bool singleton = prim->arity == 1;
				if((roundOwn(mnY) == scanLine && (!CLOSE_ENOUGH(sy,ey) || (singleton /* newEdge.isSingleton() */)))
				   || (scanLine == 0 && mnY < 0 && mxY > 0)){
					LinkN* newEdge = makeLinkEZ(e, prim);
#ifndef NDEBUG
					{
						const char* msg = "Activating %s with y-span: %f -> %f with x-span: %f -> %f(true: %f -> %f)\n",
						*color = fmtColor(prim->color);
						const float mnX = getMinXForLine(newEdge->data, scanLine),
						mxX = getMaxXForLine(newEdge->data, scanLine),
						sX = e[START]->x, eX = e[END]->x;
						dPrintf((msg, color, mnY, mxY, mnX, mxX, sX, eX));
					}
#endif
					linkFront(aelHead, newEdge);
					if (singleton) {
						dPrintf(("\t->Activating dummy end\n"));
						linkFront(aelHead, makeLink(e, prim, true));
					}
				}
			}
		}
	}
	mergeSort(&(ael->activeEdges), &leftToRight);
}
コード例 #15
0
void AbstractNavigationContext::makeLink( const QString& name, DeclarationPointer declaration, NavigationAction::Type actionType )
{
  NavigationAction action( declaration, actionType );
  QString targetId = QString::number((quint64)declaration.data() * actionType);
  makeLink(name, targetId, action);
}
コード例 #16
0
ファイル: cdlist.c プロジェクト: ptcte/allinone
void insert(CDList* cdlp,char* st){
  int n;
  int m;
  int result = 1;
  Link* c;
  Link* t;
  Link* p;
  t = makeLink(st);
  c = cdlp->s;
  p = cdlp->e;
  while(result == 1){
    if(isEmpty(cdlp))
    {
      c = t;
      p = t;
      cdlp->s = c;
      cdlp->e = p;
      cdlp->s->d = cdlp->e;
      cdlp->e->d = cdlp->s;
      cdlp->s->u = cdlp->e;
      cdlp->e->u = cdlp->s;
      break;
    }else
    if(!isEmpty(cdlp)&&(c == p))
    {
      n = strcmp(t->str,c->str);
      if(n == 0)
      {
	printf("string already present\n");
	break;  
      }
      if(n < 0)
      {
	c = t;
	t->d = p;
	p->u = t;
	cdlp->s = c;
	cdlp->e = p;
	cdlp->s->d = cdlp->e;
	cdlp->e->d = cdlp->s;
	cdlp->s->u = cdlp->e;
	cdlp->e->u = cdlp->s;
	break;
      }
      if(n > 0)
      {
	p = t;
	c->d = t;
	t->u = c;
	cdlp->s = c;
	cdlp->e = p;
	cdlp->s->d = cdlp->e;
	cdlp->e->d = cdlp->s;
	cdlp->s->u = cdlp->e;
	cdlp->e->u = cdlp->s;
	break;
      }
    }
    if(!isEmpty(cdlp) && (c != p))
    {
      n = strcmp(t->str,c->str);
      m = strcmp(t->str,p->str);
      if((c == cdlp->s)&&(p == cdlp->e))
      {
	if((n == 0)||(m == 0))
	{
	  printf("string already present\n");
	  break;
	}
	if(n < 0){
	  t->d = c;
	  t->u = p;
	  c->u = t;
	  p->d = t;
	  c = t;
	  cdlp->s = c;
	  cdlp->e = p;
	  cdlp->e->d = cdlp->s;
	  cdlp->s->u = cdlp->e;
	  break;
	}
	if(m > 0){
	  t->d = c;
	  c->u = t;
	  p->d = t;
	  t->u = p;
	  p = t;
	  cdlp->s = c;
	  cdlp->e = p;
	  cdlp->e->d = cdlp->s;
	  cdlp->s->u = cdlp->e;
	  break;
	}
	if((n > 0)&&(m < 0)){
	  p = c;
	  c = c->d;
	}  	  
      }
      if((c != cdlp->s)&&(p != cdlp->e))
      {
	if((n == 0)||(m == 0))
	{
	  printf("string already present\n");
	  break;
	}
	if((n < 0)&&(m > 0))
	{
	  t->d = c;
	  c->u = t;
	  p->d = t;
	  t->u = p;
	  p = t;
	  cdlp->e->d = cdlp->s;
	  cdlp->s->u = cdlp->e;
	  break;
	}
	if((m > 0)&&(n > 0))
	{
	  p = c;
	  c = c->d;
	}	  
      }	
    }
  }
}
コード例 #17
0
ファイル: FmFwActions.c プロジェクト: ThomasAdam/moxfm
void overwriteProc(XtPointer fsel, int conf)
{
 SelFileNamesRec *fnames = (SelFileNamesRec *) fsel;
 char to[MAXPATHLEN], from[MAXPATHLEN];
 String errstr;
 struct stat tolstats;
 size_t len;
 int devto, devfrom, deverr = -1, res;

 switch (conf)
 {
     case CANCEL:	fnames->first = fnames->n_sel; break;
     case ALL:		fnames->conf_ovwr = False;
     case YES:
	 switch (fnames->op)
	 {
	     case COPY:	errstr = "Error copying"; break;
	     case MOVE: errstr = "Error moving"; break;
	     default: errstr = "Error creating symlink to";
	 }
	 strcpy(from, fnames->directory);
	 if (from[(len = strlen(from)) - 1] != '/')
	     strcat(from, "/");
	 strcat(from, fnames->names[fnames->first]);
	 strcpy(to, fnames->target);
	 devfrom = findDev(from);
	 if (mountDev(devto = findDev(to), False))
	     deverr = devto;
	 else if (mountDev(devfrom, False))
	     deverr = devfrom;
	 if (deverr != -1)
	 {
	     error(fnames->shell, "Cannot mount device on", mntable.devices[deverr].def_mpoint);
	     fnames->first = fnames->n_sel;
	     umountDev(devto, False);
	     break;
	 }
	 if (fnames->dirtarget)  strcat(to, fnames->names[fnames->first]);
	 if (!(lstat(to, &tolstats)))
	 {
	     if (fnames->op != COPY && S_ISDIR(tolstats.st_mode))
		 rdelete(to);
	     else if (fnames->op == LINK || (fnames->op == MOVE && S_ISLNK(tolstats.st_mode)))
	     {
		 unlink(to);
		 fnames->update = True;
	     }
	 }
	 switch (fnames->op)
	 {
	     case COPY:	rcopy(from, to, False); res = 0; break;
	     case MOVE:	res = movefile(from, to); break;
	     default:	res = makeLink(from, to);
	 }
	 if (res)
	 {
	     if (opError(fnames->shell, errstr, from) != YES)
	     {
		 fnames->first = fnames->n_sel;
		 break;
	     }
	 }
	 else  fnames->update = True;
	 umountDev(devto, False);
	 umountDev(devfrom, False);
     case NO:	fnames->first++;
 }
 moveFilesProc(fsel, YES);
}
コード例 #18
0
ファイル: FmFwActions.c プロジェクト: ThomasAdam/moxfm
void moveFilesProc(XtPointer fsel, int conf)
{
 SelFileNamesRec *fnames = (SelFileNamesRec *) fsel;
 struct stat tostats, tolstats, frstats;
 char from[MAXPATHLEN], to[MAXPATHLEN];
 String name, cwd;
 String op_name, from_err, to_err;
 size_t toend, fromend;
 int devto, devfrom, deverr = -1, i, perm, res;
 Boolean is_dir, is_link;

 if (conf != YES || !fnames->op)
 {
     freeSelFiles(fnames);
     return;
 }
 if (chdir(fnames->directory))
 {
     sysError(fnames->shell, "System error:");
     freeSelFiles(fnames);
     return;
 }
 chdir(user.home);
 switch (fnames->op)
 {
     case COPY:
	 op_name = "Copy:";
	 from_err = "Error copying";
	 to_err = "Error copying to";
	 break;
     case MOVE:
	 op_name = "Move:";
	 from_err = "Error moving";
	 to_err = "Error moving to";
	 break;
     default:  /* i.e. LINK */
	 op_name = "Link:";
	 from_err = "Error creating symlink to";
	 to_err = "Error creating symlink in";
 }
 if (fnames->target[0] != '/' && fnames->target[0] != '~' && fnames->target != 0)
 {
     strcpy(to, fnames->directory);
     if (to[strlen(to)-1] != '/')  strcat(to, "/");
 }
 else to[0] = 0;
 strcat(to, fnames->target);
 fnexpand(to);
 if (!(cwd = absolutePath(to)))
 {
     error(fnames->shell, no_target, to);
     freeSelFiles(fnames);
     return;
 }
 strcpy(to, cwd);
 XTFREE(cwd);
 fromend = strlen(strcpy(from, fnames->directory));
 if (from[fromend-1] != '/')
 {
     from[fromend++] = '/';
     from[fromend] = 0;
 }
 devfrom = findDev(from);
 if (mountDev(devto = findDev(to), False))
     deverr = devto;
 else if (mountDev(devfrom, False))
     deverr = devfrom;
 if (deverr != -1)
 {
     error(fnames->shell, "Cannot mount device on", mntable.devices[deverr].def_mpoint);
     umountDev(devto, False);
     freeSelFiles(fnames);
     return;
 }
 if (!(stat(to, &tostats)) && S_ISDIR(tostats.st_mode))
 {
     if (chdir(to) || !(perm = permission(&tostats, P_WRITE)))
     {
	 chdir(user.home);
	 if (!perm)
	     error(fnames->shell, "You have no write permission for ", to);
	 else  sysError(fnames->shell, "System error:");
	 umountDev(devto, False);
	 umountDev(devfrom, False);
	 freeSelFiles(fnames);
	 return;
     }
     chdir(user.home);
     fnames->dirtarget = True;
     toend = strlen(to);
     if (to[toend-1] != '/')
     {
	 to[toend++] = '/';
	 to[toend] = 0;
     }
 }
 else if (fnames->n_sel == 1)  fnames->dirtarget = False;
 else
 {
     error(fnames->shell, op_name, "Target for multiple files must be a folder");
     umountDev(devto, False);
     umountDev(devfrom, False);
     freeSelFiles(fnames);
     return;
 }
 if (!fnames->first)  zzz();
 XTFREE(fnames->target);
 fnames->target = XtNewString(to);
 for (i = fnames->first; i < fnames->n_sel; i++)
 {
     name = fnames->names[i];
     if (fnames->op != LINK && (!strcmp(name, ".") || !strcmp(name, "..")))
     {
	 error(fnames->shell, "Cannot move or copy . or ..", NULL);
	 continue;
     }
     strcpy(from+fromend, name);
     if (fnames->dirtarget)
     {
	 if (fnames->op != LINK && prefix(from, to))
	 {
	     String err_str, format = "Cannot move or copy %s to";
	     err_str = (String) XtMalloc((strlen(format) + strlen(from)) * sizeof(char));
	     sprintf(err_str, format, from);
	     error(fnames->shell, err_str, to);
	     XTFREE(err_str);
	     umountDev(devto, False);
	     umountDev(devfrom, False);
	     freeSelFiles(fnames);
	     wakeUp();
	     return;
	 }
	 strcpy(to+toend, name);
     }
     if (!(lstat(to, &tolstats)))
     {
	 fnames->first = i;
	 is_dir = False;
	 if (!(stat(to, &tostats)))
	 {
	     if (S_ISDIR(tostats.st_mode))
		 is_dir = True;
	     if (!stat(from, &frstats) && tostats.st_ino == frstats.st_ino)
	     {
		 error(fnames->shell, op_name, "Source and destination are identical");
		 umountDev(devto, False);
		 umountDev(devfrom, False);
		 freeSelFiles(fnames);
		 wakeUp();
		 return;
	     }
	 }
	 if (S_ISLNK(tolstats.st_mode))
	     is_link = True;
	 else  is_link = False;

	 if (fnames->conf_ovwr || (is_dir && (!is_link || fnames->op == COPY) && resources.confirm_delete_folder))
	     overwriteDialog(fnames, to, (fnames->op == COPY && is_dir && (lstat(from, &frstats) || !S_ISDIR(frstats.st_mode)))?
			     "File copy:" : op_name,
			     is_dir && (!is_link || fnames->op == COPY));
	 else overwriteProc(fsel, YES);
	 umountDev(devto, False);
	 umountDev(devfrom, False);
	 return;
     }
     switch (fnames->op)
     {
	 case COPY:	rcopy(from, to, False); res = 0; break;
	 case MOVE:	res = movefile(from, to); break;
	 default:	res = makeLink(from, to);
     }
     if (res)
     {
	 if (opError(fnames->shell, from_err, name) != YES)
	     break;
     }
     else  fnames->update = True;
 }
 umountDev(devto, False);
 umountDev(devfrom, False);
 if (fnames->update)
 {
     if (fnames->op == COPY)
	 intUpdate(CHECK_DIR);		/* Check for new subdirectories */
     if (fnames->op == MOVE)
	 markForUpdate(fnames->directory, CHECK_FILES);
     markForUpdate(to, RESHOW);
     if (fnames->op != COPY)
	 intUpdate(CHECK_DIR);
 }
 freeSelFiles(fnames);
 wakeUp();
}
コード例 #19
0
ファイル: Calibd.c プロジェクト: sylarcp/anitaFlightSoft
int outputData(AnalogueCode_t code) 
{
    int retVal;
    char theFilename[FILENAME_MAX];
    char fullFilename[FILENAME_MAX];
    SSHkDataStruct_t theHkData;
    AnitaHkWriterStruct_t *wrPtr;

    static int telemCount=0;


    struct timeval timeStruct;
    gettimeofday(&timeStruct,NULL);
	    
    theHkData.unixTime=timeStruct.tv_sec;;
    theHkData.unixTimeUs=timeStruct.tv_usec;;
    switch(code) {
	case (IP320_RAW):
	    sprintf(theFilename,"sshk_%d_%d.raw.dat",theHkData.unixTime,
		theHkData.unixTimeUs);
	    theHkData.ip320=rawDataStruct;
	    wrPtr=&hkRawWriter;
	    break;
	case(IP320_CAL):
	    sprintf(theFilename,"sshk_%d_%d.cal.dat",theHkData.unixTime,
		    theHkData.unixTimeUs);
	    theHkData.ip320=calDataStruct;
	    wrPtr=&hkCalWriter;
	    break;
	case(IP320_AVZ):
	    sprintf(theFilename,"sshk_%d_%d.avz.dat",theHkData.unixTime,
		    theHkData.unixTimeUs);
	    theHkData.ip320=autoZeroStruct;
//	    printf("First two %d %d\n",theHkData.ip320.board[0].data[0]&0xfff,
//		   theHkData.ip320.board[0].data[0]&0xfff);
	    wrPtr=&hkCalWriter;
	    break;
	default:
	    syslog(LOG_WARNING,"Unknown HK data code: %d",code);
	    if(printToScreen) 
		fprintf(stderr,"Unknown HK data code: %d\n",code);
	    return -1;
    }
	    


    fillGenericHeader(&theHkData,PACKET_HKD_SS,sizeof(SSHkDataStruct_t));

    if(code==IP320_RAW) {
      int chan=0;
      printf("Raw data: ");
      for(chan=0;chan<40;chan++) {
	printf("%d ",rawDataStruct.board.data[chan]);
      }
      printf("\n");
    }


    telemCount++;
    if(telemCount>=telemEvery) {    
	//Write file and make link for SIPd
      if(printToScreen) printf("%s\n",theFilename);
	sprintf(fullFilename,"%s/%s",HK_TELEM_DIR,theFilename);
	retVal=writeStruct(&theHkData,fullFilename,sizeof(SSHkDataStruct_t));     
	retVal+=makeLink(fullFilename,HK_TELEM_LINK_DIR);      
	
	telemCount=0;
    }
    
    //Write file to main disk
    retVal=cleverHkWrite((unsigned char*)&theHkData,sizeof(SSHkDataStruct_t),
			 theHkData.unixTime,wrPtr);
    if(retVal<0) {
	//Had an error
	//Do something
    }	    
    

    return retVal;
}
コード例 #20
0
QString AbstractDeclarationNavigationContext::html(bool shorten)
{
  clear();
  m_shorten = shorten;
  modifyHtml()  += "<html><body><p>" + fontSizePrefix(shorten);

  addExternalHtml(m_prefix);

  if(!m_declaration.data()) {
    modifyHtml() += i18n("<br /> lost declaration <br />");
    return currentHtml();
  }
  
  if( m_previousContext ) {
    QString link = createLink( m_previousContext->name(), m_previousContext->name(), NavigationAction(m_previousContext) );
    modifyHtml() += navigationHighlight(i18n("Back to %1<br />", link));
  }
  
  KSharedPtr<IDocumentation> doc;
  
  if( !shorten ) {
    doc = ICore::self()->documentationController()->documentationForDeclaration(m_declaration.data());
    
    const AbstractFunctionDeclaration* function = dynamic_cast<const AbstractFunctionDeclaration*>(m_declaration.data());
    if( function ) {
      htmlFunction();
    } else if( m_declaration->isTypeAlias() || m_declaration->kind() == Declaration::Instance ) {
      if( m_declaration->isTypeAlias() )
        modifyHtml() += importantHighlight("typedef ");

      if(m_declaration->type<EnumeratorType>())
        modifyHtml() += i18n("enumerator ");

      AbstractType::Ptr useType = m_declaration->abstractType();
      if(m_declaration->isTypeAlias()) {
        //Do not show the own name as type of typedefs
        if(useType.cast<TypeAliasType>())
          useType = useType.cast<TypeAliasType>()->type();
      } 
      
      eventuallyMakeTypeLinks( useType );

      modifyHtml() += ' ' + nameHighlight(Qt::escape(declarationName(m_declaration))) + "<br>";
    }else{
      if( m_declaration->kind() == Declaration::Type && m_declaration->abstractType().cast<StructureType>() ) {
        htmlClass();
      }
      if ( m_declaration->kind() == Declaration::Namespace ) {
        modifyHtml() += i18n("namespace %1 <br />", nameHighlight(Qt::escape(m_declaration->qualifiedIdentifier().toString())));
      }

      if(m_declaration->type<EnumerationType>()) {
        EnumerationType::Ptr enumeration = m_declaration->type<EnumerationType>();
        modifyHtml() += i18n("enumeration %1 <br/>", Qt::escape(m_declaration->identifier().toString()) );
      }

      if(m_declaration->isForwardDeclaration()) {
        ForwardDeclaration* forwardDec = static_cast<ForwardDeclaration*>(m_declaration.data());
        Declaration* resolved = forwardDec->resolve(m_topContext.data());
        if(resolved) {
          modifyHtml() += i18n("( resolved forward-declaration: ");
          makeLink(resolved->identifier().toString(), KDevelop::DeclarationPointer(resolved), NavigationAction::NavigateDeclaration );
          modifyHtml() += i18n(") ");
        }else{
          modifyHtml() += i18n("(unresolved forward-declaration) ");
          QualifiedIdentifier id = forwardDec->qualifiedIdentifier();
          uint count;
          const IndexedDeclaration* decls;
          PersistentSymbolTable::self().declarations(id, count, decls);
          bool had = false;
          for(uint a = 0; a < count; ++a) {
            if(decls[a].isValid() && !decls[a].data()->isForwardDeclaration()) {
              modifyHtml() += "<br />";
              makeLink(i18n("possible resolution from"), KDevelop::DeclarationPointer(decls[a].data()), NavigationAction::NavigateDeclaration);
              modifyHtml() += ' ' + decls[a].data()->url().str();
              had = true;
            }
          }
          if(had)
            modifyHtml() += "<br />";
        }
      }
    }
  }else{
    AbstractType::Ptr showType = m_declaration->abstractType();
    if(showType && showType.cast<FunctionType>()) {
      showType = showType.cast<FunctionType>()->returnType();
      if(showType)
        modifyHtml() += labelHighlight(i18n("Returns: "));
    }else  if(showType) {
      modifyHtml() += labelHighlight(i18n("Type: "));
    }
    
    if(showType) {
      eventuallyMakeTypeLinks(showType);
      modifyHtml() += " ";
    }
  }
  
  QualifiedIdentifier identifier = m_declaration->qualifiedIdentifier();
  if( identifier.count() > 1 ) {
    if( m_declaration->context() && m_declaration->context()->owner() )
    {
      Declaration* decl = m_declaration->context()->owner();

      FunctionDefinition* definition = dynamic_cast<FunctionDefinition*>(decl);
      if(definition && definition->declaration())
        decl = definition->declaration();

      if(decl->abstractType().cast<EnumerationType>())
        modifyHtml() += labelHighlight(i18n("Enum: "));
      else
        modifyHtml() += labelHighlight(i18n("Container: "));

      makeLink( declarationName(DeclarationPointer(decl)), DeclarationPointer(decl), NavigationAction::NavigateDeclaration );
      modifyHtml() += " ";
    } else {
      QualifiedIdentifier parent = identifier;
      parent.pop();
      modifyHtml() += labelHighlight(i18n("Scope: %1 ", typeHighlight(Qt::escape(parent.toString()))));
    }
  }
  
  if( shorten && !m_declaration->comment().isEmpty() ) {
    QString comment = QString::fromUtf8(m_declaration->comment());
    if( comment.length() > 60 ) {
      comment.truncate(60);
      comment += "...";
    }
    comment.replace('\n', " ");
    comment.replace("<br />", " ");
    comment.replace("<br/>", " ");
    modifyHtml() += commentHighlight(Qt::escape(comment)) + "   ";
  }
  

  QString access = stringFromAccess(m_declaration);
  if( !access.isEmpty() )
    modifyHtml() += labelHighlight(i18n("Access: %1 ", propertyHighlight(Qt::escape(access))));


  ///@todo Enumerations

  QString detailsHtml;
  QStringList details = declarationDetails(m_declaration);
  if( !details.isEmpty() ) {
    bool first = true;
    foreach( const QString &str, details ) {
      if( !first )
        detailsHtml += ", ";
      first = false;
      detailsHtml += propertyHighlight(str);
    }
  }
コード例 #21
0
ファイル: Topology.C プロジェクト: boy999/sample
void Topology::createLinks(bool isReconfiguration)
{
  // Find maximum switchID
  SwitchID max_switch_id = 0;
  for (int i=0; i<m_links_src_vector.size(); i++) {
    max_switch_id = max(max_switch_id, m_links_src_vector[i]);
    max_switch_id = max(max_switch_id, m_links_dest_vector[i]);
  }


  //cerr << "Max switch id "<< max_switch_id<<"\n";
  // Initialize weight vector
  //typedef Vector < Vector <int> > Matrix;
  Matrix topology_weights;
  Matrix topology_latency;
  Matrix topology_bw_multis;
  int num_switches = max_switch_id+1;
  topology_weights.setSize(num_switches);
  topology_latency.setSize(num_switches);
  topology_bw_multis.setSize(num_switches);
  m_component_latencies.setSize(num_switches);  // FIXME setting the size of a member variable here is a HACK!
  m_component_inter_switches.setSize(num_switches);  // FIXME setting the size of a member variable here is a HACK!
  for(int i=0; i<topology_weights.size(); i++) {
    topology_weights[i].setSize(num_switches);
    topology_latency[i].setSize(num_switches);
    topology_bw_multis[i].setSize(num_switches);
    m_component_latencies[i].setSize(num_switches);
    m_component_inter_switches[i].setSize(num_switches);  // FIXME setting the size of a member variable here is a HACK!
    for(int j=0; j<topology_weights[i].size(); j++) {
      topology_weights[i][j] = INFINITE_LATENCY;
      topology_latency[i][j] = -1;  // initialize to an invalid value
      topology_bw_multis[i][j] = -1;  // initialize to an invalid value
      m_component_latencies[i][j] = -1; // initialize to an invalid value
      m_component_inter_switches[i][j] = 0;  // initially assume direct connections / no intermediate switches between components
    }
  }

  // Set identity weights to zero
  for(int i=0; i<topology_weights.size(); i++) {
    topology_weights[i][i] = 0;
  }

  // Fill in the topology weights and bandwidth multipliers
  for (int i=0; i<m_links_src_vector.size(); i++) {
    topology_weights[m_links_src_vector[i]][m_links_dest_vector[i]] = m_links_weight_vector[i];
    topology_latency[m_links_src_vector[i]][m_links_dest_vector[i]] = m_links_latency_vector[i];
    m_component_latencies[m_links_src_vector[i]][m_links_dest_vector[i]] = m_links_latency_vector[i];  // initialize to latency vector
    topology_bw_multis[m_links_src_vector[i]][m_links_dest_vector[i]] = m_bw_multiplier_vector[i];
  }

  // Walk topology and hookup the links
  Matrix dist = shortest_path(topology_weights, m_component_latencies, m_component_inter_switches);
  for(int i=0; i<topology_weights.size(); i++) {
    for(int j=0; j<topology_weights[i].size(); j++) {
      int weight = topology_weights[i][j];
      int bw_multiplier = topology_bw_multis[i][j];
      int latency = topology_latency[i][j];
      if (weight > 0 && weight != INFINITE_LATENCY) {
        NetDest destination_set = shortest_path_to_node(i, j, topology_weights, dist);
        assert(latency != -1);
        makeLink(i, j, destination_set, latency, weight, bw_multiplier, isReconfiguration);
      }
    }
  }

}