// Import implements the Store interface.
497766
func (s *winStore) Import(data []byte, password string) error {
	cdata := C.CBytes(data)
	defer C.free(cdata)

	cpw := stringToUTF16(password)
	defer C.free(unsafe.Pointer(cpw))

	pfx := &C.CRYPT_DATA_BLOB{
		cbData: C.DWORD(len(data)),
		pbData: (*C.BYTE)(cdata),
	}

	flags := C.CRYPT_USER_KEYSET

	// import into preferred KSP
	if winAPIFlag&C.CRYPT_ACQUIRE_PREFER_NCRYPT_KEY_FLAG > 0 {
		flags |= C.PKCS12_PREFER_CNG_KSP
	} else if winAPIFlag&C.CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG > 0 {
		flags |= C.PKCS12_ALWAYS_CNG_KSP
	}

	store := C.PFXImportCertStore(pfx, cpw, C.DWORD(flags))
	if store == nil {
		return lastError("failed to import PFX cert store")
	}
	defer C.CertCloseStore(store, C.CERT_CLOSE_STORE_FORCE_FLAG)

	var (
		ctx      = C.PCCERT_CONTEXT(nil)
		encoding = C.DWORD(C.X509_ASN_ENCODING | C.PKCS_7_ASN_ENCODING)
	)

	for {
		// iterate through certs in temporary store
		if ctx = C.CertFindCertificateInStore(store, encoding, 0, C.CERT_FIND_ANY, nil, ctx); ctx == nil {
			if err := checkError("failed to iterate certs in store"); err != nil && errors.Cause(err) != errCode(CRYPT_E_NOT_FOUND) {
				return err
			}

			break
		}

		// Copy the cert to the system store.
		if ok := C.CertAddCertificateContextToStore(s.store, ctx, C.CERT_STORE_ADD_REPLACE_EXISTING, nil); ok == winFalse {
			return lastError("failed to add importerd certificate to MY store")
		}
	}

	return nil
}
1100691
func (imp *Import) Compare(other *Import) int {
	if imp == nil {
		if other == nil {
			return 0
		}
		return -1
	} else if other == nil {
		return 1
	}
	if cmp := Compare(imp.Path, other.Path); cmp != 0 {
		return cmp
	}
	return Compare(imp.Alias, other.Alias)
}
1212041
func Import(c context.Context) error {
	cfg, err := fetch(c)
	if err != nil {
		return errors.Annotate(err, "failed to fetch configs").Err()
	}

	// Merge before validating. VMs may be invalid until referenced kinds are applied.
	if err := merge(c, cfg); err != nil {
		return errors.Annotate(err, "failed to merge kinds into configs").Err()
	}

	// Deref before validating. VMs may be invalid until metadata from file is imported.
	if err := deref(c, cfg); err != nil {
		return errors.Annotate(err, "failed to dereference files").Err()
	}

	if err := validate(c, cfg); err != nil {
		return errors.Annotate(err, "invalid configs").Err()
	}

	if err := normalize(c, cfg); err != nil {
		return errors.Annotate(err, "failed to normalize configs").Err()
	}

	if err := sync(c, cfg); err != nil {
		return errors.Annotate(err, "failed to synchronize configs").Err()
	}
	return nil
}
1160656
func Store(s storage.Store) func(r *Rego) {
	return func(r *Rego) {
		r.store = s
	}
}
1205541
func (s macStore) Import(data []byte, password string) error {
	cdata, err := bytesToCFData(data)
	if err != nil {
		return err
	}
	defer C.CFRelease(C.CFTypeRef(cdata))

	cpass := stringToCFString(password)
	defer C.CFRelease(C.CFTypeRef(cpass))

	cops := mapToCFDictionary(map[C.CFTypeRef]C.CFTypeRef{
		C.CFTypeRef(C.kSecImportExportPassphrase): C.CFTypeRef(cpass),
	})
	if cops == nilCFDictionaryRef {
		return errors.New("error creating CFDictionary")
	}
	defer C.CFRelease(C.CFTypeRef(cops))

	var cret C.CFArrayRef
	if err := osStatusError(C.SecPKCS12Import(cdata, cops, &cret)); err != nil {
		return err
	}
	defer C.CFRelease(C.CFTypeRef(cret))

	return nil
}
787906
func (s *GlobalStore) Import(r io.Reader) (n int, err error) {
	s.mu.Lock()
	defer s.mu.Unlock()

	tr := tar.NewReader(r)

	for {
		hdr, err := tr.Next()
		if err != nil {
			if err == io.EOF {
				break
			}
			return n, err
		}

		data, err := ioutil.ReadAll(tr)
		if err != nil {
			return n, err
		}

		var c mock.ExportedChunk
		if err = json.Unmarshal(data, &c); err != nil {
			return n, err
		}

		key := common.Hex2Bytes(hdr.Name)
		s.keyNodes[string(key)] = c.Addrs
		for _, addr := range c.Addrs {
			if i, has := s.nodeKeyIndex(addr, key); !has {
				s.nodeKeys[addr] = append(s.nodeKeys[addr], nil)
				copy(s.nodeKeys[addr][i+1:], s.nodeKeys[addr][i:])
				s.nodeKeys[addr][i] = key
			}
			if i, found := s.nodeIndex(addr); !found {
				s.nodes = append(s.nodes, addr)
				copy(s.nodes[i+1:], s.nodes[i:])
				s.nodes[i] = addr
			}
		}
		if i, found := s.keyIndex(key); !found {
			s.keys = append(s.keys, nil)
			copy(s.keys[i+1:], s.keys[i:])
			s.keys[i] = key
		}
		s.data[string(key)] = c.Data
		n++
	}
	return n, err
}
784216
func (a *API) ImportPath() string {
	return path.Join(a.BaseImportPath, a.PackageName())
}
715724
func Import(s *Snapshot) *Histogram {
	h := New(s.LowestTrackableValue, s.HighestTrackableValue, int(s.SignificantFigures))
	h.counts = s.Counts
	totalCount := int64(0)
	for i := int32(0); i < h.countsLen; i++ {
		countAtIndex := h.counts[i]
		if countAtIndex > 0 {
			totalCount += countAtIndex
		}
	}
	h.totalCount = totalCount
	return h
}
770146
func (l *LiteBackend) Imported(ctx context.Context) (imported bool, err error) {
	err = l.inTransaction(ctx, func(tx *sql.Tx) error {
		q, err := tx.PrepareContext(ctx,
			"SELECT imported from meta LIMIT 1")
		if err != nil {
			return trace.Wrap(err)
		}
		row := q.QueryRowContext(ctx)
		if err := row.Scan(&imported); err != nil {
			if err != sql.ErrNoRows {
				return trace.Wrap(err)
			}
		}
		return nil
	})
	return imported, err
}
1038320
func (o object) Imports() []string {
	ip := map[string]struct{}{}

	for _, f := range o.Fields {
		if name, ok := objectRegistered(f.Type); ok {
			ip[name] = struct{}{}
		}
		if f.Type == "Time" {
			ip["times"] = struct{}{}
		}
	}

	for _, p := range o.Parents {
		if name, ok := objectRegistered(p); ok {
			ip[name] = struct{}{}
		}
	}
	// del reference to our self
	if _, ok := ip[o.Name()]; ok {
		delete(ip, o.Name())
	}
	return commons.MapToSortedStrings(ip)
}
199180
func Imports(p []string) func(r *Rego) {
	return func(r *Rego) {
		r.imports = append(r.imports, p...)
	}
}
1302635
func (pkg *Package) Imports() map[string]bool {
	im := make(map[string]bool)
	for _, intf := range pkg.Interfaces {
		intf.addImports(im)
	}
	return im
}
419762
func (c *Client) Import(
	kind storage.StorageKind,
	storagePool string,
	storageProviderId string,
	storageName string,
) (names.StorageTag, error) {
	var results params.ImportStorageResults
	args := params.BulkImportStorageParams{
		[]params.ImportStorageParams{{
			StorageName: storageName,
			Kind:        params.StorageKind(kind),
			Pool:        storagePool,
			ProviderId:  storageProviderId,
		}},
	}
	if err := c.facade.FacadeCall("Import", args, &results); err != nil {
		return names.StorageTag{}, errors.Trace(err)
	}
	if len(results.Results) != 1 {
		return names.StorageTag{}, errors.Errorf(
			"expected 1 result, got %d",
			len(results.Results),
		)
	}
	if err := results.Results[0].Error; err != nil {
		return names.StorageTag{}, err
	}
	return names.ParseStorageTag(results.Results[0].Result.StorageTag)
}
1371877
func (d *Parallels9Driver) Import(name, srcPath, dstDir string, reassignMAC bool) error {
	err := d.Prlctl("register", srcPath, "--preserve-uuid")
	if err != nil {
		return err
	}

	srcID, err := getVMID(srcPath)
	if err != nil {
		return err
	}

	srcMAC := "auto"
	if !reassignMAC {
		srcMAC, err = getFirstMACAddress(srcPath)
		if err != nil {
			return err
		}
	}

	err = d.Prlctl("clone", srcID, "--name", name, "--dst", dstDir)
	if err != nil {
		return err
	}

	err = d.Prlctl("unregister", srcID)
	if err != nil {
		return err
	}

	err = d.Prlctl("set", name, "--device-set", "net0", "--mac", srcMAC)
	if err != nil {
		return err
	}
	return nil
}
270378
func (_class VMClass) Import(sessionID SessionRef, url string, sr SRRef, fullRestore bool, force bool) (_retval []VMRef, _err error) {
	_method := "VM.import"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_urlArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "url"), url)
	if _err != nil {
		return
	}
	_srArg, _err := convertSRRefToXen(fmt.Sprintf("%s(%s)", _method, "sr"), sr)
	if _err != nil {
		return
	}
	_fullRestoreArg, _err := convertBoolToXen(fmt.Sprintf("%s(%s)", _method, "full_restore"), fullRestore)
	if _err != nil {
		return
	}
	_forceArg, _err := convertBoolToXen(fmt.Sprintf("%s(%s)", _method, "force"), force)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _urlArg, _srArg, _fullRestoreArg, _forceArg)
	if _err != nil {
		return
	}
	_retval, _err = convertVMRefSetToGo(_method + " -> ", _result.Value)
	return
}
1019395
func (sd structDef) Imports() []string {
	ip := map[string]struct{}{}

	if sd.needFmt() {
		ip[`"fmt"`] = struct{}{}
	}
	if sd.OneLineDef == "" {
		ip[`"gopkg.in/validator.v2"`] = struct{}{}
	}

	// libraries
	for _, fd := range sd.Fields {
		if fd.fieldType == "json.RawMessage" {
			ip[`"encoding/json"`] = struct{}{}
		} else if lib := libImportPath(globRootImportPath, fd.fieldType, globLibRootURLs); lib != "" {
			ip[lib] = struct{}{}
		}
	}
	return commons.MapToSortedStrings(ip)
}
998394
func (p *Imports) Bind(opts libs.SassOptions) {
	entries := make([]libs.ImportEntry, p.Len())
	i := 0

	p.RLock()
	for _, ent := range p.m {
		bs := ent.bytes
		entries[i] = libs.ImportEntry{
			Parent: ent.Prev,
			Path:   ent.Path,
			Source: string(bs),
		}
		i++
	}
	p.RUnlock()

	resolver := func(url string, prev string) (newURL string, body string, resolved bool) {
		if p.resolver != nil {
			newURL, body, resolved = p.resolver(url, prev)
			if resolved {
				return
			}
		}
		entry, err := libs.GetEntry(entries, prev, url)
		if err == nil {
			return url, entry, true
		}
		return "", "", false
	}

	// set entries somewhere so GC doesn't collect it
	p.idx = libs.BindImporter(opts, resolver)
}