Ejemplo n.º 1
0
void NASHandler::characters( const XMLCh *const chars,
                             const XMLSize_t length )
{
    if( m_pszCurField != NULL )
    {
        const int nCurFieldLength = static_cast<int>(strlen(m_pszCurField));

        int nSkipped = 0;
        if (nCurFieldLength == 0)
        {
            // Ignore white space
            while( chars[nSkipped] == ' ' || chars[nSkipped] == 10 || chars[nSkipped] == 13 ||
                   chars[nSkipped] == '\t')
                nSkipped++;
        }

        transcode( chars + nSkipped, m_osCharacters,
                   static_cast<int>(length) - nSkipped );

        if( m_pszCurField == NULL )
        {
            m_pszCurField = CPLStrdup(m_osCharacters);
        }
        else
        {
            m_pszCurField = static_cast<char *>(
                CPLRealloc( m_pszCurField,
                            nCurFieldLength+m_osCharacters.size()+1 ) );
            memcpy( m_pszCurField + nCurFieldLength, m_osCharacters.c_str(),
                    m_osCharacters.size() + 1 );
        }
    }
    else if( m_pszGeometry != NULL )
    {
        int nSkipped = 0;
        if (m_nGeomLen == 0)
        {
            // Ignore white space
            while( chars[nSkipped] == ' ' || chars[nSkipped] == 10 || chars[nSkipped] == 13 ||
                   chars[nSkipped] == '\t')
                nSkipped++;
        }

        transcode( chars + nSkipped, m_osCharacters,
                   static_cast<int>(length) - nSkipped );

        const int nCharsLen = static_cast<int>(m_osCharacters.size());

        if( m_nGeomLen + nCharsLen*4 + 4 > m_nGeomAlloc )
        {
            m_nGeomAlloc = (int) (m_nGeomAlloc * 1.3 + nCharsLen*4 + 1000);
            m_pszGeometry = (char *)
                CPLRealloc( m_pszGeometry, m_nGeomAlloc);
        }

        memcpy( m_pszGeometry+m_nGeomLen, m_osCharacters.c_str(),
                m_osCharacters.size() + 1 );
        m_nGeomLen += static_cast<int>(strlen(m_pszGeometry+m_nGeomLen));
    }
}
Ejemplo n.º 2
0
    LIBUPCOREAPI UPALLOC UPWARNRESULT
    char* absolute_path(char const* p, char const* base) noexcept {
        wchar_t* native_p = nullptr, * native_base = nullptr, * native_result = nullptr;
        char* retval = nullptr;

        native_p = transcode(p);
        if (!native_p) {
            goto error;
        }

        if (base) {
            native_base = transcode(base);
            if (!native_base) {
                goto error;
            }
        }

        native_result = absolute_path(native_p, native_base);
        if (native_result) {
            retval = transcode(native_result);
        }

    error:

        free(native_result);
        free(native_base);
        free(native_p);
        return retval;
    }
Ejemplo n.º 3
0
static void recordMessage(
    Translator *tor, int line, const QString &context, const QString &text, const QString &comment,
    const QString &extracomment,  bool utf8, bool plural)
{
    TranslatorMessage msg(
        transcode(context, utf8), transcode(text, utf8), transcode(comment, utf8), QString(),
        yyFileName, line, QStringList(),
        TranslatorMessage::Unfinished, plural);
    msg.setExtraComment(transcode(extracomment.simplified(), utf8));
    if ((utf8 || yyForceUtf8) && !yyCodecIsUtf8 && msg.needs8Bit())
        msg.setUtf8(true);
    tor->extend(msg);
}
Ejemplo n.º 4
0
CPLString NASHandler::GetAttributes(const Attributes* attrs)
{
    CPLString osRes;

    for(unsigned int i=0; i < attrs->getLength(); i++)
    {
        osRes += " ";
        osRes += transcode(attrs->getQName(i), m_osAttrName);
        osRes += "=\"";
        osRes += transcode(attrs->getValue(i), m_osAttrValue);
        osRes += "\"";
    }
    return osRes;
}
Ejemplo n.º 5
0
static int fsys_open(const char *path, struct fuse_file_info *fi) 
{
    char* origpath;
    int fd;


    errno = 0;

    origpath = translate_path(path);
    if (!origpath) 
		return -errno;
	//transcoder the file
	transcode(origpath);


    fd = open(origpath, fi->flags);
    /* File does exist, but can't be opened. */
    if (fd == -1 && errno != ENOENT) 
	{
		free(origpath);
		return -errno;
    } 
	else 
        /* Not really an error. */
        errno = 0;

    /* File is real and can be opened. */
    if (fd != -1) 
	{
        close(fd);
		free(origpath);
		return -errno;
    }
	return -errno;
}
Ejemplo n.º 6
0
    // -----------------------------------------------------------------------
    //  Constructors and Destructor
    // -----------------------------------------------------------------------
	StrX(const XMLCh* const toTranscode, const unsigned int len = 0) :

        fLocalForm(0)
    {
        // Call the private transcoding method
        transcode(toTranscode, len);
    }
void
XalanOutputStream::doWrite(
            const XalanDOMChar*     theBuffer,
            size_type               theBufferLength)
{
    assert(theBuffer != 0);

    if (m_writeAsUTF16 == true)
    {
        assert(sizeof(XalanDOMChar) == sizeof(char) * 2);

        // This is a hack to write UTF-16 through as if it
        // were just chars.  Saves lots of time "transcoding."
#if defined(XALAN_OLD_STYLE_CASTS)
        writeData((const char*)theBuffer, theBufferLength * 2);
#else
        writeData(reinterpret_cast<const char*>(theBuffer), theBufferLength * 2);
#endif
    }
    else
    {
        transcode(theBuffer, theBufferLength, m_transcodingBuffer);

        assert(&m_transcodingBuffer[0] != 0);

        assert(size_type(m_transcodingBuffer.size()) == m_transcodingBuffer.size());

        writeData(
            &m_transcodingBuffer[0],
            size_type(m_transcodingBuffer.size()));
    }
}
Ejemplo n.º 8
0
TranscodeToStr::TranscodeToStr(const XMLCh *in, XMLTranscoder* trans,
                               MemoryManager *manager)
    : fString(0),
      fBytesWritten(0),
      fMemoryManager(manager)
{
    transcode(in, XMLString::stringLen(in), trans);
}
Ejemplo n.º 9
0
TranscodeToStr::TranscodeToStr(const XMLCh *in, XMLSize_t length, XMLTranscoder* trans,
                               MemoryManager *manager)
    : fString(0),
      fBytesWritten(0),
      fMemoryManager(manager)
{
    transcode(in, length, trans);
}
Ejemplo n.º 10
0
TranscodeFromStr::TranscodeFromStr(const XMLByte *data, XMLSize_t length, XMLTranscoder *trans,
                                   MemoryManager *manager)
    : fString(0),
      fCharsWritten(0),
      fMemoryManager(manager)
{
    transcode(data, length, trans);
}
Ejemplo n.º 11
0
    LIBUPCOREAPI UPNONNULLALL
    int copy_file(wchar_t const* from, wchar_t const* to, copy_option option) noexcept {
        char* native_from = transcode(from);
        if (!native_from) {
            return -1;
        }

        char* native_to = transcode(to);
        if (!native_to) {
            free(native_from);
            return -1;
        }

        int result = copy_file(native_from, native_to, option);
        free(native_to);
        free(native_from);
        return result;
    }
Ejemplo n.º 12
0
 LIBUPCOREAPI UPALLOC UPWARNRESULT
 wchar_t* observer_operations<wchar_t>::user_directory_path() noexcept {
     char const* path = getenv("HOME");
     if (!path) {
         errno = ENOENT;
         return nullptr;
     }
     return transcode(path);
 }
Ejemplo n.º 13
0
    LIBUPCOREAPI UPNONNULLALL
    int create_hard_link(wchar_t const* to, wchar_t const* new_hard_link) noexcept {
        char* native_to = transcode(to);
        if (!native_to) {
            return -1;
        }

        char* native_new = transcode(new_hard_link);
        if (!native_new) {
            free(native_to);
            return -1;
        }

        int result = create_hard_link(native_to, native_new);
        free(native_new);
        free(native_to);
        return result;
    }
Ejemplo n.º 14
0
int main(int argc, char **argv)
{
    if (argc != 3)
        return -1;

    transcode(argv[1], argv[2], NULL);

    return 0;
}
Ejemplo n.º 15
0
void ErrorLogger::print(
    const LogMessage::Category  category,
    const SAXParseException&    e) const
{
    LOG(
        m_logger,
        category,
        "while reading %s: %s.",
        m_input_filename.c_str(),
        transcode(e.getMessage()).c_str());
}
Ejemplo n.º 16
0
void NASHandler::fatalError( const SAXParseException &exception)

{
    CPLString osErrMsg;
    transcode( exception.getMessage(), osErrMsg );
    CPLError( CE_Failure, CPLE_AppDefined,
              "XML Parsing Error: %s at line %d, column %d\n",
              osErrMsg.c_str(),
              static_cast<int>(exception.getLineNumber()),
              static_cast<int>(exception.getColumnNumber()) );
}
Ejemplo n.º 17
0
void DOMString::print() const
{
    unsigned int len = this->length();

    if (len > 0)
    {
        // Transcode from Unicode to char * in whatever the system local code page is.
        char *pc = transcode(XMLPlatformUtils::fgMemoryManager);
        fputs(pc, stdout);

        XMLPlatformUtils::fgMemoryManager->deallocate(pc);//delete [] pc;
    }
}
Ejemplo n.º 18
0
    LIBUPCOREAPI
    ssize_t absolute_path(char* d, size_t dsz, char const* p, char const* base) noexcept {
        wchar_t* native_d = nullptr, * native_p = nullptr, * native_base = nullptr;
        ssize_t retval = -1;
        size_t length;

        if (dsz) {
            native_d = static_cast<wchar_t *>(malloca(dsz * sizeof(wchar_t)));
            if (!native_d) {
                return -1;
            }
        }

        native_p = transcode(p);
        if (!native_p) {
            goto error;
        }

        if (base) {
            native_base = transcode(base);
            if (!native_base) {
                goto error;
            }
        }

        retval = absolute_path(native_d, dsz, native_p, native_base);
        if (!retval) {
            length = static_cast<size_t>(retval);
            retval = transcode(d, dsz, native_d, length);
        }

    error:

        free(native_base);
        free(native_p);
        freea(native_d);
        return retval;
    }
Ejemplo n.º 19
0
// ---------------------------------------------------------------------------
//  TranscodeFromStr: Public constructors and destructor
// ---------------------------------------------------------------------------
TranscodeFromStr::TranscodeFromStr(const XMLByte *data, XMLSize_t length, const char *encoding,
                                   MemoryManager *manager)
    : fString(0),
      fCharsWritten(0),
      fMemoryManager(manager)
{
    XMLTransService::Codes failReason;
    const XMLSize_t blockSize = 2048;

    XMLTranscoder* trans = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(encoding, failReason, blockSize, fMemoryManager);
    Janitor<XMLTranscoder> janTrans(trans);

    transcode(data, length, trans);
}
Ejemplo n.º 20
0
// ---------------------------------------------------------------------------
//  TranscodeToStr: Public constructors and destructor
// ---------------------------------------------------------------------------
TranscodeToStr::TranscodeToStr(const XMLCh *in, const char *encoding,
                               MemoryManager *manager)
    : fString(0),
      fBytesWritten(0),
      fMemoryManager(manager)
{
    XMLTransService::Codes failReason;
    const XMLSize_t blockSize = 2048;

    XMLTranscoder* trans = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(encoding, failReason, blockSize, fMemoryManager);
    Janitor<XMLTranscoder> janTrans(trans);

    transcode(in, XMLString::stringLen(in), trans);
}
 //! @name Constructors/Destructor
 //@{
 beautifier( XERCES_CPP_NAMESPACE::XMLFormatTarget& target, const std::string& encoding, const XMLCh* new_line )
     : target_    ( target )
     , transcoder_( create( encoding ) )
     , level_     ( -1 )
     , cdata_     ( false )
     , inline_    ( false )
 {
     transcode( detail::OPEN_ANGLE, open_angle_ );
     transcode( detail::CLOSE_ANGLE, close_angle_ );
     transcode( detail::FORWARD_SLASH, forward_slash_ );
     transcode( detail::OPEN_ANGLE_FORWARD_SLASH, open_angle_forward_slash_ );
     transcode( detail::CDATA_START, cdata_start_ );
     transcode( detail::CDATA_END, cdata_end_ );
     transcode( new_line ? new_line : detail::NEW_LINE , new_line_ );
     transcode( detail::SPACE, space_ );
 }
Ejemplo n.º 22
0
static int fsys_getattr(const char *path, struct stat *stbuf) 
{
    char* origpath;


    errno = 0;
    origpath = translate_path(path);
    if (!origpath)
		return -errno;
	
	transcode(origpath); //transcode the file

    /* pass-through for regular files */
    if (lstat(origpath, stbuf) == 0) 
	{
		free(origpath);
		return -errno;
    } 
	else 
        /* Not really an error. */
        errno = 0;

    if (lstat(origpath, stbuf) == -1) 
	{
		free(origpath);
		return -errno;
    }

    /*
     * Get size for resulting mp3 from regular file, otherwise it's a
     * symbolic link. */
    if (S_ISREG(stbuf->st_mode)) {
//        trans = transcoder_new(origpath);
//        if (!trans) {
//            goto transcoder_fail;
//        }

  //      stbuf->st_size = trans->totalsize;
  //      stbuf->st_blocks = (stbuf->st_size + 512 - 1) / 512;

//        transcoder_finish(trans);
//        transcoder_delete(trans);
    }

    free(origpath);
    return -errno;
}
Ejemplo n.º 23
0
    //-----------------------------------------------------------------------
    void XercesWriter::writeXMLFile(const XMLNode* root, const Ogre::String& filename)
    {
        XERCES_CPP_NAMESPACE_USE;

        DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(L"Core");
        DOMDocumentType* docType = NULL;
        DOMDocument* doc = impl->createDocument(NULL, transcode(root->getName()).c_str(), docType);

        populateDOMElement(root, doc->getDocumentElement());

        LocalFileFormatTarget destination(filename.c_str());
        DOMWriter* writer = impl->createDOMWriter();
        writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
        writer->writeNode(&destination, *doc);
        writer->release();
        doc->release();
    }
int HttpSvc::Sn::Handler_mm::Run()
{
    int err = 0;

    LOG_INFO("Handler_mm[%p]: Run", this);

    err = getMediaFileInfo();
    if (err) {
        // HTTP response set by getMediaFileInfo().
        err = 0;  // reset error
        goto end;
    }

    mediafile = MediaFile::Create(vssServer, location);
    if (!mediafile) {
        LOG_ERROR("Handler_mm[%p]: Not enough memory", this);
        std::ostringstream oss;
        oss << "{\"errMsg\":\"Not enough memory\"}";
        HttpStream_Helper::SetCompleteResponse(hs, 500, oss.str(), "application/json");
        err = 0;  // reset error
        goto end;
    }

    err = transcode();
    if (err) {
        // HTTP response set by transcode().
        err = 0;  // reset error
        goto end;
    }

    err = sendResponse();
    if (err) {
        // We won't reset the error.
        // This is because we might have already sent the response header,
        // in which case, the only recourse is to drop the connection by returning a non-zero value.
        goto end;
    }

end:
    if (mediafile) {
        delete mediafile;
        mediafile = NULL;
    }

    return err;
}
Ejemplo n.º 25
0
/* Play button */
void OpenDialog::selectSlots()
{
    switch ( i_action_flag )
    {
    case OPEN_AND_STREAM:
        stream();
        break;
    case OPEN_AND_SAVE:
        transcode();
        break;
    case OPEN_AND_ENQUEUE:
        enqueue();
        break;
    case OPEN_AND_PLAY:
    default:
        play();
    }
}
Ejemplo n.º 26
0
static int fsys_read(const char *path, char *buf, size_t size, off_t offset,
								struct fuse_file_info *fi) 
{
    char* origpath;
    int fd;
    int read = 0;

    servlog(INFO, "read %s: %zu bytes from %jd", path, size, offset);

    errno = 0;

    origpath = translate_path(path);
    
    servlog(INFO, "the original file is %s\n", origpath);

    if (!origpath) 
        return -errno;

	transcode(origpath);

    /* If this is a real file, pass the call through. */
    fd = open(origpath, O_RDONLY);
    if (fd != -1) 
	{
        read = pread(fd, buf, size, offset);
        close(fd);
		free(origpath);
		if (read)
			return read;
		else 
			return -errno;
    }

    /* File does exist, but can't be opened. */
    if (fd == -1 && errno != ENOENT) 
	{
		free(origpath);
        return -errno;
    }
	
	free(origpath);
    return -errno;
}
Ejemplo n.º 27
0
jint Java_fr_free_nrw_commons_Transcoder_transcode(JNIEnv* env,
        jclass *klass, jstring infile, jstring outfile, jstring profile,
        jobject cb_obj)
{
    const char *in;
    const char *out;
    const char *prof = NULL;

    if (!infile || !outfile)
        return -1;

    in = (*env)->GetStringUTFChars(env, infile, 0);
    out = (*env)->GetStringUTFChars(env, outfile, 0);

    if (profile)
        prof = (*env)->GetStringUTFChars(env, profile, 0);

    return transcode(in, out, prof, cb_obj, env);
}
Ejemplo n.º 28
0
bool XercesCManager::initialize(Logger& logger)
{
    mutex::scoped_lock lock(s_mutex);

    try
    {
        XMLPlatformUtils::Initialize();
    }
    catch (const XMLException& e)
    {
        LOG_ERROR(
            logger,
            "failed to initialize Xerces-C++ library: %s.",
            transcode(e.getMessage()).c_str());

        return false;
    }

    return true;
}
Ejemplo n.º 29
0
tree
xml_html_parser::parse (string s2) {
  // end of line handling
  string s3;
  i= 0, n= N(s2);
  bool is_cr= false;
  while (i<n) {
    bool prev_is_cr= is_cr;
    is_cr= false;
    char c= s2[i];
    if (c == '\15') {
      s3 << '\12';
      is_cr= true;
    }
    else if (prev_is_cr && (c == '\12')) /* no-op */;
    else s3 << c;
    i++;
  }
  s2= s3;

  // cout << "Transcoding " << s2 << "\n";
  if (html) s2= transcode (s2);
  // cout << HRULE << LF;
  s= parse_string (s2);
  //cout << "Parsing " << s << "\n";
  parse ();
  // cout << HRULE << LF;
  // cout << "a= " << a << "\n";
  i= 0; n= N(a); stack= tuple ("<bottom>");
  tree r= tuple ("tag", "<document>");
  build (r);
  // cout << HRULE << LF;
  // print_tree (r);
  r= finalize_sxml (r);
  // cout << HRULE << LF;
  // print_tree (r);
  return r;
}
Ejemplo n.º 30
0
Frontend::Frontend(QWidget* parent)
	: QWidget(parent)
{
	instructions = new QLabel;
	convert = new QPushButton(tr("&Convert"));
	status = new QLabel;

	instructions->setText(tr("Instructions will go here."));
	instructions->setWordWrap(true);

	QVBoxLayout* layout = new QVBoxLayout;
	layout->addWidget(instructions);
	layout->addWidget(convert);
	layout->addWidget(status);
	setLayout(layout);

	transcoder = new Transcoder(QString("test.flv"));

	// when user clicks "Convert", start transcoding
	connect(convert, SIGNAL(released()), this, SLOT(transcode()));
	connect(transcoder, SIGNAL(statusUpdate(QString)),
		this, SLOT(updateStatus(QString)));
}