コード例 #1
0
ファイル: xml.c プロジェクト: nelsonc/eucalyptus
int main (int argc, char ** argv)
{
        if (argc!=2) {
                logprintfl (EUCAERROR, "ERROR: required parameters are <XSLT stylesheet path>\n");
                return 1;
        }
        strncpy (xslt_path, argv[1], sizeof (xslt_path));
        char * in_path = tempnam (NULL, "xml-");
        char * out_path = tempnam (NULL, "xml-");

        create_dummy_instance (in_path);

        logprintfl (EUCAINFO, "parsing stylesheet %s\n", xslt_path);
        int err = apply_xslt_stylesheet (xslt_path, in_path, out_path, NULL, 0);
        if (err!=OK) 
                goto out;
        logprintfl (EUCAINFO, "parsing stylesheet %s again\n", xslt_path);
        char xml_buf [2048];
        err = apply_xslt_stylesheet (xslt_path, in_path, out_path, xml_buf, sizeof (xml_buf));
        if (err!=OK) 
                goto out;
        logprintfl (EUCAINFO, "wrote XML to %s\n", out_path);
        if (strlen (xml_buf) < 1) {
            err = ERROR;
            logprintfl (EUCAERROR, "failed to see XML in buffer\n");
            goto out;
        }
        cat (out_path);
out:
        remove (out_path);
        remove (in_path);
        free (in_path);
        free (out_path);
        return err;
}
コード例 #2
0
ファイル: xml.c プロジェクト: NalaGinrut/eucalyptus
//!
//! Main entry point of the application
//!
//! @param[in] argc the number of parameter passed on the command line
//! @param[in] argv the list of arguments
//!
//! @return EUCA_OK on success or EUCA_ERROR on failure.
//!
int main(int argc, char **argv)
{
    int err = EUCA_ERROR;
    char *in_path = NULL;
    char *out_path = NULL;
    char xml_buf[2048] = "";

    if (argc != 2) {
        LOGERROR("required parameters are <XSLT stylesheet path>\n");
        return (EUCA_ERROR);
    }

    euca_strncpy(xslt_path, argv[1], sizeof(xslt_path));
    in_path = tempnam(NULL, "xml-");
    out_path = tempnam(NULL, "xml-");

    create_dummy_instance(in_path);

    LOGINFO("parsing stylesheet %s\n", xslt_path);
    if ((err = apply_xslt_stylesheet(xslt_path, in_path, out_path, NULL, 0)) != EUCA_OK)
        goto out;

    LOGINFO("parsing stylesheet %s again\n", xslt_path);
    if ((err = apply_xslt_stylesheet(xslt_path, in_path, out_path, xml_buf, sizeof(xml_buf))) != EUCA_OK)
        goto out;

    LOGINFO("wrote XML to %s\n", out_path);
    if (strlen(xml_buf) < 1) {
        err = EUCA_ERROR;
        LOGERROR("failed to see XML in buffer\n");
        goto out;
    }
    cat(out_path);

out:
    remove(out_path);
    remove(in_path);
    EUCA_FREE(in_path);
    EUCA_FREE(out_path);
    return (err);
}