bool Lng::is_installed( lng_eLanguage language) { pwr_tFileName fname; pwr_tFileName found_file; pwr_tStatus sts; strcpy( fname, "$pwr_exe/"); strcat( fname, lang_to_str( language)); strcat( fname, "/xtt_lng.dat"); dcli_translate_filename( fname, fname); sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT); dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END); if ( ODD(sts)) return true; // Try $pwr_eexe also strcpy( fname, "$pwr_eexe/"); strcat( fname, lang_to_str( language)); strcat( fname, "/xtt_lng.dat"); dcli_translate_filename( fname, fname); sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT); dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END); if ( ODD(sts)) return true; return false; }
int Graph::generate_web_help() { pwr_tStatus sts; pwr_tFileName fname; // Copy default css-file to pwrp_web system("cp $pwr_exe/pwr_css.css $pwrp_web/"); // If $pwrp_load/xtt_help.dat exist convert this to html sts = dcli_search_file(pwr_cNameProjectXttHelp, fname, DCLI_DIR_SEARCH_INIT); if (ODD(sts)) { system("co_convert -d $pwrp_web -t " pwr_cNameProjectXttHelp); } sts = dcli_search_file(pwr_cNameProjectXttHelp, fname, DCLI_DIR_SEARCH_END); return 1; }
void CLogNav::get_files() { char nodename[40]; pwr_tStatus sts; char file_spec[200]; char found_file[200]; pwr_tTime time = {0,0}; struct stat info; syi_NodeName( &sts, nodename, sizeof(nodename)); sprintf( file_spec, "$pwrp_log/pwr_%s.log", nodename); sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT); if ( ODD(sts)) { stat( found_file, &info); time.tv_sec = info.st_ctime; CLogFile *cf = new CLogFile( found_file, time); file_list.push_back( *cf); delete cf; } else { CLogFile *cf = new CLogFile(); file_list.push_back( *cf); delete cf; } dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END); for ( int i = 1; i < 21; i++) { sprintf( file_spec, "$pwrp_log/pwr_%s.log.%d.gz", nodename, i); sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT); if ( ODD(sts)) { stat( found_file, &info); time.tv_sec = info.st_ctime; CLogFile *cf = new CLogFile( found_file, time); file_list.push_back( *cf); delete cf; } dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END); } }
void CoWowMotif::file_search_cb( Widget widget, XtPointer data) { XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *) data; XmString names[WOW_MAXNAMES]; char *mask; char found_file[200]; int sts; int file_cnt; int i; if ( !XmStringGetLtoR( cbs->mask, XmFONTLIST_DEFAULT_TAG, &mask)) return; file_cnt = 0; sts = dcli_search_file( mask, found_file, DCLI_DIR_SEARCH_INIT); while( ODD(sts)) { if ( file_cnt >= WOW_MAXNAMES) break; names[file_cnt++] = XmStringCreateLocalized( found_file); sts = dcli_search_file( mask, found_file, DCLI_DIR_SEARCH_NEXT); } sts = dcli_search_file( mask, found_file, DCLI_DIR_SEARCH_END); XtFree( mask); if ( file_cnt) { XtVaSetValues( widget, XmNfileListItems, names, XmNfileListItemCount, file_cnt, XmNdirSpec, names[0], XmNlistUpdated, True, NULL); for ( i = 0; i < file_cnt; i++) XmStringFree( names[i]); } else XtVaSetValues( widget, XmNfileListItems, NULL, XmNfileListItemCount, 0, XmNlistUpdated, True, NULL); }
void wb_build::webgraph( pwr_tOid oid) { pwr_tFileName dest_fname; pwr_tFileName src_fname; pwr_tCmd cmd; pwr_tString80 java_name; pwr_tString80 name; pwr_tTime dest_time, src_time; int check_hierarchy = cdh_ObjidIsNotNull( m_hierarchy); int hierarchy_found = 0; int is_frame, is_applet; char jname[80]; pwr_tStatus fsts; int jexport; int found; pwr_tFileName found_file, file_spec; pwr_tFileName graph_name, dir; char dev[80], type[80]; int version; pwr_tString80 appletsignature = ""; char *s; wb_object o = m_session.object(oid); if ( !o) { m_sts = o.sts(); return; } // Check that no ancestor is a LibHier for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) { if ( p.cid() == pwr_eClass_LibHier) { m_sts = PWRB__INLIBHIER; return; } if ( check_hierarchy && cdh_ObjidIsEqual( m_hierarchy, p.oid())) hierarchy_found = 1; } if ( check_hierarchy && !hierarchy_found) { m_sts = PWRB__NOBUILT; return; } wb_attribute a = m_session.attribute( oid, "RtBody", "Name"); if ( !a) { m_sts = a.sts(); return; } a.value( java_name); if ( !a) { m_sts = a.sts(); return; } if ( isupper(java_name[0])) { cdh_ToLower( java_name, java_name); java_name[0] = toupper(java_name[0]); // Get the .pwg file for this javaname strcpy( graph_name, cdh_Low(java_name)); sprintf( name, "$pwrp_pop/%s.pwg", graph_name); dcli_translate_filename( name, name); m_sts = dcli_file_time( name, &src_time); if ( evenSts()) { // Search in all pwg files found = 0; strcpy( file_spec, "$pwrp_pop/*.pwg"); for ( fsts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT); ODD(fsts); fsts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_NEXT)) { fsts = grow_IsJava( found_file, &is_frame, &is_applet, jname); if ( EVEN(fsts)) continue; if ( is_frame && strcmp( jname, java_name) == 0) { dcli_parse_filename( found_file, dev, dir, graph_name, type, &version); strcpy( name, found_file); found = 1; break; } } dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END); if ( !found) { char msg[200]; sprintf( msg, "Graph for %s not found", java_name); MsgWindow::message('E', msg, msgw_ePop_Yes, oid); m_sts = PWRB__NOBUILT; return; } } m_sts = dcli_file_time( name, &src_time); if ( evenSts()) return; // Check exported java frame jexport = 0; sprintf( dest_fname, "$pwrp_pop/%s.java", java_name); dcli_translate_filename( dest_fname, dest_fname); fsts = dcli_file_time( dest_fname, &dest_time); if ( opt.force || EVEN(fsts) || time_Acomp( &src_time, &dest_time) == 1) jexport = 1; if ( jexport) { if ( !m_wnav) { sprintf( cmd, "Build: WebGraph Unable to export java in this environment %s", java_name); MsgWindow::message('W', cmd, msgw_ePop_No, oid); } else { // Get signature from WebHandler for ( wb_object p = o.parent(); p.oddSts(); p = p.parent()) { if ( p.cid() == pwr_cClass_WebHandler) { wb_attribute a = m_session.attribute( p.oid(), "RtBody", "AppletSignature"); if ( !a) { m_sts = a.sts(); return; } a.value( appletsignature); if ( !a) { m_sts = a.sts(); return; } dcli_trim( appletsignature, appletsignature); break; } } Ge *gectx = m_wnav->ge_new( graph_name, 1); if ( strcmp( appletsignature, "") == 0) strcpy( cmd, "export java"); else sprintf( cmd, "export java /signature=\"%s\"", appletsignature); m_sts = gectx->command( cmd); if ( evenSts()) { msg_GetMsg( m_sts, cmd, sizeof(cmd)); MsgWindow::message('E', cmd, msgw_ePop_Yes, oid); m_sts = PWRB__NOBUILT; delete gectx; return; } delete gectx; sprintf( cmd, "Build: WebGraph Export java %s", java_name); MsgWindow::message('I', cmd, msgw_ePop_No, oid); m_sts = PWRB__SUCCESS; } } } else { // Copy from $pwrp_pop to $pwrp_web strcpy( graph_name, cdh_Low(java_name)); cdh_ToLower( graph_name, graph_name); strcpy( src_fname, "$pwrp_pop/"); strcat( src_fname, graph_name); if ( strstr( src_fname, ".pwg") == 0) strcat( src_fname, ".pwg"); dcli_translate_filename( src_fname, src_fname); m_sts = dcli_file_time( src_fname, &src_time); if ( evenSts()) { m_sts = PWRB__NOBUILT; return; } strcpy( dest_fname, "$pwrp_web/"); strcat( dest_fname, graph_name); if ( strstr( dest_fname, ".pwg") == 0) strcat( dest_fname, ".pwg"); dcli_translate_filename( dest_fname, dest_fname); m_sts = dcli_file_time( dest_fname, &dest_time); if ( opt.force || evenSts() || src_time.tv_sec > dest_time.tv_sec) { sprintf( cmd, "cp %s %s", src_fname, dest_fname); system( cmd); sprintf( cmd, "Build: WebGraph copy $pwrp_pop/%s -> $pwrp_web", graph_name); MsgWindow::message( 'I', cmd, msgw_ePop_No, oid); strcpy( name, graph_name); if (( s = strrchr( name, '.'))) *s = 0; wb_log::log( wlog_eCategory_GeBuild, name, 0); m_sts = PWRB__SUCCESS; } else m_sts = PWRB__NOBUILT; } }
void Ge::activate_open() { prevtable_clear(); int file_cnt; int allocated, old_allocated; pwr_tString80 *file_p; pwr_tString80 *old_file_p; char found_file[80]; char fname[80]; int sts; char dev[80]; char dir[80]; char file[80]; char type[80]; int version; // Get the pwg files and order them dcli_translate_filename( fname, "$pwrp_pop/*.pwg"); file_cnt = 0; allocated = 0; sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT); while ( ODD(sts)) { if ( strstr( found_file, "__p")) { // Skip subgraph pages sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_NEXT); continue; } file_cnt++; if ( file_cnt > allocated - 1) { if ( allocated == 0) { allocated = 100; file_p = (pwr_tString80 *) malloc( allocated * sizeof(*file_p)); } else { old_file_p = file_p; old_allocated = allocated; allocated += 100; file_p = (pwr_tString80 *) malloc( allocated * sizeof(*file_p)); memcpy( file_p, old_file_p, old_allocated * sizeof(*file_p)); free( old_file_p); } } dcli_parse_filename( found_file, dev, dir, file, type, &version); strcpy( file_p[file_cnt - 1], file); if ( strcmp( file, "") == 0) file_cnt--; sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_NEXT); } dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END); if ( !file_cnt) { return; } strcpy( file_p[file_cnt], ""); qsort( file_p, file_cnt, sizeof(*file_p), Ge::sort_files); create_list( "Open Graph", (char *)file_p, Ge::open_list_cb, (void *)this); free( file_p); // open_input_dialog( "Graph name", "Open Graph", "", // Ge::open_graph); }
int ItemLocalSubGraphs::open_children( SubPalette *subpalette, double x, double y) { double node_x, node_y; int child_exist; brow_GetNodePosition( node, &node_x, &node_y); if ( brow_IsOpen( node)) { // Close brow_SetNodraw( subpalette->brow->ctx); brow_CloseNode( subpalette->brow->ctx, node); if ( brow_IsOpen( node) & subpalette_mOpen_Attributes) brow_RemoveAnnotPixmap( node, 1); if ( brow_IsOpen( node) & subpalette_mOpen_Children) brow_SetAnnotPixmap( node, 0, subpalette->brow->pixmap_map); brow_ResetOpen( node, subpalette_mOpen_All); brow_ResetNodraw( subpalette->brow->ctx); brow_Redraw( subpalette->brow->ctx, node_y); } else { int sts; char found_file[120]; char fname[120]; char dev[80], dir[80], file[80], type[80]; int version; char text[80]; char *s; int idx; char file_str[5][80]; int nr; int i; vector<LocalFile> fvect; // Create some children brow_SetNodraw( subpalette->brow->ctx); child_exist = 0; nr = dcli_parse( filename, ",", "", (char *)file_str, sizeof( file_str) / sizeof( file_str[0]), sizeof( file_str[0]), 0); for ( i = 0; i < nr; i++) { dcli_translate_filename( fname, file_str[i]); sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT); if ( ODD(sts)) { LocalFile f; strcpy( f.name, found_file); fvect.push_back( f); } while ( ODD(sts)) { sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_NEXT); if ( ODD(sts)) { LocalFile f; strcpy( f.name, found_file); fvect.push_back( f); } } dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END); } subpalette_sort( fvect); for ( i = 0; i < (int) fvect.size(); i++) { dcli_parse_filename( fvect[i].name, dev, dir, file, type, &version); cdh_ToLower( text, file); text[0] = toupper( text[0]); // Skip next pages in animations if ( !((s = strstr( text, "__p")) && sscanf( s+3, "%d", &idx))) { new ItemFile( subpalette, text, fvect[i].name, 0, node, flow_eDest_IntoLast); child_exist = 1; } } if ( child_exist) { brow_SetOpen( node, subpalette_mOpen_Children); brow_SetAnnotPixmap( node, 0, subpalette->brow->pixmap_openmap); } brow_ResetNodraw( subpalette->brow->ctx); if ( child_exist) brow_Redraw( subpalette->brow->ctx, node_y); } return 1; }
int main( int argc, char *argv[]) { pwr_tFileName filespec; pwr_tFileName outfile; pwr_tFileName found_file; merge_eMtype mtype; FILE *fp; FILE *outfp; char line[200]; int sts; char mtab[1000][32]; int mtabcnt = 0; int i; int idx; pwr_tCmd cmd; pwr_tFileName incdir; pwr_tFileName cfile; pwr_tFileName ofile; char pwre_cc[250]; char pwre_cxx[250]; char pwre_ar[250]; char *s; int arg_keep = 0; int arg_verbose = 0; int in_if = 0; #if defined OS_LINUX char os[] = "OS_LINUX"; char dos[] = "-DOS_LINUX -DOS_POSIX"; char cflags[] = ""; #elif defined OS_MACOS char os[] = "OS_MACOS"; char dos[] = "-DOS_MACOS -DOS_POSIX"; char cflags[] = ""; #elif defined OS_FREEBSD char os[] = "OS_FREEBSD"; char dos[] = "-DOS_FREEBSD -DOS_POSIX"; char cflags[] = ""; #elif defined OS_OPENBSD char os[] = "OS_OPENBSD"; char dos[] = "-DOS_OPENBSD -DOS_POSIX"; char cflags[] = ""; #elif defined OS_CYGWIN char os[] = "OS_CYGWIN"; char dos[] = "-DOS_CYGWIN -DOS_POSIX"; char cflags[] = "-I/usr/include/tirpc"; #endif if ( argc < 4) { usage(); exit(1); } if ( (s = getenv( "pwre_cc"))) strncpy( pwre_cc, s, sizeof(pwre_cc)); else strncpy( pwre_cc, "gcc", sizeof(pwre_cc)); if ( (s = getenv( "pwre_cxx"))) strncpy( pwre_cxx, s, sizeof(pwre_cxx)); else strncpy( pwre_cxx, "g++", sizeof(pwre_cxx)); if ( (s = getenv( "pwre_ar"))) strncpy( pwre_ar, s, sizeof(pwre_ar)); else strncpy( pwre_ar, "ar", sizeof(pwre_ar)); idx = 0; for ( i = 1; i < argc; i++) { if ( strcmp( argv[i], "-k") == 0) arg_keep = 1; else if ( strcmp( argv[i], "-v") == 0) arg_verbose = 1; else { switch ( idx) { case 0: if ( strcmp( argv[i], "io_base") == 0) mtype = merge_eMtype_IoBase; else if ( strcmp( argv[i], "wb_base") == 0) mtype = merge_eMtype_WbBase; else if ( strcmp( argv[i], "xtt_base") == 0) mtype = merge_eMtype_XttBase; else { usage(); exit(1); } idx++; break; case 1: strncpy( filespec, argv[i], sizeof(filespec)); idx++; break; case 2: strncpy( outfile, argv[i], sizeof(filespec)); idx++; break; } } } sts = dcli_search_file( filespec, found_file, DCLI_DIR_SEARCH_INIT); while ( ODD(sts)) { fp = fopen( found_file, "r"); if ( !fp) { printf( "Unable to open file %s\n", found_file); exit(1); } while( dcli_read_line( line, sizeof(line), fp)) { dcli_trim( line, line); if ( strncmp( line, "#if" , 3) == 0) { in_if = ! check_os( &line[4], os); continue; } else if ( in_if) { if ( strncmp( line, "#endif", 6) == 0) { if ( in_if) in_if = 0; continue; } continue; } else if ( line[0] == 0 || line[0] == '#') continue; strncpy( mtab[mtabcnt++], line, sizeof(mtab[0])); if ( mtabcnt > (int) sizeof(mtab)/sizeof(mtab[0]) - 1) break; } fclose( fp); sts = dcli_search_file( filespec, found_file, DCLI_DIR_SEARCH_NEXT); } dcli_search_file( filespec, found_file, DCLI_DIR_SEARCH_END); switch ( mtype) { case merge_eMtype_IoBase: { strncpy( cfile, "/tmp/rt_io_base_methods.c", sizeof(cfile)); strncpy( ofile, "/tmp/rt_io_base_methods.o", sizeof(cfile)); outfp = fopen( cfile, "w"); if ( !outfp) { printf( "Unable to open file %s\n", outfile); exit(1); } fprintf( outfp, "#include \"rt_io_base.h\"\n"); for ( i = 0; i < mtabcnt; i++) { fprintf( outfp, "pwr_dImport pwr_BindIoMethods(%s);\n", mtab[i]); } fprintf( outfp, "pwr_BindIoClasses(Base) = {\n"); for ( i = 0; i < mtabcnt; i++) { fprintf( outfp, " pwr_BindIoClass(%s),\n", mtab[i]); } fprintf( outfp, " pwr_NullClass};\n"); fclose( outfp); break; } case merge_eMtype_WbBase: { strncpy( cfile, "/tmp/wb_i_base_methods.cpp", sizeof(cfile)); strncpy( ofile, "/tmp/wb_i_base_methods.o", sizeof(cfile)); outfp = fopen( cfile, "w"); if ( !outfp) { printf( "Unable to open file %s\n", outfile); exit(1); } fprintf( outfp, "#include \"wb_pwrs.h\"\n"); for ( i = 0; i < mtabcnt; i++) { fprintf( outfp, "pwr_dImport pwr_BindMethods(%s);\n", mtab[i]); } fprintf( outfp, "pwr_BindClasses(Base) = {\n"); for ( i = 0; i < mtabcnt; i++) { fprintf( outfp, " pwr_BindClass(%s),\n", mtab[i]); } fprintf( outfp, " pwr_NullClass};\n"); fclose( outfp); break; } case merge_eMtype_XttBase: { strncpy( cfile, "/tmp/xtt_i_methods.c", sizeof(cfile)); strncpy( ofile, "/tmp/xtt_i_methods.o", sizeof(cfile)); outfp = fopen( cfile, "w"); if ( !outfp) { printf( "Unable to open file %s\n", outfile); exit(1); } fprintf( outfp, "#include \"xtt_menu.h\"\n"); for ( i = 0; i < mtabcnt; i++) { fprintf( outfp, "pwr_dImport pwr_BindXttMethods(%s);\n", mtab[i]); } fprintf( outfp, "pwr_BindXttClasses(Base) = {\n"); for ( i = 0; i < mtabcnt; i++) { fprintf( outfp, " pwr_BindXttClass(%s),\n", mtab[i]); } fprintf( outfp, " pwr_NullClass};\n"); fclose( outfp); break; } } dcli_translate_filename( incdir, "$pwr_einc"); switch ( mtype) { case merge_eMtype_WbBase: snprintf( cmd, sizeof(cmd), "%s -c %s -I%s %s -o %s %s", pwre_cxx, cflags, incdir, dos, ofile, cfile); break; default: snprintf( cmd, sizeof(cmd), "%s -c %s -I%s %s -o %s %s", pwre_cc, cflags, incdir, dos, ofile, cfile); } if ( arg_verbose) printf( "co_merge: %s\n", cmd); system( cmd); snprintf( cmd, sizeof(cmd), "%s r %s %s", pwre_ar, outfile, ofile); if ( arg_verbose) printf( "co_merge: %s\n", cmd); system(cmd); snprintf( cmd, sizeof(cmd), "rm %s", ofile); system(cmd); if ( !arg_keep) { snprintf( cmd, sizeof(cmd), "rm %s", cfile); system(cmd); } return 1; }