static void tag_attr_open(const char* name) { io_print("\n"); tag_indent(); io_print(name); io_print("=\""); }
static void tag_attr(const char* attr, ...) { va_list args; va_start(args, attr); vsprintf(g_buffer, attr, args); va_end(args); io_print("\n"); tag_indent(); io_print(g_buffer); attrib++; }
void print_list(const char** list, const char* prefix, const char* postfix, const char* infix, const char* (*func)(const char*)) { int i = 0; while (*list) { const char* value = (func != NULL) ? func(*list) : *list; if (value != NULL) { if (i++ > 0) io_print(infix); io_print("%s%s%s", prefix, value, postfix); } ++list; } }
/* * Print a number with thousands' separators. */ static int grouping_print(struct grouping_state *gs, struct io_state *iop, const CHAR *cp, const CHAR *ep, locale_t locale) { const CHAR *cp0 = cp; if (io_printandpad(iop, cp, ep, gs->lead, zeroes, locale)) return (-1); cp += gs->lead; while (gs->nseps > 0 || gs->nrepeats > 0) { if (gs->nrepeats > 0) gs->nrepeats--; else { gs->grouping--; gs->nseps--; } if (io_print(iop, &gs->thousands_sep, 1, locale)) return (-1); if (io_printandpad(iop, cp, ep, *gs->grouping, zeroes, locale)) return (-1); cp += *gs->grouping; } if (cp > ep) cp = ep; return (cp - cp0); }
static void tag_open(const char* name) { if (opened) { if (version >= VS2005 && attrib > 0) { io_print("\n"); tag_indent(); } io_print(">\n"); } tag_indent(); io_print("<"); io_print(name); indent++; opened = 1; attrib = 0; }
int io_xprint(struct io *io, const char *str) { int len; len = io_print(io, str); if (len == -1) fatal("io_xprint(%p, %s, ...)", io, str); return len; }
void vs_list_files(const char* path, int stage) { const char* ptr = path; while (strncmp(ptr, "../", 3) == 0) ptr += 3; ptr = strchr(ptr, '/'); while (ptr != NULL) ptr = strchr(ptr + 1, '/'); ptr = strrchr(path, '/'); ptr = (ptr == NULL) ? (char*)path : ptr + 1; switch (stage) { case WST_OPENGROUP: if (strlen(path) > 0 && !matches(ptr, "..")) { tag_open("Filter"); tag_attr("Name=\"%s\"", ptr); tag_attr("Filter=\"\""); } break; case WST_CLOSEGROUP: if (strlen(path) > 0 && !matches(ptr, "..")) tag_close("Filter", 1); break; case WST_SOURCEFILE: tag_open("File"); tag_attr_open("RelativePath"); if (path[0] != '.') io_print(".\\"); io_print(path_translate(path, "windows")); tag_attr_close(); tag_close("File", 1); break; } }
static void eng_handle_position(const t_uicmd_position* p_cmd) { if (eng.state == STATE_IDLE) { char boardstr[BOARD_STR_SIZE + 1]; game_init(&(eng.game)); if (!p_cmd->startpos) { game_init_fen(&(eng.game), p_cmd->fenstring); } if (p_cmd->nmoves > 0) { const t_bool legal = game_play_moves(&(eng.game), p_cmd->moves, p_cmd->nmoves); if (!legal) { io_println("Illegal move found. Moves after and including illegal move ignored"); } } board_tostr(&(eng.game.board), boardstr); io_print(boardstr); } }
static const char* listFiles(const char* filename) { int i; io_print("\t\t<Unit filename=\"%s\">\n", filename); if (matches(path_getextension(filename), ".rc")) { io_print("\t\t\t<Option compilerVar=\"WINDRES\" />\n"); } else { /* Default is C++ (compilerVar=CPP) */ if (prj_is_lang("c")) io_print("\t\t\t<Option compilerVar=\"CC\" />\n"); else io_print("\t\t\t<Option compilerVar=\"CPP\" />\n"); if (!is_cpp(filename)) { /* Look for the specified pch header */ if (prj_has_pch() && matches(filename, prj_get_pch_header())) { io_print("\t\t\t<Option compile=\"1\" />\n"); io_print("\t\t\t<Option weight=\"0\" />\n"); } } } for (i = 0; i < prj_get_numconfigs(); ++i) { Package* pkg = prj_get_package(); io_print("\t\t\t<Option target=\"%s\" />\n", pkg->configs[i]->prjConfig->name); } io_print("\t\t</Unit>\n"); return NULL; }
static void tag_close(const char* name, int form) { indent--; if (form == 1) { if (opened) io_print(">\n"); tag_indent(); io_print("</"); io_print(name); io_print(">\n"); } else { if (version >= VS2005) { io_print("\n"); tag_indent(); } io_print("/>\n"); } opened = 0; }
static int writeWorkspace() { int i; if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "dsw"))) return 0; io_print("Microsoft Developer Studio Workspace File, Format Version 6.00\n"); io_print("# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n"); io_print("\n"); io_print("###############################################################################\n"); io_print("\n"); for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); io_print("Project: \"%s\"=%s - Package Owner=<4>\n", prj_get_pkgname(), prj_get_pkgfilename("dsp")); io_print("\n"); io_print("Package=<5>\n"); io_print("{{{\n"); io_print("}}}\n"); io_print("\n"); io_print("Package=<4>\n"); io_print("{{{\n"); /* Write package dependencies */ prj_select_config(0); print_list(prj_get_links(), "", "", "", listPackageDeps); io_print("}}}\n"); io_print("\n"); io_print("###############################################################################\n"); io_print("\n"); } io_print("Global:\n"); io_print("\n"); io_print("Package=<5>\n"); io_print("{{{\n"); io_print("}}}\n"); io_print("\n"); io_print("Package=<3>\n"); io_print("{{{\n"); io_print("}}}\n"); io_print("\n"); io_print("###############################################################################\n"); io_print("\n"); io_closefile(); return 1; }
unsigned char io_menu(const char* choices, const char* title, unsigned char default_choice, char alignement, const char* text_color, const char* bg_color, const char* border_color) { const char** text; unsigned short max_length=0; /* Maximum size of a choice */ unsigned short* length; unsigned short term_width = io_consoleWidth(); unsigned short term_height = io_consoleHeight(); unsigned short* x_text; /* x coordinate of each choice to print */ unsigned short* y_text; /* same with y coo */ unsigned short x_box; /* x coordinate of the menu's box */ unsigned short y_box; /* same with y coo */ unsigned short i = 0, j = 0; unsigned char nb_choices = 1; char key_pressed; char* origin_bg_color = io_currentBgColor(); char* origin_txt_color = io_currentTxtColor(); bool origin_cursor_visibility = io_cursorVisible(); bool origin_echo_setting = io_echoSetting(); if (origin_bg_color != NULL){ origin_bg_color = (char*) malloc((int)(strlen(origin_bg_color) + 1) * sizeof(char)); strcpy(origin_bg_color, io_currentBgColor()); } if (origin_txt_color != NULL){ origin_txt_color = (char*) malloc((int)(strlen(origin_txt_color) + 1) * sizeof(char)); strcpy(origin_txt_color, io_currentTxtColor()); } io_visibleCursor(false); while (choices[i] != '\0' || choices[i+1] != '\0'){ if (choices[i] == '\0') { ++nb_choices; } ++i; } length = (unsigned short*)calloc(nb_choices, sizeof(unsigned short)); text = malloc(nb_choices*sizeof(char*)); for (i = 0; i < nb_choices; ++i) { text[i] = choices+j; /* Points right after the last '\0' encountered */ length[i] = (unsigned short)strlen(text[i]); if (length[i] > max_length) { max_length = length[i]; } for (; choices[++j] != '\0';); /* increment until reaching a '\0' */ ++j; /* the next string starts right after that */ } if (title != NULL) { j = (unsigned short) strlen(title); } else{ j = 0; } if (j > max_length) { max_length = j; } x_text = (unsigned short*) calloc(nb_choices, sizeof(unsigned short)); y_text = (unsigned short*) calloc(nb_choices, sizeof(unsigned short)); x_box = (unsigned short)((term_width - max_length - 2) / 2); y_box = (unsigned short)((term_height - nb_choices - 2) / 2); /* Border */ if (border_color != NULL) { io_setCursorPos( x_box, (unsigned short)(y_box-1)); io_setBgColor(border_color); for (i = 0 ; i < max_length + 3 ; ++i) printf(" "); for (i = 0 ; i < nb_choices + 2 ; ++i) { io_setCursorPos( (unsigned short)(x_box + max_length + 2) , (unsigned short)(i + y_box) ); printf(" "); } } if (title != NULL) { io_print(IO_CENTER, (unsigned short)(y_box-1), 0, title); } io_setBgColor(bg_color); io_setTextColor(text_color); /* The inside of the box */ for (i = 0 ; i < nb_choices + 2 ; ++i) { io_setCursorPos( x_box, (unsigned short)(y_box + i)); for (j = 0 ; j < max_length + 2 ; ++j) { printf(" "); } } /* Computation of each text coordinate and display */ for (i = 0 ; i < nb_choices ; ++i) { switch(alignement) { case IO_CENTER: x_text[i] = (unsigned short) ((max_length + 2 - length[i]) / 2 + x_box); break; case IO_RIGHT: x_text[i] = (unsigned short) (x_box + max_length + 1 - length[i]); break; case IO_LEFT: default: x_text[i] = (unsigned short) (x_box + 1); break; } y_text[i] = (unsigned short) (y_box + i + 1); io_setCursorPos(x_text[i], y_text[i]); printf("%s", text[i]); } /* Printing default selection */ io_setTextAttributes("+invert"); io_setCursorPos(x_text[default_choice], y_text[default_choice]); printf("%s", text[default_choice]); io_setTextAttributes("-invert"); io_setCursorPos(x_text[default_choice], y_text[default_choice]); /* We don't want arrow keys to display their weird stuff on the screen */ io_setEcho( false ); /* j is used to store the current selected text */ do { if (term_height != io_consoleHeight() || term_width != io_consoleWidth()) { io_setCursorPos(0, 0); printf("Changing console size now is discouraged"); } key_pressed = io_getChar(); if ((key_pressed == IO_SPECIAL_CHAR && io_getChar() == '[') || key_pressed == '[') /* pressing an arrow inputs both SPECIAL, [, and a letter ; pressing pge up/down inputs [, a number, and ~ */ { /* deselecting text */ key_pressed = io_getChar(); io_setCursorPos(x_text[default_choice], y_text[default_choice]); printf("%s", text[default_choice]); switch (key_pressed) { case 'A': /* Arrow up */ if (default_choice == 0) default_choice = (unsigned char)(nb_choices - 1); else --default_choice; break; case 'B': /* Arrow down */ if (default_choice == nb_choices - 1) default_choice = 0; else ++default_choice; break; case '5': /* Page up */ if (io_getChar() == '~') { default_choice = 0; } break; case '6': /* Page Down */ if (io_getChar() == '~') { default_choice = (unsigned char)(nb_choices - 1); } break; default: break; } /* selecting text */ io_setCursorPos(x_text[default_choice], y_text[default_choice]); io_setTextAttributes("+invert"); printf("%s", text[default_choice]); io_setTextAttributes("-invert"); io_setCursorPos(x_text[default_choice], y_text[default_choice]); } /* loop until the user press Enter */ }while( key_pressed != '\n' ); /* echo back to normal */ io_setEcho(origin_echo_setting); io_setBgColor(origin_bg_color); io_setTextColor(origin_txt_color); io_visibleCursor(origin_cursor_visibility); free(text); free(x_text); free(y_text); free(length); free(origin_bg_color); free(origin_txt_color); return default_choice; }
void vs_list_files(const char* path, int stage) { int i; const char* pchHeader = prj_get_pch_header(); const char* pchSource = prj_get_pch_source(); const char* trimPrefix = prj_get_trimprefix(); const char* ptr = path; while (strncmp(ptr, "../", 3) == 0) ptr += 3; ptr = strchr(ptr, '/'); while (ptr != NULL) ptr = strchr(ptr + 1, '/'); ptr = strrchr(path, '/'); ptr = (ptr == NULL) ? (char*)path : ptr + 1; switch (stage) { case WST_OPENGROUP: if (strlen(path) > 0 && !matches(ptr, "..") && (!trimPrefix || strncmp(path, trimPrefix, strlen(trimPrefix)) == 0)) { tag_open("Filter"); tag_attr("Name=\"%s\"", ptr); tag_attr("Filter=\"\""); } break; case WST_CLOSEGROUP: if (strlen(path) > 0 && !matches(ptr, "..") && (!trimPrefix || strncmp(path, trimPrefix, strlen(trimPrefix)) == 0)) tag_close("Filter", 1); break; case WST_SOURCEFILE: tag_open("File"); tag_attr_open("RelativePath"); if (path[0] != '.') io_print(".\\"); io_print(path_translate(path, "windows")); tag_attr_close(); /* Add FileConfiguration section if this is a special PCH file, or if it's a custom-built .asm */ if (matches(path_getname(path), pchSource) || endsWith(path, ".asm") || (prj_is_kind("cxxtestgen") && endsWith(path, ".h"))) { for (i = 0; i < prj_get_numconfigs(); ++i) { prj_select_config(i); tag_open("FileConfiguration"); tag_attr("Name=\"%s|Win32\"", prj_get_cfgname()); if (endsWith(path, ".asm")) { tag_open("Tool"); tag_attr("Name=\"VCCustomBuildTool\""); tag_attr("Description=\"Assembling $(InputPath)\""); { // note: copy into our strings because path_* use static buffers. char nasm_path[512]; // PATH_MAX isn't defined char input_dir[512]; strcpy(nasm_path, path_translate(prj_get_nasmpath(), "windows")); // note: NASM chokes on -i"path" and says "no input file". // we therefore use the *relative* input directory, not VC's $(InputDir) - // this is more likely not to contain a space in directory name. strcpy(input_dir, path_translate(path_getdir(path) , "windows")); // required - NASM just concatenates include path and filename. strcat(input_dir, "\\"); tag_attr("CommandLine=\"%s -i %s -f win32 "$(InputPath)" -o "$(IntDir)\\$(InputName).obj"\"", nasm_path, input_dir); } tag_attr("Outputs=\"$(IntDir)\\$(InputName).obj\""); tag_close("Tool", 0); } else if (prj_is_kind("cxxtestgen") && endsWith(path, ".h")) { char *targetname = strdup(path_swapextension(path, ".h", ".cpp")); char *testoptions = strdup(prj_get_cxxtest_options()); // use relative file path instead of $(InputPath) to bypass cxxtestgen command line argument parsing weirdness const char *sourcename = path; tag_open("Tool"); tag_attr("Name=\"VCCustomBuildTool\""); tag_attr("Description=\"Generating %s\"", targetname); tag_attr("CommandLine=\"%s%s --part %s -o "%s" "%s"\"", endsWith(prj_get_cxxtestpath(), ".pl")?"perl ":"", path_translate(prj_get_cxxtestpath(), "windows"), testoptions, targetname, sourcename ); tag_attr("Outputs=\"%s\"", targetname); tag_close("Tool", 0); free(targetname); free(testoptions); } else /* (.asm doesn't need PCH) */ { tag_open("Tool"); tag_attr("Name=\"VCCLCompilerTool\""); tag_attr("UsePrecompiledHeader=\"1\""); tag_close("Tool", 0); } tag_close("FileConfiguration", 1); } } tag_close("File", 1); break; } }
int vs_write_cpp() { const char* str; int i, b; VsPkgData* data = (VsPkgData*)prj_get_data(); /* Open the file and write the header */ if (!io_openfile(path_join(prj_get_pkgpath(), prj_get_pkgname(), "vcproj"))) return 0; prj_select_config(0); io_print("<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"); tag_open("VisualStudioProject"); tag_attr("ProjectType=\"Visual C++\""); switch (version) { case VS2002: str = "7.00"; break; case VS2003: str = "7.10"; break; case VS2005: str = "8.00"; break; case VS2008: str = "9.00"; break; } tag_attr("Version=\"%s\"", str); tag_attr("Name=\"%s\"", prj_get_pkgname()); tag_attr("ProjectGUID=\"{%s}\"", data->projGuid); if (version >= VS2005) tag_attr("RootNamespace=\"%s\"", prj_get_pkgname()); tag_attr("Keyword=\"%s\"", prj_has_flag("managed") ? "ManagedCProj" : "Win32Proj"); tag_open("Platforms"); tag_open("Platform"); tag_attr("Name=\"Win32\""); tag_close("Platform", 0); tag_close("Platforms", 1); if (version >= VS2005) { tag_open("ToolFiles"); tag_close("ToolFiles", 1); } /* Write configurations */ tag_open("Configurations"); for (i = 0; i < prj_get_numconfigs(); ++i) { int optimization, debug, runtime, symbols, configTypeId; const char* pchHeader = prj_get_pch_header(); prj_select_config(i); if (prj_is_kind("winexe") || prj_is_kind("exe") || prj_is_kind("cxxtestgen") || prj_is_kind("run")) { configTypeId = 1; } else if (prj_is_kind("dll")) { configTypeId = 2; } else if (prj_is_kind("lib")) { configTypeId = 4; } else if (prj_is_kind("aspnet")) { puts("** Error: C++ ASP.NET projects are not supported"); return 0; } else { printf("** Error: unknown package kind '%s'\n", prj_get_kind()); return 0; } if (prj_has_flag("optimize-speed")) optimization = 2; else if (prj_has_flag("optimize-size")) optimization = 1; else if (prj_has_flag("optimize")) optimization = 3; else optimization = 0; debug = (optimization ==0); if (prj_has_flag("static-runtime")) runtime = (debug) ? 1 : 0; else runtime = (debug) ? 3 : 2; if (prj_has_flag("no-symbols")) symbols = 0; else symbols = (prj_has_flag("managed") || prj_has_flag("no-edit-and-continue")) ? 3 : 4; tag_open("Configuration"); tag_attr("Name=\"%s|Win32\"", prj_get_cfgname()); tag_attr("OutputDirectory=\"%s\"", prj_get_outdir()); tag_attr("IntermediateDirectory=\"%s\"", prj_get_objdir()); tag_attr("ConfigurationType=\"%d\"", configTypeId); tag_attr("CharacterSet=\"%d\"", prj_has_flag("unicode") ? 1 : 2); if (prj_has_flag("managed")) tag_attr("ManagedExtensions=\"%s\"", S_TRUE); /* Write out tool blocks */ for (b = 0; blocks[version][b] != BlocksEnd; ++b) { tag_open("Tool"); switch (blocks[version][b]) { case VCPreBuildEventTool: tag_attr("Name=\"VCPreBuildEventTool\""); break; case VCCustomBuildTool: tag_attr("Name=\"VCCustomBuildTool\""); if (prj_is_kind("run")) { tag_attr("Description=\"Running CxxTest Test Suite\""); tag_attr_open("CommandLine"); print_list(prj_get_links(), "", "", " ", vs_filter_links); print_list(prj_get_buildoptions(), " ", "", "", NULL); tag_attr_close(); // This so that we're always run (and never "up-to-date") tag_attr("Outputs=\".\\dummy.file.thats.never.created\""); } else if (prj_is_kind("cxxtestgen")) { char *rootfile = strdup(prj_get_cxxtest_rootfile()); char *ctpath = strdup(path_translate(prj_get_cxxtestpath(), "windows")); char *options = strdup(prj_get_cxxtest_rootoptions()); tag_attr("Description=\"Generating test_root.cpp\""); tag_attr("CommandLine=\"%s%s --root %s -o "%s"\"", endsWith(prj_get_cxxtestpath(), ".pl")?"perl ":"", ctpath, options, rootfile); tag_attr("Outputs=\"%s\"", rootfile); free(options); free(ctpath); free(rootfile); } break; case VCXMLDataGeneratorTool: tag_attr("Name=\"VCXMLDataGeneratorTool\""); break; case VCManagedWrapperGeneratorTool: tag_attr("Name=\"VCManagedWrapperGeneratorTool\""); break; case VCAuxiliaryManagedWrapperGeneratorTool: tag_attr("Name=\"VCAuxiliaryManagedWrapperGeneratorTool\""); break; case VCWebServiceProxyGeneratorTool: tag_attr("Name=\"VCWebServiceProxyGeneratorTool\""); break; case VCMIDLTool: tag_attr("Name=\"VCMIDLTool\""); break; case VCManagedResourceCompilerTool: tag_attr("Name=\"VCManagedResourceCompilerTool\""); break; case VCResourceCompilerTool: tag_attr("Name=\"VCResourceCompilerTool\""); if (prj_get_numincpaths() > 0) { tag_attr_open("AdditionalIncludeDirectories"); print_list(prj_get_incpaths(), "", "", ";", NULL); tag_attr_close(); } break; case VCPreLinkEventTool: tag_attr("Name=\"VCPreLinkEventTool\""); break; case VCALinkTool: tag_attr("Name=\"VCALinkTool\""); break; case VCManifestTool: tag_attr("Name=\"VCManifestTool\""); break; case VCXDCMakeTool: tag_attr("Name=\"VCXDCMakeTool\""); break; case VCBscMakeTool: tag_attr("Name=\"VCBscMakeTool\""); break; case VCFxCopTool: tag_attr("Name=\"VCFxCopTool\""); break; case VCAppVerifierTool: tag_attr("Name=\"VCAppVerifierTool\""); break; case VCWebDeploymentTool: tag_attr("Name=\"VCWebDeploymentTool\""); break; case VCPostBuildEventTool: tag_attr("Name=\"VCPostBuildEventTool\""); break; case VCCLCompilerTool: tag_attr("Name=\"VCCLCompilerTool\""); if (prj_get_numbuildoptions() > 0) { tag_attr_open("AdditionalOptions"); print_list(prj_get_buildoptions(), "", "", " ", NULL); tag_attr_close(); } tag_attr("Optimization=\"%d\"", optimization); if (prj_has_flag("no-frame-pointer")) tag_attr("OmitFramePointers=\"%s\"", S_TRUE); if (prj_get_numincpaths() > 0) { tag_attr_open("AdditionalIncludeDirectories"); print_list(prj_get_incpaths(), "", "", ";", NULL); tag_attr_close(); } if (prj_has_flag("managed")) tag_attr("AdditionalUsingDirectories=\"%s\"", prj_get_bindir()); if (prj_get_numdefines() > 0) { tag_attr_open("PreprocessorDefinitions"); print_list(prj_get_defines(), "", "", ";", NULL); tag_attr_close(); } if (debug && !prj_has_flag("managed")) tag_attr("MinimalRebuild=\"%s\"", S_TRUE); if (prj_has_flag("no-exceptions")) tag_attr("ExceptionHandling=\"%s\"", S_FALSE); if (debug && !prj_has_flag("managed")) tag_attr("BasicRuntimeChecks=\"3\""); if (!debug) tag_attr("StringPooling=\"%s\"", S_TRUE); tag_attr("RuntimeLibrary=\"%d\"", runtime); tag_attr("EnableFunctionLevelLinking=\"%s\"", S_TRUE); if (version < VS2005 && !prj_has_flag("no-rtti")) tag_attr("RuntimeTypeInfo=\"%s\"", S_TRUE); if (version >= VS2005 && prj_has_flag("no-rtti")) tag_attr("RuntimeTypeInfo=\"%s\"", S_FALSE); if (version < VS2005 && prj_has_flag("native-wchar_t")) tag_attr("TreatWChar_tAsBuiltInType=\"%s\"", S_TRUE); if (version >= VS2005 && prj_has_flag("no-native-wchar_t")) tag_attr("TreatWChar_tAsBuiltInType=\"%s\"", S_FALSE); if (pchHeader) { tag_attr("UsePrecompiledHeader=\"%d\"", version < VS2005 ? 3 : 2); tag_attr("PrecompiledHeaderThrough=\"%s\"", pchHeader); } else tag_attr("UsePrecompiledHeader=\"%d\"", version < VS2005 ? 2 : 0); tag_attr("WarningLevel=\"%d\"", prj_has_flag("extra-warnings") ? 4 : 3); if (prj_has_flag("fatal-warnings")) tag_attr("WarnAsError=\"%s\"", S_TRUE); if (version < VS2008 && !prj_has_flag("managed")) tag_attr("Detect64BitPortabilityProblems=\"%s\"", prj_has_flag("no-64bit-checks") ? S_FALSE : S_TRUE); tag_attr("DebugInformationFormat=\"%d\"", symbols); break; case VCLinkerTool: if (!prj_is_kind("lib")) { tag_attr("Name=\"VCLinkerTool\""); if (prj_has_flag("no-import-lib")) tag_attr("IgnoreImportLibrary=\"%s\"", S_TRUE); if (prj_has_flag("use-library-dep-inputs") && version >= VS2005) tag_attr("UseLibraryDependencyInputs=\"%s\"", S_TRUE); if (prj_get_numlinkoptions() > 0) { tag_attr_open("AdditionalOptions"); print_list(prj_get_linkoptions(), " ", "", "", NULL); tag_attr_close(); } if (prj_get_numlinks() > 0) { tag_attr_open("AdditionalDependencies"); print_list(prj_get_links(), "", ".lib", " ", vs_filter_links); tag_attr_close(); } tag_attr("OutputFile=\"$(OutDir)/%s\"", path_getname(prj_get_target())); tag_attr("LinkIncremental=\"%d\"", debug ? 2 : 1); tag_attr_open("AdditionalLibraryDirectories"); io_print(prj_get_libdir()); print_list(prj_get_libpaths(), ";", "", "", NULL); tag_attr_close(); /* Look for a .def file for DLLs */ if (prj_find_filetype(".def") != NULL) tag_attr("ModuleDefinitionFile=\"%s\"", prj_find_filetype(".def")); if (prj_has_flag("no-manifest")) tag_attr("GenerateManifest=\"%s\"", S_FALSE); tag_attr("GenerateDebugInformation=\"%s\"", symbols ? S_TRUE : S_FALSE); if (symbols) tag_attr("ProgramDatabaseFile=\"$(OutDir)/%s.pdb\"", path_getbasename(prj_get_target())); tag_attr("SubSystem=\"%d\"", prj_is_kind("exe") ? 1 : 2); if (!debug) tag_attr("OptimizeReferences=\"2\""); if (!debug) tag_attr("EnableCOMDATFolding=\"2\""); if ((prj_is_kind("exe") || prj_is_kind("winexe")) && !prj_has_flag("no-main")) { tag_attr("EntryPointSymbol=\"mainCRTStartup\""); } else if (prj_is_kind("dll")) { tag_attr_open("ImportLibrary"); if (prj_has_flag("no-import-lib")) io_print(prj_get_objdir()); else io_print(prj_get_libdir()); io_print("/%s.lib", path_getbasename(prj_get_target())); tag_attr_close(); } tag_attr("TargetMachine=\"1\""); } else { tag_attr("Name=\"VCLibrarianTool\""); tag_attr("OutputFile=\"$(OutDir)/%s.lib\"", path_getbasename(prj_get_target())); } break; } tag_close("", 0); } tag_close("Configuration", 1); } tag_close("Configurations", 1); if (version > VS2002) { tag_open("References"); tag_close("References", 1); } tag_open("Files"); print_source_tree("", vs_list_files); /*if (prj_is_kind("cxxtestgen")) { char *rootfile = strdup(prj_get_cxxtest_rootfile()); char *ctpath = strdup(path_translate(prj_get_cxxtestpath(), "windows")); int i; tag_open("File"); tag_attr_open("RelativePath"); if (rootfile[0] != '.') io_print(".\\"); io_print(rootfile); tag_attr_close(); for (i = 0; i < prj_get_numconfigs(); ++i) { char *options; prj_select_config(i); options = strdup(prj_get_cxxtest_rootoptions()); tag_open("FileConfiguration"); tag_attr("Name=\"%s|Win32\"", prj_get_cfgname()); tag_open("Tool"); tag_attr("Name=\"VCCustomBuildTool\""); tag_attr("Description=\"Generating test_root.cpp\""); tag_attr("CommandLine=\"%s%s --root %s -o "%s"\"", endsWith(prj_get_cxxtestpath(), ".pl")?"perl ":"", ctpath, options, rootfile); tag_attr("Outputs=\"%s\"", rootfile); tag_close("Tool", 0); tag_close("FileConfiguration", 1); free(options); } tag_close("File", 1); free(ctpath); free(rootfile); }*/ tag_close("Files", 1); tag_open("Globals"); tag_close("Globals", 1); tag_close("VisualStudioProject", 1); io_closefile(); return 1; }
static void tag_attr_close() { io_print("\""); attrib++; }
static int vs2002_write_solution() { VsPkgData* data; int i, j; if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "sln"))) return 0; /* Format identification string */ io_print("Microsoft Visual Studio Solution File, Format Version "); if (vs_getversion() == VS2002) io_print("7.00\n"); else io_print("8.00\n"); /* List packages */ for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); data = (VsPkgData*)prj_get_data(); io_print("Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"\n", data->toolGuid, prj_get_pkgname(), prj_get_pkgfilename(data->projExt), data->projGuid); /* Write package dependencies for post-2002 */ if (vs_getversion() > VS2002) { prj_select_config(0); io_print("\tProjectSection(ProjectDependencies) = postProject\n"); print_list(prj_get_links(), "\t\t", "\n", "", vs_list_pkgdeps); io_print("\tEndProjectSection\n"); } io_print("EndProject\n"); } /* List configurations */ io_print("Global\n"); io_print("\tGlobalSection(SolutionConfiguration) = preSolution\n"); prj_select_package(0); for (i = 0; i < prj_get_numconfigs(); ++i) { prj_select_config(i); if (vs_getversion() == VS2002) io_print("\t\tConfigName.%d = %s\n", i, prj_get_cfgname()); else io_print("\t\t%s = %s\n", prj_get_cfgname(), prj_get_cfgname()); } io_print("\tEndGlobalSection\n"); /* Write package dependencies for 2002 */ if (vs_getversion() == VS2002) { io_print("\tGlobalSection(ProjectDependencies) = postSolution\n"); for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); prj_select_config(0); print_list(prj_get_links(), "\t\t", "\n", "", vs_list_pkgdeps); } io_print("\tEndGlobalSection\n"); } /* Write configuration for each package */ io_print("\tGlobalSection(ProjectConfiguration) = postSolution\n"); for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); for (j = 0; j < prj_get_numconfigs(); ++j) { prj_select_config(j); data = (VsPkgData*)prj_get_data(); /* I may actually be writing the wrong thing for VS2002-2003, but has * seemed to work for this long so I am going to leave it alone */ io_print("\t\t{%s}.%s.ActiveCfg = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), data->projType); io_print("\t\t{%s}.%s.Build.0 = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), data->projType); } } io_print("\tEndGlobalSection\n"); /* Finish */ io_print("\tGlobalSection(ExtensibilityGlobals) = postSolution\n"); io_print("\tEndGlobalSection\n"); io_print("\tGlobalSection(ExtensibilityAddIns) = postSolution\n"); io_print("\tEndGlobalSection\n"); io_print("EndGlobal\n"); io_closefile(); return 1; }
static int writeCombine() { const char* path; int i, j; if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "cmbx"))) return 0; io_print("<Combine fileversion=\"1.0\" name=\"%s\" description=\"\">\n", prj_get_name()); /* TODO: select the first executable project */ io_print(" <StartMode startupentry=\"\" single=\"True\">\n"); /* Write out the startup entries */ for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); io_print(" <Execute entry=\"%s\" type=\"None\" />\n", prj_get_pkgname()); } io_print(" </StartMode>\n"); io_print(" <Entries>\n"); /* Write out the project entries */ for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); path = prj_get_pkgfilename("prjx"); io_print(" <Entry filename=\""); if (path[0] != '.') io_print("./"); io_print("%s\" />\n", path); } io_print(" </Entries>\n"); io_print(" <Configurations active=\"Debug\">\n"); /* Write out the entries for each build configuration */ for (i = 0; i < prj_get_numconfigs(); ++i) { prj_select_config(i); io_print(" <Configuration name=\"%s\">\n", xmlEscape(prj_get_cfgname())); /* List all packages under this configuration */ prj_select_config(0); for(j = 0; j < prj_get_numpackages(); j++) { prj_select_package(j); io_print(" <Entry name=\"%s\" configurationname=\"%s\" build=\"False\" />\n", prj_get_pkgname(), xmlEscape(prj_get_cfgname())); } io_print(" </Configuration>\n"); } /* Finish */ io_print(" </Configurations>\n"); io_print("</Combine>"); io_closefile(); /* MonoDevelop adds another file */ if (sharpdev_target == MONODEV) { if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "mdsx"))) return 0; prj_select_config(0); io_print("<MonoDevelopSolution fileversion=\"1.0\">\n"); io_print(" <RelativeOutputPath>%s</RelativeOutputPath>\n", prj_get_bindir()); io_print("</MonoDevelopSolution>\n"); io_closefile(); } return 1; }
static void print_opt(const char* opt) { io_print("\t\t\t\t\t<Add option=\"%s\" />\n", opt); }
static void tag_indent() { int i; for (i = 0; i < indent; ++i) io_print("\t"); }
static int vs2005_write_solution(int target) { VsPkgData* data; int hasDotNet, hasCpp; int i, j; int numAspNet, port; if (!io_openfile(path_join(prj_get_path(), prj_get_name(), "sln"))) return 0; /* Format identification string */ if (target == 2005) { io_print("Microsoft Visual Studio Solution File, Format Version 9.00\n"); io_print("# Visual Studio 2005\n"); } else { io_print("Microsoft Visual Studio Solution File, Format Version 10.00\n"); io_print("# Visual Studio 2008\n"); } /* List packages */ numAspNet = 0; for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); prj_select_config(0); data = (VsPkgData*)prj_get_data(); if (prj_is_kind("aspnet")) { const char* path = prj_get_pkgpath(); if (strlen(path) == 0) path = "."; io_print("Project(\"{%s}\") = \"%s\", \"%s\\\", \"{%s}\"\n", data->toolGuid, prj_get_pkgname(), path, data->projGuid); io_print("\tProjectSection(WebsiteProperties) = preProject\n"); if (prj_get_numlinks() > 0) print_list(prj_get_links(), "\t\tProjectReferences = \"", ";\"\n", ";", list_aspnet_refs); for (j = 0; j < prj_get_numconfigs(); ++j) { prj_select_config(j); io_print("\t\t%s.AspNetCompiler.VirtualPath = \"/%s\"\n", prj_get_cfgname(), prj_get_pkgname()); io_print("\t\t%s.AspNetCompiler.PhysicalPath = \"%s\\\"\n", prj_get_cfgname(), path); io_print("\t\t%s.AspNetCompiler.TargetPath = \"PrecompiledWeb\\%s\\\"\n", prj_get_cfgname(), prj_get_pkgname()); io_print("\t\t%s.AspNetCompiler.Updateable = \"true\"\n", prj_get_cfgname()); io_print("\t\t%s.AspNetCompiler.ForceOverwrite = \"true\"\n", prj_get_cfgname()); io_print("\t\t%s.AspNetCompiler.FixedNames = \"false\"\n", prj_get_cfgname()); io_print("\t\t%s.AspNetCompiler.Debug = \"%s\"\n", prj_get_cfgname(), prj_has_flag("no-symbols") ? "False" : "True"); } if (numAspNet == 0) port = 1106; else if (numAspNet == 1) port = 1231; else port = 1251 + 2 * (numAspNet - 2); io_print("\t\tVWDPort = \"%d\"\n", port); numAspNet++; if (prj_is_lang("c#")) io_print("\t\tDefaultWebSiteLanguage = \"Visual C#\"\n"); io_print("\tEndProjectSection\n"); } else { io_print("Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"\n", data->toolGuid, prj_get_pkgname(), prj_get_pkgfilename(data->projExt), data->projGuid); /* Write dependencies */ prj_select_config(0); io_print("\tProjectSection(ProjectDependencies) = postProject\n"); print_list(prj_get_links(), "\t\t", "\n", "", vs_list_pkgdeps); io_print("\tEndProjectSection\n"); } io_print("EndProject\n"); } /* List configurations */ io_print("Global\n"); io_print("\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"); hasDotNet = 0; hasCpp = 0; for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); if (prj_is_lang("c") || prj_is_lang("c++")) hasCpp = 1; else hasDotNet = 1; } prj_select_package(0); for (i = 0; i < prj_get_numconfigs(); ++i) { prj_select_config(i); if (hasDotNet) io_print("\t\t%s|Any CPU = %s|Any CPU\n", prj_get_cfgname(), prj_get_cfgname()); if (hasDotNet && hasCpp) io_print("\t\t%s|Mixed Platforms = %s|Mixed Platforms\n", prj_get_cfgname(), prj_get_cfgname()); if (hasCpp) io_print("\t\t%s|Win32 = %s|Win32\n", prj_get_cfgname(), prj_get_cfgname()); } io_print("\tEndGlobalSection\n"); /* Write configuration for each package */ io_print("\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"); for (i = 0; i < prj_get_numpackages(); ++i) { prj_select_package(i); for (j = 0; j < prj_get_numconfigs(); ++j) { const char* arch; prj_select_config(j); data = (VsPkgData*)prj_get_data(); if (prj_is_lang("c") || prj_is_lang("c++")) arch = "Win32"; else arch = "Any CPU"; if (hasDotNet) { io_print("\t\t{%s}.%s|Any CPU.ActiveCfg = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), arch); if (!prj_is_lang("c") && !prj_is_lang("c++")) io_print("\t\t{%s}.%s|Any CPU.Build.0 = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), arch); } if (hasDotNet && hasCpp) { io_print("\t\t{%s}.%s|Mixed Platforms.ActiveCfg = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), arch); io_print("\t\t{%s}.%s|Mixed Platforms.Build.0 = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), arch); } if (hasCpp) { io_print("\t\t{%s}.%s|Win32.ActiveCfg = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), arch); if (prj_is_lang("c") || prj_is_lang("c++")) io_print("\t\t{%s}.%s|Win32.Build.0 = %s|%s\n", data->projGuid, prj_get_cfgname(), prj_get_cfgname(), arch); } } } io_print("\tEndGlobalSection\n"); /* Finish */ io_print("\tGlobalSection(SolutionProperties) = preSolution\n"); io_print("\t\tHideSolutionNode = FALSE\n"); io_print("\tEndGlobalSection\n"); io_print("EndGlobal\n"); io_closefile(); return 1; }
int main(int argc, char **argv) { Config_t conf = args_process(argc, argv); int i = 0; if (!conf.file_set) { conf.file = calloc(1014, sizeof(char)); if (getenv("HOME")) { strcpy(conf.file, getenv("HOME")); strcat(conf.file, "/.todolist"); conf.file_set = true; } else { perror("getenv"); return EXIT_FAILURE; } } TODO * tl = NULL; tl = io_import(conf.file); if (!tl) for (i=0 ; i < conf.lines; i++) printf("\n"); LOG("end import"); switch (conf.com) { case COM_ADD: if (conf.text_set) todo_push(conf.text, conf.time, &tl); break; case COM_APPEND: if (conf.text_set){ LOG("calling append"); todo_append(conf.text, conf.time, &tl); } break; case COM_POP: todo_pop(&tl); break; case COM_DROP: todo_drop(&tl); break; case COM_DEL: todo_delnum(&tl, conf.num1); break; case COM_SWAP: todo_swap(tl, conf.num1, conf.num2); break; case COM_ERROR: switch(conf.err) { case ERROR_UNKNOWN_COMMAND: fprintf(stderr, "%s: commande inconnue\n", argv[0]); break; case ERROR_MISSING_ARG: fprintf(stderr, "%s: argument manquant\n", argv[0]); break; case ERROR_WRONG_ARG: fprintf(stderr, "%s: argument erroné\n", argv[0]); break; case ERROR_WRONG_OPT: fprintf(stderr, "%s: option inconnue\n", argv[0]); break; default: fprintf(stderr, "%s: erreur indéfinie\n", argv[0]); break; } exit(EXIT_FAILURE); break; case COM_VERSION: version(argv[0]); break; case COM_HELP: usage(argv[0]); break; case COM_CONKY: io_print(tl, conf.lines, conf.color, true, conf.warn); break; default: io_print(tl, conf.lines, conf.color, false, conf.warn); break; } io_export(conf.file, tl); free(conf.file); conf.file=NULL; todo_flush(tl); return EXIT_SUCCESS; }
int cb_cpp() { int i; /* Write the file */ if (!io_openfile(path_join(prj_get_pkgpath(), prj_get_pkgname(), "cbp"))) return 0; io_print("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"); io_print("<CodeBlocks_project_file>\n"); io_print("\t<FileVersion major=\"1\" minor=\"6\" />\n"); io_print("\t<Project>\n"); io_print("\t\t<Option title=\"%s\" />\n", prj_get_pkgname()); io_print("\t\t<Option pch_mode=\"2\" />\n"); io_print("\t\t<Option compiler=\"gcc\" />\n"); io_print("\t\t<Build>\n"); for (i = 0; i < prj_get_numconfigs(); ++i) { int kindCode; prj_select_config(i); io_print("\t\t\t<Target title=\"%s\">\n", prj_get_cfgname()); io_print("\t\t\t\t<Option output=\"%s\" prefix_auto=\"0\" extension_auto=\"0\" />\n", prj_get_target()); io_print("\t\t\t\t<Option object_output=\"%s\" />\n", prj_get_objdir()); if (prj_is_kind("winexe")) kindCode = 0; else if (prj_is_kind("exe")) kindCode = 1; else if (prj_is_kind("lib")) kindCode = 2; else if (prj_is_kind("dll")) kindCode = 3; else { printf("** Unsupported project kind %s\n", prj_get_kind()); return 0; } io_print("\t\t\t\t<Option type=\"%d\" />\n", kindCode); io_print("\t\t\t\t<Option compiler=\"gcc\" />\n"); if (prj_is_kind("dll")) { io_print("\t\t\t\t<Option createDefFile=\"0\" />\n"); if (prj_has_flag("no-import-lib")) io_print("\t\t\t\t<Option createStaticLib=\"0\" />\n"); else io_print("\t\t\t\t<Option createStaticLib=\"1\" />\n"); } io_print("\t\t\t\t<Compiler>\n"); if (prj_has_flag("extra-warnings")) print_opt("-Wall"); if (prj_has_flag("fatal-warnings")) print_opt("-Werror"); if (prj_has_flag("no-exceptions")) print_opt("--no-exceptions"); if (prj_has_flag("no-frame-pointer")) print_opt("-fomit-frame-pointer"); if (prj_has_flag("no-rtti")) print_opt("--no-rtti"); if (!prj_has_flag("no-symbols")) print_opt("-g"); if (prj_has_flag("optimize-size")) print_opt("-Os"); if (prj_has_flag("optimize-speed")) print_opt("-O3"); if (prj_has_flag("optimize") && !prj_has_flag("optimize-size") && !prj_has_flag("optimize-speed")) print_opt("-O"); if (prj_has_pch()) { /* Warns you if your pch file is out of date */ print_opt("-Winvalid-pch"); /* Force include the pch header so the user doesn't need to */ io_print("\t\t\t\t\t<Add option=\"-include "%s"\" />\n", prj_get_pch_header()); } print_list(prj_get_defines(), "\t\t\t\t\t<Add option=\"-D", "\" />\n", "", NULL); print_list(prj_get_buildoptions(), "\t\t\t\t\t<Add option=\"", "\" />\n", "", NULL); print_list(prj_get_incpaths(), "\t\t\t\t\t<Add directory=\"", "\" />\n", "", NULL); io_print("\t\t\t\t</Compiler>\n"); io_print("\t\t\t\t<Linker>\n"); if (prj_has_flag("no-symbols")) print_opt("-s"); print_list(prj_get_linkoptions(), "\t\t\t\t\t<Add option=\"", "\" />\n", "", NULL); io_print("\t\t\t\t\t<Add directory=\"%s\" />\n", prj_get_bindir()); if (!matches(prj_get_bindir(), prj_get_libdir())) io_print("\t\t\t\t\t<Add directory=\"%s\" />\n", prj_get_libdir()); print_list(prj_get_libpaths(), "\t\t\t\t\t<Add directory=\"", "\" />\n", "", NULL); print_list(prj_get_links(), "\t\t\t\t\t<Add directory=\"", "\" />\n", "", filterLinksForPaths); print_list(prj_get_links(), "\t\t\t\t\t<Add library=\"", "\" />\n", "", filterLinks); io_print("\t\t\t\t</Linker>\n"); if (prj_find_filetype(".rc")) { io_print("\t\t\t\t<ResourceCompiler>\n"); print_list(prj_get_respaths(), "\t\t\t\t\t<Add directory=\"", "\" />\n", "", NULL); io_print("\t\t\t\t</ResourceCompiler>\n"); } if (prj_get_numprebuildcommands() > 0 || prj_get_numpostbuildcommands() > 0) { io_print("\t\t\t\t<ExtraCommands>\n"); if (prj_get_numprebuildcommands() > 0) print_list(prj_get_prebuildcommands(), "\t\t\t\t\t<Add before=\"", "\" />\n", "", NULL); if (prj_get_numpostbuildcommands() > 0) print_list(prj_get_postbuildcommands(), "\t\t\t\t\t<Add after=\"", "\" />\n", "", NULL); io_print("\t\t\t\t</ExtraCommands>\n"); } io_print("\t\t\t</Target>\n"); } io_print("\t\t</Build>\n"); print_list(prj_get_files(), "", "", "", listFiles); io_print("\t\t<Extensions />\n"); io_print("\t</Project>\n"); io_print("</CodeBlocks_project_file>\n"); io_closefile(); return 1; }