/* * Khoros: $Id$ */ #if !defined(__lint) && !defined(__CODECENTER__) static char rcsid[] = "Khoros: $Id$"; #endif /* * Copyright (C) 1993 - 1997, Khoral Research, Inc., ("KRI"). * All rights reserved. See $BOOTSTRAP/repos/license/License or run klicense. */ /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<< >>>> >>>> Main program for myhistogram >>>> >>>> Private: >>>> main >>>> >>>> Static: >>>> Public: >>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<< */ #include "myhistogram.h" clui_info_struct *clui_info = NULL; /*----------------------------------------------------------- | | Routine Name: main() - Histogram | | Purpose: main program for myhistogram | | Input: | char *clui_info->i_file; {First Input data object} | int clui_info->i_flag; {TRUE if -i specified} | | char *clui_info->o_file; {Resulting output data object} | int clui_info->o_flag; {TRUE if -o specified} | | Output: | Returns: | | Written By: | Date: July 1, 1997 | Modifications: | ------------------------------------------------------------*/ int main( int argc, char **argv) { /* -main_variable_list */ char *lib = "myhistogram_obj"; char *rtn = "main"; kobject in_object = NULL; kobject out_object = NULL; unsigned char *plane; unsigned int *res_plane; int w, h, d, t, e; int cw, ch, ct, pos; /* -main_variable_list_end */ khoros_init(argc, argv, "PROBA", PRODUCT_RELEASE_DATE, PRODUCT_RELEASE_NAME, PRODUCT_RELEASE_VERSION, PRODUCT_RELEASE_MAJOR, PRODUCT_RELEASE_MINOR, "$PROBA/objects/kroutine/myhistogram"); kexit_handler(myhistogram_free_args, NULL); /* -main_get_args_call */ kclui_init("PROBA", "myhistogram", KGEN_KROUTINE, &clui_uis_spec, myhistogram_usage_additions, myhistogram_get_args, myhistogram_free_args); /* -main_get_args_call_end */ /* -main_before_lib_call */ if ((in_object = kpds_open_input_object(clui_info->i_file)) == KOBJECT_INVALID) { kerror(lib, rtn, "Can not open input object %s.\n", clui_info->i_file); kexit(KEXIT_FAILURE); } if ((out_object = kpds_open_output_object(clui_info->o_file)) == KOBJECT_INVALID) { kerror(lib, rtn, "Can not open output object %s.\n", clui_info->o_file); kexit(KEXIT_FAILURE); } kpds_create_value( out_object ); kpds_set_attribute( in_object, KPDS_VALUE_DATA_TYPE, KUBYTE ); kpds_set_attribute( out_object, KPDS_VALUE_DATA_TYPE, KUINT ); kpds_get_attribute( in_object, KPDS_VALUE_SIZE, &w, &h, &d, &t, &e ); /**********************************************************/ /********* ALLITSD BE AZ OUTPUT MERETET *****/ /**********************************************************/ plane = (unsigned char* ) kmalloc ( w * h* sizeof(unsigned char) ); res_plane = ( unsigned int* ) kmalloc ( 256 *sizeof (unsigned int) ); if ( !plane || !res_plane ) { kerror(lib, rtn, "Could not allocate memory for the image\n"); kexit(KEXIT_FAILURE); } /* -main_before_lib_call_end */ /* -main_library_call */ /********************************************************/ /*** SZAMOLD KI A HISZTOGRAMOT!!! ****/ /********************************************************/ /* -main_library_call_end */ /* -main_after_lib_call */ if (!kpds_set_attribute(out_object, KPDS_HISTORY, kpds_history_string())) { kerror(lib,rtn,"Unable to set history on the destination object"); kexit(KEXIT_FAILURE); } if (plane) kfree(plane); if (res_plane) kfree(res_plane); kpds_close_object(in_object); kpds_close_object(out_object); /* -main_after_lib_call_end */ kexit(KEXIT_SUCCESS); } /*----------------------------------------------------------- | | Routine Name: myhistogram_usage_additions | | Purpose: Prints usage additions in myhistogram_usage routine | | Input: None | | Output: None | Written By: ghostwriter -oname myhistogram | Date: July 1, 1997 | Modifications: | ------------------------------------------------------------*/ void myhistogram_usage_additions(void) { kfprintf(kstderr, "\tHistogram\n"); /* -usage_additions */ /* -usage_additions_end */ } /*----------------------------------------------------------- | | Routine Name: myhistogram_free_args | | Purpose: Frees CLUI struct allocated in myhistogram_get_args() | | Input: None | | Output: None | Written By: ghostwriter -oname myhistogram | Date: July 1, 1997 | Modifications: | ------------------------------------------------------------*/ /* ARGSUSED */ void myhistogram_free_args( kexit_status status, kaddr client_data) { /* do the wild and free thing */ if (clui_info != NULL) { kfree_and_NULL(clui_info->i_file); kfree_and_NULL(clui_info->o_file); kfree_and_NULL(clui_info); } /* -free_handler_additions */ /* -free_handler_additions_end */ }