int main (int argc, char **argv) { int i ; char *source_dir = NULL ; const char *destination_dir = NULL ; Bool do_data = False; ASDocType target_type = DocType_Source ; /* Save our program name - for error messages */ set_DeadPipe_handler(DeadPipe); InitMyApp (CLASS_ASDOCGEN, argc, argv, NULL, asdocgen_usage, 0 ); LinkAfterStepConfig(); InitSession(); for( i = 1 ; i< argc ; ++i) { LOCAL_DEBUG_OUT( "argv[%d] = \"%s\", original argv[%d] = \"%s\"", i, argv[i]?argv[i]:"(null)", i, MyArgs.saved_argv[i]); if( argv[i] != NULL ) { if( (strcmp( argv[i], "-t" ) == 0 || strcmp( argv[i], "--target" ) == 0) && i+1 < argc && argv[i+1] != NULL ) { ++i ; if( mystrcasecmp( argv[i], "plain" ) == 0 || mystrcasecmp( argv[i], "text" ) == 0) target_type = DocType_Plain ; else if( mystrcasecmp( argv[i], "html" ) == 0 ) target_type = DocType_HTML ; else if( mystrcasecmp( argv[i], "php" ) == 0 ) target_type = DocType_PHP ; else if( mystrcasecmp( argv[i], "xml" ) == 0 ) target_type = DocType_XML ; else if( mystrcasecmp( argv[i], "nroff" ) == 0 ) target_type = DocType_NROFF ; else if( mystrcasecmp( argv[i], "source" ) == 0 ) target_type = DocType_Source ; else show_error( "unknown target type \"%s\"" ); }else if( (strcmp( argv[i], "-s" ) == 0 || strcmp( argv[i], "--css" ) == 0) && i+1 < argc && argv[i+1] != NULL ) { ++i ; HTML_CSS_File = argv[i] ; }else if( strcmp( argv[i], "--faq-css" ) == 0 && i+1 < argc && argv[i+1] != NULL ) { ++i ; FAQ_HTML_CSS_File = argv[i] ; }else if( strcmp( argv[i], "--html-data-back" ) == 0 && i+1 < argc && argv[i+1] != NULL ) { ++i ; if( strcasecmp( argv[i], "none") == 0 ) HTML_DATA_BACKGROUND_File = NULL ; else HTML_DATA_BACKGROUND_File = argv[i] ; }else if( (strcmp( argv[i], "-d" ) == 0 || strcmp( argv[i], "--data" ) == 0) ) { do_data = True ; }else if( (strcmp( argv[i], "-S" ) == 0 || strcmp( argv[i], "--source" ) == 0) && i+1 < argc && argv[i+1] != NULL ) { ++i ; source_dir = argv[i] ; }else if( (strcmp( argv[i], "-D" ) == 0 || strcmp( argv[i], "--dst" ) == 0) && i+1 < argc && argv[i+1] != NULL ) { ++i ; destination_dir = argv[i] ; } } } if( destination_dir == NULL ) destination_dir = do_data?"data":ASDocTypeExtentions[target_type] ; if( source_dir == NULL ) source_dir = do_data?"../../afterstep":"source" ; #if 0 ConnectAfterStep ( mask_reg, 0); SendInfo ( "Nop \"\"", 0); #endif ProcessedSyntaxes = create_ashash( 7, pointer_hash_value, NULL, NULL ); Glossary = create_ashash( 4096, string_hash_value, string_compare, string_destroy ); Index = create_ashash( 4096, string_hash_value, string_compare, string_destroy ); UserLinks = create_ashash( 4096, string_hash_value, string_compare, string_destroy ); APILinks = create_ashash( 4096, string_hash_value, string_compare, string_destroy ); Links = UserLinks; GlossaryName = UserGlossaryName ; TopicIndexName = UserTopicIndexName ; if( target_type < DocType_Source ) { time_t curtime; struct tm *loctime; DocBookVocabulary = create_ashash( 7, casestring_hash_value, casestring_compare, string_destroy_without_data ); for( i = 1 ; i < DOCBOOK_SUPPORTED_IDS ; ++i ) add_hash_item( DocBookVocabulary, AS_HASHABLE(SupportedDocBookTagInfo[i].tag), (void*)(SupportedDocBookTagInfo[i].tag_id)); /* Get the current time. */ curtime = time (NULL); /* Convert it to local time representation. */ loctime = localtime (&curtime); strftime(CurrentDateLong, DATE_SIZE, "%b %e %Y", loctime); strftime(CurrentDateShort, DATE_SIZE, "%m/%d/%Y", loctime); } i = 0 ; LOCAL_DEBUG_OUT( "Starting main action... %s", "" ); if( target_type >= DocType_Source ) /* 1) generate HTML doc structure */ { while( TopLevelSyntaxes[i] ) { /* create directory structure for source docs and all the missing files */ check_syntax_source( source_dir, TopLevelSyntaxes[i], (i >= MODULE_SYNTAX_START) ); ++i ; } check_syntax_source( source_dir, NULL, True ); }else if( do_data ) { char *env_path1 = NULL, *env_path2 = NULL ; ASColorScheme *cs = NULL ; if ((dpy = XOpenDisplay (MyArgs.display_name))) { set_current_X_display (dpy); Scr.MyDisplayWidth = DisplayWidth (dpy, Scr.screen); Scr.MyDisplayHeight = DisplayHeight (dpy, Scr.screen); Scr.asv = create_asvisual (dpy, Scr.screen, DefaultDepth(dpy,Scr.screen), NULL); }else { Scr.asv = create_asvisual(NULL, 0, 32, NULL); } asxml_var_insert("xroot.width", 640); asxml_var_insert("xroot.height", 480); env_path1 = getenv( "IMAGE_PATH" ) ; env_path2 = getenv( "PATH" ); if( env_path1 == NULL ) { env_path1 = env_path2; env_path2 = NULL ; } Scr.image_manager = create_image_manager( NULL, 2.2, env_path1, env_path2, NULL ); set_xml_image_manager( Scr.image_manager ); env_path1 = getenv( "FONT_PATH" ) ; Scr.font_manager = create_font_manager( dpy, env_path1, NULL ); set_xml_font_manager( Scr.font_manager ); /*ReloadASEnvironment( NULL, NULL, NULL, False ); */ cs = make_default_ascolor_scheme(); populate_ascs_colors_rgb( cs ); populate_ascs_colors_xml( cs ); free( cs ); TopicIndexName = NULL ; CurrHtmlBackFile = HTML_DATA_BACKGROUND_File ; gen_data_doc( source_dir, destination_dir?destination_dir:"data", "", "Installed data files - fonts, images and configuration", target_type ); flush_ashash( Glossary ); flush_ashash( Index ); }else { char *api_dest_dir ; api_dest_dir = make_file_name( destination_dir, "API" ); GlossaryName = UserGlossaryName ; TopicIndexName = UserTopicIndexName ; Links = UserLinks; DocGenerationPass = 2 ; while( --DocGenerationPass >= 0 ) { gen_code_doc( "../../libAfterImage", destination_dir, "asimagexml.c", "AfterImage XML", "XML schema to be used for scripting image manipulation by AfterStep and ascompose", target_type ); /* we need to generate some top level files for afterstep itself : */ gen_syntax_doc( source_dir, destination_dir, NULL, target_type ); for( i = 0 ; TopLevelSyntaxes[i] ; ++i ) gen_syntax_doc( source_dir, destination_dir, TopLevelSyntaxes[i], target_type ); if( DocGenerationPass == 0 ) { gen_faq_doc( source_dir, destination_dir, target_type ); gen_glossary( destination_dir, "Glossary", target_type ); gen_index( destination_dir, "index", target_type, True ); } flush_ashash( ProcessedSyntaxes ); } flush_ashash( Glossary ); flush_ashash( Index ); GlossaryName = APIGlossaryName ; TopicIndexName = APITopicIndexName ; Links = APILinks; DocGenerationPass = 2 ; CurrentManType = 3 ; while( --DocGenerationPass >= 0 ) { int s ; for( s = 0 ; libAfterImage_Sources[s].src_file != NULL ; ++s ) { gen_code_doc( "../../libAfterImage", api_dest_dir, libAfterImage_Sources[s].src_file, libAfterImage_Sources[s].descr_short, libAfterImage_Sources[s].descr_long, target_type ); } if( DocGenerationPass == 0 ) { gen_glossary( api_dest_dir, "Glossary", target_type ); gen_index( api_dest_dir, "index", target_type, False ); } flush_ashash( Glossary ); flush_ashash( Index ); } } if( dpy ) XCloseDisplay (dpy); return 0; }
Bool load_font (const char *name_in, MyFont * font) #endif { char *name; char *clean_name; int font_size = asxml_var_get ("font.size"); if (font == NULL) return False; if (font_size <= 0) font_size = 14; #if defined(LOG_FONT_CALLS) && defined(DEBUG_ALLOCS) log_call (file, line, "load_font", name); #endif if (ASDefaultScr->font_manager == NULL) { char *path = getenv ("FONT_PATH"); if (path == NULL) path = getenv ("PATH"); ASDefaultScr->font_manager = create_font_manager (dpy, path, NULL); } name = name_in ? (char *)name_in : font->name; clean_name = name; if (clean_name != NULL) { int i = 0; register char *ptr = clean_name; while (ptr[i]) ++i; while (--i >= 0) if (!isdigit (ptr[i])) break; if ((isspace (ptr[i]) || ptr[i] == '-') && ptr[i + 1]) { font_size = atoi (&(ptr[i + 1])); while (i > 0 && isspace (ptr[i - 1])) --i; clean_name = mystrndup (name, i); } } if (clean_name != NULL) { if ((font->as_font = get_asfont (ASDefaultScr->font_manager, clean_name, 0, font_size, ASF_Freetype)) != NULL) show_progress ("Successfully loaded freetype font \"%s\"", clean_name); } if (font->as_font == NULL && name != NULL) { if ((font->as_font = get_asfont (ASDefaultScr->font_manager, name, 0, font_size, ASF_GuessWho)) != NULL) show_progress ("Successfully loaded font \"%s\"", name); } if (font->as_font == NULL) { font->as_font = get_asfont (ASDefaultScr->font_manager, default_font, 0, font_size, ASF_GuessWho); show_warning ("failed to load font \"%s\" - using default instead", name); } if (clean_name && clean_name != name) free (clean_name); if (font->as_font != NULL && name != font->name) set_string (&(font->name), mystrdup (name)); return (font->as_font != NULL); }
Bool ReloadASEnvironment (ASImageManager ** old_imageman, ASFontManager ** old_fontman, BaseConfig ** config_return, Bool flush_images, Bool support_shared_images) { char *old_pixmap_path = NULL; char *old_font_path = NULL; char *configfile = NULL; BaseConfig *config = NULL; ASEnvironment *e = NULL; ScreenInfo *scr = get_current_screen (); if (Environment != NULL) { old_pixmap_path = Environment->pixmap_path; Environment->pixmap_path = NULL; old_font_path = Environment->font_path; Environment->font_path = NULL; } configfile = Session->overriding_file; if (configfile == NULL) configfile = make_session_file (Session, BASE_FILE, False /* no longer use #bpp in filenames */ ); if (configfile != NULL) { config = ParseBaseOptions (configfile, MyName); if (config != NULL) show_progress ("BASE configuration loaded from \"%s\" ...", configfile); else show_progress ("BASE could not be loaded from \"%s\" ...", configfile); if (configfile != Session->overriding_file) free (configfile); } else show_warning ("BASE configuration file cannot be found"); if (config == NULL) { if (Environment != NULL) { Environment->pixmap_path = old_pixmap_path; Environment->font_path = old_font_path; return False; } /* otherwise we should use default values - Environment should never be NULL */ Environment = make_default_environment (); } else { BaseConfig2ASEnvironment (config, &Environment); if (config_return) *config_return = config; else DestroyBaseConfig (config); } e = Environment; /* Save base filename to pass to modules */ if (mystrcmp (old_pixmap_path, e->pixmap_path) == 0 || (e->pixmap_path != NULL && scr->image_manager == NULL) || flush_images) { reload_screen_image_manager (scr, old_imageman); } if (old_pixmap_path && old_pixmap_path != e->pixmap_path) free (old_pixmap_path); if (mystrcmp (old_font_path, e->font_path) == 0 || (e->font_path != NULL && scr->font_manager == NULL)) { if (old_fontman) { *old_fontman = scr->font_manager; } else if (scr->font_manager) destroy_font_manager (scr->font_manager, False); scr->font_manager = create_font_manager (dpy, e->font_path, NULL); set_xml_font_manager (scr->font_manager); show_progress ("Font Path changed to \"%s\" ...", e->font_path ? e->font_path : ""); } if (old_font_path && old_font_path != e->font_path) free (old_font_path); if (e->desk_pages_h > 0) { if (e->desk_pages_h <= 100) scr->VxMax = (e->desk_pages_h - 1) * scr->MyDisplayWidth; else { scr->VxMax = MAX (e->desk_pages_h, scr->MyDisplayWidth) - scr->MyDisplayWidth; e->desk_pages_h = (e->desk_pages_h + scr->MyDisplayWidth - 1) / scr->MyDisplayWidth; } } else scr->VxMax = 0; if (e->desk_pages_v > 0) { if (e->desk_pages_v <= 100) scr->VyMax = (e->desk_pages_v - 1) * scr->MyDisplayHeight; else { scr->VyMax = MAX (e->desk_pages_v, scr->MyDisplayHeight) - scr->MyDisplayHeight; e->desk_pages_v = (e->desk_pages_v + scr->MyDisplayHeight - 1) / scr->MyDisplayHeight; } } else scr->VyMax = 0; scr->VScale = e->desk_scale; if (scr->VScale <= 1) scr->VScale = 2; else if (scr->VScale >= scr->MyDisplayHeight / 2) scr->VScale = scr->MyDisplayHeight / 2; #ifdef XSHMIMAGE if (support_shared_images) { if (get_flags (e->flags, ASE_NoSharedMemory)) disable_shmem_images (); else enable_shmem_images (); } SHOW_CHECKPOINT; #endif return (config != NULL); }