Provide sane defaults
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 05:37:07 +0000 (01:37 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 05:37:07 +0000 (01:37 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace.c
formats/ctf-text/ctf-text.c
formats/ctf/ctf.c

index c888ec60dc05f71cbf4142ad1c270e0980043021..cc7eabc40264b61324e47099f7d5d7e9f6f2d178 100644 (file)
@@ -164,17 +164,16 @@ int main(int argc, char **argv)
 
        printf_verbose("Converting from file: %s\n", opt_input_path);
        printf_verbose("Converting from format: %s\n",
-               opt_input_format ? : "<autodetect>");
+               opt_input_format ? : "ctf <default>");
        printf_verbose("Converting to file: %s\n",
                opt_output_path ? : "<stdout>");
        printf_verbose("Converting to format: %s\n",
-               opt_output_format ? : "ctf");
+               opt_output_format ? : "text <default>");
 
-       if (!opt_input_format) {
-               fprintf(stdout, "[error] Input format autodetection not implemented yet.\n\n");
-               usage(stdout);
-               exit(EXIT_FAILURE);
-       }
+       if (!opt_input_format)
+               opt_input_format = "ctf";
+       if (!opt_output_format)
+               opt_output_format = "text";
        fmt_read = bt_lookup_format(g_quark_from_static_string(opt_input_format));
        if (!fmt_read) {
                fprintf(stdout, "[error] Format \"%s\" is not supported.\n\n",
@@ -197,12 +196,10 @@ int main(int argc, char **argv)
                goto error_td_read;
        }
 
-       if (!opt_output_path)
-               opt_output_path = "/dev/stdout";
        td_write = fmt_write->open_trace(opt_output_path, O_WRONLY);
        if (!td_write) {
                fprintf(stdout, "Error opening trace \"%s\" for writing.\n\n",
-                       opt_output_path);
+                       opt_output_path ? : "<none>");
                goto error_td_write;
        }
 
index 2e9509e71cf281672f11c1a2afcbbbbfd001d8f7..8d84c37f932163462659d32633905f1e590b5d9d 100644 (file)
@@ -66,6 +66,8 @@ struct trace_descriptor *ctf_text_open_trace(const char *path, int flags)
 
        switch (flags & O_ACCMODE) {
        case O_WRONLY:
+               if (!path)
+                       path = "/dev/stdout";
                fp = fopen(path, "w");
                if (!fp)
                        goto error;
index e375039b84c1bbf132add88d1dd9d29afc84e043..08834e9744318e944ae97ad006c43f8ca79b8bb0 100644 (file)
@@ -573,30 +573,6 @@ error:
        return ret;
 }
 
-static
-int ctf_open_trace_write(struct ctf_trace *td, const char *path, int flags)
-{
-       int ret;
-
-       ret = mkdir(path, S_IRWXU|S_IRWXG);
-       if (ret)
-               return ret;
-
-       /* Open trace directory */
-       td->dir = opendir(path);
-       if (!td->dir) {
-               fprintf(stdout, "[error] Unable to open trace directory.\n");
-               ret = -ENOENT;
-               goto error;
-       }
-       
-
-       return 0;
-
-error:
-       return ret;
-}
-
 struct trace_descriptor *ctf_open_trace(const char *path, int flags)
 {
        struct ctf_trace *td;
@@ -606,6 +582,10 @@ struct trace_descriptor *ctf_open_trace(const char *path, int flags)
 
        switch (flags & O_ACCMODE) {
        case O_RDONLY:
+               if (!path) {
+                       fprintf(stdout, "[error] Path missing for input CTF trace.\n");
+                       goto error;
+               }
                ret = ctf_open_trace_read(td, path, flags);
                if (ret)
                        goto error;
@@ -613,12 +593,6 @@ struct trace_descriptor *ctf_open_trace(const char *path, int flags)
        case O_WRONLY:
                fprintf(stdout, "[error] Opening CTF traces for output is not supported yet.\n");
                goto error;
-#if 0
-               ret = ctf_open_trace_write(td, path, flags);
-               if (ret)
-                       goto error;
-#endif //0
-               break;
        default:
                fprintf(stdout, "[error] Incorrect open flags.\n");
                goto error;
This page took 0.028826 seconds and 4 git commands to generate.