int main() { char linebuf[MAXTEXT], name[NAMESIZE]; FILE *infile[MERGEORDER]; FILE *outfile; char *lineptr[MAXPTR]; int nlines, t, outlow, outhigh, mergelow, mergehigh; outlow = 1; mergelow = outlow + N; mergehigh = mergelow-1; for (;;) { /* * Read chunks from stdin and write to files outlow...outhigh. */ for (outhigh = outlow; outhigh < outlow+N; outhigh++) { t = gtext(lineptr, MAXPTR, linebuf, MAXTEXT, &nlines, stdin); qsort(lineptr, nlines, sizeof(lineptr[0]), qcmpstr); outfile = makefile(outhigh); ptext(lineptr, nlines, outfile); fclose(outfile); if (t == EOF) break; } if (outhigh >= outlow+N) outhigh--; /* * Merge files outlow...outhigh to mergehigh. */ gopen(infile, outlow, outhigh); ++mergehigh; outfile = makefile(mergehigh); merge(infile, outhigh-outlow+1, outfile); fclose(outfile); /* * If the merge group is full, merge them to outlow and exchange * merge group and sorting group. */ if (mergehigh-mergelow+1 >= N) { gopen(infile, mergelow, mergehigh); outfile = makefile(outlow); merge(infile, mergehigh-mergelow+1, outfile); fclose(outfile); swap(&outlow, &mergelow); mergehigh = mergelow; } if (t == EOF) break; } gopen(infile, mergelow, mergehigh); merge(infile, mergehigh-mergelow+1, stdout); gopen(infile, 1, 2*N); gremove(infile, 1, 2*N); return 0; }
static int _configure_do(Configure * configure, configArray * ca) { size_t i; size_t cnt = array_count(ca); String const * di; size_t j; Config * cj; String const * dj; for(i = 0; i < cnt; i++) { array_get_copy(ca, i, &configure->config); if((di = config_get(configure->config, "", "directory")) == NULL) continue; for(j = i; j < cnt; j++) { array_get_copy(ca, j, &cj); if((dj = config_get(cj, "", "directory")) == NULL) continue; if(string_find(dj, di) == NULL) break; } if(makefile(configure, di, ca, i, j) != 0) break; } return (i == cnt) ? 0 : 1; }
int main(){ double x0[N],y0[N]; double x[N],y[N]; makestar(x0,y0); int i; for(i = 0;i < N;i++) x[i]=x0[i],y[i]=y0[i]; simulate(x,y,3.5,50,0.1,20); makefile(x0,y0,x,y); return 0; }
void main() { node root=NULL; int ele; while(fscanf(stdin,"%d",&ele)==1) { if(ele==EOF) break; root=createTree(root,ele); } // printinorder(root); checkBinary(root); makefile(root); }
static FILE * logfile(FILE *log, struct log_ctl *lp) { static time_t lasttime = 0; time_t newtime; errfile = ERRFILE; newtime = lp->ttime - timezone; /* * If it is a new day make a new log file */ if (((newtime/NSECDAY) != (lasttime/NSECDAY)) || !log) { if (log) (void) fclose(log); lasttime = newtime; makefile(errfile, lp->ttime); return (fopen(errfile, "a+")); } lasttime = newtime; return (log); }
/* * Config builds a set of files for building a UNIX * system given a description of the desired system. */ int main(int argc, char *argv[]) { struct stat buf; int ch, len; unsigned int i; char *p; char linksrc[64], linkdest[MAXPATHLEN]; static const char *emus[] = { "linux" }; while ((ch = getopt(argc, argv, "d:gpr")) != -1) switch (ch) { case 'd': if (*destdir == '\0') strlcpy(destdir, optarg, sizeof(destdir)); else errx(2, "directory already set"); break; case 'g': debugging++; break; case 'p': profiling++; break; case 'r': no_config_clobber = FALSE; break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc != 1) usage(); if (freopen(PREFIX = *argv, "r", stdin) == NULL) err(2, "%s", PREFIX); if (*destdir != '\0') { len = strlen(destdir); while (len > 1 && destdir[len - 1] == '/') destdir[--len] = '\0'; get_srcdir(); } else { strlcpy(destdir, CDIR, sizeof(destdir)); strlcat(destdir, PREFIX, sizeof(destdir)); } p = path(NULL); if (stat(p, &buf)) { if (mkdir(p, 0777)) err(2, "%s", p); } else if ((buf.st_mode & S_IFMT) != S_IFDIR) { errx(2, "%s isn't a directory", p); } else if (!no_config_clobber) { char tmp[strlen(p) + 8]; fprintf(stderr, "Removing old directory %s: ", p); fflush(stderr); snprintf(tmp, sizeof(tmp), "rm -rf %s", p); if (system(tmp)) { fprintf(stderr, "Failed!\n"); err(2, "%s", tmp); } fprintf(stderr, "Done.\n"); if (mkdir(p, 0777)) err(2, "%s", p); } dtab = NULL; if (yyparse()) exit(3); if (platformname == NULL) { printf("Specify platform architecture, e.g. 'platform pc64'\n"); exit(1); } if (machinename == NULL) { printf("Specify machine architecture, e.g. 'machine x86_64'\n"); exit(1); } if (machinearchname == NULL) { printf("Specify cpu architecture, e.g. 'machine_arch x86_64'\n"); exit(1); } newbus_ioconf(); /* * "machine" points into platform/<PLATFORM>/include */ if (*srcdir == '\0') snprintf(linkdest, sizeof(linkdest), "../../platform/%s/include", platformname); else snprintf(linkdest, sizeof(linkdest), "%s/platform/%s/include", srcdir, platformname); symlink(linkdest, path("machine")); /* * "machine_base" points into platform/<PLATFORM> */ if (*srcdir == '\0') snprintf(linkdest, sizeof(linkdest), "../../platform/%s", platformname); else snprintf(linkdest, sizeof(linkdest), "%s/platform/%s", srcdir, platformname); symlink(linkdest, path("machine_base")); /* * "cpu" points to cpu/<MACHINE_ARCH>/include */ if (*srcdir == '\0') snprintf(linkdest, sizeof(linkdest), "../../cpu/%s/include", machinearchname); else snprintf(linkdest, sizeof(linkdest), "%s/cpu/%s/include", srcdir, machinearchname); symlink(linkdest, path("cpu")); /* * "cpu_base" points to cpu/<MACHINE_ARCH> */ if (*srcdir == '\0') snprintf(linkdest, sizeof(linkdest), "../../cpu/%s", machinearchname); else snprintf(linkdest, sizeof(linkdest), "%s/cpu/%s", srcdir, machinearchname); symlink(linkdest, path("cpu_base")); /* * XXX check directory structure for architecture subdirectories and * create the symlinks automatically XXX */ for (i = 0; i < sizeof(emus) / sizeof(emus[0]); ++i) { if (*srcdir == 0) { snprintf(linkdest, sizeof(linkdest), "../../emulation/%s/%s", emus[i], machinearchname); } else { snprintf(linkdest, sizeof(linkdest), "%s/emulation/%s/%s", srcdir, emus[i], machinearchname); } snprintf(linksrc, sizeof(linksrc), "arch_%s", emus[i]); symlink(linkdest, path(linksrc)); } options(); /* make options .h files */ makefile(); /* build Makefile */ headers(); /* make a lot of .h files */ configfile(); /* put config file into kernel*/ printf("Kernel build directory is %s\n", p); exit(EX_OK); }
bool CBLinuxProject::createProjectFile(){ ofDirectory dir(projectDir); if(!dir.exists()) dir.create(true); ofFile project(ofFilePath::join(projectDir, projectName + ".cbp")); string src = ofFilePath::join(templatePath,"emptyExample_" + target + ".cbp"); string dst = project.path(); bool ret; if(!project.exists()){ ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying cbp template from " << src << " to " << dst; return false; }else{ findandreplaceInTexfile(dst, "emptyExample", projectName); } } ofFile workspace(ofFilePath::join(projectDir, projectName + ".workspace")); if(!workspace.exists()){ src = ofFilePath::join(templatePath,"emptyExample_" + target + ".workspace"); dst = workspace.path(); ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying workspace template from "<< src << " to " << dst; return false; }else{ findandreplaceInTexfile(dst, "emptyExample", projectName); } } ofFile makefile(ofFilePath::join(projectDir,"Makefile")); if(!makefile.exists()){ src = ofFilePath::join(templatePath,"Makefile"); dst = makefile.path(); ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying Makefile template from " << src << " to " << dst; return false; } } ofFile config(ofFilePath::join(projectDir,"config.make")); if(!config.exists()){ src = ofFilePath::join(templatePath,"config.make"); dst = config.path(); ret = ofFile::copyFromTo(src,dst); if(!ret){ ofLogError(LOG_NAME) << "error copying config.make template from " << src << " to " << dst; return false; } } // handle the relative roots. string relRoot = getOFRelPath(ofFilePath::removeTrailingSlash(projectDir)); if (relRoot != "../../../"){ string relPath2 = relRoot; relPath2.erase(relPath2.end()-1); findandreplaceInTexfile(projectDir + "Makefile", "../../..", relPath2); findandreplaceInTexfile(projectDir + "config.make", "../../..", relPath2); findandreplaceInTexfile(ofFilePath::join(projectDir , projectName + ".workspace"), "../../../", relRoot); findandreplaceInTexfile(ofFilePath::join(projectDir , projectName + ".cbp"), "../../../", relRoot); } return true; }
void DocSets::initialize() { // -- get config options QCString projectName = Config_getString("PROJECT_NAME"); if (projectName.isEmpty()) projectName="root"; QCString bundleId = Config_getString("DOCSET_BUNDLE_ID"); if (bundleId.isEmpty()) bundleId="org.doxygen.Project"; QCString feedName = Config_getString("DOCSET_FEEDNAME"); if (feedName.isEmpty()) feedName="FeedName"; QCString publisherId = Config_getString("DOCSET_PUBLISHER_ID"); if (publisherId.isEmpty()) publisherId="PublisherId"; QCString publisherName = Config_getString("DOCSET_PUBLISHER_NAME"); if (publisherName.isEmpty()) publisherName="PublisherName"; QCString projectNumber = Config_getString("PROJECT_NUMBER"); if (projectNumber.isEmpty()) projectNumber="ProjectNumber"; // -- write Makefile { QCString mfName = Config_getString("HTML_OUTPUT") + "/Makefile"; QFile makefile(mfName); if (!makefile.open(IO_WriteOnly)) { err("Could not open file %s for writing\n",mfName.data()); exit(1); } FTextStream ts(&makefile); ts << "DOCSET_NAME=" << bundleId << ".docset\n" "DOCSET_CONTENTS=$(DOCSET_NAME)/Contents\n" "DOCSET_RESOURCES=$(DOCSET_CONTENTS)/Resources\n" "DOCSET_DOCUMENTS=$(DOCSET_RESOURCES)/Documents\n" "DESTDIR=~/Library/Developer/Shared/Documentation/DocSets\n" "XCODE_INSTALL=\"$(shell xcode-select -print-path)\"\n" "\n" "all: docset\n" "\n" "docset:\n" "\tmkdir -p $(DOCSET_DOCUMENTS)\n" "\tcp Nodes.xml $(DOCSET_RESOURCES)\n" "\tcp Tokens.xml $(DOCSET_RESOURCES)\n" "\tcp Info.plist $(DOCSET_CONTENTS)\n" "\ttar --exclude $(DOCSET_NAME) \\\n" "\t --exclude Nodes.xml \\\n" "\t --exclude Tokens.xml \\\n" "\t --exclude Info.plist \\\n" "\t --exclude Makefile -c -f - . \\\n" "\t | (cd $(DOCSET_DOCUMENTS); tar xvf -)\n" "\t$(XCODE_INSTALL)/usr/bin/docsetutil index $(DOCSET_NAME)\n" "\trm -f $(DOCSET_DOCUMENTS)/Nodes.xml\n" "\trm -f $(DOCSET_DOCUMENTS)/Info.plist\n" "\trm -f $(DOCSET_DOCUMENTS)/Makefile\n" "\trm -f $(DOCSET_RESOURCES)/Nodes.xml\n" "\trm -f $(DOCSET_RESOURCES)/Tokens.xml\n" "\n" "clean:\n" "\trm -rf $(DOCSET_NAME)\n" "\n" "install: docset\n" "\tmkdir -p $(DESTDIR)\n" "\tcp -R $(DOCSET_NAME) $(DESTDIR)\n" "\n" "uninstall:\n" "\trm -rf $(DESTDIR)/$(DOCSET_NAME)\n" "\n" "always:\n"; } // -- write Info.plist { QCString plName = Config_getString("HTML_OUTPUT") + "/Info.plist"; QFile plist(plName); if (!plist.open(IO_WriteOnly)) { err("Could not open file %s for writing\n",plName.data()); exit(1); } FTextStream ts(&plist); ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" "<plist version=\"1.0\">\n" "<dict>\n" " <key>CFBundleName</key>\n" " <string>" << projectName << "</string>\n" " <key>CFBundleIdentifier</key>\n" " <string>" << bundleId << "</string>\n" " <key>CFBundleVersion</key>\n" " <string>" << projectNumber << "</string>\n" " <key>DocSetFeedName</key>\n" " <string>" << feedName << "</string>\n" " <key>DocSetPublisherIdentifier</key>\n" " <string>" << publisherId << "</string>\n" " <key>DocSetPublisherName</key>\n" " <string>" << publisherName << "</string>\n" // markers for Dash " <key>DashDocSetFamily</key>\n" " <string>doxy</string>\n" " <key>DocSetPlatformFamily</key>\n" " <string>doxygen</string>\n" "</dict>\n" "</plist>\n"; } // -- start Nodes.xml QCString notes = Config_getString("HTML_OUTPUT") + "/Nodes.xml"; m_nf = new QFile(notes); if (!m_nf->open(IO_WriteOnly)) { err("Could not open file %s for writing\n",notes.data()); exit(1); } //QCString indexName=Config_getBool("GENERATE_TREEVIEW")?"main":"index"; QCString indexName="index"; m_nts.setDevice(m_nf); m_nts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; m_nts << "<DocSetNodes version=\"1.0\">" << endl; m_nts << " <TOC>" << endl; m_nts << " <Node>" << endl; m_nts << " <Name>Root</Name>" << endl; m_nts << " <Path>" << indexName << Doxygen::htmlFileExtension << "</Path>" << endl; m_nts << " <Subnodes>" << endl; m_dc = 1; m_firstNode.resize(m_dc); m_firstNode.at(0)=TRUE; QCString tokens = Config_getString("HTML_OUTPUT") + "/Tokens.xml"; m_tf = new QFile(tokens); if (!m_tf->open(IO_WriteOnly)) { err("Could not open file %s for writing\n",tokens.data()); exit(1); } m_tts.setDevice(m_tf); m_tts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; m_tts << "<Tokens version=\"1.0\">" << endl; }
static gboolean gegl_post_parse_hook (GOptionContext *context, GOptionGroup *group, gpointer data, GError **error) { glong time; if (config) return TRUE; g_assert (global_time == 0); global_time = gegl_ticks (); g_type_init (); gegl_instrument ("gegl", "gegl_init", 0); config = (void*)gegl_config (); if (cmd_gegl_swap) g_object_set (config, "swap", cmd_gegl_swap, NULL); if (cmd_gegl_quality) config->quality = atof (cmd_gegl_quality); if (cmd_gegl_cache_size) config->cache_size = atoi (cmd_gegl_cache_size)*1024*1024; if (cmd_gegl_chunk_size) config->chunk_size = atoi (cmd_gegl_chunk_size); if (cmd_gegl_tile_size) { const gchar *str = cmd_gegl_tile_size; config->tile_width = atoi(str); str = strchr (str, 'x'); if (str) config->tile_height = atoi(str+1); } if (cmd_gegl_threads) config->threads = atoi (cmd_gegl_threads); if (cmd_babl_tolerance) g_object_set (config, "babl-tolerance", atof(cmd_babl_tolerance), NULL); #ifdef GEGL_ENABLE_DEBUG { const char *env_string; env_string = g_getenv ("GEGL_DEBUG"); if (env_string != NULL) { gegl_debug_flags = g_parse_debug_string (env_string, gegl_debug_keys, G_N_ELEMENTS (gegl_debug_keys)); env_string = NULL; } } #endif /* GEGL_ENABLE_DEBUG */ time = gegl_ticks (); babl_init (); gegl_instrument ("gegl_init", "babl_init", gegl_ticks () - time); gegl_init_i18n (); time = gegl_ticks (); if (!module_db) { const gchar *gegl_path = g_getenv ("GEGL_PATH"); module_db = gegl_module_db_new (FALSE); if (gegl_path) { gegl_module_db_load (module_db, gegl_path); } else { gchar *module_path; #ifdef G_OS_WIN32 { gchar *prefix; prefix = g_win32_get_package_installation_directory_of_module ( hLibGeglModule ); module_path = g_build_filename (prefix, "lib", GEGL_LIBRARY, NULL); g_free(prefix); } #else module_path = g_build_filename (LIBDIR, GEGL_LIBRARY, NULL); #endif gegl_module_db_load (module_db, module_path); g_free (module_path); /* also load plug-ins from ~/.local/share/gegl-0.0/plugins */ module_path = g_build_filename (g_get_user_data_dir (), GEGL_LIBRARY, "plug-ins", NULL); if (g_mkdir_with_parents (module_path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) { gchar *makefile_path = g_build_filename (module_path, "Makefile", NULL); if (! g_file_test (makefile_path, G_FILE_TEST_EXISTS)) g_file_set_contents (makefile_path, makefile (), -1, NULL); g_free (makefile_path); } gegl_module_db_load (module_db, module_path); g_free (module_path); } gegl_instrument ("gegl_init", "load modules", gegl_ticks () - time); } gegl_instrument ("gegl", "gegl_init", gegl_ticks () - global_time); if (g_getenv ("GEGL_SWAP")) g_object_set (config, "swap", g_getenv ("GEGL_SWAP"), NULL); if (g_getenv ("GEGL_QUALITY")) { const gchar *quality = g_getenv ("GEGL_QUALITY"); if (g_str_equal (quality, "fast")) g_object_set (config, "quality", 0.0, NULL); if (g_str_equal (quality, "good")) g_object_set (config, "quality", 0.5, NULL); if (g_str_equal (quality, "best")) g_object_set (config, "quality", 1.0, NULL); } swap_clean (); return TRUE; }
void SymbianAbldMakefileGenerator::writeMkFile(const QString& wrapperFileName, bool deploymentOnly) { QString mkFullPath = Option::output_dir + QLatin1Char('/') + gnuMakefileName; QFile ft(mkFullPath); if (ft.open(QIODevice::WriteOnly)) { generatedFiles << ft.fileName(); QTextStream t(&ft); t << "# ==============================================================================" << endl; t << "# Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; t << QDateTime::currentDateTime().toString() << endl; t << "# This file is generated by qmake and should not be modified by the" << endl; t << "# user." << endl; t << "# Name : " << gnuMakefileName << endl; t << "# Part of : " << project->values("TARGET").join(" ") << endl; t << "# Description : This file is used to call necessary targets on wrapper makefile" << endl; t << "# during normal Symbian build process." << endl; t << "# Version : " << endl; t << "#" << endl; t << "# ==============================================================================" << "\n" << endl; t << endl << endl; t << "MAKE = make" << endl; t << endl; t << "VISUAL_CFG = RELEASE" << endl; t << "ifeq \"$(CFG)\" \"UDEB\"" << endl; t << "VISUAL_CFG = DEBUG" << endl; t << "endif" << endl; t << endl; t << DO_NOTHING_TARGET " :" << endl; t << "\t" << "@rem " DO_NOTHING_TARGET << endl << endl; QString buildDeps; QString cleanDeps; QString finalDeps; QString cleanDepsWinscw; QString finalDepsWinscw; QStringList wrapperTargets; if (deploymentOnly) { buildDeps.append(STORE_BUILD_TARGET); cleanDeps.append(DEPLOYMENT_CLEAN_TARGET); cleanDepsWinscw.append(WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET); finalDeps.append(DEPLOYMENT_TARGET); finalDepsWinscw.append(WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET); wrapperTargets << WINSCW_DEPLOYMENT_TARGET << WINSCW_DEPLOYMENT_CLEAN_TARGET << DEPLOYMENT_TARGET << DEPLOYMENT_CLEAN_TARGET << STORE_BUILD_TARGET; } else { buildDeps.append(CREATE_TEMPS_TARGET " " PRE_TARGETDEPS_TARGET " " STORE_BUILD_TARGET); cleanDeps.append(EXTENSION_CLEAN " " DEPLOYMENT_CLEAN_TARGET); cleanDepsWinscw.append(EXTENSION_CLEAN " " WINSCW_DEPLOYMENT_CLEAN_TARGET " " DEPLOYMENT_CLEAN_TARGET); finalDeps.append(FINALIZE_TARGET " " DEPLOYMENT_TARGET); finalDepsWinscw.append(FINALIZE_TARGET " " WINSCW_DEPLOYMENT_TARGET " " DEPLOYMENT_TARGET); wrapperTargets << PRE_TARGETDEPS_TARGET << CREATE_TEMPS_TARGET << EXTENSION_CLEAN << FINALIZE_TARGET << WINSCW_DEPLOYMENT_CLEAN_TARGET << WINSCW_DEPLOYMENT_TARGET << DEPLOYMENT_CLEAN_TARGET << DEPLOYMENT_TARGET << STORE_BUILD_TARGET; } t << "MAKMAKE: " << buildDeps << endl << endl; t << "LIB: " << buildDeps << endl << endl; t << "BLD: " << buildDeps << endl << endl; t << "ifeq \"$(PLATFORM)\" \"WINSCW\"" << endl; t << "CLEAN: " << cleanDepsWinscw << endl; t << "else" << endl; t << "CLEAN: " << cleanDeps << endl; t << "endif" << endl << endl; t << "CLEANLIB: " DO_NOTHING_TARGET << endl << endl; t << "RESOURCE: " DO_NOTHING_TARGET << endl << endl; t << "FREEZE: " DO_NOTHING_TARGET << endl << endl; t << "SAVESPACE: " DO_NOTHING_TARGET << endl << endl; t << "RELEASABLES: " DO_NOTHING_TARGET << endl << endl; t << "ifeq \"$(PLATFORM)\" \"WINSCW\"" << endl; t << "FINAL: " << finalDepsWinscw << endl; t << "else" << endl; t << "FINAL: " << finalDeps << endl; t << "endif" << endl << endl; QString makefile(Option::fixPathToTargetOS(fileInfo(wrapperFileName).canonicalFilePath())); foreach(QString target, wrapperTargets) { t << target << " : " << makefile << endl; t << "\t-$(MAKE) -f \"" << makefile << "\" " << target << " QT_SIS_TARGET=$(VISUAL_CFG)-$(PLATFORM)" << endl << endl; }
if (CA == NULL) { X509_NAME_free(CAName); Py_DECREF(CAList); return NULL; } if (PyList_SetItem(CAList, i, CA)) { Py_DECREF(CA); Py_DECREF(CAList); return NULL; } } return CAList; } static char ssl_Connection_makefile_doc[] = "\n\ The makefile() method is not implemented, since there is no dup semantics\n\ for SSL connections\n\ \n\ @raise NotImplementedError\n\ "; static PyObject * ssl_Connection_makefile(ssl_ConnectionObj *self, PyObject *args) { PyErr_SetString(PyExc_NotImplementedError, "Cannot make file object of SSL.Connection"); return NULL; } static char ssl_Connection_get_app_data_doc[] = "\n\ Get application data\n\ \n\ @return: The application data\n\
//Here are where the real methods start int realmake_java::output_makefile() { //First, we need to figure out what kind of Java compiler is available int rc = 0; //This is the return code from the system command std::string tmp = ""; //This is a string buffer struct stat finfo; //This is used to check if a file exists //Can we find a Java compiler on our own? if(verbose) std::cout << "Checking for a Java compiler..." << std::endl; if(!comp.empty()) rc = stat(comp.c_str(),&finfo); else { comp = JAVAC; tmp = "which " + JAVAC + " > /dev/null"; rc = system(tmp.c_str()); } if(0 != rc) { std::cerr << "realmake error: cannot determine what Java compiler to use" << std::endl; std::cerr << "use the -c option to specify a compiler (i.e. -c /usr/bin/javac)" << std::endl; return STATUS_MAKEFILE_ERR; } //Can we find a make program on our own? if(verbose) std::cout << "Checking for a make utility..." << std::endl; if(!m_util.empty()) { rc = stat(m_util.c_str(),&finfo); if(0 != rc) { std::cerr << "realmake error: cannot determine what make utility to use " << std::endl; std::cerr << "use the -m option to specify a make utility (i.e. -m /usr/bin/make)" << std::endl; return STATUS_MAKEFILE_ERR; } } else { m_util = make; tmp = "which " + make + " > /dev/null"; rc = system(tmp.c_str()); } if(0 != rc) { tmp = "which " + gmake; rc = system(tmp.c_str()); if(0 != rc) { std::cerr << "realmake error: cannot determine which make utility to use" << std::endl; return STATUS_MAKEFILE_ERR; } else m_util = gmake; } //open a handle to the source code directory DIR *dir = 0; struct dirent *d_entry = 0; dir = opendir(source_dir.c_str()); if(NULL == dir) { std::cerr << "realmake error: the directory " << source_dir << " cannot be opened" << std::endl; return STATUS_MAKEFILE_ERR; } //Now, check if the given directory actually has Java files if(verbose) std::cout << "Checking source files in (" << source_dir << ")..." << std::endl; std::map <std::string,std::string> files; while(NULL != (d_entry = readdir(dir))) { if(DT_REG == d_entry->d_type) { std::string buf(d_entry->d_name); if((buf.find_last_of(".") + 1) < buf.length()) { if(0 == strcasecmp("java",buf.substr(buf.find_last_of(".") + 1).c_str())) files[buf] = buf; //files[buf.substr(0,buf.find_last_of(".")) + ".java"] = buf; } } } if(files.empty()) { std::cout << "realmake error: no Java files found in the (" << source_dir << ") directory" << std::endl; std::cout << "Use " << src_dir << " argument to specify the source code directory" << std::endl; closedir(dir); return STATUS_MAKEFILE_ERR; } //open a file stream srand(time(0)); std::stringstream convert; convert << rand(); std::string filename = "Makefile." + convert.str(); std::ofstream makefile(filename.c_str()); if(!makefile) { std::cerr << "realmake error: cannot open makefile for writing" << std::endl; closedir(dir); return STATUS_FILE_IO_ERR; } //Now, write data to the makefile if(verbose) std::cout << "Writing makefile..." << std::endl; makefile << m_header << std::endl << std::endl; makefile << "JAVA=" + comp << std::endl; if(!flags.empty()) makefile << "CFLAGS=" + flags << std::endl; else makefile << "CFLAGS=" << std::endl; /*if(!name.empty()) makefile << "NAME=" + source_dir + "/" + name << std::endl; else makefile << "NAME=" + source_dir + "/a.out" << std::endl;*/ makefile << "FILES="; for(std::map <std::string,std::string>::iterator ii=files.begin(); ii != files.end(); ii++) makefile << source_dir + "/" + (*ii).first << " "; makefile << std::endl << std::endl; makefile << "all: $(FILES)" << std::endl; /*makefile << "$(NAME): $(CLASS)" << std::endl;*/ makefile << "\t$(JAVA) $(CFLAGS) $(FILES)" << std::endl << std::endl; /*for(std::map <std::string,std::string>::iterator ii=files.begin(); ii != files.end(); ii++) { makefile << (*ii).first << ": " << source_dir + "/" << (*ii).second << std::endl; makefile << "\t$(JAVA) $(CFLAGS) " << source_dir + "/" << (*ii).second << std::endl << std::endl; }*/ makefile << "clean:" << std::endl; makefile << "\trm -f " << source_dir + "/*.class" << std::endl; //Be sure to close the file stream makefile.close(); closedir(dir); makef_name = filename; if(verbose) std::cout << "Finished writing makefile..." << std::endl; return STATUS_OK; }
// Main Function void _main(void) { signed char STATUS, a; int plinkos; unsigned char *Home = malloc(LCD_SIZE); // Allocate the SAVE_SCREEN buffer if (Home == NULL) { Error_Memory(); return; } LCD_save(Home); // Save LCD HomeScreen Contents virtual_dark = malloc ( LCD_SIZE ); // Allocate the dark buffer if (virtual_dark == NULL) {Error_Memory(); return; } virtual_light=malloc ( LCD_SIZE ); // Allocate the light buffer if (virtual_light == NULL) { free(virtual_dark); Error_Memory(); return; } randomize(); if (Gray_prep() == QUIT) { Error_Memory(); goto end; } if (makefile() == QUIT) // Tests whether or not we need a default save file and installs one if the // user doesn't already have one on their calc goto end; for(a = 10; a--;) FADE_LIGHTER(); // Clears both Hidden Gray planes ClearGrayScreen2B(Hiddenl, Hiddend); GraySpriteX8_OR(52, 37, 27, titlel, titled, 7, Hiddenl, Hiddend); FontSetSys (F_4x6); GrayDBufSetHiddenAMSPlane (DARK_PLANE); DrawStr(122, 94, "-- By Fisch", A_NORMAL); GrayDBufSetHiddenAMSPlane (LIGHT_PLANE); DrawStr(123, 95, "-- By Fisch", A_NORMAL); GrayDBufToggleSync(); // switches two sets of planes for(a = 10; a--;) FADE_DARKER(); Waitkey(); NEW_GAME: if ((STATUS = MENU()) == QUIT) goto end; if ((plinkos = PRODUCTS()) == QUIT) goto end; if ((STATUS = INTRO()) == QUIT) goto end; if ((STATUS = main_game(plinkos)) == QUIT) goto end; goto NEW_GAME; end: // Clean up at end of Program Cleanup(); if (Home) { LCD_restore(Home); free(Home); GKeyFlush(); ST_helpMsg("Plinko --By Travis Fischer"); } }