Example #1
0
int main(int argc, char *argv[]){
	
	if(argc<2){
		printf("Specify the file name\n");
		exit(-1);
	}
	
	char*table_txt=argv[1];
	
	node*root=Init_tree();
	
	if(root==NULL)printf("Table successfully initialized\n");
	
	ReadTable(&root, table_txt);
	
	int option;
	int hop;
	char prefix[128];
	
	while(1){
		
		printf("Choose from the following options:\n1: Add Prefix\n2: Delete Prefix\n3: Print Table\n4: Convert Tree to Two Tree\n5: Address Look Up\n6: Exit\n\n");
		
		bzero(prefix, 128);
		if(scanf("%d",&option)==1)printf("deu\n");

		if(option==1){
			printf("\nPlease specify the prefix and next hop to add.\n");
			fscanf(stdin,"%s %d", prefix, &hop);
			AddPrefix(&root, prefix, hop);
			printf("\nAdded the prefix: %s with next hop: %d\n",prefix, hop);
		}
		if(option==2){
			printf("\nPlease specify the prefix to delete.\n");
			fscanf(stdin,"%s", prefix);
			printf("\n%s\t%d\n",prefix, hop);
			DeletePrefix(&root, prefix);
			printf("\nDeleted the prefix: %s\n",prefix);
		}
		if(option==3){
			PrintTable(root);
			printf("\nTable successfully printed\n");	
		}
		if(option==4){
			convert_tree(&root, root->next_hop);
			printf("\nTable successfully converted\n");
		}
		if(option==5){
			printf("\nPlease specify the prefix to scan.\n");
			fscanf(stdin,"%s", prefix);
			int result=AddressLookUp(root, prefix);
			printf("\nNext hop is: %d\n", result);
		}
		if(option==6){
			printf("The program will now exit.\n");
			exit(1);
		}
	}
	exit(0);
}
Example #2
0
nsresult
nsXMLNameSpaceMap::AddPrefix(nsIAtom *aPrefix, nsString &aURI)
{
  int32_t id;
  nsresult rv = nsContentUtils::NameSpaceManager()->RegisterNameSpace(aURI,
                                                                      id);

  NS_ENSURE_SUCCESS(rv, rv);

  return AddPrefix(aPrefix, id);
}
Example #3
0
  void RdfStorePrivate::Import(std::string url, std::string format)
  {
    std::string baseUri = m_BaseUri.ToString();

    if (baseUri.empty())
    {
      baseUri = url;
      SetBaseUri(RdfUri(baseUri));
    }

    if (format == "") format= "turtle";

    // Redland uses file paths like file:YOURPATH ( Example: file:D:/home/readme.txt )
    librdf_uri* uri = librdf_new_uri(m_World, (const unsigned char*) url.c_str());

    librdf_uri* libRdfBaseUri = librdf_new_uri(m_World, (const unsigned char*) baseUri.c_str());

    librdf_parser* p = librdf_new_parser(m_World, format.c_str(), nullptr, nullptr);

    if(!p)
    {
      mitkThrow() << "RDF Library Error";
    }

    if (librdf_parser_parse_into_model(p, uri, libRdfBaseUri, m_Model) != 0 )
    {
      librdf_free_parser(p);
      MITK_ERROR << "Parsing into Model failed.";
      return;
    }

    int namespaces = librdf_parser_get_namespaces_seen_count(p);

    for (int i = 0; i < namespaces; i++) {
      const char* prefixChar = librdf_parser_get_namespaces_seen_prefix(p, i);

      if ( !prefixChar ) continue;

      std::string prefix = prefixChar;
      RdfUri uri = LibRdfUriToRdfUri(librdf_parser_get_namespaces_seen_uri(p, i));

      if (uri == RdfUri()) return;

      RdfStorePrivate::PrefixMap::iterator it = m_Prefixes.find(prefix);

      // map iterator is equal to iterator-end so it is not already added
      if (it == m_Prefixes.end()) {
        AddPrefix(prefix, uri);
      }
    }
    librdf_free_parser(p);
  }
Example #4
0
void CViewThread::OnInfoErrorMessage( const UINT nResID )
{
	if ( m_pConsole != NULL )
	{
		CString strMessage;

		if ( strMessage.LoadString( nResID ) )
		{
			AddPrefix("Error");
			m_pConsole->DisplayText( strMessage, COLOR_ERROR, TO_BOLD | TO_ITALIC | TO_NEWLINE );
		}
	}
}
Example #5
0
void CViewThread::OnStuffText( CTextMessage* pNew )
{
	if ( m_pConsole == NULL )
	{
		m_pBotSys->IgnoreObject( pNew );
	}
	else
	{
		AddPrefix("CMD");
		m_pBotSys->LockObject( pNew );
		m_pConsole->DisplayText( pNew->GetText(), COLOR_STUFFTEXT, TO_NEWLINE );
		m_pBotSys->ReleaseObject( pNew );
	}
}
OMX_ERRORTYPE QComOMXPlugin::enumerateComponents(
        OMX_STRING name,
        size_t size,
        OMX_U32 index) {
    if (mLibHandle == NULL) {
        return OMX_ErrorUndefined;
    }

    OMX_ERRORTYPE res = (*mComponentNameEnum)(name, size, index);

    if (res != OMX_ErrorNone) {
        return res;
    }

    return AddPrefix(name);
}
Example #7
0
void YpSetPaths(const char *pathlist)
{
  char *paths= p_strcpy(pathlist);
  char *token= yp_strtok(paths, PATH_SEP_DELIMIT);
  char *prefix;

  ClearPrefixes();

  /* crack colon-or-space-delimited list of directory pathnames */
  while (token) {
    if (YIsDotRelative(token)) prefix= p_strcpy(token);
    else prefix= YExpandName(token);
    AddPrefix(prefix);
    token= yp_strtok((char *)0, PATH_SEP_DELIMIT);
  }

  p_free(paths);

  /* Set yCWD and yHOME if they haven't been initialized.  */
  if (!yCWD) YSetCWD((char *)0);
  if (!yHOME) YGetHOME();
}