int main() {
	// Create a square on the heap with a height of 5 and a width of 6
	Polygon* square = new Square(5, 6);
	// Print information using getters and method
	printDetails(square);
	// Set the height to 10 with a setter
	square->setHeight(10);
	// Set the width to 10 with a setter
	square->setWidth(10);
	// Print information using getters and method
	printDetails(square);
	// Cleanup the memory in the heap
	delete square;

	// Create a triangle on the heap with a height of 7 and a width of 8
	Polygon* triangle = new Triangle(7, 8);
	// Print information using getters and method
	printDetails(triangle);
	// Set the height to 3 with a setter
	triangle->setHeight(3);
	// Set the width to 4 with a setter
	triangle->setWidth(4);
	// Print information using getters and method
	printDetails(triangle);
	// Cleanup the memory in the heap
	delete triangle;

	return 0;
}
Exemple #2
0
int ls_func (char* pathname, FILE* outFile) {
    struct dirent* dirEntry = 0;
    char originalDirectory[INPUT_LENGTH];
    DIR* thisDir = 0;
    
    getcwd(originalDirectory, INPUT_LENGTH);
    
    // Open the pathname specified Directory
    if ((pathname == NULL) || (pathname[0] == '\0')) {
        // No pathname -> open Current Directory.
        thisDir = opendir(originalDirectory);
    } else {
        // Open the specified directory 
        thisDir = opendir(pathname);
        if (thisDir == NULL) {
            return 0;
        }
    }
    
    // Print each of the contents in the directory
    while (dirEntry = readdir(thisDir)) {
        printDetails(dirEntry, outFile);       
    }
    return 1;
}
void main()
{
	int leave = 0;
	struct student stu;
	stu.matrix = 0;
	while(!leave)
	{
		char op[10];
		enum CHOICE choice;
		printf("\nWelcome to this incredibly useful tool: \n");
		printf("In order to enter a student detail, choose 0\n");
		printf("I norder to print the details, choose 1\n");	
		printf("If instead you wish to exit, please key in 2:   ");
		scanf("%s", &op);
		choice = atoi(op);
		
		switch(choice)
		{
			case ENTER:
				stu = enterDetails(stu);
				break;
			case PRINT:
				printDetails(stu);
				break;
			case EXIT:
				leave = 1;
				break;
			default:
				printf("Invalid input, try again.\n");
		}
	}
}
Exemple #4
0
DirPage::DirPage() {
	nextPage = 0;
	prevPage = 0;
	maxSpaceAvailable = 0;
	DEcount = 0;

	memcpy(p,this,sizeof(DirPage));
	writeToPage();
	printDetails();
}
void
ArxDbgEdInputContextReactor::endGetString(Acad::PromptStatus returnStatus, const char*& pString)
{
	printReactorMessage(_T("End Get String"));

	if (printDetails()) {
		printReturnStatus(returnStatus);
		printValue(_T("STRING"), pString);
	}
}
void
ArxDbgEdInputContextReactor::endGetKeyword(Acad::PromptStatus returnStatus, const char*& pKeyword)
{
	printReactorMessage(_T("End Get Keyword"));

	if (printDetails()) {
		printReturnStatus(returnStatus);
		printValue(_T("KEYWORD"), pKeyword);
	}
}
void
ArxDbgEdInputContextReactor::beginGetString(const char* promptString, int initGetFlags)
{
	printReactorMessage(_T("Begin Get String"));

	if (printDetails()) {
		printPrompt(promptString);
		printInitGetFlags(initGetFlags);
	}
}
void
ArxDbgEdInputContextReactor::beginEntsel(const char* promptString,
					int initGetFlags,
					const char* pKeywords)
{
	printReactorMessage(_T("Begin Entsel"));

	if (printDetails()) {
		printPrompt(promptString);
		printInitGetFlags(initGetFlags);
		printKeywords(pKeywords);
	}
}
void
ArxDbgEdInputContextReactor::endGetPoint(Acad::PromptStatus returnStatus,
					const AcGePoint3d& pointOut,
					const char*& pKeyword)
{
	printReactorMessage(_T("End Get Point"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("POINT"), ArxDbgUtils::ptToStr(pointOut, str));
		printKeywordPicked(pKeyword);
	}
}
void
ArxDbgEdInputContextReactor::endGetOrientation(Acad::PromptStatus returnStatus,
                    double& angle,
                    const char*& pKeyword)
{
	printReactorMessage(_T("End GetOrientation"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("ANGLE"), ArxDbgUtils::angleToStr(angle, str));
		printKeywordPicked(pKeyword);
	}
}
void
ArxDbgEdInputContextReactor::endSSGet(Acad::PromptStatus returnStatus,
					const AcArray<AcDbObjectId>& ss)
{
	printReactorMessage(_T("End SSGet"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);

		ArxDbgUiTdmObjects dbox(ss, acedGetAcadDwgView(), _T("SSGet Set"));
		dbox.DoModal();
	}
}
void
ArxDbgEdInputContextReactor::endGetReal(Acad::PromptStatus returnStatus,
					double& returnValue,
					const char*& pKeyword)
{
	printReactorMessage(_T("End Get Real"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("REAL"), ArxDbgUtils::doubleToStr(returnValue, str));
		printKeywordPicked(pKeyword);
	}
}
void
ArxDbgEdInputContextReactor::endGetScaleFactor(Acad::PromptStatus returnStatus,
                    double& distance,
                    const char*& pKeyword)
{
	printReactorMessage(_T("End Get Scale Factor"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("SCALE FACTOR"), ArxDbgUtils::doubleToStr(distance, str));
		printKeywordPicked(pKeyword);
	}
}
void
ArxDbgEdInputContextReactor::endGetColor(Acad::PromptStatus returnStatus,
					int& retValue,
					const char*& pKeyword)
{
	printReactorMessage(_T("End Get Color"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("COLOR"), ArxDbgUtils::colorToStr(retValue, str, true));
		printKeywordPicked(pKeyword);
	}
}
void
ArxDbgEdInputContextReactor::endGetCorner(Acad::PromptStatus returnStatus,
					AcGePoint3d& secondCorner,
					const char*& pKeyword)
{
	printReactorMessage(_T("End Get Corner"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("SECOND CORNER"), ArxDbgUtils::ptToStr(secondCorner, str));
		printKeywordPicked(pKeyword);
	}
}
void
ArxDbgEdInputContextReactor::beginGetScaleFactor(const AcGePoint3d* pointIn,
                    const char* promptString,
                    int initGetFlags,
                    const char* pKeywords)
{
	printReactorMessage(_T("Begin Get Scale Factor"));

	if (printDetails()) {
		printPointIn(pointIn);
		printPrompt(promptString);
		printInitGetFlags(initGetFlags);
		printKeywords(pKeywords);
	}
}
void
ArxDbgEdInputContextReactor::beginGetColor(const int* dfault,
					const char* promptString,
					int initGetFlags,
					const char* pKeywords)
{
	printReactorMessage(_T("Begin Get Color"));

	if (printDetails()) {
		printDefaultInt(dfault);
		printPrompt(promptString);
		printInitGetFlags(initGetFlags);
		printKeywords(pKeywords);
	}
}
void IGLWidget::initializeGL(void)
{
    initializeOpenGLFunctions(); // Do not forget!

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glEnable(GL_TEXTURE_2D);
//  glEnable(GL_DEPTH_TEST);

    if(cv::ocl::haveOpenCL())
    {
        (void)cv::ogl::ocl::initializeContextFromGL(); //FIXME ici
    }

    printDetails();
}
void
ArxDbgEdInputContextReactor::beginGetCorner(const AcGePoint3d* firstCorner,
                    const char* promptString,
                    int   initGetFlags,
                    const char* pKeywords)
{
	printReactorMessage(_T("Begin Get Corner"));

	if (printDetails()) {
		printFirstCorner(firstCorner);
		printPrompt(promptString);
		printInitGetFlags(initGetFlags);
		printKeywords(pKeywords);
	}
}
void
ArxDbgEdInputContextReactor::beginNentsel(const char* promptString,
					Adesk::Boolean pickFlag,
					int initGetFlags,
					const char* pKeywords)
{
	printReactorMessage(_T("Begin Nentsel"));

	if (printDetails()) {
		CString str;
		printPrompt(promptString);
		printValue(_T("PICK FLAG"), ArxDbgUtils::booleanToStr(pickFlag, str));
		printInitGetFlags(initGetFlags);
		printKeywords(pKeywords);
	}
}
void
ArxDbgEdInputContextReactor::endEntsel(Acad::PromptStatus returnStatus,
					AcDbObjectId& entPicked,
					AcGePoint3d& pickPoint,
					const char* pKeyword)
{
	printReactorMessage(_T("End Entsel"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("ENTITY PICKED"), ArxDbgUtils::objToClassAndHandleStr(entPicked, str));
		printValue(_T("PICK POINT"), ArxDbgUtils::ptToStr(pickPoint, str));
		printKeywordPicked(pKeyword);
	}
}
static void multi_dist_build(void *state_distance, const char *id_dist,
                             MknnDistanceParams *params_distance) {
    struct State_Multi_Dist *state_dist = state_distance;
    if (mknn_distanceParams_getString(params_distance,
                                      "normalization_alpha") != NULL) {
        double alpha = mknn_distanceParams_getDouble(params_distance,
                       "normalization_alpha");
        MknnDataset *dataset = mknn_distanceParams_getObject(params_distance,
                               "normalization_dataset");
        if (dataset == NULL)
            my_log_error(
                "the dataset must be provided to autonormalize distances\n");
        auto_normalization(state_dist, alpha, dataset);
    }
    printDetails(state_dist);
}
void
ArxDbgEdInputContextReactor::endNentsel(Acad::PromptStatus returnStatus,
					AcDbObjectId entPicked,
					const AcGePoint3d&  pickPoint,
					const AcGeMatrix3d& xform,
					const resbuf* referenceStack,
					const char* pKeyword)
{
	printReactorMessage(_T("End Nentsel"));

	if (printDetails()) {
		CString str;
		printReturnStatus(returnStatus);
		printValue(_T("ENTITY PICKED"), ArxDbgUtils::objToClassAndHandleStr(entPicked, str));
		printValue(_T("PICK POINT"), ArxDbgUtils::ptToStr(pickPoint, str));
// TBD: need matrix and ref stack
		printKeywordPicked(pKeyword);
	}
}
Exemple #24
0
DirPage::DirPage(long pid):Page(pid){
	DirPage* dp;
	char* buf = new char[sizeof(DirPage)];
	memcpy(buf,p,sizeof(DirPage));
	dp = (DirPage*)buf;
	nextPage = dp->nextPage;
	prevPage = dp->prevPage;
	DEcount = dp->DEcount;
	maxSpaceAvailable = dp->maxSpaceAvailable;
	dirEntries = DirEntry::getAllEntries(p,DEcount);

	for(unsigned long i = 0;i<DEcount;i++){
		lg2("DEs: "<< i<<" " << dirEntries[i]->getPageID() << " "<<dirEntries[i]->getTFS());
	}

	printDetails();

	delete []buf;
}
void
ArxDbgEdInputContextReactor::beginSSGet(const char*  pPrompt,
					int  initGetFlags,
					const char* pKeywords,
					const char* pSSControls, // str in ADS
					const AcArray<AcGePoint3d>& points,
					const resbuf* entMask)
{
	printReactorMessage(_T("Begin SSGet"));

	if (printDetails()) {
		CString str;
		printPrompt(pPrompt);
		printInitGetFlags(initGetFlags);
		printKeywords(pKeywords);
		printValue(_T("SS CONTROLS"), pSSControls);
		printPoints(points);
		printResbufs(_T("ENT MASK"), entMask);
	}
}
Exemple #26
0
/// Verify the select clause is valid against the given data partition.
/// Returns the number of variables that are not in the data partition.
/// This function also simplifies the arithmetic expression if
/// ibis::math::preserveInputExpression is not set.
///
/// @note Simplifying the arithmetic expressions typically reduces the time
/// needed for evaluations, but may introduce a different set of round-off
/// erros in the evaluation process than the original expression.  Set the
/// variable ibis::math::preserveInputExpression to true to avoid this
/// change in error round-off property.
int ibis::selectClause::verify(const ibis::part& part0) const {
    int ierr = 0;
    for (uint32_t j = 0; j < atms_.size(); ++ j) {
        if (ibis::math::preserveInputExpressions == false) {
            ibis::math::term *tmp = atms_[j]->reduce();
            if (tmp != atms_[j]) {
                delete const_cast<ibis::math::term*>(atms_[j]);
                const_cast<mathTerms&>(atms_)[j] = tmp;
            }
        }
        ierr += verifyTerm(*(atms_[j]), part0, this);
    }

    if (ibis::gVerbose > 6) {
        ibis::util::logger lg;
        lg() << "selectClause -- after simplification, ";
        printDetails(lg());
    }
    return ierr;
} // ibis::selectClause::verify
void list_fileNfolder()
{
  char *s;
  int k=0;
  DIR *d;
  struct dirent *dir;
  d = opendir(".");

  if(d)
  {
    i = 0;
    while((dir = readdir(d)) != NULL)
    {
      listDetails[i].sn   = i;   
      listDetails[i].name = dir->d_name; 
      i++;        
    }   
    closedir(d);
    sortList(i);
    printDetails(i);
  }
}
Exemple #28
0
int main()
{
	int n,i;
	char nam[100];
	struct Person*persons;
	printf("Enter the number of persons : ");
	scanf("%d",&n);
	persons=(struct Person*)malloc(sizeof(struct Person)*n);
	for(i=0;i<n;i++)
	{
		printf("Enter the details for person %d\n",i+1);
		printf("Name : ");
		scanf(" %[^\n]s",persons[i].name);
		printf("Address : ");
		scanf(" %[^\n]s",persons[i].address);
		printf("Phone Number : ");
		scanf(" %lld",&persons[i].phone_number);
	}
	
	printf("\nEnter the name of person to be searched : ");
	scanf(" %[^\n]s",nam);
	printDetails(persons,n,nam);
	return 0;
}
void list_childFileNfolder(int choice)
{
   DIR *d;
   struct dirent *dir;
   d = opendir("./");
   int child_choice = choice;

   if(d)
   {
      if(child_choice < i)      
           scd = listDetails[child_choice].name; 
      else
      {
           printf(MAKE_RED_DARK"\nYour choice is %d but the list contains %d", choice, (i-1));
           printf("\nInvalid Input....Try Again...\n\n"RESET_COLOR);
          return;
       }
      closedir(d);
   }
   
   struct stat fileFoldStatus;
   stat(scd, &fileFoldStatus);

   struct passwd *own=getpwuid(fileFoldStatus.st_uid);
    
   int user_read, user_write, user_execute;
   int group_read, group_write, group_execute;
   int other_read, other_write, other_execute;
   
   if((S_ISREG(fileFoldStatus.st_mode)))
   {
        printf(MAKE_RED_DARK"\nFile Name :: %s\n"RESET_COLOR, scd);
        user_read  = ((fileFoldStatus.st_mode &S_IRUSR) ? 1 : 0);
        user_write = ((fileFoldStatus.st_mode &S_IWUSR) ? 1 : 0);
        user_execute = ((fileFoldStatus.st_mode &S_IXUSR) ? 1 : 0);
        
        group_read = ((fileFoldStatus.st_mode &S_IRGRP) ? 1 : 0);
        group_write = ((fileFoldStatus.st_mode &S_IWGRP) ? 1 : 0);
        group_execute = ((fileFoldStatus.st_mode &S_IXGRP) ? 1 : 0);
        
        other_read = ((fileFoldStatus.st_mode &S_IROTH) ? 1 : 0);
        other_write = ((fileFoldStatus.st_mode &S_IWOTH) ? 1 : 0);
        other_execute = ((fileFoldStatus.st_mode &S_IXOTH) ? 1 : 0);
        
        printf("File User  ID  = %d\n", fileFoldStatus.st_uid);
        printf("File Group ID  = %d\n", fileFoldStatus.st_gid);
        printf("File User Name = %s\n", own->pw_name);

        printPermission(user_read, user_write, user_execute, group_read, group_write, group_execute, other_read, other_write, other_execute);
        
   }
   else if(S_ISDIR(fileFoldStatus.st_mode))
   {
       printf(MAKE_RED_DARK"\nDirectory :: %s\n"RESET_COLOR, scd);
       
       DIR *dc;
       struct dirent *dirc;
       
       dc = opendir(scd);
       chdir(scd); 
       
       if(dc)
       {
          i = 0;
          while((dirc = readdir(dc)) != NULL)
          {
              //printf("\t%d\t%s\n", i, dirc->d_name);
              listDetails[i].sn   = i;   
              listDetails[i].name = dirc->d_name;   
              i++;
          }
          sortList(i);
          printDetails(i);
          closedir(dc);
       }
       
       user_read  = ((fileFoldStatus.st_mode &S_IRUSR) ? 1 : 0);
       user_write = ((fileFoldStatus.st_mode &S_IWUSR) ? 1 : 0);
       user_execute = ((fileFoldStatus.st_mode &S_IXUSR) ? 1 : 0);
        
       group_read = ((fileFoldStatus.st_mode &S_IRGRP) ? 1 : 0);
       group_write = ((fileFoldStatus.st_mode &S_IWGRP) ? 1 : 0);
       group_execute = ((fileFoldStatus.st_mode &S_IXGRP) ? 1 : 0);
        
       other_read = ((fileFoldStatus.st_mode &S_IROTH) ? 1 : 0);
       other_write = ((fileFoldStatus.st_mode &S_IWOTH) ? 1 : 0);
       other_execute = ((fileFoldStatus.st_mode &S_IXOTH) ? 1 : 0);
        
       printPermission(user_read, user_write, user_execute, group_read, group_write, group_execute, other_read, other_write, other_execute);
        
   }
   list_fileNfolder(".");
}
Exemple #30
0
/// Fill array names_ and xnames_.  An alias for an aggregation operation
/// is used as the external name for the whole term.  This function
/// resolves all external names first to establish all aliases, and then
/// resolve the names of the arguments to the aggregation functions.  The
/// arithmetic expressions without external names are given names of the
/// form "_hhh", where "hhh" is a hexadecimal number.
void ibis::selectClause::fillNames() {
    names_.clear();
    xnames_.clear();
    if (atms_.empty()) return;

    names_.resize(atms_.size());
    xnames_.resize(xtms_.size());

    // go through the aliases first before making up names
    for (StringToInt::const_iterator it = xalias_.begin();
         it != xalias_.end(); ++ it)
        xnames_[it->second] = it->first;

    // fill the external names
    for (uint32_t j = 0; j < xtms_.size(); ++ j) {
        if (xnames_[j].empty() &&
            xtms_[j]->termType() == ibis::math::VARIABLE) {
            const char *vn = static_cast<const ibis::math::variable*>
                (xtms_[j])->variableName();
            uint64_t jv = atms_.size();
            if (vn[0] == '_' && vn[1] == '_')
                if (0 > ibis::util::decode16(jv, vn+2))
                    jv = atms_.size();
            if (jv < names_.size() && !names_[jv].empty())
                xnames_[j] = names_[jv];
            else
                xnames_[j] = vn;

            // size_t pos = xnames_[j].rfind('.');
            // if (pos < xnames_[j].size())
            //  xnames_[j].erase(0, pos+1);
        }

        if (xnames_[j].empty()) {
            std::ostringstream oss;
            oss << "_" << std::hex << j;
            xnames_[j] = oss.str();
        }
        else {
            if (isalpha(xnames_[j][0]) == 0 && xnames_[j][0] != '_')
                xnames_[j][0] = 'A' + (xnames_[j][0] % 26);
            for (unsigned i = 1; i < xnames_[j].size(); ++ i)
                if (isalnum(xnames_[j][i]) == 0)
                    xnames_[j][i] = '_';
        }
    }

    // fill the argument name
    for (uint32_t j = 0; j < atms_.size(); ++ j) {
        if (! names_[j].empty()) continue; // have a name already

        if (atms_[j]->termType() == ibis::math::VARIABLE &&
            aggr_[j] == ibis::selectClause::NIL_AGGR) {
            names_[j] = static_cast<const ibis::math::variable*>(atms_[j])
                ->variableName();

            // size_t pos = names_[j].rfind('.');
            // if (pos < names_[j].size())
            //  names_[j].erase(0, pos+1);
        }
        if (names_[j].empty()) {
            std::ostringstream oss;
            oss << "__" << std::hex << j;
            names_[j] = oss.str();
        }
        else {
            if (isalpha(names_[j][0]) == 0 && names_[j][0] != '_')
                names_[j][0] = 'A' + (names_[j][0] % 26);
            for (unsigned i = 1; i < names_[j].size(); ++ i)
                if (isalnum(names_[j][i]) == 0)
                    names_[j][i] = '_';
        }
    }

    if (ibis::gVerbose > 2) {
        ibis::util::logger lg;
        lg() << "selectClause::fillNames -- ";
        printDetails(lg());
    }
} // ibis::selectClause::fillNames