text:
SUMMARY = "Apache Thrift"
DESCRIPTION =  "A software framework, for scalable cross-language services development"
HOMEPAGE = "https://thrift.apache.org/"

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c40a383cb3f747e0c7abbf1482f194f0 \
                    file://NOTICE;md5=2659b43daca219f99a2f2626ea128f73"

DEPENDS = "thrift-native boost flex-native bison-native openssl zlib"

SRC_URI = "https://downloads.apache.org/${BPN}/${PV}/${BP}.tar.gz \
           file://0001-DefineInstallationPaths.cmake-Define-libdir-in-terms.patch"
SRC_URI[sha256sum] = "04c6f10e5d788ca78e13ee2ef0d2152c7b070c0af55483d6b942e29cff296726"

BBCLASSEXTEND = "native nativesdk"

CVE_PRODUCT = "apache:thrift"

inherit pkgconfig cmake python3native

export STAGING_INCDIR
export STAGING_LIBDIR
export BUILD_SYS
export HOST_SYS

EXTRA_OECMAKE = " \
    -DBUILD_LIBRARIES=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_COMPILER=ON \
    -DBUILD_TESTING=OFF \
    -DBUILD_TUTORIALS=OFF \
    -DWITH_AS3=OFF \
    -DWITH_CPP=ON \
    -DWITH_JAVA=OFF \
    -DWITH_OPENSSL=ON \
    -DWITH_QT5=OFF \
    -DWITH_ZLIB=ON \
"

PACKAGECONFIG ??= "glib libevent"
PACKAGECONFIG[glib] = "-DWITH_C_GLIB=ON,-DWITH_C_GLIB=OFF,glib-2.0"
PACKAGECONFIG[libevent] = "-DWITH_LIBEVENT=ON,-DWITH_LIBEVENT=OFF,libevent"
PACKAGECONFIG[javascript] = "-DWITH_JAVASCRIPT=ON,-DWITH_JAVASCRIPT=OFF,nodejs"
PACKAGECONFIG[nodejs] = "-DWITH_NODEJS=ON,-DWITH_NODEJS=OFF,nodejs"
PACKAGECONFIG[python] = "-DWITH_PYTHON=ON,-DWITH_PYTHON=OFF,python"

do_install:append () {
    ln -sf thrift ${D}/${bindir}/thrift-compiler
}

LEAD_SONAME = "libthrift.so.${PV}"

# thrift packages
PACKAGE_BEFORE_PN = "${PN}-compiler lib${BPN} lib${BPN}z lib${BPN}nb lib${BPN}-c-glib"
FILES:lib${BPN} = "${libdir}/libthrift.so.*"
FILES:lib${BPN}z = "${libdir}/libthriftz.so.*"
FILES:lib${BPN}nb = "${libdir}/libthriftnb.so.*"
FILES:lib${BPN}-c-glib = "${libdir}/libthrift_c_glib.so.*"
FILES:${PN}-compiler = "${bindir}/*"

# The thrift packages just pulls in some default dependencies but is otherwise empty
RRECOMMENDS:${PN} = "${PN}-compiler lib${BPN}"
ALLOW_EMPTY:${PN} = "1"
RRECOMMENDS:${PN}:class-native = ""
RRECOMMENDS:${PN}:class-nativesdk = ""

repository: openembedded/meta-openembedded

repo_name: openembedded/meta-openembedded

gha_language: BitBake


text:
package format_test

import (
	"bytes"
	"fmt"
	"io"
	"testing"

	"github.com/stretchr/testify/assert"

	"github.com/speedflow/speedflow/pkg/format"
)

func TestPrint(t *testing.T) {
	// Preparing test
	w := &bytes.Buffer{}
	v := struct {
		Message string `yaml:"message" json:"message"`
	}{
		Message: "Hello Hut!",
	}
	var c format.Callback = func(w io.Writer) {
		fmt.Fprintf(w, "%s", "I'm just the callback!")
	}

	// Test JSON
	format.Print(w, format.JSON, v, c)
	assert.Equal(t, w.String(), "{\"message\":\"Hello Hut!\"}")
	w.Reset()

	// Test YAML
	format.Print(w, format.YAML, v, c)
	assert.Equal(t, w.String(), "message: Hello Hut!\n")
	w.Reset()

	// Test UNKNOWN
	format.Print(w, format.CUSTOM, v, c)
	assert.Equal(t, w.String(), "I'm just the callback!")
	w.Reset()
}

func TestStringToFormat(t *testing.T) {
	assert.Equal(t, format.StringToFormat("yaml"), format.YAML)
	assert.Equal(t, format.StringToFormat("json"), format.JSON)
	assert.Equal(t, format.StringToFormat("breux"), format.CUSTOM)
}

license: MIT

repository: speedflow/speedflow

license_type: permissive

repo_name: speedflow/speedflow

branch_name: refs/heads/main

gha_license_id: MIT

gha_language: Ruby

extension: go


text:
DESCRIPTION = "Phone input method - shared headers"
SECTION = "gpephone"
PRIORITY = "optional"
LICENSE = "LiPS"
DEPENDS = "gtk+"

inherit gpephone pkgconfig autotools

SRC_URI = "${GPEPHONE_MIRROR}/ptim-headers-${PV}/imheaders-${PV}.tar.bz2"

S = "${WORKDIR}/imheaders-${PV}"

SRC_URI[md5sum] = "33226da8468acccdcac483ea25c99a91"
SRC_URI[sha256sum] = "255b3b869e3945f8b031e9fa23649f7e342211713335ea447e40975bfed96fa8"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD

extension: bb


text:
/*
Copyright 2016 The Fission Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"fmt"
	"os"
	"text/tabwriter"

	"github.com/urfave/cli"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

	"github.com/fission/fission"
	"github.com/fission/fission/tpr"
)

func envCreate(c *cli.Context) error {
	client := getClient(c.GlobalString("server"))

	envName := c.String("name")
	if len(envName) == 0 {
		fatal("Need a name, use --name.")
	}

	envImg := c.String("image")
	if len(envImg) == 0 {
		fatal("Need an image, use --image.")
	}

	envVersion := c.Int("version")
	envBuilderImg := c.String("builder")
	envBuildCmd := c.String("buildcmd")

	if len(envBuilderImg) > 0 {
		envVersion = 2
		if len(envBuildCmd) == 0 {
			envBuildCmd = "build"
		}
	}

	// Environment API interface version is not specified and
	// builder image is empty, set default interface version
	if envVersion == 0 {
		fmt.Println("Use default environment v1 API interface")
		envVersion = 1
	}

	env := &tpr.Environment{
		Metadata: metav1.ObjectMeta{
			Name:      envName,
			Namespace: metav1.NamespaceDefault,
		},
		Spec: fission.EnvironmentSpec{
			Version: envVersion,
			Runtime: fission.Runtime{
				Image: envImg,
			},
			Builder: fission.Builder{
				Image:   envBuilderImg,
				Command: envBuildCmd,
			},
		},
	}

	_, err := client.EnvironmentCreate(env)
	checkErr(err, "create environment")

	fmt.Printf("environment '%v' created\n", envName)
	return err
}

func envGet(c *cli.Context) error {
	client := getClient(c.GlobalString("server"))

	envName := c.String("name")
	if len(envName) == 0 {
		fatal("Need a name, use --name.")
	}

	m := &metav1.ObjectMeta{
		Name:      envName,
		Namespace: metav1.NamespaceDefault,
	}
	env, err := client.EnvironmentGet(m)
	checkErr(err, "get environment")

	w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
	fmt.Fprintf(w, "%v\t%v\t%v\n", "NAME", "UID", "IMAGE")
	fmt.Fprintf(w, "%v\t%v\t%v\n",
		env.Metadata.Name, env.Metadata.UID, env.Spec.Runtime.Image)
	w.Flush()
	return nil
}

func envUpdate(c *cli.Context) error {
	client := getClient(c.GlobalString("server"))

	envName := c.String("name")
	if len(envName) == 0 {
		fatal("Need a name, use --name.")
	}
	envImg := c.String("image")
	envBuilderImg := c.String("builder")
	envBuildCmd := c.String("buildcmd")

	if len(envImg) == 0 && len(envBuilderImg) == 0 && len(envBuildCmd) == 0 {
		fatal("Need --image to specify env image, or use --builder to specify env builder, or use --buildcmd to specify new build command.")
	}

	env, err := client.EnvironmentGet(&metav1.ObjectMeta{
		Name:      envName,
		Namespace: metav1.NamespaceDefault,
	})
	checkErr(err, "find environment")

	if len(envImg) > 0 {
		env.Spec.Runtime.Image = envImg
	}

	if env.Spec.Version == 1 && (len(envBuilderImg) > 0 || len(envBuildCmd) > 0) {
		fatal("Environment v1 API interface doesn't supported environment builder.")
	}

	if len(envBuilderImg) > 0 {
		env.Spec.Builder.Image = envBuilderImg
	}
	if len(envBuildCmd) > 0 {
		env.Spec.Builder.Command = envBuildCmd
	}

	_, err = client.EnvironmentUpdate(env)
	checkErr(err, "update environment")

	fmt.Printf("environment '%v' updated\n", envName)
	return nil
}

func envDelete(c *cli.Context) error {
	client := getClient(c.GlobalString("server"))

	envName := c.String("name")
	if len(envName) == 0 {
		fatal("Need a name , use --name.")
	}

	m := &metav1.ObjectMeta{
		Name:      envName,
		Namespace: metav1.NamespaceDefault,
	}
	err := client.EnvironmentDelete(m)
	checkErr(err, "delete environment")

	fmt.Printf("environment '%v' deleted\n", envName)
	return nil
}

func envList(c *cli.Context) error {
	client := getClient(c.GlobalString("server"))

	envs, err := client.EnvironmentList()
	checkErr(err, "list environments")

	w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
	fmt.Fprintf(w, "%v\t%v\t%v\n", "NAME", "UID", "IMAGE")
	for _, env := range envs {
		fmt.Fprintf(w, "%v\t%v\t%v\n",
			env.Metadata.Name, env.Metadata.UID, env.Spec.Runtime.Image)
	}
	w.Flush()

	return nil
}

branch_name: refs/heads/master


text:
@inproceedings{johnson2019nurture,
 author = {Johnson, Janet and Schmitz, Evan and Ramnath, Venktesh and Weibel, Nadir},
 booktitle = {Proceedings of the 13th EAI International Conference on Pervasive Computing Technologies for Healthcare},
 pages = {119--128},
 title = {Nurture-Empower-Support: A Human-Centered Approach to Understand and Support ICU Families},
 year = {2019}
}

repository: robinzhx/hxi-website

repo_name: robinzhx/hxi-website

extension: bib


text:
/*
 * Cadence - The resource-oriented smart contract programming language
 *
 * Copyright Dapper Labs, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package interpreter

import (
	"regexp"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestPrimitiveStaticTypeSemaTypeConversion(t *testing.T) {

	t.Parallel()

	placeholderTypePattern := regexp.MustCompile(`PrimitiveStaticType\(\d+\)`)

	test := func(ty PrimitiveStaticType) {
		t.Run(ty.String(), func(t *testing.T) {
			t.Parallel()

			semaType := ty.SemaType()
			ty2 := ConvertSemaToPrimitiveStaticType(nil, semaType)
			require.True(t, ty2.Equal(ty))
		})
	}

	for ty := PrimitiveStaticType(1); ty < PrimitiveStaticType_Count; ty++ {
		if placeholderTypePattern.MatchString(ty.String()) {
			continue
		}
		test(ty)
	}

}

repository: onflow/cadence

repo_name: onflow/cadence

gha_language: Go


text:
require macchina.io.inc

SRC_URI += "file://macchina-io \
            file://macchina.properties"

DEPENDS = "openssl macchina.io-hosttools-native poco"

do_configure () {
    # Nothing to configure
    :
}

export POCO_TARGET_OSNAME="Linux"
export POCO_TARGET_OSARCH="${TUNE_PKGARCH}"
export CROSS_COMPILE="${TARGET_PREFIX}"

# These are provided by macchina.io-hosttools-native
export BUNDLE_TOOL="bundle"
export PAGE_COMPILER="cpspc"

# Use system supplied POCO
export POCO_EXTERNAL="1"

# Does not work with cross compilation right now
#export V8_ENABLE_SNAPSHOT="1"

# There are race conditions with parallel make that leads to file not found errors
PARALLEL_MAKE = ""

do_compile () {
    #Needs to be set for the native bundler to find it's libraries
    export LD_LIBRARY_PATH="${STAGING_LIBDIR_NATIVE}"
    oe_runmake CC="${CC}" CLFAGS="-Isrc ${CFLAGS}" CXXFLAGS="-Isrc -DPOCO_TARGET_OSARCH=\"\\\"${POCO_TARGET_OSARCH}\\\"\" ${CXXFLAGS}" CXX="${CXX}" LINKFLAGS="${LDFLAGS}" DEFAULT_TARGET=shared_release
}

do_install () {
    install -d ${D}/opt/macchina
    oe_runmake install_runtime INSTALLDIR="${D}/opt/macchina"

    # Override configuration
    install -m 0644 ${WORKDIR}/macchina.properties ${D}/opt/macchina/etc/

    # Add wrapper
    install -d ${D}${bindir}
    install -m 0755 ${WORKDIR}/macchina-io ${D}${bindir}
}

FILES_${PN} += "/opt"

#TODO: Make macchina.io not strip the resulting libraries
INSANE_SKIP_${PN} = "already-stripped"

repository: macchina-io/meta-macchina-yocto

repo_name: macchina-io/meta-macchina-yocto


text:
SUMMARY = "NVIDIA container runtime library"

DESCRIPTION = "NVIDIA container runtime library \
The nvidia-container library provides an interface to configure GNU/Linux \
containers leveraging NVIDIA hardware. The implementation relies on several \
kernel subsystems and is designed to be agnostic of the container runtime. \
"
HOMEPAGE = "https://github.com/NVIDIA/libnvidia-container"

# Taken from meta-tegra at revision 92f1be3f98cff3362e0d3c2bc7b581e541c9412b

COMPATIBLE_MACHINE = "(tegra)"

DEPENDS = " \
    coreutils-native \
    pkgconfig-native \
    libcap \
    elfutils \
    libtirpc \
    ldconfig-native \
"
LICENSE = "BSD-3-Clause & GPLv3 & Proprietary"

LIC_FILES_CHKSUM = "\
    file://LICENSE;md5=06cff45c51018e430083a716510821b7 \
    file://COPYING;md5=1ebbd3e34237af26da5dc08a4e440464 \
    file://COPYING.LESSER;md5=3000208d539ec061b899bce1d9ce9404 \
"

PR = "r1"

NVIDIA_MODPROBE_VERSION = "396.51"
ELF_TOOLCHAIN_VERSION = "0.7.1"
LIBTIRPC_VERSION = "1.1.4"

SRC_URI = "git://github.com/NVIDIA/libnvidia-container.git;name=libnvidia;branch=jetson \
           git://github.com/NVIDIA/nvidia-modprobe.git;name=modprobe;branch=main;destsuffix=git/deps/src/nvidia-modprobe-${NVIDIA_MODPROBE_VERSION} \
           file://0001-Makefile-Fix-RCP-flags-and-change-path-definitions-s.patch \
           file://0002-common.mk-Set-JETSON-variable-if-not-set-before.patch \
           file://0003-Fix-mapping-of-library-paths-for-jetson-mounts.patch \
           "

SRC_URI[modprobe.md5sum] = "f82b649e7a0f1d1279264f9494e7cf43"
SRC_URI[modprobe.sha256sum] = "25bc6437a384be670e9fd76ac2e5b9753517e23eb16e7fa891b18537b70c4b20"

SRCREV_libnvidia = "09df17a2424704c1e4af310d3ce51fe475ba292a"
# Nvidia modprobe version 396.51
SRCREV_modprobe = "d97c08af5061f1516fb2e3a26508936f69d6d71d"

S = "${WORKDIR}/git"

PACKAGECONFIG ??= ""
PACKAGECONFIG[seccomp] = " WITH_SECCOMP=yes , WITH_SECCOMP=no ,libseccomp"

# We need to link with libelf, otherwise we need to
# include bmake-native which does not exist at the moment.
EXTRA_OEMAKE:append = " WITH_LIBELF=yes JETSON=TRUE ${PACKAGECONFIG_CONFARGS}"

CFLAGS:prepend = " -I=/usr/include/tirpc "

export OBJCPY="${OBJCOPY}"

# Fix me: Create an independent recipe for nvidia-modprobe
do_configure:append() {
    # Mark Nvidia modprobe as downloaded
    touch ${S}/deps/src/nvidia-modprobe-${NVIDIA_MODPROBE_VERSION}/.download_stamp
}

do_install () {
    oe_runmake install DESTDIR=${D}
}

INSANE_SKIP:${PN} = "already-stripped"

repository: balena-os/balena-jetson

repo_name: balena-os/balena-jetson


text:
DESCRIPTION = "pyRFC3339 parses and generates RFC 3339-compliant timestamps"
HOMEPAGE = "https://github.com/kurtraschke/pyRFC3339"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=91b3003300a14a301fc1efc878bcee51"

PYPI_PACKAGE = "pyRFC3339"

inherit pypi setuptools3

SRC_URI[md5sum] = "c829980738b8271b0179ffd0c41187b0"
SRC_URI[sha256sum] = "81b8cbe1519cdb79bed04910dd6fa4e181faf8c88dff1e1b987b5f7ab23a5b1a"

RDEPENDS:${PN} = "\
    python3-pytz \
"

repository: openavr/meta-openavr

repo_name: openavr/meta-openavr


text:
@inproceedings{langley00,
 author    = {P. Langley},
 title     = {Crafting Papers on Machine Learning},
 year      = {2000},
 pages     = {1207--1216},
 editor    = {Pat Langley},
 booktitle     = {Proceedings of the 17th International Conference
              on Machine Learning (ICML 2000)},
 address   = {Stanford, CA},
 publisher = {Morgan Kaufmann}
}

@TechReport{mitchell80,
  author = 	 "T. M. Mitchell",
  title = 	 "The Need for Biases in Learning Generalizations",
  institution =  "Computer Science Department, Rutgers University",
  year = 	 "1980",
  address =	 "New Brunswick, MA",
}

@phdthesis{kearns89,
  author = {M. J. Kearns},
  title =  {Computational Complexity of Machine Learning},
  school = {Department of Computer Science, Harvard University},
  year =   {1989}
}

@Book{MachineLearningI,
  editor = 	 "R. S. Michalski and J. G. Carbonell and T.
		  M. Mitchell",
  title = 	 "Machine Learning: An Artificial Intelligence
		  Approach, Vol. I",
  publisher = 	 "Tioga",
  year = 	 "1983",
  address =	 "Palo Alto, CA"
}

@Book{DudaHart2nd,
  author =       "R. O. Duda and P. E. Hart and D. G. Stork",
  title =        "Pattern Classification",
  publisher =    "John Wiley and Sons",
  edition =      "2nd",
  year =         "2000"
}

@misc{anonymous,
  title= {Suppressed for Anonymity},
  author= {Author, N. N.},
  year= {2019}
}

@InCollection{Newell81,
  author =       "A. Newell and P. S. Rosenbloom",
  title =        "Mechanisms of Skill Acquisition and the Law of
                  Practice",
  booktitle =    "Cognitive Skills and Their Acquisition",
  pages =        "1--51",
  publisher =    "Lawrence Erlbaum Associates, Inc.",
  year =         "1981",
  editor =       "J. R. Anderson",
  chapter =      "1",
  address =      "Hillsdale, NJ"
}

@Article{Samuel59,
  author = 	 "A. L. Samuel",
  title = 	 "Some Studies in Machine Learning Using the Game of
		  Checkers",
  journal =	 "IBM Journal of Research and Development",
  year =	 "1959",
  volume =	 "3",
  number =	 "3",
  pages =	 "211--229"
}

repository: davidstutz/latex-resources

repo_name: davidstutz/latex-resources

gha_language: TeX


text:
@article{stocker13natcc,
 author = {Stocker, Benjamin D. and Roth, Raphael and Joos, Fortunat and Spahni, Renato and Steinacher, Marco and Zaehle, Soenke and Bouwman, Lex and Xu-Ri, Xu-Ri and Prentice, Iain Colin},
 journal = {Nature Clim. Change},
 number = {7},
 pages = {666--672},
 title = {Multiple greenhouse-gas feedbacks from the land biosphere under future climate change scenarios},
 volume = {3},
 xexportby = {ris2bib},
 year = {2013}
}


text:
package handlers

import (
	"bytes"
	"io"
	"os"
	"regexp"
	"testing"
	"time"

	"github.com/influxdata/go-syslog/v2/rfc5424"
	"github.com/philips-software/go-hsdp-api/logging"
	"github.com/streadway/amqp"
	"github.com/stretchr/testify/assert"
)

type NilLogger struct {
}

func (n *NilLogger) Debugf(format string, args ...interface{}) {
	// Don't log anything
}

type NilStorer struct {
}

func (n *NilStorer) StoreResources(msgs []logging.Resource, count int) (*logging.Response, error) {
	return &logging.Response{}, nil
}

func TestProcessMessage(t *testing.T) {
	var payload = `Starting Application on 50676a99-dce0-418a-6b25-1e3d with PID 8 (/home/vcap/app/BOOT-INF/classes started by vcap in /home/vcap/app)`
	var appVersion = `1.0-f53a57a`
	var transactionID = `eea9f72c-09b6-4d56-905b-b518fc4dc5b7`

	var rawMessage = `<14>1 2018-09-07T15:39:21.132433+00:00 suite-phs.staging.msa-eustaging 7215cbaa-464d-4856-967c-fd839b0ff7b2 [APP/PROC/WEB/0] - - {"app":"msa-eustaging","val":{"message":"` + payload + `"},"ver":"` + appVersion + `","evt":null,"sev":"INFO","cmp":"CPH","trns":"` + transactionID + `","usr":null,"srv":"msa-eustaging.eu-west.philips-healthsuite.com","service":"msa","inst":"50676a99-dce0-418a-6b25-1e3d","cat":"Tracelog","time":"2018-09-07T15:39:21Z"}`

	var appName = `7215cbaa-464d-4856-967c-fd839b0ff7b2`
	var hostName = `suite-phs.staging.msa-eustaging`
	var nonDHPMessage = `<14>1 2018-09-07T15:39:18.517077+00:00 ` + hostName + ` ` + appName + ` [CELL/0] - - Starting health monitoring of container`

	parser := rfc5424.NewParser()

	phLogger, err := NewPHLogger(&NilStorer{}, &NilLogger{})
	assert.Nilf(t, err, "Expected NewPHLogger() to succeed")

	msg, err := parser.Parse([]byte(rawMessage))
	assert.Nilf(t, err, "Expected Parse() to succeed")

	resource, err := phLogger.processMessage(msg)
	assert.Nilf(t, err, "Expected processMessage() to succeed")
	assert.NotNilf(t, resource, "Proccessed resource should not be nil")
	assert.Equal(t, resource.ApplicationVersion, appVersion)
	assert.Equal(t, resource.TransactionID, transactionID)
	assert.Equal(t, resource.LogData.Message, payload)

	msg, err = parser.Parse([]byte(nonDHPMessage))

	assert.Nilf(t, err, "Expected Parse() to succeed")

	resource, err = phLogger.processMessage(msg)

	assert.Nilf(t, err, "Expected Parse() to succeed")

	assert.Equal(t, resource.LogTime, "2018-09-07T15:39:18.517Z")
	assert.Equal(t, resource.ApplicationName, appName)
	assert.Equal(t, resource.ServerName, hostName)
	assert.Equal(t, resource.LogData.Message, "Starting health monitoring of container")
}

type fakeAcknowledger struct {
	t *testing.T
}

func (a *fakeAcknowledger) Ack(tag uint64, multiple bool) error {
	return nil
}

func (a *fakeAcknowledger) Nack(tag uint64, multiple bool, requeue bool) error {
	return nil
}

func (a *fakeAcknowledger) Reject(tag uint64, requeue bool) error {
	return nil
}

func TestRFC5424Worker(t *testing.T) {
	done := make(chan bool)
	deliveries := make(chan amqp.Delivery)

	var payload = `Starting Application on 50676a99-dce0-418a-6b25-1e3d with PID 8 (/home/vcap/app/BOOT-INF/classes started by vcap in /home/vcap/app)`
	var appVersion = `1.0-f53a57a`
	var transactionID = `eea9f72c-09b6-4d56-905b-b518fc4dc5b7`
	var rawMessage = `<14>1 2018-09-07T15:39:21.132433+00:00 suite-phs.staging.msa-eustaging 7215cbaa-464d-4856-967c-fd839b0ff7b2 [APP/PROC/WEB/0] - - {"app":"msa-eustaging","val":{"message":"` + payload + `"},"ver":"` + appVersion + `","evt":null,"sev":"INFO","cmp":"CPH","trns":"` + transactionID + `","usr":null,"srv":"msa-eustaging.eu-west.philips-healthsuite.com","service":"msa","inst":"50676a99-dce0-418a-6b25-1e3d","cat":"Tracelog","time":"2018-09-07T15:39:21Z"}`

	old := os.Stdout
	r, w, _ := os.Pipe()
	os.Stdout = w

	phLogger, err := NewPHLogger(&NilStorer{}, &NilLogger{})
	assert.Nilf(t, err, "Expected NewPHLogger() to succeed")

	go phLogger.RFC5424Worker(deliveries, done)

	fa := &fakeAcknowledger{
		t: t,
	}

	delivery := amqp.Delivery{
		Body:         []byte(rawMessage),
		Acknowledger: fa,
	}
	for i := 0; i < 25; i++ {
		deliveries <- delivery
	}
	done <- true

	w.Close()
	os.Stdout = old

	var buf bytes.Buffer
	_, _ = io.Copy(&buf, r)

	assert.Regexp(t, regexp.MustCompile("Batch flushing 25 messages"), buf.String())
}

func TestWrapResource(t *testing.T) {
	var rtrLog = `<14>1 2019-04-12T19:34:43.530045+00:00 suite-xxx.staging.mps 042cbd0f-1a0e-4f77-ae39-a5c6c9fe2af9 [RTR/6] - - mps.domain.com - [2019-04-12T19:34:43.528+0000] "GET /test/bogus HTTP/1.1" 200 0 60 "-" "Not A Health Check" "10.10.66.246:48666" "10.10.17.45:61014" x_forwarded_for:"16.19.148.81, 10.10.66.246" x_forwarded_proto:"https" vcap_request_id:"77350158-4a69-47d6-731b-1bc0678db78d" response_time:0.001628089 app_id:"042cbd0f-1a0e-4f77-ae39-a5c6c9fe2af9" app_index:"0" x_b3_traceid:"6aa3915b88798203" x_b3_spanid:"6aa3915b88798203" x_b3_parentspanid:"-"`

	parser := rfc5424.NewParser()

	phLogger, err := NewPHLogger(&NilStorer{}, &NilLogger{})

	assert.Nilf(t, err, "Expected NewPHLogger() to succeed")

	msg, err := parser.Parse([]byte(rtrLog))
	assert.Nilf(t, err, "Expected Parse() to succeed")

	resource, err := phLogger.processMessage(msg)

	assert.Nilf(t, err, "Expected processMessage() to succeed")
	assert.Equal(t, resource.LogTime, "2019-04-12T19:34:43.528Z")
}

func TestDroppedMessages(t *testing.T) {
	done := make(chan bool)
	deliveries := make(chan amqp.Delivery)

	var consulLog = `<14>1 2019-04-12T19:34:43.530045+00:00 suite-xxx.staging.mps 042cbd0f-1a0e-4f77-ae39-a5c6c9fe2af9 [RTR/6] - - mps.domain.com - [2019-04-12T19:34:43.528+0000] "GET /test/bogus HTTP/1.1" 200 0 60 "-" "Consul Health Check" "10.10.66.246:48666" "10.10.17.45:61014" x_forwarded_for:"16.19.148.81, 10.10.66.246" x_forwarded_proto:"https" vcap_request_id:"77350158-4a69-47d6-731b-1bc0678db78d" response_time:0.001628089 app_id:"042cbd0f-1a0e-4f77-ae39-a5c6c9fe2af9" app_index:"0" x_b3_traceid:"6aa3915b88798203" x_b3_spanid:"6aa3915b88798203" x_b3_parentspanid:"-"`

	old := os.Stdout
	r, w, _ := os.Pipe()
	os.Stdout = w

	phLogger, err := NewPHLogger(&NilStorer{}, &NilLogger{})
	assert.Nilf(t, err, "Expected NewPHLogger() to succeed")

	go phLogger.RFC5424Worker(deliveries, done)

	fa := &fakeAcknowledger{
		t: t,
	}

	delivery := amqp.Delivery{
		Body:         []byte(consulLog),
		Acknowledger: fa,
	}
	for i := 0; i < 25; i++ {
		deliveries <- delivery
	}
	time.Sleep(1100 * time.Millisecond) // Wait for the flush to happen

	done <- true

	w.Close()
	os.Stdout = old

	var buf bytes.Buffer
	_, _ = io.Copy(&buf, r)

	assert.Regexp(t, regexp.MustCompile("Dropped 25 messages"), buf.String())
}

repository: ivd-git/logproxy

repo_name: ivd-git/logproxy


text:
SUMMARY = "Tools to create boot images for QCOM SoC"

HOMEPAGE = "https://www.codeaurora.org/cgit/quic/kernel/skales/"
SECTION = "devel"

LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://mkbootimg;beginline=3;endline=29;md5=114b84083e657f3886bfa2c1e5de7deb"

DEPENDS = "python dtc"

SRCREV = "6eac9e943de53c4aaaede3697e9226a47686fe25"
PV = "1.5.0+git${SRCPV}"

SRC_URI = "git://source.codeaurora.org/quic/kernel/skales;protocol=http"

S = "${WORKDIR}/git"

do_install () {
    install -d ${D}${bindir}/skales
    install -m 0755 ${S}/mkbootimg ${D}${bindir}/skales
    install -m 0755 ${S}/dtbTool ${D}${bindir}/skales
}

BBCLASSEXTEND = "native"


text:
package widget

import (
	"reflect"
	"time"

	"github.com/jinzhu/gorm"
	"github.com/mmanjoura/adsa-cms/admin"
	"github.com/mmanjoura/adsa-cms/qor"
	"github.com/mmanjoura/adsa-cms/qor/resource"
	"github.com/mmanjoura/adsa-cms/qor/utils"
	"github.com/mmanjoura/adsa-cms/roles"
	"github.com/mmanjoura/adsa-cms/serializable_meta"
)

type QorWidgetSettingInterface interface {
	GetWidgetName() string
	SetWidgetName(string)
	GetGroupName() string
	SetGroupName(string)
	GetScope() string
	SetScope(string)
	GetTemplate() string
	SetTemplate(string)
	serializable_meta.SerializableMetaInterface
}

// QorWidgetSetting default qor widget setting struct
type QorWidgetSetting struct {
	Name        string `gorm:"primary_key"`
	WidgetType  string `gorm:"primary_key"`
	Scope       string `gorm:"primary_key;default:'default'"`
	GroupName   string
	ActivatedAt *time.Time
	Template    string
	serializable_meta.SerializableMeta
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (widgetSetting *QorWidgetSetting) ResourceName() string {
	return "Widget Content"
}

func (widgetSetting *QorWidgetSetting) BeforeCreate() {
	now := time.Now()
	widgetSetting.ActivatedAt = &now
}

func (widgetSetting *QorWidgetSetting) BeforeUpdate(scope *gorm.Scope) error {
	value := reflect.New(scope.GetModelStruct().ModelType).Interface()
	return scope.NewDB().Model(value).Where("name = ? AND scope = ?", widgetSetting.Name, widgetSetting.Scope).UpdateColumn("activated_at", gorm.Expr("NULL")).Error
}

func (widgetSetting *QorWidgetSetting) GetSerializableArgumentKind() string {
	if widgetSetting.WidgetType != "" {
		return widgetSetting.WidgetType
	}
	return widgetSetting.Kind
}

func (widgetSetting *QorWidgetSetting) SetSerializableArgumentKind(name string) {
	widgetSetting.WidgetType = name
	widgetSetting.Kind = name
}

// GetWidgetName get widget setting's group name
func (qorWidgetSetting QorWidgetSetting) GetWidgetName() string {
	return qorWidgetSetting.Name
}

// SetWidgetName set widget setting's group name
func (qorWidgetSetting *QorWidgetSetting) SetWidgetName(name string) {
	qorWidgetSetting.Name = name
}

// GetGroupName get widget setting's group name
func (qorWidgetSetting QorWidgetSetting) GetGroupName() string {
	return qorWidgetSetting.GroupName
}

// SetGroupName set widget setting's group name
func (qorWidgetSetting *QorWidgetSetting) SetGroupName(groupName string) {
	qorWidgetSetting.GroupName = groupName
}

// GetScope get widget's scope
func (qorWidgetSetting QorWidgetSetting) GetScope() string {
	return qorWidgetSetting.Scope
}

// SetScope set widget setting's scope
func (qorWidgetSetting *QorWidgetSetting) SetScope(scope string) {
	qorWidgetSetting.Scope = scope
}

// GetTemplate get used widget template
func (qorWidgetSetting QorWidgetSetting) GetTemplate() string {
	if widget := GetWidget(qorWidgetSetting.GetSerializableArgumentKind()); widget != nil {
		for _, value := range widget.Templates {
			if value == qorWidgetSetting.Template {
				return value
			}
		}

		// return first value of defined widget templates
		for _, value := range widget.Templates {
			return value
		}
	}
	return ""
}

// SetTemplate set used widget's template
func (qorWidgetSetting *QorWidgetSetting) SetTemplate(template string) {
	qorWidgetSetting.Template = template
}

// GetSerializableArgumentResource get setting's argument's resource
func (qorWidgetSetting *QorWidgetSetting) GetSerializableArgumentResource() *admin.Resource {
	widget := GetWidget(qorWidgetSetting.GetSerializableArgumentKind())
	if widget != nil {
		return widget.Setting
	}
	return nil
}

// ConfigureQorResource a method used to config Widget for qor admin
func (qorWidgetSetting *QorWidgetSetting) ConfigureQorResource(res resource.Resourcer) {
	if res, ok := res.(*admin.Resource); ok {
		res.Meta(&admin.Meta{Name: "Name", Permission: roles.Deny(roles.Update, roles.Anyone)})

		res.Meta(&admin.Meta{
			Name: "ActivatedAt",
			Type: "hidden",
			Valuer: func(result interface{}, context *qor.Context) interface{} {
				return time.Now()
			},
		})

		res.Meta(&admin.Meta{
			Name: "Scope",
			Type: "hidden",
			Valuer: func(result interface{}, context *qor.Context) interface{} {
				if scope := context.Request.URL.Query().Get("widget_scope"); scope != "" {
					return scope
				}

				if setting, ok := result.(QorWidgetSettingInterface); ok {
					if scope := setting.GetScope(); scope != "" {
						return scope
					}
				}

				return "default"
			},
			Setter: func(result interface{}, metaValue *resource.MetaValue, context *qor.Context) {
				if setting, ok := result.(QorWidgetSettingInterface); ok {
					setting.SetScope(utils.ToString(metaValue.Value))
				}
			},
		})

		res.Meta(&admin.Meta{
			Name: "Widgets",
			Type: "select_one",
			Valuer: func(result interface{}, context *qor.Context) interface{} {
				if typ := context.Request.URL.Query().Get("widget_type"); typ != "" {
					return typ
				}

				if setting, ok := result.(QorWidgetSettingInterface); ok {
					return GetWidget(setting.GetSerializableArgumentKind()).Name
				}

				return ""
			},
			Collection: func(result interface{}, context *qor.Context) (results [][]string) {
				if setting, ok := result.(QorWidgetSettingInterface); ok {
					groupName := setting.GetGroupName()
					for _, group := range registeredWidgetsGroup {
						if group.Name == groupName {
							for _, widget := range group.Widgets {
								results = append(results, []string{widget, widget})
							}
						}
					}

					if len(results) == 0 {
						results = append(results, []string{setting.GetSerializableArgumentKind(), setting.GetSerializableArgumentKind()})
					}
				}
				return
			},
			Setter: func(result interface{}, metaValue *resource.MetaValue, context *qor.Context) {
				if setting, ok := result.(QorWidgetSettingInterface); ok {
					setting.SetSerializableArgumentKind(utils.ToString(metaValue.Value))
				}
			},
		})

		res.Meta(&admin.Meta{
			Name: "Template",
			Type: "select_one",
			Valuer: func(result interface{}, context *qor.Context) interface{} {
				if setting, ok := result.(QorWidgetSettingInterface); ok {
					return setting.GetTemplate()
				}
				return ""
			},
			Collection: func(result interface{}, context *qor.Context) (results [][]string) {
				if setting, ok := result.(QorWidgetSettingInterface); ok {
					if widget := GetWidget(setting.GetSerializableArgumentKind()); widget != nil {
						for _, value := range widget.Templates {
							results = append(results, []string{value, value})
						}
					}
				}
				return
			},
			Setter: func(result interface{}, metaValue *resource.MetaValue, context *qor.Context) {
				if setting, ok := result.(QorWidgetSettingInterface); ok {
					setting.SetTemplate(utils.ToString(metaValue.Value))
				}
			},
		})

		res.UseTheme("widget")

		res.IndexAttrs("Name", "CreatedAt", "UpdatedAt")
		res.ShowAttrs("Name", "Scope", "WidgetType", "Template", "Value", "CreatedAt", "UpdatedAt")
		res.EditAttrs(
			"Scope", "ActivatedAt", "Widgets", "Template",
			&admin.Section{
				Title: "Settings",
				Rows:  [][]string{{"Kind"}, {"SerializableMeta"}},
			},
		)
	}
}

repository: mmanjoura/adsa-cms

repo_name: mmanjoura/adsa-cms


text:
SUMMARY = "Phosphor DBus Interfaces"
DESCRIPTION = "Generated bindings, using sdbus++, for the phosphor YAML"
PR = "r1"

S = "${WORKDIR}/git"

inherit autotools pkgconfig
inherit obmc-phosphor-license
inherit pythonnative

DEPENDS += "autoconf-archive-native"
DEPENDS += "sdbusplus sdbus++-native"

RDEPENDS_${PN} += "libsystemd"

SRC_URI += "git://github.com/openbmc/phosphor-dbus-interfaces"
SRCREV = "5d4f2379695f7c28549b107f325e0b0cd43d83b1"


text:
package cache

import (
	"errors"
	"fmt"

	"github.com/containerd/containerd/reference"
	"github.com/google/go-containerregistry/pkg/v1"
	"github.com/google/go-containerregistry/pkg/v1/partial"
	"github.com/google/go-containerregistry/pkg/v1/validate"
	lktspec "github.com/linuxkit/linuxkit/src/cmd/linuxkit/spec"
)

// ValidateImage given a reference, validate that it is complete. If not, pull down missing
// components as necessary. It also calculates the hash of each component.
func (p *Provider) ValidateImage(ref *reference.Spec, architecture string) (lktspec.ImageSource, error) {
	var (
		imageIndex v1.ImageIndex
		image      v1.Image
		imageName  = ref.String()
		desc       *v1.Descriptor
	)
	// next try the local cache
	root, err := p.FindRoot(imageName)
	if err == nil {
		img, err := root.Image()
		if err == nil {
			image = img
			if desc, err = partial.Descriptor(img); err != nil {
				return ImageSource{}, errors.New("image could not create valid descriptor")
			}
		} else {
			ii, err := root.ImageIndex()
			if err == nil {
				imageIndex = ii
				if desc, err = partial.Descriptor(ii); err != nil {
					return ImageSource{}, errors.New("index could not create valid descriptor")
				}
			}
		}
	}
	// three possibilities now:
	// - we did not find anything locally
	// - we found an index locally
	// - we found an image locally
	switch {
	case imageIndex == nil && image == nil:
		// we did not find it yet - either because we were told not to look locally,
		// or because it was not available - so get it from the remote
		return ImageSource{}, errors.New("no such image")
	case imageIndex != nil:
		// check that the index has a manifest for our arch
		im, err := imageIndex.IndexManifest()
		if err != nil {
			return ImageSource{}, fmt.Errorf("could not get index manifest: %v", err)
		}
		for _, m := range im.Manifests {
			if m.Platform != nil && m.Platform.Architecture == architecture && m.Platform.OS == linux {
				img, err := imageIndex.Image(m.Digest)
				if err != nil {
					return ImageSource{}, fmt.Errorf("unable to get image: %v", err)
				}
				if err := validate.Image(img); err != nil {
					return ImageSource{}, fmt.Errorf("invalid image: %s", err)
				}
				return p.NewSource(
					ref,
					architecture,
					desc,
				), nil
			}
		}
		return ImageSource{}, fmt.Errorf("index for %s did not contain image for platform linux/%s", imageName, architecture)
	case image != nil:
		// we found a local image, make sure it is up to date, and that it matches our platform
		if err := validate.Image(image); err != nil {
			return ImageSource{}, fmt.Errorf("invalid image, %s", err)
		}
		return p.NewSource(
			ref,
			architecture,
			desc,
		), nil
	}
	// if we made it to here, we had some strange error
	return ImageSource{}, errors.New("should not have reached this point, image index and image were both empty and not-empty")
}

repository: linuxkit/linuxkit

repo_name: linuxkit/linuxkit


text:
require ${PN}.inc

PR = "r1"

SRC_URI = "http://sources.openembedded.org/opie-1.2.4-split_core_pim_today_plugins_datebook.tar.bz2;name=split_core_pim_today_plugins_datebook"
SRC_URI[split_core_pim_today_plugins_datebook.md5sum] = "65d7a6d6c25a2d8dd6b1f99105a2f561"
SRC_URI[split_core_pim_today_plugins_datebook.sha256sum] = "a44d36525cee0a1adde02a14ed5c25bec4d46d85ef9819e0650fb1a15e20a77f"


text:
SUMMARY = "Utility to test spidev in a loopback configuration"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"

SRCREV = "cc1deb3c947ddc04966805b7ebff45ada4f2535c"
SRC_URI = "git://github.com/scottellis/spiloop.git"

S = "${WORKDIR}/git"

TARGET_CC_ARCH += "${LDFLAGS}"

do_install() {
    install -d ${D}${bindir}
    install -m 755 spiloop ${D}${bindir}
}

FILES_${PN} = "${bindir}"

repository: BlackZork/meta-rpi

repo_name: BlackZork/meta-rpi


text:
// disk6239.go

// Copyright (C) 2018,2019 Steve Merrony

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// Here we are emulating the disk6239 device, specifically model 6239/6240
// controller/drive combination with 14-inch platters which provide 592MB of formatted capacity.
//
// All communication with the drive is via CPU PIO instructions and memory
// accessed via the BMC interface running at 2.2MB/sec in mapped or physical mode.
// There is also a small set of flags and pulses shared between the controller and the CPU.

// ASYNCHRONOUS interrupts occur on completion of a CB (list), or when an error
// occurs during CB processing.

// SYNCHRONOUS interrupts occur after a PIO command executes.

// N.B. Assembler mnemonic: DSKP, AOS/VS mnemonic: DPJ

package devices

import (
	"bufio"
	"log"
	"os"
	"sync"
	"time"

	"github.com/SMerrony/dgemug/dg"
	"github.com/SMerrony/dgemug/logging"
	"github.com/SMerrony/dgemug/memory"
)

const (
	// Physical disk characteristics
	disk6239SurfacesPerDisk   = 8
	disk6239HeadsPerSurface   = 2
	disk6239SectorsPerTrack   = 75
	disk6239WordsPerSector    = 256
	disk6239BytesPerSector    = disk6239WordsPerSector * 2
	disk6239PhysicalCylinders = 981
	disk6239UserCylinders     = 978
	disk6239LogicalBlocks     = 1157952 // ??? 1147943 17<<16 | 43840
	disk6239LogicalBlocksH    = disk6239LogicalBlocks >> 16
	disk6239LogicalBlocksL    = disk6239LogicalBlocks & 0x0ffff
	disk6239UcodeRev          = 99

	disk6239MaxQueuedCBs = 30 // See p.2-13

	disk6239IntInfBlkSize   = 8
	disk6239CtrlrInfBlkSize = 2
	disk6239UnitInfBlkSize  = 7
	disk6239CbMaxSize       = 21
	disk6239CbMinSize       = 10 //12 // Was 10

	disk6239AsynchStatRetryInterval = time.Millisecond

	statXecStateResetting = 0x00
	statXecStateResetDone = 0x01
	statXecStateBegun     = 0x08
	statXecStateMapped    = 0x0c
	statXecStateDiagMode  = 0x04

	statCcsAsync        = 0
	statCcsPioInvCmd    = 1
	statCcsPioCmdFailed = 2
	statCcsPioCmdOk     = 3

	statAsyncNoErrors = 5

	// disk6239 PIO Command Set
	disk6239PioProgLoad        = 000
	disk6239PioBegin           = 002
	disk6239PioSysgen          = 025
	disk6239DiagMode           = 024
	disk6239SetMapping         = 026
	disk6239GetMapping         = 027
	disk6239SetInterface       = 030
	disk6239GetInterface       = 031
	disk6239SetController      = 032
	disk6239GetController      = 033
	disk6239SetUnit            = 034
	disk6239GetUnit            = 035
	disk6239GetExtendedStatus0 = 040
	disk6239GetExtendedStatus1 = 041
	disk6239GetExtendedStatus2 = 042
	disk6239GetExtendedStatus3 = 043
	disk6239StartList          = 0100
	disk6239StartListHp        = 0103
	disk6239Restart            = 0116
	disk6239CancelList         = 0123
	disk6239UnitStatus         = 0131
	disk6239Trespass           = 0132
	disk6239GetListStatus      = 0133
	disk6239PioReset           = 0777

	// disk6239 CB Command Set/OpCodes
	disk6239CbOpNoOp             = 0
	disk6239CbOpWrite            = 0100
	disk6239CbOpWriteVerify      = 0101
	disk6239CbOpWrite1Word       = 0104
	disk6239CbOpWriteVerify1Word = 0105
	disk6239CbOpWriteModBitmap   = 0142
	disk6239CbOpRead             = 0200
	disk6239CbOpReadVerify       = 0201
	disk6239CbOpReadVerify1Word  = 0205
	disk6239CbOpReadRawData      = 0210
	disk6239CbOpReadHeaders      = 0220
	disk6239CbOpReadModBitmap    = 0242
	disk6239CbOpRecalibrateDisk  = 0400

	// disk6239 CB FIELDS
	disk6239CbLinkAddrHigh       = 0
	disk6239CbLinkAddrLow        = 1
	disk6239CbInaFlagsOpcode     = 2
	disk6239CbPagenoListAddrHigh = 3
	disk6239CbPagenoListAddrLow  = 4
	disk6239CbTxferAddrHigh      = 5
	disk6239CbTxferAddrLow       = 6
	disk6239CbDevAddrHigh        = 7
	disk6239CbDevAddrLow         = 8
	disk6239CbUnitNo             = 9
	disk6239CbTxferCount         = 10
	disk6239CbCbStatus           = 11
	disk6239CbRes1               = 12
	disk6239CbRes2               = 13
	disk6239CbErrStatus          = 14
	disk6239CbUnitStatus         = 15
	disk6239CbRetriesDone        = 16
	disk6239CbSoftRtnTxferCount  = 17
	disk6239CbPhysCyl            = 18
	disk6239CbPhysHeadSect       = 19
	disk6239CbDiskErrCode        = 20

	// Mapping bits
	disk6239MapSlotLoadInts = 1 << 15
	disk6239MapIntBmcPhys   = 1 << 14
	disk6239MapUpstreamLoad = 1 << 13
	disk6239MapUpstreamHpt  = 1 << 12

	// calculated consts
	// disk6239PhysicalByteSize is the total  # bytes on a disk6239-type disk
	disk6239PhysicalByteSize = disk6239SurfacesPerDisk * disk6239HeadsPerSurface * disk6239SectorsPerTrack * disk6239BytesPerSector * disk6239PhysicalCylinders
	// disk6239PhysicalBlockSize is the total # blocks on a disk6239-type disk
	disk6239PhysicalBlockSize = disk6239SurfacesPerDisk * disk6239HeadsPerSurface * disk6239SectorsPerTrack * disk6239PhysicalCylinders
)

// Disk6239DataT holds the current state of a Type 6239 Disk
type Disk6239DataT struct {
	// MV/Em internals...
	disk6239DataMu      sync.RWMutex
	bus                 *BusT
	devNum              int
	imageAttached       bool
	imageFileName       string
	imageFile           *os.File
	reads, writes       uint64
	logID               int
	debugLogging        bool
	cbChan              chan dg.PhysAddrT
	activeCB            [disk6239CbMaxSize]dg.WordT
	readBuff, writeBuff []byte
	// DG data...
	commandRegA, commandRegB, commandRegC dg.WordT
	statusRegA, statusRegB, statusRegC    dg.WordT
	isMapped                              bool
	mappingRegA, mappingRegB              dg.WordT
	intInfBlock                           [disk6239IntInfBlkSize]dg.WordT
	ctrlInfBlock                          [disk6239CtrlrInfBlkSize]dg.WordT
	unitInfBlock                          [disk6239UnitInfBlkSize]dg.WordT
	// cylinder, head, sector                dg_word
	sectorNo dg.DwordT
}

const disk6239StatsPeriodMs = 500 // Will send status update this often

// Disk6239StatT holds the near real-time status for this device
type Disk6239StatT struct {
	ImageAttached                      bool
	StatusRegA, StatusRegB, StatusRegC dg.WordT
	//	cylinder, head, sector             dg_word
	SectorNo      dg.DwordT
	Reads, Writes uint64
}

// Disk6239Init is called once by the main routine to initialise this disk6239 emulator
func (disk *Disk6239DataT) Disk6239Init(dev int, bus *BusT, statsChann chan Disk6239StatT, logID int, logging bool) {
	disk.disk6239DataMu.Lock()
	disk.devNum = dev
	disk.bus = bus
	disk.readBuff = make([]byte, disk6239BytesPerSector)
	disk.writeBuff = make([]byte, disk6239BytesPerSector)

	go disk.disk6239StatSender(statsChann)

	bus.SetResetFunc(disk.devNum, disk.disk6239Reset)
	bus.SetDataInFunc(disk.devNum, disk.disk6239DataIn)
	bus.SetDataOutFunc(disk.devNum, disk.disk6239DataOut)

	disk.logID = logID
	disk.debugLogging = logging
	disk.imageAttached = false
	disk.cbChan = make(chan dg.PhysAddrT, disk6239MaxQueuedCBs)
	disk.disk6239DataMu.Unlock()

	go disk.disk6239CBprocessor()

	disk.disk6239Reset()
}

// Disk6239Attach attempts to attach an extant MV/Em disk image to the running emulator
func (disk *Disk6239DataT) Disk6239Attach(dNum int, imgName string) bool {
	// TODO Disk Number not currently used
	var err error
	logging.DebugPrint(disk.logID, "disk6239Attach called for disk #%d with image <%s>\n", dNum, imgName)

	disk.disk6239DataMu.Lock()

	disk.imageFile, err = os.OpenFile(imgName, os.O_RDWR, 0755)
	if err != nil {
		logging.DebugPrint(disk.logID, "Failed to open image for attaching\n")
		logging.DebugPrint(logging.DebugLog, "WARN: Failed to open disk6239 image <%s> for ATTach\n", imgName)
		return false
	}
	disk.imageFileName = imgName
	disk.imageAttached = true

	disk.disk6239DataMu.Unlock()

	disk.bus.SetAttached(disk.devNum, imgName)
	return true
}

// disk6239StatSender provides a near real-time view of the disk6239 status and should be run as a Goroutine
func (disk *Disk6239DataT) disk6239StatSender(sChan chan Disk6239StatT) {
	var stats Disk6239StatT
	logging.DebugPrint(logging.DebugLog, "disk6239StatSender() started\n")
	for {
		disk.disk6239DataMu.RLock()
		if disk.imageAttached {
			stats.ImageAttached = true
			//stats.cylinder = disk.cylinder
			//stats.head = disk.head
			//stats.sector = disk.sector
			stats.StatusRegA = disk.statusRegA
			stats.StatusRegB = disk.statusRegB
			stats.StatusRegC = disk.statusRegC
			stats.SectorNo = disk.sectorNo
			stats.Reads = disk.reads
			stats.Writes = disk.writes
		} else {
			stats = Disk6239StatT{}
		}
		disk.disk6239DataMu.RUnlock()
		// Non-blocking send of stats
		select {
		case sChan <- stats:
		default:
		}
		time.Sleep(time.Millisecond * disk6239StatsPeriodMs)
	}
}

// Disk6239CreateBlank - Create an empty disk file of the correct size for the disk6239 emulator to use
func (disk *Disk6239DataT) Disk6239CreateBlank(imgName string) bool {
	newFile, err := os.Create(imgName)
	if err != nil {
		return false
	}
	defer newFile.Close()
	logging.DebugPrint(disk.logID, "disk6239CreateBlank attempting to write %d bytes\n", disk6239PhysicalByteSize)
	w := bufio.NewWriter(newFile)
	for b := 0; b < disk6239PhysicalByteSize; b++ {
		w.WriteByte(0)
	}
	w.Flush()
	return true
}

// Disk6239LoadDKBT fakes a system ROM routine to boot from this disk.
func (disk *Disk6239DataT) Disk6239LoadDKBT() {
	logging.DebugPrint(disk.logID, "Disk6239LoadDKBT() called\n")
	disk.disk6239Reset()
	//disk.disk6239DoPioCommand() // In a reset state this will cause disk6239PioProgLoad to happen
	disk.disk6239ProgLoad()
	logging.DebugPrint(disk.logID, "Disk6239LoadDKBT() completed\n")
}

// Handle the DIA/B/C PIO commands
func (disk *Disk6239DataT) disk6239DataIn(abc byte, flag byte) (datum dg.WordT) {
	disk.disk6239DataMu.Lock()
	switch abc {
	case 'A':
		datum = disk.statusRegA
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "DIA [Read Status A] returning %s for DRV=%d\n", memory.WordToBinStr(disk.statusRegA), 0)
		}
	case 'B':
		datum = disk.statusRegB
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "DIB [Read Status B] returning %s for DRV=%d\n", memory.WordToBinStr(disk.statusRegB), 0)
		}
	case 'C':
		datum = disk.statusRegC
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "DIC [Read Status C] returning %s for DRV=%d\n", memory.WordToBinStr(disk.statusRegC), 0)
		}
	}
	disk.disk6239DataMu.Unlock()
	disk.disk6239HandleFlag(flag)
	return datum
}

// Handle the DOA/B/C PIO commands
func (disk *Disk6239DataT) disk6239DataOut(datum dg.WordT, abc byte, flag byte) {
	if disk.debugLogging {
		logging.DebugPrint(disk.logID, "DO%c\n", abc)
	}
	disk.disk6239DataMu.Lock()
	switch abc {
	case 'A':
		disk.commandRegA = datum
	case 'B':
		disk.commandRegB = datum
	case 'C':
		disk.commandRegC = datum
	}
	disk.disk6239DataMu.Unlock()
	disk.disk6239HandleFlag(flag)
}

func (disk *Disk6239DataT) disk6239ProgLoad() {
	if disk.debugLogging {
		logging.DebugPrint(disk.logID, "PROGRAM LOAD initiated\n")
	}
	readBuff := make([]byte, disk6239BytesPerSector)
	disk.imageFile.Read(readBuff)
	addr := dg.PhysAddrT(0)
	for w := 0; w < disk6239WordsPerSector; w++ {
		tmpWd := dg.WordT(readBuff[w*2]) | (dg.WordT(readBuff[(w*2)+1]) << 8)
		memory.WriteWordBmcChan(&addr, tmpWd)
	}
	if disk.debugLogging {
		logging.DebugPrint(disk.logID, "PROGRAM LOAD completed\n")
	}
}

func (disk *Disk6239DataT) disk6239DoPioCommand() {

	var addr, w dg.PhysAddrT

	disk.disk6239DataMu.Lock()

	pioCmd := disk.disk6239ExtractPioCommand(disk.commandRegC)
	switch pioCmd {
	case disk6239PioProgLoad:
		disk.disk6239ProgLoad()

	case disk6239PioBegin:
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... BEGIN command, unit # %d\n", disk.commandRegA)
		}
		// pretend we have succesfully booted ourself
		disk.statusRegB = 0
		disk.disk6239SetPioStatusRegC(statXecStateBegun, statCcsPioCmdOk, disk6239PioBegin, memory.TestWbit(disk.commandRegC, 15))

	case disk6239GetMapping:
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... GET MAPPING command\n")
		}
		disk.statusRegA = disk.mappingRegA
		disk.statusRegB = disk.mappingRegB
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... ... Status Reg A set to %s\n", memory.WordToBinStr(disk.statusRegA))
			logging.DebugPrint(disk.logID, "... ... Status Reg B set to %s\n", memory.WordToBinStr(disk.statusRegB))
		}
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239GetMapping, memory.TestWbit(disk.commandRegC, 15))

	case disk6239SetMapping:
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... SET MAPPING command\n")
		}
		disk.mappingRegA = disk.commandRegA
		disk.mappingRegB = disk.commandRegB
		disk.isMapped = true
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... ... Mapping Reg A set to %s\n", memory.WordToBinStr(disk.commandRegA))
			logging.DebugPrint(disk.logID, "... ... Mapping Reg B set to %s\n", memory.WordToBinStr(disk.commandRegB))
		}
		disk.disk6239SetPioStatusRegC(statXecStateMapped, statCcsPioCmdOk, disk6239SetMapping, memory.TestWbit(disk.commandRegC, 15))

	case disk6239GetInterface:
		addr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.commandRegA, disk.commandRegB))
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... GET INTERFACE INFO command\n")
			logging.DebugPrint(disk.logID, "... ... Destination Start Address: %d\n", addr)
		}
		for w = 0; w < disk6239IntInfBlkSize; w++ {
			memory.WriteWordBmcChan(&addr, disk.intInfBlock[w])
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "... ... Word %d: %s\n", w, memory.WordToBinStr(disk.intInfBlock[w]))
			}
		}
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239GetInterface, memory.TestWbit(disk.commandRegC, 15))

	case disk6239SetInterface:
		addr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.commandRegA, disk.commandRegB))
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... SET INTERFACE INFO command\n")
			logging.DebugPrint(disk.logID, "... ... Origin Start Address: %d\n", addr)
		}
		// only a few fields can be changed...
		addr += 5
		disk.intInfBlock[w] = memory.ReadWordBmcChan(&addr) // word 5
		disk.intInfBlock[w] &= 0xff00
		disk.intInfBlock[w] = memory.ReadWordBmcChan(&addr) // word 6
		disk.intInfBlock[w] = memory.ReadWordBmcChan(&addr) // word 7
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... ... Word 5: %s\n", memory.WordToBinStr(disk.intInfBlock[5]))
			logging.DebugPrint(disk.logID, "... ... Word 6: %s\n", memory.WordToBinStr(disk.intInfBlock[6]))
			logging.DebugPrint(disk.logID, "... ... Word 7: %s\n", memory.WordToBinStr(disk.intInfBlock[7]))
		}
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239SetInterface, memory.TestWbit(disk.commandRegC, 15))

	case disk6239GetUnit:
		addr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.commandRegA, disk.commandRegB))
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... GET UNIT INFO command\n")
			logging.DebugPrint(disk.logID, "... ... Destination Start Address: %d\n", addr)
		}
		for w = 0; w < disk6239UnitInfBlkSize; w++ {
			memory.WriteWordBmcChan(&addr, disk.unitInfBlock[w])
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "... ... Word %d: %s\n", w, memory.WordToBinStr(disk.unitInfBlock[w]))
			}
		}
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239GetUnit, memory.TestWbit(disk.commandRegC, 15))

	case disk6239SetUnit:
		addr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.commandRegA, disk.commandRegB))
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... SET UNIT INFO command\n")
			logging.DebugPrint(disk.logID, "... ... Origin Start Address: %d\n", addr)
		}
		// only the first word is writable according to p.2-16
		// TODO check no active CBs first
		disk.unitInfBlock[0] = memory.ReadWord(addr)
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... ... Overwrote word 0 of UIB with: %s\n", memory.WordToBinStr(disk.unitInfBlock[0]))
		}
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239SetUnit, memory.TestWbit(disk.commandRegC, 15))

	case disk6239PioReset:
		// disk6239Reset() has to do its own locking...
		disk.disk6239DataMu.Unlock()
		disk.disk6239Reset()
		disk.disk6239DataMu.Lock()

	case disk6239SetController:
		addr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.commandRegA, disk.commandRegB))
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... SET CONTROLLER INFO command\n")
			logging.DebugPrint(disk.logID, "... ... Origin Start Address: %d\n", addr)
		}
		disk.ctrlInfBlock[0] = memory.ReadWord(addr)
		disk.ctrlInfBlock[1] = memory.ReadWord(addr + 1)
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... ... Word 0: %s\n", memory.WordToBinStr(disk.ctrlInfBlock[0]))
			logging.DebugPrint(disk.logID, "... ... Word 1: %s\n", memory.WordToBinStr(disk.ctrlInfBlock[1]))
		}
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239SetController, memory.TestWbit(disk.commandRegC, 15))

	case disk6239StartList:
		addr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.commandRegA, disk.commandRegB))
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... START LIST command\n")
			logging.DebugPrint(disk.logID, "... ..... First CB Address: %d\n", addr)
			logging.DebugPrint(disk.logID, "... ..... CB Channel Q length: %d\n", len(disk.cbChan))
		}
		// TODO should check addr validity before starting processing
		//disk6239ProcessCB(addr)
		disk.cbChan <- addr
		disk.statusRegA = memory.DwordGetUpperWord(dg.DwordT(addr)) // return address of 1st CB processed
		disk.statusRegB = memory.DwordGetLowerWord(dg.DwordT(addr))
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239StartList, memory.TestWbit(disk.commandRegC, 15))

	case disk6239UnitStatus:
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... GET UNIT STATUS command\n")
			logging.DebugPrint(disk.logID, "... ... Unit: %d\n", disk.commandRegA)
		}
		disk.statusRegB = 0
		memory.SetWbit(&disk.statusRegB, 2) // Ready
		// TODO may need to handle bit 3 'Busy' in the future
		disk.disk6239SetPioStatusRegC(0, statCcsPioCmdOk, disk6239UnitStatus, memory.TestWbit(disk.commandRegC, 15))

	default:
		log.Panicf("disk6239 command %d not yet implemented\n", pioCmd)
	}
	disk.disk6239DataMu.Unlock()
}

func (disk *Disk6239DataT) disk6239ExtractPioCommand(word dg.WordT) uint {
	res := uint((word & 01776) >> 1) // mask penultimate 9 bits
	return res
}

func (disk *Disk6239DataT) disk6239GetCBextendedStatusSize() int {
	word := disk.intInfBlock[5]
	word >>= 8
	word &= 0x0f
	return int(word)
}

// Handle flag/pulse to disk6239
func (disk *Disk6239DataT) disk6239HandleFlag(f byte) {
	switch f {
	case 'S':
		disk.bus.SetBusy(disk.devNum, true)
		disk.bus.SetDone(disk.devNum, false)
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... S flag set\n")
		}
		disk.disk6239DoPioCommand()

		disk.bus.SetBusy(disk.devNum, false)
		// set the DONE flag if the return bit was set
		disk.disk6239DataMu.RLock()
		if memory.TestWbit(disk.commandRegC, 15) {
			disk.bus.SetDone(disk.devNum, true)
		}
		disk.disk6239DataMu.RUnlock()

	case 'C':
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... C flag set, clearing DONE flag\n")
		}
		disk.bus.SetDone(disk.devNum, false)
		// TODO clear pending interrupt
		//disk.statusRegC = 0
		disk.disk6239SetPioStatusRegC(statXecStateMapped,
			statCcsPioCmdOk,
			dg.WordT(disk.disk6239ExtractPioCommand(disk.commandRegC)),
			memory.TestWbit(disk.commandRegC, 15))

	case 'P':
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... P flag set\n")
		}
		log.Fatalln("P flag not yet implemented in disk6239")

	default:
		// no/empty flag - nothing to do
	}
}

// seek to the disk position according to sector number in disk6239Data structure
func (disk *Disk6239DataT) disk6239PositionDiskImage() {
	var offset = int64(disk.sectorNo) * disk6239BytesPerSector
	_, err := disk.imageFile.Seek(offset, 0)
	if err != nil {
		log.Fatalln("disk6239 could not position disk image")
	}
	// TODO Set C/H/S???
}

// CB processing in a goroutine
func (disk *Disk6239DataT) disk6239CBprocessor() {
	var (
		w, cbLength   int
		nextCB        dg.PhysAddrT
		sect          dg.DwordT
		physTransfers bool
		physAddr      dg.PhysAddrT
		tmpWd         dg.WordT
	)
	for {
		cbAddr := <-disk.cbChan
		cbLength = disk6239CbMinSize + disk.disk6239GetCBextendedStatusSize()
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... Processing CB, extended status size is: %d\n", disk.disk6239GetCBextendedStatusSize())
		}
		// copy CB contents from host memory
		addr := cbAddr
		for w = 0; w < cbLength; w++ {
			disk.activeCB[w] = memory.ReadWordBmcChan(&addr)
			// if disk.debugLogging {
			// 	logging.DebugPrint(disk.logID, "... CB[%d]: %d\n", w, cb[w])
			// }
		}
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... CB: ")
			for cbwd := 0; cbwd < cbLength; cbwd++ {
				logging.DebugPrint(disk.logID, "%d: %d, ", cbwd, disk.activeCB[cbwd])
			}
		}

		opCode := disk.activeCB[disk6239CbInaFlagsOpcode] & 0x03ff
		nextCB = dg.PhysAddrT(memory.DwordFromTwoWords(disk.activeCB[disk6239CbLinkAddrHigh], disk.activeCB[disk6239CbLinkAddrLow]))
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "... CB OpCode: %d\n", opCode)
			logging.DebugPrint(disk.logID, "... .. Next CB Addr: %d\n", nextCB)
		}
		switch opCode {

		case disk6239CbOpNoOp:
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "... .. NO OP\n")
			}
			if cbLength >= disk6239CbErrStatus+1 {
				disk.activeCB[disk6239CbErrStatus] = 0
			}
			if cbLength >= disk6239CbUnitStatus+1 {
				disk.activeCB[disk6239CbUnitStatus] = 1 << 13 // b0010000000000000; // Ready
			}
			if cbLength >= disk6239CbCbStatus+1 {
				disk.activeCB[disk6239CbCbStatus] = 1 // finally, set Done bit
			}

		case disk6239CbOpRecalibrateDisk:
			disk.disk6239DataMu.Lock()
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "... .. RECALIBRATE\n")
			}
			//disk.cylinder = 0
			//disk.head = 0
			//disk.sector = 0
			disk.sectorNo = 0
			disk.disk6239PositionDiskImage()
			disk.disk6239DataMu.Unlock()
			if cbLength >= disk6239CbErrStatus+1 {
				disk.activeCB[disk6239CbErrStatus] = 0
			}
			if cbLength >= disk6239CbUnitStatus+1 {
				disk.activeCB[disk6239CbUnitStatus] = 1 << 13 // b0010000000000000; // Ready
			}
			if cbLength >= disk6239CbCbStatus+1 {
				disk.activeCB[disk6239CbCbStatus] = 1 // finally, set Done bit
			}

		case disk6239CbOpRead:
			disk.disk6239DataMu.Lock()
			disk.sectorNo = memory.DwordFromTwoWords(disk.activeCB[disk6239CbDevAddrHigh], disk.activeCB[disk6239CbDevAddrLow])
			if memory.TestWbit(disk.activeCB[disk6239CbPagenoListAddrHigh], 0) {
				// logical premapped host address
				physTransfers = false
				log.Fatal("disk6239 - CB READ from premapped logical addresses  Not Yet Implemented")
			} else {
				physTransfers = true
				physAddr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.activeCB[disk6239CbTxferAddrHigh], disk.activeCB[disk6239CbTxferAddrLow]))
			}
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "... .. CB READ command, SECCNT: %d\n", disk.activeCB[disk6239CbTxferCount])
				logging.DebugPrint(disk.logID, "... .. .. .... from sector:     %d\n", disk.sectorNo)
				logging.DebugPrint(disk.logID, "... .. .. .... from phys addr:  %d\n", physAddr)
				logging.DebugPrint(disk.logID, "... .. .. .... physical txfer?: %d\n", memory.BoolToInt(physTransfers))
			}
			for sect = 0; sect < dg.DwordT(disk.activeCB[disk6239CbTxferCount]); sect++ {
				disk.sectorNo += sect
				disk.disk6239PositionDiskImage()
				disk.imageFile.Read(disk.readBuff)
				addr = physAddr + (dg.PhysAddrT(sect) * disk6239WordsPerSector)
				for w = 0; w < disk6239WordsPerSector; w++ {
					tmpWd = dg.WordT(disk.readBuff[w*2]) | (dg.WordT(disk.readBuff[(w*2)+1]) << 8)
					memory.WriteWordBmcChan(&addr, tmpWd)
				}
				disk.reads++
			}
			if cbLength > disk6239CbErrStatus {
				disk.activeCB[disk6239CbErrStatus] = 0
			}
			if cbLength > disk6239CbUnitStatus {
				disk.activeCB[disk6239CbUnitStatus] = 1 << 13 // b0010000000000000; // Ready
			}
			if cbLength > disk6239CbCbStatus {
				disk.activeCB[disk6239CbCbStatus] = 1 // finally, set Done bit
			}

			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "... .. .... READ command finished\n")
				logging.DebugPrint(disk.logID, "Last buffer: %X\n", disk.readBuff)
			}
			disk.disk6239DataMu.Unlock()

		case disk6239CbOpWrite:
			disk.disk6239DataMu.Lock()
			disk.sectorNo = memory.DwordFromTwoWords(disk.activeCB[disk6239CbDevAddrHigh], disk.activeCB[disk6239CbDevAddrLow])
			if memory.TestWbit(disk.activeCB[disk6239CbPagenoListAddrHigh], 0) {
				// logical premapped host address
				physTransfers = false
				log.Fatal("disk6239 - CB WRITE from premapped logical addresses  Not Yet Implemented")
			} else {
				physTransfers = true
				physAddr = dg.PhysAddrT(memory.DwordFromTwoWords(disk.activeCB[disk6239CbTxferAddrHigh], disk.activeCB[disk6239CbTxferAddrLow]))
			}
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "... .. CB WRITE command, SECCNT: %d\n", disk.activeCB[disk6239CbTxferCount])
				logging.DebugPrint(disk.logID, "... .. .. ..... to sector:       %d\n", disk.sectorNo)
				logging.DebugPrint(disk.logID, "... .. .. ..... from phys addr:  %d\n", physAddr)
				logging.DebugPrint(disk.logID, "... .. .. ..... physical txfer?: %d\n", memory.BoolToInt(physTransfers))
			}
			for sect = 0; sect < dg.DwordT(disk.activeCB[disk6239CbTxferCount]); sect++ {
				disk.sectorNo += sect
				disk.disk6239PositionDiskImage()
				memAddr := physAddr + (dg.PhysAddrT(sect) * disk6239WordsPerSector)
				for w = 0; w < disk6239WordsPerSector; w++ {
					tmpWd = memory.ReadWordBmcChan(&memAddr)
					disk.writeBuff[(w*2)+1] = byte(tmpWd >> 8)
					disk.writeBuff[w*2] = byte(tmpWd & 0x00ff)
				}
				disk.imageFile.Write(disk.writeBuff)
				if disk.debugLogging {
					logging.DebugPrint(disk.logID, "Wrote buffer: %X\n", disk.writeBuff)
				}
				disk.writes++
			}
			if cbLength >= disk6239CbErrStatus+1 {
				disk.activeCB[disk6239CbErrStatus] = 0
			}
			if cbLength >= disk6239CbUnitStatus+1 {
				disk.activeCB[disk6239CbUnitStatus] = 1 << 13 // b0010000000000000; // Ready
			}
			if cbLength >= disk6239CbCbStatus+1 {
				disk.activeCB[disk6239CbCbStatus] = 1 // finally, set Done bit
			}
			disk.disk6239DataMu.Unlock()

		default:
			log.Fatalf("disk6239 CB Command %d not yet implemented\n", opCode)
		}

		// write back CB
		addr = cbAddr
		for w = 0; w < cbLength; w++ {
			memory.WriteWordBmcChan(&addr, disk.activeCB[w])
		}

		if nextCB == 0 {
			// send ASYNCH status. See p.4-15
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "...ready to set ASYNC status\n")
			}
			for disk.bus.GetBusy(disk.devNum) || disk.bus.GetDone(disk.devNum) {
				time.Sleep(disk6239AsynchStatRetryInterval)
			}
			disk.disk6239DataMu.Lock()
			disk.statusRegC = dg.WordT(statXecStateMapped) << 12
			disk.statusRegC |= (statAsyncNoErrors & 0x03ff)
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "disk6239 ASYNCHRONOUS status C set to: %s\n",
					memory.WordToBinStr(disk.statusRegC))
			}
			disk.disk6239DataMu.Unlock()
			if disk.debugLogging {
				logging.DebugPrint(disk.logID, "...set ASYNC status\n")
			}
			disk.bus.SetDone(disk.devNum, true)
		} else {
			// chain to next CB
			//disk6239ProcessCB(nextCB)
			disk.cbChan <- nextCB
		}
	}
}

func (disk *Disk6239DataT) disk6239Reset() {
	disk.disk6239DataMu.Lock()
	disk.disk6239ResetMapping()
	disk.disk6239ResetIntInfBlk()
	disk.disk6239ResetCtrlrInfBlock()
	disk.disk6239ResetUnitInfBlock()
	//disk.statusRegA = 0
	disk.statusRegB = 0
	disk.statusRegC = 0
	disk.disk6239SetPioStatusRegC(statXecStateResetDone, 0, disk6239PioReset, memory.TestWbit(disk.commandRegC, 15))
	disk.disk6239DataMu.Unlock()
	if disk.debugLogging {
		logging.DebugPrint(disk.logID, "disk6239 ***Reset*** via call to disk6239Reset()\n")
	}

}

// N.B. We assume disk6239Data is LOCKED before calling ANY of the following functions

// setup the controller information block to power-up defaults p.2-15
func (disk *Disk6239DataT) disk6239ResetCtrlrInfBlock() {
	disk.ctrlInfBlock[0] = 0
	disk.ctrlInfBlock[1] = 0
}

// setup the interface information block to power-up defaults
func (disk *Disk6239DataT) disk6239ResetIntInfBlk() {
	disk.intInfBlock[0] = 0101
	disk.intInfBlock[1] = disk6239UcodeRev
	disk.intInfBlock[2] = 3
	disk.intInfBlock[3] = 8<<11 | disk6239MaxQueuedCBs
	disk.intInfBlock[4] = 0
	disk.intInfBlock[5] = 11 << 8
	disk.intInfBlock[6] = 0
	disk.intInfBlock[7] = 0
}

// set mapping options after IORST, power-up or Reset
func (disk *Disk6239DataT) disk6239ResetMapping() {
	disk.mappingRegA = 0x4000 // DMA over the BMC
	disk.mappingRegB = disk6239MapIntBmcPhys | disk6239MapUpstreamLoad | disk6239MapUpstreamHpt
	disk.isMapped = false
}

// setup the unit information block to power-up defaults pp.2-16
func (disk *Disk6239DataT) disk6239ResetUnitInfBlock() {
	disk.unitInfBlock[0] = 0
	disk.unitInfBlock[1] = 9<<12 | disk6239UcodeRev
	disk.unitInfBlock[2] = dg.WordT(disk6239LogicalBlocksH) // 17.
	disk.unitInfBlock[3] = dg.WordT(disk6239LogicalBlocksL) // 43840.
	disk.unitInfBlock[4] = disk6239BytesPerSector
	disk.unitInfBlock[5] = disk6239UserCylinders
	disk.unitInfBlock[6] = ((disk6239SurfacesPerDisk * disk6239HeadsPerSurface) << 8) | (0x00ff & disk6239SectorsPerTrack)
}

// this is used to set the SYNCHRONOUS standard return as per p.3-22
func (disk *Disk6239DataT) disk6239SetPioStatusRegC(stat byte, ccs byte, cmdEcho dg.WordT, rr bool) {
	if stat == 0 && disk.isMapped {
		stat = statXecStateMapped
	}
	if rr || cmdEcho == disk6239PioReset {
		disk.statusRegC = dg.WordT(stat) << 12
		disk.statusRegC |= (dg.WordT(ccs) & 3) << 10
		disk.statusRegC |= (cmdEcho & 0x01ff) << 1
		if rr {
			disk.statusRegC |= 1
		}
		if disk.debugLogging {
			logging.DebugPrint(disk.logID, "disk6239 PIO (SYNCH) status C set to: %s\n",
				memory.WordToBinStr(disk.statusRegC))
		}
	}
}

// Disk6239SetLogging sets the internal debugging/logging flag according to the passed value
// N.B. The disk will run slower when this is set.
func (disk *Disk6239DataT) Disk6239SetLogging(debug bool) {
	disk.disk6239DataMu.Lock()
	disk.debugLogging = debug
	disk.disk6239DataMu.Unlock()
}

repository: SMerrony/dgemug

repo_name: SMerrony/dgemug


text:
@book{MMDM,
  author    = {秦大同 and 谢里阳},
  location  = {北京},
  publisher = {化学工业出版社},
  date      = {2019},
  title     = {现代机械设计手册. 第二卷},
}

repository: WaiwaiTAN/kfcrobot

repo_name: WaiwaiTAN/kfcrobot


text:
//You are given a doubly linked list which in addition to the next and previous
//pointers, it could have a child pointer, which may or may not point to a
//separate doubly linked list. These child lists may have one or more children of their
//own, and so on, to produce a multilevel data structure, as shown in the example
//below.
//
// Flatten the list so that all the nodes appear in a single-level, doubly
//linked list. You are given the head of the first level of the list.
//
//
// Example 1:
//
//
//Input: head = [1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]
//Output: [1,2,3,7,8,11,12,9,10,4,5,6]
//Explanation:
//
//The multilevel linked list in the input is as follows:
//
//
//
//After flattening the multilevel linked list it becomes:
//
//
//
//
// Example 2:
//
//
//Input: head = [1,2,null,3]
//Output: [1,3,2]
//Explanation:
//
//The input multilevel linked list is as follows:
//
//  1---2---NULL
//  |
//  3---NULL
//
//
// Example 3:
//
//
//Input: head = []
//Output: []
//
//
//
//
// How multilevel linked list is represented in test case:
//
// We use the multilevel linked list from Example 1 above:
//
//
// 1---2---3---4---5---6--NULL
//         |
//         7---8---9---10--NULL
//             |
//             11--12--NULL
//
// The serialization of each level is as follows:
//
//
//[1,2,3,4,5,6,null]
//[7,8,9,10,null]
//[11,12,null]
//
//
// To serialize all levels together we will add nulls in each level to signify
//no node connects to the upper node of the previous level. The serialization
//becomes:
//
//
//[1,2,3,4,5,6,null]
//[null,null,7,8,9,10,null]
//[null,11,12,null]
//
//
// Merging the serialization of each level and removing trailing nulls we
//obtain:
//
//
//[1,2,3,4,5,6,null,null,null,7,8,9,10,null,null,11,12]
//
//
// Constraints:
//
//
// The number of Nodes will not exceed 1000.
// 1 <= Node.val <= 10⁵
//
// Related Topics 深度优先搜索 链表 双向链表 👍 291 👎 0

package main

import "fmt"

type Node struct {
	Val   int
	Prev  *Node
	Next  *Node
	Child *Node
}

//leetcode submit region begin(Prohibit modification and deletion)
/**
 * Definition for a Node.
 * type Node struct {
 *     Val int
 *     Prev *Node
 *     Next *Node
 *     Child *Node
 * }
 */

func flatten(root *Node) *Node {
	var stack []*Node
	for p := root; p != nil; p = p.Next {
		if p.Child != nil {
			if p.Next != nil {
				stack = append(stack, p.Next)
			}
			p.Next = p.Child
		}
		if p.Next == nil {
			if len(stack) != 0 {
				p.Next = stack[len(stack)-1]
				stack = stack[:len(stack)-1]
			}
		}
	}
	for p := root; p != nil; p = p.Next {
		p.Child = nil
		if p.Next != nil {
			p.Next.Prev = p
		}
	}
	return root
}

//leetcode submit region end(Prohibit modification and deletion)

func main() {
	fmt.Println(flatten(&Node{
		Val:  1,
		Prev: nil,
		Next: &Node{
			Val:  2,
			Prev: nil,
			Next: &Node{
				Val:  3,
				Prev: nil,
				Next: &Node{
					Val:  4,
					Prev: nil,
					Next: &Node{
						Val:  5,
						Prev: nil,
						Next: &Node{
							Val:   6,
							Prev:  nil,
							Next:  nil,
							Child: nil,
						},
						Child: nil,
					},
					Child: nil,
				},
				Child: &Node{
					Val:  7,
					Prev: nil,
					Next: &Node{
						Val:  8,
						Prev: nil,
						Next: nil,
						Child: &Node{
							Val:  11,
							Prev: nil,
							Next: &Node{
								Val:   12,
								Prev:  nil,
								Next:  nil,
								Child: nil,
							},
							Child: nil,
						},
					},
					Child: nil,
				},
			},
			Child: nil,
		},
		Child: nil,
	}))
	fmt.Println(flatten(&Node{
		Val:  1,
		Prev: nil,
		Next: &Node{
			Val:  2,
			Prev: nil,
			Next: &Node{
				Val:  3,
				Prev: nil,
				Next: &Node{
					Val:  4,
					Prev: nil,
					Next: &Node{
						Val:  5,
						Prev: nil,
						Next: &Node{
							Val:   6,
							Prev:  nil,
							Next:  nil,
							Child: nil,
						},
						Child: nil,
					},
					Child: nil,
				},
				Child: &Node{
					Val:  7,
					Prev: nil,
					Next: &Node{
						Val:  8,
						Prev: nil,
						Next: &Node{
							Val:  9,
							Prev: nil,
							Next: &Node{
								Val:   10,
								Prev:  nil,
								Next:  nil,
								Child: nil,
							},
							Child: nil,
						},
						Child: &Node{
							Val:  11,
							Prev: nil,
							Next: &Node{
								Val:   12,
								Prev:  nil,
								Next:  nil,
								Child: nil,
							},
							Child: nil,
						},
					},
					Child: nil,
				},
			},
			Child: nil,
		},
		Child: nil,
	}))
}

gha_language: Java


text:
package tui

import beholder "github.com/dhleong/beholder/src"

// NewSimpleRenderer will create a Renderer that can render
// anything that's just a name and text. The label will be
// rendered immediately after the name.
func NewSimpleRenderer(label string) *EntityRenderer {
	return &EntityRenderer{
		replacements: func(e beholder.Entity) []string {
			return []string{
				"{label}", label,
			}
		},

		template: `
[::bu]{name}[-:-:-]{label}

{text}
`,
	}
}

repository: dhleong/beholder

repo_name: dhleong/beholder


text:
@incollection{HansonRichardsCal-2008,
 abstract = {In this chapter we examine ways of programmatically expanding the functionality of conventional browsers. We consider various mechanisms for creating extensions and add-ons in Internet Explorer and Firefox and briefly review other browsers. We explore some existing browser extensions. The focus is on accessibility extensions, but some prominent other examples of browser extensions are also mentioned. Information for using and creating various types of extensions is presented. Finally, the usefulness of browser extensions compared with other accessibility enablement options for the Web is considered.},
 address = {London},
 author = {Hanson, Vicki L and Richards, John T and Swart, Cal},
 booktitle = {Web Accessibility},
 chapter = {13},
 doi = {http://dx.doi.org/10.1007/978-1-84800-050-6_13},
 edition = {1st},
 editor = {Harper, Simon and Yesilada, Yeliz},
 keywords = {wa-book},
 mendeley-groups = {WWW/Internet,WA Book Chapters,Books},
 month = {sep},
 pages = {215--229},
 publisher = {Springer},
 series = {Human-Computer Interaction Series},
 title = {Browser Augmentation},
 url = {http://dx.doi.org/http://dx.doi.org/10.1007/978-1-84800-050-6_13},
 year = {2008}
}

repository: sharpic/academic-kickstart

repo_name: sharpic/academic-kickstart


text:
$(function(){
	setTimeout(function(){
		$('.nav1>li:nth-of-type(1)').addClass('left_nac');
	},10)
})

repository: Micoozz/incourse

repo_name: Micoozz/incourse

extension: js


text:
SECTION = "devel"
DESCRIPTION = "OProfile is a system-wide profiler for Linux systems, capable \
of profiling all running code at low overhead."
LICENSE = "GPL"
DEPENDS = "popt binutils"

SRC_URI = "${SOURCEFORGE_MIRROR}/oprofile/oprofile-${PV}.tar.gz \
	   file://acinclude.m4"
S = "${WORKDIR}/oprofile-${PV}"

inherit autotools

# NOTE: this disables the build of the kernel modules.
# Should add the oprofile kernel modules, for those with 2.4
# kernels, as a seperate .oe file.
EXTRA_OECONF = "--with-kernel-support \
		--without-x \
		--disable-werror "

do_configure () {
	cp ${WORKDIR}/acinclude.m4 ${S}/
	autotools_do_configure
}
# Available config options
#  --enable-abi                 enable abi portability code (default is disabled)
#  --enable-pch                 enable precompiled header (default is disabled)
#  --enable-gcov                enable option for gcov coverage testing (default is disabled)
#  --disable-werror            disable -Werror flag (default is enabled for non-release)
#  --disable-optimization      disable optimization flags (default is enabled)
#  --with-kernel-support        Use 2.6 kernel (no kernel source tree required)
#  --with-linux=dir             Path to Linux source tree
#  --with-module-dir=dir        Path to module installation directory
#  --with-extra-includes=DIR    add extra include paths
#  --with-extra-libs=DIR        add extra library paths
#  --with-x                use the X Window System
#  --with-qt-dir           where the root of Qt is installed
#  --with-qt-includes      where the Qt includes are.
#  --with-qt-libraries     where the Qt library is installed.

repository: jdegges/gumstix-pip-oe

repo_name: jdegges/gumstix-pip-oe