text
stringlengths
2
99.9k
meta
dict
<?xml version="1.0" encoding="UTF-8"?> <executable> <category>Filtering</category> <title>Voting Binary Hole Filling Image Filter</title> <description><![CDATA[Applies a voting operation in order to fill-in cavities. This can be used for smoothing contours and for filling holes in binary images. This technique is used frequently when segmenting complete organs that may have ducts or vasculature that may not have been included in the initial segmentation, e.g. lungs, kidneys, liver.]]></description> <version>0.1.0.$Revision$(alpha)</version> <documentation-url>http://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Modules/VotingBinaryHoleFillingImageFilter</documentation-url> <license/> <contributor>Bill Lorensen (GE)</contributor> <acknowledgements><![CDATA[This command module was derived from Insight/Examples/Filtering/VotingBinaryHoleFillingImageFilter (copyright) Insight Software Consortium]]></acknowledgements> <parameters> <label>Binary Hole Filling Parameters</label> <description><![CDATA[Parameters for Hole Filling]]></description> <integer-vector> <name>radius</name> <longflag>--radius</longflag> <description><![CDATA[The radius of a hole to be filled]]></description> <label>Maximum Radius</label> <default>1,1,1</default> </integer-vector> <integer> <name>majorityThreshold</name> <longflag>--majorityThreshold</longflag> <description><![CDATA[The number of pixels over 50% that will decide whether an OFF pixel will become ON or not. For example, if the neighborhood of a pixel has 124 pixels (excluding itself), the 50% will be 62, and if you set a Majority threshold of 5, that means that the filter will require 67 or more neighbor pixels to be ON in order to switch the current OFF pixel to ON.]]></description> <label>Majority Threshold</label> <default>1</default> </integer> <integer> <name>background</name> <longflag>--background</longflag> <description><![CDATA[The value associated with the background (not object)]]></description> <label>Background</label> <default>0</default> </integer> <integer> <name>foreground</name> <longflag>--foreground</longflag> <description><![CDATA[The value associated with the foreground (object)]]></description> <label>Foreground</label> <default>255</default> </integer> </parameters> <parameters> <label>IO</label> <description><![CDATA[Input/output parameters]]></description> <image type="label"> <name>inputVolume</name> <label>Input Volume</label> <channel>input</channel> <index>0</index> <description><![CDATA[Input volume to be filtered]]></description> </image> <image type="label" reference="inputVolume"> <name>outputVolume</name> <label>Output Volume</label> <channel>output</channel> <index>1</index> <description><![CDATA[Output filtered]]></description> </image> </parameters> </executable>
{ "pile_set_name": "Github" }
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Linq; using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeGeneration; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting; using Roslyn.Utilities; using static Microsoft.CodeAnalysis.CodeGeneration.CodeGenerationHelpers; namespace Microsoft.CodeAnalysis.CSharp.CodeGeneration { internal static class CSharpCodeGenerationHelpers { public static TDeclarationSyntax ConditionallyAddFormattingAnnotationTo<TDeclarationSyntax>( TDeclarationSyntax result, SyntaxList<MemberDeclarationSyntax> members) where TDeclarationSyntax : MemberDeclarationSyntax { return members.Count == 1 ? result.WithAdditionalAnnotations(Formatter.Annotation) : result; } internal static void AddAccessibilityModifiers( Accessibility accessibility, IList<SyntaxToken> tokens, CodeGenerationOptions options, Accessibility defaultAccessibility) { options = options ?? CodeGenerationOptions.Default; if (!options.GenerateDefaultAccessibility && accessibility == defaultAccessibility) { return; } switch (accessibility) { case Accessibility.Public: tokens.Add(SyntaxFactory.Token(SyntaxKind.PublicKeyword)); break; case Accessibility.Protected: tokens.Add(SyntaxFactory.Token(SyntaxKind.ProtectedKeyword)); break; case Accessibility.Private: tokens.Add(SyntaxFactory.Token(SyntaxKind.PrivateKeyword)); break; case Accessibility.ProtectedAndInternal: case Accessibility.Internal: tokens.Add(SyntaxFactory.Token(SyntaxKind.InternalKeyword)); break; case Accessibility.ProtectedOrInternal: tokens.Add(SyntaxFactory.Token(SyntaxKind.ProtectedKeyword)); tokens.Add(SyntaxFactory.Token(SyntaxKind.InternalKeyword)); break; } } public static TypeDeclarationSyntax AddMembersTo( TypeDeclarationSyntax destination, SyntaxList<MemberDeclarationSyntax> members) { destination = ReplaceUnterminatedConstructs(destination); return ConditionallyAddFormattingAnnotationTo( destination.EnsureOpenAndCloseBraceTokens().WithMembers(members), members); } private static TypeDeclarationSyntax ReplaceUnterminatedConstructs(TypeDeclarationSyntax destination) { const string MultiLineCommentTerminator = "*/"; var lastToken = destination.GetLastToken(); var updatedToken = lastToken.ReplaceTrivia(lastToken.TrailingTrivia, (t1, t2) => { if (t1.Kind() == SyntaxKind.MultiLineCommentTrivia) { var text = t1.ToString(); if (!text.EndsWith(MultiLineCommentTerminator)) { return SyntaxFactory.SyntaxTrivia(SyntaxKind.MultiLineCommentTrivia, text + MultiLineCommentTerminator); } } else if (t1.Kind() == SyntaxKind.SkippedTokensTrivia) { return ReplaceUnterminatedConstructs(t1); } return t1; }); return destination.ReplaceToken(lastToken, updatedToken); } private static SyntaxTrivia ReplaceUnterminatedConstructs(SyntaxTrivia skippedTokensTrivia) { var syntax = (SkippedTokensTriviaSyntax)skippedTokensTrivia.GetStructure(); var tokens = syntax.Tokens; var updatedTokens = SyntaxFactory.TokenList(tokens.Select(ReplaceUnterminatedConstruct)); var updatedSyntax = syntax.WithTokens(updatedTokens); return SyntaxFactory.Trivia(updatedSyntax); } private static SyntaxToken ReplaceUnterminatedConstruct(SyntaxToken token) { if (token.IsVerbatimStringLiteral()) { var tokenText = token.ToString(); if (tokenText.Length <= 2 || tokenText.Last() != '"') { tokenText += '"'; return SyntaxFactory.Literal(token.LeadingTrivia, tokenText, token.ValueText, token.TrailingTrivia); } } else if (token.IsRegularStringLiteral()) { var tokenText = token.ToString(); if (tokenText.Length <= 1 || tokenText.Last() != '"') { tokenText += '"'; return SyntaxFactory.Literal(token.LeadingTrivia, tokenText, token.ValueText, token.TrailingTrivia); } } return token; } public static MemberDeclarationSyntax FirstMember(SyntaxList<MemberDeclarationSyntax> members) { return members.FirstOrDefault(); } public static MemberDeclarationSyntax FirstMethod(SyntaxList<MemberDeclarationSyntax> members) { return members.FirstOrDefault(m => m is MethodDeclarationSyntax); } public static MemberDeclarationSyntax LastField(SyntaxList<MemberDeclarationSyntax> members) { return members.LastOrDefault(m => m is FieldDeclarationSyntax); } public static MemberDeclarationSyntax LastConstructor(SyntaxList<MemberDeclarationSyntax> members) { return members.LastOrDefault(m => m is ConstructorDeclarationSyntax); } public static MemberDeclarationSyntax LastMethod(SyntaxList<MemberDeclarationSyntax> members) { return members.LastOrDefault(m => m is MethodDeclarationSyntax); } public static MemberDeclarationSyntax LastOperator(SyntaxList<MemberDeclarationSyntax> members) { return members.LastOrDefault(m => m is OperatorDeclarationSyntax || m is ConversionOperatorDeclarationSyntax); } public static SyntaxList<TDeclaration> Insert<TDeclaration>( SyntaxList<TDeclaration> declarationList, TDeclaration declaration, CodeGenerationOptions options, IList<bool> availableIndices, Func<SyntaxList<TDeclaration>, TDeclaration> after = null, Func<SyntaxList<TDeclaration>, TDeclaration> before = null) where TDeclaration : SyntaxNode { var index = GetInsertionIndex(declarationList, declaration, options, availableIndices, after, before); if (availableIndices != null) { availableIndices.Insert(index, true); } if (index != 0 && declarationList[index - 1].ContainsDiagnostics && AreBracesMissing(declarationList[index - 1])) { return declarationList.Insert(index, declaration.WithLeadingTrivia(SyntaxFactory.ElasticCarriageReturnLineFeed)); } return declarationList.Insert(index, declaration); } private static bool AreBracesMissing<TDeclaration>(TDeclaration declaration) where TDeclaration : SyntaxNode { return declaration.ChildTokens().Where(t => t.IsKind(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken) && t.IsMissing).Any(); } public static int GetInsertionIndex<TDeclaration>( SyntaxList<TDeclaration> declarationList, TDeclaration declaration, CodeGenerationOptions options, IList<bool> availableIndices, Func<SyntaxList<TDeclaration>, TDeclaration> after = null, Func<SyntaxList<TDeclaration>, TDeclaration> before = null) where TDeclaration : SyntaxNode { Contract.ThrowIfTrue(availableIndices != null && availableIndices.Count != declarationList.Count + 1); if (options != null) { // Try to strictly obey the after option by inserting immediately after the member containing the location if (options.AfterThisLocation != null) { var afterMember = declarationList.LastOrDefault(m => m.SpanStart <= options.AfterThisLocation.SourceSpan.Start); if (afterMember != null) { var index = declarationList.IndexOf(afterMember); index = GetPreferredIndex(index + 1, availableIndices, forward: true); if (index != -1) { return index; } } } // Try to strictly obey the before option by inserting immediately before the member containing the location if (options.BeforeThisLocation != null) { var beforeMember = declarationList.FirstOrDefault(m => m.Span.End >= options.BeforeThisLocation.SourceSpan.End); if (beforeMember != null) { var index = declarationList.IndexOf(beforeMember); index = GetPreferredIndex(index, availableIndices, forward: false); if (index != -1) { return index; } } } if (options.AutoInsertionLocation) { if (declarationList.IsEmpty()) { return 0; } else if (declarationList.IsSorted(CSharpDeclarationComparer.Instance)) { var result = Array.BinarySearch(declarationList.ToArray(), declaration, CSharpDeclarationComparer.Instance); var index = GetPreferredIndex(result < 0 ? ~result : result, availableIndices, forward: true); if (index != -1) { return index; } } if (after != null) { var member = after(declarationList); if (member != null) { var index = declarationList.IndexOf(member); if (index >= 0) { index = GetPreferredIndex(index + 1, availableIndices, forward: true); if (index != -1) { return index; } } } } if (before != null) { var member = before(declarationList); if (member != null) { var index = declarationList.IndexOf(member); if (index >= 0) { index = GetPreferredIndex(index, availableIndices, forward: false); if (index != -1) { return index; } } } } } } // Otherwise, add the declaration to the end. { var index = GetPreferredIndex(declarationList.Count, availableIndices, forward: false); if (index != -1) { return index; } } return declarationList.Count; } public static SyntaxNode GetContextNode( Location location, CancellationToken cancellationToken) { var contextLocation = location as Location; var contextTree = contextLocation != null && contextLocation.IsInSource ? (SyntaxTree)contextLocation.SourceTree : null; return contextTree == null ? null : contextTree.GetRoot(cancellationToken).FindToken(contextLocation.SourceSpan.Start).Parent; } public static ExplicitInterfaceSpecifierSyntax GenerateExplicitInterfaceSpecifier( IEnumerable<ISymbol> implementations) { var implementation = implementations.FirstOrDefault(); if (implementation == null) { return null; } var name = implementation.ContainingType.GenerateTypeSyntax() as NameSyntax; if (name == null) { return null; } return SyntaxFactory.ExplicitInterfaceSpecifier(name); } public static CodeGenerationDestination GetDestination(SyntaxNode destination) { if (destination != null) { switch (destination.Kind()) { case SyntaxKind.ClassDeclaration: return CodeGenerationDestination.ClassType; case SyntaxKind.CompilationUnit: return CodeGenerationDestination.CompilationUnit; case SyntaxKind.EnumDeclaration: return CodeGenerationDestination.EnumType; case SyntaxKind.InterfaceDeclaration: return CodeGenerationDestination.InterfaceType; case SyntaxKind.NamespaceDeclaration: return CodeGenerationDestination.Namespace; case SyntaxKind.StructDeclaration: return CodeGenerationDestination.StructType; default: return CodeGenerationDestination.Unspecified; } } return CodeGenerationDestination.Unspecified; } public static TSyntaxNode ConditionallyAddDocumentationCommentTo<TSyntaxNode>( TSyntaxNode node, ISymbol symbol, CodeGenerationOptions options, CancellationToken cancellationToken = default(CancellationToken)) where TSyntaxNode : SyntaxNode { if (!options.GenerateDocumentationComments || node.GetLeadingTrivia().Any(t => t.IsDocComment())) { return node; } string comment; var result = TryGetDocumentationComment(symbol, "///", out comment, cancellationToken) ? node.WithPrependedLeadingTrivia(SyntaxFactory.ParseLeadingTrivia(comment)) .WithPrependedLeadingTrivia(SyntaxFactory.ElasticMarker) : node; return result; } } }
{ "pile_set_name": "Github" }
Run Render ===========
{ "pile_set_name": "Github" }
# Created by: Anton Berezin <tobez@FreeBSD.org> # $FreeBSD$ PORTNAME= Class-Prototyped PORTVERSION= 1.13 PORTREVISION= 1 CATEGORIES= devel perl5 MASTER_SITES= CPAN PKGNAMEPREFIX= p5- MAINTAINER= perl@FreeBSD.org COMMENT= Fast prototype-based OO programming in Perl USES= perl5 USE_PERL5= configure .include <bsd.port.mk>
{ "pile_set_name": "Github" }
FROM ubuntu:18.04 ENV PYTHONUNBUFFERED TRUE RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ fakeroot \ ca-certificates \ dpkg-dev \ g++ \ python3-dev \ openjdk-8-jdk-headless \ curl \ vim \ && rm -rf /var/lib/apt/lists/* \ && cd /tmp \ && curl -O https://bootstrap.pypa.io/get-pip.py \ && python3 get-pip.py RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 RUN update-alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip3 1 RUN pip install --no-cache-dir --pre multi-model-server \ && pip install --no-cache-dir mxnet-mkl RUN useradd -m model-server \ && mkdir -p /home/model-server/tmp COPY dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh COPY config.properties /home/model-server RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh \ && chown -R model-server /home/model-server EXPOSE 8080 8081 USER model-server WORKDIR /home/model-server ENV TEMP=/home/model-server/tmp ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"] CMD ["serve"] LABEL maintainer="dantu@amazon.com, rakvas@amazon.com, lufen@amazon.com, dden@amazon.com"
{ "pile_set_name": "Github" }
import {_ALPHANUM, _DEFAULT_SEED} from './constants'; import {indexers} from './data'; export function generate(date: Date, seed: string = _DEFAULT_SEED) { const idx = indexers(date, seed); const passwordOfTheDay = []; const len = idx.length; for (let i = 0; i < len; i++) { passwordOfTheDay[i] = _ALPHANUM[idx[i]]; } return passwordOfTheDay.join(''); } export class InvalidDateRangeError extends Error { constructor() { super('The start date must precede the end date.'); } } export function generate_multi(startDate: Date, endDate: Date, seed: string = _DEFAULT_SEED) { if (startDate > endDate) { throw new InvalidDateRangeError(); } const days = 1 + Math.ceil((endDate.getTime() - startDate.getTime()) / (1000*60*60*24)); const passwordList = []; for (let i = 0; i < days; i++) { const date = new Date(new Date(startDate).setDate(startDate.getDate() + i)); passwordList.push({ 'date': date, 'password': generate(date, seed) }); } return passwordList; } export const DEFAULT_SEED = _DEFAULT_SEED;
{ "pile_set_name": "Github" }
################################################################################ # # python-arrow # ################################################################################ PYTHON_ARROW_VERSION = 0.15.2 PYTHON_ARROW_SOURCE = arrow-$(PYTHON_ARROW_VERSION).tar.gz PYTHON_ARROW_SITE = https://files.pythonhosted.org/packages/43/0e/47416c54ad7742981bf77fdfc405987551ab14b181a6140c8cd2a5823872 PYTHON_ARROW_SETUP_TYPE = setuptools PYTHON_ARROW_LICENSE = Apache-2.0 PYTHON_ARROW_LICENSE_FILES = LICENSE $(eval $(python-package))
{ "pile_set_name": "Github" }
{ "layers": { "GPW_Population_Density_2010": { "id": "GPW_Population_Density_2010", "title": "Population Density, 2010", "subtitle": "GPWv4: UN-Adjusted Population Density, v4 (2000, 2005, 2010, 2015, 2020)", "description": "sedac/GPW_Population_Density_2010", "tags": "human sedac population", "group": "overlays", "layergroup": [ "sedac" ], "product": "CIESIN_SEDAC_GPWv4_APDENS_WPP_2015", "inactive": true, "wrapX": true } } }
{ "pile_set_name": "Github" }
<template> <div style="margin: 200px 0;"> <div> <Tag color="default">default</Tag> <Tag color="primary">primary</Tag> <Tag color="success">success</Tag> <Tag color="error">error</Tag> <Tag color="warning">warning</Tag> <Tag color="magenta">magenta</Tag> <Tag color="red">red</Tag> <Tag color="volcano">volcano</Tag> <Tag color="orange">orange</Tag> <Tag color="gold">gold</Tag> <Tag color="gold">不错</Tag> <Tag color="lime">lime</Tag> <Tag color="green">green</Tag> <Tag color="cyan">cyan</Tag> <Tag color="blue">blue</Tag> <Tag color="geekblue">geekblue</Tag> <Tag color="purple">purple</Tag> <Tag color="white">purple</Tag> </div> <Tag checkable>标签一</Tag> <Tag>标签二</Tag> <Tag v-if="show" closable @on-close="handleClose">标签三</Tag> <br><br> <Tag type="border" checkable>标签三</Tag> <Tag type="border" closable>标签四</Tag> <Tag type="dot">标签一</Tag> <Tag type="dot" closable>标签二</Tag> <br><br> <Tag closable color="primary" checkable>标签一</Tag> <Tag closable color="success" checkable>标签二</Tag> <Tag closable color="error" checkable>标签三</Tag> <Tag closable color="warning" checkable>标签四</Tag> <br><br> <Tag color="primary" checkable>标签一</Tag> <Tag color="success" checkable>标签二</Tag> <Tag color="error" checkable>标签三</Tag> <Tag color="warning" checkable>标签四</Tag> <br><br> <Tag closable color="#EF6AFF" checkable>标签一</Tag> <Tag color="#EF6AFF" checkable>标签一</Tag> <Tag type="border" closable color="#EF6AFF" checkable>标签二</Tag> <Tag type="dot" closable color="#EF6AFF" checkable>标签三</Tag> <Tag closable color="default" checkable>标签四</Tag> <br><br> <Tag closable color="#EF6AFF">标签一</Tag> <Tag type="border" closable color="#EF6AFF">标签二</Tag> <Tag type="dot" closable color="#EF6AFF">标签三</Tag> <Tag closable color="default">标签四</Tag> <br><br> <Tag type="border" closable color="primary" checkable>标签一</Tag> <Tag type="border" closable color="success">标签二</Tag> <Tag type="border" closable color="error">标签三</Tag> <Tag type="border" closable color="warning">标签四</Tag> <br><br> <Tag type="dot" closable color="primary" checkable>标签一</Tag> <Tag type="dot" closable color="success">标签二</Tag> <Tag type="dot" closable color="error">标签三</Tag> <Tag type="dot" closable color="warning">标签四</Tag> <br><br> <Tag v-for="item in count" :key="item" :name="item" closable @on-close="handleClose2">标签{{ item + 1 }}</Tag> <Button icon="ios-plus-empty" type="dashed" size="small" @click="handleAdd">添加标签</Button> <br><br><hr><br> <Tag :checked="checked" checkable>test</Tag> <Button @click="toggle"> Toggle </Button> <span>{{ checked }}</span> <br><br> <Tag type="dot" color="gold">标签四</Tag> <Divider>Size</Divider> <Tag color="primary" size="large">大号标签</Tag> <Tag color="primary" size="medium">中号标签</Tag> <Tag color="primary">默认尺寸</Tag> <Tag color="blue" size="large">大号标签</Tag> <Tag color="blue" size="medium">中号标签</Tag> <Tag color="blue">默认尺寸</Tag> </div> </template> <script> export default { data () { return { show: true, count: [0, 1, 2], checked: true }; }, methods: { handleClose () { this.show = false; }, handleAdd () { if (this.count.length) { this.count.push(this.count[this.count.length - 1] + 1); } else { this.count.push(0); } }, handleClose2 (event, name) { const index = this.count.indexOf(name); this.count.splice(index, 1); }, toggle() { this.checked = !this.checked; } } }; </script>
{ "pile_set_name": "Github" }
<Canvas> <Kind>42</Kind> <Name>Post Effects</Name> <IsMinified>0</IsMinified> <XPosition>1697.000000000</XPosition> <YPosition>1.000000000</YPosition> </Canvas> <Widget> <Kind>2</Kind> <Name>Enable</Name> <Value>1</Value> </Widget> <Widget> <Kind>4</Kind> <Name>Chroma_Distortion</Name> <Value>0.000000000</Value> </Widget> <Widget> <Kind>4</Kind> <Name>Grain_Distortion</Name> <Value>0.000000000</Value> </Widget> <Widget> <Kind>2</Kind> <Name>Do Bloom</Name> <Value>1</Value> </Widget> <Widget> <Kind>4</Kind> <Name>Bloom Level</Name> <Value>0.620689631</Value> </Widget> <Widget> <Kind>44</Kind> <Name>Bloom Size</Name> <Value>3</Value> </Widget>
{ "pile_set_name": "Github" }
from messybrainz.db import exceptions import sqlalchemy.exc from messybrainz.db import data from messybrainz import db def submit_listens_and_sing_me_a_sweet_song(recordings): for r in recordings: if "artist" not in r or "title" not in r: raise exceptions.BadDataException("Require artist and title keys in submission") attempts = 0 success = False while not success and attempts < 3: try: data = insert_all_in_transaction(recordings) success = True except sqlalchemy.exc.IntegrityError as e: # If we get an IntegrityError then our transaction failed. # We should try again pass attempts += 1 if success: return {"payload": data} else: raise exceptions.ErrorAddingException("Failed to add data") def load_recording(mbid): with db.engine.begin() as connection: return data.load_recording(connection, mbid) def insert_single(connection, recording): gid = data.get_id_from_recording(connection, recording) if not gid: gid = data.submit_recording(connection, recording) loaded = data.load_recording(connection, gid) return loaded def insert_all_in_transaction(recordings): ret = [] with db.engine.begin() as connection: for recording in recordings: result = insert_single(connection, recording) ret.append(result) return ret
{ "pile_set_name": "Github" }
<?php /** * Page Template * * Displays the FAQ pages for the Gift-Certificate/Voucher system.<br /> * * @copyright Copyright 2003-2020 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: mc12345678 2019 Nov 14 Modified in v1.5.7 $ */ ?> <div class="centerColumn" id="gvFaqDefault"> <?php // only show when there is a GV balance if (!empty($customer_has_gv_balance) ) { ?> <div id="sendSpendWrapper"> <?php require($template->get_template_dir('tpl_modules_send_or_spend.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_send_or_spend.php'); ?> </div> <?php } ?> <h1 id="gvFaqDefaultHeading"><?php echo HEADING_TITLE; ?></h1> <div id="gvFaqDefaultMainContent" class="content"><?php echo TEXT_INFORMATION; ?></div> <h2 id="gvFaqDefaultSubHeading"><?php echo $subHeadingTitle; ?></h2> <div id="gvFaqDefaultContent" class="content"><?php echo $subHeadingText; ?></div> <div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_BACK, BUTTON_BACK_ALT) . '</a>'; ?></div> <br class="clearBoth" /> <form action="<?php echo zen_href_link(FILENAME_GV_REDEEM, '', 'NONSSL', false); ?>" method="get"> <?php echo zen_draw_hidden_field('main_page',FILENAME_GV_REDEEM) . zen_draw_hidden_field('goback','true') . zen_hide_session_id(); ?> <fieldset> <legend><?php echo TEXT_GV_REDEEM_INFO; ?></legend> <label class="inputLabel" for="lookup-gv-redeem"><?php echo TEXT_GV_REDEEM_ID; ?></label> <?php echo zen_draw_input_field('gv_no', $gv_faq_item, 'size="18" id="lookup-gv-redeem"');?> </fieldset> <div class="buttonRow forward"><?php echo zen_image_submit(BUTTON_IMAGE_REDEEM, BUTTON_REDEEM_ALT); ?></div> </form> </div>
{ "pile_set_name": "Github" }
from bootstrapvz.base import Task from bootstrapvz.common import phases from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import initd from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import rel_path from bootstrapvz.common.tools import sed_i import os import shutil ASSETS_DIR = rel_path(__file__, 'assets') class InstallGrowpart(Task): description = 'Adding necessary packages for growpart.' phase = phases.preparation predecessors = [apt.AddBackports] @classmethod def run(cls, info): # Use the cloud-guest-utils package from jessie-backports which has # several significant bug fixes from the mainline growpart script. target = None from bootstrapvz.common.releases import jessie if info.manifest.release == jessie: target = '{system.release}-backports' info.packages.add('cloud-guest-utils', target) class InstallExpandRootScripts(Task): description = 'Installing scripts for expand-root.' phase = phases.system_modification successors = [initd.InstallInitScripts] @classmethod def run(cls, info): expand_root_script = os.path.join(ASSETS_DIR, 'expand-root') expand_root_service = os.path.join(ASSETS_DIR, 'expand-root.service') expand_root_script_dest = os.path.join(info.root, 'usr/local/sbin/expand-root') expand_root_service_dest = os.path.join(info.root, 'etc/systemd/system/expand-root.service') filesystem_type = info.manifest.plugins['expand_root'].get('filesystem_type') root_device = info.manifest.plugins['expand_root'].get('root_device') root_partition = info.manifest.plugins['expand_root'].get('root_partition') # Copy files over shutil.copy(expand_root_script, expand_root_script_dest) os.chmod(expand_root_script_dest, 0o750) shutil.copy(expand_root_service, expand_root_service_dest) # Expand out options into expand-root script. opts = '%s %s %s' % (root_device, root_partition, filesystem_type) sed_i(expand_root_service_dest, r'^ExecStart=/usr/local/sbin/expand-root.*$', 'ExecStart=/usr/local/sbin/expand-root %s' % opts) # Enable systemd service log_check_call(['chroot', info.root, 'systemctl', 'enable', 'expand-root.service'])
{ "pile_set_name": "Github" }
#!/usr/bin/env python # # The JTAG Whisperer https://github.com/sowbug/JTAGWhisperer # Copyright 2012 Mike Tsao http://www.sowbug.com/ # # See LICENSE file for BSD-style licensing information. # import binascii from time import time import getopt import sys try: import serial except ImportError: print """ You don't have pyserial installed. Please install it and try again. "easy_install pyserial" or "pip install pyserial" will probably work. """ total_bytes_sent = 0 need_lf = False def send_xsvf_chunk(s, xsvf): global total_bytes_sent, need_lf if len(xsvf) == 0: print 'Problem: tried to send empty xsvf.' return xsvf chunk = xsvf[:32] xsvf = xsvf[len(chunk):] bytes_to_write = len(chunk) while bytes_to_write > 0: bytes_written = s.write(chunk) total_bytes_sent += bytes_written chunk = chunk[bytes_written:] bytes_to_write -= bytes_written print '\rSent: %8d bytes, %8d remaining' % (total_bytes_sent, len(xsvf)), need_lf = True sys.stdout.flush() return xsvf def get_xsvf_checksum(xsvf): xsvf_sum = 0 for c in xsvf: xsvf_sum += ord(c) return (xsvf_sum, len(xsvf)) def maybe_print_lf(): global need_lf if need_lf: need_lf = False print def program(xsvf_filename, port, bps): global total_bytes_sent start_time = 0 f = open(xsvf_filename, 'rb') xsvf = f.read() f.close() print 'Ready to send file of size %d bytes.' % (len(xsvf)) (xsvf_sum, xsvf_len) = get_xsvf_checksum(xsvf) s = serial.Serial(port=port, baudrate=bps, rtscts=True) s.flushInput() s.flushOutput() is_device_ready = False while True: line = s.readline().strip() if len(line) == 0: continue command = line[0] text = line[1:].strip() if command == 'R': if text == 'XSVF': if not is_device_ready: is_device_ready = True print 'Device is ready.' start_time = time() continue elif text == 'SEND': xsvf = send_xsvf_chunk(s, xsvf) continue else: print 'Unrecognized ready command:', text elif command == 'Q': maybe_print_lf() print 'Received device quit:', text break elif command == 'D': maybe_print_lf() print 'Device:', text elif command == '!': maybe_print_lf() print 'IMPORTANT:', text else: maybe_print_lf() print 'Unrecognized line:', line s.close() print 'Expected checksum: %lx/%lx.' % (xsvf_sum, xsvf_len) if start_time > 0: print 'Elapsed time: %.02f seconds.' % (time() - start_time) return 0 def usage(): print 'send_xsvf [-b bps] -p /dev/your_arduino_serial_port xsvf_filename' def main(): try: opts, args = getopt.getopt(sys.argv[1:], 'b:p:', ['bps=', 'port=']) except getopt.GetoptError, err: print str(err) usage() sys.exit(2) xsvf_filename = args[0] port = None bps = 115200 for o, a in opts: if o in ['-b', '--bps']: bps = int(a) elif o in ['-p', '--port']: port = a else: assert False, 'unhandled option' if port is None: usage() sys.exit(2) sys.exit(program(xsvf_filename, port, bps)) if __name__ == '__main__': main()
{ "pile_set_name": "Github" }
// SPDX-License-Identifier: GPL-2.0-or-later /* * Digital Audio (PCM) abstract layer * Copyright (c) by Jaroslav Kysela <perex@perex.cz> * Abramo Bagnara <abramo@alsa-project.org> */ #include <linux/slab.h> #include <linux/sched/signal.h> #include <linux/time.h> #include <linux/math64.h> #include <linux/export.h> #include <sound/core.h> #include <sound/control.h> #include <sound/tlv.h> #include <sound/info.h> #include <sound/pcm.h> #include <sound/pcm_params.h> #include <sound/timer.h> #include "pcm_local.h" #ifdef CONFIG_SND_PCM_XRUN_DEBUG #define CREATE_TRACE_POINTS #include "pcm_trace.h" #else #define trace_hwptr(substream, pos, in_interrupt) #define trace_xrun(substream) #define trace_hw_ptr_error(substream, reason) #define trace_applptr(substream, prev, curr) #endif static int fill_silence_frames(struct snd_pcm_substream *substream, snd_pcm_uframes_t off, snd_pcm_uframes_t frames); /* * fill ring buffer with silence * runtime->silence_start: starting pointer to silence area * runtime->silence_filled: size filled with silence * runtime->silence_threshold: threshold from application * runtime->silence_size: maximal size from application * * when runtime->silence_size >= runtime->boundary - fill processed area with silence immediately */ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t frames, ofs, transfer; int err; if (runtime->silence_size < runtime->boundary) { snd_pcm_sframes_t noise_dist, n; snd_pcm_uframes_t appl_ptr = READ_ONCE(runtime->control->appl_ptr); if (runtime->silence_start != appl_ptr) { n = appl_ptr - runtime->silence_start; if (n < 0) n += runtime->boundary; if ((snd_pcm_uframes_t)n < runtime->silence_filled) runtime->silence_filled -= n; else runtime->silence_filled = 0; runtime->silence_start = appl_ptr; } if (runtime->silence_filled >= runtime->buffer_size) return; noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silence_filled; if (noise_dist >= (snd_pcm_sframes_t) runtime->silence_threshold) return; frames = runtime->silence_threshold - noise_dist; if (frames > runtime->silence_size) frames = runtime->silence_size; } else { if (new_hw_ptr == ULONG_MAX) { /* initialization */ snd_pcm_sframes_t avail = snd_pcm_playback_hw_avail(runtime); if (avail > runtime->buffer_size) avail = runtime->buffer_size; runtime->silence_filled = avail > 0 ? avail : 0; runtime->silence_start = (runtime->status->hw_ptr + runtime->silence_filled) % runtime->boundary; } else { ofs = runtime->status->hw_ptr; frames = new_hw_ptr - ofs; if ((snd_pcm_sframes_t)frames < 0) frames += runtime->boundary; runtime->silence_filled -= frames; if ((snd_pcm_sframes_t)runtime->silence_filled < 0) { runtime->silence_filled = 0; runtime->silence_start = new_hw_ptr; } else { runtime->silence_start = ofs; } } frames = runtime->buffer_size - runtime->silence_filled; } if (snd_BUG_ON(frames > runtime->buffer_size)) return; if (frames == 0) return; ofs = runtime->silence_start % runtime->buffer_size; while (frames > 0) { transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames; err = fill_silence_frames(substream, ofs, transfer); snd_BUG_ON(err < 0); runtime->silence_filled += transfer; frames -= transfer; ofs = 0; } } #ifdef CONFIG_SND_DEBUG void snd_pcm_debug_name(struct snd_pcm_substream *substream, char *name, size_t len) { snprintf(name, len, "pcmC%dD%d%c:%d", substream->pcm->card->number, substream->pcm->device, substream->stream ? 'c' : 'p', substream->number); } EXPORT_SYMBOL(snd_pcm_debug_name); #endif #define XRUN_DEBUG_BASIC (1<<0) #define XRUN_DEBUG_STACK (1<<1) /* dump also stack */ #define XRUN_DEBUG_JIFFIESCHECK (1<<2) /* do jiffies check */ #ifdef CONFIG_SND_PCM_XRUN_DEBUG #define xrun_debug(substream, mask) \ ((substream)->pstr->xrun_debug & (mask)) #else #define xrun_debug(substream, mask) 0 #endif #define dump_stack_on_xrun(substream) do { \ if (xrun_debug(substream, XRUN_DEBUG_STACK)) \ dump_stack(); \ } while (0) /* call with stream lock held */ void __snd_pcm_xrun(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; trace_xrun(substream); if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { struct timespec64 tstamp; snd_pcm_gettime(runtime, &tstamp); runtime->status->tstamp.tv_sec = tstamp.tv_sec; runtime->status->tstamp.tv_nsec = tstamp.tv_nsec; } snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { char name[16]; snd_pcm_debug_name(substream, name, sizeof(name)); pcm_warn(substream->pcm, "XRUN: %s\n", name); dump_stack_on_xrun(substream); } } #ifdef CONFIG_SND_PCM_XRUN_DEBUG #define hw_ptr_error(substream, in_interrupt, reason, fmt, args...) \ do { \ trace_hw_ptr_error(substream, reason); \ if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { \ pr_err_ratelimited("ALSA: PCM: [%c] " reason ": " fmt, \ (in_interrupt) ? 'Q' : 'P', ##args); \ dump_stack_on_xrun(substream); \ } \ } while (0) #else /* ! CONFIG_SND_PCM_XRUN_DEBUG */ #define hw_ptr_error(substream, fmt, args...) do { } while (0) #endif int snd_pcm_update_state(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime) { snd_pcm_uframes_t avail; avail = snd_pcm_avail(substream); if (avail > runtime->avail_max) runtime->avail_max = avail; if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { if (avail >= runtime->buffer_size) { snd_pcm_drain_done(substream); return -EPIPE; } } else { if (avail >= runtime->stop_threshold) { __snd_pcm_xrun(substream); return -EPIPE; } } if (runtime->twake) { if (avail >= runtime->twake) wake_up(&runtime->tsleep); } else if (avail >= runtime->control->avail_min) wake_up(&runtime->sleep); return 0; } static void update_audio_tstamp(struct snd_pcm_substream *substream, struct timespec64 *curr_tstamp, struct timespec64 *audio_tstamp) { struct snd_pcm_runtime *runtime = substream->runtime; u64 audio_frames, audio_nsecs; struct timespec64 driver_tstamp; if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE) return; if (!(substream->ops->get_time_info) || (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) { /* * provide audio timestamp derived from pointer position * add delay only if requested */ audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr; if (runtime->audio_tstamp_config.report_delay) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) audio_frames -= runtime->delay; else audio_frames += runtime->delay; } audio_nsecs = div_u64(audio_frames * 1000000000LL, runtime->rate); *audio_tstamp = ns_to_timespec64(audio_nsecs); } if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec || runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) { runtime->status->audio_tstamp.tv_sec = audio_tstamp->tv_sec; runtime->status->audio_tstamp.tv_nsec = audio_tstamp->tv_nsec; runtime->status->tstamp.tv_sec = curr_tstamp->tv_sec; runtime->status->tstamp.tv_nsec = curr_tstamp->tv_nsec; } /* * re-take a driver timestamp to let apps detect if the reference tstamp * read by low-level hardware was provided with a delay */ snd_pcm_gettime(substream->runtime, &driver_tstamp); runtime->driver_tstamp = driver_tstamp; } static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, unsigned int in_interrupt) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t pos; snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; snd_pcm_sframes_t hdelta, delta; unsigned long jdelta; unsigned long curr_jiffies; struct timespec64 curr_tstamp; struct timespec64 audio_tstamp; int crossed_boundary = 0; old_hw_ptr = runtime->status->hw_ptr; /* * group pointer, time and jiffies reads to allow for more * accurate correlations/corrections. * The values are stored at the end of this routine after * corrections for hw_ptr position */ pos = substream->ops->pointer(substream); curr_jiffies = jiffies; if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { if ((substream->ops->get_time_info) && (runtime->audio_tstamp_config.type_requested != SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) { substream->ops->get_time_info(substream, &curr_tstamp, &audio_tstamp, &runtime->audio_tstamp_config, &runtime->audio_tstamp_report); /* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */ if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT) snd_pcm_gettime(runtime, &curr_tstamp); } else snd_pcm_gettime(runtime, &curr_tstamp); } if (pos == SNDRV_PCM_POS_XRUN) { __snd_pcm_xrun(substream); return -EPIPE; } if (pos >= runtime->buffer_size) { if (printk_ratelimit()) { char name[16]; snd_pcm_debug_name(substream, name, sizeof(name)); pcm_err(substream->pcm, "invalid position: %s, pos = %ld, buffer size = %ld, period size = %ld\n", name, pos, runtime->buffer_size, runtime->period_size); } pos = 0; } pos -= pos % runtime->min_align; trace_hwptr(substream, pos, in_interrupt); hw_base = runtime->hw_ptr_base; new_hw_ptr = hw_base + pos; if (in_interrupt) { /* we know that one period was processed */ /* delta = "expected next hw_ptr" for in_interrupt != 0 */ delta = runtime->hw_ptr_interrupt + runtime->period_size; if (delta > new_hw_ptr) { /* check for double acknowledged interrupts */ hdelta = curr_jiffies - runtime->hw_ptr_jiffies; if (hdelta > runtime->hw_ptr_buffer_jiffies/2 + 1) { hw_base += runtime->buffer_size; if (hw_base >= runtime->boundary) { hw_base = 0; crossed_boundary++; } new_hw_ptr = hw_base + pos; goto __delta; } } } /* new_hw_ptr might be lower than old_hw_ptr in case when */ /* pointer crosses the end of the ring buffer */ if (new_hw_ptr < old_hw_ptr) { hw_base += runtime->buffer_size; if (hw_base >= runtime->boundary) { hw_base = 0; crossed_boundary++; } new_hw_ptr = hw_base + pos; } __delta: delta = new_hw_ptr - old_hw_ptr; if (delta < 0) delta += runtime->boundary; if (runtime->no_period_wakeup) { snd_pcm_sframes_t xrun_threshold; /* * Without regular period interrupts, we have to check * the elapsed time to detect xruns. */ jdelta = curr_jiffies - runtime->hw_ptr_jiffies; if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) goto no_delta_check; hdelta = jdelta - delta * HZ / runtime->rate; xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; while (hdelta > xrun_threshold) { delta += runtime->buffer_size; hw_base += runtime->buffer_size; if (hw_base >= runtime->boundary) { hw_base = 0; crossed_boundary++; } new_hw_ptr = hw_base + pos; hdelta -= runtime->hw_ptr_buffer_jiffies; } goto no_delta_check; } /* something must be really wrong */ if (delta >= runtime->buffer_size + runtime->period_size) { hw_ptr_error(substream, in_interrupt, "Unexpected hw_ptr", "(stream=%i, pos=%ld, new_hw_ptr=%ld, old_hw_ptr=%ld)\n", substream->stream, (long)pos, (long)new_hw_ptr, (long)old_hw_ptr); return 0; } /* Do jiffies check only in xrun_debug mode */ if (!xrun_debug(substream, XRUN_DEBUG_JIFFIESCHECK)) goto no_jiffies_check; /* Skip the jiffies check for hardwares with BATCH flag. * Such hardware usually just increases the position at each IRQ, * thus it can't give any strange position. */ if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) goto no_jiffies_check; hdelta = delta; if (hdelta < runtime->delay) goto no_jiffies_check; hdelta -= runtime->delay; jdelta = curr_jiffies - runtime->hw_ptr_jiffies; if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { delta = jdelta / (((runtime->period_size * HZ) / runtime->rate) + HZ/100); /* move new_hw_ptr according jiffies not pos variable */ new_hw_ptr = old_hw_ptr; hw_base = delta; /* use loop to avoid checks for delta overflows */ /* the delta value is small or zero in most cases */ while (delta > 0) { new_hw_ptr += runtime->period_size; if (new_hw_ptr >= runtime->boundary) { new_hw_ptr -= runtime->boundary; crossed_boundary--; } delta--; } /* align hw_base to buffer_size */ hw_ptr_error(substream, in_interrupt, "hw_ptr skipping", "(pos=%ld, delta=%ld, period=%ld, jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n", (long)pos, (long)hdelta, (long)runtime->period_size, jdelta, ((hdelta * HZ) / runtime->rate), hw_base, (unsigned long)old_hw_ptr, (unsigned long)new_hw_ptr); /* reset values to proper state */ delta = 0; hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); } no_jiffies_check: if (delta > runtime->period_size + runtime->period_size / 2) { hw_ptr_error(substream, in_interrupt, "Lost interrupts?", "(stream=%i, delta=%ld, new_hw_ptr=%ld, old_hw_ptr=%ld)\n", substream->stream, (long)delta, (long)new_hw_ptr, (long)old_hw_ptr); } no_delta_check: if (runtime->status->hw_ptr == new_hw_ptr) { runtime->hw_ptr_jiffies = curr_jiffies; update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp); return 0; } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && runtime->silence_size > 0) snd_pcm_playback_silence(substream, new_hw_ptr); if (in_interrupt) { delta = new_hw_ptr - runtime->hw_ptr_interrupt; if (delta < 0) delta += runtime->boundary; delta -= (snd_pcm_uframes_t)delta % runtime->period_size; runtime->hw_ptr_interrupt += delta; if (runtime->hw_ptr_interrupt >= runtime->boundary) runtime->hw_ptr_interrupt -= runtime->boundary; } runtime->hw_ptr_base = hw_base; runtime->status->hw_ptr = new_hw_ptr; runtime->hw_ptr_jiffies = curr_jiffies; if (crossed_boundary) { snd_BUG_ON(crossed_boundary != 1); runtime->hw_ptr_wrap += runtime->boundary; } update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp); return snd_pcm_update_state(substream, runtime); } /* CAUTION: call it with irq disabled */ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) { return snd_pcm_update_hw_ptr0(substream, 0); } /** * snd_pcm_set_ops - set the PCM operators * @pcm: the pcm instance * @direction: stream direction, SNDRV_PCM_STREAM_XXX * @ops: the operator table * * Sets the given PCM operators to the pcm instance. */ void snd_pcm_set_ops(struct snd_pcm *pcm, int direction, const struct snd_pcm_ops *ops) { struct snd_pcm_str *stream = &pcm->streams[direction]; struct snd_pcm_substream *substream; for (substream = stream->substream; substream != NULL; substream = substream->next) substream->ops = ops; } EXPORT_SYMBOL(snd_pcm_set_ops); /** * snd_pcm_sync - set the PCM sync id * @substream: the pcm substream * * Sets the PCM sync identifier for the card. */ void snd_pcm_set_sync(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; runtime->sync.id32[0] = substream->pcm->card->number; runtime->sync.id32[1] = -1; runtime->sync.id32[2] = -1; runtime->sync.id32[3] = -1; } EXPORT_SYMBOL(snd_pcm_set_sync); /* * Standard ioctl routine */ static inline unsigned int div32(unsigned int a, unsigned int b, unsigned int *r) { if (b == 0) { *r = 0; return UINT_MAX; } *r = a % b; return a / b; } static inline unsigned int div_down(unsigned int a, unsigned int b) { if (b == 0) return UINT_MAX; return a / b; } static inline unsigned int div_up(unsigned int a, unsigned int b) { unsigned int r; unsigned int q; if (b == 0) return UINT_MAX; q = div32(a, b, &r); if (r) ++q; return q; } static inline unsigned int mul(unsigned int a, unsigned int b) { if (a == 0) return 0; if (div_down(UINT_MAX, a) < b) return UINT_MAX; return a * b; } static inline unsigned int muldiv32(unsigned int a, unsigned int b, unsigned int c, unsigned int *r) { u_int64_t n = (u_int64_t) a * b; if (c == 0) { *r = 0; return UINT_MAX; } n = div_u64_rem(n, c, r); if (n >= UINT_MAX) { *r = 0; return UINT_MAX; } return n; } /** * snd_interval_refine - refine the interval value of configurator * @i: the interval value to refine * @v: the interval value to refer to * * Refines the interval value with the reference value. * The interval is changed to the range satisfying both intervals. * The interval status (min, max, integer, etc.) are evaluated. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code. */ int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) { int changed = 0; if (snd_BUG_ON(snd_interval_empty(i))) return -EINVAL; if (i->min < v->min) { i->min = v->min; i->openmin = v->openmin; changed = 1; } else if (i->min == v->min && !i->openmin && v->openmin) { i->openmin = 1; changed = 1; } if (i->max > v->max) { i->max = v->max; i->openmax = v->openmax; changed = 1; } else if (i->max == v->max && !i->openmax && v->openmax) { i->openmax = 1; changed = 1; } if (!i->integer && v->integer) { i->integer = 1; changed = 1; } if (i->integer) { if (i->openmin) { i->min++; i->openmin = 0; } if (i->openmax) { i->max--; i->openmax = 0; } } else if (!i->openmin && !i->openmax && i->min == i->max) i->integer = 1; if (snd_interval_checkempty(i)) { snd_interval_none(i); return -EINVAL; } return changed; } EXPORT_SYMBOL(snd_interval_refine); static int snd_interval_refine_first(struct snd_interval *i) { const unsigned int last_max = i->max; if (snd_BUG_ON(snd_interval_empty(i))) return -EINVAL; if (snd_interval_single(i)) return 0; i->max = i->min; if (i->openmin) i->max++; /* only exclude max value if also excluded before refine */ i->openmax = (i->openmax && i->max >= last_max); return 1; } static int snd_interval_refine_last(struct snd_interval *i) { const unsigned int last_min = i->min; if (snd_BUG_ON(snd_interval_empty(i))) return -EINVAL; if (snd_interval_single(i)) return 0; i->min = i->max; if (i->openmax) i->min--; /* only exclude min value if also excluded before refine */ i->openmin = (i->openmin && i->min <= last_min); return 1; } void snd_interval_mul(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c) { if (a->empty || b->empty) { snd_interval_none(c); return; } c->empty = 0; c->min = mul(a->min, b->min); c->openmin = (a->openmin || b->openmin); c->max = mul(a->max, b->max); c->openmax = (a->openmax || b->openmax); c->integer = (a->integer && b->integer); } /** * snd_interval_div - refine the interval value with division * @a: dividend * @b: divisor * @c: quotient * * c = a / b * * Returns non-zero if the value is changed, zero if not changed. */ void snd_interval_div(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c) { unsigned int r; if (a->empty || b->empty) { snd_interval_none(c); return; } c->empty = 0; c->min = div32(a->min, b->max, &r); c->openmin = (r || a->openmin || b->openmax); if (b->min > 0) { c->max = div32(a->max, b->min, &r); if (r) { c->max++; c->openmax = 1; } else c->openmax = (a->openmax || b->openmin); } else { c->max = UINT_MAX; c->openmax = 0; } c->integer = 0; } /** * snd_interval_muldivk - refine the interval value * @a: dividend 1 * @b: dividend 2 * @k: divisor (as integer) * @c: result * * c = a * b / k * * Returns non-zero if the value is changed, zero if not changed. */ void snd_interval_muldivk(const struct snd_interval *a, const struct snd_interval *b, unsigned int k, struct snd_interval *c) { unsigned int r; if (a->empty || b->empty) { snd_interval_none(c); return; } c->empty = 0; c->min = muldiv32(a->min, b->min, k, &r); c->openmin = (r || a->openmin || b->openmin); c->max = muldiv32(a->max, b->max, k, &r); if (r) { c->max++; c->openmax = 1; } else c->openmax = (a->openmax || b->openmax); c->integer = 0; } /** * snd_interval_mulkdiv - refine the interval value * @a: dividend 1 * @k: dividend 2 (as integer) * @b: divisor * @c: result * * c = a * k / b * * Returns non-zero if the value is changed, zero if not changed. */ void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k, const struct snd_interval *b, struct snd_interval *c) { unsigned int r; if (a->empty || b->empty) { snd_interval_none(c); return; } c->empty = 0; c->min = muldiv32(a->min, k, b->max, &r); c->openmin = (r || a->openmin || b->openmax); if (b->min > 0) { c->max = muldiv32(a->max, k, b->min, &r); if (r) { c->max++; c->openmax = 1; } else c->openmax = (a->openmax || b->openmin); } else { c->max = UINT_MAX; c->openmax = 0; } c->integer = 0; } /* ---- */ /** * snd_interval_ratnum - refine the interval value * @i: interval to refine * @rats_count: number of ratnum_t * @rats: ratnum_t array * @nump: pointer to store the resultant numerator * @denp: pointer to store the resultant denominator * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code. */ int snd_interval_ratnum(struct snd_interval *i, unsigned int rats_count, const struct snd_ratnum *rats, unsigned int *nump, unsigned int *denp) { unsigned int best_num, best_den; int best_diff; unsigned int k; struct snd_interval t; int err; unsigned int result_num, result_den; int result_diff; best_num = best_den = best_diff = 0; for (k = 0; k < rats_count; ++k) { unsigned int num = rats[k].num; unsigned int den; unsigned int q = i->min; int diff; if (q == 0) q = 1; den = div_up(num, q); if (den < rats[k].den_min) continue; if (den > rats[k].den_max) den = rats[k].den_max; else { unsigned int r; r = (den - rats[k].den_min) % rats[k].den_step; if (r != 0) den -= r; } diff = num - q * den; if (diff < 0) diff = -diff; if (best_num == 0 || diff * best_den < best_diff * den) { best_diff = diff; best_den = den; best_num = num; } } if (best_den == 0) { i->empty = 1; return -EINVAL; } t.min = div_down(best_num, best_den); t.openmin = !!(best_num % best_den); result_num = best_num; result_diff = best_diff; result_den = best_den; best_num = best_den = best_diff = 0; for (k = 0; k < rats_count; ++k) { unsigned int num = rats[k].num; unsigned int den; unsigned int q = i->max; int diff; if (q == 0) { i->empty = 1; return -EINVAL; } den = div_down(num, q); if (den > rats[k].den_max) continue; if (den < rats[k].den_min) den = rats[k].den_min; else { unsigned int r; r = (den - rats[k].den_min) % rats[k].den_step; if (r != 0) den += rats[k].den_step - r; } diff = q * den - num; if (diff < 0) diff = -diff; if (best_num == 0 || diff * best_den < best_diff * den) { best_diff = diff; best_den = den; best_num = num; } } if (best_den == 0) { i->empty = 1; return -EINVAL; } t.max = div_up(best_num, best_den); t.openmax = !!(best_num % best_den); t.integer = 0; err = snd_interval_refine(i, &t); if (err < 0) return err; if (snd_interval_single(i)) { if (best_diff * result_den < result_diff * best_den) { result_num = best_num; result_den = best_den; } if (nump) *nump = result_num; if (denp) *denp = result_den; } return err; } EXPORT_SYMBOL(snd_interval_ratnum); /** * snd_interval_ratden - refine the interval value * @i: interval to refine * @rats_count: number of struct ratden * @rats: struct ratden array * @nump: pointer to store the resultant numerator * @denp: pointer to store the resultant denominator * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code. */ static int snd_interval_ratden(struct snd_interval *i, unsigned int rats_count, const struct snd_ratden *rats, unsigned int *nump, unsigned int *denp) { unsigned int best_num, best_diff, best_den; unsigned int k; struct snd_interval t; int err; best_num = best_den = best_diff = 0; for (k = 0; k < rats_count; ++k) { unsigned int num; unsigned int den = rats[k].den; unsigned int q = i->min; int diff; num = mul(q, den); if (num > rats[k].num_max) continue; if (num < rats[k].num_min) num = rats[k].num_max; else { unsigned int r; r = (num - rats[k].num_min) % rats[k].num_step; if (r != 0) num += rats[k].num_step - r; } diff = num - q * den; if (best_num == 0 || diff * best_den < best_diff * den) { best_diff = diff; best_den = den; best_num = num; } } if (best_den == 0) { i->empty = 1; return -EINVAL; } t.min = div_down(best_num, best_den); t.openmin = !!(best_num % best_den); best_num = best_den = best_diff = 0; for (k = 0; k < rats_count; ++k) { unsigned int num; unsigned int den = rats[k].den; unsigned int q = i->max; int diff; num = mul(q, den); if (num < rats[k].num_min) continue; if (num > rats[k].num_max) num = rats[k].num_max; else { unsigned int r; r = (num - rats[k].num_min) % rats[k].num_step; if (r != 0) num -= r; } diff = q * den - num; if (best_num == 0 || diff * best_den < best_diff * den) { best_diff = diff; best_den = den; best_num = num; } } if (best_den == 0) { i->empty = 1; return -EINVAL; } t.max = div_up(best_num, best_den); t.openmax = !!(best_num % best_den); t.integer = 0; err = snd_interval_refine(i, &t); if (err < 0) return err; if (snd_interval_single(i)) { if (nump) *nump = best_num; if (denp) *denp = best_den; } return err; } /** * snd_interval_list - refine the interval value from the list * @i: the interval value to refine * @count: the number of elements in the list * @list: the value list * @mask: the bit-mask to evaluate * * Refines the interval value from the list. * When mask is non-zero, only the elements corresponding to bit 1 are * evaluated. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code. */ int snd_interval_list(struct snd_interval *i, unsigned int count, const unsigned int *list, unsigned int mask) { unsigned int k; struct snd_interval list_range; if (!count) { i->empty = 1; return -EINVAL; } snd_interval_any(&list_range); list_range.min = UINT_MAX; list_range.max = 0; for (k = 0; k < count; k++) { if (mask && !(mask & (1 << k))) continue; if (!snd_interval_test(i, list[k])) continue; list_range.min = min(list_range.min, list[k]); list_range.max = max(list_range.max, list[k]); } return snd_interval_refine(i, &list_range); } EXPORT_SYMBOL(snd_interval_list); /** * snd_interval_ranges - refine the interval value from the list of ranges * @i: the interval value to refine * @count: the number of elements in the list of ranges * @ranges: the ranges list * @mask: the bit-mask to evaluate * * Refines the interval value from the list of ranges. * When mask is non-zero, only the elements corresponding to bit 1 are * evaluated. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code. */ int snd_interval_ranges(struct snd_interval *i, unsigned int count, const struct snd_interval *ranges, unsigned int mask) { unsigned int k; struct snd_interval range_union; struct snd_interval range; if (!count) { snd_interval_none(i); return -EINVAL; } snd_interval_any(&range_union); range_union.min = UINT_MAX; range_union.max = 0; for (k = 0; k < count; k++) { if (mask && !(mask & (1 << k))) continue; snd_interval_copy(&range, &ranges[k]); if (snd_interval_refine(&range, i) < 0) continue; if (snd_interval_empty(&range)) continue; if (range.min < range_union.min) { range_union.min = range.min; range_union.openmin = 1; } if (range.min == range_union.min && !range.openmin) range_union.openmin = 0; if (range.max > range_union.max) { range_union.max = range.max; range_union.openmax = 1; } if (range.max == range_union.max && !range.openmax) range_union.openmax = 0; } return snd_interval_refine(i, &range_union); } EXPORT_SYMBOL(snd_interval_ranges); static int snd_interval_step(struct snd_interval *i, unsigned int step) { unsigned int n; int changed = 0; n = i->min % step; if (n != 0 || i->openmin) { i->min += step - n; i->openmin = 0; changed = 1; } n = i->max % step; if (n != 0 || i->openmax) { i->max -= n; i->openmax = 0; changed = 1; } if (snd_interval_checkempty(i)) { i->empty = 1; return -EINVAL; } return changed; } /* Info constraints helpers */ /** * snd_pcm_hw_rule_add - add the hw-constraint rule * @runtime: the pcm runtime instance * @cond: condition bits * @var: the variable to evaluate * @func: the evaluation function * @private: the private data pointer passed to function * @dep: the dependent variables * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, int var, snd_pcm_hw_rule_func_t func, void *private, int dep, ...) { struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; struct snd_pcm_hw_rule *c; unsigned int k; va_list args; va_start(args, dep); if (constrs->rules_num >= constrs->rules_all) { struct snd_pcm_hw_rule *new; unsigned int new_rules = constrs->rules_all + 16; new = krealloc(constrs->rules, new_rules * sizeof(*c), GFP_KERNEL); if (!new) { va_end(args); return -ENOMEM; } constrs->rules = new; constrs->rules_all = new_rules; } c = &constrs->rules[constrs->rules_num]; c->cond = cond; c->func = func; c->var = var; c->private = private; k = 0; while (1) { if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) { va_end(args); return -EINVAL; } c->deps[k++] = dep; if (dep < 0) break; dep = va_arg(args, int); } constrs->rules_num++; va_end(args); return 0; } EXPORT_SYMBOL(snd_pcm_hw_rule_add); /** * snd_pcm_hw_constraint_mask - apply the given bitmap mask constraint * @runtime: PCM runtime instance * @var: hw_params variable to apply the mask * @mask: the bitmap mask * * Apply the constraint of the given bitmap mask to a 32-bit mask parameter. * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int32_t mask) { struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; struct snd_mask *maskp = constrs_mask(constrs, var); *maskp->bits &= mask; memset(maskp->bits + 1, 0, (SNDRV_MASK_MAX-32) / 8); /* clear rest */ if (*maskp->bits == 0) return -EINVAL; return 0; } /** * snd_pcm_hw_constraint_mask64 - apply the given bitmap mask constraint * @runtime: PCM runtime instance * @var: hw_params variable to apply the mask * @mask: the 64bit bitmap mask * * Apply the constraint of the given bitmap mask to a 64-bit mask parameter. * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int64_t mask) { struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; struct snd_mask *maskp = constrs_mask(constrs, var); maskp->bits[0] &= (u_int32_t)mask; maskp->bits[1] &= (u_int32_t)(mask >> 32); memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX-64) / 8); /* clear rest */ if (! maskp->bits[0] && ! maskp->bits[1]) return -EINVAL; return 0; } EXPORT_SYMBOL(snd_pcm_hw_constraint_mask64); /** * snd_pcm_hw_constraint_integer - apply an integer constraint to an interval * @runtime: PCM runtime instance * @var: hw_params variable to apply the integer constraint * * Apply the constraint of integer to an interval parameter. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code. */ int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var) { struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; return snd_interval_setinteger(constrs_interval(constrs, var)); } EXPORT_SYMBOL(snd_pcm_hw_constraint_integer); /** * snd_pcm_hw_constraint_minmax - apply a min/max range constraint to an interval * @runtime: PCM runtime instance * @var: hw_params variable to apply the range * @min: the minimal value * @max: the maximal value * * Apply the min/max range constraint to an interval parameter. * * Return: Positive if the value is changed, zero if it's not changed, or a * negative error code. */ int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, unsigned int min, unsigned int max) { struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; struct snd_interval t; t.min = min; t.max = max; t.openmin = t.openmax = 0; t.integer = 0; return snd_interval_refine(constrs_interval(constrs, var), &t); } EXPORT_SYMBOL(snd_pcm_hw_constraint_minmax); static int snd_pcm_hw_rule_list(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_pcm_hw_constraint_list *list = rule->private; return snd_interval_list(hw_param_interval(params, rule->var), list->count, list->list, list->mask); } /** * snd_pcm_hw_constraint_list - apply a list of constraints to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the list constraint * @l: list * * Apply the list of constraints to an interval parameter. * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, const struct snd_pcm_hw_constraint_list *l) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_list, (void *)l, var, -1); } EXPORT_SYMBOL(snd_pcm_hw_constraint_list); static int snd_pcm_hw_rule_ranges(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_pcm_hw_constraint_ranges *r = rule->private; return snd_interval_ranges(hw_param_interval(params, rule->var), r->count, r->ranges, r->mask); } /** * snd_pcm_hw_constraint_ranges - apply list of range constraints to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the list of range constraints * @r: ranges * * Apply the list of range constraints to an interval parameter. * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_ranges(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, const struct snd_pcm_hw_constraint_ranges *r) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_ranges, (void *)r, var, -1); } EXPORT_SYMBOL(snd_pcm_hw_constraint_ranges); static int snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { const struct snd_pcm_hw_constraint_ratnums *r = rule->private; unsigned int num = 0, den = 0; int err; err = snd_interval_ratnum(hw_param_interval(params, rule->var), r->nrats, r->rats, &num, &den); if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { params->rate_num = num; params->rate_den = den; } return err; } /** * snd_pcm_hw_constraint_ratnums - apply ratnums constraint to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the ratnums constraint * @r: struct snd_ratnums constriants * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, const struct snd_pcm_hw_constraint_ratnums *r) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_ratnums, (void *)r, var, -1); } EXPORT_SYMBOL(snd_pcm_hw_constraint_ratnums); static int snd_pcm_hw_rule_ratdens(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { const struct snd_pcm_hw_constraint_ratdens *r = rule->private; unsigned int num = 0, den = 0; int err = snd_interval_ratden(hw_param_interval(params, rule->var), r->nrats, r->rats, &num, &den); if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { params->rate_num = num; params->rate_den = den; } return err; } /** * snd_pcm_hw_constraint_ratdens - apply ratdens constraint to a parameter * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the ratdens constraint * @r: struct snd_ratdens constriants * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, const struct snd_pcm_hw_constraint_ratdens *r) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_ratdens, (void *)r, var, -1); } EXPORT_SYMBOL(snd_pcm_hw_constraint_ratdens); static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { unsigned int l = (unsigned long) rule->private; int width = l & 0xffff; unsigned int msbits = l >> 16; const struct snd_interval *i = hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); if (!snd_interval_single(i)) return 0; if ((snd_interval_value(i) == width) || (width == 0 && snd_interval_value(i) > msbits)) params->msbits = min_not_zero(params->msbits, msbits); return 0; } /** * snd_pcm_hw_constraint_msbits - add a hw constraint msbits rule * @runtime: PCM runtime instance * @cond: condition bits * @width: sample bits width * @msbits: msbits width * * This constraint will set the number of most significant bits (msbits) if a * sample format with the specified width has been select. If width is set to 0 * the msbits will be set for any sample format with a width larger than the * specified msbits. * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, unsigned int cond, unsigned int width, unsigned int msbits) { unsigned long l = (msbits << 16) | width; return snd_pcm_hw_rule_add(runtime, cond, -1, snd_pcm_hw_rule_msbits, (void*) l, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); } EXPORT_SYMBOL(snd_pcm_hw_constraint_msbits); static int snd_pcm_hw_rule_step(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { unsigned long step = (unsigned long) rule->private; return snd_interval_step(hw_param_interval(params, rule->var), step); } /** * snd_pcm_hw_constraint_step - add a hw constraint step rule * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the step constraint * @step: step size * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, unsigned long step) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_step, (void *) step, var, -1); } EXPORT_SYMBOL(snd_pcm_hw_constraint_step); static int snd_pcm_hw_rule_pow2(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { static const unsigned int pow2_sizes[] = { 1<<0, 1<<1, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6, 1<<7, 1<<8, 1<<9, 1<<10, 1<<11, 1<<12, 1<<13, 1<<14, 1<<15, 1<<16, 1<<17, 1<<18, 1<<19, 1<<20, 1<<21, 1<<22, 1<<23, 1<<24, 1<<25, 1<<26, 1<<27, 1<<28, 1<<29, 1<<30 }; return snd_interval_list(hw_param_interval(params, rule->var), ARRAY_SIZE(pow2_sizes), pow2_sizes, 0); } /** * snd_pcm_hw_constraint_pow2 - add a hw constraint power-of-2 rule * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the power-of-2 constraint * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_pow2, NULL, var, -1); } EXPORT_SYMBOL(snd_pcm_hw_constraint_pow2); static int snd_pcm_hw_rule_noresample_func(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { unsigned int base_rate = (unsigned int)(uintptr_t)rule->private; struct snd_interval *rate; rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); return snd_interval_list(rate, 1, &base_rate, 0); } /** * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling * @runtime: PCM runtime instance * @base_rate: the rate at which the hardware does not resample * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_hw_rule_noresample(struct snd_pcm_runtime *runtime, unsigned int base_rate) { return snd_pcm_hw_rule_add(runtime, SNDRV_PCM_HW_PARAMS_NORESAMPLE, SNDRV_PCM_HW_PARAM_RATE, snd_pcm_hw_rule_noresample_func, (void *)(uintptr_t)base_rate, SNDRV_PCM_HW_PARAM_RATE, -1); } EXPORT_SYMBOL(snd_pcm_hw_rule_noresample); static void _snd_pcm_hw_param_any(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { if (hw_is_mask(var)) { snd_mask_any(hw_param_mask(params, var)); params->cmask |= 1 << var; params->rmask |= 1 << var; return; } if (hw_is_interval(var)) { snd_interval_any(hw_param_interval(params, var)); params->cmask |= 1 << var; params->rmask |= 1 << var; return; } snd_BUG(); } void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params) { unsigned int k; memset(params, 0, sizeof(*params)); for (k = SNDRV_PCM_HW_PARAM_FIRST_MASK; k <= SNDRV_PCM_HW_PARAM_LAST_MASK; k++) _snd_pcm_hw_param_any(params, k); for (k = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++) _snd_pcm_hw_param_any(params, k); params->info = ~0U; } EXPORT_SYMBOL(_snd_pcm_hw_params_any); /** * snd_pcm_hw_param_value - return @params field @var value * @params: the hw_params instance * @var: parameter to retrieve * @dir: pointer to the direction (-1,0,1) or %NULL * * Return: The value for field @var if it's fixed in configuration space * defined by @params. -%EINVAL otherwise. */ int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { const struct snd_mask *mask = hw_param_mask_c(params, var); if (!snd_mask_single(mask)) return -EINVAL; if (dir) *dir = 0; return snd_mask_value(mask); } if (hw_is_interval(var)) { const struct snd_interval *i = hw_param_interval_c(params, var); if (!snd_interval_single(i)) return -EINVAL; if (dir) *dir = i->openmin; return snd_interval_value(i); } return -EINVAL; } EXPORT_SYMBOL(snd_pcm_hw_param_value); void _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { if (hw_is_mask(var)) { snd_mask_none(hw_param_mask(params, var)); params->cmask |= 1 << var; params->rmask |= 1 << var; } else if (hw_is_interval(var)) { snd_interval_none(hw_param_interval(params, var)); params->cmask |= 1 << var; params->rmask |= 1 << var; } else { snd_BUG(); } } EXPORT_SYMBOL(_snd_pcm_hw_param_setempty); static int _snd_pcm_hw_param_first(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed; if (hw_is_mask(var)) changed = snd_mask_refine_first(hw_param_mask(params, var)); else if (hw_is_interval(var)) changed = snd_interval_refine_first(hw_param_interval(params, var)); else return -EINVAL; if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } return changed; } /** * snd_pcm_hw_param_first - refine config space and return minimum value * @pcm: PCM instance * @params: the hw_params instance * @var: parameter to retrieve * @dir: pointer to the direction (-1,0,1) or %NULL * * Inside configuration space defined by @params remove from @var all * values > minimum. Reduce configuration space accordingly. * * Return: The minimum, or a negative error code on failure. */ int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { int changed = _snd_pcm_hw_param_first(params, var); if (changed < 0) return changed; if (params->rmask) { int err = snd_pcm_hw_refine(pcm, params); if (err < 0) return err; } return snd_pcm_hw_param_value(params, var, dir); } EXPORT_SYMBOL(snd_pcm_hw_param_first); static int _snd_pcm_hw_param_last(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed; if (hw_is_mask(var)) changed = snd_mask_refine_last(hw_param_mask(params, var)); else if (hw_is_interval(var)) changed = snd_interval_refine_last(hw_param_interval(params, var)); else return -EINVAL; if (changed > 0) { params->cmask |= 1 << var; params->rmask |= 1 << var; } return changed; } /** * snd_pcm_hw_param_last - refine config space and return maximum value * @pcm: PCM instance * @params: the hw_params instance * @var: parameter to retrieve * @dir: pointer to the direction (-1,0,1) or %NULL * * Inside configuration space defined by @params remove from @var all * values < maximum. Reduce configuration space accordingly. * * Return: The maximum, or a negative error code on failure. */ int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { int changed = _snd_pcm_hw_param_last(params, var); if (changed < 0) return changed; if (params->rmask) { int err = snd_pcm_hw_refine(pcm, params); if (err < 0) return err; } return snd_pcm_hw_param_value(params, var, dir); } EXPORT_SYMBOL(snd_pcm_hw_param_last); static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, void *arg) { struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; snd_pcm_stream_lock_irqsave(substream, flags); if (snd_pcm_running(substream) && snd_pcm_update_hw_ptr(substream) >= 0) runtime->status->hw_ptr %= runtime->buffer_size; else { runtime->status->hw_ptr = 0; runtime->hw_ptr_wrap = 0; } snd_pcm_stream_unlock_irqrestore(substream, flags); return 0; } static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream, void *arg) { struct snd_pcm_channel_info *info = arg; struct snd_pcm_runtime *runtime = substream->runtime; int width; if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) { info->offset = -1; return 0; } width = snd_pcm_format_physical_width(runtime->format); if (width < 0) return width; info->offset = 0; switch (runtime->access) { case SNDRV_PCM_ACCESS_MMAP_INTERLEAVED: case SNDRV_PCM_ACCESS_RW_INTERLEAVED: info->first = info->channel * width; info->step = runtime->channels * width; break; case SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED: case SNDRV_PCM_ACCESS_RW_NONINTERLEAVED: { size_t size = runtime->dma_bytes / runtime->channels; info->first = info->channel * size * 8; info->step = width; break; } default: snd_BUG(); break; } return 0; } static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, void *arg) { struct snd_pcm_hw_params *params = arg; snd_pcm_format_t format; int channels; ssize_t frame_size; params->fifo_size = substream->runtime->hw.fifo_size; if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { format = params_format(params); channels = params_channels(params); frame_size = snd_pcm_format_size(format, channels); if (frame_size > 0) params->fifo_size /= (unsigned)frame_size; } return 0; } /** * snd_pcm_lib_ioctl - a generic PCM ioctl callback * @substream: the pcm substream instance * @cmd: ioctl command * @arg: ioctl argument * * Processes the generic ioctl commands for PCM. * Can be passed as the ioctl callback for PCM ops. * * Return: Zero if successful, or a negative error code on failure. */ int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { switch (cmd) { case SNDRV_PCM_IOCTL1_RESET: return snd_pcm_lib_ioctl_reset(substream, arg); case SNDRV_PCM_IOCTL1_CHANNEL_INFO: return snd_pcm_lib_ioctl_channel_info(substream, arg); case SNDRV_PCM_IOCTL1_FIFO_SIZE: return snd_pcm_lib_ioctl_fifo_size(substream, arg); } return -ENXIO; } EXPORT_SYMBOL(snd_pcm_lib_ioctl); /** * snd_pcm_period_elapsed - update the pcm status for the next period * @substream: the pcm substream instance * * This function is called from the interrupt handler when the * PCM has processed the period size. It will update the current * pointer, wake up sleepers, etc. * * Even if more than one periods have elapsed since the last call, you * have to call this only once. */ void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime; unsigned long flags; if (snd_BUG_ON(!substream)) return; snd_pcm_stream_lock_irqsave(substream, flags); if (PCM_RUNTIME_CHECK(substream)) goto _unlock; runtime = substream->runtime; if (!snd_pcm_running(substream) || snd_pcm_update_hw_ptr0(substream, 1) < 0) goto _end; #ifdef CONFIG_SND_PCM_TIMER if (substream->timer_running) snd_timer_interrupt(substream->timer, 1); #endif _end: kill_fasync(&runtime->fasync, SIGIO, POLL_IN); _unlock: snd_pcm_stream_unlock_irqrestore(substream, flags); } EXPORT_SYMBOL(snd_pcm_period_elapsed); /* * Wait until avail_min data becomes available * Returns a negative error code if any error occurs during operation. * The available space is stored on availp. When err = 0 and avail = 0 * on the capture stream, it indicates the stream is in DRAINING state. */ static int wait_for_avail(struct snd_pcm_substream *substream, snd_pcm_uframes_t *availp) { struct snd_pcm_runtime *runtime = substream->runtime; int is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; wait_queue_entry_t wait; int err = 0; snd_pcm_uframes_t avail = 0; long wait_time, tout; init_waitqueue_entry(&wait, current); set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&runtime->tsleep, &wait); if (runtime->no_period_wakeup) wait_time = MAX_SCHEDULE_TIMEOUT; else { /* use wait time from substream if available */ if (substream->wait_time) { wait_time = substream->wait_time; } else { wait_time = 10; if (runtime->rate) { long t = runtime->period_size * 2 / runtime->rate; wait_time = max(t, wait_time); } wait_time = msecs_to_jiffies(wait_time * 1000); } } for (;;) { if (signal_pending(current)) { err = -ERESTARTSYS; break; } /* * We need to check if space became available already * (and thus the wakeup happened already) first to close * the race of space already having become available. * This check must happen after been added to the waitqueue * and having current state be INTERRUPTIBLE. */ avail = snd_pcm_avail(substream); if (avail >= runtime->twake) break; snd_pcm_stream_unlock_irq(substream); tout = schedule_timeout(wait_time); snd_pcm_stream_lock_irq(substream); set_current_state(TASK_INTERRUPTIBLE); switch (runtime->status->state) { case SNDRV_PCM_STATE_SUSPENDED: err = -ESTRPIPE; goto _endloop; case SNDRV_PCM_STATE_XRUN: err = -EPIPE; goto _endloop; case SNDRV_PCM_STATE_DRAINING: if (is_playback) err = -EPIPE; else avail = 0; /* indicate draining */ goto _endloop; case SNDRV_PCM_STATE_OPEN: case SNDRV_PCM_STATE_SETUP: case SNDRV_PCM_STATE_DISCONNECTED: err = -EBADFD; goto _endloop; case SNDRV_PCM_STATE_PAUSED: continue; } if (!tout) { pcm_dbg(substream->pcm, "%s write error (DMA or IRQ trouble?)\n", is_playback ? "playback" : "capture"); err = -EIO; break; } } _endloop: set_current_state(TASK_RUNNING); remove_wait_queue(&runtime->tsleep, &wait); *availp = avail; return err; } typedef int (*pcm_transfer_f)(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, void *buf, unsigned long bytes); typedef int (*pcm_copy_f)(struct snd_pcm_substream *, snd_pcm_uframes_t, void *, snd_pcm_uframes_t, snd_pcm_uframes_t, pcm_transfer_f); /* calculate the target DMA-buffer position to be written/read */ static void *get_dma_ptr(struct snd_pcm_runtime *runtime, int channel, unsigned long hwoff) { return runtime->dma_area + hwoff + channel * (runtime->dma_bytes / runtime->channels); } /* default copy_user ops for write; used for both interleaved and non- modes */ static int default_write_copy(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, void *buf, unsigned long bytes) { if (copy_from_user(get_dma_ptr(substream->runtime, channel, hwoff), (void __user *)buf, bytes)) return -EFAULT; return 0; } /* default copy_kernel ops for write */ static int default_write_copy_kernel(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, void *buf, unsigned long bytes) { memcpy(get_dma_ptr(substream->runtime, channel, hwoff), buf, bytes); return 0; } /* fill silence instead of copy data; called as a transfer helper * from __snd_pcm_lib_write() or directly from noninterleaved_copy() when * a NULL buffer is passed */ static int fill_silence(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, void *buf, unsigned long bytes) { struct snd_pcm_runtime *runtime = substream->runtime; if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return 0; if (substream->ops->fill_silence) return substream->ops->fill_silence(substream, channel, hwoff, bytes); snd_pcm_format_set_silence(runtime->format, get_dma_ptr(runtime, channel, hwoff), bytes_to_samples(runtime, bytes)); return 0; } /* default copy_user ops for read; used for both interleaved and non- modes */ static int default_read_copy(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, void *buf, unsigned long bytes) { if (copy_to_user((void __user *)buf, get_dma_ptr(substream->runtime, channel, hwoff), bytes)) return -EFAULT; return 0; } /* default copy_kernel ops for read */ static int default_read_copy_kernel(struct snd_pcm_substream *substream, int channel, unsigned long hwoff, void *buf, unsigned long bytes) { memcpy(buf, get_dma_ptr(substream->runtime, channel, hwoff), bytes); return 0; } /* call transfer function with the converted pointers and sizes; * for interleaved mode, it's one shot for all samples */ static int interleaved_copy(struct snd_pcm_substream *substream, snd_pcm_uframes_t hwoff, void *data, snd_pcm_uframes_t off, snd_pcm_uframes_t frames, pcm_transfer_f transfer) { struct snd_pcm_runtime *runtime = substream->runtime; /* convert to bytes */ hwoff = frames_to_bytes(runtime, hwoff); off = frames_to_bytes(runtime, off); frames = frames_to_bytes(runtime, frames); return transfer(substream, 0, hwoff, data + off, frames); } /* call transfer function with the converted pointers and sizes for each * non-interleaved channel; when buffer is NULL, silencing instead of copying */ static int noninterleaved_copy(struct snd_pcm_substream *substream, snd_pcm_uframes_t hwoff, void *data, snd_pcm_uframes_t off, snd_pcm_uframes_t frames, pcm_transfer_f transfer) { struct snd_pcm_runtime *runtime = substream->runtime; int channels = runtime->channels; void **bufs = data; int c, err; /* convert to bytes; note that it's not frames_to_bytes() here. * in non-interleaved mode, we copy for each channel, thus * each copy is n_samples bytes x channels = whole frames. */ off = samples_to_bytes(runtime, off); frames = samples_to_bytes(runtime, frames); hwoff = samples_to_bytes(runtime, hwoff); for (c = 0; c < channels; ++c, ++bufs) { if (!data || !*bufs) err = fill_silence(substream, c, hwoff, NULL, frames); else err = transfer(substream, c, hwoff, *bufs + off, frames); if (err < 0) return err; } return 0; } /* fill silence on the given buffer position; * called from snd_pcm_playback_silence() */ static int fill_silence_frames(struct snd_pcm_substream *substream, snd_pcm_uframes_t off, snd_pcm_uframes_t frames) { if (substream->runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || substream->runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) return interleaved_copy(substream, off, NULL, 0, frames, fill_silence); else return noninterleaved_copy(substream, off, NULL, 0, frames, fill_silence); } /* sanity-check for read/write methods */ static int pcm_sanity_check(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime; if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; runtime = substream->runtime; if (snd_BUG_ON(!substream->ops->copy_user && !runtime->dma_area)) return -EINVAL; if (runtime->status->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; return 0; } static int pcm_accessible_state(struct snd_pcm_runtime *runtime) { switch (runtime->status->state) { case SNDRV_PCM_STATE_PREPARED: case SNDRV_PCM_STATE_RUNNING: case SNDRV_PCM_STATE_PAUSED: return 0; case SNDRV_PCM_STATE_XRUN: return -EPIPE; case SNDRV_PCM_STATE_SUSPENDED: return -ESTRPIPE; default: return -EBADFD; } } /* update to the given appl_ptr and call ack callback if needed; * when an error is returned, take back to the original value */ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream, snd_pcm_uframes_t appl_ptr) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr; int ret; if (old_appl_ptr == appl_ptr) return 0; runtime->control->appl_ptr = appl_ptr; if (substream->ops->ack) { ret = substream->ops->ack(substream); if (ret < 0) { runtime->control->appl_ptr = old_appl_ptr; return ret; } } trace_applptr(substream, old_appl_ptr, appl_ptr); return 0; } /* the common loop for read/write data */ snd_pcm_sframes_t __snd_pcm_lib_xfer(struct snd_pcm_substream *substream, void *data, bool interleaved, snd_pcm_uframes_t size, bool in_kernel) { struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t xfer = 0; snd_pcm_uframes_t offset = 0; snd_pcm_uframes_t avail; pcm_copy_f writer; pcm_transfer_f transfer; bool nonblock; bool is_playback; int err; err = pcm_sanity_check(substream); if (err < 0) return err; is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; if (interleaved) { if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && runtime->channels > 1) return -EINVAL; writer = interleaved_copy; } else { if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) return -EINVAL; writer = noninterleaved_copy; } if (!data) { if (is_playback) transfer = fill_silence; else return -EINVAL; } else if (in_kernel) { if (substream->ops->copy_kernel) transfer = substream->ops->copy_kernel; else transfer = is_playback ? default_write_copy_kernel : default_read_copy_kernel; } else { if (substream->ops->copy_user) transfer = (pcm_transfer_f)substream->ops->copy_user; else transfer = is_playback ? default_write_copy : default_read_copy; } if (size == 0) return 0; nonblock = !!(substream->f_flags & O_NONBLOCK); snd_pcm_stream_lock_irq(substream); err = pcm_accessible_state(runtime); if (err < 0) goto _end_unlock; runtime->twake = runtime->control->avail_min ? : 1; if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) snd_pcm_update_hw_ptr(substream); /* * If size < start_threshold, wait indefinitely. Another * thread may start capture */ if (!is_playback && runtime->status->state == SNDRV_PCM_STATE_PREPARED && size >= runtime->start_threshold) { err = snd_pcm_start(substream); if (err < 0) goto _end_unlock; } avail = snd_pcm_avail(substream); while (size > 0) { snd_pcm_uframes_t frames, appl_ptr, appl_ofs; snd_pcm_uframes_t cont; if (!avail) { if (!is_playback && runtime->status->state == SNDRV_PCM_STATE_DRAINING) { snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); goto _end_unlock; } if (nonblock) { err = -EAGAIN; goto _end_unlock; } runtime->twake = min_t(snd_pcm_uframes_t, size, runtime->control->avail_min ? : 1); err = wait_for_avail(substream, &avail); if (err < 0) goto _end_unlock; if (!avail) continue; /* draining */ } frames = size > avail ? avail : size; appl_ptr = READ_ONCE(runtime->control->appl_ptr); appl_ofs = appl_ptr % runtime->buffer_size; cont = runtime->buffer_size - appl_ofs; if (frames > cont) frames = cont; if (snd_BUG_ON(!frames)) { err = -EINVAL; goto _end_unlock; } snd_pcm_stream_unlock_irq(substream); err = writer(substream, appl_ofs, data, offset, frames, transfer); snd_pcm_stream_lock_irq(substream); if (err < 0) goto _end_unlock; err = pcm_accessible_state(runtime); if (err < 0) goto _end_unlock; appl_ptr += frames; if (appl_ptr >= runtime->boundary) appl_ptr -= runtime->boundary; err = pcm_lib_apply_appl_ptr(substream, appl_ptr); if (err < 0) goto _end_unlock; offset += frames; size -= frames; xfer += frames; avail -= frames; if (is_playback && runtime->status->state == SNDRV_PCM_STATE_PREPARED && snd_pcm_playback_hw_avail(runtime) >= (snd_pcm_sframes_t)runtime->start_threshold) { err = snd_pcm_start(substream); if (err < 0) goto _end_unlock; } } _end_unlock: runtime->twake = 0; if (xfer > 0 && err >= 0) snd_pcm_update_state(substream, runtime); snd_pcm_stream_unlock_irq(substream); return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; } EXPORT_SYMBOL(__snd_pcm_lib_xfer); /* * standard channel mapping helpers */ /* default channel maps for multi-channel playbacks, up to 8 channels */ const struct snd_pcm_chmap_elem snd_pcm_std_chmaps[] = { { .channels = 1, .map = { SNDRV_CHMAP_MONO } }, { .channels = 2, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, { .channels = 4, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, { .channels = 6, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_RL, SNDRV_CHMAP_RR, SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE } }, { .channels = 8, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_RL, SNDRV_CHMAP_RR, SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE, SNDRV_CHMAP_SL, SNDRV_CHMAP_SR } }, { } }; EXPORT_SYMBOL_GPL(snd_pcm_std_chmaps); /* alternative channel maps with CLFE <-> surround swapped for 6/8 channels */ const struct snd_pcm_chmap_elem snd_pcm_alt_chmaps[] = { { .channels = 1, .map = { SNDRV_CHMAP_MONO } }, { .channels = 2, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } }, { .channels = 4, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, { .channels = 6, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE, SNDRV_CHMAP_RL, SNDRV_CHMAP_RR } }, { .channels = 8, .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE, SNDRV_CHMAP_RL, SNDRV_CHMAP_RR, SNDRV_CHMAP_SL, SNDRV_CHMAP_SR } }, { } }; EXPORT_SYMBOL_GPL(snd_pcm_alt_chmaps); static bool valid_chmap_channels(const struct snd_pcm_chmap *info, int ch) { if (ch > info->max_channels) return false; return !info->channel_mask || (info->channel_mask & (1U << ch)); } static int pcm_chmap_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = info->max_channels; uinfo->value.integer.min = 0; uinfo->value.integer.max = SNDRV_CHMAP_LAST; return 0; } /* get callback for channel map ctl element * stores the channel position firstly matching with the current channels */ static int pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); struct snd_pcm_substream *substream; const struct snd_pcm_chmap_elem *map; if (!info->chmap) return -EINVAL; substream = snd_pcm_chmap_substream(info, idx); if (!substream) return -ENODEV; memset(ucontrol->value.integer.value, 0, sizeof(long) * info->max_channels); if (!substream->runtime) return 0; /* no channels set */ for (map = info->chmap; map->channels; map++) { int i; if (map->channels == substream->runtime->channels && valid_chmap_channels(info, map->channels)) { for (i = 0; i < map->channels; i++) ucontrol->value.integer.value[i] = map->map[i]; return 0; } } return -EINVAL; } /* tlv callback for channel map ctl element * expands the pre-defined channel maps in a form of TLV */ static int pcm_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag, unsigned int size, unsigned int __user *tlv) { struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); const struct snd_pcm_chmap_elem *map; unsigned int __user *dst; int c, count = 0; if (!info->chmap) return -EINVAL; if (size < 8) return -ENOMEM; if (put_user(SNDRV_CTL_TLVT_CONTAINER, tlv)) return -EFAULT; size -= 8; dst = tlv + 2; for (map = info->chmap; map->channels; map++) { int chs_bytes = map->channels * 4; if (!valid_chmap_channels(info, map->channels)) continue; if (size < 8) return -ENOMEM; if (put_user(SNDRV_CTL_TLVT_CHMAP_FIXED, dst) || put_user(chs_bytes, dst + 1)) return -EFAULT; dst += 2; size -= 8; count += 8; if (size < chs_bytes) return -ENOMEM; size -= chs_bytes; count += chs_bytes; for (c = 0; c < map->channels; c++) { if (put_user(map->map[c], dst)) return -EFAULT; dst++; } } if (put_user(count, tlv + 1)) return -EFAULT; return 0; } static void pcm_chmap_ctl_private_free(struct snd_kcontrol *kcontrol) { struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol); info->pcm->streams[info->stream].chmap_kctl = NULL; kfree(info); } /** * snd_pcm_add_chmap_ctls - create channel-mapping control elements * @pcm: the assigned PCM instance * @stream: stream direction * @chmap: channel map elements (for query) * @max_channels: the max number of channels for the stream * @private_value: the value passed to each kcontrol's private_value field * @info_ret: store struct snd_pcm_chmap instance if non-NULL * * Create channel-mapping control elements assigned to the given PCM stream(s). * Return: Zero if successful, or a negative error value. */ int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, const struct snd_pcm_chmap_elem *chmap, int max_channels, unsigned long private_value, struct snd_pcm_chmap **info_ret) { struct snd_pcm_chmap *info; struct snd_kcontrol_new knew = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, .info = pcm_chmap_ctl_info, .get = pcm_chmap_ctl_get, .tlv.c = pcm_chmap_ctl_tlv, }; int err; if (WARN_ON(pcm->streams[stream].chmap_kctl)) return -EBUSY; info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; info->pcm = pcm; info->stream = stream; info->chmap = chmap; info->max_channels = max_channels; if (stream == SNDRV_PCM_STREAM_PLAYBACK) knew.name = "Playback Channel Map"; else knew.name = "Capture Channel Map"; knew.device = pcm->device; knew.count = pcm->streams[stream].substream_count; knew.private_value = private_value; info->kctl = snd_ctl_new1(&knew, info); if (!info->kctl) { kfree(info); return -ENOMEM; } info->kctl->private_free = pcm_chmap_ctl_private_free; err = snd_ctl_add(pcm->card, info->kctl); if (err < 0) return err; pcm->streams[stream].chmap_kctl = info->kctl; if (info_ret) *info_ret = info; return 0; } EXPORT_SYMBOL_GPL(snd_pcm_add_chmap_ctls);
{ "pile_set_name": "Github" }
SET(COIN_ROOT_DIR "" CACHE PATH "COIN root directory") FIND_PATH(COIN_INCLUDE_DIR coin/CoinUtilsConfig.h HINTS ${COIN_ROOT_DIR}/include ) FIND_LIBRARY(COIN_CBC_LIBRARY NAMES Cbc libCbc HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_CBC_SOLVER_LIBRARY NAMES CbcSolver libCbcSolver HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_CGL_LIBRARY NAMES Cgl libCgl HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_CLP_LIBRARY NAMES Clp libClp HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_COIN_UTILS_LIBRARY NAMES CoinUtils libCoinUtils HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_OSI_LIBRARY NAMES Osi libOsi HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_OSI_CBC_LIBRARY NAMES OsiCbc libOsiCbc HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_OSI_CLP_LIBRARY NAMES OsiClp libOsiClp HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_OSI_VOL_LIBRARY NAMES OsiVol libOsiVol HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_VOL_LIBRARY NAMES Vol libVol HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_ZLIB_LIBRARY NAMES z libz HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) FIND_LIBRARY(COIN_BZ2_LIBRARY NAMES bz2 libbz2 HINTS ${COIN_ROOT_DIR}/lib/coin HINTS ${COIN_ROOT_DIR}/lib ) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG COIN_INCLUDE_DIR COIN_CBC_LIBRARY COIN_CBC_SOLVER_LIBRARY COIN_CGL_LIBRARY COIN_CLP_LIBRARY COIN_COIN_UTILS_LIBRARY COIN_OSI_LIBRARY COIN_OSI_CBC_LIBRARY COIN_OSI_CLP_LIBRARY # COIN_OSI_VOL_LIBRARY # COIN_VOL_LIBRARY ) IF(COIN_FOUND) SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR}) SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY}") IF(COIN_ZLIB_LIBRARY) SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_ZLIB_LIBRARY}") ENDIF(COIN_ZLIB_LIBRARY) IF(COIN_BZ2_LIBRARY) SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_BZ2_LIBRARY}") ENDIF(COIN_BZ2_LIBRARY) SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY};${COIN_CLP_LIBRARIES}") SET(COIN_LIBRARIES ${COIN_CBC_LIBRARIES}) ENDIF(COIN_FOUND) MARK_AS_ADVANCED( COIN_INCLUDE_DIR COIN_CBC_LIBRARY COIN_CBC_SOLVER_LIBRARY COIN_CGL_LIBRARY COIN_CLP_LIBRARY COIN_COIN_UTILS_LIBRARY COIN_OSI_LIBRARY COIN_OSI_CBC_LIBRARY COIN_OSI_CLP_LIBRARY COIN_OSI_VOL_LIBRARY COIN_VOL_LIBRARY COIN_ZLIB_LIBRARY COIN_BZ2_LIBRARY )
{ "pile_set_name": "Github" }
/****************************************************************************** * * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license. * * GPL LICENSE SUMMARY * * Copyright(c) 2017 Intel Deutschland GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * The full GNU General Public License is included in this distribution * in the file called COPYING. * * Contact Information: * Intel Linux Wireless <linuxwifi@intel.com> * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * * BSD LICENSE * * Copyright(c) 2017 Intel Deutschland GmbH * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name Intel Corporation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ #include "iwl-drv.h" #include "runtime.h" #include "dbg.h" #include "debugfs.h" void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans, const struct iwl_fw *fw, const struct iwl_fw_runtime_ops *ops, void *ops_ctx, struct dentry *dbgfs_dir) { memset(fwrt, 0, sizeof(*fwrt)); fwrt->trans = trans; fwrt->fw = fw; fwrt->dev = trans->dev; fwrt->dump.conf = FW_DBG_INVALID; fwrt->ops = ops; fwrt->ops_ctx = ops_ctx; INIT_DELAYED_WORK(&fwrt->dump.wk, iwl_fw_error_dump_wk); iwl_fwrt_dbgfs_register(fwrt, dbgfs_dir); } IWL_EXPORT_SYMBOL(iwl_fw_runtime_init); void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt) { iwl_fw_suspend_timestamp(fwrt); } IWL_EXPORT_SYMBOL(iwl_fw_runtime_suspend); void iwl_fw_runtime_resume(struct iwl_fw_runtime *fwrt) { iwl_fw_resume_timestamp(fwrt); } IWL_EXPORT_SYMBOL(iwl_fw_runtime_resume);
{ "pile_set_name": "Github" }
// Copyright ©2017 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gonum import "gonum.org/v1/gonum/blas" // Dgerq2 computes an RQ factorization of the m×n matrix A, // A = R * Q. // On exit, if m <= n, the upper triangle of the subarray // A[0:m, n-m:n] contains the m×m upper triangular matrix R. // If m >= n, the elements on and above the (m-n)-th subdiagonal // contain the m×n upper trapezoidal matrix R. // The remaining elements, with tau, represent the // orthogonal matrix Q as a product of min(m,n) elementary // reflectors. // // The matrix Q is represented as a product of elementary reflectors // Q = H_0 H_1 . . . H_{min(m,n)-1}. // Each H(i) has the form // H_i = I - tau_i * v * vᵀ // where v is a vector with v[0:n-k+i-1] stored in A[m-k+i, 0:n-k+i-1], // v[n-k+i:n] = 0 and v[n-k+i] = 1. // // tau must have length min(m,n) and work must have length m, otherwise // Dgerq2 will panic. // // Dgerq2 is an internal routine. It is exported for testing purposes. func (impl Implementation) Dgerq2(m, n int, a []float64, lda int, tau, work []float64) { switch { case m < 0: panic(mLT0) case n < 0: panic(nLT0) case lda < max(1, n): panic(badLdA) case len(work) < m: panic(shortWork) } // Quick return if possible. k := min(m, n) if k == 0 { return } switch { case len(a) < (m-1)*lda+n: panic(shortA) case len(tau) < k: panic(shortTau) } for i := k - 1; i >= 0; i-- { // Generate elementary reflector H[i] to annihilate // A[m-k+i, 0:n-k+i-1]. mki := m - k + i nki := n - k + i var aii float64 aii, tau[i] = impl.Dlarfg(nki+1, a[mki*lda+nki], a[mki*lda:], 1) // Apply H[i] to A[0:m-k+i-1, 0:n-k+i] from the right. a[mki*lda+nki] = 1 impl.Dlarf(blas.Right, mki, nki+1, a[mki*lda:], 1, tau[i], a, lda, work) a[mki*lda+nki] = aii } }
{ "pile_set_name": "Github" }
// RUN: %clang_cc1 -fsyntax-only -verify %s void* my_malloc(unsigned char) __attribute__((alloc_size(1))); void* my_calloc(unsigned char, short) __attribute__((alloc_size(1,2))); void* my_realloc(void*, unsigned) __attribute__((alloc_size(2))); void* fn1(int) __attribute__((alloc_size("xpto"))); // expected-error{{attribute requires integer constant}} void* fn2(void*) __attribute__((alloc_size(1))); // expected-error{{attribute requires integer constant}} void* fn3(unsigned) __attribute__((alloc_size(0))); // expected-error{{attribute parameter 1 is out of bounds}} void* fn4(unsigned) __attribute__((alloc_size(2))); // expected-error{{attribute parameter 1 is out of bounds}} void fn5(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}} char fn6(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}} void* fn7(unsigned) __attribute__((alloc_size)); // expected-error {{attribute takes at least 1 argument}} void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-warning {{integer constant is too large for its type}} // expected-error {{attribute parameter 1 is out of bounds}} void* fn10(size_t, size_t) __attribute__((alloc_size(1,2))); // expected-error{{redefinition of parameter}} \ // expected-error{{a parameter list without types is only allowed in a function definition}} \ // expected-warning{{alloc_size attribute only applies to functions and methods}}
{ "pile_set_name": "Github" }
bebb998e1104c844b4a55a52b8552549
{ "pile_set_name": "Github" }
/********************************************************************************* * * * The MIT License (MIT) * * * * Copyright (c) 2015-2020 aoju.org and other contributors. * * * * 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. * ********************************************************************************/ package org.aoju.bus.forest.complex; import org.aoju.bus.forest.Complex; import java.util.Collection; /** * ANY逻辑混合规则,即任意一个规则满足时就满足, * 当没有规则的时候,就是不满足 * * @author Kimi Liu * @version 6.1.0 * @since JDK 1.8+ */ public class AnyComplex<E> extends MixComplex<E> implements Complex<E> { public AnyComplex() { super(null); } public AnyComplex(Collection<? extends Complex<? extends E>> filters) { super(filters); } @Override public AnyComplex<E> mix(Complex<? extends E> filter) { add(filter); return this; } @Override public boolean on(E entry) { Complex[] filters = this.filters.toArray(new Complex[0]); for (Complex filter : filters) { if (filter.on(entry)) { return true; } } return false; } }
{ "pile_set_name": "Github" }
fileFormatVersion: 2 guid: b28f133eeb1a34b4b9ff1529e712b2bc folderAsset: yes timeCreated: 1445422081 licenseType: Free DefaultImporter: userData: assetBundleName: assetBundleVariant:
{ "pile_set_name": "Github" }
rule m2319_358b7ac1c4000b32 { meta: copyright="Copyright (c) 2014-2018 Support Intelligence Inc, All Rights Reserved." engine="saphire/1.3.8 divinorum/0.9992 icewater/0.4" viz_url="http://icewater.io/en/cluster/query?h64=m2319.358b7ac1c4000b32" cluster="m2319.358b7ac1c4000b32" cluster_size="7" filetype = "" tlp = "amber" version = "icewater snowflake" author = "Rick Wesson (@wessorh) rick@support-intelligence.com" date = "20180910" license = "RIL-1.0 [Rick's Internet License]" family="fakejquery script trojandownloader" md5_hashes="['74724d04e95ac07c9086579cb9299326f72d64e0','5b467f7880f0c7cf213f9a23a878232e12ece74e','f6633de8ce1434e8cfb179b426c7cb49d059901e']" cluster_members="http://icewater.io/en/cluster/detail?h64=m2319.358b7ac1c4000b32" strings: $hex_string = { 746d702f696e7374616c6c5f346466653566333565633333362f64756d702e70687029205b3c6120687265663d2766756e6374696f6e2e696e636c756465273e } condition: filesize > 65536 and filesize < 262144 and $hex_string }
{ "pile_set_name": "Github" }
package main func mulGood(xs []int) int { res := 1 for i := 0; i < len(xs); i++ { x := xs[i] res *= x if res == 0 { return 0 } } return res }
{ "pile_set_name": "Github" }
# Copyright 2012 Mozilla Foundation # # 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. # Main toolbar buttons (tooltips and alt text for images) previous.title=Páxina anterior previous_label=Anterior next.title=Páxina siguiente next_label=Siguiente # LOCALIZATION NOTE (page.title): The tooltip for the pageNumber input. page.title=Páxina # LOCALIZATION NOTE (of_pages): "{{pagesCount}}" will be replaced by a number # representing the total number of pages in the document. of_pages=de {{pagesCount}} # LOCALIZATION NOTE (page_of_pages): "{{pageNumber}}" and "{{pagesCount}}" # will be replaced by a number representing the currently visible page, # respectively a number representing the total number of pages in the document. page_of_pages=({{pageNumber}} de {{pagesCount}}) zoom_out.title=Reducir zoom_out_label=Reducir zoom_in.title=Aumentar zoom_in_label=Aumentar zoom.title=Tamañu presentation_mode.title= presentation_mode_label= open_file.title=Abrir ficheru open_file_label=Abrir print.title=Imprentar print_label=Imprentar download.title=Descargar download_label=Descargar bookmark.title=Vista actual (copiar o abrir nuna nueva ventana) bookmark_label=Vista actual # Secondary toolbar and context menu tools.title=Ferramientes tools_label=Ferramientes first_page.title=Dir a la primer páxina first_page.label=Dir a la primer páxina first_page_label=Dir a la primer páxina last_page.title=Dir a la postrer páxina last_page.label=Dir a la cabera páxina last_page_label=Dir a la postrer páxina page_rotate_cw.title=Xirar en sen horariu page_rotate_cw.label= page_rotate_cw_label=Xirar en sen horariu page_rotate_ccw.title=Xirar en sen antihorariu page_rotate_ccw.label= page_rotate_ccw_label=Xirar en sen antihorariu # Document properties dialog box document_properties.title=Propiedaes del documentu… document_properties_label=Propiedaes del documentu… document_properties_file_name=Nome de ficheru: document_properties_file_size=Tamañu de ficheru: # LOCALIZATION NOTE (document_properties_kb): "{{size_kb}}" and "{{size_b}}" # will be replaced by the PDF file size in kilobytes, respectively in bytes. document_properties_kb={{size_kb}} KB ({{size_b}} bytes) # LOCALIZATION NOTE (document_properties_mb): "{{size_mb}}" and "{{size_b}}" # will be replaced by the PDF file size in megabytes, respectively in bytes. document_properties_mb={{size_mb}} MB ({{size_b}} bytes) document_properties_title=Títulu: document_properties_author=Autor: document_properties_subject=Asuntu: document_properties_keywords=Pallabres clave: document_properties_creation_date=Data de creación: document_properties_modification_date=Data de modificación: # LOCALIZATION NOTE (document_properties_date_string): "{{date}}" and "{{time}}" # will be replaced by the creation/modification date, and time, of the PDF file. document_properties_date_string={{date}}, {{time}} document_properties_creator=Creador: document_properties_producer=Productor PDF: document_properties_version=Versión PDF: document_properties_page_count=Númberu de páxines: document_properties_close=Zarrar print_progress_message=Tresnando documentu pa imprentar… # LOCALIZATION NOTE (print_progress_percent): "{{progress}}" will be replaced by # a numerical per cent value. print_progress_percent={{progress}}% print_progress_close=Encaboxar # Tooltips and alt text for side panel toolbar buttons # (the _label strings are alt text for the buttons, the .title strings are # tooltips) toggle_sidebar.title=Camudar barra llateral toggle_sidebar_label=Camudar barra llateral document_outline.title=Amosar esquema del documentu (duble clic pa espander/contrayer tolos elementos) document_outline_label=Esquema del documentu attachments.title=Amosar axuntos attachments_label=Axuntos thumbs.title=Amosar miniatures thumbs_label=Miniatures findbar.title=Guetar nel documentu findbar_label=Guetar # Thumbnails panel item (tooltip and alt text for images) # LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page # number. thumb_page_title=Páxina {{page}} # LOCALIZATION NOTE (thumb_page_canvas): "{{page}}" will be replaced by the page # number. thumb_page_canvas=Miniatura de la páxina {{page}} # Find panel button title and messages find_previous.title=Alcontrar l'anterior apaición de la fras find_previous_label=Anterior find_next.title=Alcontrar la siguiente apaición d'esta fras find_next_label=Siguiente find_highlight=Remarcar toos find_match_case_label=Coincidencia de mayús./minús. find_reached_top=Algamóse'l principiu del documentu, siguir dende'l final find_reached_bottom=Algamóse'l final del documentu, siguir dende'l principiu find_not_found=Frase non atopada # Error panel labels error_more_info=Más información error_less_info=Menos información error_close=Zarrar # LOCALIZATION NOTE (error_version_info): "{{version}}" and "{{build}}" will be # replaced by the PDF.JS version and build ID. error_version_info=PDF.js v{{version}} (build: {{build}}) # LOCALIZATION NOTE (error_message): "{{message}}" will be replaced by an # english string describing the error. error_message=Mensaxe: {{message}} # LOCALIZATION NOTE (error_stack): "{{stack}}" will be replaced with a stack # trace. error_stack=Pila: {{stack}} # LOCALIZATION NOTE (error_file): "{{file}}" will be replaced with a filename error_file=Ficheru: {{file}} # LOCALIZATION NOTE (error_line): "{{line}}" will be replaced with a line number error_line=Llinia: {{line}} rendering_error=Hebo un fallu al renderizar la páxina. # Predefined zoom values page_scale_width=Anchor de la páxina page_scale_fit=Axuste de la páxina page_scale_auto=Tamañu automáticu page_scale_actual=Tamañu actual # LOCALIZATION NOTE (page_scale_percent): "{{scale}}" will be replaced by a # numerical scale value. page_scale_percent={{scale}}% # Loading indicator messages loading_error_indicator=Fallu loading_error=Hebo un fallu al cargar el PDF. invalid_file_error=Ficheru PDF inválidu o corruptu. missing_file_error=Nun hai ficheru PDF. unexpected_response_error=Rempuesta inesperada del sirvidor. # LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip. # "{{type}}" will be replaced with an annotation type from a list defined in # the PDF spec (32000-1:2008 Table 169 – Annotation types). # Some common types are e.g.: "Check", "Text", "Comment", "Note" text_annotation_type.alt=[Anotación {{type}}] password_label=Introduz la contraseña p'abrir esti ficheru PDF password_invalid=Contraseña non válida. Vuelvi a intentalo. password_ok=Aceutar password_cancel=Encaboxar printing_not_supported=Alvertencia: La imprentación entá nun ta sofitada dafechu nesti restolador. printing_not_ready=Avisu: Esti PDF nun se cargó completamente pa poder imprentase. web_fonts_disabled=Les fontes web tán desactivaes: ye imposible usar les fontes PDF embebíes. document_colors_not_allowed=Los documentos PDF nun tienen permisu pa usar les sos colores: «Permitir que les páxines escueyan les sos colores» ta desactivao nel restolador.
{ "pile_set_name": "Github" }
<md-sidenav md-is-locked-open="$mdMedia('gt-sm')" md-component-id="left" class="md-whiteframe-z2 md-sidenav-left"> <md-toolbar md-theme="custom" class="md-hue-1 md-whiteframe-z2"> <md-button layout="row" layout-align="center center" class="md-toolbar-tools md-warn"> <h1>Bassa</h1> </md-button> </md-toolbar> <md-button ng-repeat-start="item in menuItems" layout="column" layout-align="center center" flex class="capitalize" ng-click="selectItem(item)" ui-sref-active="md-warn" ui-sref="{{item.sref}}"> <div hide-sm hide-md class="md-tile-content"> <i class="material-icons md-36">{{item.icon}}</i> </div> <div class="md-tile-content"> {{item.name}} </div> </md-button> <md-divider ng-repeat-end></md-divider> </md-sidenav> <div layout="column" flex> <md-toolbar layout="row" layout-align="center center"> <section layout-align="start center" layout-fill flex> </section> <section layout-align="end center"> <md-menu md-offset="0 20"> <md-button class="capitalize" ng-click="$mdOpenMenu()" aria-label="Open menu"> <i class="material-icons">menu</i> </md-button> <md-menu-content width="3"> <md-menu-item><md-button ng-click="logout()" ui-sref="login">Log out from {{ username }} </md-button></md-menu-item> </md-menu-content> </md-menu> </section> </md-toolbar> <md-content flex class="md-padding page-content"> <div ui-view></div> </md-content> </div>
{ "pile_set_name": "Github" }
# DVB-T Niedersachsen # Created from http://www.ueberallfernsehen.de/data/senderliste.pdf [CH21: NDR NDS, WDR/NDR SH, MDR/NDR MVP, HR/NDR HH] DELIVERY_SYSTEM = DVBT FREQUENCY = 474000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH22: Das Erste (RB), RB TV (NDR NDS), arte, Phoenix] DELIVERY_SYSTEM = DVBT FREQUENCY = 482000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO # CH22: Das Erste, arte, Phoenix, EinsExtra [CH23: ZDF, 3sat, KiKa / ZDFneo, ZDFinfo] DELIVERY_SYSTEM = DVBT FREQUENCY = 490000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH24: RTL, RTL2, Super RTL, VOX] DELIVERY_SYSTEM = DVBT FREQUENCY = 498000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH26: Das Erste, arte, Phoenix, EinsExtra] DELIVERY_SYSTEM = DVBT FREQUENCY = 514000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH28: Tele 5, Nickelodeon/Comedy Central, Eurosport, Mona / Bibel TV / Das Vierte] DELIVERY_SYSTEM = DVBT FREQUENCY = 530000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH29: NDR NDS, WDR/NDR SH, MDR/NDR MVP, HR/NDR HH] DELIVERY_SYSTEM = DVBT FREQUENCY = 538000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH31: ZDF, 3sat, KiKa / ZDFneo, ZDFinfo] DELIVERY_SYSTEM = DVBT FREQUENCY = 554000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH32: ZDF, 3sat, KiKa / ZDFneo, ZDFinfo] DELIVERY_SYSTEM = DVBT FREQUENCY = 562000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH35: ZDF, 3sat, KiKa / ZDFneo, ZDFinfo] DELIVERY_SYSTEM = DVBT FREQUENCY = 586000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH36: NDR NDS, WDR/NDR SH, MDR/NDR MVP, HR/NDR HH] DELIVERY_SYSTEM = DVBT FREQUENCY = 594000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH38: Das Erste, arte, Phoenix, EinsExtra] DELIVERY_SYSTEM = DVBT FREQUENCY = 610000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO # CH38: ZDF, 3sat, KiKa / ZDFneo, ZDFinfo [CH42: RTL, RTL2, Super RTL, VOX] DELIVERY_SYSTEM = DVBT FREQUENCY = 642000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO # CH42: ZDF, 3sat, KiKa / ZDFneo, ZDFinfo [CH43: Das Erste, arte, Phoenix, EinsExtra] DELIVERY_SYSTEM = DVBT FREQUENCY = 650000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO # CH43: NDR NDS, WDR/NDR SH, MDR/NDR MVP, HR/NDR HH [CH44: ProSieben, Sat.1, Kabel1, N24] DELIVERY_SYSTEM = DVBT FREQUENCY = 658000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH45: Tele 5, SIXX, QVC, Mona / Bibel TV / Das Vierte] DELIVERY_SYSTEM = DVBT FREQUENCY = 666000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH47: Das Erste, arte, Phoenix, EinsExtra] DELIVERY_SYSTEM = DVBT FREQUENCY = 682000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH48: Das Erste, arte, Phoenix, EinsExtra] DELIVERY_SYSTEM = DVBT FREQUENCY = 690000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH49: ProSieben, Sat.1, Kabel1, N24] DELIVERY_SYSTEM = DVBT FREQUENCY = 698000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH58: NDR NDS, WDR/NDR SH, MDR/NDR MVP, HR/NDR HH] DELIVERY_SYSTEM = DVBT FREQUENCY = 770000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH59: Das Erste, arte, Phoenix, EinsExtra] DELIVERY_SYSTEM = DVBT FREQUENCY = 778000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO [CH60: Tele 5, Nickelodeon/Comedy Central, Eurosport, Mona / Bibel TV / Das Vierte] DELIVERY_SYSTEM = DVBT FREQUENCY = 786000000 BANDWIDTH_HZ = 8000000 CODE_RATE_HP = 2/3 CODE_RATE_LP = NONE MODULATION = QAM/16 TRANSMISSION_MODE = 8K GUARD_INTERVAL = 1/4 HIERARCHY = NONE INVERSION = AUTO
{ "pile_set_name": "Github" }
//-------------------------------------------------------------------------------------------------- /** * Copyright (C) Sierra Wireless Inc. */ //-------------------------------------------------------------------------------------------------- #ifndef LEGATO_MKTOOLS_CLI_GENERATEDEFTEMPLATE_H_INCLUDE_GUARD #define LEGATO_MKTOOLS_CLI_GENERATEDEFTEMPLATE_H_INCLUDE_GUARD namespace defs { void GenerateSystemTemplate(ArgHandler_t& handler); void GenerateApplicationTemplate(ArgHandler_t& handler); void GenerateComponentTemplate(ArgHandler_t& handler); void GenerateModuleTemplate(ArgHandler_t& handler); } #endif
{ "pile_set_name": "Github" }
import "style/TextToggle.less"; const Toggle = ({ leftText, rightText, activeButton, onClick }) => ( <div className="text-toggle is-row"> <div className={ "text-toggle-button-left" + (activeButton === "left" ? " text-toggle-button-active" : "") } onClick={activeButton == "right" ? () => onClick("left") : null}> {leftText} </div> <div className={ "text-toggle-button-right" + (activeButton === "right" ? " text-toggle-button-active" : "") } onClick={activeButton == "left" ? () => onClick("right") : null}> {rightText} </div> </div> ); export default Toggle;
{ "pile_set_name": "Github" }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.6"/> <title>yaml: Data Structure Index</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">yaml &#160;<span id="projectnumber">0.1.7</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.6 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li class="current"><a href="annotated.html"><span>Data&#160;Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li> <li><a href="functions.html"><span>Data&#160;Fields</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">Data Structure Index</div> </div> </div><!--header--> <div class="contents"> <div class="qindex"><a class="qindex" href="#letter_Y">Y</a></div> <table style="margin: 10px; white-space: nowrap;" align="center" width="95%" border="0" cellspacing="0" cellpadding="0"> <tr><td rowspan="2" valign="bottom"><a name="letter_y"></a><table border="0" cellspacing="0" cellpadding="0"><tr><td><div class="ah">&#160;&#160;y&#160;&#160;</div></td></tr></table> </td><td valign="top"><a class="el" href="structyaml__document__s.html">yaml_document_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__mark__s.html">yaml_mark_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__parser__s.html">yaml_parser_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__token__s.html">yaml_token_s</a>&#160;&#160;&#160;</td></tr> <tr><td valign="top"><a class="el" href="structyaml__emitter__s.html">yaml_emitter_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__node__pair__s.html">yaml_node_pair_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__simple__key__s.html">yaml_simple_key_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__version__directive__s.html">yaml_version_directive_s</a>&#160;&#160;&#160;</td></tr> <tr><td valign="top"><a class="el" href="structyaml__alias__data__s.html">yaml_alias_data_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__event__s.html">yaml_event_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__node__s.html">yaml_node_s</a>&#160;&#160;&#160;</td><td valign="top"><a class="el" href="structyaml__tag__directive__s.html">yaml_tag_directive_s</a>&#160;&#160;&#160;</td><td></td></tr> <tr><td></td><td></td><td></td><td></td><td></td></tr> </table> <div class="qindex"><a class="qindex" href="#letter_Y">Y</a></div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Sun Aug 28 2016 23:56:54 for yaml by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.6 </small></address> </body> </html>
{ "pile_set_name": "Github" }
import matplotlib.pyplot as plt import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms import numpy as np from .misc import * __all__ = ['make_image', 'show_batch', 'show_mask', 'show_mask_single'] # functions to show an image def make_image(img, mean=(0,0,0), std=(1,1,1)): for i in range(0, 3): img[i] = img[i] * std[i] + mean[i] # unnormalize npimg = img.numpy() return np.transpose(npimg, (1, 2, 0)) def gauss(x,a,b,c): return torch.exp(-torch.pow(torch.add(x,-b),2).div(2*c*c)).mul(a) def colorize(x): ''' Converts a one-channel grayscale image to a color heatmap image ''' if x.dim() == 2: torch.unsqueeze(x, 0, out=x) if x.dim() == 3: cl = torch.zeros([3, x.size(1), x.size(2)]) cl[0] = gauss(x,.5,.6,.2) + gauss(x,1,.8,.3) cl[1] = gauss(x,1,.5,.3) cl[2] = gauss(x,1,.2,.3) cl[cl.gt(1)] = 1 elif x.dim() == 4: cl = torch.zeros([x.size(0), 3, x.size(2), x.size(3)]) cl[:,0,:,:] = gauss(x,.5,.6,.2) + gauss(x,1,.8,.3) cl[:,1,:,:] = gauss(x,1,.5,.3) cl[:,2,:,:] = gauss(x,1,.2,.3) return cl def show_batch(images, Mean=(2, 2, 2), Std=(0.5,0.5,0.5)): images = make_image(torchvision.utils.make_grid(images), Mean, Std) plt.imshow(images) plt.show() def show_mask_single(images, mask, Mean=(2, 2, 2), Std=(0.5,0.5,0.5)): im_size = images.size(2) # save for adding mask im_data = images.clone() for i in range(0, 3): im_data[:,i,:,:] = im_data[:,i,:,:] * Std[i] + Mean[i] # unnormalize images = make_image(torchvision.utils.make_grid(images), Mean, Std) plt.subplot(2, 1, 1) plt.imshow(images) plt.axis('off') # for b in range(mask.size(0)): # mask[b] = (mask[b] - mask[b].min())/(mask[b].max() - mask[b].min()) mask_size = mask.size(2) # print('Max %f Min %f' % (mask.max(), mask.min())) mask = (upsampling(mask, scale_factor=im_size/mask_size)) # mask = colorize(upsampling(mask, scale_factor=im_size/mask_size)) # for c in range(3): # mask[:,c,:,:] = (mask[:,c,:,:] - Mean[c])/Std[c] # print(mask.size()) mask = make_image(torchvision.utils.make_grid(0.3*im_data+0.7*mask.expand_as(im_data))) # mask = make_image(torchvision.utils.make_grid(0.3*im_data+0.7*mask), Mean, Std) plt.subplot(2, 1, 2) plt.imshow(mask) plt.axis('off') def show_mask(images, masklist, Mean=(2, 2, 2), Std=(0.5,0.5,0.5)): im_size = images.size(2) # save for adding mask im_data = images.clone() for i in range(0, 3): im_data[:,i,:,:] = im_data[:,i,:,:] * Std[i] + Mean[i] # unnormalize images = make_image(torchvision.utils.make_grid(images), Mean, Std) plt.subplot(1+len(masklist), 1, 1) plt.imshow(images) plt.axis('off') for i in range(len(masklist)): mask = masklist[i].data.cpu() # for b in range(mask.size(0)): # mask[b] = (mask[b] - mask[b].min())/(mask[b].max() - mask[b].min()) mask_size = mask.size(2) # print('Max %f Min %f' % (mask.max(), mask.min())) mask = (upsampling(mask, scale_factor=im_size/mask_size)) # mask = colorize(upsampling(mask, scale_factor=im_size/mask_size)) # for c in range(3): # mask[:,c,:,:] = (mask[:,c,:,:] - Mean[c])/Std[c] # print(mask.size()) mask = make_image(torchvision.utils.make_grid(0.3*im_data+0.7*mask.expand_as(im_data))) # mask = make_image(torchvision.utils.make_grid(0.3*im_data+0.7*mask), Mean, Std) plt.subplot(1+len(masklist), 1, i+2) plt.imshow(mask) plt.axis('off') # x = torch.zeros(1, 3, 3) # out = colorize(x) # out_im = make_image(out) # plt.imshow(out_im) # plt.show()
{ "pile_set_name": "Github" }
export enum MessageType { default = 'default', secondary = 'secondary', success = 'success', warning = 'warning', error = 'error' }
{ "pile_set_name": "Github" }
# test asynchat from test import support import asynchat import asyncore import errno import socket import sys import threading import time import unittest import unittest.mock HOST = support.HOST SERVER_QUIT = b'QUIT\n' TIMEOUT = 3.0 class echo_server(threading.Thread): # parameter to determine the number of bytes passed back to the # client each send chunk_size = 1 def __init__(self, event): threading.Thread.__init__(self) self.event = event self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = support.bind_port(self.sock) # This will be set if the client wants us to wait before echoing # data back. self.start_resend_event = None def run(self): self.sock.listen() self.event.set() conn, client = self.sock.accept() self.buffer = b"" # collect data until quit message is seen while SERVER_QUIT not in self.buffer: data = conn.recv(1) if not data: break self.buffer = self.buffer + data # remove the SERVER_QUIT message self.buffer = self.buffer.replace(SERVER_QUIT, b'') if self.start_resend_event: self.start_resend_event.wait() # re-send entire set of collected data try: # this may fail on some tests, such as test_close_when_done, # since the client closes the channel when it's done sending while self.buffer: n = conn.send(self.buffer[:self.chunk_size]) time.sleep(0.001) self.buffer = self.buffer[n:] except: pass conn.close() self.sock.close() class echo_client(asynchat.async_chat): def __init__(self, terminator, server_port): asynchat.async_chat.__init__(self) self.contents = [] self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.connect((HOST, server_port)) self.set_terminator(terminator) self.buffer = b"" def handle_connect(self): pass if sys.platform == 'darwin': # select.poll returns a select.POLLHUP at the end of the tests # on darwin, so just ignore it def handle_expt(self): pass def collect_incoming_data(self, data): self.buffer += data def found_terminator(self): self.contents.append(self.buffer) self.buffer = b"" def start_echo_server(): event = threading.Event() s = echo_server(event) s.start() event.wait() event.clear() time.sleep(0.01) # Give server time to start accepting. return s, event class TestAsynchat(unittest.TestCase): usepoll = False def setUp(self): self._threads = support.threading_setup() def tearDown(self): support.threading_cleanup(*self._threads) def line_terminator_check(self, term, server_chunk): event = threading.Event() s = echo_server(event) s.chunk_size = server_chunk s.start() event.wait() event.clear() time.sleep(0.01) # Give server time to start accepting. c = echo_client(term, s.port) c.push(b"hello ") c.push(b"world" + term) c.push(b"I'm not dead yet!" + term) c.push(SERVER_QUIT) asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"]) # the line terminator tests below check receiving variously-sized # chunks back from the server in order to exercise all branches of # async_chat.handle_read def test_line_terminator1(self): # test one-character terminator for l in (1, 2, 3): self.line_terminator_check(b'\n', l) def test_line_terminator2(self): # test two-character terminator for l in (1, 2, 3): self.line_terminator_check(b'\r\n', l) def test_line_terminator3(self): # test three-character terminator for l in (1, 2, 3): self.line_terminator_check(b'qqq', l) def numeric_terminator_check(self, termlen): # Try reading a fixed number of bytes s, event = start_echo_server() c = echo_client(termlen, s.port) data = b"hello world, I'm not dead yet!\n" c.push(data) c.push(SERVER_QUIT) asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, [data[:termlen]]) def test_numeric_terminator1(self): # check that ints & longs both work (since type is # explicitly checked in async_chat.handle_read) self.numeric_terminator_check(1) def test_numeric_terminator2(self): self.numeric_terminator_check(6) def test_none_terminator(self): # Try reading a fixed number of bytes s, event = start_echo_server() c = echo_client(None, s.port) data = b"hello world, I'm not dead yet!\n" c.push(data) c.push(SERVER_QUIT) asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, []) self.assertEqual(c.buffer, data) def test_simple_producer(self): s, event = start_echo_server() c = echo_client(b'\n', s.port) data = b"hello world\nI'm not dead yet!\n" p = asynchat.simple_producer(data+SERVER_QUIT, buffer_size=8) c.push_with_producer(p) asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"]) def test_string_producer(self): s, event = start_echo_server() c = echo_client(b'\n', s.port) data = b"hello world\nI'm not dead yet!\n" c.push_with_producer(data+SERVER_QUIT) asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"]) def test_empty_line(self): # checks that empty lines are handled correctly s, event = start_echo_server() c = echo_client(b'\n', s.port) c.push(b"hello world\n\nI'm not dead yet!\n") c.push(SERVER_QUIT) asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, [b"hello world", b"", b"I'm not dead yet!"]) def test_close_when_done(self): s, event = start_echo_server() s.start_resend_event = threading.Event() c = echo_client(b'\n', s.port) c.push(b"hello world\nI'm not dead yet!\n") c.push(SERVER_QUIT) c.close_when_done() asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) # Only allow the server to start echoing data back to the client after # the client has closed its connection. This prevents a race condition # where the server echoes all of its data before we can check that it # got any down below. s.start_resend_event.set() support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, []) # the server might have been able to send a byte or two back, but this # at least checks that it received something and didn't just fail # (which could still result in the client not having received anything) self.assertGreater(len(s.buffer), 0) def test_push(self): # Issue #12523: push() should raise a TypeError if it doesn't get # a bytes string s, event = start_echo_server() c = echo_client(b'\n', s.port) data = b'bytes\n' c.push(data) c.push(bytearray(data)) c.push(memoryview(data)) self.assertRaises(TypeError, c.push, 10) self.assertRaises(TypeError, c.push, 'unicode') c.push(SERVER_QUIT) asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01) support.join_thread(s, timeout=TIMEOUT) self.assertEqual(c.contents, [b'bytes', b'bytes', b'bytes']) class TestAsynchat_WithPoll(TestAsynchat): usepoll = True class TestAsynchatMocked(unittest.TestCase): def test_blockingioerror(self): # Issue #16133: handle_read() must ignore BlockingIOError sock = unittest.mock.Mock() sock.recv.side_effect = BlockingIOError(errno.EAGAIN) dispatcher = asynchat.async_chat() dispatcher.set_socket(sock) self.addCleanup(dispatcher.del_channel) with unittest.mock.patch.object(dispatcher, 'handle_error') as error: dispatcher.handle_read() self.assertFalse(error.called) class TestHelperFunctions(unittest.TestCase): def test_find_prefix_at_end(self): self.assertEqual(asynchat.find_prefix_at_end("qwerty\r", "\r\n"), 1) self.assertEqual(asynchat.find_prefix_at_end("qwertydkjf", "\r\n"), 0) class TestNotConnected(unittest.TestCase): def test_disallow_negative_terminator(self): # Issue #11259 client = asynchat.async_chat() self.assertRaises(ValueError, client.set_terminator, -1) if __name__ == "__main__": unittest.main()
{ "pile_set_name": "Github" }
/* * Copyright (C) 2016 JFrog Ltd. * * 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. */ /** * @author Uriah Levy */ import org.artifactory.fs.FileInfo download { altResponse { request, responseRepoPath -> FileInfo info = repositories.getFileInfo(responseRepoPath) checksumsInfo = info.getChecksumsInfo() checksumInfo = checksumsInfo.getChecksums() // .getOriginal() returns the original checksum value published by the client // .getActual() returns the checksum value Artifactory calculated for the artifact checksumInfo.each { // check both Md5 and Sha1 log.warn("Original: " + it.getOriginal() + " Actual: " + it.getActual()) if(it.getOriginal() == null) { // The client didn't provide a checksum or provided one the was rejected; reject status = 409 message = "Download rejected: this artifact has no original checksum" log.warn "Download rejected: this artifact has no original checksum" } } } }
{ "pile_set_name": "Github" }
/* * 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. */ /* * This code was generated by https://github.com/googleapis/google-api-java-client-services/ * Modify at your own risk. */ package com.google.api.services.containeranalysis.v1alpha1.model; /** * Response message for `TestIamPermissions` method. * * <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is * transmitted over HTTP when working with the Container Analysis API. For a detailed explanation * see: * <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a> * </p> * * @author Google, Inc. */ @SuppressWarnings("javadoc") public final class TestIamPermissionsResponse extends com.google.api.client.json.GenericJson { /** * A subset of `TestPermissionsRequest.permissions` that the caller is allowed. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.util.List<java.lang.String> permissions; /** * A subset of `TestPermissionsRequest.permissions` that the caller is allowed. * @return value or {@code null} for none */ public java.util.List<java.lang.String> getPermissions() { return permissions; } /** * A subset of `TestPermissionsRequest.permissions` that the caller is allowed. * @param permissions permissions or {@code null} for none */ public TestIamPermissionsResponse setPermissions(java.util.List<java.lang.String> permissions) { this.permissions = permissions; return this; } @Override public TestIamPermissionsResponse set(String fieldName, Object value) { return (TestIamPermissionsResponse) super.set(fieldName, value); } @Override public TestIamPermissionsResponse clone() { return (TestIamPermissionsResponse) super.clone(); } }
{ "pile_set_name": "Github" }
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ // ============== // Preload script // ============== const {remote, ipcRenderer} = require('electron'); const flipperState = { mainWindowId: 0, isClientInit: false, plugins: null, appName: 'JS App', }; ipcRenderer.on('parent-window-id', (event, message) => { flipperState.mainWindowId = message; }); function cleanUpGWTArray(arr) { const res = []; for (let i = 0; i < arr.length; i++) { res.push(arr[i]); } return res; } function initClient(plugins, appName) { if (flipperState.isClientInit) { return; } if (plugins) { flipperState.plugins = cleanUpGWTArray(plugins); } if (appName) { flipperState.appName = appName; } if (flipperState.mainWindowId != 0) { ipcRenderer.sendTo( flipperState.mainWindowId, 'from-js-emulator-init-client', { command: 'initClient', windowId: remote.getCurrentWebContents().id, payload: { plugins: flipperState.plugins, appName: flipperState.appName, }, }, ); flipperState.isClientInit = true; } } window.FlipperWebviewBridge = { registerPlugins: function (plugins) { flipperState.plugins = plugins; }, start: function (appName) { flipperState.appName = appName; initClient(); }, sendFlipperObject: function (plugin, method, data) { initClient(); if (flipperState.mainWindowId != 0) { ipcRenderer.sendTo(flipperState.mainWindowId, 'from-js-emulator', { command: 'sendFlipperObject', payload: { api: plugin, method: method, params: data, }, }); } }, isFlipperSupported: true, initClient: initClient, }; ipcRenderer.on('message-to-plugin', (event, message) => { const flipper = window.flipper; if (!flipper) { return; } const receiver = flipper.FlipperWebviewMessageReceiver.receive; const {api, method, params} = message.params; receiver(api, method, JSON.stringify(params)); });
{ "pile_set_name": "Github" }
ps.1.4 ; Get the 3-vector from the normal map texld r0, t0 ; Get environment matrix texcrd r1.rgb, t1 texcrd r2.rgb, t2 texcrd r3.rgb, t3 ; Normalize eye-ray vector through normalizer cube map texld r4, t4 ; <---- CUBE MAP here!!! ; Transform normal dp3 r5.r, r1, r0_bx2 dp3 r5.g, r2, r0_bx2 dp3 r5.b, r3, r0_bx2 ; Reflection calculatiom dp3_x2 r3.rgb, r5, r4_bx2 ; 2(N.Eye) mul r3.rgb, r5, r3 ; 2N(N.Eye) dp3 r2.rgb, r5, r5 ; N.N mad r2.rgb, -r4_bx2, r2, r3 ; 2N(N.Eye) - Eye(N.N) phase ; Sample environment map texld r3, r2 ; multiply color by reflecttint mul r0, r3, c1 ; blend between reflected color and fog color based on constant factor lrp r0.rgb, c1.a, r0, c0
{ "pile_set_name": "Github" }
namespace KendoUIMVC5.Models { public class Customer { public int CustomerId { get; set; } public string CustomerName { get; set; } } }
{ "pile_set_name": "Github" }
import RcCollapse, { Panel } from 'rc-collapse'; import * as React from 'react'; import { AccordionPropsTypes } from './PropsType'; export interface AccordionProps extends AccordionPropsTypes { className?: string; prefixCls?: string; openAnimation?: any; accordion?: boolean; style?: React.CSSProperties; } export default class Accordion extends React.Component<AccordionProps, any> { static Panel = Panel; static defaultProps = { prefixCls: 'am-accordion', }; render() { return <RcCollapse {...this.props} />; } }
{ "pile_set_name": "Github" }
// RUN: %clang_cc1 -triple mips64el-unknown-linux -O3 -S -target-abi n64 -o - -emit-llvm %s | FileCheck %s class B0 { double d; }; class D0 : public B0 { float f; }; class B1 { }; class D1 : public B1 { double d; float f; }; class D2 : public B0 { double d2; }; extern D0 gd0; extern D1 gd1; extern D2 gd2; // CHECK: define inreg { i64, i64 } @_Z4foo1v() D0 foo1(void) { return gd0; } // CHECK: define inreg { double, float } @_Z4foo2v() D1 foo2(void) { return gd1; } // CHECK-LABEL: define void @_Z4foo32D2(i64 inreg %a0.coerce0, double inreg %a0.coerce1) void foo3(D2 a0) { gd2 = a0; } // CHECK-LABEL: define void @_Z4foo42D0(i64 inreg %a0.coerce0, i64 inreg %a0.coerce1) void foo4(D0 a0) { gd0 = a0; }
{ "pile_set_name": "Github" }
// Copyright 2008 The Closure Library Authors. All Rights Reserved. // // 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. /** * @fileoverview Date range data structure. Based loosely on * com.google.common.util.DateRange. * * @author dpb@google.com (David P. Baker) */ goog.provide('goog.date.DateRange'); goog.provide('goog.date.DateRange.Iterator'); goog.provide('goog.date.DateRange.StandardDateRangeKeys'); goog.require('goog.date.Date'); goog.require('goog.date.Interval'); goog.require('goog.iter.Iterator'); goog.require('goog.iter.StopIteration'); /** * Constructs a date range. * @constructor * @struct * @param {goog.date.Date} startDate The first date in the range. * @param {goog.date.Date} endDate The last date in the range. * @final */ goog.date.DateRange = function(startDate, endDate) { /** * The first date in the range. * @type {goog.date.Date} * @private */ this.startDate_ = startDate; /** * The last date in the range. * @type {goog.date.Date} * @private */ this.endDate_ = endDate; }; /** * The first possible day, as far as this class is concerned. * @type {goog.date.Date} */ goog.date.DateRange.MINIMUM_DATE = new goog.date.Date(0, 0, 1); /** * The last possible day, as far as this class is concerned. * @type {goog.date.Date} */ goog.date.DateRange.MAXIMUM_DATE = new goog.date.Date(9999, 11, 31); /** * @return {goog.date.Date} The first date in the range. */ goog.date.DateRange.prototype.getStartDate = function() { return this.startDate_; }; /** * @return {goog.date.Date} The last date in the range. */ goog.date.DateRange.prototype.getEndDate = function() { return this.endDate_; }; /** * Tests if a date falls within this range. * * @param {goog.date.Date} date The date to test. * @return {boolean} Whether the date is in the range. */ goog.date.DateRange.prototype.contains = function(date) { return date.valueOf() >= this.startDate_.valueOf() && date.valueOf() <= this.endDate_.valueOf(); }; /** * @return {!goog.date.DateRange.Iterator} An iterator over the date range. */ goog.date.DateRange.prototype.iterator = function() { return new goog.date.DateRange.Iterator(this); }; /** * Tests two {@link goog.date.DateRange} objects for equality. * @param {goog.date.DateRange} a A date range. * @param {goog.date.DateRange} b A date range. * @return {boolean} Whether |a| is the same range as |b|. */ goog.date.DateRange.equals = function(a, b) { // Test for same object reference; type conversion is irrelevant. if (a === b) { return true; } if (a == null || b == null) { return false; } return a.startDate_.equals(b.startDate_) && a.endDate_.equals(b.endDate_); }; /** * Calculates a date that is a number of days after a date. Does not modify its * input. * @param {goog.date.Date} date The input date. * @param {number} offset Number of days. * @return {!goog.date.Date} The date that is |offset| days after |date|. * @private */ goog.date.DateRange.offsetInDays_ = function(date, offset) { var newDate = date.clone(); newDate.add(new goog.date.Interval(goog.date.Interval.DAYS, offset)); return newDate; }; /** * Calculates a date that is a number of months after the first day in the * month that contains its input. Does not modify its input. * @param {goog.date.Date} date The input date. * @param {number} offset Number of months. * @return {!goog.date.Date} The date that is |offset| months after the first * day in the month that contains |date|. * @private */ goog.date.DateRange.offsetInMonths_ = function(date, offset) { var newDate = date.clone(); newDate.setDate(1); newDate.add(new goog.date.Interval(goog.date.Interval.MONTHS, offset)); return newDate; }; /** * Returns the range from yesterday to yesterday. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that includes only yesterday. */ goog.date.DateRange.yesterday = function(opt_today) { var today = goog.date.DateRange.cloneOrCreate_(opt_today); var yesterday = goog.date.DateRange.offsetInDays_(today, -1); return new goog.date.DateRange(yesterday, yesterday.clone()); }; /** * Returns the range from today to today. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that includes only today. */ goog.date.DateRange.today = function(opt_today) { var today = goog.date.DateRange.cloneOrCreate_(opt_today); return new goog.date.DateRange(today, today.clone()); }; /** * Returns the range that includes the seven days that end yesterday. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that includes the seven days that * end yesterday. */ goog.date.DateRange.last7Days = function(opt_today) { var today = goog.date.DateRange.cloneOrCreate_(opt_today); var yesterday = goog.date.DateRange.offsetInDays_(today, -1); return new goog.date.DateRange( goog.date.DateRange.offsetInDays_(today, -7), yesterday); }; /** * Returns the range that starts the first of this month and ends the last day * of this month. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that starts the first of this month * and ends the last day of this month. */ goog.date.DateRange.thisMonth = function(opt_today) { var today = goog.date.DateRange.cloneOrCreate_(opt_today); return new goog.date.DateRange( goog.date.DateRange.offsetInMonths_(today, 0), goog.date.DateRange.offsetInDays_( goog.date.DateRange.offsetInMonths_(today, 1), -1)); }; /** * Returns the range that starts the first of last month and ends the last day * of last month. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that starts the first of last month * and ends the last day of last month. */ goog.date.DateRange.lastMonth = function(opt_today) { var today = goog.date.DateRange.cloneOrCreate_(opt_today); return new goog.date.DateRange( goog.date.DateRange.offsetInMonths_(today, -1), goog.date.DateRange.offsetInDays_( goog.date.DateRange.offsetInMonths_(today, 0), -1)); }; /** * Returns the seven-day range that starts on the first day of the week * (see {@link goog.i18n.DateTimeSymbols.FIRSTDAYOFWEEK}) on or before today. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that starts the Monday on or before * today and ends the Sunday on or after today. */ goog.date.DateRange.thisWeek = function(opt_today) { var today = goog.date.DateRange.cloneOrCreate_(opt_today); var iso = today.getIsoWeekday(); var firstDay = today.getFirstDayOfWeek(); var i18nFirstDay = (iso >= firstDay) ? iso - firstDay : iso + (7 - firstDay); var start = goog.date.DateRange.offsetInDays_(today, -i18nFirstDay); var end = goog.date.DateRange.offsetInDays_(start, 6); return new goog.date.DateRange(start, end); }; /** * Returns the seven-day range that ends the day before the first day of * the week (see {@link goog.i18n.DateTimeSymbols.FIRSTDAYOFWEEK}) that * contains today. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that starts seven days before the * Monday on or before today and ends the Sunday on or before yesterday. */ goog.date.DateRange.lastWeek = function(opt_today) { var thisWeek = goog.date.DateRange.thisWeek(opt_today); var start = goog.date.DateRange.offsetInDays_(thisWeek.getStartDate(), -7); var end = goog.date.DateRange.offsetInDays_(thisWeek.getEndDate(), -7); return new goog.date.DateRange(start, end); }; /** * Returns the range that starts seven days before the Monday on or before * today and ends the Friday before today. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that starts seven days before the * Monday on or before today and ends the Friday before today. */ goog.date.DateRange.lastBusinessWeek = function(opt_today) { // TODO(user): should be i18nized. var today = goog.date.DateRange.cloneOrCreate_(opt_today); var start = goog.date.DateRange.offsetInDays_(today, -7 - today.getIsoWeekday()); var end = goog.date.DateRange.offsetInDays_(start, 4); return new goog.date.DateRange(start, end); }; /** * Returns the range that includes all days between January 1, 1900 and * December 31, 9999. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The range that includes all days between * January 1, 1900 and December 31, 9999. */ goog.date.DateRange.allTime = function(opt_today) { return new goog.date.DateRange( goog.date.DateRange.MINIMUM_DATE, goog.date.DateRange.MAXIMUM_DATE); }; /** * Standard date range keys. Equivalent to the enum IDs in * DateRange.java http://go/datarange.java * * @enum {string} */ goog.date.DateRange.StandardDateRangeKeys = { YESTERDAY: 'yesterday', TODAY: 'today', LAST_7_DAYS: 'last7days', THIS_MONTH: 'thismonth', LAST_MONTH: 'lastmonth', THIS_WEEK: 'thisweek', LAST_WEEK: 'lastweek', LAST_BUSINESS_WEEK: 'lastbusinessweek', ALL_TIME: 'alltime' }; /** * @param {string} dateRangeKey A standard date range key. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.DateRange} The date range that corresponds to that key. * @throws {Error} If no standard date range with that key exists. */ goog.date.DateRange.standardDateRange = function(dateRangeKey, opt_today) { switch (dateRangeKey) { case goog.date.DateRange.StandardDateRangeKeys.YESTERDAY: return goog.date.DateRange.yesterday(opt_today); case goog.date.DateRange.StandardDateRangeKeys.TODAY: return goog.date.DateRange.today(opt_today); case goog.date.DateRange.StandardDateRangeKeys.LAST_7_DAYS: return goog.date.DateRange.last7Days(opt_today); case goog.date.DateRange.StandardDateRangeKeys.THIS_MONTH: return goog.date.DateRange.thisMonth(opt_today); case goog.date.DateRange.StandardDateRangeKeys.LAST_MONTH: return goog.date.DateRange.lastMonth(opt_today); case goog.date.DateRange.StandardDateRangeKeys.THIS_WEEK: return goog.date.DateRange.thisWeek(opt_today); case goog.date.DateRange.StandardDateRangeKeys.LAST_WEEK: return goog.date.DateRange.lastWeek(opt_today); case goog.date.DateRange.StandardDateRangeKeys.LAST_BUSINESS_WEEK: return goog.date.DateRange.lastBusinessWeek(opt_today); case goog.date.DateRange.StandardDateRangeKeys.ALL_TIME: return goog.date.DateRange.allTime(opt_today); default: throw Error('no such date range key: ' + dateRangeKey); } }; /** * Clones or creates new. * @param {goog.date.Date=} opt_today The date to consider today. * Defaults to today. * @return {!goog.date.Date} cloned or new. * @private */ goog.date.DateRange.cloneOrCreate_ = function(opt_today) { return opt_today ? opt_today.clone() : new goog.date.Date(); }; /** * Creates an iterator over the dates in a {@link goog.date.DateRange}. * @constructor * @struct * @extends {goog.iter.Iterator<goog.date.Date>} * @param {goog.date.DateRange} dateRange The date range to iterate. * @final */ goog.date.DateRange.Iterator = function(dateRange) { /** * The next date. * @type {goog.date.Date} * @private */ this.nextDate_ = dateRange.getStartDate().clone(); /** * The end date, expressed as an integer: YYYYMMDD. * @type {number} * @private */ this.endDate_ = Number(dateRange.getEndDate().toIsoString()); }; goog.inherits(goog.date.DateRange.Iterator, goog.iter.Iterator); /** @override */ goog.date.DateRange.Iterator.prototype.next = function() { if (Number(this.nextDate_.toIsoString()) > this.endDate_) { throw goog.iter.StopIteration; } var rv = this.nextDate_.clone(); this.nextDate_.add(new goog.date.Interval(goog.date.Interval.DAYS, 1)); return rv; };
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <Scheme LastUpgradeVersion = "0700" version = "1.3"> <BuildAction parallelizeBuildables = "YES" buildImplicitDependencies = "YES"> <BuildActionEntries> <BuildActionEntry buildForTesting = "YES" buildForRunning = "YES" buildForProfiling = "YES" buildForArchiving = "YES" buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "2EA377071BB7D2AC00C6B4E4" BuildableName = "Intruduction Tips.app" BlueprintName = "Intruduction Tips" ReferencedContainer = "container:Intruduction Tips.xcodeproj"> </BuildableReference> </BuildActionEntry> </BuildActionEntries> </BuildAction> <TestAction buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> <Testables> <TestableReference skipped = "NO"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "2EA3771B1BB7D2AC00C6B4E4" BuildableName = "Intruduction TipsTests.xctest" BlueprintName = "Intruduction TipsTests" ReferencedContainer = "container:Intruduction Tips.xcodeproj"> </BuildableReference> </TestableReference> <TestableReference skipped = "NO"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "2EA377261BB7D2AC00C6B4E4" BuildableName = "Intruduction TipsUITests.xctest" BlueprintName = "Intruduction TipsUITests" ReferencedContainer = "container:Intruduction Tips.xcodeproj"> </BuildableReference> </TestableReference> </Testables> <MacroExpansion> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "2EA377071BB7D2AC00C6B4E4" BuildableName = "Intruduction Tips.app" BlueprintName = "Intruduction Tips" ReferencedContainer = "container:Intruduction Tips.xcodeproj"> </BuildableReference> </MacroExpansion> <AdditionalOptions> </AdditionalOptions> </TestAction> <LaunchAction buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> <BuildableProductRunnable runnableDebuggingMode = "0"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "2EA377071BB7D2AC00C6B4E4" BuildableName = "Intruduction Tips.app" BlueprintName = "Intruduction Tips" ReferencedContainer = "container:Intruduction Tips.xcodeproj"> </BuildableReference> </BuildableProductRunnable> <AdditionalOptions> </AdditionalOptions> </LaunchAction> <ProfileAction buildConfiguration = "Release" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> <BuildableProductRunnable runnableDebuggingMode = "0"> <BuildableReference BuildableIdentifier = "primary" BlueprintIdentifier = "2EA377071BB7D2AC00C6B4E4" BuildableName = "Intruduction Tips.app" BlueprintName = "Intruduction Tips" ReferencedContainer = "container:Intruduction Tips.xcodeproj"> </BuildableReference> </BuildableProductRunnable> </ProfileAction> <AnalyzeAction buildConfiguration = "Debug"> </AnalyzeAction> <ArchiveAction buildConfiguration = "Release" revealArchiveInOrganizer = "YES"> </ArchiveAction> </Scheme>
{ "pile_set_name": "Github" }
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ // Do not edit this file. It is machine generated. { "unexpected.end.of.arguments": "Final inesperado al analizar los argumentos de la línea de comandos", "unknown.control.gflag.cpp": "Marca de control del estándar C++ desconocida: {0}", "unknown.control.gflag.c": "Marca de control del estándar C desconocida: {0}", "unknown.control.gflag": "Marca de control del estándar desconocida: {0}", "unknown language": "Lenguaje desconocido: {0}", "path.not.found.in.cmake.cache": "No se encontró la ruta de acceso al compilador de uno o más archivos de código fuente en la memoria caché de CMake. Si usa un archivo de cadena de herramientas, probablemente deba especificar la opción CACHE al establecer la ruta de acceso del compilador de C o C++." }
{ "pile_set_name": "Github" }
/* * Copyright 2019 * Ubiquitous Knowledge Processing (UKP) Lab and FG Language Technology * Technische Universität Darmstadt * * 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 de.tudarmstadt.ukp.clarin.webanno.agreement.results.coding; import static de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.RELATION_TYPE; import static de.tudarmstadt.ukp.clarin.webanno.api.WebAnnoConst.SPAN_TYPE; import static de.tudarmstadt.ukp.clarin.webanno.model.AnchoringMode.SENTENCES; import static de.tudarmstadt.ukp.clarin.webanno.model.AnchoringMode.SINGLE_TOKEN; import static de.tudarmstadt.ukp.clarin.webanno.model.AnchoringMode.TOKENS; import static java.util.Arrays.asList; import java.util.List; import java.util.Map; import org.apache.uima.cas.CAS; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.IModel; import org.danekja.java.util.function.serializable.SerializableSupplier; import org.dkpro.statistics.agreement.coding.ICodingAnnotationStudy; import de.tudarmstadt.ukp.clarin.webanno.agreement.PairwiseAnnotationResult; import de.tudarmstadt.ukp.clarin.webanno.agreement.measures.AgreementMeasureSupport_ImplBase; import de.tudarmstadt.ukp.clarin.webanno.agreement.measures.DefaultAgreementTraits; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; public abstract class AbstractCodingAgreementMeasureSupport<T extends DefaultAgreementTraits> extends AgreementMeasureSupport_ImplBase< T, PairwiseAnnotationResult<CodingAgreementResult>, ICodingAnnotationStudy> { @Override public boolean accepts(AnnotationFeature aFeature) { AnnotationLayer layer = aFeature.getLayer(); if ( asList(SPAN_TYPE, RELATION_TYPE).contains(layer.getType()) && asList(SINGLE_TOKEN, TOKENS, SENTENCES).contains(layer.getAnchoringMode()) ) { return true; } return false; } @Override public Panel createResultsPanel(String aId, IModel<PairwiseAnnotationResult<CodingAgreementResult>> aResults, SerializableSupplier<Map<String, List<CAS>>> aCasMapSupplier) { return new PairwiseCodingAgreementTable(aId, aResults, aCasMapSupplier); } }
{ "pile_set_name": "Github" }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="ko"> <head> <!-- Generated by javadoc (1.8.0_191) on Tue Mar 03 19:55:18 KST 2020 --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ForParagraphList (HWP Library 1.0.1 API)</title> <meta name="date" content="2020-03-03"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> <script type="text/javascript" src="../../../../../script.js"></script> </head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="ForParagraphList (HWP Library 1.0.1 API)"; } } catch(err) { } //--> var methods = {"i0":9}; var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; var tableTab = "tableTab"; var activeTableTab = "activeTableTab"; </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/ForParagraphList.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../index-all.html">Index</a></li> <li><a href="../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/ForParagraph.html" title="class in kr.dogfoot.hwplib.writer.autosetter"><span class="typeNameLink">Prev&nbsp;Class</span></a></li> <li><a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/InstanceID.html" title="class in kr.dogfoot.hwplib.writer.autosetter"><span class="typeNameLink">Next&nbsp;Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../../index.html?kr/dogfoot/hwplib/writer/autosetter/ForParagraphList.html" target="_top">Frames</a></li> <li><a href="ForParagraphList.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a name="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <!-- ======== START OF CLASS DATA ======== --> <div class="header"> <div class="subTitle">kr.dogfoot.hwplib.writer.autosetter</div> <h2 title="Class ForParagraphList" class="title">Class ForParagraphList</h2> </div> <div class="contentContainer"> <ul class="inheritance"> <li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> <li> <ul class="inheritance"> <li>kr.dogfoot.hwplib.writer.autosetter.ForParagraphList</li> </ul> </li> </ul> <div class="description"> <ul class="blockList"> <li class="blockList"> <hr> <br> <pre>public class <span class="typeNameLabel">ForParagraphList</span> extends <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre> <div class="block">문단 리스트 객체를 쓰기 전에 자동 설정하기 위한 객체</div> <dl> <dt><span class="simpleTagLabel">Author:</span></dt> <dd>neolord</dd> </dl> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <ul class="blockList"> <li class="blockList"><a name="constructor.summary"> <!-- --> </a> <h3>Constructor Summary</h3> <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tr class="altColor"> <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/ForParagraphList.html#ForParagraphList--">ForParagraphList</a></span>()</code>&nbsp;</td> </tr> </table> </li> </ul> <!-- ========== METHOD SUMMARY =========== --> <ul class="blockList"> <li class="blockList"><a name="method.summary"> <!-- --> </a> <h3>Method Summary</h3> <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr id="i0" class="altColor"> <td class="colFirst"><code>static void</code></td> <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/ForParagraphList.html#autoSet-kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface-kr.dogfoot.hwplib.writer.autosetter.InstanceID-">autoSet</a></span>(<a href="../../../../../kr/dogfoot/hwplib/object/bodytext/ParagraphListInterface.html" title="interface in kr.dogfoot.hwplib.object.bodytext">ParagraphListInterface</a>&nbsp;pli, <a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/InstanceID.html" title="class in kr.dogfoot.hwplib.writer.autosetter">InstanceID</a>&nbsp;iid)</code> <div class="block">문단 리스트를 자동 설정한다.</div> </td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> <!-- --> </a> <h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li> </ul> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <!-- ========= CONSTRUCTOR DETAIL ======== --> <ul class="blockList"> <li class="blockList"><a name="constructor.detail"> <!-- --> </a> <h3>Constructor Detail</h3> <a name="ForParagraphList--"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>ForParagraphList</h4> <pre>public&nbsp;ForParagraphList()</pre> </li> </ul> </li> </ul> <!-- ============ METHOD DETAIL ========== --> <ul class="blockList"> <li class="blockList"><a name="method.detail"> <!-- --> </a> <h3>Method Detail</h3> <a name="autoSet-kr.dogfoot.hwplib.object.bodytext.ParagraphListInterface-kr.dogfoot.hwplib.writer.autosetter.InstanceID-"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>autoSet</h4> <pre>public static&nbsp;void&nbsp;autoSet(<a href="../../../../../kr/dogfoot/hwplib/object/bodytext/ParagraphListInterface.html" title="interface in kr.dogfoot.hwplib.object.bodytext">ParagraphListInterface</a>&nbsp;pli, <a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/InstanceID.html" title="class in kr.dogfoot.hwplib.writer.autosetter">InstanceID</a>&nbsp;iid)</pre> <div class="block">문단 리스트를 자동 설정한다.</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>pli</code> - 문단 리스트 객체</dd> <dd><code>iid</code> - 인스턴스 id</dd> </dl> </li> </ul> </li> </ul> </li> </ul> </div> </div> <!-- ========= END OF CLASS DATA ========= --> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a name="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/ForParagraphList.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../index-all.html">Index</a></li> <li><a href="../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/ForParagraph.html" title="class in kr.dogfoot.hwplib.writer.autosetter"><span class="typeNameLink">Prev&nbsp;Class</span></a></li> <li><a href="../../../../../kr/dogfoot/hwplib/writer/autosetter/InstanceID.html" title="class in kr.dogfoot.hwplib.writer.autosetter"><span class="typeNameLink">Next&nbsp;Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../../index.html?kr/dogfoot/hwplib/writer/autosetter/ForParagraphList.html" target="_top">Frames</a></li> <li><a href="ForParagraphList.html" target="_top">No&nbsp;Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a name="skip.navbar.bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small>Copyright &#169; 2020. All rights reserved.</small></p> </body> </html>
{ "pile_set_name": "Github" }
'lang sweet.js'; // null export syntax khali = ctx => #`null` export syntax khaali = ctx => #`null` // true export syntax sahi = ctx => #`true` // false export syntax galat = ctx => #`false` export syntax ghalat = ctx => #`false` // if export syntax agar = function (ctx) { let ifparam = ctx.next().value let ifblock = ctx.next().value; let warnas = ctx.next(); let ctxCounter = 3; let result = #`if ${ifparam} ${ifblock}`; while(!warnas.done){ var isWarna = false; if (warnas.value.value.token.value === "warna"){ let elseblock = ctx.next().value; result = result.concat(#`else ${elseblock}`) //isWarna = true; return result; } if (warnas.value.value.token.value === "warnaagar"){ let elseifparam = ctx.next().value; let elseifblock = ctx.next().value; ctxCounter += 2 result = result.concat(#`else if ${elseifparam} ${elseifblock}`) isWarna = true; } if (!isWarna) { // we fetched something beyond this code block. reset context and fwd correctly. ctx.reset() while (--ctxCounter){ ctx.next() } return result; } warnas = ctx.next(); ctxCounter++; } //console.log("warnas",warnas.value.token.value) return result //return #`if ${ifparam} ${ifblock}`; } // var export syntax rakho = ctx => #`var` // while export syntax jabtak = function (ctx) { let wparam = ctx.next().value let wblock = ctx.next().value; return #`while ${wparam} ${wblock}`; } // console.log export syntax likho = ctx => #`console.log ${ctx.next().value}` // alert export syntax _testAlert = ctx => #`alert ${ctx.next().value}` // prompt (only works on browser right now) export syntax pucho = ctx => #`prompt ${ctx.next().value}` // function export syntax kaam = function (ctx) { let fname = ctx.next().value let fparam = ctx.next().value let fblock = ctx.next().value; return #`function ${fname} ${fparam} ${fblock}`; } // for and foreach loop export syntax har = function (ctx) { let fparam = ctx.next().value if (fparam.type==="RawSyntax"){ //foreach let fparamk = ctx.next().value; let fparamvar = ctx.next().value; let fblock = ctx.next().value; //ignore 'per' or 'pe' if present if (fblock.type==="RawSyntax" && (fblock.value.token.value==="per" || fblock.value.token.value==="pe") ){ fblock = ctx.next().value; } return #`for (var ${fparamvar} of ${fparam}) ${fblock}`; } else{ let fblock = ctx.next().value; return #`for ${fparam} ${fblock}`; } } // return export syntax bhejo = ctx => #`return ${ctx.next().value}`; //do while export syntax karo = function(ctx) { let dblock = ctx.next().value; let jabtak = ctx.next(); if(jabtak.value != null){ if(jabtak.value.value.token.value === "jabtak"){ //console.log(jabtak.value.value.token.value); let jabtakparams = ctx.next().value; return #`do ${dblock} while ${jabtakparams}`; } else { return #`console.log("galti: karo ke liye jabtak hona lazmi hai!")`; } } else { return #`console.log("galti: karo ke liye jabtak hona lazmi hai!")`; } } // break export syntax rukjao = (ctx) => #`break`;
{ "pile_set_name": "Github" }
package types import ( "database/sql/driver" "encoding/json" "time" "github.com/pkg/errors" "github.com/cortezaproject/corteza-server/pkg/rh" ) type ( Attachment struct { ID uint64 `db:"id" json:"attachmentID,string"` OwnerID uint64 `db:"rel_owner" json:"ownerID,string"` Kind string `db:"kind" json:"-"` Url string `db:"url" json:"url,omitempty"` PreviewUrl string `db:"preview_url" json:"previewUrl,omitempty"` Name string `db:"name" json:"name,omitempty"` Meta attachmentMeta `db:"meta" json:"meta"` CreatedAt time.Time `db:"created_at" json:"createdAt,omitempty"` UpdatedAt *time.Time `db:"updated_at" json:"updatedAt,omitempty"` DeletedAt *time.Time `db:"deleted_at" json:"deletedAt,omitempty"` } // AttachmentFilter is used for filtering and as a return value from Find AttachmentFilter struct { Kind string `json:"kind,omitempty"` Filter string `json:"filter"` Sort string `json:"sort"` // Standard paging fields & helpers rh.PageFilter } attachmentImageMeta struct { Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` Animated bool `json:"animated"` } attachmentFileMeta struct { Size int64 `json:"size"` Extension string `json:"ext"` Mimetype string `json:"mimetype"` Image *attachmentImageMeta `json:"image,omitempty"` } attachmentMeta struct { Original attachmentFileMeta `json:"original"` Preview *attachmentFileMeta `json:"preview,omitempty"` Labels map[string]string `json:"labels,omitempty"` } ) const ( AttachmentKindSettings string = "settings" ) func (a *Attachment) SetOriginalImageMeta(width, height int, animated bool) *attachmentFileMeta { a.imageMeta(&a.Meta.Original, width, height, animated) return &a.Meta.Original } func (a *Attachment) SetPreviewImageMeta(width, height int, animated bool) *attachmentFileMeta { if a.Meta.Preview == nil { a.Meta.Preview = &attachmentFileMeta{} } a.imageMeta(a.Meta.Preview, width, height, animated) return a.Meta.Preview } func (a *Attachment) imageMeta(in *attachmentFileMeta, width, height int, animated bool) { if in.Image == nil { in.Image = &attachmentImageMeta{} } if width > 0 && height > 0 { in.Image.Animated = animated in.Image.Width = width in.Image.Height = height } } func (meta *attachmentMeta) Scan(value interface{}) error { //lint:ignore S1034 This typecast is intentional, we need to get []byte out of a []uint8 switch value.(type) { case nil: *meta = attachmentMeta{} case []uint8: if err := json.Unmarshal(value.([]byte), meta); err != nil { return errors.Wrapf(err, "Can not scan '%v' into attachmentMeta", value) } } return nil } func (meta attachmentMeta) Value() (driver.Value, error) { return json.Marshal(meta) }
{ "pile_set_name": "Github" }
StartChar: uni0526 Encoding: 1318 1318 716 Width: 1060 Flags: W HStem: 0 21G<30 289.988> 665 210<572.107 785.5> 1276 20G<241 539> VStem: 659 248<-262 -4.79169 326.411 664.075> LayerCount: 2 Fore SplineSet 30 0 m 1 114 432 199 864 283 1296 c 1 539 1296 l 1 426 703 l 1 574 851 624 875 736 875 c 0 835 875 907 786 907 618 c 0 907 492 878 370 848 205 c 1 985 210 l 1 979 183 970 140 964 110 c 0 941 -7 915 -178 914 -262 c 1 663 -283 l 1 665 -225 683 -100 699 0 c 1 552 0 l 1 626 383 659 555 659 624 c 0 659 654 653 665 641 665 c 0 601 665 485 564 353 336 c 1 286 0 l 1 30 0 l 1 EndSplineSet Validated: 1 EndChar
{ "pile_set_name": "Github" }
package main import ( "testing" "github.com/cnabio/cnab-go/bundle" "github.com/stretchr/testify/assert" ) func TestGenCredentialSet(t *testing.T) { name := "zed" credlocs := map[string]bundle.Credential{ "first": { Location: bundle.Location{ EnvironmentVariable: "FIRST_VAR", }, }, "second": { Location: bundle.Location{ EnvironmentVariable: "SECOND_VAR", Path: "/second/path", }, }, "third": { Location: bundle.Location{ Path: "/third/path", }, }, } is := assert.New(t) creds, err := genCredentialSet(name, credlocs, genEmptyCredentials) is.NoError(err) is.Equal(creds.Name, name) is.Len(creds.Credentials, 3) found := map[string]bool{"first": false, "second": false, "third": false} var assignmentOrder []string for _, cred := range creds.Credentials { assignmentOrder = append(assignmentOrder, cred.Name) found[cred.Name] = true is.Equal(cred.Source.Value, "EMPTY") } is.Equal([]string{"first", "second", "third"}, assignmentOrder) is.Len(found, 3) for k, v := range found { is.True(v, "%q not found", k) } } func TestGenCredentialSetBadName(t *testing.T) { testcases := []string{ "period.", "forwardslash/", "backslash\\", "all.of.the/above\\", } for _, tc := range testcases { t.Run(tc, func(t *testing.T) { is := assert.New(t) _, err := genCredentialSet(tc, nil, genEmptyCredentials) is.Error(err) }) } }
{ "pile_set_name": "Github" }
package org.redisson.executor; import java.io.Serializable; import java.util.concurrent.Callable; public class ParameterizedTask implements Callable<String>, Serializable { private String param; public ParameterizedTask() { } public ParameterizedTask(String param) { super(); this.param = param; } @Override public String call() throws Exception { return param; } }
{ "pile_set_name": "Github" }
/** * @auther: TKQ * @Title: LeetCode_200_346 * @Copyright: Copyright (c) 2019 * @Description: * @Company: * @Created: 2019-11-03 14:04 */ public class LeetCode_200_346 { private int n; private int m; public int numIslands(char[][] grid) { int count = 0; n = grid.length; if (n == 0) {return 0;} m = grid[0].length; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (grid[i][j] == '1') { DFSMarking(grid, i, j); ++count; } } } return count; } private void DFSMarking(char[][] grid, int i, int j) { if (i < 0 || j < 0 || i >= n || j >= m || grid[i][j] != '1') {return;} grid[i][j] = '0'; DFSMarking(grid, i + 1, j); DFSMarking(grid, i - 1, j); DFSMarking(grid, i, j + 1); DFSMarking(grid, i, j - 1); } }
{ "pile_set_name": "Github" }
import randomSeed from './random'; const femaleFirstNames = ['Mary', 'Linda', 'Barbara', 'Maria', 'Lisa', 'Nancy', 'Betty', 'Sandra', 'Sharon']; const maleFirstNames = ['James', 'John', 'Robert', 'William', 'David', 'Richard', 'Thomas', 'Paul', 'Mark']; const lastNames = [ 'Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Johnson', 'Miller', 'Wilson', 'Moore', 'Taylor', 'Anderson', 'Thomas', 'Jackson', 'Williams', 'White', 'Harris', 'Davis', 'Martin', 'Thompson', 'Garcia', 'Martinez', 'Robinson', 'Clark', ]; const usStates = [ { name: 'Alabama', abbr: 'AL' }, { name: 'Alaska', abbr: 'AK' }, { name: 'American Samoa', abbr: 'AS' }, { name: 'Arizona', abbr: 'AZ' }, { name: 'Arkansas', abbr: 'AR' }, { name: 'California', abbr: 'CA' }, { name: 'Colorado', abbr: 'CO' }, { name: 'Connecticut', abbr: 'CT' }, { name: 'Delaware', abbr: 'DE' }, { name: 'District Of Columbia', abbr: 'DC' }, { name: 'Federated States Of Micronesia', abbr: 'FM' }, { name: 'Florida', abbr: 'FL' }, { name: 'Georgia', abbr: 'GA' }, { name: 'Guam', abbr: 'GU' }, { name: 'Hawaii', abbr: 'HI' }, { name: 'Idaho', abbr: 'ID' }, { name: 'Illinois', abbr: 'IL' }, { name: 'Indiana', abbr: 'IN' }, { name: 'Iowa', abbr: 'IA' }, { name: 'Kansas', abbr: 'KS' }, { name: 'Kentucky', abbr: 'KY' }, { name: 'Louisiana', abbr: 'LA' }, { name: 'Maine', abbr: 'ME' }, { name: 'Marshall Islands', abbr: 'MH' }, { name: 'Maryland', abbr: 'MD' }, { name: 'Massachusetts', abbr: 'MA' }, { name: 'Michigan', abbr: 'MI' }, { name: 'Minnesota', abbr: 'MN' }, { name: 'Mississippi', abbr: 'MS' }, { name: 'Missouri', abbr: 'MO' }, { name: 'Montana', abbr: 'MT' }, { name: 'Nebraska', abbr: 'NE' }, { name: 'Nevada', abbr: 'NV' }, { name: 'New Hampshire', abbr: 'NH' }, { name: 'New Jersey', abbr: 'NJ' }, { name: 'New Mexico', abbr: 'NM' }, { name: 'New York', abbr: 'NY' }, { name: 'North Carolina', abbr: 'NC' }, { name: 'North Dakota', abbr: 'ND' }, { name: 'Northern Mariana Islands', abbr: 'MP' }, { name: 'Ohio', abbr: 'OH' }, { name: 'Oklahoma', abbr: 'OK' }, { name: 'Oregon', abbr: 'OR' }, { name: 'Palau', abbr: 'PW' }, { name: 'Pennsylvania', abbr: 'PA' }, { name: 'Puerto Rico', abbr: 'PR' }, { name: 'Rhode Island', abbr: 'RI' }, { name: 'South Carolina', abbr: 'SC' }, { name: 'South Dakota', abbr: 'SD' }, { name: 'Tennessee', abbr: 'TN' }, { name: 'Texas', abbr: 'TX' }, { name: 'Utah', abbr: 'UT' }, { name: 'Vermont', abbr: 'VT' }, { name: 'Virgin Islands', abbr: 'VI' }, { name: 'Virginia', abbr: 'VA' }, { name: 'Washington', abbr: 'WA' }, { name: 'West Virginia', abbr: 'WV' }, { name: 'Wisconsin', abbr: 'WI' }, { name: 'Wyoming', abbr: 'WY' }, ]; const cities = ['New York', 'Los Angeles', 'Chicago', 'Las Vegas', 'Austin', 'Tokyo', 'Rio de Janeiro', 'London', 'Paris']; const cars = ['Honda Civic', 'Toyota Corolla', 'Chevrolet Cruze', 'Honda Accord', 'Nissan Altima', 'Kia Optima', 'Audi A4', 'BMW 750']; const positions = ['CEO', 'IT Manager', 'Ombudsman', 'CMO', 'Controller', 'HR Manager', 'Shipping Manager', 'Sales Assistant', 'HR Assistant']; const generateDate = ({ random, year = 2017, month = rand => Math.floor(rand() * 12), day = rand => Math.floor(rand() * 30) + 1, }) => { const getPart = part => (typeof part === 'function' ? part(random) : part); const date = new Date(Date.UTC(getPart(year), getPart(month), getPart(day))); return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`; }; export const defaultColumnValues = { gender: ['Male', 'Female'], name: [ 'gender', { Male: maleFirstNames, Female: femaleFirstNames, }, ], city: cities, car: cars, }; export const defaultNestedColumnValues = { user: [ ...[...maleFirstNames, ...femaleFirstNames].map((name, i) => ({ firstName: name, lastName: lastNames[i], })), ], position: positions, city: cities, car: cars.map(car => ({ model: car })), }; export const globalSalesValues = { region: ['Asia', 'Europe', 'North America', 'South America', 'Australia', 'Africa'], sector: ['Energy', 'Health', 'Manufacturing', 'Insurance', 'Banking', 'Telecom'], channel: ['Resellers', 'Retail', 'VARs', 'Consultants', 'Direct', 'Telecom'], units: ({ random }) => Math.floor(random() * 4) + 1, customer: [ 'Renewable Supplies', 'Energy Systems', 'Environment Solar', 'Beacon Systems', 'Apollo Inc', 'Gemini Stores', 'McCord Builders', 'Building M Inc', 'Global Services', 'Market Eco', 'Johnson & Assoc', 'Get Solar Inc', 'Supply Warehouse', 'Discovery Systems', 'Mercury Solar'], product: ['SolarMax', 'SolarOne', 'EnviroCare', 'EnviroCare Max'], amount: ({ random }) => Math.floor(random() * 10000) + 1000, discount: ({ random }) => Math.round(random() * 0.5 * 1000) / 1000, saleDate: ({ random }) => generateDate({ random, year: 2016, month: () => Math.floor(random() * 3) + 1, }), shipped: [true, false], }; export const employeeValues = { gender: ['Male', 'Female'], prefix: [ 'gender', { Male: ['Mr.', 'Dr.'], Female: ['Mrs.', 'Ms.', 'Dr.'], }, ], firstName: [ 'gender', { Male: maleFirstNames, Female: femaleFirstNames, }, ], lastName: lastNames, position: positions, state: usStates.map(state => state.name), birthDate: ({ random }) => generateDate({ random, year: () => Math.floor(random() * 30) + 1960, }), }; export const employeeTaskValues = { priority: ['High', 'Low', 'Normal'], status: ['Completed', 'In Progress', 'Deferred', 'Need Assistance'], subject: [ 'Choose between PPO and HMO Health Plan', 'Google AdWords Strategy', 'New Brochures', 'Update NDA Agreement', 'Review Product Recall Report by Engineering Team', 'Update Personnel Files', 'Review Health Insurance Options Under the Affordable Care Act', 'Non-Compete Agreements', 'Give Final Approval for Refunds', 'Deliver R&D Plans', 'Decide on Mobile Devices to Use in the Field', 'Try New Touch-Enabled Apps', 'Approval on Converting to New HDMI Specification', 'Approve Hiring', 'Update Employee Files with New NDA', 'Provide New Health Insurance Docs', 'Prepare 3013 Marketing Plan', 'Rollout of New Website and Marketing Brochures', 'Review Sales Report and Approve Plans', 'Review Site Up-Time Report', 'Review HR Budget Company Wide', 'Final Budget Review', 'Sign Updated NDA', 'Review Overtime Report', 'Upgrade Server Hardware', 'Upgrade Personal Computers', 'Prepare Financial', 'Update Revenue Projections', 'Submit D&B Number to ISP for Credit Approval', 'Update Sales Strategy Documents', 'Refund Request Template', ], startDate: ({ random }) => generateDate({ random, year: 2016, }), dueDate: ({ random, record }) => generateDate({ random, year: 2016, month: () => Math.floor(random() * 2) + (new Date(record.startDate)).getMonth(), }), }; export function generateRows({ columnValues = defaultColumnValues, length, random = randomSeed(329972281), }) { const data = []; const columns = Object.keys(columnValues); for (let i = 0; i < length; i += 1) { const record = {}; columns.forEach((column) => { let values = columnValues[column]; if (typeof values === 'function') { record[column] = values({ random, index: i, record }); return; } while (values.length === 2 && typeof values[1] === 'object') { values = values[1][record[values[0]]]; } const value = values[Math.floor(random() * values.length)]; if (typeof value === 'object') { record[column] = Object.assign({}, value); } else { record[column] = value; } }); data.push(record); } return data; }
{ "pile_set_name": "Github" }
#* * Copyright (C) 2011-2015 The XDocReport Team <xdocreport@googlegroups.com> * * All rights reserved. * * 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. *# #if( $packageName )package ${packageName};#end import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.io.StringReader; import java.util.Map; import fr.opensagres.xdocreport.core.utils.Base64Utility; import fr.opensagres.xdocreport.document.IXDocReport; import fr.opensagres.xdocreport.document.json.JSONObject; import fr.opensagres.xdocreport.document.json.JSONTokener; import fr.opensagres.xdocreport.document.registry.XDocReportRegistry; import fr.opensagres.xdocreport.template.formatter.FieldsMetadata; import fr.opensagres.xdocreport.template.formatter.FieldsMetadataXMLSerializer; public class ${className} { public static void main( String[] args ) { try { // Load report #if( $document )String document = "${document}"; InputStream in = new ByteArrayInputStream( Base64Utility.decode( document ) ); #{else}InputStream in = ${className}.class.getResourceAsStream("${documentFile}"); #{end}IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, null, "${templateEngineKind}" ); #if( $xmlFields ) // Set FieldsMetadata StringReader fieldsReader = new StringReader(${xmlFields}); FieldsMetadata metadata = FieldsMetadataXMLSerializer.getInstance().load( fieldsReader ); report.setFieldsMetadata( metadata ); #else #if( $xmlFieldsFile ) // Set FieldsMetadata InputStream fieldsStream = ${className}.class.getResourceAsStream("${xmlFieldsFile}"); FieldsMetadata metadata = FieldsMetadataXMLSerializer.getInstance().load( fieldsStream ); report.setFieldsMetadata( metadata ); #end #end // Create context #if( $json )String json = "${json}"; Map context = new JSONObject( json ); #{else}InputStream jsonStream = ${className}.class.getResourceAsStream("${jsonFile}"); Map context = new JSONObject( new JSONTokener(jsonStream) ); #end // Generate report by merging context and template report. OutputStream out = new FileOutputStream( new File( "${outFileName}" ) ); report.process( context, out ); } catch ( Exception e ) { e.printStackTrace(); } } }
{ "pile_set_name": "Github" }
/* *Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * *WSO2 Inc. licenses this file to you 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 org.wso2.carbon.esb.mediator.test.payload.factory; import org.apache.axiom.om.OMElement; import org.apache.axis2.AxisFault; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.esb.integration.common.utils.ESBIntegrationTest; import org.wso2.esb.integration.common.utils.ESBTestConstant; import javax.xml.xpath.XPathExpressionException; import static org.testng.Assert.assertTrue; public class TransformPayloadWhenArgsValueTestCase extends ESBIntegrationTest { @BeforeClass(alwaysRun = true) public void uploadSynapseConfig() throws Exception { super.init(); loadESBConfigurationFromClasspath("/artifacts/ESB/mediatorconfig/payload/factory/value_arg_payload_factory_synapse.xml"); } @Test(groups = {"wso2.esb"}, description = "Do transformation with a Payload Format that has arguments - Argument Type : Value") public void transformPayloadByArgsValue() throws AxisFault, XPathExpressionException { OMElement response; response = axis2Client.sendSimpleStockQuoteRequest(getMainSequenceURL(), getBackEndServiceUrl(ESBTestConstant.SIMPLE_STOCK_QUOTE_SERVICE), "IBM"); assertTrue(response.toString().contains("WSO2"), "Symbol WSO2 not found in response message"); } @AfterClass(alwaysRun = true) private void destroy() throws Exception { super.cleanup(); } }
{ "pile_set_name": "Github" }
--- title: "Companion 2.0 is here" date: 2020-09-09 author: ife published: true --- We are happy to announce version 2.0 of Companion! 🎉 After maintaining and improving the 1.x series for over a year, we're now releasing a major version bump on the Companion package. The drive on this release is mainly towards fixing some terminology inconsistencies and aligning with Node.js LTS to ease the maintenance burden. <!--more--> So what are the changes you can expect with Companion 2.0? ## Node >= v10 Node.js 8.x has reached end-of-life. Consequently, Companion 2.0 has dropped support for Node.js 6.x and Node.js 8.x, and now requires that you run at least Node.js 10.20.1. ## Renamed provider options Pre 2.0, there were inconsistencies in relation to the provider names. In some places, the Google Drive provider was referred to as *google* (e.g., in `providerOptions`) while in some other places, it was referred to as *drive* (e.g., the server endpoints `/drive/list`). Companion 2.0 now consistently uses the name *drive* everywhere. Similarly, the OneDrive provider was made to have the consistent name *onedrive*. ## Changed Redirect URIs On the topic of consistent naming, we have also made some changes to the redirect URIs supplied during the OAuth process. For example, in the case of Google Drive, the form of the old redirect URI was `https://mycompanionwebsite.tld/connect/google/callback`. In Companion 2.0, this is now changed to `https://mycompanionwebsite.tld/drive/redirect`. This is a Breaking Change: you will need to make the corresponding changes to your redirect URIs on your Providers' API Dashboards. ## Compatibility with Uppy 1.x client Companion 2.0 is compatible with any Uppy 1.x version, so you don't have to worry about upgrading your Uppy client installations when you upgrade Companion on your server. ## Will Companion v1 still receive updates? Companion 1.x will continue to receive security patches until March 1, 2021. ## Migrating from Companion 1.x to 2.x Given the breaking changes, we've created a [migration tutorial for upgrading from Companion v1 to v2](https://uppy.io/docs/companion/#Migrating-v1-to-v2).
{ "pile_set_name": "Github" }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using indice.Edi.Serialization; namespace indice.Edi.Tests.Models { public class EDIFact_D01B_IFCSUM { public List<Message> Messages { get; set; } [EdiMessage] public class Message { public BeginingOfMessage BeginingOfMessage { get; set; } [EdiCondition("10", Path = "CNT/0/0")] public ControlTotal TotalNumberOfConsignments { get; set; } [EdiCondition("7", Path = "CNT/0/0")] public ControlTotal TotalGrossWeight { get; set; } [EdiCondition("137", Path = "DTM/0/0")] public Date Date { get; set; } [EdiCondition("11", Path = "DTM/0/0")] public Date DespatchDate { get; set; } /// <summary> /// Party which, by contract with a carrier, consigns or sends goods with the carrier, or has them conveyed by him. Synonym: shipper, sender. /// </summary> [EdiCondition("CZ", Path = "NAD/0/0")] public NameAndAddress Sender { get; set; } /// <summary> /// Party undertaking or arranging transport of goods between named points. /// </summary> [EdiCondition("CA", Path = "NAD/0/0")] public NameAndAddress Carrier { get; set; } public List<Consignment> Consignments { get; set; } } [EdiSegment, EdiPath("BGM")] public class BeginingOfMessage { public MessageName Name { get; set; } public MessageIdentification Identification { get; set; } public override string ToString() => $"{Name} {Identification}"; [EdiElement, EdiPath("BGM/0")] public class MessageName { [EdiValue("X(3)", Path = "BGM/0/0")] public string NameCode { get; set; } [EdiValue("X(17)", Path = "BGM/0/1")] public string IdentificationCode { get; set; } [EdiValue("X(3)", Path = "BGM/0/2")] public string ResponsibleAgencyCode { get; set; } [EdiValue("X(35)", Path = "BGM/0/3")] public string Name { get; set; } public override string ToString() { return $"{NameCode} {Name}".Trim(); } } [EdiElement, EdiPath("BGM/1")] public class MessageIdentification { [EdiValue("X(35)", Path = "BGM/1/0")] public string DocumentId { get; set; } [EdiValue("X(9)", Path = "BGM/1/1")] public string VersionId { get; set; } [EdiValue("X(6)", Path = "BGM/1/2")] public string RevisionId { get; set; } [EdiValue("X(3)", Path = "BGM/1/3")] public string MessageFucntionCode { get; set; } [EdiValue("X(3)", Path = "BGM/1/4")] public string ResponseTypeCode { get; set; } public override string ToString() { return $"{DocumentId}.{VersionId}.{RevisionId}"; } } } [EdiSegment, EdiPath("CNT")] public class ControlTotal { [EdiValue("X(3)", Path = "CNT/0/0")] public string Code { get; set; } [EdiValue("9(18)", Path = "CNT/0/1")] public decimal Value { get; set; } [EdiValue("X(3)", Path = "CNT/0/2")] public string MeasurementUnit { get; set; } public override string ToString() => $"{Value} {MeasurementUnit}".Trim(); public static implicit operator decimal(ControlTotal total) => total.Value; } [EdiSegmentGroup("CNI")] public class Consignment : ConsignmentInformation { [EdiCondition("2", Path = "DTM/0/0")] public DateTimePeriod DeliveryDate { get; set; } [EdiCondition("2", Path = "CNT/0/0")] public ControlTotal NumberOfLines { get; set; } [EdiCondition("7", Path = "CNT/0/0")] public ControlTotal TotalGrossWeight { get; set; } [EdiCondition("11", Path = "CNT/0/0")] public ControlTotal TotalNumberOfPackages { get; set; } public Party Party { get; set; } public List<GoodsItem> Goods { get; set; } } [EdiSegment, EdiPath("CNI")] public class ConsignmentInformation { [EdiValue("9(4)", Path = "CNI/0/0")] public int ConsolidationItemNumber { get; set; } public DocumentDetails Document { get; set; } [EdiValue("9(4)", Path = "CNI/2/0")] public string LoadSequenceIdentifier { get; set; } [EdiElement, EdiPath("CNI/1")] public class DocumentDetails { [EdiValue("X(35)", Path = "CNI/1/0")] public string Identifier { get; set; } [EdiValue("X(3)", Path = "CNI/1/1")] public string StatusCode { get; set; } [EdiValue("X(70)", Path = "CNI/1/2")] public string SourceDescription { get; set; } [EdiValue("X(3)", Path = "CNI/1/3")] public string LanguageNameCode { get; set; } [EdiValue("X(9)", Path = "CNI/1/4")] public string VersionIdentifier { get; set; } [EdiValue("X(6)", Path = "CNI/1/5")] public string RevisionIdentifier { get; set; } public override string ToString() => $"{Identifier} {SourceDescription}".Trim(); } public override string ToString() => $"{ConsolidationItemNumber}. {Document}".Trim(); } [EdiSegmentGroup("GID", "HAN", "TMP", "RNG", "TMD", "LOC", "MOA", "PIA", "GIN", "FTX")] public class GoodsItem : GoodsItemDetails { } [EdiSegment, EdiPath("GID")] public class GoodsItemDetails { [EdiValue("9(5)", Path = "GID/0/0")] public int ItemNumber { get; set; } } [EdiSegment, EdiPath("NAD")] public class NameAndAddress { [EdiValue("X(3)", Path = "NAD/0/0")] public string PartyFunctionCode { get; set; } public PartyIdentificationDetails Identification { get; set; } public NameAndAddressDescription Description { get; set; } public PartyName Name { get; set; } public AddressLines Street { get; set; } [EdiValue("X(35)", Path = "NAD/5/0")] public string City { get; set; } public CountryDetails Country { get; set; } [EdiValue("X(17)", Path = "NAD/7/0")] public string PostalIdentificationCode { get; set; } [EdiValue("X(3)", Path = "NAD/8/0")] public string CountryNameCode { get; set; } public override string ToString() { var sb = new StringBuilder(); sb.AppendLine(Name.ToString()); sb.AppendLine(" @ "); sb.AppendLine($"{Street}"); sb.AppendLine($"{City}, {Country}".Trim(' ', ',')); return sb.ToString(); } [EdiElement, EdiPath("NAD/1")] public class PartyIdentificationDetails { [EdiValue("X(35)", Path = "NAD/1/0")] public string Identifier { get; set; } [EdiValue("X(17)", Path = "NAD/1/1")] public string CodeListIdentificationCode { get; set; } [EdiValue("X(3)", Path = "NAD/1/2")] public string CodeListResponsibleAgencyCode { get; set; } public override string ToString() => Identifier; } [EdiElement, EdiPath("NAD/2")] public class NameAndAddressDescription { [EdiValue("X(35)", Path = "NAD/2/0")] public string Part1 { get; set; } [EdiValue("X(35)", Path = "NAD/2/1")] public string Part2 { get; set; } [EdiValue("X(35)", Path = "NAD/2/2")] public string Part3 { get; set; } [EdiValue("X(35)", Path = "NAD/2/3")] public string Part4 { get; set; } [EdiValue("X(35)", Path = "NAD/2/4")] public string Part5 { get; set; } public override string ToString() => $"{Part1} {Part2} {Part3} {Part4} {Part5}".Trim(); } [EdiElement, EdiPath("NAD/3")] public class PartyName { [EdiValue("X(35)", Path = "NAD/3/0")] public string Part1 { get; set; } [EdiValue("X(35)", Path = "NAD/3/1")] public string Part2 { get; set; } [EdiValue("X(35)", Path = "NAD/3/2")] public string Part3 { get; set; } [EdiValue("X(35)", Path = "NAD/3/3")] public string Part4 { get; set; } [EdiValue("X(35)", Path = "NAD/3/4")] public string Part5 { get; set; } [EdiValue("X(3)", Path = "NAD/3/5")] public string FormatCode { get; set; } public override string ToString() => $"{Part1} {Part2} {Part3} {Part4} {Part5}".Trim(); } [EdiElement, EdiPath("NAD/4")] public class AddressLines { [EdiValue("X(35)", Path = "NAD/4/0")] public string Line1 { get; set; } [EdiValue("X(35)", Path = "NAD/4/1")] public string Line2 { get; set; } [EdiValue("X(35)", Path = "NAD/4/2")] public string Line3 { get; set; } [EdiValue("X(35)", Path = "NAD/4/3")] public string Line4 { get; set; } public override string ToString() => Line1; } [EdiElement, EdiPath("NAD/6")] public class CountryDetails { [EdiValue("X(9)", Path = "NAD/6/0")] public string CountrySubentryNameCode { get; set; } [EdiValue("X(17)", Path = "NAD/6/1")] public string CodeListIdentificationCode { get; set; } [EdiValue("X(3)", Path = "NAD/6/2")] public string CodeListResponsibleAgencyCode { get; set; } [EdiValue("X(70)", Path = "NAD/6/3")] public string CountrySubentryName { get; set; } public override string ToString() => $"{CountrySubentryNameCode} {CountrySubentryName}".Trim(); } } [EdiSegmentGroup("NAD", "CTA", "RFF")] public class Party : NameAndAddress { public Contact Contact { get; set; } [EdiCondition("DQ", Path = "RFF/0/0")] public ReferenceAndDate DeliveryNoteNumber { get; set; } [EdiCondition("CR", Path = "RFF/0/0")] public ReferenceAndDate CustomerReferenceNumber { get; set; } [EdiCondition("DQ", "CR", CheckFor = EdiConditionCheckType.NotEqual, Path = "RFF/0/0")] public List<ReferenceAndDate> OtherReferences { get; set; } } [EdiSegment, EdiPath("RFF")] public class Reference { [EdiValue("X(3)", Path = "RFF/0/0")] public string CodeQualifier { get; set; } [EdiValue("X(70)", Path = "RFF/0/1")] public string Identifier { get; set; } [EdiValue("X(6)", Path = "RFF/0/2")] public string DocumentLineIdentifier { get; set; } [EdiValue("X(35)", Path = "RFF/0/3")] public string ReferenceVersionIdentifier { get; set; } [EdiValue("X(6)", Path = "RFF/0/4")] public string RevisionIdentifier { get; set; } public override string ToString() => $"{Identifier} {DocumentLineIdentifier} {ReferenceVersionIdentifier} {RevisionIdentifier}".Trim(); } [EdiSegmentGroup("RFF", "DTM")] public class ReferenceAndDate : Reference { public DateTimePeriod Date { get; set; } } [EdiSegmentGroup("CTA", "COM")] public class Contact : ContactInformation { public ContactCommunication Communication { get; set; } } [EdiSegment, EdiPath("DTM")] public class DateTimePeriod { [EdiValue(Path = "DTM/0/0")] public int Function { get; set; } [EdiValue("9(12)", Path = "DTM/0/1", Format = "yyyyMMddHHmm")] public virtual DateTime Value { get; set; } [EdiValue("9(8)", Path = "DTM/0/2")] public string Code { get; set; } public static implicit operator DateTime(DateTimePeriod input) => input.Value; public override string ToString() => Value.ToString(); } public class Date : DateTimePeriod { [EdiValue("9(8)", Path = "DTM/0/1", Format = "yyyyMMdd")] public override DateTime Value { get => base.Value; set => base.Value = value; } } /// <summary> /// COM - To identify a communication number of a department or a person to whom communication should be directed. /// </summary> [EdiSegment, EdiPath("COM")] public class ContactCommunication { /// <summary> /// This should be a list /// </summary> public ContactCommunicationEntry[] Entries { get; set; } public override string ToString() => Entries?.FirstOrDefault()?.ToString(); [EdiElement, EdiPath("COM/0")] public class ContactCommunicationEntry { [EdiValue("X(512)", Path = "COM/0/0")] public string AddressIdentifier { get; set; } [EdiValue("X(3)", Path = "COM/0/1")] public string AddressCodeQualifier { get; set; } public override string ToString() => $"{AddressCodeQualifier} {AddressIdentifier}".Trim(); } } [EdiSegment, EdiPath("CNI")] public class ContactInformation { [EdiValue("X(3)", Path = "CNI/0/0")] public string ContactFunctionCode { get; set; } public DepartmentOrEmployeeDetails Details { get; set; } public override string ToString() => $"{ContactFunctionCode} {Details}".Trim(); [EdiElement, EdiPath("CNI/1")] public class DepartmentOrEmployeeDetails { [EdiValue("X(17)", Path = "CNI/1/0")] public string DepartmentOrEmployeeNameCode { get; set; } [EdiValue("X(35)", Path = "CNI/1/1")] public string DepartmentOrEmployeeName { get; set; } public override string ToString() => $"{DepartmentOrEmployeeNameCode} {DepartmentOrEmployeeName}".Trim(); } } } }
{ "pile_set_name": "Github" }
/* ssl/s3_pkt.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ #include <stdio.h> #include <errno.h> #define USE_SOCKETS #include "ssl_locl.h" #include <openssl/evp.h> #include <openssl/buffer.h> #include <openssl/rand.h> static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment); static int ssl3_get_record(SSL *s); int ssl3_read_n(SSL *s, int n, int max, int extend) { /* If extend == 0, obtain new n-byte packet; if extend == 1, increase * packet by another n bytes. * The packet will be in the sub-array of s->s3->rbuf.buf specified * by s->packet and s->packet_length. * (If s->read_ahead is set, 'max' bytes may be stored in rbuf * [plus s->packet_length bytes if extend == 1].) */ int i,len,left; long align=0; unsigned char *pkt; SSL3_BUFFER *rb; if (n <= 0) return n; rb = &(s->s3->rbuf); if (rb->buf == NULL) if (!ssl3_setup_read_buffer(s)) return -1; left = rb->left; #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 align = (long)rb->buf + SSL3_RT_HEADER_LENGTH; align = (-align)&(SSL3_ALIGN_PAYLOAD-1); #endif if (!extend) { /* start with empty packet ... */ if (left == 0) rb->offset = align; else if (align != 0 && left >= SSL3_RT_HEADER_LENGTH) { /* check if next packet length is large * enough to justify payload alignment... */ pkt = rb->buf + rb->offset; if (pkt[0] == SSL3_RT_APPLICATION_DATA && (pkt[3]<<8|pkt[4]) >= 128) { /* Note that even if packet is corrupted * and its length field is insane, we can * only be led to wrong decision about * whether memmove will occur or not. * Header values has no effect on memmove * arguments and therefore no buffer * overrun can be triggered. */ memmove (rb->buf+align,pkt,left); rb->offset = align; } } s->packet = rb->buf + rb->offset; s->packet_length = 0; /* ... now we can act as if 'extend' was set */ } /* For DTLS/UDP reads should not span multiple packets * because the read operation returns the whole packet * at once (as long as it fits into the buffer). */ if (SSL_version(s) == DTLS1_VERSION || SSL_version(s) == DTLS1_BAD_VER) { if (left > 0 && n > left) n = left; } /* if there is enough in the buffer from a previous read, take some */ if (left >= n) { s->packet_length+=n; rb->left=left-n; rb->offset+=n; return(n); } /* else we need to read more data */ len = s->packet_length; pkt = rb->buf+align; /* Move any available bytes to front of buffer: * 'len' bytes already pointed to by 'packet', * 'left' extra ones at the end */ if (s->packet != pkt) /* len > 0 */ { memmove(pkt, s->packet, len+left); s->packet = pkt; rb->offset = len + align; } if (n > (int)(rb->len - rb->offset)) /* does not happen */ { SSLerr(SSL_F_SSL3_READ_N,ERR_R_INTERNAL_ERROR); return -1; } if (!s->read_ahead) /* ignore max parameter */ max = n; else { if (max < n) max = n; if (max > (int)(rb->len - rb->offset)) max = rb->len - rb->offset; } while (left < n) { /* Now we have len+left bytes at the front of s->s3->rbuf.buf * and need to read in more until we have len+n (up to * len+max if possible) */ clear_sys_error(); if (s->rbio != NULL) { s->rwstate=SSL_READING; i=BIO_read(s->rbio,pkt+len+left, max-left); } else { SSLerr(SSL_F_SSL3_READ_N,SSL_R_READ_BIO_NOT_SET); i = -1; } if (i <= 0) { rb->left = left; if (s->mode & SSL_MODE_RELEASE_BUFFERS && SSL_version(s) != DTLS1_VERSION && SSL_version(s) != DTLS1_BAD_VER) if (len+left == 0) ssl3_release_read_buffer(s); return(i); } left+=i; /* reads should *never* span multiple packets for DTLS because * the underlying transport protocol is message oriented as opposed * to byte oriented as in the TLS case. */ if (SSL_version(s) == DTLS1_VERSION || SSL_version(s) == DTLS1_BAD_VER) { if (n > left) n = left; /* makes the while condition false */ } } /* done reading, now the book-keeping */ rb->offset += n; rb->left = left - n; s->packet_length += n; s->rwstate=SSL_NOTHING; return(n); } /* Call this to get a new input record. * It will return <= 0 if more data is needed, normally due to an error * or non-blocking IO. * When it finishes, one packet has been decoded and can be found in * ssl->s3->rrec.type - is the type of record * ssl->s3->rrec.data, - data * ssl->s3->rrec.length, - number of bytes */ /* used only by ssl3_read_bytes */ static int ssl3_get_record(SSL *s) { int ssl_major,ssl_minor,al; int enc_err,n,i,ret= -1; SSL3_RECORD *rr; SSL_SESSION *sess; unsigned char *p; unsigned char md[EVP_MAX_MD_SIZE]; short version; unsigned mac_size, orig_len; size_t extra; rr= &(s->s3->rrec); sess=s->session; if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER) extra=SSL3_RT_MAX_EXTRA; else extra=0; if (extra && !s->s3->init_extra) { /* An application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER * set after ssl3_setup_buffers() was done */ SSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR); return -1; } again: /* check if we have the header */ if ( (s->rstate != SSL_ST_READ_BODY) || (s->packet_length < SSL3_RT_HEADER_LENGTH)) { n=ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0); if (n <= 0) return(n); /* error or non-blocking */ s->rstate=SSL_ST_READ_BODY; p=s->packet; /* Pull apart the header into the SSL3_RECORD */ rr->type= *(p++); ssl_major= *(p++); ssl_minor= *(p++); version=(ssl_major<<8)|ssl_minor; n2s(p,rr->length); #if 0 fprintf(stderr, "Record type=%d, Length=%d\n", rr->type, rr->length); #endif /* Lets check version */ if (!s->first_packet) { if (version != s->version) { SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER); if ((s->version & 0xFF00) == (version & 0xFF00)) /* Send back error using their minor version number :-) */ s->version = (unsigned short)version; al=SSL_AD_PROTOCOL_VERSION; goto f_err; } } if ((version>>8) != SSL3_VERSION_MAJOR) { SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_WRONG_VERSION_NUMBER); goto err; } if (rr->length > s->s3->rbuf.len - SSL3_RT_HEADER_LENGTH) { al=SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG); goto f_err; } /* now s->rstate == SSL_ST_READ_BODY */ } /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ if (rr->length > s->packet_length-SSL3_RT_HEADER_LENGTH) { /* now s->packet_length == SSL3_RT_HEADER_LENGTH */ i=rr->length; n=ssl3_read_n(s,i,i,1); if (n <= 0) return(n); /* error or non-blocking io */ /* now n == rr->length, * and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */ } s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */ /* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length, * and we have that many bytes in s->packet */ rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]); /* ok, we can now read from 's->packet' data into 'rr' * rr->input points at rr->length bytes, which * need to be copied into rr->data by either * the decryption or by the decompression * When the data is 'copied' into the rr->data buffer, * rr->input will be pointed at the new buffer */ /* We now have - encrypted [ MAC [ compressed [ plain ] ] ] * rr->length bytes of encrypted compressed stuff. */ /* check is not needed I believe */ if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) { al=SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG); goto f_err; } /* decrypt in place in 'rr->input' */ rr->data=rr->input; enc_err = s->method->ssl3_enc->enc(s,0); /* enc_err is: * 0: (in non-constant time) if the record is publically invalid. * 1: if the padding is valid * -1: if the padding is invalid */ if (enc_err == 0) { al=SSL_AD_DECRYPTION_FAILED; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); goto f_err; } #ifdef TLS_DEBUG printf("dec %d\n",rr->length); { unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); } printf("\n"); #endif /* r->length is now the compressed data plus mac */ if ((sess != NULL) && (s->enc_read_ctx != NULL) && (EVP_MD_CTX_md(s->read_hash) != NULL)) { /* s->read_hash != NULL => mac_size != -1 */ unsigned char *mac = NULL; unsigned char mac_tmp[EVP_MAX_MD_SIZE]; mac_size=EVP_MD_CTX_size(s->read_hash); OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); /* kludge: *_cbc_remove_padding passes padding length in rr->type */ orig_len = rr->length+((unsigned int)rr->type>>8); /* orig_len is the length of the record before any padding was * removed. This is public information, as is the MAC in use, * therefore we can safely process the record in a different * amount of time if it's too short to possibly contain a MAC. */ if (orig_len < mac_size || /* CBC records must have a padding length byte too. */ (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE && orig_len < mac_size+1)) { al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); goto f_err; } if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE) { /* We update the length so that the TLS header bytes * can be constructed correctly but we need to extract * the MAC in constant time from within the record, * without leaking the contents of the padding bytes. * */ mac = mac_tmp; ssl3_cbc_copy_mac(mac_tmp, rr, mac_size, orig_len); rr->length -= mac_size; } else { /* In this case there's no padding, so |orig_len| * equals |rec->length| and we checked that there's * enough bytes for |mac_size| above. */ rr->length -= mac_size; mac = &rr->data[rr->length]; } i=s->method->ssl3_enc->mac(s,md,0 /* not send */); if (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0) enc_err = -1; if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size) enc_err = -1; } if (enc_err < 0) { /* A separate 'decryption_failed' alert was introduced with TLS 1.0, * SSL 3.0 only has 'bad_record_mac'. But unless a decryption * failure is directly visible from the ciphertext anyway, * we should not reveal which kind of error occured -- this * might become visible to an attacker (e.g. via a logfile) */ al=SSL_AD_BAD_RECORD_MAC; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC); goto f_err; } /* r->length is now just compressed */ if (s->expand != NULL) { if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra) { al=SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG); goto f_err; } if (!ssl3_do_uncompress(s)) { al=SSL_AD_DECOMPRESSION_FAILURE; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BAD_DECOMPRESSION); goto f_err; } } if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH+extra) { al=SSL_AD_RECORD_OVERFLOW; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG); goto f_err; } rr->off=0; /* So at this point the following is true * ssl->s3->rrec.type is the type of record * ssl->s3->rrec.length == number of bytes in record * ssl->s3->rrec.off == offset to first valid byte * ssl->s3->rrec.data == where to take bytes from, increment * after use :-). */ /* we have pulled in a full packet so zero things */ s->packet_length=0; /* just read a 0 length packet */ if (rr->length == 0) goto again; #if 0 fprintf(stderr, "Ultimate Record type=%d, Length=%d\n", rr->type, rr->length); #endif return(1); f_err: ssl3_send_alert(s,SSL3_AL_FATAL,al); err: return(ret); } int ssl3_do_uncompress(SSL *ssl) { #ifndef OPENSSL_NO_COMP int i; SSL3_RECORD *rr; rr= &(ssl->s3->rrec); i=COMP_expand_block(ssl->expand,rr->comp, SSL3_RT_MAX_PLAIN_LENGTH,rr->data,(int)rr->length); if (i < 0) return(0); else rr->length=i; rr->data=rr->comp; #endif return(1); } int ssl3_do_compress(SSL *ssl) { #ifndef OPENSSL_NO_COMP int i; SSL3_RECORD *wr; wr= &(ssl->s3->wrec); i=COMP_compress_block(ssl->compress,wr->data, SSL3_RT_MAX_COMPRESSED_LENGTH, wr->input,(int)wr->length); if (i < 0) return(0); else wr->length=i; wr->input=wr->data; #endif return(1); } /* Call this to write data in records of type 'type' * It will return <= 0 if not all data has been sent or non-blocking IO. */ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) { const unsigned char *buf=buf_; unsigned int tot,n,nw; int i; s->rwstate=SSL_NOTHING; tot=s->s3->wnum; s->s3->wnum=0; if (SSL_in_init(s) && !s->in_handshake) { i=s->handshake_func(s); if (i < 0) return(i); if (i == 0) { SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); return -1; } } n=(len-tot); for (;;) { if (n > s->max_send_fragment) nw=s->max_send_fragment; else nw=n; i=do_ssl3_write(s, type, &(buf[tot]), nw, 0); if (i <= 0) { s->s3->wnum=tot; return i; } if ((i == (int)n) || (type == SSL3_RT_APPLICATION_DATA && (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { /* next chunk of data should get another prepended empty fragment * in ciphersuites with known-IV weakness: */ s->s3->empty_fragment_done = 0; return tot+i; } n-=i; tot+=i; } } static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment) { unsigned char *p,*plen; int i,mac_size,clear=0; int prefix_len=0; int eivlen; long align=0; SSL3_RECORD *wr; SSL3_BUFFER *wb=&(s->s3->wbuf); SSL_SESSION *sess; if (wb->buf == NULL) if (!ssl3_setup_write_buffer(s)) return -1; /* first check if there is a SSL3_BUFFER still being written * out. This will happen with non blocking IO */ if (wb->left != 0) return(ssl3_write_pending(s,type,buf,len)); /* If we have an alert to send, lets send it */ if (s->s3->alert_dispatch) { i=s->method->ssl_dispatch_alert(s); if (i <= 0) return(i); /* if it went, fall through and send more stuff */ } if (len == 0 && !create_empty_fragment) return 0; wr= &(s->s3->wrec); sess=s->session; if ( (sess == NULL) || (s->enc_write_ctx == NULL) || (EVP_MD_CTX_md(s->write_hash) == NULL)) { #if 1 clear=s->enc_write_ctx?0:1; /* must be AEAD cipher */ #else clear=1; #endif mac_size=0; } else { mac_size=EVP_MD_CTX_size(s->write_hash); if (mac_size < 0) goto err; } /* 'create_empty_fragment' is true only when this function calls itself */ if (!clear && !create_empty_fragment && !s->s3->empty_fragment_done) { /* countermeasure against known-IV weakness in CBC ciphersuites * (see http://www.openssl.org/~bodo/tls-cbc.txt) */ if (s->s3->need_empty_fragments && type == SSL3_RT_APPLICATION_DATA) { /* recursive function call with 'create_empty_fragment' set; * this prepares and buffers the data for an empty fragment * (these 'prefix_len' bytes are sent out later * together with the actual payload) */ prefix_len = do_ssl3_write(s, type, buf, 0, 1); if (prefix_len <= 0) goto err; if (prefix_len > (SSL3_RT_HEADER_LENGTH + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD)) { /* insufficient space */ SSLerr(SSL_F_DO_SSL3_WRITE, ERR_R_INTERNAL_ERROR); goto err; } } s->s3->empty_fragment_done = 1; } if (create_empty_fragment) { #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 /* extra fragment would be couple of cipher blocks, * which would be multiple of SSL3_ALIGN_PAYLOAD, so * if we want to align the real payload, then we can * just pretent we simply have two headers. */ align = (long)wb->buf + 2*SSL3_RT_HEADER_LENGTH; align = (-align)&(SSL3_ALIGN_PAYLOAD-1); #endif p = wb->buf + align; wb->offset = align; } else if (prefix_len) { p = wb->buf + wb->offset + prefix_len; } else { #if defined(SSL3_ALIGN_PAYLOAD) && SSL3_ALIGN_PAYLOAD!=0 align = (long)wb->buf + SSL3_RT_HEADER_LENGTH; align = (-align)&(SSL3_ALIGN_PAYLOAD-1); #endif p = wb->buf + align; wb->offset = align; } /* write the header */ *(p++)=type&0xff; wr->type=type; *(p++)=(s->version>>8); /* Some servers hang if iniatial client hello is larger than 256 * bytes and record version number > TLS 1.0 */ if (s->state == SSL3_ST_CW_CLNT_HELLO_B && !s->renegotiate && TLS1_get_version(s) > TLS1_VERSION) *(p++) = 0x1; else *(p++)=s->version&0xff; /* field where we are to write out packet length */ plen=p; p+=2; /* Explicit IV length, block ciphers and TLS version 1.1 or later */ if (s->enc_write_ctx && s->version >= TLS1_1_VERSION) { int mode = EVP_CIPHER_CTX_mode(s->enc_write_ctx); if (mode == EVP_CIPH_CBC_MODE) { eivlen = EVP_CIPHER_CTX_iv_length(s->enc_write_ctx); if (eivlen <= 1) eivlen = 0; } /* Need explicit part of IV for GCM mode */ else if (mode == EVP_CIPH_GCM_MODE) eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN; else eivlen = 0; } else eivlen = 0; /* lets setup the record stuff. */ wr->data=p + eivlen; wr->length=(int)len; wr->input=(unsigned char *)buf; /* we now 'read' from wr->input, wr->length bytes into * wr->data */ /* first we compress */ if (s->compress != NULL) { if (!ssl3_do_compress(s)) { SSLerr(SSL_F_DO_SSL3_WRITE,SSL_R_COMPRESSION_FAILURE); goto err; } } else { memcpy(wr->data,wr->input,wr->length); wr->input=wr->data; } /* we should still have the output to wr->data and the input * from wr->input. Length should be wr->length. * wr->data still points in the wb->buf */ if (mac_size != 0) { if (s->method->ssl3_enc->mac(s,&(p[wr->length + eivlen]),1) < 0) goto err; wr->length+=mac_size; } wr->input=p; wr->data=p; if (eivlen) { /* if (RAND_pseudo_bytes(p, eivlen) <= 0) goto err; */ wr->length += eivlen; } /* ssl3_enc can only have an error on read */ s->method->ssl3_enc->enc(s,1); /* record length after mac and block padding */ s2n(wr->length,plen); /* we should now have * wr->data pointing to the encrypted data, which is * wr->length long */ wr->type=type; /* not needed but helps for debugging */ wr->length+=SSL3_RT_HEADER_LENGTH; if (create_empty_fragment) { /* we are in a recursive call; * just return the length, don't write out anything here */ return wr->length; } /* now let's set up wb */ wb->left = prefix_len + wr->length; /* memorize arguments so that ssl3_write_pending can detect bad write retries later */ s->s3->wpend_tot=len; s->s3->wpend_buf=buf; s->s3->wpend_type=type; s->s3->wpend_ret=len; /* we now just need to write the buffer */ return ssl3_write_pending(s,type,buf,len); err: return -1; } /* if s->s3->wbuf.left != 0, we need to call this */ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) { int i; SSL3_BUFFER *wb=&(s->s3->wbuf); /* XXXX */ if ((s->s3->wpend_tot > (int)len) || ((s->s3->wpend_buf != buf) && !(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)) || (s->s3->wpend_type != type)) { SSLerr(SSL_F_SSL3_WRITE_PENDING,SSL_R_BAD_WRITE_RETRY); return(-1); } for (;;) { clear_sys_error(); if (s->wbio != NULL) { s->rwstate=SSL_WRITING; i=BIO_write(s->wbio, (char *)&(wb->buf[wb->offset]), (unsigned int)wb->left); } else { SSLerr(SSL_F_SSL3_WRITE_PENDING,SSL_R_BIO_NOT_SET); i= -1; } if (i == wb->left) { wb->left=0; wb->offset+=i; if (s->mode & SSL_MODE_RELEASE_BUFFERS && SSL_version(s) != DTLS1_VERSION && SSL_version(s) != DTLS1_BAD_VER) ssl3_release_write_buffer(s); s->rwstate=SSL_NOTHING; return(s->s3->wpend_ret); } else if (i <= 0) { if (s->version == DTLS1_VERSION || s->version == DTLS1_BAD_VER) { /* For DTLS, just drop it. That's kind of the whole point in using a datagram service */ wb->left = 0; } return(i); } wb->offset+=i; wb->left-=i; } } /* Return up to 'len' payload bytes received in 'type' records. * 'type' is one of the following: * * - SSL3_RT_HANDSHAKE (when ssl3_get_message calls us) * - SSL3_RT_APPLICATION_DATA (when ssl3_read calls us) * - 0 (during a shutdown, no data has to be returned) * * If we don't have stored data to work from, read a SSL/TLS record first * (possibly multiple records if we still don't have anything to return). * * This function must handle any surprises the peer may have for us, such as * Alert records (e.g. close_notify), ChangeCipherSpec records (not really * a surprise, but handled as if it were), or renegotiation requests. * Also if record payloads contain fragments too small to process, we store * them until there is enough for the respective protocol (the record protocol * may use arbitrary fragmentation and even interleaving): * Change cipher spec protocol * just 1 byte needed, no need for keeping anything stored * Alert protocol * 2 bytes needed (AlertLevel, AlertDescription) * Handshake protocol * 4 bytes needed (HandshakeType, uint24 length) -- we just have * to detect unexpected Client Hello and Hello Request messages * here, anything else is handled by higher layers * Application data protocol * none of our business */ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) { int al,i,j,ret; unsigned int n; SSL3_RECORD *rr; void (*cb)(const SSL *ssl,int type2,int val)=NULL; if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ if (!ssl3_setup_read_buffer(s)) return(-1); if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) || (peek && (type != SSL3_RT_APPLICATION_DATA))) { SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); return -1; } if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0)) /* (partially) satisfy request from storage */ { unsigned char *src = s->s3->handshake_fragment; unsigned char *dst = buf; unsigned int k; /* peek == 0 */ n = 0; while ((len > 0) && (s->s3->handshake_fragment_len > 0)) { *dst++ = *src++; len--; s->s3->handshake_fragment_len--; n++; } /* move any remaining fragment bytes: */ for (k = 0; k < s->s3->handshake_fragment_len; k++) s->s3->handshake_fragment[k] = *src++; return n; } /* Now s->s3->handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */ if (!s->in_handshake && SSL_in_init(s)) { /* type == SSL3_RT_APPLICATION_DATA */ i=s->handshake_func(s); if (i < 0) return(i); if (i == 0) { SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); return(-1); } } start: s->rwstate=SSL_NOTHING; /* s->s3->rrec.type - is the type of record * s->s3->rrec.data, - data * s->s3->rrec.off, - offset into 'data' for next read * s->s3->rrec.length, - number of bytes. */ rr = &(s->s3->rrec); /* get new packet if necessary */ if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) { ret=ssl3_get_record(s); if (ret <= 0) return(ret); } /* we now have a packet which can be read and processed */ if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, * reset by ssl3_get_finished */ && (rr->type != SSL3_RT_HANDSHAKE)) { al=SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); goto f_err; } /* If the other end has shut down, throw anything we read away * (even in 'peek' mode) */ if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { rr->length=0; s->rwstate=SSL_NOTHING; return(0); } if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ { /* make sure that we are not getting application data when we * are doing a handshake for the first time */ if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) && (s->enc_read_ctx == NULL)) { al=SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE); goto f_err; } if (len <= 0) return(len); if ((unsigned int)len > rr->length) n = rr->length; else n = (unsigned int)len; memcpy(buf,&(rr->data[rr->off]),n); if (!peek) { rr->length-=n; rr->off+=n; if (rr->length == 0) { s->rstate=SSL_ST_READ_HEADER; rr->off=0; if (s->mode & SSL_MODE_RELEASE_BUFFERS) ssl3_release_read_buffer(s); } } return(n); } /* If we get here, then type != rr->type; if we have a handshake * message, then it was unexpected (Hello Request or Client Hello). */ /* In case of record types for which we have 'fragment' storage, * fill that so that we can process the data at a fixed place. */ { unsigned int dest_maxlen = 0; unsigned char *dest = NULL; unsigned int *dest_len = NULL; if (rr->type == SSL3_RT_HANDSHAKE) { dest_maxlen = sizeof s->s3->handshake_fragment; dest = s->s3->handshake_fragment; dest_len = &s->s3->handshake_fragment_len; } else if (rr->type == SSL3_RT_ALERT) { dest_maxlen = sizeof s->s3->alert_fragment; dest = s->s3->alert_fragment; dest_len = &s->s3->alert_fragment_len; } #ifndef OPENSSL_NO_HEARTBEATS else if (rr->type == TLS1_RT_HEARTBEAT) { tls1_process_heartbeat(s); /* Exit and notify application to read again */ rr->length = 0; s->rwstate=SSL_READING; BIO_clear_retry_flags(SSL_get_rbio(s)); BIO_set_retry_read(SSL_get_rbio(s)); return(-1); } #endif if (dest_maxlen > 0) { n = dest_maxlen - *dest_len; /* available space in 'dest' */ if (rr->length < n) n = rr->length; /* available bytes */ /* now move 'n' bytes: */ while (n-- > 0) { dest[(*dest_len)++] = rr->data[rr->off++]; rr->length--; } if (*dest_len < dest_maxlen) goto start; /* fragment was too small */ } } /* s->s3->handshake_fragment_len == 4 iff rr->type == SSL3_RT_HANDSHAKE; * s->s3->alert_fragment_len == 2 iff rr->type == SSL3_RT_ALERT. * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) */ /* If we are a client, check for an incoming 'Hello Request': */ if ((!s->server) && (s->s3->handshake_fragment_len >= 4) && (s->s3->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) && (s->session != NULL) && (s->session->cipher != NULL)) { s->s3->handshake_fragment_len = 0; if ((s->s3->handshake_fragment[1] != 0) || (s->s3->handshake_fragment[2] != 0) || (s->s3->handshake_fragment[3] != 0)) { al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_HELLO_REQUEST); goto f_err; } if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg); if (SSL_is_init_finished(s) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && !s->s3->renegotiate) { ssl3_renegotiate(s); if (ssl3_renegotiate_check(s)) { i=s->handshake_func(s); if (i < 0) return(i); if (i == 0) { SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); return(-1); } if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) /* no read-ahead left? */ { BIO *bio; /* In the case where we try to read application data, * but we trigger an SSL handshake, we return -1 with * the retry option set. Otherwise renegotiation may * cause nasty problems in the blocking world */ s->rwstate=SSL_READING; bio=SSL_get_rbio(s); BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); return(-1); } } } } /* we either finished a handshake or ignored the request, * now try again to obtain the (application) data we were asked for */ goto start; } /* If we are a server and get a client hello when renegotiation isn't * allowed send back a no renegotiation alert and carry on. * WARNING: experimental code, needs reviewing (steve) */ if (s->server && SSL_is_init_finished(s) && !s->s3->send_connection_binding && (s->version > SSL3_VERSION) && (s->s3->handshake_fragment_len >= 4) && (s->s3->handshake_fragment[0] == SSL3_MT_CLIENT_HELLO) && (s->session != NULL) && (s->session->cipher != NULL) && !(s->ctx->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { /*s->s3->handshake_fragment_len = 0;*/ rr->length = 0; ssl3_send_alert(s,SSL3_AL_WARNING, SSL_AD_NO_RENEGOTIATION); goto start; } if (s->s3->alert_fragment_len >= 2) { int alert_level = s->s3->alert_fragment[0]; int alert_descr = s->s3->alert_fragment[1]; s->s3->alert_fragment_len = 0; if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg); if (s->info_callback != NULL) cb=s->info_callback; else if (s->ctx->info_callback != NULL) cb=s->ctx->info_callback; if (cb != NULL) { j = (alert_level << 8) | alert_descr; cb(s, SSL_CB_READ_ALERT, j); } if (alert_level == 1) /* warning */ { s->s3->warn_alert = alert_descr; if (alert_descr == SSL_AD_CLOSE_NOTIFY) { s->shutdown |= SSL_RECEIVED_SHUTDOWN; return(0); } /* This is a warning but we receive it if we requested * renegotiation and the peer denied it. Terminate with * a fatal alert because if application tried to * renegotiatie it presumably had a good reason and * expects it to succeed. * * In future we might have a renegotiation where we * don't care if the peer refused it where we carry on. */ else if (alert_descr == SSL_AD_NO_RENEGOTIATION) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_NO_RENEGOTIATION); goto f_err; } #ifdef SSL_AD_MISSING_SRP_USERNAME else if (alert_descr == SSL_AD_MISSING_SRP_USERNAME) return(0); #endif } else if (alert_level == 2) /* fatal */ { char tmp[16]; s->rwstate=SSL_NOTHING; s->s3->fatal_alert = alert_descr; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); BIO_snprintf(tmp,sizeof tmp,"%d",alert_descr); ERR_add_error_data(2,"SSL alert number ",tmp); s->shutdown|=SSL_RECEIVED_SHUTDOWN; SSL_CTX_remove_session(s->ctx,s->session); return(0); } else { al=SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE); goto f_err; } goto start; } if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */ { s->rwstate=SSL_NOTHING; rr->length=0; return(0); } if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) { /* 'Change Cipher Spec' is just a single byte, so we know * exactly what the record payload has to look like */ if ( (rr->length != 1) || (rr->off != 0) || (rr->data[0] != SSL3_MT_CCS)) { al=SSL_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC); goto f_err; } /* Check we have a cipher to change to */ if (s->s3->tmp.new_cipher == NULL) { al=SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_CCS_RECEIVED_EARLY); goto f_err; } rr->length=0; if (s->msg_callback) s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg); s->s3->change_cipher_spec=1; if (!ssl3_do_change_cipher_spec(s)) goto err; else goto start; } /* Unexpected handshake message (Client Hello, or protocol violation) */ if ((s->s3->handshake_fragment_len >= 4) && !s->in_handshake) { if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) { #if 0 /* worked only because C operator preferences are not as expected (and * because this is not really needed for clients except for detecting * protocol violations): */ s->state=SSL_ST_BEFORE|(s->server) ?SSL_ST_ACCEPT :SSL_ST_CONNECT; #else s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; #endif s->renegotiate=1; s->new_session=1; } i=s->handshake_func(s); if (i < 0) return(i); if (i == 0) { SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); return(-1); } if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) /* no read-ahead left? */ { BIO *bio; /* In the case where we try to read application data, * but we trigger an SSL handshake, we return -1 with * the retry option set. Otherwise renegotiation may * cause nasty problems in the blocking world */ s->rwstate=SSL_READING; bio=SSL_get_rbio(s); BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); return(-1); } } goto start; } switch (rr->type) { default: #ifndef OPENSSL_NO_TLS /* TLS up to v1.1 just ignores unknown message types: * TLS v1.2 give an unexpected message alert. */ if (s->version >= TLS1_VERSION && s->version <= TLS1_1_VERSION) { rr->length = 0; goto start; } #endif al=SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); goto f_err; case SSL3_RT_CHANGE_CIPHER_SPEC: case SSL3_RT_ALERT: case SSL3_RT_HANDSHAKE: /* we already handled all of these, with the possible exception * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that * should not happen when type != rr->type */ al=SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES,ERR_R_INTERNAL_ERROR); goto f_err; case SSL3_RT_APPLICATION_DATA: /* At this point, we were expecting handshake data, * but have application data. If the library was * running inside ssl3_read() (i.e. in_read_app_data * is set) and it makes sense to read application data * at this point (session renegotiation not yet started), * we will indulge it. */ if (s->s3->in_read_app_data && (s->s3->total_renegotiations != 0) && (( (s->state & SSL_ST_CONNECT) && (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && (s->state <= SSL3_ST_CR_SRVR_HELLO_A) ) || ( (s->state & SSL_ST_ACCEPT) && (s->state <= SSL3_ST_SW_HELLO_REQ_A) && (s->state >= SSL3_ST_SR_CLNT_HELLO_A) ) )) { s->s3->in_read_app_data=2; return(-1); } else { al=SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); goto f_err; } } /* not reached */ f_err: ssl3_send_alert(s,SSL3_AL_FATAL,al); err: return(-1); } int ssl3_do_change_cipher_spec(SSL *s) { int i; const char *sender; int slen; if (s->state & SSL_ST_ACCEPT) i=SSL3_CHANGE_CIPHER_SERVER_READ; else i=SSL3_CHANGE_CIPHER_CLIENT_READ; if (s->s3->tmp.key_block == NULL) { if (s->session == NULL) { /* might happen if dtls1_read_bytes() calls this */ SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC,SSL_R_CCS_RECEIVED_EARLY); return (0); } s->session->cipher=s->s3->tmp.new_cipher; if (!s->method->ssl3_enc->setup_key_block(s)) return(0); } if (!s->method->ssl3_enc->change_cipher_state(s,i)) return(0); /* we have to record the message digest at * this point so we can get it before we read * the finished message */ if (s->state & SSL_ST_CONNECT) { sender=s->method->ssl3_enc->server_finished_label; slen=s->method->ssl3_enc->server_finished_label_len; } else { sender=s->method->ssl3_enc->client_finished_label; slen=s->method->ssl3_enc->client_finished_label_len; } s->s3->tmp.peer_finish_md_len = s->method->ssl3_enc->final_finish_mac(s, sender,slen,s->s3->tmp.peer_finish_md); return(1); } int ssl3_send_alert(SSL *s, int level, int desc) { /* Map tls/ssl alert value to correct one */ desc=s->method->ssl3_enc->alert_value(desc); if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION) desc = SSL_AD_HANDSHAKE_FAILURE; /* SSL 3.0 does not have protocol_version alerts */ if (desc < 0) return -1; /* If a fatal one, remove from cache */ if ((level == 2) && (s->session != NULL)) SSL_CTX_remove_session(s->ctx,s->session); s->s3->alert_dispatch=1; s->s3->send_alert[0]=level; s->s3->send_alert[1]=desc; if (s->s3->wbuf.left == 0) /* data still being written out? */ return s->method->ssl_dispatch_alert(s); /* else data is still being written out, we will get written * some time in the future */ return -1; } int ssl3_dispatch_alert(SSL *s) { int i,j; void (*cb)(const SSL *ssl,int type,int val)=NULL; s->s3->alert_dispatch=0; i = do_ssl3_write(s, SSL3_RT_ALERT, &s->s3->send_alert[0], 2, 0); if (i <= 0) { s->s3->alert_dispatch=1; } else { /* Alert sent to BIO. If it is important, flush it now. * If the message does not get sent due to non-blocking IO, * we will not worry too much. */ if (s->s3->send_alert[0] == SSL3_AL_FATAL) (void)BIO_flush(s->wbio); if (s->msg_callback) s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg); if (s->info_callback != NULL) cb=s->info_callback; else if (s->ctx->info_callback != NULL) cb=s->ctx->info_callback; if (cb != NULL) { j=(s->s3->send_alert[0]<<8)|s->s3->send_alert[1]; cb(s,SSL_CB_WRITE_ALERT,j); } } return(i); }
{ "pile_set_name": "Github" }
/********************* */ /*! \file theory_proof_step_buffer.h ** \verbatim ** Top contributors (to current version): ** Andrew Reynolds ** This file is part of the CVC4 project. ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS ** in the top-level source directory and their institutional affiliations. ** All rights reserved. See the file COPYING in the top-level source ** directory for licensing information.\endverbatim ** ** \brief Theory proof step buffer utility. **/ #include "cvc4_private.h" #ifndef CVC4__THEORY__THEORY_PROOF_STEP_BUFFER_H #define CVC4__THEORY__THEORY_PROOF_STEP_BUFFER_H #include <vector> #include "expr/node.h" #include "expr/proof_step_buffer.h" #include "theory/builtin/proof_checker.h" namespace CVC4 { namespace theory { /** * Class used to speculatively try and buffer a set of proof steps before * sending them to a proof object, extended with theory-specfic proof rule * utilities. */ class TheoryProofStepBuffer : public ProofStepBuffer { public: TheoryProofStepBuffer(ProofChecker* pc = nullptr); ~TheoryProofStepBuffer() {} //---------------------------- utilities builtin proof rules /** * Apply predicate transform. If this method returns true, it adds (at most * one) proof step to the buffer that conclude tgt from premises src, exp. In * particular, it may attempt to apply MACRO_SR_PRED_TRANSFORM. This method * should be applied when src and tgt are equivalent formulas assuming exp. */ bool applyPredTransform(Node src, Node tgt, const std::vector<Node>& exp, MethodId ids = MethodId::SB_DEFAULT, MethodId idr = MethodId::RW_REWRITE); /** * Apply predicate introduction. If this method returns true, it adds proof * step(s) to the buffer that conclude tgt from premises exp. In particular, * it may attempt to apply the rule MACRO_SR_PRED_INTRO. This method should be * applied when tgt is equivalent to true assuming exp. */ bool applyPredIntro(Node tgt, const std::vector<Node>& exp, MethodId ids = MethodId::SB_DEFAULT, MethodId idr = MethodId::RW_REWRITE); /** * Apply predicate elimination. This method returns the result of applying * the rule MACRO_SR_PRED_ELIM on src, exp. The returned formula is equivalent * to src assuming exp. If the return value is equivalent to src, then no * proof step is added to this buffer, since this step is a no-op in this * case. * * Notice that in contrast to the other rules above, predicate elimination * never fails and proves a formula that is not explicitly given as an * argument tgt. Thus, the return value of this method is Node not bool. */ Node applyPredElim(Node src, const std::vector<Node>& exp, MethodId ids = MethodId::SB_DEFAULT, MethodId idr = MethodId::RW_REWRITE); //---------------------------- end utilities builtin proof rules //---------------------------- utility methods for normalizing clauses /** * Normalizes a non-unit clause (an OR node) according to factoring and * reordering, i.e. removes duplicates and reorders literals (according to * node ids). Moreover it eliminates double negations, which can be done also * for unit clauses (a arbitrary Boolean node). All normalization steps are * tracked via proof steps added to this proof step buffer. * * @param n the clause to be normalized * @return the normalized clause node */ Node factorReorderElimDoubleNeg(Node n); /** * Eliminates double negation of a literal if it has the form * (not (not t)) * If the elimination happens, a step is added to this proof step buffer. * * @param n the node to have the top-level double negation eliminated * @return the normalized clause node */ Node elimDoubleNegLit(Node n); }; } // namespace theory } // namespace CVC4 #endif /* CVC4__THEORY__THEORY_PROOF_STEP_BUFFER_H */
{ "pile_set_name": "Github" }
runc Copyright 2012-2015 Docker, Inc. This product includes software developed at Docker, Inc. (http://www.docker.com). The following is courtesy of our legal counsel: Use and transfer of Docker may be subject to certain restrictions by the United States and other governments. It is your responsibility to ensure that your use and/or transfer does not violate applicable laws. For more information, please see http://www.bis.doc.gov See also http://www.apache.org/dev/crypto.html and/or seek legal counsel.
{ "pile_set_name": "Github" }
/////////////////////////////////////////////////////////////////////////////// // // AutobahnJS - http://autobahn.ws, http://wamp.ws // // A JavaScript library for WAMP ("The Web Application Messaging Protocol"). // // Copyright (C) 2011-2014 Tavendo GmbH, http://tavendo.com // // Licensed under the MIT License. // http://www.opensource.org/licenses/mit-license.php // /////////////////////////////////////////////////////////////////////////////// var util = require('../util.js'); var log = require('../log.js'); var EventEmitter = require('events').EventEmitter; function Factory (options) { var self = this; if (!options.protocols) { options.protocols = ['wamp.2.json']; } else { util.assert(Array.isArray(options.protocols), "options.protocols must be an array"); } options.rawsocket_max_len_exp = options.rawsocket_max_len_exp || 24; self._options = options; } Factory.prototype.type = "rawsocket"; Factory.prototype.create = function () { var self = this; // the WAMP transport we create var transport = {}; // these will get defined further below transport.protocol = undefined; transport.send = undefined; transport.close = undefined; // these will get overridden by the WAMP session using this transport transport.onmessage = function () {}; transport.onopen = function () {}; transport.onclose = function () {}; transport.info = { type: 'rawsocket', url: null, protocol: 'wamp.2.json' }; // Test below used to be via the 'window' object in the browser. // This fails when running in a Web worker. // // running in Node.js // if (global.process && global.process.versions.node) { (function () { var net = require('net'); var socket, protocol; // Create the options object to initiate the connection if (self._options.path) { connectionOptions = { path: self._options.path, allowHalfOpen: true }; } else if (self._options.port) { connectionOptions = { port: self._options.port || 8000, host: self._options.host || 'localhost', allowHalfOpen: true }; } else { throw "You must specify a host/port combination or a unix socket path to connect to"; } // Open a TCP socket and setup the protocol socket = net.connect(connectionOptions); protocol = new Protocol(socket, { serializer: 'json', max_len_exp: self._options.rawsocket_max_len_exp }); // Relay connect event to the onopen transport handler protocol.on('connect', function (msg) { log.debug('RawSocket transport negociated'); transport.onopen(msg); }); // Relay data event to the onmessage transport handler protocol.on('data', function (msg) { log.debug('RawSocket transport received', msg); transport.onmessage(msg); }); // Relay the close event to the onclose transport handler protocol.on('close', function (had_error) { log.debug('RawSocket transport closed'); transport.onclose({ code: 999, reason: '', wasClean: !had_error }); }); // Log errors protocol.on('error', function (error) { log.debug('RawSocket transport error', error); }); // Relay close call transport.close = function (code, reason) { log.debug('RawSocket transport closing', code, reason); protocol.close(); }; // Relay send call transport.send = function (msg) { log.debug('RawSocket transport sending', msg); protocol.write(msg); }; })(); // // running in the browser // } else { throw "No RawSocket support in browser"; } return transport; }; /** * Protocol constructor * * @param {Stream} stream Source stream object * @param {Object} [options] Protocol options * * @param {String} [options.serializer] The serializer to use (default: json) * @param {Integer} [options.max_len_exp] The maximum allowed frame length as * 2^x(default: 24) * @param {Integer|False} [options.ping_timeout] Maximum duration in ms to wait * for an answer to a PING packet (default: 2000) * @param {Integer|False} [options.autoping] If an integer, send a PING packet* * every `x`ms (default: false) * @param {Boolean} [options.fail_on_ping_timeout] Whether to close the * underlying connection when the peer fails to answer to a PING within * the `ping_timeout` window (default: true) * @param {Integer|False} [options.packet_timeout] The maximum amount of time to * wait for a packet !!NOT IMPLEMENTED!! (default: 2000) * * @see https://github.com/wamp-proto/wamp-proto */ function Protocol (stream, options) { this._options = { _peer_serializer: null, // Will hold the serializer declared by the peer _peer_max_len_exp: 0 // Will hold the maximum frame length declared by // the peer }; this._options = util.defaults(this._options, options, this.DEFAULT_OPTIONS); // Check valid options util.assert(this._options.serializer in this.SERIALIZERS, 'Unsupported serializer: ' + this._options.serializer); util.assert(this._options.max_len_exp >= 9 && this._options.max_len_exp <= 36, 'Message length out of bounds [9, 36]: '+ this._options.max_len_exp); util.assert(!this._options.autoping || (Number.isInteger(this._options.autoping) && this._options.autoping >= 0), 'Autoping interval must be positive'); util.assert(!this._options.ping_timeout || (Number.isInteger(this._options.ping_timeout) && this._options.ping_timeout >= 0), 'Ping timeout duration must be positive'); util.assert(!this._options.packet_timeout || (Number.isInteger(this._options.packet_timeout) && this._options.packet_timeout >= 0), 'Packet timeout duration must be positive'); util.assert((!this._options.autoping || !this._options.ping_timeout) || this._options.autoping > this._options.ping_timeout, 'Autoping interval (' + this._options.autoping + ') must be lower ' + 'than ping timeout (' + this._options.ping_timeout + ')'); // Will store a reference to the timeout function associated with the last // PING packet this._ping_timeout = null; // Will store the payload of the last PING packet this._ping_payload = null; // Will store the autoping setInterval reference this._ping_interval = null; // Protocol status (see Protocol.prototype.STATUS) this._status = this.STATUS.UNINITIATED; this._stream = stream; this._emitter = new EventEmitter(); // Frame buffer this._buffer = new Buffer(4); this._bufferLen = 0; this._msgLen = 0; // Hook events var self = this; this._stream.on('data', function (data) { self._read(data); }); this._stream.on('connect', function () { self._handshake(); }); // Proxy these events from the stream as we don't need to handle them var proxyEvents = [ 'close', 'drain', 'end', 'error', 'timeout' ]; proxyEvents.forEach(function (evt) { self._stream.on(evt, function (data) { self._emitter.emit(evt, data); }); }); } /* Protocol magic byte */ Protocol.prototype._MAGIC_BYTE = 0x7f; /* Supported serializers */ Protocol.prototype.SERIALIZERS = { json: 1 }; /* Protocol states */ Protocol.prototype.STATUS = { CLOSED: -1, UNINITIATED: 0, NEGOCIATING: 1, NEGOCIATED: 2, RXHEAD: 3, RXDATA: 4, RXPING: 5, RXPONG: 6 }; /* RawSocket error codes */ Protocol.prototype.ERRORS = { 0: "illegal (must not be used)", 1: "serializer unsupported", 2: "maximum message length unacceptable", 3: "use of reserved bits (unsupported feature)", 4: "maximum connection count reached" }; /* RawSocket message types */ Protocol.prototype.MSGTYPES = { WAMP: 0x0, PING: 0x1, PONG: 0x2 }; /* Default protocol options */ Protocol.prototype.DEFAULT_OPTIONS = { fail_on_ping_timeout: true, strict_pong: true, ping_timeout: 2000, autoping: 0, max_len_exp: 24, serializer: 'json', packet_timeout: 2000 }; /** * Close transport * * @returns {Integer} Closed state code */ Protocol.prototype.close = function () { this._status = this.STATUS.CLOSED; this._stream.end(); return this.STATUS.CLOSED; }; /** * Write a frame to the transport * * @param {Oject} msg The frame to send * @param {Integer} type The frame type * @param {Function} callback Callback function called when frame is sent */ Protocol.prototype.write = function (msg, type, callback) { type = type === undefined ? 0 : type; // If WAMP frame, serialize the object passed // Otherwise send as-is if (type === this.MSGTYPES.WAMP) { msg = JSON.stringify(msg); } // Get the frame size var msgLen = Buffer.byteLength(msg, 'utf8'); // Check frame size against negociated max size if (msgLen > Math.pow(2, this._options._peer_max_len_exp)) { this._emitter.emit('error', new ProtocolError('Frame too big')); return; } // Create the frame var frame = new Buffer(msgLen + 4); // Message type frame.writeUInt8(type, 0); // Prefix by frame size as a 24 bit integer frame.writeUIntBE(msgLen, 1, 3); frame.write(msg, 4); this._stream.write(frame, callback); }; Protocol.prototype.ping = function (payload) { payload = payload || 255; // Generate a random payload if none provided if (Number.isInteger(payload)) { var base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'+ '0123456789&~"#\'{([-|`_\\^@)]=},?;.:/!*$<>'; var len = Math.max(1, payload); for (var i = 0; i < len; i++) payload += base.charAt((Math.random() * base.length) | 0); } // Store the payload for checking against PONG packet this._ping_payload = payload; // Send the packet and register the ping timeout once done return this.write(payload, this.MSGTYPES.PING, this._setupPingTimeout.bind(this)); }; Protocol.prototype._setupPingTimeout = function () { if (this._options.ping_timeout) { this._ping_timeout = setTimeout(this._onPingTimeout.bind(this), this._options.ping_timeout); } }; Protocol.prototype._clearPingTimeout = function () { if (this._ping_timeout) { clearTimeout(this._ping_timeout); this._ping_timeout = null; } }; Protocol.prototype._setupAutoPing = function () { this._clearAutoPing(); if (this._options.autoping) { this._autoping_interval = setInterval(this.ping.bind(this), this._options.autoping); } }; Protocol.prototype._clearAutoPing = function () { if (this._autoping_interval) { clearInterval(this._autoping_interval); this._autoping_interval = null; } }; Protocol.prototype._onPingTimeout = function () { this._emitter.emit('error', new ProtocolError('PING timeout')); if (this._options.fail_on_ping_timeout) { this.close(); } }; /** * Handle incoming data * * @param {Buffer} data Incoming data */ Protocol.prototype._read = function (data) { var handler, frame; switch (this._status) { case this.STATUS.CLOSED: case this.STATUS.UNINITIATED: this._emitter.emit('error', ProtocolError('Unexpected packet')); break; case this.STATUS.NEGOCIATING: handler = this._handleHandshake; frame = 4; break; case this.STATUS.NEGOCIATED: case this.STATUS.RXHEAD: this._status = this.STATUS.RXHEAD; handler = this._handleHeaderPacket; frame = 4; break; case this.STATUS.RXDATA: handler = this._handleDataPacket; frame = this._msgLen; break; case this.STATUS.RXPING: handler = this._handlePingPacket; frame = this._msgLen; break; case this.STATUS.RXPONG: handler = this._handlePongPacket; frame = this._msgLen; break; } // Get a frame of the expected size var chunks = this._splitBytes(data, frame); // Protocol#_splitBytes returns null if there isn't enough data to fill the // requested frame yet. Wait for more if (!chunks) return; // Call the packet handler with the frame this._status = handler.call(this, chunks[0]); // If there is more data, handle it if (chunks[1].length > 0) { this._read(chunks[1]); } }; /** * Send the handshake packet to the peer */ Protocol.prototype._handshake = function () { if (this._status !== this.STATUS.UNINITIATED) { throw 'Handshake packet already sent'; } // Compose handshake message var gday = new Buffer(4); // Protocol magic byte gday.writeUInt8(this._MAGIC_BYTE, 0); // Announce message max length and serializer gday.writeUInt8((this._options.max_len_exp - 9) << 4 | this.SERIALIZERS[this._options.serializer], 1); // Reserved bytes gday.writeUInt8(0x00, 2); gday.writeUInt8(0x00, 3); this._stream.write(gday); this._status = this.STATUS.NEGOCIATING; }; /** * Make a frame of the requested length using the data already buffered and the * passed incoming data * * @param {Buffer} data Incoming data * @param {Integer} len Frame size * * @returns {null|Array(2)} Returns null if there is'nt enough data to fill the * frame yet, or an array containing the frame at * index 0 and the leftover bytes at index 1 otherwise. */ Protocol.prototype._splitBytes = function (data, len) { // If the buffer we have already isn't the right size, throw the data away // and make a new one if (len !== this._buffer.length) { this._buffer = new Buffer(len); this._bufferLen = 0; } // Push the data to the buffer data.copy(this._buffer, this._bufferLen); // If there still isn't enough data, increment the counter and return null if (this._bufferLen + data.length < len) { this._bufferLen += data.length; return null; // Otherwise, return the requested frame and the leftover data } else { var bytes = this._buffer.slice(); var extra = data.slice(len - this._bufferLen); this._bufferLen = 0; return [ bytes, extra ]; } }; /** * Handle the handshake response packet * * @param {Buffer} int32 A 4 byte buffer containing the handshake packet * * @returns {Integer} The new protocol state */ Protocol.prototype._handleHandshake = function (int32) { // Check magic byte if (int32[0] !== this._MAGIC_BYTE) { this._emitter.emit('error', new ProtocolError( 'Invalid magic byte. Expected 0x' + this._MAGIC_BYTE.toString(16) + ', got 0x' + int32[0].toString(16)) ); return this.close(); } // Check for error if ((int32[1] & 0x0f) === 0) { var errcode = int32[1] >> 4; this._emitter.emit('error', new ProtocolError('Peer failed handshake: ' + (this.ERRORS[errcode] || '0x' + errcode.toString(16)))); return this.close(); } // Extract max message length and serializer this._options._peer_max_len_exp = (int32[1] >> 4) + 9; this._options._peer_serializer = int32[1] & 0x0f; // We only support JSON so far // TODO: Support more serializers if (this._options._peer_serializer !== this.SERIALIZERS.json) { this._emitter.emit('error', new ProtocolError( 'Unsupported serializer: 0x' + this._options._peer_serializer.toString(16)) ); return this.close(); } // Protocol negociation complete, we're connected to the peer and ready to // talk this._emitter.emit('connect'); // Setup the autoping this._setupAutoPing(); return this.STATUS.NEGOCIATED; }; /** * Handle a frame header * * @param {Buffer} int32 A 4 byte buffer representing the packet length * * @returns {Integer} The new protocol state */ Protocol.prototype._handleHeaderPacket = function (int32) { var type = int32[0] & 0x0f; // Decode integer and store it this._msgLen = int32.readUIntBE(1, 3); switch (type) { case this.MSGTYPES.WAMP: // WAMP frame return this.STATUS.RXDATA; case this.MSGTYPES.PING: // PING frame return this.STATUS.RXPING; case this.MSGTYPES.PONG: // PONG frame return this.STATUS.RXPONG; default: this._emitter.emit('error', new ProtocolError( 'Invalid frame type: 0x' + type.toString(16)) ); return this.close(); } }; /** * Handle a data packet * * @param {Buffer} buffer The received data * * @returns {Integer} The new protocol state */ Protocol.prototype._handleDataPacket = function (buffer) { var msg; // Attempt to deserialize the frame // TODO: Support other serializers try { msg = JSON.parse(buffer.toString('utf8')); } catch (e) { this._emitter.emit('error', new ProtocolError('Invalid JSON frame') ); return this.STATUS.RXHEAD; } // Emit a data event for consumers this._emitter.emit('data', msg); return this.STATUS.RXHEAD; }; /** * Handle a ping packet - Reply with a PONG and the same payload * * @param {Buffer} buffer The received data * * @returns {Integer} The new protocol state */ Protocol.prototype._handlePingPacket = function (buffer) { this.write(buffer.toString('utf8'), this.MSGTYPES.PONG); return this.STATUS.RXHEAD; }; /** * Handle a pong packet * * @param {Buffer} buffer The received data * * @returns {Integer} The new protocol state */ Protocol.prototype._handlePongPacket = function (buffer) { // Clear the ping timeout (if any) this._clearPingTimeout(); // If strict PONG checking is activated and the payloads don't match, throw // an error and close the connection if (this._options.strict_pong && this._ping_payload !== buffer.toString('utf8')) { this._emitter.emit('error', new ProtocolError( 'PONG response payload doesn\'t match PING.' )); return this.close(); } return this.STATUS.RXHEAD; }; Protocol.prototype.on = function (evt, handler) { return this._emitter.on(evt, handler); }; Protocol.prototype.once = function (evt, handler) { return this._emitter.once(evt, handler); }; Protocol.prototype.removeListener = function (evt, handler) { return this._emitter.removeListener(evt, handler); }; /** * ProtocolError type */ var ProtocolError = exports.ProtocolError = function (msg) { Error.apply(this, Array.prototype.splice.call(arguments)); Error.captureStackTrace(this, this.constructor); this.message = msg; this.name = 'ProtocolError'; }; ProtocolError.prototype = Object.create(Error.prototype); exports.Factory = Factory; exports.Protocol = Protocol;
{ "pile_set_name": "Github" }
'use strict'; module.exports = (flag, argv) => { argv = argv || process.argv; const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); const pos = argv.indexOf(prefix + flag); const terminatorPos = argv.indexOf('--'); return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); };
{ "pile_set_name": "Github" }
// This file generated by `generator/`. DO NOT EDIT package models import ( "log" hcl "github.com/hashicorp/hcl/v2" "github.com/terraform-linters/tflint/tflint" ) // AwsGlobalacceleratorListenerInvalidAcceleratorArnRule checks the pattern is valid type AwsGlobalacceleratorListenerInvalidAcceleratorArnRule struct { resourceType string attributeName string max int } // NewAwsGlobalacceleratorListenerInvalidAcceleratorArnRule returns new rule with default attributes func NewAwsGlobalacceleratorListenerInvalidAcceleratorArnRule() *AwsGlobalacceleratorListenerInvalidAcceleratorArnRule { return &AwsGlobalacceleratorListenerInvalidAcceleratorArnRule{ resourceType: "aws_globalaccelerator_listener", attributeName: "accelerator_arn", max: 255, } } // Name returns the rule name func (r *AwsGlobalacceleratorListenerInvalidAcceleratorArnRule) Name() string { return "aws_globalaccelerator_listener_invalid_accelerator_arn" } // Enabled returns whether the rule is enabled by default func (r *AwsGlobalacceleratorListenerInvalidAcceleratorArnRule) Enabled() bool { return true } // Severity returns the rule severity func (r *AwsGlobalacceleratorListenerInvalidAcceleratorArnRule) Severity() string { return tflint.ERROR } // Link returns the rule reference link func (r *AwsGlobalacceleratorListenerInvalidAcceleratorArnRule) Link() string { return "" } // Check checks the pattern is valid func (r *AwsGlobalacceleratorListenerInvalidAcceleratorArnRule) Check(runner *tflint.Runner) error { log.Printf("[TRACE] Check `%s` rule for `%s` runner", r.Name(), runner.TFConfigPath()) return runner.WalkResourceAttributes(r.resourceType, r.attributeName, func(attribute *hcl.Attribute) error { var val string err := runner.EvaluateExpr(attribute.Expr, &val) return runner.EnsureNoError(err, func() error { if len(val) > r.max { runner.EmitIssue( r, "accelerator_arn must be 255 characters or less", attribute.Expr.Range(), ) } return nil }) }) }
{ "pile_set_name": "Github" }
namespace ClassLib094 { public class Class093 { public static string Property => "ClassLib094"; } }
{ "pile_set_name": "Github" }
# configuration is read from SQLite database
{ "pile_set_name": "Github" }
config BR2_PACKAGE_MESA3D_DEMOS bool "mesa3d-demos" depends on BR2_PACKAGE_HAS_LIBGL || BR2_PACKAGE_HAS_LIBGLES \ || BR2_PACKAGE_HAS_LIBEGL || BR2_PACKAGE_HAS_LIBOPENVG select BR2_PACKAGE_LIBGLEW if BR2_PACKAGE_XORG7 && BR2_PACKAGE_HAS_LIBGL select BR2_PACKAGE_LIBGLU if BR2_PACKAGE_XORG7 && BR2_PACKAGE_HAS_LIBGL select BR2_PACKAGE_XLIB_LIBX11 if BR2_PACKAGE_XORG7 && BR2_PACKAGE_HAS_LIBGL select BR2_PACKAGE_XLIB_LIBXEXT if BR2_PACKAGE_XORG7 && BR2_PACKAGE_HAS_LIBGL help OpenGL demos from the Mesa 3D project. http://mesa3d.org
{ "pile_set_name": "Github" }
{ "extends": "../../configs/base.tsconfig", "compilerOptions": { "composite": true, "rootDir": "src", "outDir": "lib", "lib": [ "es6", "dom", "webworker" ] }, "include": [ "src" ], "references": [] }
{ "pile_set_name": "Github" }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.14"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>ProcessViewBrowser-ServerProgramming: QwtCompass</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">ProcessViewBrowser-ServerProgramming </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.14 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */ var searchBox = new SearchBox("searchBox", "search",false,'Search'); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */</script> <div id="main-nav"></div> </div><!-- top --> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="summary"> <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">QwtCompass</div> </div> </div><!--header--> <div class="contents"> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:ga947510da753749d8565e272766810671"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga947510da753749d8565e272766810671">qwtCompassSetSimpleCompassRose</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int numThorns, int numThornLevels, float width=0.2f)</td></tr> <tr class="separator:ga947510da753749d8565e272766810671"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga4889dec7435211bfee96a166870ed480"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga4889dec7435211bfee96a166870ed480">qwtCompassSetRange</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, float vmin, float vmax, float step=0.0f)</td></tr> <tr class="separator:ga4889dec7435211bfee96a166870ed480"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga184d68f60481887df39f669848cd6967"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga184d68f60481887df39f669848cd6967">qwtCompassSetMass</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, float mass)</td></tr> <tr class="separator:ga184d68f60481887df39f669848cd6967"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga943204243a02586ce53743b54f12bbf5"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga943204243a02586ce53743b54f12bbf5">qwtCompassSetReadOnly</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int rdonly)</td></tr> <tr class="separator:ga943204243a02586ce53743b54f12bbf5"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga41e3e7de188683554d3a53ba43701d23"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga41e3e7de188683554d3a53ba43701d23">qwtCompassSetFrameShadow</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int shadow)</td></tr> <tr class="separator:ga41e3e7de188683554d3a53ba43701d23"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga0931355af8023157001a13f3bea57d76"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga0931355af8023157001a13f3bea57d76">qwtCompassShowBackground</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int show)</td></tr> <tr class="separator:ga0931355af8023157001a13f3bea57d76"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga97a710edd258be54028ea7121e89a942"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga97a710edd258be54028ea7121e89a942">qwtCompassSetLineWidth</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int width)</td></tr> <tr class="separator:ga97a710edd258be54028ea7121e89a942"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga8d027e5858007df0e5218d0ebfbc6b6d"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga8d027e5858007df0e5218d0ebfbc6b6d">qwtCompassSetMode</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int mode)</td></tr> <tr class="separator:ga8d027e5858007df0e5218d0ebfbc6b6d"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga768811f369d04d44f37aba242b039940"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga768811f369d04d44f37aba242b039940">qwtCompassSetWrapping</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int wrap)</td></tr> <tr class="separator:ga768811f369d04d44f37aba242b039940"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga5562e4560f675bbe0edd7dcfdfe0b1a8"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga5562e4560f675bbe0edd7dcfdfe0b1a8">qwtCompassSetScale</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int maxMajIntv, int maxMinIntv, float step)</td></tr> <tr class="separator:ga5562e4560f675bbe0edd7dcfdfe0b1a8"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:gaae5fc86eafb2cde68303ac85c94a5149"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#gaae5fc86eafb2cde68303ac85c94a5149">qwtCompassSetScaleArc</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, float min, float max)</td></tr> <tr class="separator:gaae5fc86eafb2cde68303ac85c94a5149"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga0ffe80513cca601cdc69d7a3471d56b2"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga0ffe80513cca601cdc69d7a3471d56b2">qwtCompassSetOrigin</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, float o)</td></tr> <tr class="separator:ga0ffe80513cca601cdc69d7a3471d56b2"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga481e59381168cd19468c2c17f7cc964b"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga481e59381168cd19468c2c17f7cc964b">qwtCompassSetNeedle</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, int which, int r1=0, int g1=0, int b1=0, int r2=255, int g2=255, int b2=255, int r3=128, int g3=128, int b3=128)</td></tr> <tr class="separator:ga481e59381168cd19468c2c17f7cc964b"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:ga6babc6e3a31500933fbd3cbb00d11108"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__QwtCompass.html#ga6babc6e3a31500933fbd3cbb00d11108">qwtCompassSetValue</a> (<a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *p, int id, float value)</td></tr> <tr class="separator:ga6babc6e3a31500933fbd3cbb00d11108"><td class="memSeparator" colspan="2">&#160;</td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <p>QwtCompass Widget </p> <h2 class="groupheader">Function Documentation</h2> <a id="ga41e3e7de188683554d3a53ba43701d23"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga41e3e7de188683554d3a53ba43701d23">&#9670;&nbsp;</a></span>qwtCompassSetFrameShadow()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetFrameShadow </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>shadow</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> <a class="el" href="group__DefinesAndEnums.html#gaf31c9033ceddee69ad7bea3067b40276">DialShadow</a>. </pre> </div> </div> <a id="ga97a710edd258be54028ea7121e89a942"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga97a710edd258be54028ea7121e89a942">&#9670;&nbsp;</a></span>qwtCompassSetLineWidth()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetLineWidth </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>width</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga184d68f60481887df39f669848cd6967"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga184d68f60481887df39f669848cd6967">&#9670;&nbsp;</a></span>qwtCompassSetMass()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetMass </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>mass</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga8d027e5858007df0e5218d0ebfbc6b6d"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga8d027e5858007df0e5218d0ebfbc6b6d">&#9670;&nbsp;</a></span>qwtCompassSetMode()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetMode </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>mode</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> <a class="el" href="group__DefinesAndEnums.html#ga83400f3ac84ef3db48330f4cedeecb7a">DialMode</a>. </pre> </div> </div> <a id="ga481e59381168cd19468c2c17f7cc964b"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga481e59381168cd19468c2c17f7cc964b">&#9670;&nbsp;</a></span>qwtCompassSetNeedle()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetNeedle </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>which</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>r1</em> = <code>0</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>g1</em> = <code>0</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>b1</em> = <code>0</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>r2</em> = <code>255</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>g2</em> = <code>255</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>b2</em> = <code>255</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>r3</em> = <code>128</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>g3</em> = <code>128</code>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>b3</em> = <code>128</code>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> which = <a class="el" href="group__DefinesAndEnums.html#gabf9c3eb6073027971b7278b55b3a32fe">CompassNeedle</a>. </pre> </div> </div> <a id="ga0ffe80513cca601cdc69d7a3471d56b2"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga0ffe80513cca601cdc69d7a3471d56b2">&#9670;&nbsp;</a></span>qwtCompassSetOrigin()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetOrigin </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>o</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga4889dec7435211bfee96a166870ed480"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga4889dec7435211bfee96a166870ed480">&#9670;&nbsp;</a></span>qwtCompassSetRange()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetRange </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>vmin</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>vmax</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>step</em> = <code>0.0f</code>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga943204243a02586ce53743b54f12bbf5"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga943204243a02586ce53743b54f12bbf5">&#9670;&nbsp;</a></span>qwtCompassSetReadOnly()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetReadOnly </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>rdonly</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> rdonly = 0 | 1 </pre> </div> </div> <a id="ga5562e4560f675bbe0edd7dcfdfe0b1a8"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga5562e4560f675bbe0edd7dcfdfe0b1a8">&#9670;&nbsp;</a></span>qwtCompassSetScale()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetScale </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>maxMajIntv</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>maxMinIntv</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>step</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="gaae5fc86eafb2cde68303ac85c94a5149"></a> <h2 class="memtitle"><span class="permalink"><a href="#gaae5fc86eafb2cde68303ac85c94a5149">&#9670;&nbsp;</a></span>qwtCompassSetScaleArc()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetScaleArc </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>min</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>max</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga947510da753749d8565e272766810671"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga947510da753749d8565e272766810671">&#9670;&nbsp;</a></span>qwtCompassSetSimpleCompassRose()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetSimpleCompassRose </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>numThorns</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>numThornLevels</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>width</em> = <code>0.2f</code>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga6babc6e3a31500933fbd3cbb00d11108"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga6babc6e3a31500933fbd3cbb00d11108">&#9670;&nbsp;</a></span>qwtCompassSetValue()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetValue </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">float&#160;</td> <td class="paramname"><em>value</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga768811f369d04d44f37aba242b039940"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga768811f369d04d44f37aba242b039940">&#9670;&nbsp;</a></span>qwtCompassSetWrapping()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassSetWrapping </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>wrap</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> <a id="ga0931355af8023157001a13f3bea57d76"></a> <h2 class="memtitle"><span class="permalink"><a href="#ga0931355af8023157001a13f3bea57d76">&#9670;&nbsp;</a></span>qwtCompassShowBackground()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int qwtCompassShowBackground </td> <td>(</td> <td class="paramtype"><a class="el" href="group__DefinesAndEnums.html#ga18296754012515ac673ee13d34243180">PARAM</a> *&#160;</td> <td class="paramname"><em>p</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int&#160;</td> <td class="paramname"><em>show</em>&#160;</td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <pre> </pre> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.14 </small></address> </body> </html>
{ "pile_set_name": "Github" }
<%-- Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v. 2.0, which is available at http://www.eclipse.org/legal/epl-2.0. This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License v. 2.0 are satisfied: GNU General Public License, version 2 with the GNU Classpath Exception, which is available at https://www.gnu.org/software/classpath/license.html. SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head><title>Simple jsp page</title></head> <body>JSP Error Page</body> </html>
{ "pile_set_name": "Github" }
// Copyright 2018 The Prometheus 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 procfs import ( "bufio" "bytes" "fmt" "io" "strconv" "strings" "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) // CPUStat shows how much time the cpu spend in various stages. type CPUStat struct { User float64 Nice float64 System float64 Idle float64 Iowait float64 IRQ float64 SoftIRQ float64 Steal float64 Guest float64 GuestNice float64 } // SoftIRQStat represent the softirq statistics as exported in the procfs stat file. // A nice introduction can be found at https://0xax.gitbooks.io/linux-insides/content/interrupts/interrupts-9.html // It is possible to get per-cpu stats by reading /proc/softirqs type SoftIRQStat struct { Hi uint64 Timer uint64 NetTx uint64 NetRx uint64 Block uint64 BlockIoPoll uint64 Tasklet uint64 Sched uint64 Hrtimer uint64 Rcu uint64 } // Stat represents kernel/system statistics. type Stat struct { // Boot time in seconds since the Epoch. BootTime uint64 // Summed up cpu statistics. CPUTotal CPUStat // Per-CPU statistics. CPU []CPUStat // Number of times interrupts were handled, which contains numbered and unnumbered IRQs. IRQTotal uint64 // Number of times a numbered IRQ was triggered. IRQ []uint64 // Number of times a context switch happened. ContextSwitches uint64 // Number of times a process was created. ProcessCreated uint64 // Number of processes currently running. ProcessesRunning uint64 // Number of processes currently blocked (waiting for IO). ProcessesBlocked uint64 // Number of times a softirq was scheduled. SoftIRQTotal uint64 // Detailed softirq statistics. SoftIRQ SoftIRQStat } // Parse a cpu statistics line and returns the CPUStat struct plus the cpu id (or -1 for the overall sum). func parseCPUStat(line string) (CPUStat, int64, error) { cpuStat := CPUStat{} var cpu string count, err := fmt.Sscanf(line, "%s %f %f %f %f %f %f %f %f %f %f", &cpu, &cpuStat.User, &cpuStat.Nice, &cpuStat.System, &cpuStat.Idle, &cpuStat.Iowait, &cpuStat.IRQ, &cpuStat.SoftIRQ, &cpuStat.Steal, &cpuStat.Guest, &cpuStat.GuestNice) if err != nil && err != io.EOF { return CPUStat{}, -1, fmt.Errorf("couldn't parse %s (cpu): %s", line, err) } if count == 0 { return CPUStat{}, -1, fmt.Errorf("couldn't parse %s (cpu): 0 elements parsed", line) } cpuStat.User /= userHZ cpuStat.Nice /= userHZ cpuStat.System /= userHZ cpuStat.Idle /= userHZ cpuStat.Iowait /= userHZ cpuStat.IRQ /= userHZ cpuStat.SoftIRQ /= userHZ cpuStat.Steal /= userHZ cpuStat.Guest /= userHZ cpuStat.GuestNice /= userHZ if cpu == "cpu" { return cpuStat, -1, nil } cpuID, err := strconv.ParseInt(cpu[3:], 10, 64) if err != nil { return CPUStat{}, -1, fmt.Errorf("couldn't parse %s (cpu/cpuid): %s", line, err) } return cpuStat, cpuID, nil } // Parse a softirq line. func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) { softIRQStat := SoftIRQStat{} var total uint64 var prefix string _, err := fmt.Sscanf(line, "%s %d %d %d %d %d %d %d %d %d %d %d", &prefix, &total, &softIRQStat.Hi, &softIRQStat.Timer, &softIRQStat.NetTx, &softIRQStat.NetRx, &softIRQStat.Block, &softIRQStat.BlockIoPoll, &softIRQStat.Tasklet, &softIRQStat.Sched, &softIRQStat.Hrtimer, &softIRQStat.Rcu) if err != nil { return SoftIRQStat{}, 0, fmt.Errorf("couldn't parse %s (softirq): %s", line, err) } return softIRQStat, total, nil } // NewStat returns information about current cpu/process statistics. // See https://www.kernel.org/doc/Documentation/filesystems/proc.txt // // Deprecated: use fs.Stat() instead func NewStat() (Stat, error) { fs, err := NewFS(fs.DefaultProcMountPoint) if err != nil { return Stat{}, err } return fs.Stat() } // NewStat returns information about current cpu/process statistics. // See https://www.kernel.org/doc/Documentation/filesystems/proc.txt // // Deprecated: use fs.Stat() instead func (fs FS) NewStat() (Stat, error) { return fs.Stat() } // Stat returns information about current cpu/process statistics. // See https://www.kernel.org/doc/Documentation/filesystems/proc.txt func (fs FS) Stat() (Stat, error) { fileName := fs.proc.Path("stat") data, err := util.ReadFileNoStat(fileName) if err != nil { return Stat{}, err } stat := Stat{} scanner := bufio.NewScanner(bytes.NewReader(data)) for scanner.Scan() { line := scanner.Text() parts := strings.Fields(scanner.Text()) // require at least <key> <value> if len(parts) < 2 { continue } switch { case parts[0] == "btime": if stat.BootTime, err = strconv.ParseUint(parts[1], 10, 64); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s (btime): %s", parts[1], err) } case parts[0] == "intr": if stat.IRQTotal, err = strconv.ParseUint(parts[1], 10, 64); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s (intr): %s", parts[1], err) } numberedIRQs := parts[2:] stat.IRQ = make([]uint64, len(numberedIRQs)) for i, count := range numberedIRQs { if stat.IRQ[i], err = strconv.ParseUint(count, 10, 64); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s (intr%d): %s", count, i, err) } } case parts[0] == "ctxt": if stat.ContextSwitches, err = strconv.ParseUint(parts[1], 10, 64); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s (ctxt): %s", parts[1], err) } case parts[0] == "processes": if stat.ProcessCreated, err = strconv.ParseUint(parts[1], 10, 64); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s (processes): %s", parts[1], err) } case parts[0] == "procs_running": if stat.ProcessesRunning, err = strconv.ParseUint(parts[1], 10, 64); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s (procs_running): %s", parts[1], err) } case parts[0] == "procs_blocked": if stat.ProcessesBlocked, err = strconv.ParseUint(parts[1], 10, 64); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s (procs_blocked): %s", parts[1], err) } case parts[0] == "softirq": softIRQStats, total, err := parseSoftIRQStat(line) if err != nil { return Stat{}, err } stat.SoftIRQTotal = total stat.SoftIRQ = softIRQStats case strings.HasPrefix(parts[0], "cpu"): cpuStat, cpuID, err := parseCPUStat(line) if err != nil { return Stat{}, err } if cpuID == -1 { stat.CPUTotal = cpuStat } else { for int64(len(stat.CPU)) <= cpuID { stat.CPU = append(stat.CPU, CPUStat{}) } stat.CPU[cpuID] = cpuStat } } } if err := scanner.Err(); err != nil { return Stat{}, fmt.Errorf("couldn't parse %s: %s", fileName, err) } return stat, nil }
{ "pile_set_name": "Github" }
using System; using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Filters; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Web.Composing; using Umbraco.Web.Editors; namespace Umbraco.Web.WebApi.Filters { /// <summary> /// Auth filter to check if the current user has access to the content item /// </summary> /// <remarks> /// Since media doesn't have permissions, this simply checks start node access /// </remarks> internal sealed class EnsureUserPermissionForMediaAttribute : ActionFilterAttribute { private readonly int? _nodeId; private readonly string _paramName; public enum DictionarySource { ActionArguments, RequestForm, RequestQueryString } /// <summary> /// This constructor will only be able to test the start node access /// </summary> public EnsureUserPermissionForMediaAttribute(int nodeId) { _nodeId = nodeId; } public EnsureUserPermissionForMediaAttribute(string paramName) { if (paramName == null) throw new ArgumentNullException(nameof(paramName)); if (string.IsNullOrEmpty(paramName)) throw new ArgumentException("Value can't be empty.", nameof(paramName)); _paramName = paramName; } // TODO: v8 guess this is not used anymore, source is ignored?! public EnsureUserPermissionForMediaAttribute(string paramName, DictionarySource source) { if (paramName == null) throw new ArgumentNullException(nameof(paramName)); if (string.IsNullOrEmpty(paramName)) throw new ArgumentException("Value can't be empty.", nameof(paramName)); _paramName = paramName; } public override bool AllowMultiple => true; private int GetNodeIdFromParameter(object parameterValue) { if (parameterValue is int) { return (int) parameterValue; } var guidId = Guid.Empty; if (parameterValue is Guid) { guidId = (Guid)parameterValue; } else if (parameterValue is GuidUdi) { guidId = ((GuidUdi) parameterValue).Guid; } if (guidId != Guid.Empty) { var found = Current.Services.EntityService.GetId(guidId, UmbracoObjectTypes.Media); if (found) return found.Result; } throw new InvalidOperationException("The id type: " + parameterValue.GetType() + " is not a supported id"); } public override void OnActionExecuting(HttpActionContext actionContext) { if (Current.UmbracoContext.Security.CurrentUser == null) { throw new HttpResponseException(System.Net.HttpStatusCode.Unauthorized); } int nodeId; if (_nodeId.HasValue == false) { var parts = _paramName.Split(new [] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (actionContext.ActionArguments[parts[0]] == null) { throw new InvalidOperationException("No argument found for the current action with the name: " + _paramName); } if (parts.Length == 1) { nodeId = GetNodeIdFromParameter(actionContext.ActionArguments[parts[0]]); } else { //now we need to see if we can get the property of whatever object it is var pType = actionContext.ActionArguments[parts[0]].GetType(); var prop = pType.GetProperty(parts[1]); if (prop == null) { throw new InvalidOperationException("No argument found for the current action with the name: " + _paramName); } nodeId = GetNodeIdFromParameter(prop.GetValue(actionContext.ActionArguments[parts[0]])); } } else { nodeId = _nodeId.Value; } if (MediaController.CheckPermissions( actionContext.Request.Properties, Current.UmbracoContext.Security.CurrentUser, Current.Services.MediaService, Current.Services.EntityService, nodeId)) { base.OnActionExecuting(actionContext); } else { throw new HttpResponseException(System.Net.HttpStatusCode.Unauthorized); } } } }
{ "pile_set_name": "Github" }
declare module 'node-snackbar' { export = Snackbar } declare namespace Snackbar { function show (options: SnackbarOptions): void } interface SnackbarOptions { /** The text to displae inside the notification. (default: null) */ text?: string /** Text color of the notification text. (default: '#FFFFFF') */ textColor?: string /** The position the notification will show. Refer to the examples above for possible positions. (default: bottom-left) */ pos?: 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right' /** Add a custom class to the notification for custom styling. (default: null) */ customClass?: string /** * Width of the notification. Used to shrink/expand window as you wish. * Accepted value is same as HTMLElement.style.width * (default: 'auto') */ width?: string /** to show the action buton or not. (default: true) */ showAction?: boolean /** Text to display as the action button. (default: 'Dismiss') */ actionText?: string /** Text color of the action button. (default: '#4CAF50') */ actionTextColor?: string /** Background color of the notification window. (default: '#323232') */ backgroundColor?: string /** * Time in milliseconds the notification is displayed before fading out. * Passing 0 or null as value will cause the notification to be permanent until dismissed by clicking the button. * (default: 5000) */ duration?: number /** Default action closes the notification. */ onActionClick?: (element: HTMLElement) => void /** Event fired when the notification has closed. */ onClose?: (element: HTMLElement) => void }
{ "pile_set_name": "Github" }
import os import config from flask import Flask class SkyLines(Flask): def __init__(self, name="skylines", config_file=None, *args, **kw): # Create Flask instance super(SkyLines, self).__init__(name, *args, **kw) # Load default settings and from environment variable self.config.from_pyfile(config.DEFAULT_CONF_PATH) if "SKYLINES_CONFIG" in os.environ: self.config.from_pyfile(os.environ["SKYLINES_CONFIG"]) if config_file: self.config.from_pyfile(config_file) def add_sqlalchemy(self): """ Create and configure SQLAlchemy extension """ from skylines.database import db db.init_app(self) def add_cache(self): """ Create and attach Cache extension """ from skylines.api.cache import cache cache.init_app(self) def add_logging_handlers(self): if self.debug: return import logging from logging import Formatter from logging.handlers import RotatingFileHandler # Set general log level self.logger.setLevel(logging.INFO) # Add log file handler (if configured) path = self.config.get("LOGFILE") if path: file_handler = RotatingFileHandler(path, "a", 10000, 4) file_handler.setLevel(logging.INFO) file_formatter = Formatter( "%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]" ) file_handler.setFormatter(file_formatter) self.logger.addHandler(file_handler) def add_sentry(self): import sentry_sdk from sentry_sdk.integrations.flask import FlaskIntegration from sentry_sdk.integrations.redis import RedisIntegration from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration from sentry_sdk.integrations.celery import CeleryIntegration sentry_config = self.config.get("SENTRY_CONFIG") dsn = sentry_config.get("dsn") if sentry_config else None sentry_sdk.init( dsn=dsn, integrations=[ FlaskIntegration(transaction_style="url"), SqlalchemyIntegration(), RedisIntegration(), CeleryIntegration(), ], ) def add_celery(self): from skylines.worker.celery import celery celery.init_app(self) def load_egm96(self): from skylines.lib.geoid import load_geoid load_geoid() def create_app(*args, **kw): app = SkyLines(*args, **kw) app.add_sqlalchemy() app.add_sentry() return app def create_http_app(*args, **kw): app = create_app(*args, **kw) app.add_logging_handlers() app.add_celery() return app def create_frontend_app(*args, **kw): app = create_http_app("skylines.frontend", *args, **kw) import skylines.frontend.views skylines.frontend.views.register(app) return app def create_api_app(*args, **kw): from skylines.api.oauth import oauth app = create_http_app("skylines.api", *args, **kw) app.config["JSON_SORT_KEYS"] = False app.load_egm96() app.add_cache() oauth.init_app(app) import skylines.api.views skylines.api.views.register(app) return app def create_combined_app(*args, **kw): from werkzeug.wsgi import DispatcherMiddleware frontend = create_frontend_app(*args, **kw) api = create_api_app(*args, **kw) mounts = {"/api": api} frontend.wsgi_app = DispatcherMiddleware(frontend.wsgi_app, mounts) return frontend def create_celery_app(*args, **kw): app = create_app("skylines.worker", *args, **kw) app.add_celery() return app
{ "pile_set_name": "Github" }
{ "name": "Checkpoint", "properties": { "seq": { "type": "number" }, "time": { "type": "date" }, "sourceId": { "type": "string" } } }
{ "pile_set_name": "Github" }
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build 386 arm mips32 mips32le package crc32 // The file contains the generic version of updateCastagnoli which just calls // the software implementation. func updateCastagnoli(crc uint32, p []byte) uint32 { return update(crc, castagnoliTable, p) }
{ "pile_set_name": "Github" }
/* * Copyright 2004, 2007-2011 Freescale Semiconductor, Inc. * * (C) Copyright 2003 Motorola Inc. * Xianghua Xiao, (X.Xiao@motorola.com) * * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <ppc_asm.tmpl> #include <linux/compiler.h> #include <asm/processor.h> #include <asm/io.h> DECLARE_GLOBAL_DATA_PTR; #ifndef CONFIG_SYS_FSL_NUM_CC_PLLS #define CONFIG_SYS_FSL_NUM_CC_PLLS 6 #endif /* --------------------------------------------------------------- */ void get_sys_info(sys_info_t *sys_info) { volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); #ifdef CONFIG_FSL_IFC struct fsl_ifc *ifc_regs = (void *)CONFIG_SYS_IFC_ADDR; u32 ccr; #endif #ifdef CONFIG_FSL_CORENET volatile ccsr_clk_t *clk = (void *)(CONFIG_SYS_FSL_CORENET_CLK_ADDR); unsigned int cpu; #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 int cc_group[12] = CONFIG_SYS_FSL_CLUSTER_CLOCKS; #endif __maybe_unused u32 svr; const u8 core_cplx_PLL[16] = { [ 0] = 0, /* CC1 PPL / 1 */ [ 1] = 0, /* CC1 PPL / 2 */ [ 2] = 0, /* CC1 PPL / 4 */ [ 4] = 1, /* CC2 PPL / 1 */ [ 5] = 1, /* CC2 PPL / 2 */ [ 6] = 1, /* CC2 PPL / 4 */ [ 8] = 2, /* CC3 PPL / 1 */ [ 9] = 2, /* CC3 PPL / 2 */ [10] = 2, /* CC3 PPL / 4 */ [12] = 3, /* CC4 PPL / 1 */ [13] = 3, /* CC4 PPL / 2 */ [14] = 3, /* CC4 PPL / 4 */ }; const u8 core_cplx_pll_div[16] = { [ 0] = 1, /* CC1 PPL / 1 */ [ 1] = 2, /* CC1 PPL / 2 */ [ 2] = 4, /* CC1 PPL / 4 */ [ 4] = 1, /* CC2 PPL / 1 */ [ 5] = 2, /* CC2 PPL / 2 */ [ 6] = 4, /* CC2 PPL / 4 */ [ 8] = 1, /* CC3 PPL / 1 */ [ 9] = 2, /* CC3 PPL / 2 */ [10] = 4, /* CC3 PPL / 4 */ [12] = 1, /* CC4 PPL / 1 */ [13] = 2, /* CC4 PPL / 2 */ [14] = 4, /* CC4 PPL / 4 */ }; uint i, freq_c_pll[CONFIG_SYS_FSL_NUM_CC_PLLS]; #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) uint rcw_tmp; #endif uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS]; unsigned long sysclk = CONFIG_SYS_CLK_FREQ; uint mem_pll_rat; sys_info->freq_systembus = sysclk; #ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK uint ddr_refclk_sel; unsigned int porsr1_sys_clk; porsr1_sys_clk = in_be32(&gur->porsr1) >> FSL_DCFG_PORSR1_SYSCLK_SHIFT & FSL_DCFG_PORSR1_SYSCLK_MASK; if (porsr1_sys_clk == FSL_DCFG_PORSR1_SYSCLK_DIFF) sys_info->diff_sysclk = 1; else sys_info->diff_sysclk = 0; /* * DDR_REFCLK_SEL rcw bit is used to determine if DDR PLLS * are driven by separate DDR Refclock or single source * differential clock. */ ddr_refclk_sel = (in_be32(&gur->rcwsr[5]) >> FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT) & FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK; /* * For single source clocking, both ddrclock and sysclock * are driven by differential sysclock. */ if (ddr_refclk_sel == FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK) sys_info->freq_ddrbus = CONFIG_SYS_CLK_FREQ; else #endif #ifdef CONFIG_DDR_CLK_FREQ sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ; #else sys_info->freq_ddrbus = sysclk; #endif sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT) & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; #ifdef CONFIG_SYS_FSL_ERRATUM_A007212 if (mem_pll_rat == 0) { mem_pll_rat = (in_be32(&gur->rcwsr[0]) >> FSL_CORENET_RCWSR0_MEM_PLL_RAT_RESV_SHIFT) & FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK; } #endif /* T4240/T4160 Rev2.0 MEM_PLL_RAT uses a value which is half of * T4240/T4160 Rev1.0. eg. It's 12 in Rev1.0, however, for Rev2.0 * it uses 6. * T2080 rev 1.1 and later also use half mem_pll comparing with rev 1.0 */ #if defined(CONFIG_PPC_T4240) || defined(CONFIG_PPC_T4160) || \ defined(CONFIG_PPC_T4080) || defined(CONFIG_PPC_T2080) svr = get_svr(); switch (SVR_SOC_VER(svr)) { case SVR_T4240: case SVR_T4160: case SVR_T4120: case SVR_T4080: if (SVR_MAJ(svr) >= 2) mem_pll_rat *= 2; break; case SVR_T2080: case SVR_T2081: if ((SVR_MAJ(svr) > 1) || (SVR_MIN(svr) >= 1)) mem_pll_rat *= 2; break; default: break; } #endif if (mem_pll_rat > 2) sys_info->freq_ddrbus *= mem_pll_rat; else sys_info->freq_ddrbus = sys_info->freq_systembus * mem_pll_rat; for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) { ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0x3f; if (ratio[i] > 4) freq_c_pll[i] = sysclk * ratio[i]; else freq_c_pll[i] = sys_info->freq_systembus * ratio[i]; } #ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2 /* * As per CHASSIS2 architeture total 12 clusters are posible and * Each cluster has up to 4 cores, sharing the same PLL selection. * The cluster clock assignment is SoC defined. * * Total 4 clock groups are possible with 3 PLLs each. * as per array indices, clock group A has 0, 1, 2 numbered PLLs & * clock group B has 3, 4, 6 and so on. * * Clock group A having PLL1, PLL2, PLL3, feeding cores of any cluster * depends upon the SoC architeture. Same applies to other * clock groups and clusters. * */ for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { int cluster = fsl_qoriq_core_to_cluster(cpu); u32 c_pll_sel = (in_be32(&clk->clkcsr[cluster].clkcncsr) >> 27) & 0xf; u32 cplx_pll = core_cplx_PLL[c_pll_sel]; cplx_pll += cc_group[cluster] - 1; sys_info->freq_processor[cpu] = freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; } #if defined(CONFIG_PPC_B4860) || defined(CONFIG_PPC_B4420) || \ defined(CONFIG_PPC_T2080) || defined(CONFIG_PPC_T2081) #define FM1_CLK_SEL 0xe0000000 #define FM1_CLK_SHIFT 29 #elif defined(CONFIG_PPC_T1024) || defined(CONFIG_PPC_T1023) #define FM1_CLK_SEL 0x00000007 #define FM1_CLK_SHIFT 0 #else #define PME_CLK_SEL 0xe0000000 #define PME_CLK_SHIFT 29 #define FM1_CLK_SEL 0x1c000000 #define FM1_CLK_SHIFT 26 #endif #if !defined(CONFIG_FM_PLAT_CLK_DIV) || !defined(CONFIG_PME_PLAT_CLK_DIV) #if defined(CONFIG_PPC_T1024) || defined(CONFIG_PPC_T1023) rcw_tmp = in_be32(&gur->rcwsr[15]) - 4; #else rcw_tmp = in_be32(&gur->rcwsr[7]); #endif #endif #ifdef CONFIG_SYS_DPAA_PME #ifndef CONFIG_PME_PLAT_CLK_DIV switch ((rcw_tmp & PME_CLK_SEL) >> PME_CLK_SHIFT) { case 1: sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK]; break; case 2: sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 2; break; case 3: sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 3; break; case 4: sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK] / 4; break; case 6: sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 2; break; case 7: sys_info->freq_pme = freq_c_pll[CONFIG_SYS_PME_CLK + 1] / 3; break; default: printf("Error: Unknown PME clock select!\n"); case 0: sys_info->freq_pme = sys_info->freq_systembus / 2; break; } #else sys_info->freq_pme = sys_info->freq_systembus / CONFIG_SYS_PME_CLK; #endif #endif #ifdef CONFIG_SYS_DPAA_QBMAN #ifndef CONFIG_QBMAN_CLK_DIV #define CONFIG_QBMAN_CLK_DIV 2 #endif sys_info->freq_qman = sys_info->freq_systembus / CONFIG_QBMAN_CLK_DIV; #endif #ifdef CONFIG_SYS_DPAA_FMAN #ifndef CONFIG_FM_PLAT_CLK_DIV switch ((rcw_tmp & FM1_CLK_SEL) >> FM1_CLK_SHIFT) { case 1: sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK]; break; case 2: sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 2; break; case 3: sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 3; break; case 4: sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK] / 4; break; case 5: sys_info->freq_fman[0] = sys_info->freq_systembus; break; case 6: sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 2; break; case 7: sys_info->freq_fman[0] = freq_c_pll[CONFIG_SYS_FM1_CLK + 1] / 3; break; default: printf("Error: Unknown FMan1 clock select!\n"); case 0: sys_info->freq_fman[0] = sys_info->freq_systembus / 2; break; } #if (CONFIG_SYS_NUM_FMAN) == 2 #ifdef CONFIG_SYS_FM2_CLK #define FM2_CLK_SEL 0x00000038 #define FM2_CLK_SHIFT 3 rcw_tmp = in_be32(&gur->rcwsr[15]); switch ((rcw_tmp & FM2_CLK_SEL) >> FM2_CLK_SHIFT) { case 1: sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1]; break; case 2: sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 2; break; case 3: sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 3; break; case 4: sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 4; break; case 5: sys_info->freq_fman[1] = sys_info->freq_systembus; break; case 6: sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 2; break; case 7: sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 3; break; default: printf("Error: Unknown FMan2 clock select!\n"); case 0: sys_info->freq_fman[1] = sys_info->freq_systembus / 2; break; } #endif #endif /* CONFIG_SYS_NUM_FMAN == 2 */ #else sys_info->freq_fman[0] = sys_info->freq_systembus / CONFIG_SYS_FM1_CLK; #endif #endif #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ for_each_cpu(i, cpu, cpu_numcores(), cpu_mask()) { u32 c_pll_sel = (in_be32(&clk->clkcsr[cpu].clkcncsr) >> 27) & 0xf; u32 cplx_pll = core_cplx_PLL[c_pll_sel]; sys_info->freq_processor[cpu] = freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel]; } #define PME_CLK_SEL 0x80000000 #define FM1_CLK_SEL 0x40000000 #define FM2_CLK_SEL 0x20000000 #define HWA_ASYNC_DIV 0x04000000 #if (CONFIG_SYS_FSL_NUM_CC_PLLS == 2) #define HWA_CC_PLL 1 #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 3) #define HWA_CC_PLL 2 #elif (CONFIG_SYS_FSL_NUM_CC_PLLS == 4) #define HWA_CC_PLL 2 #else #error CONFIG_SYS_FSL_NUM_CC_PLLS not set or unknown case #endif rcw_tmp = in_be32(&gur->rcwsr[7]); #ifdef CONFIG_SYS_DPAA_PME if (rcw_tmp & PME_CLK_SEL) { if (rcw_tmp & HWA_ASYNC_DIV) sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 4; else sys_info->freq_pme = freq_c_pll[HWA_CC_PLL] / 2; } else { sys_info->freq_pme = sys_info->freq_systembus / 2; } #endif #ifdef CONFIG_SYS_DPAA_FMAN if (rcw_tmp & FM1_CLK_SEL) { if (rcw_tmp & HWA_ASYNC_DIV) sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 4; else sys_info->freq_fman[0] = freq_c_pll[HWA_CC_PLL] / 2; } else { sys_info->freq_fman[0] = sys_info->freq_systembus / 2; } #if (CONFIG_SYS_NUM_FMAN) == 2 if (rcw_tmp & FM2_CLK_SEL) { if (rcw_tmp & HWA_ASYNC_DIV) sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 4; else sys_info->freq_fman[1] = freq_c_pll[HWA_CC_PLL] / 2; } else { sys_info->freq_fman[1] = sys_info->freq_systembus / 2; } #endif #endif #ifdef CONFIG_SYS_DPAA_QBMAN sys_info->freq_qman = sys_info->freq_systembus / 2; #endif #endif /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */ #ifdef CONFIG_U_QE sys_info->freq_qe = sys_info->freq_systembus / 2; #endif #else /* CONFIG_FSL_CORENET */ uint plat_ratio, e500_ratio, half_freq_systembus; int i; #ifdef CONFIG_QE __maybe_unused u32 qe_ratio; #endif plat_ratio = (gur->porpllsr) & 0x0000003e; plat_ratio >>= 1; sys_info->freq_systembus = plat_ratio * CONFIG_SYS_CLK_FREQ; /* Divide before multiply to avoid integer * overflow for processor speeds above 2GHz */ half_freq_systembus = sys_info->freq_systembus/2; for (i = 0; i < cpu_numcores(); i++) { e500_ratio = ((gur->porpllsr) >> (i * 8 + 16)) & 0x3f; sys_info->freq_processor[i] = e500_ratio * half_freq_systembus; } /* Note: freq_ddrbus is the MCLK frequency, not the data rate. */ sys_info->freq_ddrbus = sys_info->freq_systembus; #ifdef CONFIG_DDR_CLK_FREQ { u32 ddr_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO) >> MPC85xx_PORPLLSR_DDR_RATIO_SHIFT; if (ddr_ratio != 0x7) sys_info->freq_ddrbus = ddr_ratio * CONFIG_DDR_CLK_FREQ; } #endif #ifdef CONFIG_QE #if defined(CONFIG_P1012) || defined(CONFIG_P1021) || defined(CONFIG_P1025) sys_info->freq_qe = sys_info->freq_systembus; #else qe_ratio = ((gur->porpllsr) & MPC85xx_PORPLLSR_QE_RATIO) >> MPC85xx_PORPLLSR_QE_RATIO_SHIFT; sys_info->freq_qe = qe_ratio * CONFIG_SYS_CLK_FREQ; #endif #endif #ifdef CONFIG_SYS_DPAA_FMAN sys_info->freq_fman[0] = sys_info->freq_systembus; #endif #endif /* CONFIG_FSL_CORENET */ #if defined(CONFIG_FSL_LBC) uint lcrr_div; #if defined(CONFIG_SYS_LBC_LCRR) /* We will program LCRR to this value later */ lcrr_div = CONFIG_SYS_LBC_LCRR & LCRR_CLKDIV; #else lcrr_div = in_be32(&(LBC_BASE_ADDR)->lcrr) & LCRR_CLKDIV; #endif if (lcrr_div == 2 || lcrr_div == 4 || lcrr_div == 8) { #if defined(CONFIG_FSL_CORENET) /* If this is corenet based SoC, bit-representation * for four times the clock divider values. */ lcrr_div *= 4; #elif !defined(CONFIG_MPC8540) && !defined(CONFIG_MPC8541) && \ !defined(CONFIG_MPC8555) && !defined(CONFIG_MPC8560) /* * Yes, the entire PQ38 family use the same * bit-representation for twice the clock divider values. */ lcrr_div *= 2; #endif sys_info->freq_localbus = sys_info->freq_systembus / lcrr_div; } else { /* In case anyone cares what the unknown value is */ sys_info->freq_localbus = lcrr_div; } #endif #if defined(CONFIG_FSL_IFC) ccr = ifc_in32(&ifc_regs->ifc_ccr); ccr = ((ccr & IFC_CCR_CLK_DIV_MASK) >> IFC_CCR_CLK_DIV_SHIFT) + 1; sys_info->freq_localbus = sys_info->freq_systembus / ccr; #endif } int get_clocks (void) { sys_info_t sys_info; #ifdef CONFIG_MPC8544 volatile ccsr_gur_t *gur = (void *) CONFIG_SYS_MPC85xx_GUTS_ADDR; #endif #if defined(CONFIG_CPM2) volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR; uint sccr, dfbrg; /* set VCO = 4 * BRG */ cpm->im_cpm_intctl.sccr &= 0xfffffffc; sccr = cpm->im_cpm_intctl.sccr; dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT; #endif get_sys_info (&sys_info); gd->cpu_clk = sys_info.freq_processor[0]; gd->bus_clk = sys_info.freq_systembus; gd->mem_clk = sys_info.freq_ddrbus; gd->arch.lbc_clk = sys_info.freq_localbus; #ifdef CONFIG_QE gd->arch.qe_clk = sys_info.freq_qe; gd->arch.brg_clk = gd->arch.qe_clk / 2; #endif /* * The base clock for I2C depends on the actual SOC. Unfortunately, * there is no pattern that can be used to determine the frequency, so * the only choice is to look up the actual SOC number and use the value * for that SOC. This information is taken from application note * AN2919. */ #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555) || \ defined(CONFIG_P1022) gd->arch.i2c1_clk = sys_info.freq_systembus; #elif defined(CONFIG_MPC8544) /* * On the 8544, the I2C clock is the same as the SEC clock. This can be * either CCB/2 or CCB/3, depending on the value of cfg_sec_freq. See * 4.4.3.3 of the 8544 RM. Note that this might actually work for all * 85xx, but only the 8544 has cfg_sec_freq, so it's unknown if the * PORDEVSR2_SEC_CFG bit is 0 on all 85xx boards that are not an 8544. */ if (gur->pordevsr2 & MPC85xx_PORDEVSR2_SEC_CFG) gd->arch.i2c1_clk = sys_info.freq_systembus / 3; else gd->arch.i2c1_clk = sys_info.freq_systembus / 2; #else /* Most 85xx SOCs use CCB/2, so this is the default behavior. */ gd->arch.i2c1_clk = sys_info.freq_systembus / 2; #endif gd->arch.i2c2_clk = gd->arch.i2c1_clk; #if defined(CONFIG_FSL_ESDHC) #if defined(CONFIG_MPC8569) || defined(CONFIG_P1010) ||\ defined(CONFIG_P1014) gd->arch.sdhc_clk = gd->bus_clk; #else gd->arch.sdhc_clk = gd->bus_clk / 2; #endif #endif /* defined(CONFIG_FSL_ESDHC) */ #if defined(CONFIG_CPM2) gd->arch.vco_out = 2*sys_info.freq_systembus; gd->arch.cpm_clk = gd->arch.vco_out / 2; gd->arch.scc_clk = gd->arch.vco_out / 4; gd->arch.brg_clk = gd->arch.vco_out / (1 << (2 * (dfbrg + 1))); #endif if(gd->cpu_clk != 0) return (0); else return (1); } /******************************************** * get_bus_freq * return system bus freq in Hz *********************************************/ ulong get_bus_freq (ulong dummy) { return gd->bus_clk; } /******************************************** * get_ddr_freq * return ddr bus freq in Hz *********************************************/ ulong get_ddr_freq (ulong dummy) { return gd->mem_clk; }
{ "pile_set_name": "Github" }
/// <summary> /// this enum describes the type of step a mob/player should have /// </summary> public enum StepType { None, Barefoot, Claw, Shoes, Suit, Heavy, Clown }
{ "pile_set_name": "Github" }
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Multiply-included message file, no traditional include guard. #include <stdint.h> #include "chrome/common/prerender_types.h" #include "content/public/common/referrer.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_param_traits.h" #include "ui/gfx/geometry/size.h" #include "url/gurl.h" #include "url/ipc/url_param_traits.h" #define IPC_MESSAGE_START PrerenderMsgStart IPC_ENUM_TRAITS_MAX_VALUE(prerender::PrerenderMode, prerender::PRERENDER_MODE_COUNT - 1) // PrerenderLinkManager Messages // These are messages sent from the renderer to the browser in // relation to <link rel=prerender> elements. IPC_STRUCT_BEGIN(PrerenderAttributes) IPC_STRUCT_MEMBER(GURL, url) IPC_STRUCT_MEMBER(uint32_t, rel_types) IPC_STRUCT_END() // Notifies of the insertion of a <link rel=prerender> element in the // document. IPC_MESSAGE_CONTROL5(PrerenderHostMsg_AddLinkRelPrerender, int /* prerender_id, assigned by WebPrerendererClient */, PrerenderAttributes, content::Referrer, gfx::Size, int /* render_view_route_id of launcher */) // Notifies on removal of a <link rel=prerender> element from the document. IPC_MESSAGE_CONTROL1(PrerenderHostMsg_CancelLinkRelPrerender, int /* prerender_id, assigned by WebPrerendererClient */) // Notifies on unloading a <link rel=prerender> element from a frame. IPC_MESSAGE_CONTROL1(PrerenderHostMsg_AbandonLinkRelPrerender, int /* prerender_id, assigned by WebPrerendererClient */) // Sent by the renderer process to notify that the resource prefetcher has // discovered all possible subresources and issued requests for them. IPC_MESSAGE_CONTROL0(PrerenderHostMsg_PrefetchFinished) // PrerenderDispatcher Messages // These are messages sent from the browser to the renderer in relation to // running prerenders. // Tells a renderer if it's currently being prerendered. Must only be set // before any navigation occurs, and only set to NO_PRERENDER at most once after // that. IPC_MESSAGE_ROUTED1(PrerenderMsg_SetIsPrerendering, prerender::PrerenderMode) // Signals to launcher that a prerender is running. IPC_MESSAGE_CONTROL1(PrerenderMsg_OnPrerenderStart, int /* prerender_id */) // Signals to launcher that a prerender is running. IPC_MESSAGE_CONTROL1(PrerenderMsg_OnPrerenderStopLoading, int /* prerender_id */) // Signals to launcher that a prerender has had it's 'domcontentloaded' event. IPC_MESSAGE_CONTROL1(PrerenderMsg_OnPrerenderDomContentLoaded, int /* prerender_id */) // Signals to a launcher that a new alias has been added to a prerender. IPC_MESSAGE_CONTROL1(PrerenderMsg_OnPrerenderAddAlias, GURL /* url */) // Signals to a launcher that a new alias has been added to a prerender. IPC_MESSAGE_CONTROL1(PrerenderMsg_OnPrerenderRemoveAliases, std::vector<GURL> /* urls */) // Signals to a launcher that a prerender is no longer running. IPC_MESSAGE_CONTROL1(PrerenderMsg_OnPrerenderStop, int /* prerender_id */)
{ "pile_set_name": "Github" }
/*++ Copyright (c) Microsoft Corporation. All rights reserved. Module Name: ws2san.h Abstract: This module contains the Microsoft-specific extensions to the Windows Sockets SPI for WinSock Direct (SAN) support. Revision History: --*/ #ifndef _WS2SAN_H_ #define _WS2SAN_H_ #ifdef __cplusplus extern "C" { #endif /* * Option for getting maximum RDMA transfer size supported by provider */ #define SO_MAX_RDMA_SIZE 0x700D /* * Option for getting minimum RDMA transfer size feasible (performance-wise) * for the provider */ #define SO_RDMA_THRESHOLD_SIZE 0x700E /* * The upcall table. This structure is passed by value to the service * provider's WSPStartup() entrypoint. */ typedef struct _WSPUPCALLTABLEEX { LPWPUCLOSEEVENT lpWPUCloseEvent; LPWPUCLOSESOCKETHANDLE lpWPUCloseSocketHandle; LPWPUCREATEEVENT lpWPUCreateEvent; LPWPUCREATESOCKETHANDLE lpWPUCreateSocketHandle; LPWPUFDISSET lpWPUFDIsSet; LPWPUGETPROVIDERPATH lpWPUGetProviderPath; LPWPUMODIFYIFSHANDLE lpWPUModifyIFSHandle; LPWPUPOSTMESSAGE lpWPUPostMessage; LPWPUQUERYBLOCKINGCALLBACK lpWPUQueryBlockingCallback; LPWPUQUERYSOCKETHANDLECONTEXT lpWPUQuerySocketHandleContext; LPWPUQUEUEAPC lpWPUQueueApc; LPWPURESETEVENT lpWPUResetEvent; LPWPUSETEVENT lpWPUSetEvent; LPWPUOPENCURRENTTHREAD lpWPUOpenCurrentThread; LPWPUCLOSETHREAD lpWPUCloseThread; LPWPUCOMPLETEOVERLAPPEDREQUEST lpWPUCompleteOverlappedRequest; } WSPUPCALLTABLEEX, FAR * LPWSPUPCALLTABLEEX; /* * An extended WSABUF, that includes a registration handle */ typedef struct _WSABUFEX { u_long len; /* the length of the buffer */ char FAR * buf; /* the pointer to the buffer */ HANDLE handle; /* The handle returned by WSPRegisterMemory */ } WSABUFEX, FAR * LPWSABUFEX; /* * WinSock 2 SPI socket function prototypes */ int WSPAPI WSPStartupEx( IN WORD wVersionRequested, OUT LPWSPDATA lpWSPData, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, IN LPWSPUPCALLTABLEEX lpUpcallTable, OUT LPWSPPROC_TABLE lpProcTable ); typedef int (WSPAPI * LPWSPSTARTUPEX)( WORD wVersionRequested, LPWSPDATA lpWSPData, LPWSAPROTOCOL_INFOW lpProtocolInfo, LPWSPUPCALLTABLEEX lpUpcallTable, LPWSPPROC_TABLE lpProcTable ); #define WSAID_REGISTERMEMORY \ {0xC0B422F5,0xF58C,0x11d1,{0xAD,0x6C,0x00,0xC0,0x4F,0xA3,0x4A,0x2D}} #define WSAID_DEREGISTERMEMORY \ {0xC0B422F6,0xF58C,0x11d1,{0xAD,0x6C,0x00,0xC0,0x4F,0xA3,0x4A,0x2D}} #define WSAID_REGISTERRDMAMEMORY \ {0xC0B422F7,0xF58C,0x11d1,{0xAD,0x6C,0x00,0xC0,0x4F,0xA3,0x4A,0x2D}} #define WSAID_DEREGISTERRDMAMEMORY \ {0xC0B422F8,0xF58C,0x11d1,{0xAD,0x6C,0x00,0xC0,0x4F,0xA3,0x4A,0x2D}} #define WSAID_RDMAWRITE \ {0xC0B422F9,0xF58C,0x11d1,{0xAD,0x6C,0x00,0xC0,0x4F,0xA3,0x4A,0x2D}} #define WSAID_RDMAREAD \ {0xC0B422FA,0xF58C,0x11d1,{0xAD,0x6C,0x00,0xC0,0x4F,0xA3,0x4A,0x2D}} #define WSAID_MEMORYREGISTRATIONCACHECALLBACK \ {0xE5DA4AF8,0xD824,0x48CD,{0xA7,0x99,0x63,0x37,0xA9,0x8E,0xD2,0xAF}} #define MEM_READ 1 #define MEM_WRITE 2 #define MEM_READWRITE 3 HANDLE WSPAPI WSPRegisterMemory( IN SOCKET s, IN PVOID lpBuffer, IN DWORD dwBufferLength, IN DWORD dwFlags, OUT LPINT lpErrno ); int WSPAPI WSPDeregisterMemory( IN SOCKET s, IN HANDLE handle, OUT LPINT lpErrno ); int WSPAPI WSPRegisterRdmaMemory( IN SOCKET s, IN PVOID lpBuffer, IN DWORD dwBufferLength, IN DWORD dwFlags, OUT LPVOID lpRdmaBufferDescriptor, IN OUT LPDWORD lpdwDescriptorLength, OUT LPINT lpErrno ); int WSPAPI WSPDeregisterRdmaMemory( IN SOCKET s, IN LPVOID lpRdmaBufferDescriptor, IN DWORD dwDescriptorLength, OUT LPINT lpErrno ); int WSPAPI WSPRdmaWrite( IN SOCKET s, IN LPWSABUFEX lpBuffers, IN DWORD dwBufferCount, IN LPVOID lpTargetBufferDescriptor, IN DWORD dwTargetDescriptorLength, IN DWORD dwTargetBufferOffset, OUT LPDWORD lpdwNumberOfBytesWritten, IN DWORD dwFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno ); int WSPAPI WSPRdmaRead( IN SOCKET s, IN LPWSABUFEX lpBuffers, IN DWORD dwBufferCount, IN LPVOID lpTargetBufferDescriptor, IN DWORD dwTargetDescriptorLength, IN DWORD dwTargetBufferOffset, OUT LPDWORD lpdwNumberOfBytesRead, IN DWORD dwFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno ); int WSPAPI WSPMemoryRegistrationCacheCallback( IN LPVOID lpvAddress, IN SIZE_T Size, OUT LPINT lpErrno ); /* * "QueryInterface" versions of the above APIs. */ typedef HANDLE (WSPAPI * LPFN_WSPREGISTERMEMORY)( IN SOCKET s, IN PVOID lpBuffer, IN DWORD dwBufferLength, IN DWORD dwFlags, OUT LPINT lpErrno ); typedef int (WSPAPI * LPFN_WSPDEREGISTERMEMORY)( IN SOCKET s, IN HANDLE handle, OUT LPINT lpErrno ); typedef BOOL (WSPAPI * LPFN_WSPREGISTERRDMAMEMORY)( IN SOCKET s, IN PVOID lpBuffer, IN DWORD dwBufferLength, IN DWORD dwFlags, OUT LPVOID lpRdmaBufferDescriptor, IN OUT LPDWORD lpdwDescriptorLength, OUT LPINT lpErrno ); typedef int (WSPAPI * LPFN_WSPDEREGISTERRDMAMEMORY)( IN SOCKET s, IN LPVOID lpRdmaBufferDescriptor, IN DWORD dwDescriptorLength, OUT LPINT lpErrno ); typedef int (WSPAPI * LPFN_WSPRDMAWRITE)( IN SOCKET s, IN LPWSABUFEX lpBuffers, IN DWORD dwBufferCount, IN LPVOID lpTargetBufferDescriptor, IN DWORD dwTargetDescriptorLength, IN DWORD dwTargetBufferOffset, OUT LPDWORD lpdwNumberOfBytesWritten, IN DWORD dwFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno ); typedef int (WSPAPI * LPFN_WSPRDMAREAD)( IN SOCKET s, IN LPWSABUFEX lpBuffers, IN DWORD dwBufferCount, IN LPVOID lpTargetBufferDescriptor, IN DWORD dwTargetDescriptorLength, IN DWORD dwTargetBufferOffset, OUT LPDWORD lpdwNumberOfBytesRead, IN DWORD dwFlags, IN LPWSAOVERLAPPED lpOverlapped, IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, IN LPWSATHREADID lpThreadId, OUT LPINT lpErrno ); typedef int (WSPAPI * LPFN_WSPMEMORYREGISTRATIONCACHECALLBACK)( IN LPVOID lpvAddress, IN SIZE_T Size, OUT LPINT lpErrno ); #ifdef __cplusplus } #endif #endif // _WS2SAN_H_
{ "pile_set_name": "Github" }
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Model logs table class. * * @package tool_analytics * @copyright 2017 David Monllao {@link http://www.davidmonllao.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace tool_analytics\output; defined('MOODLE_INTERNAL') || die; require_once($CFG->libdir . '/tablelib.php'); /** * Model logs table class. * * @package tool_analytics * @copyright 2017 David Monllao {@link http://www.davidmonllao.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class model_logs extends \table_sql { /** * @var \core_analytics\model */ protected $model = null; /** * @var string|false */ protected $evaluationmode = false; /** * Sets up the table_log parameters. * * @param string $uniqueid unique id of form. * @param \core_analytics\model $model */ public function __construct($uniqueid, $model) { global $PAGE; parent::__construct($uniqueid); $this->model = $model; $this->set_attribute('class', 'modellog generaltable generalbox'); $this->set_attribute('aria-live', 'polite'); $this->define_columns(array('time', 'version', 'evaluationmode', 'indicators', 'timesplitting', 'accuracy', 'info', 'usermodified')); $this->define_headers(array( get_string('time'), get_string('version'), get_string('evaluationmode', 'tool_analytics'), get_string('indicators', 'tool_analytics'), get_string('timesplittingmethod', 'analytics'), get_string('accuracy', 'tool_analytics'), get_string('info', 'tool_analytics'), get_string('fullnameuser'), )); $evaluationmodehelp = new \help_icon('evaluationmode', 'tool_analytics'); $this->define_help_for_headers([null, null, $evaluationmodehelp, null, null, null, null, null]); $this->pageable(true); $this->collapsible(false); $this->sortable(false); $this->is_downloadable(false); $this->evaluationmode = optional_param('evaluationmode', false, PARAM_ALPHANUM); if ($this->evaluationmode && $this->evaluationmode != 'configuration' && $this->evaluationmode != 'trainedmodel') { $this->evaluationmode = ''; } $this->define_baseurl($PAGE->url); } /** * Generate the version column. * * @param \stdClass $log log data. * @return string HTML for the version column */ public function col_version($log) { $recenttimestr = get_string('strftimerecent', 'core_langconfig'); return userdate($log->version, $recenttimestr); } /** * Generate the evaluation mode column. * * @param \stdClass $log log data. * @return string HTML for the evaluationmode column */ public function col_evaluationmode($log) { return get_string('evaluationmodecol' . $log->evaluationmode, 'tool_analytics'); } /** * Generate the time column. * * @param \stdClass $log log data. * @return string HTML for the time column */ public function col_time($log) { $recenttimestr = get_string('strftimerecent', 'core_langconfig'); return userdate($log->timecreated, $recenttimestr); } /** * Generate the indicators column. * * @param \stdClass $log log data. * @return string HTML for the indicators column */ public function col_indicators($log) { $indicatorclasses = json_decode($log->indicators); $indicators = array(); foreach ($indicatorclasses as $indicatorclass) { $indicator = \core_analytics\manager::get_indicator($indicatorclass); if ($indicator) { $indicators[] = $indicator->get_name(); } else { debugging('Can\'t load ' . $indicatorclass . ' indicator', DEBUG_DEVELOPER); } } return '<ul><li>' . implode('</li><li>', $indicators) . '</li></ul>'; } /** * Generate the context column. * * @param \stdClass $log log data. * @return string HTML for the context column */ public function col_timesplitting($log) { $timesplitting = \core_analytics\manager::get_time_splitting($log->timesplitting); return $timesplitting->get_name(); } /** * Generate the accuracy column. * * @param \stdClass $log log data. * @return string HTML for the accuracy column */ public function col_accuracy($log) { return strval(round($log->score * 100, 2)) . '%'; } /** * Generate the info column. * * @param \stdClass $log log data. * @return string HTML for the score column */ public function col_info($log) { global $PAGE; if (empty($log->info) && empty($log->dir)) { return ''; } $info = array(); if (!empty($log->info)) { $info = json_decode($log->info); } if (!empty($log->dir)) { $info[] = get_string('predictorresultsin', 'tool_analytics', $log->dir); } $PAGE->requires->js_call_amd('tool_analytics/log_info', 'loadInfo', array($log->id, $info)); return \html_writer::link('#', get_string('view'), array('data-model-log-id' => $log->id)); } /** * Generate the usermodified column. * * @param \stdClass $log log data. * @return string HTML for the usermodified column */ public function col_usermodified($log) { $user = \core_user::get_user($log->usermodified); return fullname($user); } /** * Query the logs table. Store results in the object for use by build_table. * * @param int $pagesize size of page for paginated displayed table. * @param bool $useinitialsbar do you want to use the initials bar. */ public function query_db($pagesize, $useinitialsbar = true) { $total = count($this->model->get_logs()); $this->pagesize($pagesize, $total); $this->rawdata = $this->model->get_logs($this->get_page_start(), $this->get_page_size()); // Set initial bars. if ($useinitialsbar) { $this->initialbars($total > $pagesize); } } }
{ "pile_set_name": "Github" }
# How to Contribute We want your help to make Project Hydra great. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. ## Hydra Project Intellectual Property Licensing and Ownership All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group. If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file. https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project. ## Contribution Tasks * Reporting Issues * Making Changes * Submitting Changes * Merging Changes ### Reporting Issues * Make sure you have a [GitHub account](https://github.com/signup/free) * Submit a [Github issue](./issues) by: * Clearly describing the issue * Provide a descriptive summary * Explain the expected behavior * Explain the actual behavior * Provide steps to reproduce the actual behavior ### Making Changes * Fork the repository on GitHub * Create a topic branch from where you want to base your work. * This is usually the master branch. * To quickly create a topic branch based on master; `git branch fix/master/my_contribution master` * Then checkout the new branch with `git checkout fix/master/my_contribution`. * Please avoid working directly on the `master` branch. * You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful * Make commits of logical units. * Your commit should include a high level description of your work in HISTORY.textile * Check for unnecessary whitespace with `git diff --check` before committing. * Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). * If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages) ``` Present tense short summary (50 characters or less) More detailed description, if necessary. It should be wrapped to 72 characters. Try to be as descriptive as you can, even if you think that the commit content is obvious, it may not be obvious to others. You should add such description also if it's already present in bug tracker, it should not be necessary to visit a webpage to check the history. Include Closes #<issue-number> when relavent. Description can have multiple paragraphs and you can use code examples inside, just indent it with 4 spaces: class PostsController def index respond_with Post.limit(10) end end You can also add bullet points: - you can use dashes or asterisks - also, try to indent next line of a point for readability, if it's too long to fit in 72 characters ``` * Make sure you have added the necessary tests for your changes. * Run _all_ the tests to assure nothing else was accidentally broken. * When you are ready to submit a pull request ### Submitting Changes [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/) * Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub. * Make sure your branch is up to date with its parent branch (i.e. master) * `git checkout master` * `git pull --rebase` * `git checkout <your-branch>` * `git rebase master` * It is likely a good idea to run your tests again. * Squash the commits for your branch into one commit * `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase)) * To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l` * Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on. * Push your changes to a topic branch in your fork of the repository. * Submit a pull request from your fork to the project. ### Merging Changes * It is considered "poor from" to merge your own request. * Please take the time to review the changes and get a sense of what is being changed. Things to consider: * Does the commit message explain what is going on? * Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_ * Does the commit contain more than it should? Are two separate concerns being addressed in one commit? * Did the Travis tests complete successfully? * If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username. * If you like the pull request, but want others to chime in, create a +1 comment and tag a user. # Additional Resources * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) * [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git. * [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
{ "pile_set_name": "Github" }
--- version: 1.0 tool: script template: "/templates/sdcard" params: run: "copy_initfs.sh"
{ "pile_set_name": "Github" }
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. #----------------------------------------------------------------------- # a couple of test stopwords to test that the words are really being # configured from this file: stopworda stopwordb #Standard english stop words taken from Lucene's StopAnalyzer a an and are as at be but by for how if in into is it no not of on or s such t that the their then there these they this to was will with who what when where why
{ "pile_set_name": "Github" }
// Package otp allows authentication through a one time password // instead of a traditional password. package otp import ( "context" "crypto/rand" "crypto/sha512" "crypto/subtle" "encoding/base64" "fmt" "io" "net/http" "strconv" "strings" "github.com/friendsofgo/errors" "github.com/volatiletech/authboss/v3" ) const ( otpSize = 16 maxOTPs = 5 // PageLogin is for identifying the login page for parsing & validation PageLogin = "otplogin" // PageAdd is for adding an otp to the user PageAdd = "otpadd" // PageClear is for deleting all the otps from the user PageClear = "otpclear" // DataNumberOTPs shows the number of otps for add/clear operations DataNumberOTPs = "otp_count" // DataOTP shows the new otp that was added DataOTP = "otp" ) // User for one time passwords type User interface { authboss.User // GetOTPs retrieves a string of comma separated bcrypt'd one time passwords GetOTPs() string // PutOTPs puts a string of comma separated bcrypt'd one time passwords PutOTPs(string) } // MustBeOTPable ensures the user can use one time passwords func MustBeOTPable(user authboss.User) User { u, ok := user.(User) if !ok { panic(fmt.Sprintf("could not upgrade user to an otpable user, type: %T", u)) } return u } func init() { authboss.RegisterModule("otp", &OTP{}) } // OTP module type OTP struct { *authboss.Authboss } // Init module func (o *OTP) Init(ab *authboss.Authboss) (err error) { o.Authboss = ab if err = o.Authboss.Config.Core.ViewRenderer.Load(PageLogin, PageAdd, PageClear); err != nil { return err } o.Authboss.Config.Core.Router.Get("/otp/login", o.Authboss.Core.ErrorHandler.Wrap(o.LoginGet)) o.Authboss.Config.Core.Router.Post("/otp/login", o.Authboss.Core.ErrorHandler.Wrap(o.LoginPost)) var unauthedResponse authboss.MWRespondOnFailure if ab.Config.Modules.ResponseOnUnauthed != 0 { unauthedResponse = ab.Config.Modules.ResponseOnUnauthed } else if ab.Config.Modules.RoutesRedirectOnUnauthed { unauthedResponse = authboss.RespondRedirect } middleware := authboss.MountedMiddleware2(ab, true, authboss.RequireNone, unauthedResponse) o.Authboss.Config.Core.Router.Get("/otp/add", middleware(o.Authboss.Core.ErrorHandler.Wrap(o.AddGet))) o.Authboss.Config.Core.Router.Post("/otp/add", middleware(o.Authboss.Core.ErrorHandler.Wrap(o.AddPost))) o.Authboss.Config.Core.Router.Get("/otp/clear", middleware(o.Authboss.Core.ErrorHandler.Wrap(o.ClearGet))) o.Authboss.Config.Core.Router.Post("/otp/clear", middleware(o.Authboss.Core.ErrorHandler.Wrap(o.ClearPost))) return nil } // LoginGet simply displays the login form func (o *OTP) LoginGet(w http.ResponseWriter, r *http.Request) error { var data authboss.HTMLData if redir := r.URL.Query().Get(authboss.FormValueRedirect); len(redir) != 0 { data = authboss.HTMLData{authboss.FormValueRedirect: redir} } return o.Core.Responder.Respond(w, r, http.StatusOK, PageLogin, data) } // LoginPost attempts to validate the credentials passed in // to log in a user. func (o *OTP) LoginPost(w http.ResponseWriter, r *http.Request) error { logger := o.RequestLogger(r) validatable, err := o.Authboss.Core.BodyReader.Read(PageLogin, r) if err != nil { return err } // Skip validation since all the validation happens during the database lookup and // password check. creds := authboss.MustHaveUserValues(validatable) pid := creds.GetPID() pidUser, err := o.Authboss.Storage.Server.Load(r.Context(), pid) if err == authboss.ErrUserNotFound { logger.Infof("failed to load user requested by pid: %s", pid) data := authboss.HTMLData{authboss.DataErr: "Invalid Credentials"} return o.Authboss.Core.Responder.Respond(w, r, http.StatusOK, PageLogin, data) } else if err != nil { return err } otpUser := MustBeOTPable(pidUser) passwords := splitOTPs(otpUser.GetOTPs()) r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyUser, pidUser)) inputSum := sha512.Sum512([]byte(creds.GetPassword())) matchPassword := -1 for i, p := range passwords { dbSum, err := base64.StdEncoding.DecodeString(p) if err != nil { return errors.Wrap(err, "otp in database was not valid base64") } if 1 == subtle.ConstantTimeCompare(inputSum[:], dbSum) { matchPassword = i break } } var handled bool if matchPassword < 0 { handled, err = o.Authboss.Events.FireAfter(authboss.EventAuthFail, w, r) if err != nil { return err } else if handled { return nil } logger.Infof("user %s failed to log in with otp", pid) data := authboss.HTMLData{authboss.DataErr: "Invalid Credentials"} return o.Authboss.Core.Responder.Respond(w, r, http.StatusOK, PageLogin, data) } logger.Infof("removing otp password from %s", pid) passwords[matchPassword] = passwords[len(passwords)-1] passwords = passwords[:len(passwords)-1] otpUser.PutOTPs(joinOTPs(passwords)) if err = o.Authboss.Config.Storage.Server.Save(r.Context(), pidUser); err != nil { return err } r = r.WithContext(context.WithValue(r.Context(), authboss.CTXKeyValues, validatable)) handled, err = o.Events.FireBefore(authboss.EventAuth, w, r) if err != nil { return err } else if handled { return nil } handled, err = o.Events.FireBefore(authboss.EventAuthHijack, w, r) if err != nil { return err } else if handled { return nil } logger.Infof("user %s logged in via otp", pid) authboss.PutSession(w, authboss.SessionKey, pid) authboss.DelSession(w, authboss.SessionHalfAuthKey) handled, err = o.Authboss.Events.FireAfter(authboss.EventAuth, w, r) if err != nil { return err } else if handled { return nil } ro := authboss.RedirectOptions{ Code: http.StatusTemporaryRedirect, RedirectPath: o.Authboss.Paths.AuthLoginOK, FollowRedirParam: true, } return o.Authboss.Core.Redirector.Redirect(w, r, ro) } // AddGet shows how many passwords exist and allows the user to create a new one func (o *OTP) AddGet(w http.ResponseWriter, r *http.Request) error { return o.showOTPCount(w, r, PageAdd) } // AddPost adds a new password to the user and displays it func (o *OTP) AddPost(w http.ResponseWriter, r *http.Request) error { logger := o.RequestLogger(r) user, err := o.Authboss.CurrentUser(r) if err != nil { return err } otpUser := MustBeOTPable(user) currentOTPs := splitOTPs(otpUser.GetOTPs()) if len(currentOTPs) >= maxOTPs { data := authboss.HTMLData{authboss.DataValidation: fmt.Sprintf("you cannot have more than %d one time passwords", maxOTPs)} return o.Core.Responder.Respond(w, r, http.StatusOK, PageAdd, data) } logger.Infof("generating otp for %s", user.GetPID()) otp, hash, err := generateOTP() if err != nil { return err } currentOTPs = append(currentOTPs, hash) otpUser.PutOTPs(joinOTPs(currentOTPs)) if err := o.Authboss.Config.Storage.Server.Save(r.Context(), user); err != nil { return err } return o.Core.Responder.Respond(w, r, http.StatusOK, PageAdd, authboss.HTMLData{DataOTP: otp}) } // ClearGet shows how many passwords exist and allows the user to clear them all func (o *OTP) ClearGet(w http.ResponseWriter, r *http.Request) error { return o.showOTPCount(w, r, PageClear) } // ClearPost clears all otps that are stored for the user. func (o *OTP) ClearPost(w http.ResponseWriter, r *http.Request) error { logger := o.RequestLogger(r) user, err := o.Authboss.CurrentUser(r) if err != nil { return err } logger.Infof("clearing all otps for user: %s", user.GetPID()) otpUser := MustBeOTPable(user) otpUser.PutOTPs("") if err := o.Authboss.Config.Storage.Server.Save(r.Context(), user); err != nil { return err } return o.Core.Responder.Respond(w, r, http.StatusOK, PageAdd, authboss.HTMLData{DataNumberOTPs: "0"}) } func (o *OTP) showOTPCount(w http.ResponseWriter, r *http.Request, page string) error { user, err := o.Authboss.CurrentUser(r) if err != nil { return err } otpUser := MustBeOTPable(user) ln := strconv.Itoa(len(splitOTPs(otpUser.GetOTPs()))) return o.Core.Responder.Respond(w, r, http.StatusOK, page, authboss.HTMLData{DataNumberOTPs: ln}) } func joinOTPs(otps []string) string { return strings.Join(otps, ",") } func splitOTPs(otps string) []string { if len(otps) == 0 { return nil } return strings.Split(otps, ",") } func generateOTP() (otp string, hash string, err error) { secret := make([]byte, otpSize) if _, err = io.ReadFull(rand.Reader, secret); err != nil { return "", "", err } otp = fmt.Sprintf("%x-%x-%x-%x", secret[0:4], secret[4:8], secret[8:12], secret[12:16], ) sum := sha512.Sum512([]byte(otp)) encoded := make([]byte, base64.StdEncoding.EncodedLen(sha512.Size)) base64.StdEncoding.Encode(encoded, sum[:]) hash = string(encoded) return otp, hash, nil }
{ "pile_set_name": "Github" }
<?php /** * Generated by phpSPO model generator 2020-05-24T21:23:29+00:00 */ namespace Office365\Graph; use Office365\Runtime\ClientValue; class AppIdentity extends ClientValue { /** * @var string */ public $AppId; /** * @var string */ public $DisplayName; /** * @var string */ public $ServicePrincipalId; /** * @var string */ public $ServicePrincipalName; }
{ "pile_set_name": "Github" }
/* * Copyright (C) 2007 The Android Open Source Project * * 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 com.android.internal.app; import android.app.Activity; import android.content.DialogInterface; import android.os.Bundle; import android.view.KeyEvent; /** * An activity that follows the visual style of an AlertDialog. * * @see #mAlert * @see #mAlertParams * @see #setupAlert() */ public abstract class AlertActivity extends Activity implements DialogInterface { /** * The model for the alert. * * @see #mAlertParams */ protected AlertController mAlert; /** * The parameters for the alert. */ protected AlertController.AlertParams mAlertParams; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAlert = new AlertController(this, this, getWindow()); mAlertParams = new AlertController.AlertParams(this); } public void cancel() { finish(); } public void dismiss() { // This is called after the click, since we finish when handling the // click, don't do that again here. if (!isFinishing()) { finish(); } } /** * Sets up the alert, including applying the parameters to the alert model, * and installing the alert's content. * * @see #mAlert * @see #mAlertParams */ protected void setupAlert() { mAlertParams.apply(mAlert); mAlert.installContent(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (mAlert.onKeyDown(keyCode, event)) return true; return super.onKeyDown(keyCode, event); } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (mAlert.onKeyUp(keyCode, event)) return true; return super.onKeyUp(keyCode, event); } }
{ "pile_set_name": "Github" }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.10"/> <title>0.9.9 API documenation: gtc Directory Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { init_search(); }); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectlogo"><img alt="Logo" src="logo-mini.png"/></td> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">0.9.9 API documenation </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.10 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dir_934f46a345653ef2b3014a1b37a162c1.html">G:</a></li><li class="navelem"><a class="el" href="dir_98f7f9d41f9d3029bd68cf237526a774.html">Source</a></li><li class="navelem"><a class="el" href="dir_9344afb825aed5e2f5be1d2015dde43c.html">G-Truc</a></li><li class="navelem"><a class="el" href="dir_45973f864e07b2505003ae343b7c8af7.html">glm</a></li><li class="navelem"><a class="el" href="dir_304be5dfae1339a7705426c0b536faf2.html">glm</a></li><li class="navelem"><a class="el" href="dir_7997edb062bdde9a99cb6835d42b0d9d.html">gtc</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">gtc Directory Reference</div> </div> </div><!--header--> <div class="contents"> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="files"></a> Files</h2></td></tr> <tr class="memitem:a00009"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00009.html">bitfield.hpp</a> <a href="a00009_source.html">[code]</a></td></tr> <tr class="memdesc:a00009"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00159.html">GLM_GTC_bitfield</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00011"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00011.html">color_encoding.hpp</a> <a href="a00011_source.html">[code]</a></td></tr> <tr class="memdesc:a00011"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00160.html">GLM_GTC_color_encoding</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00012"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00012.html">gtc/color_space.hpp</a> <a href="a00012_source.html">[code]</a></td></tr> <tr class="memdesc:a00012"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00161.html">GLM_GTC_color_space</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00019"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00019.html">constants.hpp</a> <a href="a00019_source.html">[code]</a></td></tr> <tr class="memdesc:a00019"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00162.html">GLM_GTC_constants</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00021"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00021.html">epsilon.hpp</a> <a href="a00021_source.html">[code]</a></td></tr> <tr class="memdesc:a00021"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00163.html">GLM_GTC_epsilon</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00038"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00038.html">functions.hpp</a> <a href="a00038_source.html">[code]</a></td></tr> <tr class="memdesc:a00038"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00164.html">GLM_GTC_functions</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00045"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00045.html">gtc/integer.hpp</a> <a href="a00045_source.html">[code]</a></td></tr> <tr class="memdesc:a00045"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00165.html">GLM_GTC_integer</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00062"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00062.html">matrix_access.hpp</a> <a href="a00062_source.html">[code]</a></td></tr> <tr class="memdesc:a00062"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00166.html">GLM_GTC_matrix_access</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00065"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00065.html">matrix_integer.hpp</a> <a href="a00065_source.html">[code]</a></td></tr> <tr class="memdesc:a00065"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00167.html">GLM_GTC_matrix_integer</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00067"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00067.html">matrix_inverse.hpp</a> <a href="a00067_source.html">[code]</a></td></tr> <tr class="memdesc:a00067"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00168.html">GLM_GTC_matrix_inverse</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00071"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00071.html">matrix_transform.hpp</a> <a href="a00071_source.html">[code]</a></td></tr> <tr class="memdesc:a00071"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00169.html">GLM_GTC_matrix_transform</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00074"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00074.html">noise.hpp</a> <a href="a00074_source.html">[code]</a></td></tr> <tr class="memdesc:a00074"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00170.html">GLM_GTC_noise</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00081"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00081.html">gtc/packing.hpp</a> <a href="a00081_source.html">[code]</a></td></tr> <tr class="memdesc:a00081"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00171.html">GLM_GTC_packing</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00088"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00088.html">gtc/quaternion.hpp</a> <a href="a00088_source.html">[code]</a></td></tr> <tr class="memdesc:a00088"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00172.html">GLM_GTC_quaternion</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00090"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00090.html">random.hpp</a> <a href="a00090_source.html">[code]</a></td></tr> <tr class="memdesc:a00090"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00173.html">GLM_GTC_random</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00093"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00093.html">reciprocal.hpp</a> <a href="a00093_source.html">[code]</a></td></tr> <tr class="memdesc:a00093"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00174.html">GLM_GTC_reciprocal</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00096"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00096.html">round.hpp</a> <a href="a00096_source.html">[code]</a></td></tr> <tr class="memdesc:a00096"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00175.html">GLM_GTC_round</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00106"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00106.html">gtc/type_aligned.hpp</a> <a href="a00106_source.html">[code]</a></td></tr> <tr class="memdesc:a00106"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00176.html">GLM_GTC_type_aligned</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00122"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00122.html">type_precision.hpp</a> <a href="a00122_source.html">[code]</a></td></tr> <tr class="memdesc:a00122"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00177.html">GLM_GTC_type_precision</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00123"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00123.html">type_ptr.hpp</a> <a href="a00123_source.html">[code]</a></td></tr> <tr class="memdesc:a00123"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00178.html">GLM_GTC_type_ptr</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00130"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html">ulp.hpp</a> <a href="a00130_source.html">[code]</a></td></tr> <tr class="memdesc:a00130"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00179.html">GLM_GTC_ulp</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a00131"><td class="memItemLeft" align="right" valign="top">file &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00131.html">vec1.hpp</a> <a href="a00131_source.html">[code]</a></td></tr> <tr class="memdesc:a00131"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="a00180.html">GLM_GTC_vec1</a> <br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr> </table> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.10 </small></address> </body> </html>
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#ff083b6b" /> <stroke android:width="1.0px" android:color="#ff476592" /> </shape>
{ "pile_set_name": "Github" }
// go run mksyscall.go -netbsd -tags netbsd,arm64 syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm64.go // Code generated by the command above; see README.md. DO NOT EDIT. // +build netbsd,arm64 package unix import ( "syscall" "unsafe" ) var _ syscall.Errno // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getgroups(ngid int, gid *_Gid_t) (n int, err error) { r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func setgroups(ngid int, gid *_Gid_t) (err error) { _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) wpid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func socket(domain int, typ int, proto int) (fd int, err error) { r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Shutdown(s int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { var _p0 unsafe.Pointer if len(buf) > 0 { _p0 = unsafe.Pointer(&buf[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func utimes(path string, timeval *[2]Timeval) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func futimes(fd int, timeval *[2]Timeval) (err error) { _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Madvise(b []byte, behav int) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mlock(b []byte) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mlockall(flags int) (err error) { _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mprotect(b []byte, prot int) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Msync(b []byte, flags int) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Munlock(b []byte) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func pipe() (fd1 int, fd2 int, err error) { r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0) fd1 = int(r0) fd2 = int(r1) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { _p0 = unsafe.Pointer(&buf[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getcwd(buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { _p0 = unsafe.Pointer(&buf[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS___GETCWD, uintptr(_p0), uintptr(len(buf)), 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { _p0 = unsafe.Pointer(&mib[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chflags(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chmod(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chroot(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Close(fd int) (err error) { _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Dup(fd int) (nfd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) nfd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Dup2(from int, to int) (err error) { _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Dup3(from int, to int, flags int) (err error) { _, _, e1 := Syscall(SYS_DUP3, uintptr(from), uintptr(to), uintptr(flags)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Exit(code int) { Syscall(SYS_EXIT, uintptr(code), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(attrname) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(attrname) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0)), uintptr(data), uintptr(nbytes), 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(attrname) if err != nil { return } _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FD, uintptr(fd), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p0))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FD, uintptr(fd), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(file) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(attrname) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_GET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(file) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(attrname) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_SET_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(file) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(attrname) if err != nil { return } _, _, e1 := Syscall(SYS_EXTATTR_DELETE_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(file) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_FILE, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(link) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(attrname) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_GET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(link) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(attrname) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_SET_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1)), uintptr(data), uintptr(nbytes), 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(link) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(attrname) if err != nil { return } _, _, e1 := Syscall(SYS_EXTATTR_DELETE_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(unsafe.Pointer(_p1))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) { var _p0 *byte _p0, err = BytePtrFromString(link) if err != nil { return } r0, _, e1 := Syscall6(SYS_EXTATTR_LIST_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(attrnamespace), uintptr(data), uintptr(nbytes), 0, 0) ret = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fadvise(fd int, offset int64, length int64, advice int) (err error) { _, _, e1 := Syscall6(SYS_POSIX_FADVISE, uintptr(fd), 0, uintptr(offset), 0, uintptr(length), uintptr(advice)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchflags(fd int, flags int) (err error) { _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchmod(fd int, mode uint32) (err error) { _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fpathconf(fd int, name int) (val int, err error) { r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) val = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstat(fd int, stat *Stat_t) (err error) { _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstatvfs1(fd int, buf *Statvfs_t, flags int) (err error) { _, _, e1 := Syscall(SYS_FSTATVFS1, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(flags)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fsync(fd int) (err error) { _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Ftruncate(fd int, length int64) (err error) { _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getegid() (egid int) { r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) egid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Geteuid() (uid int) { r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) uid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getgid() (gid int) { r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) gid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpgid(pid int) (pgid int, err error) { r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) pgid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpgrp() (pgrp int) { r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) pgrp = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpid() (pid int) { r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) pid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getppid() (ppid int) { r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) ppid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpriority(which int, who int) (prio int, err error) { r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) prio = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getrusage(who int, rusage *Rusage) (err error) { _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getsid(pid int) (sid int, err error) { r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) sid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Gettimeofday(tv *Timeval) (err error) { _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getuid() (uid int) { r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) uid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Issetugid() (tainted bool) { r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) tainted = bool(r0 != 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Kill(pid int, signum syscall.Signal) (err error) { _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Kqueue() (fd int, err error) { r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Link(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(link) if err != nil { return } _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(link) if err != nil { return } _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Lstat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mkdir(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mkdirat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mkfifoat(dirfd int, path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKFIFOAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mknod(path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Open(path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Pathconf(path string, name int) (val int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) val = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func read(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Readlink(path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 unsafe.Pointer if len(buf) > 0 { _p1 = unsafe.Pointer(&buf[0]) } else { _p1 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 unsafe.Pointer if len(buf) > 0 { _p1 = unsafe.Pointer(&buf[0]) } else { _p1 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(to) if err != nil { return } _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Renameat(fromfd int, from string, tofd int, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(to) if err != nil { return } _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Rmdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0) newoffset = int64(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setegid(egid int) (err error) { _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Seteuid(euid int) (err error) { _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setgid(gid int) (err error) { _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setpgid(pid int, pgid int) (err error) { _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setpriority(which int, who int, prio int) (err error) { _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setregid(rgid int, egid int) (err error) { _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setreuid(ruid int, euid int) (err error) { _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Settimeofday(tp *Timeval) (err error) { _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setuid(uid int) (err error) { _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Stat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Statvfs1(path string, buf *Statvfs_t, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_STATVFS1, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), uintptr(flags)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Symlink(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(link) if err != nil { return } _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(oldpath) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(newpath) if err != nil { return } _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Truncate(path string, length int64) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Umask(newmask int) (oldmask int) { r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) oldmask = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Unlink(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Unlinkat(dirfd int, path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func write(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0) ret = uintptr(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func munmap(addr uintptr, length uintptr) (err error) { _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func readlen(fd int, buf *byte, nbuf int) (n int, err error) { r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func writelen(fd int, buf *byte, nbuf int) (n int, err error) { r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return }
{ "pile_set_name": "Github" }
name: "springmeetup" url: "https://www.meetup.com/Istanbul-Spring-Meetup/"
{ "pile_set_name": "Github" }
// // Created by ljc on 17-6-28. // #ifndef __MEMPROTECT_H #define __MEMPROTECT_H #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <ctype.h> #include <assert.h> #include <limits.h> #include <malloc.h> #include <sys/types.h> #include <sys/mman.h> #include <unistd.h> #include <assert.h> #include "sds.h" #include "sdsalloc.h" #define PAGE_SIZE (sysconf(_SC_PAGESIZE)) int protectMemWrite(void *p, int len); int protectMemAccess(void *p, int len); int unprotectMemAccess(void *p, int len); #endif // __MEMPROTECT_H
{ "pile_set_name": "Github" }
/* * 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. */ /* * This code was generated by https://github.com/googleapis/google-api-java-client-services/ * Modify at your own risk. */ package com.google.api.services.androiddeviceprovisioning.v1.model; /** * Tracks the status of a long-running operation to asynchronously update a batch of reseller * metadata attached to devices. To learn more, read [Long‑running batch operations](/zero- * touch/guides/how-it-works#operations). * * <p> This is the Java data model class that specifies how to parse/serialize into the JSON that is * transmitted over HTTP when working with the Android Device Provisioning Partner API. For a * detailed explanation see: * <a href="https://developers.google.com/api-client-library/java/google-http-java-client/json">https://developers.google.com/api-client-library/java/google-http-java-client/json</a> * </p> * * @author Google, Inc. */ @SuppressWarnings("javadoc") public final class DevicesLongRunningOperationMetadata extends com.google.api.client.json.GenericJson { /** * The number of metadata updates in the operation. This might be different from the number of * updates in the request if the API can't parse some of the updates. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Integer devicesCount; /** * The processing status of the operation. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.String processingStatus; /** * The processing progress of the operation. Measured as a number from 0 to 100. A value of 10O * doesnt always mean the operation completed—check for the inclusion of a `done` field. * The value may be {@code null}. */ @com.google.api.client.util.Key private java.lang.Integer progress; /** * The number of metadata updates in the operation. This might be different from the number of * updates in the request if the API can't parse some of the updates. * @return value or {@code null} for none */ public java.lang.Integer getDevicesCount() { return devicesCount; } /** * The number of metadata updates in the operation. This might be different from the number of * updates in the request if the API can't parse some of the updates. * @param devicesCount devicesCount or {@code null} for none */ public DevicesLongRunningOperationMetadata setDevicesCount(java.lang.Integer devicesCount) { this.devicesCount = devicesCount; return this; } /** * The processing status of the operation. * @return value or {@code null} for none */ public java.lang.String getProcessingStatus() { return processingStatus; } /** * The processing status of the operation. * @param processingStatus processingStatus or {@code null} for none */ public DevicesLongRunningOperationMetadata setProcessingStatus(java.lang.String processingStatus) { this.processingStatus = processingStatus; return this; } /** * The processing progress of the operation. Measured as a number from 0 to 100. A value of 10O * doesnt always mean the operation completed—check for the inclusion of a `done` field. * @return value or {@code null} for none */ public java.lang.Integer getProgress() { return progress; } /** * The processing progress of the operation. Measured as a number from 0 to 100. A value of 10O * doesnt always mean the operation completed—check for the inclusion of a `done` field. * @param progress progress or {@code null} for none */ public DevicesLongRunningOperationMetadata setProgress(java.lang.Integer progress) { this.progress = progress; return this; } @Override public DevicesLongRunningOperationMetadata set(String fieldName, Object value) { return (DevicesLongRunningOperationMetadata) super.set(fieldName, value); } @Override public DevicesLongRunningOperationMetadata clone() { return (DevicesLongRunningOperationMetadata) super.clone(); } }
{ "pile_set_name": "Github" }
<?php namespace Symfony\Component\Routing\Tests\Matcher\Dumper; use PHPUnit\Framework\TestCase; use Symfony\Component\Routing\Matcher\Dumper\StaticPrefixCollection; use Symfony\Component\Routing\Route; class StaticPrefixCollectionTest extends TestCase { /** * @dataProvider routeProvider */ public function testGrouping(array $routes, $expected) { $collection = new StaticPrefixCollection('/'); foreach ($routes as $route) { list($path, $name) = $route; $staticPrefix = (new Route($path))->compile()->getStaticPrefix(); $collection->addRoute($staticPrefix, [$name]); } $dumped = $this->dumpCollection($collection); $this->assertEquals($expected, $dumped); } public function routeProvider() { return [ 'Simple - not nested' => [ [ ['/', 'root'], ['/prefix/segment/', 'prefix_segment'], ['/leading/segment/', 'leading_segment'], ], <<<EOF root prefix_segment leading_segment EOF ], 'Nested - small group' => [ [ ['/', 'root'], ['/prefix/segment/aa', 'prefix_segment'], ['/prefix/segment/bb', 'leading_segment'], ], <<<EOF root /prefix/segment/ -> prefix_segment -> leading_segment EOF ], 'Nested - contains item at intersection' => [ [ ['/', 'root'], ['/prefix/segment/', 'prefix_segment'], ['/prefix/segment/bb', 'leading_segment'], ], <<<EOF root /prefix/segment/ -> prefix_segment -> leading_segment EOF ], 'Simple one level nesting' => [ [ ['/', 'root'], ['/group/segment/', 'nested_segment'], ['/group/thing/', 'some_segment'], ['/group/other/', 'other_segment'], ], <<<EOF root /group/ -> nested_segment -> some_segment -> other_segment EOF ], 'Retain matching order with groups' => [ [ ['/group/aa/', 'aa'], ['/group/bb/', 'bb'], ['/group/cc/', 'cc'], ['/(.*)', 'root'], ['/group/dd/', 'dd'], ['/group/ee/', 'ee'], ['/group/ff/', 'ff'], ], <<<EOF /group/ -> aa -> bb -> cc root /group/ -> dd -> ee -> ff EOF ], 'Retain complex matching order with groups at base' => [ [ ['/aaa/111/', 'first_aaa'], ['/prefixed/group/aa/', 'aa'], ['/prefixed/group/bb/', 'bb'], ['/prefixed/group/cc/', 'cc'], ['/prefixed/(.*)', 'root'], ['/prefixed/group/dd/', 'dd'], ['/prefixed/group/ee/', 'ee'], ['/prefixed/', 'parent'], ['/prefixed/group/ff/', 'ff'], ['/aaa/222/', 'second_aaa'], ['/aaa/333/', 'third_aaa'], ], <<<EOF /aaa/ -> first_aaa -> second_aaa -> third_aaa /prefixed/ -> /prefixed/group/ -> -> aa -> -> bb -> -> cc -> root -> /prefixed/group/ -> -> dd -> -> ee -> -> ff -> parent EOF ], 'Group regardless of segments' => [ [ ['/aaa-111/', 'a1'], ['/aaa-222/', 'a2'], ['/aaa-333/', 'a3'], ['/group-aa/', 'g1'], ['/group-bb/', 'g2'], ['/group-cc/', 'g3'], ], <<<EOF /aaa- -> a1 -> a2 -> a3 /group- -> g1 -> g2 -> g3 EOF ], ]; } private function dumpCollection(StaticPrefixCollection $collection, $prefix = '') { $lines = []; foreach ($collection->getRoutes() as $item) { if ($item instanceof StaticPrefixCollection) { $lines[] = $prefix.$item->getPrefix(); $lines[] = $this->dumpCollection($item, $prefix.'-> '); } else { $lines[] = $prefix.implode(' ', $item); } } return implode("\n", $lines); } }
{ "pile_set_name": "Github" }
/*----------------------------------------------------------------------------- * Copyright (C) 2010-2014 ARM Limited. All rights reserved. * * $Date: 12. March 2014 * $Revision: V1.4.4 * * Project: CMSIS DSP Library * Title: arm_biquad_cascade_df1_init_q15.c * * Description: Q15 Biquad cascade DirectFormI(DF1) filter initialization function. * * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * - Neither the name of ARM LIMITED nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ---------------------------------------------------------------------------*/ #include "arm_math.h" /** * @ingroup groupFilters */ /** * @addtogroup BiquadCascadeDF1 * @{ */ /** * @details * * @param[in,out] *S points to an instance of the Q15 Biquad cascade structure. * @param[in] numStages number of 2nd order stages in the filter. * @param[in] *pCoeffs points to the filter coefficients. * @param[in] *pState points to the state buffer. * @param[in] postShift Shift to be applied to the accumulator result. Varies according to the coefficients format * @return none * * <b>Coefficient and State Ordering:</b> * * \par * The coefficients are stored in the array <code>pCoeffs</code> in the following order: * <pre> * {b10, 0, b11, b12, a11, a12, b20, 0, b21, b22, a21, a22, ...} * </pre> * where <code>b1x</code> and <code>a1x</code> are the coefficients for the first stage, * <code>b2x</code> and <code>a2x</code> are the coefficients for the second stage, * and so on. The <code>pCoeffs</code> array contains a total of <code>6*numStages</code> values. * The zero coefficient between <code>b1</code> and <code>b2</code> facilities use of 16-bit SIMD instructions on the Cortex-M4. * * \par * The state variables are stored in the array <code>pState</code>. * Each Biquad stage has 4 state variables <code>x[n-1], x[n-2], y[n-1],</code> and <code>y[n-2]</code>. * The state variables are arranged in the <code>pState</code> array as: * <pre> * {x[n-1], x[n-2], y[n-1], y[n-2]} * </pre> * The 4 state variables for stage 1 are first, then the 4 state variables for stage 2, and so on. * The state array has a total length of <code>4*numStages</code> values. * The state variables are updated after each block of data is processed; the coefficients are untouched. */ void arm_biquad_cascade_df1_init_q15( arm_biquad_casd_df1_inst_q15 * S, uint8_t numStages, q15_t * pCoeffs, q15_t * pState, int8_t postShift) { /* Assign filter stages */ S->numStages = numStages; /* Assign postShift to be applied to the output */ S->postShift = postShift; /* Assign coefficient pointer */ S->pCoeffs = pCoeffs; /* Clear state buffer and size is always 4 * numStages */ memset(pState, 0, (4u * (uint32_t) numStages) * sizeof(q15_t)); /* Assign state pointer */ S->pState = pState; } /** * @} end of BiquadCascadeDF1 group */
{ "pile_set_name": "Github" }
/* SPDX-License-Identifier: MIT */ /* * Copyright © 2019 Intel Corporation */ #ifndef __INTEL_FBDEV_H__ #define __INTEL_FBDEV_H__ #include <linux/types.h> struct drm_device; struct drm_i915_private; #ifdef CONFIG_DRM_FBDEV_EMULATION int intel_fbdev_init(struct drm_device *dev); void intel_fbdev_initial_config_async(struct drm_device *dev); void intel_fbdev_unregister(struct drm_i915_private *dev_priv); void intel_fbdev_fini(struct drm_i915_private *dev_priv); void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous); void intel_fbdev_output_poll_changed(struct drm_device *dev); void intel_fbdev_restore_mode(struct drm_device *dev); #else static inline int intel_fbdev_init(struct drm_device *dev) { return 0; } static inline void intel_fbdev_initial_config_async(struct drm_device *dev) { } static inline void intel_fbdev_unregister(struct drm_i915_private *dev_priv) { } static inline void intel_fbdev_fini(struct drm_i915_private *dev_priv) { } static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous) { } static inline void intel_fbdev_output_poll_changed(struct drm_device *dev) { } static inline void intel_fbdev_restore_mode(struct drm_device *dev) { } #endif #endif /* __INTEL_FBDEV_H__ */
{ "pile_set_name": "Github" }
fileFormatVersion: 2 guid: 75c3f3639dfe941889a7e6c0ebd79e22 folderAsset: yes DefaultImporter: externalObjects: {} userData: assetBundleName: assetBundleVariant:
{ "pile_set_name": "Github" }
/** * The Seeks proxy and plugin framework are part of the SEEKS project. * Copyright (C) 2011 Emmanuel Benazera, ebenazer@seeks-project.info * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * \brief cr_store is a record store in which items are put from a * cr_store object. Item removal however is automatic. Every time * a cached_record is deleted, its removal trickles up the chain * and frees cr_cache entries as needed. * * Adding an item to the cr_store registers a cached_record object * with the Seeks' proxy sweeper. When a cached_record object times * out, the sweeper deletes it, triggering the deletion chain. */ #ifndef CR_STORE_H #define CR_STORE_H #include "stl_hash.h" #include "sweeper.h" #include "db_record.h" #include "mutexes.h" using sp::sweepable; using sp::db_record; namespace seeks_plugins { class cr_cache; class cr_store; class cached_record : public sweepable { public: cached_record(const std::string &key, db_record *rec, cr_cache *cache); virtual ~cached_record(); virtual bool sweep_me(); void update_last_use(); std::string _key; db_record *_rec; time_t _last_use; private: cr_cache *_cache; }; class cr_cache { public: cr_cache(const std::string &peer, cr_store *store); ~cr_cache(); void add(const std::string &key, db_record *rec); void remove(const std::string &key); cached_record *find(const std::string &key); std::string _peer; hash_map<const char*,cached_record*,hash<const char*>,eqstr> _records; private: cr_store *_store; sp_mutex_t _cache_mutex; }; class cr_store { public: cr_store(); ~cr_store(); void add(const std::string &host, const int &port, const std::string &path, const std::string &key, db_record *rec); void add(const std::string &peer, const std::string &key, db_record *rec); void remove(const std::string &host, const int &port, const std::string &path); void remove(const std::string &peer); db_record* find(const std::string &host, const int &port, const std::string &path, const std::string &key, bool &has_key); db_record* find(const std::string &peer, const std::string &key, bool &has_key); static std::string generate_peer(const std::string &host, const int &port, const std::string &path=""); hash_map<const char*,cr_cache*,hash<const char*>,eqstr> _store; private: sp_mutex_t _store_mutex; }; } /* end of namespace. */ #endif
{ "pile_set_name": "Github" }
- activity_section(activity) do |title| %p= title.html_safe
{ "pile_set_name": "Github" }
TEST_PROGS := dscr_default_test dscr_explicit_test dscr_user_test \ dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test \ dscr_sysfs_thread_test dscr_default_test: LDLIBS += -lpthread all: $(TEST_PROGS) $(TEST_PROGS): ../harness.c include ../../lib.mk clean: rm -f $(TEST_PROGS) *.o
{ "pile_set_name": "Github" }
/* * Copyright (C) 2010 The Android Open Source Project * * 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 libcore.java.io; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import junit.framework.TestCase; public final class RandomAccessFileTest extends TestCase { // http://b/3015023 public void testRandomAccessFileHasCleanupFinalizer() throws IOException { int tooManyOpenFiles = 2000; File file = File.createTempFile("RandomAccessFileTest", "tmp"); for (int i = 0; i < tooManyOpenFiles; i++) { new RandomAccessFile(file, "rw"); System.gc(); System.runFinalization(); } } }
{ "pile_set_name": "Github" }
{{#if (has-block)}} {{yield}} {{else}} <div class="globalSearch"> {{#if this.themeInstance.searchLabelMsg}} <label for={{this.inputId}}>{{this.themeInstance.searchLabelMsg}}</label> {{/if}} <Input id={{this.inputId}} class={{concat this.themeInstance.input " filterString"}} @value={{this.value}} @placeholder={{this.themeInstance.searchPlaceholderMsg}} @oninput={{this.updateGlobalFilterString}}/> <button type="button" class="clearFilterIcon" disabled={{unless this.globalFilterUsed "disabled"}} onClick={{fn this.clearGlobalFilter}}> <i class={{this.themeInstance.clearFilterIcon}}></i> <span class="emt-sr-only">{{this.themeInstance.clearGlobalFilterMsg}}</span> </button> </div> {{/if}}
{ "pile_set_name": "Github" }