void SetMyName (char *argv0) { char *temp = strrchr (argv0, '/'); /* Save our program name - for error messages */ MyName = temp ? temp + 1 : argv0; set_application_name(argv0); }
DHANDLE DINO_EXPORT dino_config_start_http(const char *application_name, const char *host, bool enable_logging, const char *function, const char *file, int line) { set_application_name(application_name); set_log_mode(enable_logging); log_message(LOG_INFO, function, file, line, "Config Start with host %s.", host); dino_http_site_t *dino_site = (dino_http_site_t *) memory_alloc(sizeof(dino_http_site_t)); if (NULL != dino_site) { dino_site->host = dino_string_new_with_str(host); dino_site->port = 80; dino_site->list = NULL; dino_site->handle_type = dino_handle_site; } return dino_site; }
DHANDLE DINO_EXPORT dino_config_start_https(const char *application_name, const char *host, bool enable_logging, const char *function, const char *file, int line) { set_application_name(application_name); set_log_mode(enable_logging); log_message(LOG_INFO, function, file, line, "Config Start with host %s.", host); dino_http_site_t *dino_site = (dino_http_site_t *) memory_alloc(sizeof(dino_http_site_t)); if (NULL != dino_site) { dino_site->host = dino_string_new_with_str(host); dino_site->port = 443; dino_site->list = NULL; // SSL_CTX *ctx = SSL_CTX_new (SSLv23_server_method ()); // SSL_CTX_set_options (ctx, // SSL_OP_SINGLE_DH_USE | // SSL_OP_SINGLE_ECDH_USE | // SSL_OP_NO_SSLv2); dino_site->handle_type = dino_handle_site; } return dino_site; }
int main(int argc, char* argv[]) { Display *dpy = NULL; ASVisual *asv ; int screen = 0, depth = 0; int dummy, geom_flags = 0; unsigned int to_width, to_height ; ASGradient grad ; ASGradient default_grad = { 1, 11, &(default_colors[0]), &(default_offsets[0])} ; ASImage *grad_im = NULL; /* see ASView.1 : */ set_application_name( argv[0] ); #if (HAVE_AFTERBASE_FLAG==1) set_output_threshold(OUTPUT_LEVEL_DEBUG); #endif if( argc > 1 ) { if( strcmp( argv[1], "-h") == 0 ) { usage(); return 0; } /* see ASScale.1 : */ geom_flags = XParseGeometry( argv[1], &dummy, &dummy, &to_width, &to_height ); }else usage(); memset( &grad, 0x00, sizeof(ASGradient)); #ifndef X_DISPLAY_MISSING dpy = XOpenDisplay(NULL); _XA_WM_DELETE_WINDOW = XInternAtom( dpy, "WM_DELETE_WINDOW", False); screen = DefaultScreen(dpy); depth = DefaultDepth( dpy, screen ); #endif if( argc >= 5 ) { int i = 2; /* see ASGrad.1 : */ grad.type = atoi( argv[2] ); grad.npoints = 0 ; grad.color = safemalloc( ((argc-2)/2)*sizeof(ARGB32)); grad.offset = safemalloc( ((argc-2)/2)*sizeof(double)); while( ++i < argc ) { if( grad.npoints > 0 ) { if( i == argc-1 ) grad.offset[grad.npoints] = 1.0; else grad.offset[grad.npoints] = atof( argv[i] ); ++i ; } /* see ASTile.1 : */ if( parse_argb_color( argv[i], &(grad.color[grad.npoints])) != argv[i] ) if( grad.offset[grad.npoints] >= 0. && grad.offset[grad.npoints]<= 1.0 ) grad.npoints++ ; } }else { grad = default_grad ; if( argc >= 3 ) grad.type = atoi( argv[2] ); } if( grad.npoints <= 0 ) { show_error( " not enough gradient points specified."); return 1; } /* Making sure tiling geometry is sane : */ #ifndef X_DISPLAY_MISSING if( !get_flags(geom_flags, WidthValue ) ) to_width = DisplayWidth(dpy, screen)*2/3 ; if( !get_flags(geom_flags, HeightValue ) ) to_height = DisplayHeight(dpy, screen)*2/3 ; #else if( !get_flags(geom_flags, WidthValue ) ) to_width = 500 ; if( !get_flags(geom_flags, HeightValue ) ) to_height = 500 ; #endif printf( "%s: rendering gradient of type %d to %dx%d\n", get_application_name(), grad.type&GRADIENT_TYPE_MASK, to_width, to_height ); /* see ASView.3 : */ asv = create_asvisual( dpy, screen, depth, NULL ); /* see ASGrad.2 : */ grad_im = make_gradient( asv, &grad, to_width, to_height, SCL_DO_ALL, #ifndef X_DISPLAY_MISSING ASA_XImage, #else ASA_ASImage, #endif 0, ASIMAGE_QUALITY_DEFAULT ); if( grad_im ) { #ifndef X_DISPLAY_MISSING /* see ASView.4 : */ Window w = create_top_level_window( asv, DefaultRootWindow(dpy), 32, 32, to_width, to_height, 1, 0, NULL, "ASGradient", NULL ); if( w != None ) { Pixmap p ; XMapRaised (dpy, w); /* see ASView.5 : */ p = asimage2pixmap( asv, DefaultRootWindow(dpy), grad_im, NULL, True ); destroy_asimage( &grad_im ); /* see common.c: set_window_background_and_free() : */ p = set_window_background_and_free( w, p ); /* see common.c: wait_closedown() : */ } wait_closedown(w); dpy = NULL; #else ASImage2file( grad_im, NULL, "asgrad.jpg", ASIT_Jpeg, NULL ); destroy_asimage( &grad_im ); #endif } return 0 ; }
int main(int argc, char* argv[]) { char *image_file = "rose512.jpg" ; ASImage *im ; ASVisual *asv ; int screen = 0, depth = 24; Display *dpy = NULL; /* see ASView.1 : */ set_application_name( argv[0] ); #if (HAVE_AFTERBASE_FLAG==1) set_output_threshold(OUTPUT_LEVEL_DEBUG); #ifdef DEBUG_ALLOCS fprintf( stderr, "have DEBUG_ALLOCS\n"); #endif #ifdef AFTERBASE_DEBUG_ALLOCS fprintf( stderr, "have AFTERBASE_DEBUG_ALLOCS\n"); #endif #endif if( argc > 1 ) { if( strcmp( argv[1], "-h" ) == 0 ) { usage(); return 0; } image_file = argv[1] ; }else { show_warning( "Image filename was not specified. " "Using default: \"%s\"", image_file ); usage(); } #ifndef X_DISPLAY_MISSING dpy = XOpenDisplay(NULL); XSynchronize (dpy, True); _XA_WM_DELETE_WINDOW = XInternAtom( dpy, "WM_DELETE_WINDOW", False); screen = DefaultScreen(dpy); depth = DefaultDepth( dpy, screen ); #endif /* see ASView.3 : */ asv = create_asvisual( dpy, screen, depth, NULL ); /* asv = create_asvisual_for_id( dpy, screen, depth, 0x28, None, NULL ); */ /* see ASView.2 : */ im = file2ASImage( image_file, 0xFFFFFFFF, SCREEN_GAMMA, 0, getenv("IMAGE_PATH"), NULL ); /* The following could be used to dump JPEG version of the image into * stdout : */ /* ASImage2file( im, NULL, NULL, ASIT_Jpeg, NULL ); ASImage2file( im, NULL, "asview.png", ASIT_Png, NULL ); ASImage2file( im, NULL, "asview.gif", ASIT_Gif, NULL ); */ if( im != NULL ) { #ifndef X_DISPLAY_MISSING Window w ; #if 0 /* test example for get_asimage_channel_rects() : */ XRectangle *rects ; unsigned int rects_count =0; int i ; rects = get_asimage_channel_rects( im, IC_ALPHA, 10, &rects_count ); fprintf( stderr, " %d rectangles generated : \n", rects_count ); for( i = 0 ; i < rects_count ; ++i ) fprintf( stderr, "\trect[%d]=%dx%d%+d%+d;\n", i, rects[i].width, rects[i].height, rects[i].x, rects[i].y ); #endif #if 0 /* test example for fill_asimage : */ fill_asimage(asv, im, 0, 0, 50, 50, 0xFFFF0000); fill_asimage(asv, im, 50, 50, 100, 50, 0xFFFF0000); fill_asimage(asv, im, 0, 100, 200, 50, 0xFFFF0000); fill_asimage(asv, im, 150, 0, 50, 50, 0xFFFF0000); #endif #if 0 /* test example for conversion to argb32 :*/ { ASImage *tmp = tile_asimage( asv, im, 0, 0, im->width, im->height, TINT_NONE, ASA_ARGB32, 0, ASIMAGE_QUALITY_DEFAULT ); destroy_asimage( &im ); set_flags( tmp->flags, ASIM_DATA_NOT_USEFUL|ASIM_XIMAGE_NOT_USEFUL ); im = tmp ; } #endif /* see ASView.4 : */ w = create_top_level_window( asv, DefaultRootWindow(dpy), 32, 32, im->width, im->height, 1, 0, NULL, "ASView", image_file ); if( w != None ) { Pixmap p ; XMapRaised (dpy, w); XSync(dpy,False); /* see ASView.5 : */ p = create_visual_pixmap( asv, DefaultRootWindow(dpy), im->width, im->height, 0 ); { START_TIME(started); /* for( int i = 0 ; i < 100 ; ++i ) To test performance! */ asimage2drawable( asv, p, im, NULL, 0, 0, 0, 0, im->width, im->height, False); SHOW_TIME("", started); } /* print_storage(NULL); */ destroy_asimage( &im ); /* see common.c:set_window_background_and_free(): */ p = set_window_background_and_free( w, p ); } /* see common.c: wait_closedown() : */ wait_closedown(w); dpy = NULL; /* no longer need this - lets clean it up :*/ destroy_asvisual( asv, False ); asv = NULL ; #else /* writing result into the file */ ASImage2file( im, NULL, "asview.png", ASIT_Png, NULL ); #endif } #ifdef DEBUG_ALLOCS /* different cleanups of static memory pools : */ flush_ashash_memory_pool(); asxml_var_cleanup(); custom_color_cleanup(); build_xpm_colormap( NULL ); flush_default_asstorage(); /* requires libAfterBase */ print_unfreed_mem(); #endif return 0 ; }
int main(int argc, char* argv[]) { Display *dpy = NULL; ASVisual *asv ; int screen = 0, depth = 0; int to_width = 1, to_height = 1; ASImageLayer *layers ; int layers_num = 0, i; ASImage *merged_im ; /* see ASView.1 : */ set_application_name( argv[0] ); #if (HAVE_AFTERBASE_FLAG==1) set_output_threshold(OUTPUT_LEVEL_DEBUG); #endif if( argc == 2 && strncmp(argv[1],"-h", 2) == 0 ) { usage(); return 0; } if( argc <= 3 ) { show_error( "not enough arguments, please see usage:%s", " "); usage() ; printf( "Using the default, \"The Burning Rose\", composition :\n"); printf( "\n\trose512.jpg add back.xpm:512x386 hue " "fore.xpm:512x386\n"); argv = &(burning_rose[0]) ; argc = 6; } #ifndef X_DISPLAY_MISSING dpy = XOpenDisplay(NULL); _XA_WM_DELETE_WINDOW = XInternAtom( dpy, "WM_DELETE_WINDOW", False); screen = DefaultScreen(dpy); depth = DefaultDepth( dpy, screen ); #endif /* see ASView.3 : */ asv = create_asvisual( dpy, screen, depth, NULL ); /* see ASMerge.1 : */ layers = safecalloc( argc/2, sizeof(ASImageLayer) ); for( i = 1 ; i < argc ; i++ ) { int x = 0, y = 0; unsigned int width, height ; int geom_flags = 0 ; char *separator; char *filename ; /* see ASMerge.2 */ if( i > 1 ) { /* see blend_scanlines_name2func() : */ if((layers[layers_num].merge_scanlines = blend_scanlines_name2func( argv[i] )) == NULL ) continue ; if( ++i >= argc ) break; } if( (separator = strchr( argv[i], ':' )) != NULL ) { /* see ASTile.1 : */ geom_flags = XParseGeometry( separator+1, &x, &y, &width, &height); filename = mystrndup( argv[i], separator-argv[i] ); }else filename = argv[i] ; layers[layers_num].im = file2ASImage( filename, 0xFFFFFFFF, SCREEN_GAMMA, 100, getenv("IMAGE_PATH"), NULL ); if( filename != argv[i] ) free( filename ); if( layers[layers_num].im != NULL ) { if( !get_flags(geom_flags, WidthValue) ) width = layers[layers_num].im->width ; if( !get_flags(geom_flags, HeightValue) ) height = layers[layers_num].im->height ; /* see ASMerge.3 : */ if( layers[layers_num].merge_scanlines == NULL ) layers[layers_num].merge_scanlines = alphablend_scanlines ; layers[layers_num].clip_width = width ; layers[layers_num].clip_height = height ; if( layers_num > 0 ) { layers[layers_num].dst_x = x ; layers[layers_num].dst_y = y ; }else { to_width = width ; to_height = height ; if( width != layers[layers_num].im->width || height != layers[layers_num].im->height ) { ASImage *scaled_bottom ; /* see ASScale.2 : */ scaled_bottom = scale_asimage( asv, layers[layers_num].im, width, height, False, 100, ASIMAGE_QUALITY_DEFAULT ); destroy_asimage( &(layers[layers_num].im) ); layers[layers_num].im = scaled_bottom ; } } ++layers_num ; } } if( layers_num <= 0 ) { show_error( "there is no images to merge. Aborting"); return 2; } /* see ASMerge.4 */ merged_im = merge_layers( asv, layers, layers_num, to_width, to_height, #ifndef X_DISPLAY_MISSING ASA_XImage, #else ASA_ASImage, #endif 0, ASIMAGE_QUALITY_DEFAULT ); while( --layers_num >= 0 ) destroy_asimage( &(layers[layers_num].im) ); free( layers ); if( merged_im ) { #ifndef X_DISPLAY_MISSING /* see ASView.4 : */ Window w = create_top_level_window( asv, DefaultRootWindow(dpy), 32, 32, to_width, to_height, 1, 0, NULL, "ASMerge", NULL ); if( w != None ) { Pixmap p ; XMapRaised (dpy, w); /* see ASView.5 : */ p = asimage2pixmap( asv, DefaultRootWindow(dpy), merged_im, NULL, True ); destroy_asimage( &merged_im ); /* see common.c: set_window_background_and_free() : */ p = set_window_background_and_free( w, p ); /* see common.c: wait_closedown() : */ } wait_closedown(w); dpy = NULL; #else /* writing result into the file */ ASImage2file( merged_im, NULL, "asmerge.jpg", ASIT_Jpeg, NULL ); destroy_asimage( &merged_im ); #endif } #ifdef DEBUG_ALLOCS build_xpm_colormap(NULL); print_unfreed_mem(); #endif return 0 ; }