Example #1
0
File: myls.c Project: junk2112/os
int main (int arc, char **argv) 
{
  bool key_l = isKey_l(arc, argv);
  char **path = getPath(arc, argv);
  int pathCount = getPathCount(arc, argv);
  bool isFewPathes = false;
  if (pathCount > 1)
    isFewPathes = true;
  int i;
  for (i=0; i<pathCount; ++i)
  {
    //printf("key_l is %d, dir is \"%s\" \n", key_l, path[i]);
    DIR *directory = opendir(path[i]);
    if (directory == NULL)
    {
     printf("\"%s\" is file or does not exist \n",path[i]); 
     continue;
    }
    if (isFewPathes)
      printf("%s:\n",path[i]);
    if (key_l == false) 
      ls(directory);
    else 
      ls_l(directory, path[i]);
    if (isFewPathes && i!=pathCount-1)
      printf("%s", "\n");
    closedir(directory);
  }
  return 0;
}
Example #2
0
		/// \brief Returns path count for pin 
		size_t getPathCount(InstancePinSharedPtr pinPtr){
			size_t index =0;
			Net::InstancePinSharedPtrIterator sip = superNet->sourcesBegin();
			Net::InstancePinSharedPtrIterator sie = superNet->sourcesEnd();
			while(sip != sie){
				if(**sip == *pinPtr)
					return getPathCount(index);;
				++index;
				++sip;
			}
			
			sip = superNet->sinksBegin();
			sie = superNet->sinksEnd();
			while(sip != sie){
				if(**sip == *pinPtr)
					return getPathCount(index);;
				++index;
				++sip;
			}
			return getPathCount(index);			
		}
Example #3
0
/* ===========================================================================
	DESC
	
	@param	none	desc
	@return	none	desc
	==========================================================================*/
int PDF_Object_Stream::renderObj() {

	//cout << "----------------------------------------------------------------\n";
	//cout << "\tPDF_Object_Stream::renderObj() called...\n";

	string renderString = "";
	string renderStream = "";
	unsigned streamLength = 0;
	pdf_obj::coords currentPoint;
	
	//cout << "\t\tProcessing " << getPathCount() << " paths...\n";
	
	// Process each Path in paths
	for (unsigned p = 0; p < getPathCount(); p++) {
		
		// Set graphics state 
		// Set Stroke width /pattern
		// Set line width (w): "4 w " 
		
		//cout << "\t\tPath " << p << ": ";
		//cout << "stroke width: " << paths[p]->getStrokeWidth() << ", filled: ";
		//if (paths[p]->getFilled() ) cout << "YES, "; else cout << "NO, "; 
		//cout << "closed: ";
		//if (paths[p]->getClosePath() ) cout << "YES\n"; else cout << "NO\n"; 
		
		//cout << "stroke: |";
		//cout << paths[p]->getStrokeWidth();
		
		// Stroke Set
		if (paths[p]->getStrokeWidth() > 0.0) {
		
			//cout << ", cs: " << paths[p]->stroke.getColorSpace();
		
			// Stroke Specified
			renderStream += convertToString( paths[p]->getStrokeWidth() ); 
			renderStream += " w "; 
			
			// Line dash (d) array [units on, units off] units space at start: "[ 4 6 ] 0 d ";
			if ( paths[p]->getDashedStroke() ) {
				renderStream += "[ ";
				renderStream += convertToString( paths[p]->getStrokeDash() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->getStrokeGap() );
				renderStream += " ] ";
				renderStream += convertToString( paths[p]->getStrokeOffset() );
				renderStream += " d ";
			}
			
			// Set stroke color (RGB values, 0.0-1.0) (RG): "0.9 0.5 0.0 RG "; 	
			switch( paths[p]->stroke.getColorSpace() ) {
		
				case 1: // Grayscale
					//cout << ", grey: " << paths[p]->stroke.getValuePDF('A');
					renderStream += convertToString( paths[p]->stroke.getValuePDF('A') );
					renderStream += " G ";
				break;
			
				case 3: // RGB
					renderStream += convertToString( paths[p]->stroke.getValuePDF('R') );
					renderStream += " "; 
					renderStream += convertToString( paths[p]->stroke.getValuePDF('G') );
					renderStream += " ";
					renderStream += convertToString( paths[p]->stroke.getValuePDF('B') );
					renderStream += " RG ";
				break;
			
				case 4: // CMYK
					renderStream += convertToString( paths[p]->stroke.getValuePDF('C') );
					renderStream += " "; 
					renderStream += convertToString( paths[p]->stroke.getValuePDF('M') );
					renderStream += " ";
					renderStream += convertToString( paths[p]->stroke.getValuePDF('Y') );
					renderStream += " ";
					renderStream += convertToString( paths[p]->stroke.getValuePDF('K') );
					renderStream += " K "; 
				break;
			
				default:
					// Paper Color
					renderStream += "1.0 1.0 1.0 G ";
				break;
			}	

		} else {
		
			// No Stroke
			renderStream += "0 w "; 
		}
		
		//cout << "|, ";
		
		// Process Fill (if needed
		//cout << "fill: |cs: ";
		//cout << paths[p]->fill.getColorSpace();
	
		// Set fill color (RGB values, 0.0-1.0) (rg): "0.9 0.5 0.0 rg "; 
		switch( paths[p]->fill.getColorSpace() ) {
		
			case 1: // Grayscale
				//cout << ", grey: " << paths[p]->fill.getValue('A');
				renderStream += convertToString( paths[p]->fill.getValuePDF('A') );
				renderStream += " g ";
			break;
			
			case 3: // RGB
				renderStream += convertToString( paths[p]->fill.getValuePDF('R') );
				renderStream += " "; 
				renderStream += convertToString( paths[p]->fill.getValuePDF('G') );
				renderStream += " ";
				renderStream += convertToString( paths[p]->fill.getValuePDF('B') );
				renderStream += " rg ";
			break;
			
			case 4: // CMYK
				renderStream += convertToString( paths[p]->fill.getValuePDF('C') );
				renderStream += " "; 
				renderStream += convertToString( paths[p]->fill.getValuePDF('M') );
				renderStream += " ";
				renderStream += convertToString( paths[p]->fill.getValuePDF('Y') );
				renderStream += " ";
				renderStream += convertToString( paths[p]->fill.getValuePDF('K') );
				renderStream += " k "; 
			break;
			
			default:
				// Transparent
				//renderStream += "1.0 g ";
			break;
		}	
		
		//cout << "|\n";

		// Store Current Graphics State (q): "q "
		renderStream += "q\n";
		
		// Get Starting point for Path
		currentPoint.x = paths[p]->path[0]->getStartX();
		currentPoint.y = paths[p]->path[0]->getStartY();

		// Process each element in Path
		for (unsigned e = 0; e < paths[p]->getPathSize(); e++) {

			// Get "pen" location
			// Check if start
			// Begun new path (x,y) (m): "150 250 m"; // 
			if (e == 0) {
				renderStream += convertToString( currentPoint.x ); 
				renderStream += " ";
				renderStream += convertToString( currentPoint.y ); 
				renderStream += " m "; // BEGIN NEW PATH
				
			} else if (paths[p]->path[e]->getStartX() != currentPoint.x || 
				 		  paths[p]->path[e]->getStartY() != currentPoint.y) {
			
				// the next point is not lined up with current point
				// End Path and start a new one
				renderStream += "s \n"; // End previous path
			
				// Get new start point
				renderStream += convertToString( currentPoint.x ); 
				renderStream += " ";
				renderStream += convertToString( currentPoint.y ); 
				renderStream += " m "; // BEGIN NEW PATH
			} 		
	
			// Get end point of pen
			if (paths[p]->path[e]->getType() == 1) {

				// Bezier with curve handles at start (c1x, c1y, c2x, c2y, destx, desty) (c):
				// 	"300 400 400 400 400 300 c "; 
				renderStream += convertToString( paths[p]->path[e]->getStartHandleX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getStartHandleY() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndHandleX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndHandleY() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndY() );
				renderStream += " c ";
			
			} else if (paths[p]->path[e]->getType() == 2) {

				// Draw line from current point to new point (x,y) (l): "150 350 l";
				renderStream += convertToString( paths[p]->path[e]->getEndX() );
				renderStream += " ";
				renderStream += convertToString( paths[p]->path[e]->getEndY() );
				renderStream += " l ";
			
			} 
		
			// "MOVE" pen to current location
			currentPoint.x = paths[p]->path[e]->getEndX();
			currentPoint.y = paths[p]->path[e]->getEndY();
			
		} // end processing of elements in path
		
		// Close path? Stroke? Fill?
		// S	-	Stroke the path
		// s	-	Close and stroke the path same effect as the sequence h S .
		// f	-	Fill the path, using the nonzero winding number rule
		// f*	-	Fill the path, using the even-odd rule t
		// B	-	Fill and then stroke the path, using the nonzero winding number rule
		// B*	-	Fill and then stroke the path, using the even-odd rule t
		// b	-	Close, fill, and then stroke the path, using the nonzero winding number rule t
		// b*	-	Close, fill, and then stroke the path, using the even-odd rule
		//	n	-	End the path object without filling or stroking it. 	
		if ( paths[p]->getClosePath() ) renderStream += "h ";
		if ( paths[p]->getStrokeWidth() > 0 ) renderStream += "S ";
		if ( paths[p]->getFilled() ) renderStream += "f ";
		
		// Rectangle x,y w,h rectangle (re), filled (f): "100 400 300 300 re f "
		// Stroke Path (S): "S ";	
		
		// Reset Dash to solid line: "[ ] 0 d " if needed
		if ( paths[p]->getDashedStroke() ) renderStream += "[ ] 0 d ";
		
		// Clear Current Graphics state (Q): "Q "
		renderStream += "Q\n";
	}
	
	//renderStream += "h S ";
	
	streamLength = renderStream.length();
	renderString += getIndexString() + " " + getRevisionString();
	renderString += " obj\n";
	renderString += "<</Length ";
	renderString += convertToString( streamLength ); // Get Stream length
	renderString += ">>\n";
	renderString += "stream\n";
	renderString += renderStream;
	renderString += "endstream\n";
	renderString += "endobj\n";
	
	//cout << "\tPDF_Object_Stream::renderObj() called...DONE.\n";
	//cout << "----------------------------------------------------------------\n";
	
	return setRenderContent( renderString );
}