Example #1
0
static Bool inupath( int32 matrixok, int32 intype, int32 filltype )
{
  OMATRIX adjustment_matrix ;
  OBJECT *arg ;
  PATHINFO upath ;
  Bool has_matrix = FALSE ;
  int32 nargs = 0 ;
  Bool result ;

  if ( isEmpty(operandstack) )
    return error_handler(STACKUNDERFLOW) ;

  arg = theTop(operandstack) ;
  if ( matrixok )
    if ( (has_matrix = is_matrix_noerror(arg, & adjustment_matrix)) != (int32)0 )
      nargs++ ;

  if ( theStackSize(operandstack) < nargs )
    return error_handler(STACKUNDERFLOW) ;

  arg = stackindex(nargs++, &operandstack) ;

  if ( ! upath_to_path(arg, UPARSE_CLOSE, &upath) )
    return FALSE ;

  /* don't bother stroking upath if it is degenerate, result is the same */
  if ( intype == INSTROKE && thePath(upath) ) { /* convert to outline */
    STROKE_PARAMS params ;

    set_gstate_stroke(&params, &upath, &upath, FALSE) ; /* replace path */

    if ( has_matrix ) {
      params.usematrix = TRUE ;
      matrix_mult( &adjustment_matrix, &thegsPageCTM(*gstateptr), &params.orig_ctm ) ;
    }

    if ( ! dostroke(&params, GSC_ILLEGAL, STROKE_NOT_VIGNETTE) ) { /* replaces original path */
      path_free_list(thePath(upath), mm_pool_temp) ; /* dispose of original path on error */
      return FALSE ;
    }

    HQASSERT(! thePath(upath) ||
             theILineType(upath.lastline) == MYCLOSE ||
             theILineType(upath.lastline) == CLOSEPATH,
             "Path from stroked dostroke is NULL") ;
  }

  result = inpath_common(filltype, thePath(upath), nargs) ;

  path_free_list(thePath(upath), mm_pool_temp) ; /* dispose of path */

  return result ;
}
Example #2
0
/* Common part of insideness testing for gstate paths and userpaths. Path to
   check inside is passed in as inpath, nargs gives number of operands on
   stack before call. */
static Bool inpath_common( int32 filltype, PATHLIST *inpath, int32 nargs )
{
  OBJECT *arg ;
  int32 type ;
  Bool result ;
  Bool inside ;

  if ( theStackSize(operandstack) < nargs )
    return error_handler(STACKUNDERFLOW) ;

  arg = stackindex(nargs++, &operandstack) ;

  type = oType(*arg) ;

  if ( type == OARRAY || type == OPACKEDARRAY ) { /* aperture intersection */
    PATHINFO appath ;

    if ( ! upath_to_path(arg, UPARSE_CLOSE, &appath) )
      return FALSE ;

    result = path_in_path(thePath(appath), inpath, filltype, &inside) ;

    path_free_list(thePath(appath), mm_pool_temp) ;
  } else { /* point in path */
    SYSTEMVALUE px, py, tx, ty ;

    if ( ! object_get_numeric(arg, &py) )
      return FALSE ;

    if ( theStackSize(operandstack) < nargs )
      return error_handler(STACKUNDERFLOW) ;

    arg = stackindex(nargs++, &operandstack) ;

    if ( ! object_get_numeric(arg, &px) )
      return FALSE ;

    MATRIX_TRANSFORM_XY( px, py, tx, ty, & thegsPageCTM(*gstateptr)) ;

    result = point_in_path(tx, ty, inpath, filltype, &inside) ;
  }

  if ( result ) { /* remove consumed operands */
    npop(nargs, &operandstack) ;
    result = push((inside ? &tnewobj : &fnewobj), &operandstack) ;
  }

  return result ;
}
Example #3
0
    bool
    TeaSafe::doExistanceCheck(std::string const &path, EntryType const &entryType) const
    {
        std::string thePath(path);
        char ch = *path.rbegin();
        // ignore trailing slash, but only if folder type
        // an entry of file type should never have a trailing
        // slash and is allowed to fail in this case
        if (ch == '/' && entryType == EntryType::FolderType) {
            std::string(path.begin(), path.end() - 1).swap(thePath);
        }

        SharedTeaSafeFolder parentEntry = doGetParentTeaSafeFolder(thePath);
        if (!parentEntry) {
            return false;
        }

        std::string filename = boost::filesystem::path(thePath).filename().string();


        SharedEntryInfo entryInfo = parentEntry->getEntryInfo(filename);

        if (!entryInfo) {
            return false;
        }

        if (entryInfo->type() == entryType) {
            return true;
        }

        return false;
    }
Example #4
0
    EntryInfo
    TeaSafe::getInfo(std::string const &path)
    {
        StateLock lock(m_stateMutex);
        std::string thePath(path);
        char ch = *path.rbegin();
        // ignore trailing slash, but only if folder type
        // an entry of file type should never have a trailing
        // slash and is allowed to fail in this case
        if (ch == '/') {
            std::string(path.begin(), path.end() - 1).swap(thePath);
        }

        SharedTeaSafeFolder parentEntry = doGetParentTeaSafeFolder(thePath);
        if (!parentEntry) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }

        std::string fname = boost::filesystem::path(thePath).filename().string();
        SharedEntryInfo childInfo = parentEntry->getEntryInfo(boost::filesystem::path(thePath).filename().string());

        if (!childInfo) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }
        return *childInfo;
    }
Example #5
0
/// attempts to implement tab complete by matching the provided string
/// with an entry at the given parent path
std::string tabCompleteTeaSafeEntry(teasafe::TeaSafe &theBfs, std::string const &path)
{
    // make sure path begins with a slash
    std::string thePath(*path.begin() != '/' ? "/" : "");
    thePath.append(path);

    // find out the parent of the thing we're trying to tab complete
    // the item we're trying to tab-complete should be a child of this parent
    boost::filesystem::path bp(path);
    auto parentPath(bp.parent_path().string());

    // get the parent folder
    auto folder = theBfs.getFolder(parentPath);

    // iterate over entries in folder
    auto & entries = folder.listAllEntries();
    for (auto const &it : entries) {

        // try to match the entry with the thing that we want to tab-complete
        auto extracted(it.second->filename().substr(0, bp.filename().string().length()));
        if(extracted == bp.filename()) {
            return it.second->filename(); // match, return name of entry
        }
    }
    return bp.filename().string(); // no match, return non tab-completed token
}
Example #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setFixedSize(467, 304);
    bytesSent = 0;
    ui->lineEdit_localPort->setEnabled(false);
    ui->lineEdit_filePath->setEnabled(false);
    ui->lineEdit_localAddress->setEnabled(false);
    ui->lineEdit_remoteAddress->setEnabled(false);
    ui->progressBar->setValue(0);
    ui->progressBar->setRange(0, 10000);

    connect(&server, SIGNAL(currentStatus(int)), this, SLOT(setCurrentStatus(int)));
    connect(&server, SIGNAL(error(int)), this, SLOT(errorHandler(int)));
    connect(&server, SIGNAL(ipAddress(QString, quint16)),this, SLOT(displayIPAddress(QString, quint16)));
    connect(&server, SIGNAL(bytesSent(qint64)), this, SLOT(updateProgressBar(qint64)));
    connect(&server, SIGNAL(progressRange(qint64)), this, SLOT(setProgressRange(qint64)));

    QFile thePath("C:/imageFilePath_inkPresettingSystem");
    if (thePath.open(QIODevice::ReadOnly)){
        QString dir = thePath.readAll();
        ui->lineEdit_filePath->setText(dir);

        server.setFilePath(dir);
        thePath.close();
    }
}
Example #7
0
XMLParser::XMLParser( char* inPath, DTDVerifier* verifier)
    : fRootTag(NULL), fFilePath(NULL)
{
    StrPtrLen thePath(inPath);
    fFilePath = thePath.GetAsCString();
    fFile.Set(inPath);
    fVerifier = verifier;
}
Example #8
0
//! @brief Read path from file.
void XC::PathTimeSeries::readFromFile(const std::string &fileName)
  {
    // determine the number of data points
    int numDataPoints= 0;
    double dataPoint;
    std::ifstream theFile;

    // first open and go through file counting entries
    theFile.open(fileName.c_str(), std::ios::in);
    if(theFile.bad() || !theFile.is_open())
      {
        std::cerr << getClassName() << "::" << __FUNCTION__
	          << "; WARNING could not open file "
		  << fileName << std::endl;
      }
    else
      {
        while(theFile >> dataPoint)
          {
            numDataPoints++;
            theFile >> dataPoint; // Read in second value of pair
          }
      }
    theFile.close();

    // create a vector and read in the data
    if(numDataPoints != 0)
      {
        // now create the two vector
        thePath.resize(numDataPoints);
        time.resize(numDataPoints);

        // first open the file and read in the data
        std::ifstream theFile1;
        theFile1.open(fileName.c_str(), std::ios::in);
        if(theFile1.bad() || !theFile1.is_open())
          {
            std::cerr << getClassName() << "::" << __FUNCTION__
		      << "; WARNING - could not open file "
		      << fileName << std::endl;
          }
        else
          { // read in the time and then read the value
            int count= 0;
            while(theFile1 >> dataPoint)
              {
                time(count)= dataPoint;
                theFile1 >> dataPoint;
                thePath(count)= dataPoint;
                count++;
              }

            // finally close the file
            theFile1.close();
          }

      }
QString cConfig::mulPath() const
{
	QDir thePath( mulPath_ );
	if ( !thePath.exists() || thePath.entryList( QStringList() << "*.mul" ).isEmpty() )
	{
		// Can't detect under *nix, so just warn the user :(
		qWarning( "Unable to find *.mul files path. Please check wolfpack.xml, section \"General\", key \"MulPath\"" );
	}
	return mulPath_;
}
Example #10
0
//! @brief Returns the value of the factor at the pseudo-time.
//!
//! Determines the load factor based on the \p pseudoTime and the data
//! points. Returns \f$0.0\f$ if \p pseudoTime is greater than time of last
//! data point, otherwise returns a linear interpolation of the data
//! points times the factor \p cFactor.
double XC::PathSeries::getFactor(double pseudoTime) const
  {
    double retval= 0.0;
    if(pseudoTime > 0.0)
      {

        // determine indexes into the data array whose boundary holds the time
        const double incr = pseudoTime/pathTimeIncr;
        const int incr1= static_cast<int>(floor(incr));
        const int incr2= incr1+1;

        if(incr2 <thePath.Size())
          {
            const double value1= thePath(incr1);
            const double value2= thePath(incr2);
            retval= cFactor*(value1 + (value2-value1)*(pseudoTime/pathTimeIncr - incr1));
          }
      }
    return retval;
  }
Example #11
0
std::vector<Coordinate> Path::route() const
{
	std::vector<Coordinate> route;
	long distance = length();
	Path thePath(m_from, m_to);

	for(long i = 0; i < distance; i++)
	{
		route.push_back(thePath.getTo());		//push destination to route
		thePath.setTo(thePath.getTo() - thePath.direction());	//increment destination closer
	}

	return route;
}
Example #12
0
Bool instroke_(ps_context_t *pscontext)
{
  int32 result ;
  STROKE_PARAMS params ;
  PATHINFO spath ;

  UNUSED_PARAM(ps_context_t *, pscontext) ;

  set_gstate_stroke(&params, &thePathInfo(*gstateptr), &spath, FALSE) ;

  if ( ! dostroke(&params, GSC_ILLEGAL, STROKE_NOT_VIGNETTE) )
    return FALSE ;

  HQASSERT(! thePath(spath) ||
           theILineType(spath.lastline) == MYCLOSE ||
           theILineType(spath.lastline) == CLOSEPATH,
           "Path from stroked dostroke is NULL") ;

  result = inpath_common(NZFILL_TYPE, thePath(spath), 0) ;

  path_free_list(thePath(spath), mm_pool_temp) ; /* dispose of stroked path */

  return result ;
}
Example #13
0
/// the 'ls' command for listing dir contents
void com_ls(teasafe::TeaSafe &theBfs, std::string const &path)
{
    // make sure path begins with a slash
    std::string thePath(*path.begin() != '/' ? "/" : "");
    thePath.append(path);

    // iterate over entries in folder and print filenames of each
    auto folder = theBfs.getFolder(thePath);
    auto & entries = folder.listAllEntries();
    for (auto const &it : entries) {
        if (it.second->type() == teasafe::EntryType::FileType) {
            std::cout<<boost::format("%1% %|30t|%2%\n") % it.second->filename() % "<F>";
        } else {
            std::cout<<boost::format("%1% %|30t|%2%\n") % it.second->filename() % "<D>";
        }
    }
}
/*!
	Returns the *.mul files path, extracted from wolfpack.xml
	If the path is not especified or if we can't find the mul files in there,
	this method will query the registry to try to figure where the UO client
	was installed
*/
QString cConfig::mulPath() const
{
	QDir thePath( mulPath_ );
	if ( !thePath.exists() || thePath.entryList( "*.mul" ).isEmpty() )
	{
		Console::instance()->log( LOG_WARNING, tr( "UO Mul files not found at '%1', trying to locate...\n" ).arg( mulPath_ ) );
		QString uoPath( getUOPath() );
		if ( !uoPath.isEmpty() )
		{
			//mulPath_ = uoPath;
			cConfig* that = const_cast<cConfig*>( this ); // perhaps not so const ;)
			that->setMulPath( uoPath );
		}
		else
			Console::instance()->log( LOG_ERROR, tr( "Unable to find *.mul files path. Please check wolfpack.xml, section \"General\", key \"MulPath\"" ) );
	}
	return mulPath_;
}
Example #15
0
void MainWindow::findFile()
{
    QString dir = QFileDialog::getExistingDirectory(this, tr("请选择图像文件的存放目录"),
                                                     "C:",
                                                     QFileDialog::ShowDirsOnly
                                                     | QFileDialog::DontResolveSymlinks);
    QFile thePath("C:/imageFilePath_inkPresettingSystem");
    if (thePath.open(QIODevice::WriteOnly)){
        thePath.write(dir.toUtf8());
        thePath.close();
    }
    if (dir == NULL)
        return;
    bytesSent = 0;
    ui->lineEdit_filePath->setText(dir);

    server.setFilePath(dir);
}
Example #16
0
QTSS_Error CreateRTPFileSession(QTSS_StandardRTSP_Params* inParamBlock, const StrPtrLen& inPath, FileSession** outFile)
{   
    *outFile = NEW FileSession();
    StrPtrLen thePath(inPath);
    RTPFileSession::ErrorCode theErr = (*outFile)->fFile.Initialize(thePath, 8);
    if (theErr != RTPFileSession::errNoError)
    {
        delete *outFile;
        *outFile = NULL;
        
        if (theErr == RTPFileSession::errFileNotFound)
            return QTSSModuleUtils::SendErrorResponse(  inParamBlock->inRTSPRequest,
                                                        qtssClientNotFound,
                                                        sBadQTFileErr);
        AssertV(0, theErr);
    }
    return QTSS_NoErr;
}
Example #17
0
Bool16 CheckWorldDirAccess(char* pathBuff)
{

    Bool16 result = true;
    struct stat statData;
    char searchBuffer[kMaxPathLen] = {};
    StrPtrLen searchPath(searchBuffer, kMaxPathLen -1);
    StrPtrLen thePath(pathBuff);
    
    if (thePath.Len <= searchPath.Len)
    {   
        memcpy(searchBuffer,thePath.Ptr, thePath.Len);
    
        while ( (true == result) && (0 != GetPathParentDestructive(&searchPath, &searchPath, kMaxPathLen)) ) // loop until fail or have checked full directory path and file
        {
            result = false;
                        
            do // once only check for the current entity
            {
                //qtss_printf("stat on %s \n",searchBuffer);
                if (0 != stat(searchBuffer,&statData))
                {   
                    //qtss_printf("no world access to path =%s\n",searchBuffer);
                    result = true; // let the server deal with this one
                    break;
                }           
                    
                //qtss_printf("statData.st_mode = %x \n",statData.st_mode);  
                if (0 == (statData.st_mode & 0001) )
                {   
                    //qtss_printf("no world access to path =%s\n",searchBuffer);
                    result = false;
                    break;
                }
        
                result = true;
                    
            
            } while (false);
        } ;
    }

    return result;
}  
Example #18
0
    void
    TeaSafe::addFolder(std::string const &path) const
    {
        StateLock lock(m_stateMutex);
        std::string thePath(path);
        char ch = *path.rbegin();
        // ignore trailing slash
        if (ch == '/') {
            std::string(path.begin(), path.end() - 1).swap(thePath);
        }

        SharedTeaSafeFolder parentEntry = doGetParentTeaSafeFolder(thePath);
        if (!parentEntry) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }

        // throw if already exists
        throwIfAlreadyExists(path);

        parentEntry->addTeaSafeFolder(boost::filesystem::path(thePath).filename().string());
    }
Example #19
0
    void
    TeaSafe::addFile(std::string const &path)
    {
        StateLock lock(m_stateMutex);
        std::string thePath(path);
        char ch = *path.rbegin();
        // file entries with trailing slash should throw
        if (ch == '/') {
            throw TeaSafeException(TeaSafeError::IllegalFilename);
        }

        SharedTeaSafeFolder parentEntry = doGetParentTeaSafeFolder(thePath);
        if (!parentEntry) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }

        // throw if already exists
        throwIfAlreadyExists(path);

        parentEntry->addTeaSafeFile(boost::filesystem::path(thePath).filename().string());
    }
Example #20
0
    void
    TeaSafe::removeFolder(std::string const &path, FolderRemovalType const &removalType)
    {
        StateLock lock(m_stateMutex);
        std::string thePath(path);
        char ch = *path.rbegin();
        // ignore trailing slash, but only if folder type
        // an entry of file type should never have a trailing
        // slash and is allowed to fail in this case
        if (ch == '/') {
            std::string(path.begin(), path.end() - 1).swap(thePath);
        }

        SharedTeaSafeFolder parentEntry = doGetParentTeaSafeFolder(thePath);
        if (!parentEntry) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }

        SharedEntryInfo childInfo = parentEntry->getEntryInfo(boost::filesystem::path(thePath).filename().string());
        if (!childInfo) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }
        if (childInfo->type() == EntryType::FileType) {
            throw TeaSafeException(TeaSafeError::NotFound);
        }

        if (removalType == FolderRemovalType::MustBeEmpty) {

            TeaSafeFolder childEntry = parentEntry->getTeaSafeFolder(boost::filesystem::path(thePath).filename().string());
            if (!childEntry.listAllEntries().empty()) {
                throw TeaSafeException(TeaSafeError::FolderNotEmpty);
            }
        }

        parentEntry->removeTeaSafeFolder(boost::filesystem::path(thePath).filename().string());

        // also remove entry from parent cache
        this->removeDeletedParentFromCache(boost::filesystem::path(thePath));

    }
Example #21
0
/* Intersect a userpath aperture with a path. Fill rule applied to aperture
   in NZFILL_TYPE, fill type applied to path is filltype. Note that makeconvex
   and cliptoall free their argument paths, so only the flattened paths
   need to be freed */
Bool path_in_path(PATHLIST *appath, PATHLIST *path, int32 filltype,
                  Bool *inside)
{
  PATHINFO apath, fpath ;

  if ( ! appath || ! path) { /* can't be inside a degenerate path */
    *inside = FALSE ;
    return TRUE ;
  }

  /* prepare both paths, using filltype for path and NZFILL for aperture */
  fl_setflat( theFlatness( theLineStyle(*gstateptr))) ;
  if ( ! path_flatten(appath, &apath) ||
       ! normalise_path(&apath, NZFILL_TYPE, FALSE, FALSE) )
    return FALSE ;

  if ( ! thePath(apath) ) {
    *inside = FALSE ;
    return TRUE ;
  }

  if ( ! path_flatten(path, &fpath) ||
       ! normalise_path(&fpath, filltype, FALSE, FALSE) ) {
    path_free_list(thePath(apath), mm_pool_temp) ;
    return FALSE ;
  }

  if ( ! thePath(fpath) ) {
    path_free_list(thePath(apath), mm_pool_temp) ;
    *inside = FALSE ;
    return TRUE ;
  }

  /* intersect aperture and path */
  if ( ! cliptoall(&apath, &fpath, &apath, FALSE) )
    return FALSE ;

  if ( thePath(apath) ) {
    *inside = TRUE ; /*  if it's not degenerate, aperture is painted */
    path_free_list(thePath(apath), mm_pool_temp) ;
  } else
    *inside = FALSE ; /* if clip is degenerate, it's not inside */

  return TRUE ;
}
Example #22
0
int wxFileDialog::ShowModal()
{
    wxBeginBusyCursor();

    //  static char fileBuf[512];
    Widget parentWidget = (Widget) 0;
    if (m_parent)
        parentWidget = (Widget) m_parent->GetTopWidget();
    else
        parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
    // prepare the arg list
    Display* dpy = XtDisplay(parentWidget);
    Arg args[10];
    int ac = 0;

    if (m_backgroundColour.IsOk())
    {
        wxComputeColours (dpy, & m_backgroundColour, NULL);

        XtSetArg(args[ac], XmNbackground, g_itemColors[wxBACK_INDEX].pixel); ac++;
        XtSetArg(args[ac], XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel); ac++;
        XtSetArg(args[ac], XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel); ac++;
        XtSetArg(args[ac], XmNforeground, g_itemColors[wxFORE_INDEX].pixel); ac++;
    }

    wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);

#if __WXMOTIF20__ && !__WXLESSTIF__
    XtSetArg(args[ac], XmNbuttonRenderTable, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNlabelRenderTable, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNtextRenderTable, font.GetFontTypeC(dpy)); ac++;
#else
    XtSetArg(args[ac], XmNbuttonFontList, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNlabelFontList, font.GetFontTypeC(dpy)); ac++;
    XtSetArg(args[ac], XmNtextFontList, font.GetFontTypeC(dpy)); ac++;
#endif

    Widget fileSel = XmCreateFileSelectionDialog(parentWidget,
                                                 wxMOTIF_STR("file_selector"),
                                                 args, ac);
#define wxFSChild( name ) \
    XmFileSelectionBoxGetChild(fileSel, name)

    XtUnmanageChild(wxFSChild(XmDIALOG_HELP_BUTTON));

    Widget filterWidget = wxFSChild(XmDIALOG_FILTER_TEXT);
    Widget selectionWidget = wxFSChild(XmDIALOG_TEXT);
    Widget dirListWidget = wxFSChild(XmDIALOG_DIR_LIST);
    Widget fileListWidget = wxFSChild(XmDIALOG_LIST);

    // for changing labels
    Widget okWidget = wxFSChild(XmDIALOG_OK_BUTTON);
    Widget applyWidget = wxFSChild(XmDIALOG_APPLY_BUTTON);
    Widget cancelWidget = wxFSChild(XmDIALOG_CANCEL_BUTTON);
    Widget dirlistLabel = wxFSChild(XmDIALOG_DIR_LIST_LABEL);
    Widget filterLabel = wxFSChild(XmDIALOG_FILTER_LABEL);
    Widget listLabel = wxFSChild(XmDIALOG_LIST_LABEL);
    Widget selectionLabel = wxFSChild(XmDIALOG_SELECTION_LABEL);

#undef wxFSChild

    // change labels
    wxXmString btnOK( wxGetStockLabel( wxID_OK, false ) ),
               btnCancel( wxGetStockLabel( wxID_CANCEL, false ) ),
               btnFilter( _("Filter") ), lblFilter( _("Filter") ),
               lblDirectories( _("Directories") ),
               lblFiles( _("Files" ) ), lblSelection( _("Selection") );

    XtVaSetValues( okWidget, XmNlabelString, btnOK(), NULL );
    XtVaSetValues( applyWidget, XmNlabelString, btnFilter(), NULL );
    XtVaSetValues( cancelWidget, XmNlabelString, btnCancel(), NULL );
    XtVaSetValues( dirlistLabel, XmNlabelString, lblDirectories(), NULL );
    XtVaSetValues( filterLabel, XmNlabelString, lblFilter(), NULL );
    XtVaSetValues( listLabel, XmNlabelString, lblFiles(), NULL );
    XtVaSetValues( selectionLabel, XmNlabelString, lblSelection(), NULL );

    Widget shell = XtParent(fileSel);

    if ( !m_message.empty() )
        XtVaSetValues(shell,
                      XmNtitle, (const char*)m_message.mb_str(),
                      NULL);

    if (!m_wildCard.empty())
    {
        // return something understandable by Motif
        wxString wildCard = ParseWildCard( m_wildCard );
        wxString filter;
        if (!m_dir.empty())
            filter = m_dir + wxString("/") + wildCard;
        else
            filter = wildCard;

        XmTextSetString(filterWidget, filter.char_str());
        XmFileSelectionDoSearch(fileSel, NULL);
    }

    // Suggested by Terry Gitnick, 16/9/97, because of change in Motif
    // file selector on Solaris 1.5.1.
    if ( !m_dir.empty() )
    {
        wxXmString thePath( m_dir );

        XtVaSetValues (fileSel,
            XmNdirectory, thePath(),
            NULL);
    }

    wxString entirePath;

    if (!m_dir.empty())
    {
        entirePath = m_dir + wxString("/") + m_fileName;
    }
    else
    {
        entirePath = m_fileName;
    }

    if (!entirePath.empty())
    {
        XmTextSetString(selectionWidget, entirePath.char_str());
    }

    XtAddCallback(fileSel, XmNcancelCallback,
                  (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
    XtAddCallback(fileSel, XmNokCallback,
                  (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
    XtAddCallback(fileSel, XmNunmapCallback,
                  (XtCallbackProc)wxFileSelClose, (XtPointer)this);

    //#if XmVersion > 1000
    // I'm not sure about what you mean with XmVersion.
    // If this is for Motif1.1/Motif1.2, then check XmVersion>=1200
    // (Motif1.1.4 ==> XmVersion 1100 )
    // Nevertheless, I put here a #define, so anyone can choose in (I)makefile.
    //
#if !DEFAULT_FILE_SELECTOR_SIZE
    int width = wxFSB_WIDTH;
    int height = wxFSB_HEIGHT;
    XtVaSetValues(fileSel,
        XmNwidth, width,
        XmNheight, height,
        XmNresizePolicy, XmRESIZE_NONE,
        NULL);
#endif
    wxDoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE);
    wxDoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE);

    wxChangeListBoxColours(this, dirListWidget);
    wxChangeListBoxColours(this, fileListWidget);

    XtManageChild(fileSel);

    m_fileSelectorAnswer = wxEmptyString;
    m_fileSelectorReturned = false;

    wxEndBusyCursor();

    XtAddGrab(XtParent(fileSel), True, False);
    XtAppContext context = (XtAppContext) wxTheApp->GetAppContext();
    XEvent event;
    while (!m_fileSelectorReturned)
    {
        XtAppNextEvent(context, &event);
        XtDispatchEvent(&event);
    }
    XtRemoveGrab(XtParent(fileSel));

    XtUnmapWidget(XtParent(fileSel));
    XtDestroyWidget(XtParent(fileSel));

    // Now process all events, because otherwise
    // this might remain on the screen
    wxFlushEvents(XtDisplay(fileSel));

    m_path = m_fileSelectorAnswer;
    m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
    m_dir = wxPathOnly(m_path);

    if (m_fileName.empty())
        return wxID_CANCEL;
    else
        return wxID_OK;
}
Example #23
0
/** Create and link the DL structures for the clips happening to the current
   object. Essentially, this means chasing down the cliprecord structure for
   the current gstate (including imposition clips), creating CLIPOBJECTs and
   filling in the bress structure, bbox, fill rules and other information,
   until such point as we find a cliprecord for which this has already been
   done, and linking them together with the top clip pointing down the chain.
   The clipping form (or forms) state is tracked at render time, and
   regenerated using pointers to these CLIPOBJECTs to determine how much has
   been done. */
static Bool prepare_dl_clipping(DL_STATE *page, CLIPRECORD *cliprec,
                                CLIPOBJECT * pExistingContext,
                                Bool imposition,
                                Bool fWithRecombine,
                                CLIPOBJECT **clipptr)
{
  CLIPRECORD *previous ;
  CLIPOBJECT *context = NULL ;
  NFILLOBJECT *nfill = NULL ;
  uint8 cliptype = 0 ;
  int32 device = CURRENT_DEVICE() ;
  uint16 ncomplex = 0 ;

  int32 x1c , y1c , x2c , y2c ;

  HQASSERT(cliprec, "No current clip to dl_clipping") ;

  if ( (theClipType(*cliprec) & CLIPISDEGN) != 0 ) {
    *clipptr = NULL ;
    return TRUE ; /* Nothing to do if degenerate */
  }

  *clipptr = clipObjectLookup(page->stores.clip, cliprec->clipno,
                              pageBaseMatrixId) ;
  if ( *clipptr != NULL )
    return TRUE ; /* We've done it all already */

  HQASSERT(device != DEVICE_NULL, "null device should have degenerate clip") ;

  /* Use recursion to ensure that all previous clip objects have been set up */
  previous = cliprec->next ;
  if ( previous == NULL && ! imposition &&
       device != DEVICE_PATTERN1 && device != DEVICE_PATTERN2 &&
       pExistingContext == NULL ) {
    /* Build imposition clip list */
    previous = theClipRecord(impositionclipping) ;
    imposition = TRUE ;
  }

  x1c = theX1Clip(*cliprec) ;
  y1c = theY1Clip(*cliprec) ;
  x2c = theX2Clip(*cliprec) ;
  y2c = theY2Clip(*cliprec) ;
  if ( previous != NULL ) {     /* Check back down chain */
    /* Create clip context for previous record. */
    if ( ! prepare_dl_clipping(page, previous, pExistingContext,
                               imposition, fWithRecombine, &context) )
      return FALSE ;

    /* Check if noted as degenerate, and propagate to this record if so */
    if ( (theClipType(*previous) & CLIPISDEGN) != 0 ) {
      theClipType(*cliprec) |= CLIPISDEGN ;
      return TRUE ;
    }

    HQASSERT(context,
             "dl_clipping failed to initialise previous clip object") ;

    ncomplex = context->ncomplex ;

    if ( x1c < theX1Clip(*previous))
      theX1Clip(*cliprec) = x1c = theX1Clip(*previous) ;
    if ( y1c < theY1Clip(*previous))
      theY1Clip(*cliprec) = y1c = theY1Clip(*previous) ;

    if ( x2c > theX2Clip(*previous))
      theX2Clip(*cliprec) = x2c = theX2Clip(*previous) ;
    if ( y2c > theY2Clip(*previous))
      theY2Clip(*cliprec) = y2c = theY2Clip(*previous) ;

    if ( x1c > x2c || y1c > y2c ) {
      theClipType(*cliprec) |= CLIPISDEGN ;
      return TRUE ;
    }
  } else if (pExistingContext != NULL) {
    /* In most circumstances, we'll have the CLIPRECORD chain to work from,
       but in the case of adjusting the clipping during the postprocessing
       pass of recombine we don't have that luxury so if we're changing the
       clipping (as we do for overprinted vignette objects) we need to refer
       to the existing CLIPOBJECT from the dl object's state */
    context = pExistingContext;
    ncomplex = context->ncomplex ;

    HQASSERT (x1c >= theX1Clip(*context) &&
              y1c >= theY1Clip(*context) &&
              x2c <= theX2Clip(*context) &&
              y2c <= theY2Clip(*context),
              "cliprec's clipping is not a subset of context's");
  }

  /* We need the clip boundaries before flattening the path, in case
     parts of it are clipped out. */
  bbox_store(&cclip_bbox, x1c, y1c, x2c, y2c) ;
  HQASSERT(bbox_is_normalised(&cclip_bbox), "clip out of order(pre)") ;

  /* Rectangle has no fill, skip to clip object creation */
  if ( (theClipType(*cliprec) & CLIPISRECT) == 0 ) {
    USERVALUE flat ;
    dbbox_t bbox = { 0 } ;

    /* First of all flatten path. */
    flat = theClipFlat(*cliprec) ;

    /* flat is negative if the fill is already prepared and present in the
       clip record. This will only happen when the clip is artificial -
       provided as a side effect of vignette detection and applied to prevent
       problems with overprinting and color management */
    if (flat <  0.0) {
      nfill = cliprec->u.nfill;
    } else {
      if ( flat == 0.0f ) {
        flat = theFlatness(theLineStyle(*gstateptr)) ;
        HQASSERT(flat >= 0.0f, "Gstate flatness negative") ;
        theClipFlat(*cliprec) = flat ;
      }
      fl_setflat( flat ) ;

      if ( !make_nfill(page, thePath(theClipPath(*cliprec)), NFILL_ISCLIP,
                       &nfill) )
        return FALSE ;
    }

    /* If pExistingContext is not NULL, we are supplying a ready made fill,
       and the globals which control the fill are not valid. */
    if ( nfill == NULL ) {
      theClipType(*cliprec) |= CLIPISDEGN ;
      return TRUE ;
    } else {
      Bool clipped;

    /* Do BB calculation and degenerate detection a' la addnbressfill.
       Note that the memory used by the nfill may be wasted, but we can't
       just chuck it away in case it was shared with another clip. */

      bbox_nfill(nfill, &cclip_bbox, &bbox, &clipped);
      if ( clipped ) {
        if ( flat >= 0.0f ) /* Did we just create that fill above? */
          free_fill(nfill, page) ;
        theClipType(*cliprec) |= CLIPISDEGN ;
        return TRUE ;
      }
    }

    cliptype = theClipType(*cliprec) ;
    ncomplex += 1 ;     /* Add this fill to number of complex clips */

    /* Add nfill to nfill cache */
    {
      NFILLCACHE nfillcache ;
      NFILLCACHE* cached ;

      nfillcache.nfill = nfill ;

      cached = (NFILLCACHE*)dlSSInsert( page->stores.nfill,
                                        &nfillcache.storeEntry, TRUE );
      if (cached == NULL) {
        return error_handler( VMERROR ) ;
      }
      nfill = cached->nfill;

      /* Dispose of this fill if we found a different one in the cache */
      if ( nfill != nfillcache.nfill ) {
        /* Free our copy of this fill if used for clipping solely.
           A vignette may use the nfill as a fill and a clip */
        if ( pExistingContext == NULL )
          free_fill( nfillcache.nfill , page ) ;
      } else if (fWithRecombine) {
        /* Else add recombine fuzzy trap info (if required). */
        PATHINFO *tmppath = &theClipPath(*cliprec) ;
        (void)path_bbox(tmppath, NULL, BBOX_IGNORE_ALL|BBOX_SAVE) ;

        if ( !rcbt_addtrap(page->dlpools, nfill, tmppath, FALSE /* fDonut */, NULL) )
          return FALSE ;
      }
    }

    /* Reduce the clip area to exactly the area touched by the path. */
    if ( (cliptype & CLIPINVERT) == 0 ) {
      theX1Clip(*cliprec) = x1c = bbox.x1 ;
      theY1Clip(*cliprec) = y1c = bbox.y1 ;
      theX2Clip(*cliprec) = x2c = bbox.x2 ;
      theY2Clip(*cliprec) = y2c = bbox.y2 ;

      HQASSERT( x1c <= x2c , "x clip out of order(pst)" ) ;
      HQASSERT( y1c <= y2c , "y clip out of order(pst)" ) ;
    }

    if ( !dl_reserve_band(page, RESERVED_BAND_CLIPPING) )
      return FALSE ;

    if ( device == DEVICE_PATTERN1 || device == DEVICE_PATTERN2 ) {
      if ( ncomplex > 1 &&     /* Fourth band for nested pattern clipping */
           !dl_reserve_band(page, RESERVED_BAND_PATTERN_CLIP) )
        return FALSE ;
    }
  }

  /* We need to create a CLIPOBJECT for the clip, and fill in the relevant
     info */
  {
    CLIPOBJECT theclip;

    theX1Clip(theclip) = x1c ;
    theY1Clip(theclip) = y1c ;
    theX2Clip(theclip) = x2c ;
    theY2Clip(theclip) = y2c ;
    theclip.context = context ;
    theclip.fill = nfill ;
    theclip.rule = cliptype ;
    theclip.ncomplex = ncomplex ;
    theclip.clipno = cliprec->clipno ;
    theclip.pagebasematrixid = pageBaseMatrixId ;

    /* Insert clip object into clip cache. */
    *clipptr = (CLIPOBJECT*)dlSSInsert(page->stores.clip,
                                       &theclip.storeEntry, TRUE) ;
    if ( *clipptr == NULL ) {
      return error_handler(VMERROR) ;
    }
  }

  return TRUE ;
}
Example #24
0
/// the 'mkdir' command for adding a folder to the current working dir
void com_mkdir(teasafe::TeaSafe &theBfs, std::string const &path)
{
    std::string thePath(*path.begin() != '/' ? "/" : "");
    thePath.append(path);
    theBfs.addFolder(thePath);
}
Example #25
0
/// the 'rm' command for removing a folder or file
void com_rm(teasafe::TeaSafe &theBfs, std::string const &path)
{
    std::string thePath(*path.begin() != '/' ? "/" : "");
    thePath.append(path);
    teasafe::utility::removeEntry(theBfs, thePath);
}
Example #26
0
Bool16 CheckDirAccess(struct passwd *passwdStructPtr, StrPtrLen */*nameStrPtr*/, char* pathBuff)
{
    Bool16 result = true;

    char searchBuffer[kMaxPathLen] = {};
    StrPtrLen searchPath(searchBuffer, kMaxPathLen -1);
    StrPtrLen thePath(pathBuff);
    
/*
    for each directory in path until fail
         if the user is the owner then
            if owner access then succeed-continue
            else fail - stop
            
        if user is in group then
            if group access then succeed-continue
            else fail - stop
            
        if guest access then
            succeed - continue
            else fail - stop
*/

    if (thePath.Len <= searchPath.Len)
    {   
        memcpy(searchBuffer,thePath.Ptr, thePath.Len);
    
        while ( (true == result) && (0 != GetPathParentDestructive(&searchPath, &searchPath, kMaxPathLen)) ) // loop until fail or have checked full directory path and file
        {
            result = false;
                        
            do // once only check for the current entity
            {
                struct stat statData;
                
                int statResult =  stat(searchBuffer,&statData);
                    
                if (0 != statResult)
                {   
                    //qtss_printf("no access to path =%s\n",searchBuffer);
                    result = true; // let the error be handled in the server
                    break; //  allow
                }   
            
        

                if ( statData.st_uid == (UInt16) passwdStructPtr->pw_uid) // check if owner
                {
                    if  (  (statData.st_mode & 0100 ) != 0 ) // has owner search access
                    {   //qtss_printf("owner search access to directory =%s\n",pathBuff); 
                        result = true;
                        break;
                    }
                    else
                    {   //qtss_printf("no owner search access to directory =%s\n",pathBuff); 
                        result = false;
                        break;
                    
                    }
                }
                
                
                if (statData.st_gid == (UInt16) passwdStructPtr->pw_gid)  // check if user's default group owns
                {
                    if  ( (statData.st_mode & 0010) != 0 ) // has group search access
                    {   //qtss_printf("user default group has search access to directory =%s\n",pathBuff); 
                        result = true;
                        break;
                    }
                    else
                    {   //qtss_printf("user default group has no search access to directory =%s\n",pathBuff); 
                        result = false;
                        break;
                    }
                
                }

                if (IsUserMember(passwdStructPtr->pw_uid, statData.st_gid)) // check if user in group
                {
                    if  ( (statData.st_mode & 0010) != 0 ) // has group search access
                    {   //qtss_printf("user member group has search access to directory =%s\n",pathBuff); 
                        result = true;
                        break;
                    }
                    else
                    {   //qtss_printf("user member group has no search access to directory =%s\n",pathBuff); 
                        result = false;
                        break;
                    }
                
                }
                
                if  ( (statData.st_mode & 0001) != 0 ) // has world search access
                {       
                    //qtss_printf("world has search access to directory =%s\n",pathBuff); 
                    result = true;
                    break;
                    
                }
                
                //qtss_printf("world has no search access to directory =%s\n",pathBuff); 
                result = false;

                                
            } while (false);
            
        } 

    }
    
    
    if (!result) 
    {   
        //qtss_printf("CheckDirAccess failed for %s on file %s\n",nameStrPtr->Ptr, searchBuffer);
    }
    else
    {
        //qtss_printf("success on file %s for %s\n",searchBuffer, nameStrPtr->Ptr);
    }
    
    return result;
}   
Example #27
0
/** Construct a \c CLIPOBJECT chain on the stack representing the \c
    CLIPRECORD chain, and call \c regenerate_clipping() when at the bottom of
    the chain. */
static Bool fillclip_recurse(DL_STATE *page, render_info_t *p_ri,
                             CLIPRECORD *rec, int32 clipmapid,
                             CLIPOBJECT *clipobject, CLIPOBJECT *topclip)
{
  HQASSERT(clipobject != NULL, "No current clip object") ;
  HQASSERT(topclip != NULL, "No top clip object") ;

  for (;;) {
    Bool result ;

    if ( rec == NULL || rec->clipno == clipmapid ) {
      render_tracker_t *renderTracker = p_ri->p_rs->cs.renderTracker ;
      uint32 sema = 0 ;

      HQASSERT(clipobject != topclip,
               "Should have had at least one complex clip record") ;

      /* We reached the record representing the current state of the
         front-end clipping. The previous clip record links to clipobject, so
         we need to make it usable. We'll turn it into a rectangular clip the
         same size as the top clip, and put the clipmapid into it, so it's
         used as a stop record by regenerate_clipping(), but doesn't
         contribute to the filled mask. */
      clipobject->bounds = topclip->bounds ;
      clipobject->context = NULL ;
      clipobject->fill = NULL ;
      clipobject->ncomplex = 0 ;
      clipobject->rule = CLIPISRECT ;
      clipobject->clipno = clipmapid ;
      clipobject->pagebasematrixid = PAGEBASEID_INVALID ;

      if ( rec == NULL ) {
        /* Ran out of clips because we reached the end of the CLIPRECORD
           chain. The clipping form we are going to use was inserted in the
           character's render state by render_state_mask, but it has no form
           memory associated with it. If this is the first clip, allocate a
           clip map from the basemap. clipmapid is used to determine if the
           basemap data is damaged, and needs repairing. */
        renderTracker->clipping = CLIPPING_firstcomplex ;
        renderTracker->clippingformstate = NULL ;

        if ( (sema = newclipmap(p_ri)) == 0 )
          return error_handler(VMERROR) ;
      } else {
        renderTracker->clipping = CLIPPING_complex ;
        renderTracker->clippingformstate = clipobject ;
      }

      result = regenerate_clipping(p_ri, topclip) ;

      if ( sema != 0 )
        free_basemap_semaphore(sema) ;

      return result ;
    } else if ( (theClipType(*rec) & CLIPISRECT) == 0 ) {
      /* Construct a clip object for the complex clip record. */
      CLIPOBJECT next_clipobject ;
      USERVALUE flat ;

      /* Don't bother shrinking the bounds to the path. */
      clipobject->bounds = rec->bounds ;
      clipobject->context = &next_clipobject ;
      clipobject->rule = rec->cliptype ;
      clipobject->clipno = rec->clipno ;
      clipobject->ncomplex = 1 ;
      clipobject->pagebasematrixid = PAGEBASEID_INVALID ;

      flat = theClipFlat(*rec) ;
      if ( flat == 0.0f )
        flat = theFlatness(theLineStyle(*gstateptr)) ;
      fl_setflat(flat) ;

      /* Not going to DL, don't allocate extra nodes */
      if ( !make_nfill(page, thePath(theClipPath(*rec)), NFILL_ISCLIP,
                       &clipobject->fill) )
        return FALSE ;

      result = fillclip_recurse(page, p_ri, rec->next,
                                clipmapid, &next_clipobject, topclip) ;

      free_fill(clipobject->fill, page) ;

      return result ;
    } else {
      /* Rect clip; skip this record, an overriding complex will be further
         resticted. */
      rec = rec->next ;
    }
  }
}