From eb84617baf5e646eb0e1da539a1ada5eb5c6155b Mon Sep 17 00:00:00 2001 From: sumagnadas Date: Thu, 25 Mar 2021 11:10:06 +0530 Subject: [PATCH] Removed 2nd level grouping in mime types. --- include/bu/mime.h | 6 +-- include/gcv/api.h | 2 +- include/icv/io.h | 6 +-- src/conv/3dm/3dm-g.c | 4 +- src/conv/gcv/gcv.c | 50 +++++++++--------- src/libbu/mime.cmake | 83 +++++------------------------- src/libbu/tests/file_mime.c | 17 +++--- src/libged/overlay/overlay.c | 14 ++--- src/libged/screengrab/screengrab.c | 10 ++-- src/libicv/fileformat.c | 6 +-- src/libicv/size.c | 2 +- src/libicv/tests/crop.c | 2 +- src/libicv/tests/fade.c | 2 +- src/libicv/tests/filter.c | 2 +- src/libicv/tests/operations.c | 2 +- src/libicv/tests/read_write.c | 2 +- src/libicv/tests/rect.c | 2 +- src/libicv/tests/saturate.c | 2 +- src/libicv/tests/size_down.c | 2 +- src/libicv/tests/size_up.c | 2 +- src/rt/viewxray.c | 2 +- src/rtwizard/main.c | 4 +- src/util/icv.cpp | 20 +++---- 23 files changed, 91 insertions(+), 153 deletions(-) diff --git a/include/bu/mime.h b/include/bu/mime.h index 2f2c9eacb58..744ca43e459 100644 --- a/include/bu/mime.h +++ b/include/bu/mime.h @@ -56,7 +56,7 @@ __BEGIN_DECLS * was found. It is the responsibility of the caller to cast * the return int to the correct mime_CONTEXT_t type. */ -BU_EXPORT extern int bu_file_mime(const char *ext, bu_mime_context context); +BU_EXPORT extern int bu_file_mime(const char *ext); /** @@ -67,7 +67,7 @@ BU_EXPORT extern int bu_file_mime(const char *ext, bu_mime_context context); * containing the extensions if a result was found. * It is the responsibility of the caller to free the returned string. */ -BU_EXPORT extern const char *bu_file_mime_ext(int t, bu_mime_context context); +BU_EXPORT extern const char *bu_file_mime_ext(int t); /** @@ -78,7 +78,7 @@ BU_EXPORT extern const char *bu_file_mime_ext(int t, bu_mime_context context); * returns NULL if no match was found, or a string if a result was found. * It is the responsibility of the caller to free the returned string. */ -BU_EXPORT extern const char *bu_file_mime_str(int t, bu_mime_context context); +BU_EXPORT extern const char *bu_file_mime_str(int t); /** diff --git a/include/gcv/api.h b/include/gcv/api.h index b15f680f473..56e322c8764 100644 --- a/include/gcv/api.h +++ b/include/gcv/api.h @@ -147,7 +147,7 @@ struct gcv_filter { * FIXME: input/output plugins conceivably could be something * other than geometry (e.g., png input or csv output). */ - const bu_mime_context_t mime_type; + const bu_mime_t mime_type; /* For plugins supporting multiple file types, call this to * process them. diff --git a/include/icv/io.h b/include/icv/io.h index 8e7efc4ac07..7d73442ba78 100644 --- a/include/icv/io.h +++ b/include/icv/io.h @@ -83,7 +83,7 @@ ICV_EXPORT extern int icv_destroy(icv_image_t *bif); * Returns 1 if an image size was identified, zero otherwise. * */ -ICV_EXPORT extern int icv_image_size(const char *label, size_t dpi, size_t data_size, bu_mime_context_t type, size_t *widthp, size_t *heightp); +ICV_EXPORT extern int icv_image_size(const char *label, size_t dpi, size_t data_size, bu_mime_t type, size_t *widthp, size_t *heightp); /** * Load a file into an ICV struct. For most formats, this will be @@ -108,7 +108,7 @@ ICV_EXPORT extern int icv_image_size(const char *label, size_t dpi, size_t data_ * program. * @return A newly allocated struct holding the loaded image info. */ -ICV_EXPORT extern icv_image_t *icv_read(const char *filename, bu_mime_context_t format, size_t width, size_t height); +ICV_EXPORT extern icv_image_t *icv_read(const char *filename, bu_mime_t format, size_t width, size_t height); /** * Saves Image to a file or streams to stdout in respective format @@ -120,7 +120,7 @@ ICV_EXPORT extern icv_image_t *icv_read(const char *filename, bu_mime_context_t * @param format Specific format of the file to be written. * @return on success 0, on failure -1 with log messages. */ -ICV_EXPORT extern int icv_write(icv_image_t *bif, const char*filename, bu_mime_context_t format); +ICV_EXPORT extern int icv_write(icv_image_t *bif, const char*filename, bu_mime_t format); /** * Write an image line to the data of ICV struct. Can handle unsigned diff --git a/src/conv/3dm/3dm-g.c b/src/conv/3dm/3dm-g.c index b1b4e16ad44..066f185b4d4 100644 --- a/src/conv/3dm/3dm-g.c +++ b/src/conv/3dm/3dm-g.c @@ -35,13 +35,13 @@ static const struct gcv_filter * -find_filter(enum gcv_filter_type filter_type, bu_mime_context_t mime_type, const char *data) +find_filter(enum gcv_filter_type filter_type, bu_mime_t mime_type, const char *data) { const struct gcv_filter * const *entry; const struct bu_ptbl * const filters = gcv_list_filters(); for (BU_PTBL_FOR(entry, (const struct gcv_filter * const *), filters)) { - bu_mime_context_t emt = (*entry)->mime_type; + bu_mime_t emt = (*entry)->mime_type; if ((*entry)->filter_type != filter_type) continue; if ( (emt != BU_MIME_MODEL_AUTO) && (emt == mime_type)) return *entry; if ( (emt == BU_MIME_MODEL_AUTO) && ((*entry)->data_supported && data && (*(*entry)->data_supported)(data)) ) return *entry; diff --git a/src/conv/gcv/gcv.c b/src/conv/gcv/gcv.c index e2c7672997c..2907ecd83a8 100644 --- a/src/conv/gcv/gcv.c +++ b/src/conv/gcv/gcv.c @@ -186,7 +186,7 @@ static int parse_model_string(struct bu_vls *format, struct bu_vls *slog, const char *opt, const char *input) { int type_int = 0; - bu_mime_context_t type = BU_MIME_MODEL_UNKNOWN; + bu_mime_t type = BU_MIME_MODEL_UNKNOWN; struct bu_vls format_cpy = BU_VLS_INIT_ZERO; struct bu_vls path = BU_VLS_INIT_ZERO; @@ -206,8 +206,8 @@ parse_model_string(struct bu_vls *format, struct bu_vls *slog, const char *opt, /* If we have an explicit option, that overrides any other format specifiers */ if (opt) { - type_int = bu_file_mime(opt, BU_MIME_AUTO); - type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(opt); + type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_MODEL_UNKNOWN) { /* Have prefix, but doesn't result in a known format - that's an error */ if (slog) @@ -223,8 +223,8 @@ parse_model_string(struct bu_vls *format, struct bu_vls *slog, const char *opt, * find out if it maps to a valid type */ if (type == BU_MIME_MODEL_UNKNOWN && format) { /* Yes - see if the prefix specifies a model format */ - type_int = bu_file_mime(bu_vls_addr(format), BU_MIME_AUTO); - type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(bu_vls_addr(format)); + type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_MODEL_UNKNOWN) { /* Have prefix, but doesn't result in a known format - that's an error */ if (slog) @@ -238,8 +238,8 @@ parse_model_string(struct bu_vls *format, struct bu_vls *slog, const char *opt, /* If we don't already have a type and we were passed a format string, give it a try */ if (type == BU_MIME_MODEL_UNKNOWN && format && bu_vls_strlen(&format_cpy) > 0) { bu_vls_sprintf(format, "%s", bu_vls_addr(&format_cpy)); - type_int = bu_file_mime(bu_vls_addr(&format_cpy), BU_MIME_AUTO); - type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(bu_vls_addr(&format_cpy)); + type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_MODEL_UNKNOWN) { /* Have prefix, but doesn't result in a known format - that's an error */ if (slog) @@ -252,8 +252,8 @@ parse_model_string(struct bu_vls *format, struct bu_vls *slog, const char *opt, /* If we have no prefix or the prefix didn't map to a model type, try file extension */ if (type == BU_MIME_MODEL_UNKNOWN && extract_path(&path, input)) { if (bu_path_component(format, bu_vls_addr(&path), BU_PATH_EXT)) { - type_int = bu_file_mime(bu_vls_addr(format), BU_MIME_AUTO); - type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(bu_vls_addr(format)); + type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_MODEL_UNKNOWN) { /* Have file extension, but doesn't result in a known format - that's an error */ if (slog) @@ -315,13 +315,13 @@ static int model_mime(struct bu_vls *msg, size_t argc, const char **argv, void *set_mime) { int type_int; - bu_mime_context_t type = BU_MIME_MODEL_UNKNOWN; - bu_mime_context_t *set_type = (bu_mime_context_t *)set_mime; + bu_mime_t type = BU_MIME_MODEL_UNKNOWN; + bu_mime_t *set_type = (bu_mime_t *)set_mime; BU_OPT_CHECK_ARGV0(msg, argc, argv, "mime format"); - type_int = bu_file_mime(argv[0], BU_MIME_AUTO); - type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(argv[0]); + type = (type_int < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_MODEL_UNKNOWN) { if (msg) { bu_vls_sprintf(msg, "Error - unknown geometry file type: %s \n", argv[0]); @@ -361,8 +361,8 @@ help(struct bu_vls *UNUSED(msg), size_t argc, const char **argv, void *set_var) static int do_conversion( struct bu_vls *messages, - const char *in_path, bu_mime_context_t in_type, - const char *out_path, bu_mime_context_t out_type, + const char *in_path, bu_mime_t in_type, + const char *out_path, bu_mime_t out_type, size_t in_argc, const char **in_argv, size_t out_argc, const char **out_argv) { @@ -372,7 +372,7 @@ do_conversion( struct gcv_context context; for (BU_PTBL_FOR(entry, (const struct gcv_filter * const *), filters)) { - bu_mime_context_t emt = (*entry)->mime_type; + bu_mime_t emt = (*entry)->mime_type; if ((*entry)->filter_type == GCV_FILTER_READ) { if (!in_filter && (emt != BU_MIME_MODEL_AUTO) && (emt == in_type)) in_filter = *entry; @@ -385,16 +385,16 @@ do_conversion( if (!out_filter && (emt != BU_MIME_MODEL_AUTO) && (emt == out_type)) out_filter = *entry; if (!out_filter && (emt == BU_MIME_MODEL_AUTO) && - ((*entry)->data_supported && (*(*entry)->data_supported)(bu_file_mime_str(out_type, BU_MIME_AUTO)))) { + ((*entry)->data_supported && (*(*entry)->data_supported)(bu_file_mime_str(out_type)))) { out_filter = *entry; } } } if (!in_filter) - bu_vls_printf(messages, "No filter for %s\n", bu_file_mime_str(in_type, BU_MIME_AUTO)); + bu_vls_printf(messages, "No filter for %s\n", bu_file_mime_str(in_type)); if (!out_filter) - bu_vls_printf(messages, "No filter for %s\n", bu_file_mime_str(out_type, BU_MIME_AUTO)); + bu_vls_printf(messages, "No filter for %s\n", bu_file_mime_str(out_type)); if (!in_filter || !out_filter) return 0; @@ -435,8 +435,8 @@ main(int ac, const char **av) int fmt = 0; int ret = 0; - static bu_mime_context_t in_type = BU_MIME_MODEL_UNKNOWN; - static bu_mime_context_t out_type = BU_MIME_MODEL_UNKNOWN; + static bu_mime_t in_type = BU_MIME_MODEL_UNKNOWN; + static bu_mime_t out_type = BU_MIME_MODEL_UNKNOWN; static struct fmt_opts in_only_opts; static struct fmt_opts out_only_opts; @@ -630,13 +630,13 @@ main(int ac, const char **av) /* Find out what input file type we are dealing with */ if (in_type == BU_MIME_MODEL_UNKNOWN) { fmt = parse_model_string(&in_format, &slog, in_fmt, bu_vls_addr(&in_path_raw)); - in_type = (fmt < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_context_t)fmt; + in_type = (fmt < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_t)fmt; in_fmt = NULL; } /* Identify output file type */ if (out_type == BU_MIME_MODEL_UNKNOWN) { fmt = parse_model_string(&out_format, &slog, out_fmt, bu_vls_addr(&out_path_raw)); - out_type = (fmt < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_context_t)fmt; + out_type = (fmt < 0) ? BU_MIME_MODEL_UNKNOWN : (bu_mime_t)fmt; out_fmt = NULL; } @@ -663,8 +663,8 @@ main(int ac, const char **av) /* If we've gotten this far, we know enough to try to convert. Until we * hook in conversion calls to libgcv, print a summary of the option * parsing results for debugging. */ - in_fmt = bu_file_mime_str((int)in_type, BU_MIME_AUTO); - out_fmt = bu_file_mime_str((int)out_type, BU_MIME_AUTO); + in_fmt = bu_file_mime_str((int)in_type); + out_fmt = bu_file_mime_str((int)out_type); if (in_fmt) { bu_log("Input file format: %s\n", in_fmt); } else { diff --git a/src/libbu/mime.cmake b/src/libbu/mime.cmake index a4d2d862176..b228b399b44 100644 --- a/src/libbu/mime.cmake +++ b/src/libbu/mime.cmake @@ -124,23 +124,6 @@ endforeach(line ${TYPES}) # HEADER with typedefs -list(GET ACTIVE_TYPES 0 FIRST_TYPE) -set(mcstr "typedef enum {") -set(last_type "") -foreach(context ${ACTIVE_TYPES}) - string(TOUPPER "${context}" c) - if("${context}" STREQUAL "${FIRST_TYPE}") - set(mcstr "${mcstr}\n BU_MIME_${c} = 0,") - else("${context}" STREQUAL "${FIRST_TYPE}") - set(mcstr "${mcstr}\n BU_MIME_${c},") - endif("${context}" STREQUAL "${FIRST_TYPE}") - set(last_type "BU_MIME_${c}") -endforeach(context ${ACTIVE_TYPES}) -set(mcstr "${mcstr}\n BU_MIME_UNKNOWN,") -set(mcstr "${mcstr}\n BU_MIME_AUTO") -set(mcstr "${mcstr}\n} bu_mime_context;\n\n") -set(h_contents "${h_contents}\n${mcstr}") - set(enum_str "typedef enum {") list(GET ACTIVE_TYPES 0 FIRST_ACTIVE_TYPE) foreach(c ${ACTIVE_TYPES}) @@ -158,7 +141,7 @@ foreach(c ${ACTIVE_TYPES}) set(enum_str "${enum_str}\n BU_MIME_${c_u}_UNKNOWN,") endif("${c_u}" STREQUAL "${FIRST_TYPE}") endforeach(c ${ACTIVE_TYPES}) -set(enum_str "${enum_str}\n} bu_mime_context_t;\n\n") +set(enum_str "${enum_str}\n} bu_mime_t;\n\n") set(h_contents "${h_contents}\n${enum_str}") set(h_contents "${h_contents}\n__END_DECLS\n") set(h_contents "${h_contents}\n#endif /*BU_MIME_TYPES_H*/\n") @@ -177,26 +160,12 @@ foreach(c ${ACTIVE_TYPES}) endforeach(c ${ACTIVE_TYPES}) # Public C mapping function - extension to type -set(mcstr "\nint\nbu_file_mime(const char *ext, bu_mime_context context)\n{") -set(mcstr "${mcstr}\n switch (context) {\n") -foreach(context ${ACTIVE_TYPES}) - string(TOUPPER "${context}" c) - set(mcstr "${mcstr} case BU_MIME_${c}:\n") - set(mcstr "${mcstr} return mime_${context}(ext);\n") - set(mcstr "${mcstr} break;\n") -endforeach(context ${ACTIVE_TYPES}) -set(mcstr "${mcstr} case BU_MIME_AUTO:\n") +set(mcstr "\nint\nbu_file_mime(const char *ext)\n{") foreach(context ${ACTIVE_TYPES}) - string(TOUPPER "${context}" c) - set(mcstr "${mcstr} if (mime_${context}(ext) != -1){\n") - set(mcstr "${mcstr} return mime_${context}(ext);\n") - set(mcstr "${mcstr} }\n") + set(mcstr "${mcstr} if (mime_${context}(ext) != -1){\n") + set(mcstr "${mcstr} return mime_${context}(ext);\n") + set(mcstr "${mcstr} }\n") endforeach(context ${ACTIVE_TYPES}) -set(mcstr "${mcstr} break;\n") -set(mcstr "${mcstr} default:\n") -set(mcstr "${mcstr} return -1;\n") -set(mcstr "${mcstr} break;\n") -set(mcstr "${mcstr} }\n") set(mcstr "${mcstr} return -1;\n") set(mcstr "${mcstr}}\n") set(c_contents "${c_contents}\n${mcstr}") @@ -217,26 +186,13 @@ foreach(c ${ACTIVE_TYPES}) endforeach(c ${ACTIVE_TYPES}) # Public C mapping function - type to string -set(mcstr "\nconst char *\nbu_file_mime_str(int t, bu_mime_context context)\n{") -set(mcstr "${mcstr}\n switch (context) {\n") -foreach(context ${ACTIVE_TYPES}) - string(TOUPPER "${context}" c) - set(mcstr "${mcstr} case BU_MIME_${c}:\n") - set(mcstr "${mcstr} return mime_str_${context}(t);\n") - set(mcstr "${mcstr} break;\n") -endforeach(context ${ACTIVE_TYPES}) -set(mcstr "${mcstr} case BU_MIME_AUTO:\n") +set(mcstr "\nconst char *\nbu_file_mime_str(int t)\n{") foreach(context ${ACTIVE_TYPES}) string(TOUPPER "${context}" c) - set(mcstr "${mcstr} if (mime_str_${context}(t) != NULL && !BU_STR_EQUIV(\"BU_MIME_${c}_UNKNOWN\", mime_str_${context}(t))){\n") - set(mcstr "${mcstr} return mime_str_${context}(t);\n") - set(mcstr "${mcstr} }\n") + set(mcstr "${mcstr} if (mime_str_${context}(t) != NULL && !BU_STR_EQUIV(\"BU_MIME_${c}_UNKNOWN\", mime_str_${context}(t))){\n") + set(mcstr "${mcstr} return mime_str_${context}(t);\n") + set(mcstr "${mcstr} }\n") endforeach(context ${ACTIVE_TYPES}) -set(mcstr "${mcstr} break;\n") -set(mcstr "${mcstr} default:\n") -set(mcstr "${mcstr} return NULL;\n") -set(mcstr "${mcstr} break;\n") -set(mcstr "${mcstr} }\n") set(mcstr "${mcstr} return NULL;\n") set(mcstr "${mcstr}}\n") set(c_contents "${c_contents}\n${mcstr}") @@ -271,26 +227,13 @@ foreach(c ${ACTIVE_TYPES}) endforeach(c ${ACTIVE_TYPES}) # Public C mapping function - type to string -set(mcstr "\nconst char *\nbu_file_mime_ext(int t, bu_mime_context context)\n{") -set(mcstr "${mcstr}\n switch (context) {\n") -foreach(context ${ACTIVE_TYPES}) - string(TOUPPER "${context}" c) - set(mcstr "${mcstr} case BU_MIME_${c}:\n") - set(mcstr "${mcstr} return mime_ext_${context}(t);\n") - set(mcstr "${mcstr} break;\n") -endforeach(context ${ACTIVE_TYPES}) -set(mcstr "${mcstr} case BU_MIME_AUTO:\n") +set(mcstr "\nconst char *\nbu_file_mime_ext(int t)\n{") foreach(context ${ACTIVE_TYPES}) string(TOUPPER "${context}" c) - set(mcstr "${mcstr} if (mime_ext_${context}(t) != NULL){\n") - set(mcstr "${mcstr} return mime_ext_${context}(t);\n") - set(mcstr "${mcstr} }\n") + set(mcstr "${mcstr} if (mime_ext_${context}(t) != NULL){\n") + set(mcstr "${mcstr} return mime_ext_${context}(t);\n") + set(mcstr "${mcstr} }\n") endforeach(context ${ACTIVE_TYPES}) -set(mcstr "${mcstr} break;\n") -set(mcstr "${mcstr} default:\n") -set(mcstr "${mcstr} return NULL;\n") -set(mcstr "${mcstr} break;\n") -set(mcstr "${mcstr} }\n") set(mcstr "${mcstr} return NULL;\n") set(mcstr "${mcstr}}\n") set(c_contents "${c_contents}\n${mcstr}") diff --git a/src/libbu/tests/file_mime.c b/src/libbu/tests/file_mime.c index 64bcd171c25..819c314d3a2 100644 --- a/src/libbu/tests/file_mime.c +++ b/src/libbu/tests/file_mime.c @@ -26,10 +26,10 @@ #include "bu.h" int -test_ext(const char *str, bu_mime_context context, int expected) +test_ext(const char *str, int expected) { int status = 0; - int type = bu_file_mime(str, context); + int type = bu_file_mime(str); if (type == expected) { bu_log("%s -> %d [PASS]\n", str, type); @@ -45,21 +45,16 @@ test_ext(const char *str, bu_mime_context context, int expected) int main(int ac, char *av[]) { - int context = 0; int expected = 0; bu_setprogname(av[0]); - if (ac != 4) - bu_exit(1, "Usage: %s {extension} {context} {expected}\n", av[0]); + if (ac != 3) + bu_exit(1, "Usage: %s {extension} {expected}\n", av[0]); - sscanf(av[2], "%d", &context); - sscanf(av[3], "%d", &expected); + sscanf(av[2], "%d", &expected); - if (context >= BU_MIME_UNKNOWN) - return -1; - - return test_ext(av[1], (bu_mime_context)context, expected); + return test_ext(av[1], expected); } diff --git a/src/libged/overlay/overlay.c b/src/libged/overlay/overlay.c index 6c421c77ae2..9ee7b298d28 100644 --- a/src/libged/overlay/overlay.c +++ b/src/libged/overlay/overlay.c @@ -37,13 +37,13 @@ static int image_mime(struct bu_vls *msg, size_t argc, const char **argv, void *set_mime) { int type_int; - bu_mime_context_t type = BU_MIME_IMAGE_UNKNOWN; - bu_mime_context_t *set_type = (bu_mime_context_t *)set_mime; + bu_mime_t type = BU_MIME_IMAGE_UNKNOWN; + bu_mime_t *set_type = (bu_mime_t *)set_mime; BU_OPT_CHECK_ARGV0(msg, argc, argv, "mime format"); - type_int = bu_file_mime(argv[0], BU_MIME_IMAGE); - type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(argv[0]); + type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_IMAGE_UNKNOWN) { if (msg) { bu_vls_sprintf(msg, "Error - unknown geometry file type: %s \n", argv[0]); @@ -59,7 +59,7 @@ image_mime(struct bu_vls *msg, size_t argc, const char **argv, void *set_mime) int ged_overlay_core(struct ged *gedp, int argc, const char *argv[]) { - bu_mime_context_t type = BU_MIME_IMAGE_UNKNOWN; + bu_mime_t type = BU_MIME_IMAGE_UNKNOWN; double size = 0.0; int clear = 0; int height = 0; /* may need to specify for some formats (such as PIX) */ @@ -217,8 +217,8 @@ ged_overlay_core(struct ged *gedp, int argc, const char *argv[]) if (type == BU_MIME_IMAGE_UNKNOWN) { struct bu_vls c = BU_VLS_INIT_ZERO; if (bu_path_component(&c, file_name, BU_PATH_EXT)) { - int itype = bu_file_mime(bu_vls_cstr(&c), BU_MIME_IMAGE); - type = (bu_mime_context_t)itype; + int itype = bu_file_mime(bu_vls_cstr(&c)); + type = (bu_mime_t)itype; } else { bu_vls_printf(gedp->ged_result_str, "no input file image type specified - need either a specified input image type or a path that provides MIME information.\n"); bu_vls_free(&c); diff --git a/src/libged/screengrab/screengrab.c b/src/libged/screengrab/screengrab.c index fa2e8397ac4..fcc154db294 100644 --- a/src/libged/screengrab/screengrab.c +++ b/src/libged/screengrab/screengrab.c @@ -37,13 +37,13 @@ static int image_mime(struct bu_vls *msg, size_t argc, const char **argv, void *set_mime) { int type_int; - bu_mime_context_t type = BU_MIME_IMAGE_UNKNOWN; - bu_mime_context_t *set_type = (bu_mime_context_t *)set_mime; + bu_mime_t type = BU_MIME_IMAGE_UNKNOWN; + bu_mime_t *set_type = (bu_mime_t *)set_mime; BU_OPT_CHECK_ARGV0(msg, argc, argv, "mime format"); - type_int = bu_file_mime(argv[0], BU_MIME_IMAGE); - type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(argv[0]); + type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_IMAGE_UNKNOWN) { if (msg) { bu_vls_sprintf(msg, "Error - unknown geometry file type: %s \n", argv[0]); @@ -70,7 +70,7 @@ ged_screen_grab_core(struct ged *gedp, int argc, const char *argv[]) struct icv_image *bif = NULL; /**< icv image container for saving images */ struct dm *dmp = NULL; struct fb *fbp = NULL; - bu_mime_context_t type = BU_MIME_IMAGE_AUTO; + bu_mime_t type = BU_MIME_IMAGE_AUTO; static char usage[] = "Usage: screengrab [-h] [-F] [--format fmt] [file.img]\n"; struct bu_opt_desc d[4]; diff --git a/src/libicv/fileformat.c b/src/libicv/fileformat.c index cea1f373cf7..5c89fb32eb9 100644 --- a/src/libicv/fileformat.c +++ b/src/libicv/fileformat.c @@ -51,7 +51,7 @@ * return the string as as return type (making the int type be an int* * argument instead that gets set). */ -bu_mime_context_t +bu_mime_t icv_guess_file_format(const char *filename, char *trimmedname) { /* look for the FMT: header */ @@ -83,7 +83,7 @@ icv_guess_file_format(const char *filename, char *trimmedname) /* begin public functions */ icv_image_t * -icv_read(const char *filename, bu_mime_context_t format, size_t width, size_t height) +icv_read(const char *filename, bu_mime_t format, size_t width, size_t height) { if (format == BU_MIME_IMAGE_AUTO) { /* do some voodoo with the file magic or something... */ @@ -109,7 +109,7 @@ icv_read(const char *filename, bu_mime_context_t format, size_t width, size_t he int -icv_write(icv_image_t *bif, const char *filename, bu_mime_context_t format) +icv_write(icv_image_t *bif, const char *filename, bu_mime_t format) { /* FIXME: should not be introducing fixed size buffers */ char buf[BUFSIZ] = {0}; diff --git a/src/libicv/size.c b/src/libicv/size.c index 6b2225d680b..dfecd604046 100644 --- a/src/libicv/size.c +++ b/src/libicv/size.c @@ -170,7 +170,7 @@ struct paper_size paper_sizes[] = { size_t dpi_array[] = {72, 96, 150, 300, 2540, 4000, 0}; int -icv_image_size(const char *name, size_t udpi, size_t file_size, bu_mime_context_t img_type, size_t *widthp, size_t *heightp) +icv_image_size(const char *name, size_t udpi, size_t file_size, bu_mime_t img_type, size_t *widthp, size_t *heightp) { struct xy_size *sp; struct paper_size *ps; diff --git a/src/libicv/tests/crop.c b/src/libicv/tests/crop.c index 836425b18c5..149658e22ae 100644 --- a/src/libicv/tests/crop.c +++ b/src/libicv/tests/crop.c @@ -55,7 +55,7 @@ int main(int argc, char* argv[]) int inx=0, iny=0; int outx=0, outy=0; icv_image_t *bif; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; int urx, ury, ulx, uly, llx, lly, lrx, lry; int ret; diff --git a/src/libicv/tests/fade.c b/src/libicv/tests/fade.c index 44241802883..4a0db72b8d4 100644 --- a/src/libicv/tests/fade.c +++ b/src/libicv/tests/fade.c @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) int c; int inx=0, iny=0; icv_image_t *bif; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; double multiplier=0.2; bu_setprogname(argv[0]); diff --git a/src/libicv/tests/filter.c b/src/libicv/tests/filter.c index 759a6420f86..f8738f70521 100644 --- a/src/libicv/tests/filter.c +++ b/src/libicv/tests/filter.c @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) int c; int inx=0, iny=0; icv_image_t *bif; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; ICV_FILTER filter = ICV_FILTER_LOW_PASS; bu_setprogname(argv[0]); diff --git a/src/libicv/tests/operations.c b/src/libicv/tests/operations.c index b1065973376..3caa0264488 100644 --- a/src/libicv/tests/operations.c +++ b/src/libicv/tests/operations.c @@ -58,7 +58,7 @@ int main(int argc, char* argv[]) int inx=0, iny=0; char *operation = NULL; icv_image_t *bif1, *bif2, *out_bif; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; bu_setprogname(argv[0]); diff --git a/src/libicv/tests/read_write.c b/src/libicv/tests/read_write.c index e4c3ce9e585..d3447fe1369 100644 --- a/src/libicv/tests/read_write.c +++ b/src/libicv/tests/read_write.c @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) char *in_file = NULL; int inx=0, iny=0; icv_image_t *bif; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; int c; bu_setprogname(argv[0]); diff --git a/src/libicv/tests/rect.c b/src/libicv/tests/rect.c index 5632536fb6b..512e02556b8 100644 --- a/src/libicv/tests/rect.c +++ b/src/libicv/tests/rect.c @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) int xorig=0, yorig=0; int outx=0, outy=0; icv_image_t *bif; - bu_mime_context_t format=BU_MIME_IMAGE_AUTO; + bu_mime_t format=BU_MIME_IMAGE_AUTO; bu_setprogname(argv[0]); diff --git a/src/libicv/tests/saturate.c b/src/libicv/tests/saturate.c index 09f3f2cf397..34a186c11ca 100644 --- a/src/libicv/tests/saturate.c +++ b/src/libicv/tests/saturate.c @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) int inx=0, iny=0; icv_image_t *bif; double fraction = 0; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; bu_setprogname(argv[0]); diff --git a/src/libicv/tests/size_down.c b/src/libicv/tests/size_down.c index 1cac40cf13d..03c18017d88 100644 --- a/src/libicv/tests/size_down.c +++ b/src/libicv/tests/size_down.c @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) int inx=0, iny=0; int factor=2; icv_image_t *bif; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; ICV_RESIZE_METHOD method = ICV_RESIZE_SHRINK; size_t index; diff --git a/src/libicv/tests/size_up.c b/src/libicv/tests/size_up.c index 538ba7e15bf..9a25d94d966 100644 --- a/src/libicv/tests/size_up.c +++ b/src/libicv/tests/size_up.c @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) int inx=0, iny=0; int outx=0, outy=0; icv_image_t *bif; - bu_mime_context_t format = BU_MIME_IMAGE_AUTO; + bu_mime_t format = BU_MIME_IMAGE_AUTO; ICV_RESIZE_METHOD method = ICV_RESIZE_NINTERP; bu_setprogname(argv[0]); diff --git a/src/rt/viewxray.c b/src/rt/viewxray.c index fe3827a38fd..753a4939b80 100644 --- a/src/rt/viewxray.c +++ b/src/rt/viewxray.c @@ -105,7 +105,7 @@ view_init(struct application *UNUSED(ap), char *UNUSED(file), char *UNUSED(obj), struct bu_vls c = BU_VLS_INIT_ZERO; char buf[BUFSIZ]; if (bu_path_component(&c, outputfile, BU_PATH_EXT)) { - if (bu_file_mime(bu_vls_addr(&c), BU_MIME_IMAGE) != BU_MIME_IMAGE_UNKNOWN) { + if (bu_file_mime(bu_vls_addr(&c)) != BU_MIME_IMAGE_UNKNOWN) { bu_strlcpy(buf, outputfile, BUFSIZ); bu_strlcat(buf, floatfileext, BUFSIZ); outputfile = floatfilename = bu_strdup(buf); diff --git a/src/rtwizard/main.c b/src/rtwizard/main.c index f14e875d383..a6f15735867 100644 --- a/src/rtwizard/main.c +++ b/src/rtwizard/main.c @@ -1054,7 +1054,7 @@ main(int argc, char **argv) /* First, see if we have an input .g file */ if (bu_vls_strlen(s->input_file) == 0) { if (bu_path_component(&c, argv[i], BU_PATH_EXT)) { - if (bu_file_mime(bu_vls_addr(&c), BU_MIME_MODEL) == BU_MIME_MODEL_VND_BRLCAD_PLUS_BINARY) { + if (bu_file_mime(bu_vls_addr(&c)) == BU_MIME_MODEL_VND_BRLCAD_PLUS_BINARY) { if (bu_file_exists(argv[i], NULL)) { bu_vls_sprintf(s->input_file, "%s", argv[i]); /* This was the .g name - don't add it to the color list */ @@ -1069,7 +1069,7 @@ main(int argc, char **argv) /* Next, see if we have an image specified as an output destination */ if (bu_vls_strlen(s->output_file) == 0 && bu_vls_strlen(s->fb_dev) == 0) { if (bu_path_component(&c, argv[i], BU_PATH_EXT)) { - if (rtwizard_imgformat_supported(bu_file_mime(bu_vls_addr(&c), BU_MIME_IMAGE))) { + if (rtwizard_imgformat_supported(bu_file_mime(bu_vls_addr(&c)))) { bu_vls_sprintf(s->output_file, "%s", argv[i]); /* This looks like the output image name - don't add it to the color list */ continue; diff --git a/src/util/icv.cpp b/src/util/icv.cpp index 81bdd3b19d4..6328f8adee8 100644 --- a/src/util/icv.cpp +++ b/src/util/icv.cpp @@ -70,13 +70,13 @@ int image_mime(struct bu_vls *msg, size_t argc, const char **argv, void *set_mime) { int type_int; - bu_mime_context_t type = BU_MIME_IMAGE_UNKNOWN; - bu_mime_context_t *set_type = (bu_mime_context_t *)set_mime; + bu_mime_t type = BU_MIME_IMAGE_UNKNOWN; + bu_mime_t *set_type = (bu_mime_t *)set_mime; BU_OPT_CHECK_ARGV0(msg, argc, argv, "mime format"); - type_int = bu_file_mime(argv[0], BU_MIME_IMAGE); - type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_context_t)type_int; + type_int = bu_file_mime(argv[0]); + type = (type_int < 0) ? BU_MIME_IMAGE_UNKNOWN : (bu_mime_t)type_int; if (type == BU_MIME_IMAGE_UNKNOWN) { if (msg) bu_vls_sprintf(msg, "Error - unknown geometry file type: %s \n", argv[0]); return -1; @@ -95,8 +95,8 @@ main(int ac, const char **av) size_t height = 0; const char *in_fmt = NULL; const char *out_fmt = NULL; - static bu_mime_context_t in_type = BU_MIME_IMAGE_UNKNOWN; - static bu_mime_context_t out_type = BU_MIME_IMAGE_UNKNOWN; + static bu_mime_t in_type = BU_MIME_IMAGE_UNKNOWN; + static bu_mime_t out_type = BU_MIME_IMAGE_UNKNOWN; static char *in_path_str = NULL; static char *out_path_str = NULL; int need_help = 0; @@ -214,7 +214,7 @@ main(int ac, const char **av) ret = 1; } else { if (bu_path_component(&c, bu_vls_addr(&in_path), BU_PATH_EXT)) { - in_type = (bu_mime_context_t)bu_file_mime(bu_vls_addr(&c), BU_MIME_IMAGE); + in_type = (bu_mime_t)bu_file_mime(bu_vls_addr(&c)); } else { bu_vls_printf(&slog, "No input file image type specified - need either a specified input image type or a path that provides MIME information.\n"); ret = 1; @@ -229,7 +229,7 @@ main(int ac, const char **av) ret = 1; } else { if (bu_path_component(&c, bu_vls_addr(&out_path), BU_PATH_EXT)) { - out_type = (bu_mime_context_t)bu_file_mime(bu_vls_addr(&c), BU_MIME_IMAGE); + out_type = (bu_mime_t)bu_file_mime(bu_vls_addr(&c)); } else { bu_vls_printf(&slog, "No output file image type specified - need either a specified output image type or a path that provides MIME information.\n"); ret = 1; @@ -244,8 +244,8 @@ main(int ac, const char **av) /* If we've gotten this far, we know enough to try to convert. Until we * hook in conversion calls to libicv, print a summary of the option * parsing results for debugging. */ - in_fmt = bu_file_mime_str((int)in_type, BU_MIME_IMAGE); - out_fmt = bu_file_mime_str((int)out_type, BU_MIME_IMAGE); + in_fmt = bu_file_mime_str((int)in_type); + out_fmt = bu_file_mime_str((int)out_type); bu_log("Input file format: %s\n", in_fmt); bu_log("Output file format: %s\n", out_fmt); bu_log("Input file path: %s\n", bu_vls_addr(&in_path));