void glk_main () { int file; struct stat info; const char * ptr; if (gStartupError) fatalError(gStartupError); file = open (gFilename, O_RDONLY); if (file < 0) goto error; if (fstat (file, &info) != 0) goto error; if (info.st_size < 256) fatalError("This is too small to be a glulx file."); ptr = mmap (NULL, info.st_size, PROT_READ, MAP_PRIVATE, file, 0); if (ptr == MAP_FAILED) goto error; git (ptr, info.st_size, CACHE_SIZE, UNDO_SIZE); munmap ((void*) ptr, info.st_size); return; error: perror ("git"); exit (errno); }
void glk_main () { strid_t file = mac_gamefile; size_t size, remaining; git_uint8 * data; git_uint8 * ptr; glk_stream_set_position (file, 0, seekmode_End); size = glk_stream_get_position (file); glk_stream_set_position (file, 0, seekmode_Start); data = malloc (size); ptr = data; remaining = size; while (remaining > 0) { size_t n = glk_get_buffer_stream (file, (char *) ptr, remaining); if (n == 0) { printf ("Can't read file."); exit(1); } remaining -= n; ptr += n; } glk_stream_close (file, NULL); git (data, size, CACHE_SIZE, UNDO_SIZE); }
void Area::load() { Aurora::GFF3File are(_resRef, Aurora::kFileTypeARE, MKTAG('A', 'R', 'E', ' '), true); loadARE(are.getTopLevel()); Aurora::GFF3File git(_resRef, Aurora::kFileTypeGIT, MKTAG('G', 'I', 'T', ' '), true); loadGIT(git.getTopLevel()); }
static gboolean git_mirror_repo (const char *repo_location, gboolean update, const char *ref, BuilderContext *context, GError **error) { g_autoptr(GFile) mirror_dir = NULL; g_autofree char *current_commit = NULL; mirror_dir = git_get_mirror_dir (repo_location, context); if (!g_file_query_exists (mirror_dir, NULL)) { g_autofree char *filename = g_file_get_basename (mirror_dir); g_autoptr(GFile) parent = g_file_get_parent (mirror_dir); g_autofree char *filename_tmp = g_strconcat (filename, ".clone_tmp", NULL); g_autoptr(GFile) mirror_dir_tmp = g_file_get_child (parent, filename_tmp); g_print ("Cloning git repo %s\n", repo_location); if (!git (parent, NULL, error, "clone", "--mirror", repo_location, filename_tmp, NULL) || !g_file_move (mirror_dir_tmp, mirror_dir, 0, NULL, NULL, NULL, error)) return FALSE; } else if (update) { g_print ("Fetching git repo %s\n", repo_location); if (!git (mirror_dir, NULL, error, "fetch", "-p", NULL)) return FALSE; } current_commit = git_get_current_commit (mirror_dir, ref, context, error); if (current_commit == NULL) return FALSE; if (!git_mirror_submodules (repo_location, update, mirror_dir, current_commit, context, error)) return FALSE; return TRUE; }
bool ApsHandler::savePrinterDriver(KMPrinter *prt, PrintcapEntry *entry, DrMain *driver, bool*) { if (driver->get("gsdriver").isEmpty()) { manager()->setErrorMsg(i18n("The APS driver is not defined.")); return false; } TQFile f(sysconfDir() + "/" + prt->printerName() + "/apsfilterrc"); if (f.open(IO_WriteOnly)) { TQTextStream t(&f); t << "# File generated by TDEPrint" << endl; t << "PRINTER='" << driver->get("gsdriver") << "'" << endl; TQValueStack<DrGroup*> stack; stack.push(driver); while (stack.count() > 0) { DrGroup *grp = stack.pop(); TQPtrListIterator<DrGroup> git(grp->groups()); for (; git.current(); ++git) stack.push(git.current()); TQPtrListIterator<DrBase> oit(grp->options()); TQString value; for (; oit.current(); ++oit) { value = oit.current()->valueText(); switch (oit.current()->type()) { case DrBase::Boolean: if (value == "true") t << oit.current()->name() << "='" << value << "'" << endl; break; case DrBase::List: if (value != "(empty)") t << oit.current()->name() << "='" << value << "'" << endl; break; case DrBase::String: if (!value.isEmpty()) t << oit.current()->name() << "='" << value << "'" << endl; break; default: break; } } } return true; } else { manager()->setErrorMsg(i18n("Unable to create the file %1.").arg(f.name())); return false; } }
static gboolean builder_source_git_extract (BuilderSource *source, GFile *dest, BuilderContext *context, GError **error) { BuilderSourceGit *self = BUILDER_SOURCE_GIT (source); g_autoptr(GFile) mirror_dir = NULL; g_autofree char *mirror_dir_path = NULL; g_autofree char *dest_path = NULL; g_autofree char *location = NULL; location = get_url_or_path (self, context, error); if (location == NULL) return FALSE; mirror_dir = git_get_mirror_dir (location, context); mirror_dir_path = g_file_get_path (mirror_dir); dest_path = g_file_get_path (dest); if (!git (NULL, NULL, error, "clone", mirror_dir_path, dest_path, NULL)) return FALSE; if (!git (dest, NULL, error, "checkout", get_branch (self), NULL)) return FALSE; if (!git_extract_submodule (location, dest, context, error)) return FALSE; if (!git (dest, NULL, error, "config", "--local", "remote.origin.url", location, NULL)) return FALSE; return TRUE; }
DrBase *DrGroup::clone() { DrGroup *grp = static_cast< DrGroup * >(DrBase::clone()); QPtrListIterator< DrGroup > git(m_subgroups); for(; git.current(); ++git) grp->addGroup(static_cast< DrGroup * >(git.current()->clone())); QPtrListIterator< DrBase > oit(m_listoptions); for(; oit.current(); ++oit) grp->addOption(oit.current()->clone()); return static_cast< DrBase * >(grp); }
void KviRegisteredUserDataBase::save(const QString & szFilename) { KviConfigurationFile cfg(szFilename, KviConfigurationFile::Write); cfg.clear(); cfg.preserveEmptyGroups(true); KviPointerHashTableIterator<QString, KviRegisteredUser> it(*m_pUserDict); while(it.current()) { cfg.setGroup(it.current()->name()); // Write properties cfg.writeEntry("IgnoreEnabled", it.current()->ignoreEnabled()); cfg.writeEntry("IgnoreFlags", it.current()->ignoreFlags()); if(it.current()->propertyDict()) { KviPointerHashTableIterator<QString, QString> pit(*(it.current()->propertyDict())); while(pit.current()) { QString tmp = "prop_"; tmp.append(pit.currentKey()); cfg.writeEntry(tmp, *(pit.current())); ++pit; } } // Write masks int i = 0; for(KviIrcMask * pMask = it.current()->maskList()->first(); pMask; pMask = it.current()->maskList()->next()) { QString szTmp = QString("mask_%1").arg(i); QString szMask; pMask->mask(szMask, KviIrcMask::NickUserHost); cfg.writeEntry(szTmp, szMask); ++i; } cfg.writeEntry("Group", it.current()->group()); ++it; } KviPointerHashTableIterator<QString, KviRegisteredUserGroup> git(*m_pGroupDict); QString szTmp; while(git.current()) { szTmp = QString("#Group %1").arg(git.current()->name()); cfg.setGroup(szTmp); ++git; } }
void Area::load(const Common::UString &resRef) { _resRef = resRef; loadLYT(); // Room layout loadVIS(); // Room visibilities loadRooms(); Aurora::GFF3File are(_resRef, Aurora::kFileTypeARE, MKTAG('A', 'R', 'E', ' ')); loadARE(are.getTopLevel()); Aurora::GFF3File git(_resRef, Aurora::kFileTypeGIT, MKTAG('G', 'I', 'T', ' ')); loadGIT(git.getTopLevel()); _loaded = true; }
static char * git_get_current_commit (GFile *repo_dir, const char *branch, BuilderContext *context, GError **error) { char *output = NULL; if (!git (repo_dir, &output, error, "rev-parse", branch, NULL)) return NULL; /* Trim trailing whitespace */ g_strchomp (output); return output; }
void KviRegisteredUserDataBase::copyFrom(KviRegisteredUserDataBase * db) { m_pUserDict->clear(); m_pWildMaskList->clear(); m_pMaskDict->clear(); m_pGroupDict->clear(); emit(databaseCleared()); KviPointerHashTableIterator<QString, KviRegisteredUser> it(*(db->m_pUserDict)); while(KviRegisteredUser * theCur = it.current()) { KviRegisteredUser * u = getUser(theCur->name()); // copy masks KviPointerList<KviIrcMask> * l = theCur->maskList(); for(KviIrcMask * m = l->first(); m; m = l->next()) { KviIrcMask * m2 = new KviIrcMask(*m); addMask(u, m2); } // copy properties KviPointerHashTable<QString, QString> * pd = theCur->propertyDict(); if(pd) { KviPointerHashTableIterator<QString, QString> pdi(*pd); while(pdi.current()) { u->setProperty(pdi.currentKey(), *(pdi.current())); ++pdi; } } u->m_iIgnoreFlags = theCur->m_iIgnoreFlags; u->m_bIgnoreEnabled = theCur->m_bIgnoreEnabled; u->setGroup(theCur->group()); ++it; } KviPointerHashTableIterator<QString, KviRegisteredUserGroup> git(*db->m_pGroupDict); while(git.current()) { addGroup(git.currentKey()); ++git; } }
void SmoothedClassProbabilites< TImage> ::GenerateData() { typename TImage::Pointer out = this->GetOutput(0); out->SetRegions(this->GetInput(0)->GetLargestPossibleRegion()); out->Allocate(); for(unsigned int i = 0 ; i < this->GetNumberOfInputs(); i++) { auto gf = itk::DiscreteGaussianImageFilter<TImage,TImage>::New(); gf->SetInput(this->GetInput(i)); gf->SetVariance(this->m_Sigma); gf->Update(); ImageRegionConstIterator<TImage> git(gf->GetOutput(),gf->GetOutput()->GetLargestPossibleRegion()); ImageRegionIterator<TImage> maskiter(m_MaskImage, m_MaskImage->GetLargestPossibleRegion()); ImageRegionIterator<TImage> outputIter(out, out->GetLargestPossibleRegion()); while (!outputIter.IsAtEnd()) { if(maskiter.Value() > 0 ){ if(git.Value() > outputIter.Value()) outputIter.Set(i); }else { outputIter.Set(0); } ++git; ++outputIter; ++maskiter; } } }
Area::Area(Module &module, const Common::UString &resRef) : Object(kObjectTypeArea), _module(&module), _resRef(resRef), _visible(false), _activeObject(0), _highlightAll(false) { try { // Load ARE and GIT Aurora::GFF3File are(_resRef, Aurora::kFileTypeARE, MKTAG('A', 'R', 'E', ' ')); loadARE(are.getTopLevel()); Aurora::GFF3File git(_resRef, Aurora::kFileTypeGIT, MKTAG('G', 'I', 'T', ' ')); loadGIT(git.getTopLevel()); } catch (...) { clear(); throw; } // Tell the module that we exist _module->addObject(*this); }
PMRuleGroup::PMRuleGroup( QDomElement& e, QPtrList<PMRuleDefineGroup>& globalGroups, QPtrList<PMRuleDefineGroup>& localGroups ) : PMRuleCategory( ) { m_pGroup = 0; QString groupName = e.attribute( "name" ); if( groupName.isEmpty( ) ) kdError( PMArea ) << "RuleSystem: Invalid group name" << endl; // find group QPtrListIterator<PMRuleDefineGroup> lit( localGroups ); for( ; lit.current( ) && !m_pGroup; ++lit ) if( lit.current( )->name( ) == groupName ) m_pGroup = lit.current( ); QPtrListIterator<PMRuleDefineGroup> git( globalGroups ); for( ; git.current( ) && !m_pGroup; ++git ) if( git.current( )->name( ) == groupName ) m_pGroup = git.current( ); if( !m_pGroup ) kdError( PMArea ) << "RuleSystem: Group not defined: " << groupName << endl; }
void DrGroup::flattenGroup(QMap< QString, DrBase * > &optmap, int &index) { QPtrListIterator< DrGroup > git(m_subgroups); for(; git.current(); ++git) git.current()->flattenGroup(optmap, index); QDictIterator< DrBase > oit(m_options); for(; oit.current(); ++oit) optmap[oit.current()->name()] = oit.current(); if(name().isEmpty()) optmap[QString::fromLatin1("group%1").arg(index++)] = this; else optmap[name()] = this; m_subgroups.setAutoDelete(false); m_options.setAutoDelete(false); m_subgroups.clear(); m_options.clear(); m_listoptions.clear(); m_subgroups.setAutoDelete(true); m_options.setAutoDelete(true); }
bool Track::IsSyncLockSelected() const { #ifdef EXPERIMENTAL_SYNC_LOCK AudacityProject *p = GetActiveProject(); if (!p || !p->IsSyncLocked()) return false; SyncLockedTracksIterator git(mList); Track *t = git.StartWith(const_cast<Track*>(this)); if (!t) { // Not in a sync-locked group. return ((this->GetKind() == Track::Wave) || (this->GetKind() == Track::Label)) && GetSelected(); } for (; t; t = git.Next()) { if (t->GetSelected()) return true; } #endif return false; }
void KXmlCommandAdvancedDlg::parseGroupItem(DrGroup *grp, TQListViewItem *parent) { TQListViewItem *item(0); TQPtrListIterator<DrGroup> git(grp->groups()); for (; git.current(); ++git) { TQString namestr = git.current()->name(); if (namestr.isEmpty()) { namestr = "group_"+kapp->randomString(4); } git.current()->setName(namestr); item = new TQListViewItem(parent, item, git.current()->get("text"), git.current()->name()); item->setPixmap(0, SmallIcon("folder")); item->setOpen(true); item->setRenameEnabled(0, true); parseGroupItem(git.current(), item); m_opts[namestr] = git.current(); } TQPtrListIterator<DrBase> oit(grp->options()); for (; oit.current(); ++oit) { TQString namestr = oit.current()->name().mid(m_xmlcmd->name().length()+6); if (namestr.isEmpty()) { namestr = "option_"+kapp->randomString(4); } oit.current()->setName(namestr); item = new TQListViewItem(parent, item, oit.current()->get("text"), namestr); item->setPixmap(0, SmallIcon("document")); item->setRenameEnabled(0, true); m_opts[namestr] = oit.current(); } }
bool EffectNyquist::ProcessOne() { nyx_rval rval; if (GetEffectFlags() & INSERT_EFFECT) { nyx_set_audio_params(mCurTrack[0]->GetRate(), 0); } else { nyx_set_audio_params(mCurTrack[0]->GetRate(), mCurLen); nyx_set_input_audio(StaticGetCallback, (void *)this, mCurNumChannels, mCurLen, mCurTrack[0]->GetRate()); } wxString cmd; if (mDebug) { cmd += wxT("(setf *tracenable* T)\n"); if (mExternal) { cmd += wxT("(setf *breakenable* T)\n"); } } for (unsigned int j = 0; j < mControls.GetCount(); j++) { if (mControls[j].type == NYQ_CTRL_REAL) { // We use Internat::ToString() rather than "%f" here because we // always have to use the dot as decimal separator when giving // numbers to Nyquist, whereas using "%f" will use the user's // decimal separator which may be a comma in some countries. cmd += wxString::Format(wxT("(setf %s %s)\n"), mControls[j].var.c_str(), Internat::ToString(mControls[j].val).c_str()); } else if (mControls[j].type == NYQ_CTRL_INT || mControls[j].type == NYQ_CTRL_CHOICE) { cmd += wxString::Format(wxT("(setf %s %d)\n"), mControls[j].var.c_str(), (int)(mControls[j].val)); } else if (mControls[j].type == NYQ_CTRL_STRING) { wxString str = mControls[j].valStr; str.Replace(wxT("\\"), wxT("\\\\")); str.Replace(wxT("\""), wxT("\\\"")); cmd += wxT("(setf "); // restrict variable names to 7-bit ASCII: cmd += mControls[j].var.c_str(); cmd += wxT(" \""); cmd += str; // unrestricted value will become quoted UTF-8 cmd += wxT("\")\n"); } } if (mIsSal) { wxString str = mCmd; str.Replace(wxT("\\"), wxT("\\\\")); str.Replace(wxT("\""), wxT("\\\"")); // this is tricky: we need SAL to call main so that we can get a // SAL traceback in the event of an error (sal-compile catches the // error and calls sal-error-output), but SAL does not return values. // We will catch the value in a special global aud:result and if no // error occurs, we will grab the value with a LISP expression str += wxT("\nset aud:result = main()\n"); if (mDebug) { // since we're about to evaluate SAL, remove LISP trace enable and // break enable (which stops SAL processing) and turn on SAL stack // trace cmd += wxT("(setf *tracenable* nil)\n"); cmd += wxT("(setf *breakenable* nil)\n"); cmd += wxT("(setf *sal-traceback* t)\n"); } if (mCompiler) { cmd += wxT("(setf *sal-compiler-debug* t)\n"); } cmd += wxT("(setf *sal-call-stack* nil)\n"); // if we do not set this here and an error occurs in main, another // error will be raised when we try to return the value of aud:result // which is unbound cmd += wxT("(setf aud:result nil)\n"); cmd += wxT("(sal-compile-audacity \"") + str + wxT("\" t t nil)\n"); // Capture the value returned by main (saved in aud:result), but // set aud:result to nil so sound results can be evaluated without // retaining audio in memory cmd += wxT("(prog1 aud:result (setf aud:result nil))\n"); } else { cmd += mCmd; } int i; for (i = 0; i < mCurNumChannels; i++) { mCurBuffer[i] = NULL; } rval = nyx_eval_expression(cmd.mb_str(wxConvUTF8)); if (rval == nyx_string) { wxMessageBox(NyquistToWxString(nyx_get_string()), wxT("Nyquist"), wxOK | wxCENTRE, mParent); return true; } if (rval == nyx_double) { wxString str; str.Printf(_("Nyquist returned the value:") + wxString(wxT(" %f")), nyx_get_double()); wxMessageBox(str, wxT("Nyquist"), wxOK | wxCENTRE, mParent); return true; } if (rval == nyx_int) { wxString str; str.Printf(_("Nyquist returned the value:") + wxString(wxT(" %d")), nyx_get_int()); wxMessageBox(str, wxT("Nyquist"), wxOK | wxCENTRE, mParent); return true; } if (rval == nyx_labels) { unsigned int numLabels = nyx_get_num_labels(); unsigned int l; LabelTrack *ltrack = NULL; TrackListIterator iter(mOutputTracks); for (Track *t = iter.First(); t; t = iter.Next()) { if (t->GetKind() == Track::Label) { ltrack = (LabelTrack *)t; break; } } if (!ltrack) { ltrack = mFactory->NewLabelTrack(); this->AddToOutputTracks((Track *)ltrack); } for (l = 0; l < numLabels; l++) { double t0, t1; const char *str; nyx_get_label(l, &t0, &t1, &str); ltrack->AddLabel(t0 + mT0, t1 + mT0, UTF8CTOWX(str)); } return true; } if (rval != nyx_audio) { wxMessageBox(_("Nyquist did not return audio.\n"), wxT("Nyquist"), wxOK | wxCENTRE, mParent); return false; } int outChannels; outChannels = nyx_get_audio_num_channels(); if (outChannels > mCurNumChannels) { wxMessageBox(_("Nyquist returned too many audio channels.\n"), wxT("Nyquist"), wxOK | wxCENTRE, mParent); return false; } double rate = mCurTrack[0]->GetRate(); for (i = 0; i < outChannels; i++) { sampleFormat format = mCurTrack[i]->GetSampleFormat(); if (outChannels == mCurNumChannels) { rate = mCurTrack[i]->GetRate(); } mOutputTrack[i] = mFactory->NewWaveTrack(format, rate); mCurBuffer[i] = NULL; } int success = nyx_get_audio(StaticPutCallback, (void *)this); if (!success) { for(i = 0; i < outChannels; i++) { delete mOutputTrack[i]; mOutputTrack[i] = NULL; } return false; } for (i = 0; i < outChannels; i++) { mOutputTrack[i]->Flush(); if (mCurBuffer[i]) { DeleteSamples(mCurBuffer[i]); } mOutputTime = mOutputTrack[i]->GetEndTime(); } for (i = 0; i < mCurNumChannels; i++) { WaveTrack *out; if (outChannels == mCurNumChannels) { out = mOutputTrack[i]; } else { out = mOutputTrack[0]; } mCurTrack[i]->ClearAndPaste(mT0, mT1, out, false, false); // If we were first in the group adjust non-selected group tracks if (mFirstInGroup) { SyncLockedTracksIterator git(mOutputTracks); Track *t; for (t = git.First(mCurTrack[i]); t; t = git.Next()) { if (!t->GetSelected() && t->IsSyncLockSelected()) { t->SyncLockAdjust(mT1, mT0 + out->GetEndTime()); } } } // Only the first channel can be first in its group mFirstInGroup = false; } for (i = 0; i < outChannels; i++) { delete mOutputTrack[i]; mOutputTrack[i] = NULL; } return true; }
static gboolean git_extract_submodule (const char *repo_url, GFile *checkout_dir, BuilderContext *context, GError **error) { g_autofree char *submodule_status = NULL; if (!git (checkout_dir, &submodule_status, error, "submodule", "status", NULL)) return FALSE; if (submodule_status) { int i; g_auto(GStrv) lines = g_strsplit (submodule_status, "\n", -1); for (i = 0; lines[i] != NULL; i++) { g_autoptr(GFile) mirror_dir = NULL; g_autoptr(GFile) child_dir = NULL; g_autofree char *child_url = NULL; g_autofree char *option = NULL; g_autofree char *child_relative_url = NULL; g_autofree char *mirror_dir_as_url = NULL; g_auto(GStrv) words = NULL; if (*lines[i] == 0) continue; words = g_strsplit (lines[i] + 1, " ", 3); option = g_strdup_printf ("submodule.%s.url", words[1]); if (!git (checkout_dir, &child_relative_url, error, "config", "-f", ".gitmodules", option, NULL)) return FALSE; /* Trim trailing whitespace */ g_strchomp (child_relative_url); g_print ("processing submodule %s\n", words[1]); child_url = make_absolute_url (repo_url, child_relative_url, error); if (child_url == NULL) return FALSE; mirror_dir = git_get_mirror_dir (child_url, context); mirror_dir_as_url = g_file_get_uri (mirror_dir); if (!git (checkout_dir, NULL, error, "config", option, mirror_dir_as_url, NULL)) return FALSE; if (!git (checkout_dir, NULL, error, "submodule", "update", "--init", words[1], NULL)) return FALSE; child_dir = g_file_resolve_relative_path (checkout_dir, words[1]); if (!git_extract_submodule (child_url, child_dir, context, error)) return FALSE; } } return TRUE; }
void DiffusionOdfPrepareVisualizationImageFilter< TOdfPixelType, NrOdfDirections> ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType ) { typename OutputImageType::Pointer outputImage = static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0)); ImageRegionIterator< OutputImageType > oit(outputImage, outputRegionForThread); oit.GoToBegin(); typedef itk::OrientationDistributionFunction<TOdfPixelType,NrOdfDirections> OdfType; typedef ImageRegionConstIterator< InputImageType > InputIteratorType; typedef typename InputImageType::PixelType OdfVectorType; typename InputImageType::Pointer inputImagePointer = nullptr; inputImagePointer = static_cast< InputImageType * >( this->ProcessObject::GetInput(0) ); InputIteratorType git(inputImagePointer, outputRegionForThread ); git.GoToBegin(); typedef ImageRegionConstIterator< GfaImageType > GfaIteratorType; GfaIteratorType gfaIt(m_GfaImage, outputRegionForThread); while( !git.IsAtEnd() ) { OdfVectorType b = git.Get(); OdfType odf = b.GetDataPointer(); switch( m_NormalizationMethod ) { case PV_NONE: { break; } case PV_MAX: { odf = odf.MaxNormalize(); break; } case PV_MIN_MAX: { odf = odf.MinMaxNormalize(); break; } case PV_GLOBAL_MAX: { odf *= 1.0/m_GlobalInputMaximum; break; } case PV_MIN_MAX_INVERT: { odf = odf.MinMaxNormalize(); for(int i=0; i<NrOdfDirections; i++) { odf[i] = 1.0 - odf[i]; } break; } } if(m_DoScaleGfa) { odf *= gfaIt.Get(); ++gfaIt; } odf *= 0.5; oit.Set( odf.GetDataPointer() ); ++oit; ++git; // Gradient image iterator } std::cout << "One Thread finished extraction" << std::endl; }
ECPComponentBuilder::GridType* ECPComponentBuilder::createGrid(xmlNodePtr cur, bool useLinear) { RealType ri = 1e-6; RealType rf = 100.0; RealType ascale = -1.0e0; RealType astep = -1.0; //RealType astep = 1.25e-2; int npts = 1001; string gridType("log"); string gridID("global"); OhmmsAttributeSet radAttrib; radAttrib.add(gridType,"type"); radAttrib.add(gridID,"grid_id"); radAttrib.add(gridID,"grid_def"); radAttrib.add(gridID,"name"); radAttrib.add(gridID,"id"); radAttrib.add(npts,"npts"); radAttrib.add(ri,"ri"); radAttrib.add(rf,"rf"); radAttrib.add(ascale,"ascale"); radAttrib.add(astep,"astep"); radAttrib.add(ascale,"scale"); radAttrib.add(astep,"step"); radAttrib.put(cur); map<string,GridType*>::iterator git(grid_inp.find(gridID)); if(git != grid_inp.end()) { return (*git).second; //use the same grid } //overwrite the grid type to linear starting at 0.0 if(useLinear) { gridType="linear"; ri=0.0; } GridType *agrid=0; if(gridType == "log") { if(ascale>0.0) { app_log() << " Log grid scale=" << ascale << " step=" << astep << " npts=" << npts << endl; agrid = new LogGridZero<RealType>; agrid->set(astep,ascale,npts); } else { if(ri<numeric_limits<RealType>::epsilon()) { ri=numeric_limits<RealType>::epsilon(); } agrid = new LogGrid<RealType>; agrid->set(ri,rf,npts); } } else if(gridType == "linear") { agrid = new LinearGrid<RealType>; if(astep>0.0) { npts = static_cast<int>((rf-ri)/astep)+1; } agrid->set(ri,rf,npts); app_log() << " Linear grid ri=" << ri << " rf=" << rf << " npts = " << npts << endl; } else //accept numerical data { xmlNodePtr cur1=cur->children; while(cur1 != NULL) { string cname((const char*)cur1->name); if(cname == "data") { std::vector<double> gIn(npts); putContent(gIn,cur1); agrid = new NumericalGrid<RealType>(gIn); app_log() << " Numerical grid npts = " << gIn.size() << endl; } cur1 = cur1->next; } } return agrid; }
static gboolean git_mirror_submodules (const char *repo_location, gboolean update, GFile *mirror_dir, const char *revision, BuilderContext *context, GError **error) { g_autofree char *mirror_dir_path = NULL; g_autoptr(GFile) checkout_dir_template = NULL; g_autoptr(GFile) checkout_dir = NULL; g_autofree char *checkout_dir_path = NULL; g_autofree char *submodule_status = NULL; mirror_dir_path = g_file_get_path (mirror_dir); checkout_dir_template = g_file_get_child (builder_context_get_state_dir (context), "tmp-checkout-XXXXXX"); checkout_dir_path = g_file_get_path (checkout_dir_template); if (g_mkdtemp (checkout_dir_path) == NULL) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Can't create temporary checkout directory"); return FALSE; } checkout_dir = g_file_new_for_path (checkout_dir_path); if (!git (NULL, NULL, error, "clone", "-q", "--no-checkout", mirror_dir_path, checkout_dir_path, NULL)) return FALSE; if (!git (checkout_dir, NULL, error, "checkout", "-q", "-f", revision, NULL)) return FALSE; if (!git (checkout_dir, &submodule_status, error, "submodule", "status", NULL)) return FALSE; if (submodule_status) { int i; g_auto(GStrv) lines = g_strsplit (submodule_status, "\n", -1); for (i = 0; lines[i] != NULL; i++) { g_autofree char *url = NULL; g_autofree char *option = NULL; g_autofree char *old = NULL; g_auto(GStrv) words = NULL; if (*lines[i] == 0) continue; words = g_strsplit (lines[i] + 1, " ", 3); option = g_strdup_printf ("submodule.%s.url", words[1]); if (!git (checkout_dir, &url, error, "config", "-f", ".gitmodules", option, NULL)) return FALSE; /* Trim trailing whitespace */ g_strchomp (url); old = url; url = make_absolute (repo_location, old, error); if (url == NULL) return FALSE; if (!git_mirror_repo (url, update, words[0], context, error)) return FALSE; } } if (!gs_shutil_rm_rf (checkout_dir, NULL, error)) return FALSE; return TRUE; }
static gboolean git_extract_submodule (const char *repo_location, GFile *checkout_dir, BuilderContext *context, GError **error) { g_autofree char *submodule_status = NULL; if (!git (checkout_dir, &submodule_status, error, "submodule", "status", NULL)) return FALSE; if (submodule_status) { int i; g_auto(GStrv) lines = g_strsplit (submodule_status, "\n", -1); for (i = 0; lines[i] != NULL; i++) { g_autoptr(GFile) mirror_dir = NULL; g_autoptr(GFile) child_dir = NULL; g_autofree char *child_url = NULL; g_autofree char *option = NULL; g_autofree char *update_method = NULL; g_autofree char *child_relative_url = NULL; g_autofree char *mirror_dir_as_url = NULL; g_auto(GStrv) words = NULL; if (*lines[i] == 0) continue; words = g_strsplit (lines[i] + 1, " ", 3); /* Skip any submodules that are disabled (have the update method set to "none") Only check if the command succeeds. If it fails, the update method is not set. */ option = g_strdup_printf ("submodule.%s.update", words[1]); if (git (checkout_dir, &update_method, NULL, "config", "-f", ".gitmodules", option, NULL)) { /* Trim trailing whitespace */ g_strchomp (update_method); if (g_strcmp0 (update_method, "none") == 0) continue; } option = g_strdup_printf ("submodule.%s.url", words[1]); if (!git (checkout_dir, &child_relative_url, error, "config", "-f", ".gitmodules", option, NULL)) return FALSE; /* Trim trailing whitespace */ g_strchomp (child_relative_url); g_print ("processing submodule %s\n", words[1]); child_url = make_absolute (repo_location, child_relative_url, error); if (child_url == NULL) return FALSE; mirror_dir = git_get_mirror_dir (child_url, context); mirror_dir_as_url = g_file_get_uri (mirror_dir); if (!git (checkout_dir, NULL, error, "config", option, mirror_dir_as_url, NULL)) return FALSE; if (!git (checkout_dir, NULL, error, "submodule", "update", "--init", words[1], NULL)) return FALSE; child_dir = g_file_resolve_relative_path (checkout_dir, words[1]); if (!git_extract_submodule (child_url, child_dir, context, error)) return FALSE; } } return TRUE; }