Ejemplo n.º 1
0
int
operator == (const UAS_String &s1, const char *cp) {
    if (!cp) {
        return s1.length() == 0;
    }
    if (strlen (cp) != s1.length())
        return 0;
    return !memcmp (cp, (char *) s1, s1.length());
}
Ejemplo n.º 2
0
Archivo: EnvMgr.C Proyecto: juddy/edcde
// fqlToFilePath()
//
// convert a fully qualified locator to the infolib's absolute path,
// as resolved during the load phase. This function is expecting only
// fully qualified forms which include the "INFOLIB=<path>" part, such
// as are returned by the UAS_Common method "locator()", and serves to
// extract the "path".
//
// Caution: An fql does not have to have the "INFOLIB=" part...
//          Could add insurance check for that here to be more robust.
//
UAS_String
EnvMgr::fqlToFilePath( UAS_String fulloc )
{
  UAS_String discard;

  fulloc.split ('=', discard, fulloc);
  fulloc.split ('&', fulloc, discard);
  return fulloc ;
}
Ejemplo n.º 3
0
UAS_String
UAS_String::operator + (const UAS_String &more) {
    int newLength = length() + more.length();
    char *ptr = new char[newLength + 1];
    (void) memcpy (ptr, fStringRep->fData, fStringRep->fDataSize);
    (void) memcpy (ptr + fStringRep->fDataSize,
                   more.fStringRep->fData,
                   more.fStringRep->fDataSize);
    ptr[newLength] = 0;
    //
    // The following two lines are weird but serve to
    // remove and extra malloc/copy.
    //
    UAS_String rval (ptr, newLength, UAS_NOT_OWNER);
    rval.fStringRep->fOwner = UAS_OWNER;
    return rval;
}
Ejemplo n.º 4
0
UAS_Pointer<UAS_Common>
UAS_Factory::create (const UAS_String &locator) {
    UAS_String access, rest;
    locator.split (':', access, rest);
    if (access == "") {
	throw (UAS_Exception((char*)UAS_String(
		CATGETS(Set_UAS_Base, 1,
			"No access part provided in locator (URL)."))));
    }
    UAS_Factory *theFactory = UAS_Factory::lookup(access);
    if (theFactory == 0) {
	char buf[BUFSIZ];
	(void) snprintf (buf, sizeof(buf), CATGETS(Set_UAS_Base, 2,
				     "Don't know how to create %s: objects"),
			(char*)access);

	throw (UAS_Exception(buf));
    }
    return theFactory->create_object (locator);
}
Ejemplo n.º 5
0
Archivo: EnvMgr.C Proyecto: juddy/edcde
UAS_List<UAS_String>
EnvMgr::sectionStringToList( const UAS_String & s_sections )
{
  // ... currently only handles a comma-separated list
  // ... for section "range" specifiers, need to make second pass
  //     on results of following, which will require some kind of
  //     dive into the UAS to interpret what a "range" of sections
  //     means, at the moment. This was to only apply with "-print",
  //     though.
  return s_sections.splitFields (SLSEP);

//   UAS_List initial_cut = s_sections.splitFields (SLSEP);
//   UAS_String  doc_locator, start_doc, end_doc ;
// 
//   for (int i = 0; i < docs.length(); i++)
//   {
//     (*(initial_cut[i])).split( '-', start_doc, end_doc ) ;
//     initial_cut.insert( start_doc.length() ? start_doc : end_doc ) ;
//     ... duely process rest of any range here to build "expanded_list" ...
//   }
//   return expanded_list;
}
Ejemplo n.º 6
0
Archivo: EnvMgr.C Proyecto: juddy/edcde
// parse_cmdline()
//
// Extracts info from command line and sets up internal flags.
// -1 returned on error. Innocuous problems ignored, like if no arg
// provided where we might have a default or environment variable
// specified. Caller should do "usage()" on error return, as this
// method flags rather than performs it. 
//
int
EnvMgr::parse_cmdline( int     argc_i,
                       char ** argv_i )
{
    for (int i = 1; i < argc_i; i++)
    {	
      if(strcmp(argv_i[i], "-help") == 0 ||
         strcmp(argv_i[i], "-h") == 0)
      {
	// Print a summary of the command's syntax.
        return -1;
      }
      else if (strcmp(argv_i[i], "-l") == 0 ||
               strcmp(argv_i[i], "-lib") == 0 )
      {
        // get infolibs from command line
        i++;
        if( ( i < argc_i ) && ( argv_i[i][0] != '-' ) )
        {
          // This arg gives an absolute file path to an information
          // library, or the short name of the library (which will be
          // used for substitution into the search path specified by
          // DTINFOLIBSEARCHPATH in order to locate the infolib).
          // If the -l option is not provided, the browser displays
          // the default information library by path obtained from
          // substituting DTINFOLIBDEFAULT into DTINFOLIBSEARCHPATH.
          // [DTINFOLIBDEFAULT should be a single library short name.]
          // The "-l" option may be specified more than once.

          UAS_String pathname;

          if( !strchr( argv_i[i], ':' ) )
          {
            char *tmp = infolibStringToPath(argv_i[i]);
            if( tmp )
            {
              pathname = UAS_String(tmp);
              if( tmp != argv_i[i] )  XtFree(tmp);	// clean-up case
            }
          }
          else   // defer validation if arg contains colon separators
            pathname = UAS_String(argv_i[i]);  

          if( pathname.length() != 0 )
            if( f_infolibsStr.length() != 0 )
            {
              // need to concatenate
              f_infolibsStr = f_infolibsStr + ":" + pathname ;
            }
            else
            {
              // init string
              f_infolibsStr = pathname ;
            }
          else
          {
            // invalid infolib--display error message, but not fatal
            message_mgr().error_dialog (
                  (char*)UAS_String(CATGETS(Set_AddLibraryAgent, 5,
                  "Infolib specification format error.")));
          }
        }
      //else ... ignore this one
      }
      else if (strcmp(argv_i[i], "-sect") == 0 ||
               strcmp(argv_i[i], "-section") == 0 )
      {
        // get a list of sections from the command line
        i++;
        if( ( i < argc_i ) && ( argv_i[i][0] != '-' ) )
        {
	  // This arg specifies the infolib section (or a comma-separated
          // list of sections) via their unique locator IDs to either
          // display or print. 
	  // Sections can be specified using the hyphen character to
          // represent a range of sections, although it is up the print
          // interface to resolve what such a range means. Note that a
          // section "range" is only predictable within the same version
          // of an infolib from which it was mapped.
          // If the -print option is specified, the sections are printed;
          // otherwise, they are displayed (if a range is specified without
          // "-print", only the first ID in the range will be processed).
          // If a specified location ID is not at the top of a section,
          // the section containing the location is printed.

          f_sectionsArg = UAS_String(argv_i[i]);
          // (we actually build the sections "list" later, based
          //  on document windows actually displayed)
        }
      //else ... ignore this one
      }
      else if (strcmp(argv_i[i], "-secondary") == 0)
      {
        // Run this dtinfo instance without tooltalk session participation.
	// Secondary instances do not respond to ToolTalk messages. 
        f_secondary = True;
      }
      else if (strcmp(argv_i[i], "-verbose") == 0 ||
               strcmp(argv_i[i], "-v") == 0)
      {
        // make verbose a boolean flag
        f_verbose = True;
      }
#ifdef UseSessionMgmt
      else if (strcmp(argv_i[i], "-session") == 0)
      {
        // Get special session save-state file name
        // This option will usually result only from programmatic insertion
        // for purpose of session restart.
        i++;
        if(argv_i[i][0] != '-')
        {
          session().file( argv_i[i] ) ;
        }
      //else, ignore any errors for this arg, which is usually transparent
#endif
      }
      else if (strcmp(argv_i[i], "-Debug") == 0 ||
               strcmp(argv_i[i], "-D") == 0)
      {
        // Undocumented flag:  turn on debugging
        g_debug = TRUE;
        f_debug = TRUE;
        cerr << "\nInternal debugging activated." << endl;
      }
      else
      {
        cerr << CATGETS(Set_EnvMgr, 2, "Invalid argument") << endl;
        return -1;
      }
   }

   // do any argument consistency/cross-validation here

    // make sure that if print option was specified that some sections 
    // to print were also specified.
    if ( (window_system().videoShell()->print_only) && (f_sectionsArg == (UAS_String)NULL)) {
	cerr << CATGETS(Set_EnvMgr, 3, "ERROR: The -sect option must be specified with the -print option.") << endl;
	cerr << endl;
	usage();
	exit(1);
    }
   return 0;
}
Ejemplo n.º 7
0
Archivo: EnvMgr.C Proyecto: juddy/edcde
// infolibStringToList()
//
// parse a string of colon-separated infolib paths and return as a list.
//
UAS_List<UAS_String>
EnvMgr::infolibStringToList( const UAS_String & s_infolibs )
{
  return s_infolibs.splitFields (ILSEP);
}
Ejemplo n.º 8
0
int
operator == (const UAS_String &s1, const UAS_String &s2) {
    if (s1.length() != s2.length())
        return 0;
    return !memcmp ((char *) s1, (char *) s2, s1.length());
}