text
stringlengths
2
100k
meta
dict
package com.infinityraider.agricraft.api.v1.items; /** * Marker interface for objects that may be used as a rake. */ public interface IAgriRakeItem extends IAgriCraftItem { }
{ "pile_set_name": "Github" }
**To retrieve the analytics configuration for a bucket with a specific ID** The following ``get-bucket-analytics-configuration`` example displays the analytics configuration for the specified bucket and ID. :: aws s3api get-bucket-analytics-configuration \ --bucket my-bucket \ --id 1 Output:: { "AnalyticsConfiguration": { "StorageClassAnalysis": {}, "Id": "1" } }
{ "pile_set_name": "Github" }
; <<>> DiG 9.9.5-3ubuntu0.8-Ubuntu <<>> AXFR pg. @ns1.unitech.ac.pg. +nocomments +nocmd +noquestion +nostats +time=15 ;; global options: +cmd ; Transfer failed.
{ "pile_set_name": "Github" }
// Extra test date for CS3013.cs using System; public class CLSClass { }
{ "pile_set_name": "Github" }
# Makefile.plg.in -- default rules for plugins -*- makefile -*- # # Copyright (C) 1996-2004 by Ian Piumarta and other authors/contributors # listed elsewhere in this file. # All rights reserved. # # This file is part of Unix Squeak. # # 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. # # Author: [email protected] # # Last edited: 2006-10-18 10:13:37 by piumarta on emilia.local [make_cfg] [make_plg] XINCLUDES = [includes] OBJS = [targets] TARGET = [target] PLIBS = [plibs] [make_inc] $(TARGET) : $(OBJS) Makefile $(LINK) $(TARGET) $(OBJS) $(PLIBS) $(RANLIB) $(TARGET) [make_targets] .force :
{ "pile_set_name": "Github" }
/** * * WARNING! This file was autogenerated by: * _ _ _ _ __ __ * | | | | | | |\ \ / / * | | | | |_| | \ V / * | | | | _ | / \ * | |_| | | | |/ /^\ \ * \___/\_| |_/\/ \/ * * This file was autogenerated by UnrealHxGenerator using UHT definitions. * It only includes UPROPERTYs and UFUNCTIONs. Do not modify it! * In order to add more definitions, create or edit a type with the same name/package, but with an `_Extra` suffix **/ package unreal.umgeditor; @:umodule("UMGEditor") @:glueCppIncludes("Public/WidgetBlueprint.h") @:uextern @:ustruct extern class FDelegateEditorBinding { @:uproperty public var Kind : unreal.umg.EBindingKind; /** If it's an actual Function Graph in the blueprint that we're bound to, there's a GUID we can use to lookup that function, to deal with renames better. This is that GUID. **/ @:uproperty public var MemberGuid : unreal.FGuid; @:uproperty public var SourcePath : unreal.umgeditor.FEditorPropertyPath; /** The property we are bindings to directly on the source object. **/ @:uproperty public var SourceProperty : unreal.FName; /** The function that was generated to return the SourceProperty **/ @:uproperty public var FunctionName : unreal.FName; /** The property on the ObjectName that we are binding to. **/ @:uproperty public var PropertyName : unreal.FName; /** The member widget the binding is on, must be a direct variable of the UUserWidget. **/ @:uproperty public var ObjectName : unreal.FString; }
{ "pile_set_name": "Github" }
package com.tencent.mm.plugin.card.ui; import android.content.Context; import android.database.Cursor; import android.view.View; import android.view.ViewGroup; import com.tencent.mm.plugin.card.model.CardInfo; import com.tencent.mm.plugin.card.model.ab; import com.tencent.mm.sdk.platformtools.v; import com.tencent.mm.ui.i; public final class b extends i<CardInfo> implements l { private final String TAG = "MicroMsg.CardAdapter"; private boolean cMB = true; com.tencent.mm.plugin.card.base.c cPN; private int cRz; private int count = 0; public b(Context paramContext, int paramInt) { super(paramContext, new CardInfo()); cRz = paramInt; setCacheEnable(true); cPN = new j(paramContext, this); } public final void GH() { v.v("MicroMsg.CardAdapter", "resetCursor"); Cursor localCursor = ab.No().gd(cRz); if (localCursor != null) { count = localCursor.getCount(); v.v("MicroMsg.CardAdapter", "card count:" + count); } setCursor(localCursor); notifyDataSetChanged(); } protected final void GI() { closeCursor(); GH(); } public final void bl(boolean paramBoolean) { cMB = paramBoolean; } public final View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { paramViewGroup = (CardInfo)getItem(paramInt); cMB = cMB; return cPN.a(paramInt, paramView, paramViewGroup); } } /* Location: * Qualified Name: com.tencent.mm.plugin.card.ui.b * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */
{ "pile_set_name": "Github" }
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <Notes/ICNFMCByteSet.h> @interface ICNFMCMutableByteSet : ICNFMCByteSet { } - (void)invert; - (void)removeBytesInRange:(struct _NSRange)arg1; - (void)addBytesInRange:(struct _NSRange)arg1; - (id)copyWithZone:(struct _NSZone *)arg1; @end
{ "pile_set_name": "Github" }
/*! \file Module.h \author Andrew Kerr <[email protected]> \date Jan 15, 2009 \brief declares a Module loadable from a PTX source file */ #ifndef IR_MODULE_H_INCLUDED #define IR_MODULE_H_INCLUDED #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <ocelot/ir/interface/PTXEmitter.h> #include <ocelot/ir/interface/Texture.h> #include <ocelot/ir/interface/Instruction.h> #include <ocelot/ir/interface/PTXKernel.h> #include <ocelot/ir/interface/PTXStatement.h> #include <ocelot/ir/interface/Global.h> namespace executive { class Executive; } namespace ir { class Module { public: /*! \brief Map from texture variable names to objects */ typedef std::map< std::string, Texture > TextureMap; /*! \brief Typedef for a vector of PTXStatements */ typedef std::vector< PTXStatement > StatementVector; typedef std::unordered_map< std::string, PTXKernel* > KernelMap; typedef std::vector< PTXKernel* > KernelVector; /*! \brief Map from unique identifier to global variable */ typedef std::unordered_map< std::string, Global > GlobalMap; /*! \brief map from unique identifier to function prototype */ typedef std::unordered_map< std::string, ir::PTXKernel::Prototype > FunctionPrototypeMap; public: /*! Given a path to a PTX source file, construct the Module, load and parse the PTX file, and extract kernels into Kernel objects */ Module(const std::string& path, bool dontLoad = false); /*! Given a stream constaining a PTX file, parse the PTX file, and extract kernels into Kernel objects */ Module(std::istream& source, const std::string& path = "::unknown path::"); /*! Construct a Module from a name and a vector of PTXStatements */ Module(const std::string& , const StatementVector&); /*! Construct an empty module */ Module(); /*! Construct a module from an existing one */ Module(const Module& m); /*! \brief copy a module */ const Module& operator=(const Module& m); /*! Deconstruct a module */ ~Module(); /*! Write the module to an assembly file using statements */ void write(std::ostream& stream) const; /*! \brief Write the module to an assembly file from the IR */ void writeIR(std::ostream& stream, PTXEmitter::Target emitterTarget = PTXEmitter::Target_OcelotIR) const; /*! \brief Write the module to a string from the IR */ std::string toString(PTXEmitter::Target emitterTarget = PTXEmitter::Target_OcelotIR) const; /*! Deletes everything associated with this particular module */ void unload(); /*! Unloads module and indicates that the empty module is loaded */ void isLoaded(); /*! Unloads module and loads PTX source file in given path */ bool load(const std::string& path); /*! Unloads module and loads PTX source file in given stream */ bool load(std::istream& source, const std::string& path = "::unknown path::"); /*! Unloads module and loads PTX source string via a destructive copy */ bool lazyLoad(std::string& source, const std::string& path = "::unknown path::"); /*! Unloads module and loads PTX source, this pointer must be valid until the module is loaded */ bool lazyLoad(const char* source, const std::string& path = "::unknown path::"); /*! \brief Load the module if it has not already been loaded */ void loadNow(); /*! \brief Is the module loaded? */ bool loaded() const; /*! \brief Gets a kernel instance by name. \param name [mangled] name of kernel \return pointer to kernel instance with (name) or 0 if kernel does not exist */ PTXKernel* getKernel(const std::string& name); /*! \brief Gets a kernel instance by name. \param name [mangled] name of kernel \return const pointer to kernel instance with (name) or 0 if kernel does not exist */ const PTXKernel* getKernel(const std::string& name) const; /*! \brief Removes an existing kernel by name. \param name [mangled] name of kernel */ void removeKernel(const std::string& name); /*! \brief Adds a new kernel. \param kernel The kernel being inserted, it will be owned by the module. \return A pointer to the newly inserted kernel. */ PTXKernel* insertKernel(PTXKernel* kernel); /*! \brief Gets a texture instance by name. \param name [mangled] name of texture \return pointer to texture instance with (name) or 0 if it does not exist */ Texture* getTexture(const std::string& name); /*! \brief Insert a texture into the module. \param texture the texture being inserted, it will be owned by the module. \return pointer to texture instance being inserted */ Texture* insertTexture(const Texture& texture); void removeTexture(const std::string& name); /*! \brief Gets a global instance by name. \param name [mangled] name of global \return pointer to global instance with (name) or 0 if it does not exist */ Global* getGlobal(const std::string& name); /*! \brief Gets a global instance by name. \param name [mangled] name of global \return pointer to global instance with (name) or 0 if it does not exist */ const Global* getGlobal(const std::string& name) const; /*! \brief Insert a global into the module. \param global the global being inserted, it will be owned by the module. \return pointer to global instance being inserted */ Global* insertGlobal(const Global& global); void removeGlobal(const std::string& name); void insertGlobalAsStatement(const PTXStatement &statement); /*! \brief Gets the module path */ const std::string& path() const; /*! \brief Gets the kernel map */ const KernelMap& kernels() const; /*! \brief Gets the global map */ const GlobalMap& globals() const; /*! \brief Gets the texture map */ const TextureMap& textures() const; /*! \brief Gets the statement vector */ const StatementVector& statements() const; /*! \brief gets all declared function prototypes */ const FunctionPrototypeMap& prototypes() const; /*! \brief get the address size */ unsigned int addressSize() const; void addPrototype(const std::string &identifier, const ir::PTXKernel::Prototype &prototype); void removePrototype(const std::string& identifier); /*! \brief Set the PTX version of the module */ void setVersion(unsigned int major, unsigned int minor); ir::PTXStatement version() const; ir::PTXStatement target() const; private: /*! After a successful parse; constructs all kernels for PTX isa. */ void extractPTXKernels(); private: /*! \brief This is a copy of the original ptx source for lazy loading */ std::string _ptx; /*! \brief This is a pointer to the original ptx source for lazy loading */ const char* _ptxPointer; /*! Set of PTX statements loaded from PTX source file. This must not change after parsing, as all kernels have const_iterators into this vector. */ StatementVector _statements; /*! \brief maps declared function name onto a prototype structure */ FunctionPrototypeMap _prototypes; /*! Set of kernels belonging to Module. These are PTX Kernels */ KernelMap _kernels; /*! Set of textures in the module */ TextureMap _textures; /*! Set of global variables in the modules */ GlobalMap _globals; /*! Path from which Module was loaded */ std::string _modulePath; /*! Target statment */ PTXStatement _target; /*! \brief Version statment */ PTXStatement _version; /*! \brief The address size */ unsigned int _addressSize; /*! Is the module currently loaded? */ bool _loaded; friend class executive::Executive; }; } #endif
{ "pile_set_name": "Github" }
--- title: Jest+Enzyme进行react项目测试 date: 2018-08-01 20:18:06 tags: - react - jest - enzyme - test --- ## 前言 [Jest](https://facebook.github.io/jest/) 是 Facebook 开发的一个测试框架,它集成了测试执行器、断言库、spy、mock、snapshot和测试覆盖率报告等功能。React项目本身也是使用Jest进行单测的,因此它们俩的契合度相当高。 [Enzyme](http://airbnb.io/enzyme/) 是由 airbnb 开发的React单测工具。它扩展了React的TestUtils并通过支持类似jQuery的find语法可以很方便的对render出来的结果做各种断言。 Jest+Enzyme是目前比较流行的React项目单测组合。 ## 安装与配置 ``` npm install --save-dev jest jest-cli enzyme ``` 在package.json中添加jest命令,并指定配置文件.jest.js ``` scripts: { "test": "jest --config .jest.js" } ``` 在项目根目录新建配置文件.jest.js,如下 ```js module.exports = { setupFiles: [ './tests/setup.js', // 测试启动文件 ], testURL: 'http://localhost', // 测试环境URL testEnvironment: 'jsdom', // 测试环境 moduleFileExtensions: ['js', 'jsx'], // 单元测试文件检测后缀名 testPathIgnorePatterns: ['/node_modules/'], moduleNameMapper: { // mock模块 "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/__mocks__/fileMock.js", "\\.(css|less)$": "<rootDir>/tests/__mocks__/cssMock.js" }, transformIgnorePatterns: [ // 不转化es6的文件夹匹配 'node_modules\/[^/]+?\/(?!(es|node_modules)\/)', // Ignore modules without es dir ] }; ``` 由配置文件的testEnvironment可以看到,测试环境使用的是`jsdom`,jsdom 为许多 WEB标准的 JavaScript 实现,它主要是为了在服务器端模拟足够的Web浏览器子集,以便进行自动化测试。 由于jest默认不支持es6和jsx语法,我们需要通过babel对其进行转化,在项目根目录新建.babelrc文件: ```json { "env": { "test": { "presets": ["es2015", "react", "stage-2"] } } } ``` 对于测试环境来说,一些模块我们不需要进行处理,比如图片模块、样式模块,我们需要把这些模块mock掉,通过moduleNameMapper配置,把指定文件后缀的模块使用自定义文件mock掉,如图片模块,我们新建/tests/\_\_mock__/fileMock.js文件: ``` module.exports = {} ``` 导出一个空对象来mock图片文件。 对于一些css、less等文件,可能涉及到一些css-module的内容,可能引入的模块里包含了css中:export导出的内容,如classPrefix,这个时候如果导出空对象可能会影响测试的结果,我们这里针对项目导出写死的内容,/tests/\_\_mock__/cssMock.js如下: ```js module.exports = { prefix: "test", switchPrefix: "test-switch", btnPrefix: "test-btn", inputPrefix: "test-input" } ``` 这个时候当我们导入css模块时候,我们可以模拟到css-module的功能,使用s.prefix取到test字符串。 接下来新建启动文件/tests/setup.js ```js import { JSDOM } from 'jsdom'; // fixed jsdom miss if (typeof window !== 'undefined') { const documentHTML = '<!doctype html><html><body</body></html>'; global.document = new JSDOM(documentHTML); // 模拟 document 对象 global.window = document.parentWindow; // 模拟 window 对象 } global.requestAnimationFrame = global.requestAnimationFrame || function (cb) { // 处理兼容 添加 requestAnimationFrame 动画函数 return setTimeout(cb, 0); }; const Enzyme = require('enzyme'); const Adapter = require('enzyme-adapter-react-16'); Enzyme.configure({ adapter: new Adapter() }); // 为 enzyme 添加适配器,针对不同的react版本使用不同的适配器 ``` ## 编写单元测试 默认情况下,jest会检测`__tests__`文件下的所有`.js`和`.jsx`后缀以及项目中`.test.js`和`.spec.js`后缀(包括jsx)的文件,以标记这些文件为单元测试文件。 以antd为例,新建一个button.test.js文件: ```js import React, { Component } from 'react'; import { render, mount } from 'enzyme'; import { Button } from 'antd'; describe('Button', () => { it('按钮测试', () => { const wrapper = render( <Button>测试</Button> ); expect(wrapper).toMatchSnapshot(); }); it('测试加载中', () => { class DefaultButton extends Component { state = { loading: false, }; enterLoading = () => { this.setState({ loading: true }); } render() { return <Button loading={this.state.loading} onClick={this.enterLoading}>Button</Button>; } } const wrapper = mount( <DefaultButton /> ); wrapper.simulate('click'); expect(wrapper.find('.ant-btn-loading').length).toBe(1); }); }) ``` `toMatchSnapshot`方法会测试两次单测渲染的结果是否一致。 执行命令 `npm run test`,结果如下: ![运行结果](../images/Jest+Enzyme进行react项目测试/1.jpg) enzyme提供了三种渲染方式,`render`、`mount`、`shallow`,分别存在以下区别: * `render`采用的是第三方库Cheerio的渲染,渲染结果是普通的html结构,对于snapshot使用render比较合适。 * `shallow`和`mount`对组件的渲染结果不是html的dom树,而是react树,如果你chrome装了react devtool插件,他的渲染结果就是react devtool tab下查看的组件结构,而render函数的结果是element tab下查看的结果。 * `shallow`和`mount`的结果是个被封装的`ReactWrapper`,可以进行多种操作,譬如`find()、parents()、children()`等选择器进行元素查找;`state()`、`props()`进行数据查找,setState()、setprops()操作数据;simulate()模拟事件触发。 * `shallow`只渲染当前组件,只能能对当前组件做断言;`mount`会渲染当前组件以及所有子组件,对所有子组件也可以做上述操作。一般交互测试都会关心到子组件,我使用的都是mount。但是mount耗时更长,内存啥的也都占用的更多,如果没必要操作和断言子组件,可以使用shallow。 enzyme还提供了`simulate()`接口模拟事件,实际上simulate是通过触发事件绑定函数,来模拟事件的触发。触发事件后,去判断props上特定函数是否被调用,传参是否正确;组件状态是否发生预料之中的修改;某个dom节点是否存在是否符合期望。 ## WebStorm集成jest进行单测调试 自 WebStorm 2017.3之后的版本(之前几个版本也有,但是不知道怎么试都不行),WebStorm也提供了jest的单元测试环境,下面结合我们前面的项目进行配置: 打开debug配置窗口,在defaults里面找到jest,修改jest的全局配置,选择jest配置文件,如下: ![jest配置](../images/Jest+Enzyme进行react项目测试/2.png) 选择完后点击确定,然后找到对应的单元测试文件,点击左边的运行键,如下: ![运行单测](../images/Jest+Enzyme进行react项目测试/3.png) 选择 Debug 即可在对应的位置打断点进行调试。 ## 总结 单元测试的目的是为了检测一段代码在特定条件下某个特定的函数行为,对程序员来说,单元测试还是很必要的存在,因为测试人员不会完全把bug测出来,这个时候为了更好的发现bug,我们就需要单元测试来保证测试的全面性。 上面项目 [github传送门](https://github.com/yacan8/jest-enzyme)。
{ "pile_set_name": "Github" }
/* * Copyright (C) 2014 Divide.io * * 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 io.divide.otto; import io.divide.shared.event.Event; import io.divide.shared.event.Subscriber; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class SubscriberHandlerFinder implements HandlerFinder { private static final Map<Class<?>, Map<Class<?>, Method>> PRODUCERS_CACHE = new HashMap<Class<?>, Map<Class<?>, Method>>(); /** Cache event bus subscriber methods for each class. */ private static final Map<Class<?>, Map<Class<?>, Set<Method>>> SUBSCRIBERS_CACHE = new HashMap<Class<?>, Map<Class<?>, Set<Method>>>(); @Override public Map<Class<?>, EventProducer> findAllProducers(Object listener) { final Class<?> listenerClass = listener.getClass(); Map<Class<?>, EventProducer> handlersInMethod = new HashMap<Class<?>, EventProducer>(); if (!PRODUCERS_CACHE.containsKey(listenerClass)) { loadProducers(listenerClass); } Map<Class<?>, Method> methods = PRODUCERS_CACHE.get(listenerClass); if (!methods.isEmpty()) { for (Map.Entry<Class<?>, Method> e : methods.entrySet()) { EventProducer producer = new EventProducer(listener, e.getValue()); handlersInMethod.put(e.getKey(), producer); } } return handlersInMethod; } @Override public Map<Class<?>, Set<EventHandler>> findAllSubscribers(Object listener) { Class<?> listenerClass = listener.getClass(); Map<Class<?>, Set<EventHandler>> handlersInMethod = new HashMap<Class<?>, Set<EventHandler>>(); if (!SUBSCRIBERS_CACHE.containsKey(listenerClass)) { loadSubscribers(listenerClass); } Map<Class<?>, Set<Method>> methods = SUBSCRIBERS_CACHE.get(listenerClass); if (!methods.isEmpty()) { for (Map.Entry<Class<?>, Set<Method>> e : methods.entrySet()) { Set<EventHandler> handlers = new HashSet<EventHandler>(); for (Method m : e.getValue()) { handlers.add(new EventHandler(listener, m)); } handlersInMethod.put(e.getKey(), handlers); } } return handlersInMethod; } private static boolean isSubscriberMethod(Method m){ if(!m.getName().equals("onEvent"))return false; Class param = m.getParameterTypes()[0]; if(!Event.class.isAssignableFrom(param) || param.equals(Event.class))return false; return true; } private static boolean isSubscriberClass(Class clazz){ if(clazz.equals(Subscriber.class) || Subscriber.class.isAssignableFrom(clazz))return true; return false; } private static void loadSubscribers(Class<?> listenerClass) { Map<Class<?>, Set<Method>> subscriberMethods = new HashMap<Class<?>, Set<Method>>(); if(!isSubscriberClass(listenerClass))return; // no need checking this for each method... for (Method method : listenerClass.getDeclaredMethods()) { if (isSubscriberMethod(method)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 1) { throw new IllegalArgumentException("Method " + method + " has @Subscribe annotation but requires " + parameterTypes.length + " arguments. Methods must require a single argument."); } Class<?> eventType = parameterTypes[0]; if (eventType.isInterface()) { throw new IllegalArgumentException("Method " + method + " has @Subscribe annotation on " + eventType + " which is an interface. Subscription must be on a concrete class type."); } if ((method.getModifiers() & Modifier.PUBLIC) == 0) { throw new IllegalArgumentException("Method " + method + " has @Subscribe annotation on " + eventType + " but is not 'public'."); } System.out.println("EventType: " + eventType); Set<Method> methods = subscriberMethods.get(eventType); if (methods == null) { methods = new HashSet<Method>(); subscriberMethods.put(eventType, methods); } methods.add(method); } } SUBSCRIBERS_CACHE.put(listenerClass, subscriberMethods); } private static void loadProducers(Class<?> listenerClass) { Map<Class<?>, Method> producerMethods = new HashMap<Class<?>, Method>(); for (Method method : listenerClass.getDeclaredMethods()) { if (method.isAnnotationPresent(Produce.class)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != 0) { throw new IllegalArgumentException("Method " + method + "has @Produce annotation but requires " + parameterTypes.length + " arguments. Methods must require zero arguments."); } if (method.getReturnType() == Void.class) { throw new IllegalArgumentException("Method " + method + " has a return type of void. Must declare a non-void type."); } Class<?> eventType = method.getReturnType(); if (eventType.isInterface()) { throw new IllegalArgumentException("Method " + method + " has @Produce annotation on " + eventType + " which is an interface. Producers must return a concrete class type."); } if (eventType.equals(Void.TYPE)) { throw new IllegalArgumentException("Method " + method + " has @Produce annotation but has no return type."); } if ((method.getModifiers() & Modifier.PUBLIC) == 0) { throw new IllegalArgumentException("Method " + method + " has @Produce annotation on " + eventType + " but is not 'public'."); } if (producerMethods.containsKey(eventType)) { throw new IllegalArgumentException("Producer for type " + eventType + " has already been registered."); } producerMethods.put(eventType, method); } } PRODUCERS_CACHE.put(listenerClass, producerMethods); } }
{ "pile_set_name": "Github" }
/* Copyright (c) 2007, Google Inc. * 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 of Google Inc. 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. * * --- * Author: Mike Burrows * * This module gets enough CPU information to optimize the * atomicops module on x86. */ #include "base/atomicops.h" #include "base/basictypes.h" #include "base/googleinit.h" #include "base/logging.h" #include <string.h> // Inline cpuid instruction. In PIC compilations, %ebx contains the address // of the global offset table. To avoid breaking such executables, this code // must preserve that register's value across cpuid instructions. #if defined(__i386__) #define cpuid(a, b, c, d, inp) \ asm ("mov %%ebx, %%edi\n" \ "cpuid\n" \ "xchg %%edi, %%ebx\n" \ : "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (inp)) #elif defined (__x86_64__) #define cpuid(a, b, c, d, inp) \ asm ("mov %%rbx, %%rdi\n" \ "cpuid\n" \ "xchg %%rdi, %%rbx\n" \ : "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (inp)) #endif #if defined(cpuid) // initialize the struct only on x86 // Set the flags so that code will run correctly and conservatively // until InitGoogle() is called. struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = { false, // bug can't exist before process spawns multiple threads false, // no SSE2 false, // no cmpxchg16b }; // Initialize the AtomicOps_Internalx86CPUFeatures struct. static void AtomicOps_Internalx86CPUFeaturesInit() { uint32 eax; uint32 ebx; uint32 ecx; uint32 edx; // Get vendor string (issue CPUID with eax = 0) cpuid(eax, ebx, ecx, edx, 0); char vendor[13]; memcpy(vendor, &ebx, 4); memcpy(vendor + 4, &edx, 4); memcpy(vendor + 8, &ecx, 4); vendor[12] = 0; // get feature flags in ecx/edx, and family/model in eax cpuid(eax, ebx, ecx, edx, 1); int family = (eax >> 8) & 0xf; // family and model fields int model = (eax >> 4) & 0xf; if (family == 0xf) { // use extended family and model fields family += (eax >> 20) & 0xff; model += ((eax >> 16) & 0xf) << 4; } // Opteron Rev E has a bug in which on very rare occasions a locked // instruction doesn't act as a read-acquire barrier if followed by a // non-locked read-modify-write instruction. Rev F has this bug in // pre-release versions, but not in versions released to customers, // so we test only for Rev E, which is family 15, model 32..63 inclusive. if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD family == 15 && 32 <= model && model <= 63) { AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; } else { AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; } // edx bit 26 is SSE2 which we use to tell use whether we can use mfence AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1); // ecx bit 13 indicates whether the cmpxchg16b instruction is supported AtomicOps_Internalx86CPUFeatures.has_cmpxchg16b = ((ecx >> 13) & 1); } REGISTER_MODULE_INITIALIZER(atomicops_x86, { AtomicOps_Internalx86CPUFeaturesInit(); }); #endif
{ "pile_set_name": "Github" }
#include "windows.h" #include "notify.h" GenericMenu MENU { POPUP "&File" { MENUITEM "Clear &Display", IDM_CLEAR MENUITEM "&Verbose Trace", IDM_VERBOSE MENUITEM "E&xit", IDM_EXIT } POPUP "&Bus" { MENUITEM "&PlugIn", IDM_PLUGIN MENUITEM "&UnPlug (Surprise Removal)", IDM_UNPLUG MENUITEM "&Eject", IDM_EJECT } POPUP "&Function" { MENUITEM "&Open", IDM_OPEN MENUITEM "&Close", IDM_CLOSE MENUITEM "&Hide", IDM_HIDE } POPUP "Fil&ter" { MENUITEM "&Ioctl to Control Device", IDM_IOCTL } } ///////////////////////////////////////////////////////////////////////////// // // Dialog for plug in // IDD_DIALOG DIALOG DISCARDABLE 0, 0, 289, 86 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Plug In Device" FONT 8, "MS Shell Dlg" BEGIN DEFPUSHBUTTON "OK",ID_OK,72,61,50,14,BS_NOTIFY PUSHBUTTON "CANCEL",ID_CANCEL,170,60,50,14,BS_NOTIFY LTEXT "Serial Number :",IDC_STATIC,18,13,55,8 LTEXT "Device ID :",IDC_STATIC,20,35,55,8 EDITTEXT IDC_SERIALNO,75,11,24,14,ES_NUMBER EDITTEXT IDC_DEVICEID,76,32,200,14,ES_AUTOHSCROLL END ///////////////////////////////////////////////////////////////////////////// // // Dialog for unplug/hide/enable/disable // IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 232, 86 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Enter SerialNo of the device" FONT 8, "MS Shell Dlg" BEGIN LTEXT "Serial Number :",IDC_STATIC,18,13,55,8 EDITTEXT IDC_SERIALNO,75,11,24,14,ES_NUMBER DEFPUSHBUTTON "OK",ID_OK,27,61,50,14,BS_NOTIFY PUSHBUTTON "CANCEL",ID_CANCEL,121,60,50,14,BS_NOTIFY END ///////////////////////////////////////////////////////////////////////////// // // Icon // IDI_CLASS_ICON ICON DISCARDABLE "TOASTER.ICO"
{ "pile_set_name": "Github" }
--- title: <backupLists> ms.date: 03/30/2017 ms.assetid: 593b3390-f65b-4684-ad40-0596b62f0954 ms.openlocfilehash: 940bf28958251e7257b2cc19a9c5ff0059411bcd ms.sourcegitcommit: 5b475c1855b32cf78d2d1bbb4295e4c236f39464 ms.translationtype: MT ms.contentlocale: zh-CN ms.lasthandoff: 09/24/2020 ms.locfileid: "91201546" --- # \<backupLists> 表示一个配置节,用于定义一组用来处理错误的备份服务。 每个子元素都是一个备份列表,用于枚举当无法到达主终结点时路由服务将使用的一组终结点。 如果列表中的第一个终结点关闭,则路由服务会自动故障转移到列表中的下一个终结点。 这样,可以方便地提高应用程序的可靠性,而不必告诉客户端应用程序应如何处理复杂模式或所有服务的部署位置。 [**\<configuration>**](../configuration-element.md)\ &nbsp;&nbsp;[**\<system.serviceModel>**](system-servicemodel.md)\ &nbsp;&nbsp;&nbsp;&nbsp;[**\<routing>**](routing.md)\ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**\<backupLists>** ## <a name="syntax"></a>语法 ```xml <routing> <backupLists> <backupList name="String"> <add endpointName="String" /> </backupList> </backupLists> </routing> ``` ## <a name="attributes-and-elements"></a>特性和元素 下列各节描述了特性、子元素和父元素。 ### <a name="attributes"></a>特性 无。 ### <a name="child-elements"></a>子元素 |元素|描述| |-------------|-----------------| |[\<filter>](filter.md)|包含当无法访问主终结点时路由服务将使用的终结点的列表。 .| ### <a name="parent-elements"></a>父元素 |元素|描述| |-------------|-----------------| |[\<routing>](routing.md)|表示用于定义一组路由筛选器的配置节,这些筛选器确定计算传入消息时要使用的 Windows Communication Foundation 的类型 (WCF) ,以及用于 <xref:System.ServiceModel.Dispatcher.MessageFilter> 定义筛选器匹配时要将消息发送到的目标终结点的路由表。| ## <a name="see-also"></a>请参阅 - <xref:System.ServiceModel.Routing.Configuration.BackupEndpointCollection?displayProperty=nameWithType>
{ "pile_set_name": "Github" }
(function(GoNorth) { "use strict"; (function(Tale) { (function(Localization) { Localization.ViewModel = {}; Localization.ViewModel.ChooseQuest = "Quest auswählen"; Localization.ViewModel.ChooseNpc = "Npc auswählen"; Localization.ViewModel.ChooseSkill = "Fähigkeit auswählen"; Localization.ViewModel.ChooseDailyRoutineEvent = "Tagesablauf Ereignis auswählen"; Localization.ViewModel.ChooseMarker = "Markierung auswählen"; // Text Lines GoNorth.DefaultNodeShapes.Localization.TypeNames["tale.PlayerText"] = "Spieler Zeile"; GoNorth.DefaultNodeShapes.Localization.TypeNames["tale.NpcText"] = "Npc Zeile"; Localization.PlayerTextPlaceHolder = "Spieler Zeile"; Localization.NpcTextPlaceHolder = "Npc Zeile"; // Choice GoNorth.DefaultNodeShapes.Localization.TypeNames["tale.Choice"] = "Auswahl"; Localization.Choices = {}; Localization.Choices.ChoiceText = "Auswahltext"; Localization.Choices.AddNewChoice = "Auswahl hinzufügen"; Localization.Choices.MoveUpToolTip = "Auswahl nach oben bewegen"; Localization.Choices.MoveDownToolTip = "Auswahl nach unten bewegen"; Localization.Choices.EditConditionToolTip = "Bedingung editieren"; Localization.Choices.AllowMultipleSelectionToolTip = "Dem Spieler erlauben die Antwort mehrfach auszuwählen"; Localization.Choices.DeleteToolTip = "Auswahl Löschen"; // Action Localization.Actions = {}; Localization.Actions.PersistDialogStateLabel = "Dialogzustand speichern"; Localization.Actions.PersistDialogStateWillContinueOnThisPointNextTalk = "Der Dialog wird an diesem Punkt forgesetzt wenn der Npc das nächste mal angesprochen wird."; Localization.Actions.OpenShopLabel = "Handel öffnen"; Localization.Actions.WillOpenAShopForTheCurrentNpc = "Es wird ein Handel mit dem aktuellen Npc gestartet."; // Condition Localization.Conditions = {}; }(Tale.Localization = Tale.Localization || {})); }(GoNorth.Tale = GoNorth.Tale || {})); }(window.GoNorth = window.GoNorth || {}));
{ "pile_set_name": "Github" }
package com.cgutman.adblib; /** * This interface specifies the required functions for AdbCrypto to * perform Base64 encoding of its public key. * @author Cameron Gutman */ public interface AdbBase64 { /** * This function must encoded the specified data as a base 64 string, without * appending any extra newlines or other characters. * @param data Data to encode * @return String containing base 64 encoded data */ public String encodeToString(byte[] data); }
{ "pile_set_name": "Github" }
/* * LZO 1x decompression * Copyright (c) 2006 Reimar Doeffinger * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * FFmpeg 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avutil.h" #include "common.h" //! Avoid e.g. MPlayers fast_memcpy, it slows things down here. #undef memcpy #include <string.h> #include "lzo.h" //! Define if we may write up to 12 bytes beyond the output buffer. #define OUTBUF_PADDED 1 //! Define if we may read up to 8 bytes beyond the input buffer. #define INBUF_PADDED 1 typedef struct LZOContext { const uint8_t *in, *in_end; uint8_t *out_start, *out, *out_end; int error; } LZOContext; /** * \brief Reads one byte from the input buffer, avoiding an overrun. * \return byte read */ static inline int get_byte(LZOContext *c) { if (c->in < c->in_end) return *c->in++; c->error |= AV_LZO_INPUT_DEPLETED; return 1; } #ifdef INBUF_PADDED #define GETB(c) (*(c).in++) #else #define GETB(c) get_byte(&(c)) #endif /** * \brief Decodes a length value in the coding used by lzo. * \param x previous byte value * \param mask bits used from x * \return decoded length value */ static inline int get_len(LZOContext *c, int x, int mask) { int cnt = x & mask; if (!cnt) { while (!(x = get_byte(c))) cnt += 255; cnt += mask + x; } return cnt; } //#define UNALIGNED_LOADSTORE #define BUILTIN_MEMCPY #ifdef UNALIGNED_LOADSTORE #define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s); #define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s); #elif defined(BUILTIN_MEMCPY) #define COPY2(d, s) memcpy(d, s, 2); #define COPY4(d, s) memcpy(d, s, 4); #else #define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; #define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3]; #endif /** * \brief Copies bytes from input to output buffer with checking. * \param cnt number of bytes to copy, must be >= 0 */ static inline void copy(LZOContext *c, int cnt) { register const uint8_t *src = c->in; register uint8_t *dst = c->out; if (cnt > c->in_end - src) { cnt = FFMAX(c->in_end - src, 0); c->error |= AV_LZO_INPUT_DEPLETED; } if (cnt > c->out_end - dst) { cnt = FFMAX(c->out_end - dst, 0); c->error |= AV_LZO_OUTPUT_FULL; } #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED) COPY4(dst, src); src += 4; dst += 4; cnt -= 4; if (cnt > 0) #endif memcpy(dst, src, cnt); c->in = src + cnt; c->out = dst + cnt; } static inline void memcpy_backptr(uint8_t *dst, int back, int cnt); /** * \brief Copies previously decoded bytes to current position. * \param back how many bytes back we start * \param cnt number of bytes to copy, must be >= 0 * * cnt > back is valid, this will copy the bytes we just copied, * thus creating a repeating pattern with a period length of back. */ static inline void copy_backptr(LZOContext *c, int back, int cnt) { register const uint8_t *src = &c->out[-back]; register uint8_t *dst = c->out; if (src < c->out_start || src > dst) { c->error |= AV_LZO_INVALID_BACKPTR; return; } if (cnt > c->out_end - dst) { cnt = FFMAX(c->out_end - dst, 0); c->error |= AV_LZO_OUTPUT_FULL; } memcpy_backptr(dst, back, cnt); c->out = dst + cnt; } static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { const uint8_t *src = &dst[-back]; if (back == 1) { memset(dst, *src, cnt); } else { #ifdef OUTBUF_PADDED COPY2(dst, src); COPY2(dst + 2, src + 2); src += 4; dst += 4; cnt -= 4; if (cnt > 0) { COPY2(dst, src); COPY2(dst + 2, src + 2); COPY2(dst + 4, src + 4); COPY2(dst + 6, src + 6); src += 8; dst += 8; cnt -= 8; } #endif if (cnt > 0) { int blocklen = back; while (cnt > blocklen) { memcpy(dst, src, blocklen); dst += blocklen; cnt -= blocklen; blocklen <<= 1; } memcpy(dst, src, cnt); } } } void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { memcpy_backptr(dst, back, cnt); } int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { int state= 0; int x; LZOContext c; c.in = in; c.in_end = (const uint8_t *)in + *inlen; c.out = c.out_start = out; c.out_end = (uint8_t *)out + * outlen; c.error = 0; x = GETB(c); if (x > 17) { copy(&c, x - 17); x = GETB(c); if (x < 16) c.error |= AV_LZO_ERROR; } if (c.in > c.in_end) c.error |= AV_LZO_INPUT_DEPLETED; while (!c.error) { int cnt, back; if (x > 15) { if (x > 63) { cnt = (x >> 5) - 1; back = (GETB(c) << 3) + ((x >> 2) & 7) + 1; } else if (x > 31) { cnt = get_len(&c, x, 31); x = GETB(c); back = (GETB(c) << 6) + (x >> 2) + 1; } else { cnt = get_len(&c, x, 7); back = (1 << 14) + ((x & 8) << 11); x = GETB(c); back += (GETB(c) << 6) + (x >> 2); if (back == (1 << 14)) { if (cnt != 1) c.error |= AV_LZO_ERROR; break; } } } else if(!state){ cnt = get_len(&c, x, 15); copy(&c, cnt + 3); x = GETB(c); if (x > 15) continue; cnt = 1; back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1; } else { cnt = 0; back = (GETB(c) << 2) + (x >> 2) + 1; } copy_backptr(&c, back, cnt + 2); state= cnt = x & 3; copy(&c, cnt); x = GETB(c); } *inlen = c.in_end - c.in; if (c.in > c.in_end) *inlen = 0; *outlen = c.out_end - c.out; return c.error; } #ifdef TEST #include <stdio.h> #include <lzo/lzo1x.h> #include "log.h" #define MAXSZ (10*1024*1024) /* Define one of these to 1 if you wish to benchmark liblzo * instead of our native implementation. */ #define BENCHMARK_LIBLZO_SAFE 0 #define BENCHMARK_LIBLZO_UNSAFE 0 int main(int argc, char *argv[]) { FILE *in = fopen(argv[1], "rb"); uint8_t *orig = av_malloc(MAXSZ + 16); uint8_t *comp = av_malloc(2*MAXSZ + 16); uint8_t *decomp = av_malloc(MAXSZ + 16); size_t s = fread(orig, 1, MAXSZ, in); lzo_uint clen = 0; long tmp[LZO1X_MEM_COMPRESS]; int inlen, outlen; int i; av_log_set_level(AV_LOG_DEBUG); lzo1x_999_compress(orig, s, comp, &clen, tmp); for (i = 0; i < 300; i++) { START_TIMER inlen = clen; outlen = MAXSZ; #if BENCHMARK_LIBLZO_SAFE if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL)) #elif BENCHMARK_LIBLZO_UNSAFE if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL)) #else if (av_lzo1x_decode(decomp, &outlen, comp, &inlen)) #endif av_log(NULL, AV_LOG_ERROR, "decompression error\n"); STOP_TIMER("lzod") } if (memcmp(orig, decomp, s)) av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n"); else av_log(NULL, AV_LOG_ERROR, "decompression OK\n"); return 0; } #endif
{ "pile_set_name": "Github" }
<body bgcolor=white> <table bgcolor=blue cellpadding=0> <tr><td> <table bgcolor=yellow> <tr><td>hello </table> </table> </body>
{ "pile_set_name": "Github" }
/* Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or http://ckeditor.com/license */ CKEDITOR.plugins.setLang( 'iframe', 'bs', { border: 'Show frame border', // MISSING noUrl: 'Please type the iframe URL', // MISSING scrolling: 'Enable scrollbars', // MISSING title: 'IFrame Properties', // MISSING toolbar: 'IFrame' // MISSING } );
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:padding="@dimen/dp_12" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <com.bilibili.magicasakura.widgets.TintView android:layout_alignBottom="@+id/tv_hot_search_title" android:layout_alignTop="@+id/tv_hot_search_title" android:id="@+id/view_small_line" android:background="@drawable/shape_line_small" android:layout_width="5dp" android:layout_height="wrap_content" /> <TextView android:layout_centerVertical="true" android:id="@+id/tv_hot_search_title" android:layout_marginLeft="@dimen/dp_8" android:layout_toRightOf="@+id/view_small_line" android:textColor="@color/black" android:textStyle="bold" android:text="@string/home_search_hot" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/tv_hot_more" android:layout_centerVertical="true" android:textSize="@dimen/sp_12" android:textColor="@color/normal_txt" android:text="@string/home_search_hot_more" android:drawableRight="@mipmap/icon_common_arrow" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout>
{ "pile_set_name": "Github" }
<div id="container"> <div id="middle"> <div id="content">I</div> </div> </div> #parent { display: table; } #middle { display: table-cell; vertical-align: bottom; } #child { font-size: 30px; height: 30px; text-align: center; }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="321dp" android:layout_height="456dp" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_gravity="center_horizontal" app:cardCornerRadius="5dp" app:elevation="10dp" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/img_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:layout_above="@+id/rela_bottom" /> <TextView android:id="@+id/tv_title" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:textColor="@android:color/white" android:textStyle="bold" android:layout_marginTop="16dp" android:textSize="30sp" /> <RelativeLayout android:id="@+id/rela_bottom" android:layout_width="match_parent" android:layout_height="56dp" android:layout_alignParentBottom="true" android:background="@android:color/white" > <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/img_user" android:layout_width="35dp" android:layout_height="35dp" android:layout_centerVertical="true" android:layout_marginLeft="16dp" app:civ_border_overlay="true" android:elevation="3dp" /> <TextView android:id="@+id/tv_user_say" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textStyle="bold" android:layout_centerVertical="true" android:layout_toRightOf="@+id/img_user" android:layout_marginLeft="10dp" android:layout_marginRight="16dp" android:singleLine="true" /> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="1px" android:background="#b2b2b2" android:layout_alignParentBottom="true" /> </RelativeLayout> </android.support.v7.widget.CardView>
{ "pile_set_name": "Github" }
/* * Copyright (c) Eicon Networks, 2002. * This source file is supplied for the use with Eicon Networks range of DIVA Server Adapters. * Eicon File Revision : 2.1 * This program 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 2, or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY 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 this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "platform.h" #include "capidtmf.h" /* #define TRACE_ */ #define FILE_ "CAPIDTMF.C" /*---------------------------------------------------------------------------*/ #define trace(a) /*---------------------------------------------------------------------------*/ static short capidtmf_expand_table_alaw[0x0100] = { -5504, 5504, -344, 344, -22016, 22016, -1376, 1376, -2752, 2752, -88, 88, -11008, 11008, -688, 688, -7552, 7552, -472, 472, -30208, 30208, -1888, 1888, -3776, 3776, -216, 216, -15104, 15104, -944, 944, -4480, 4480, -280, 280, -17920, 17920, -1120, 1120, -2240, 2240, -24, 24, -8960, 8960, -560, 560, -6528, 6528, -408, 408, -26112, 26112, -1632, 1632, -3264, 3264, -152, 152, -13056, 13056, -816, 816, -6016, 6016, -376, 376, -24064, 24064, -1504, 1504, -3008, 3008, -120, 120, -12032, 12032, -752, 752, -8064, 8064, -504, 504, -32256, 32256, -2016, 2016, -4032, 4032, -248, 248, -16128, 16128, -1008, 1008, -4992, 4992, -312, 312, -19968, 19968, -1248, 1248, -2496, 2496, -56, 56, -9984, 9984, -624, 624, -7040, 7040, -440, 440, -28160, 28160, -1760, 1760, -3520, 3520, -184, 184, -14080, 14080, -880, 880, -5248, 5248, -328, 328, -20992, 20992, -1312, 1312, -2624, 2624, -72, 72, -10496, 10496, -656, 656, -7296, 7296, -456, 456, -29184, 29184, -1824, 1824, -3648, 3648, -200, 200, -14592, 14592, -912, 912, -4224, 4224, -264, 264, -16896, 16896, -1056, 1056, -2112, 2112, -8, 8, -8448, 8448, -528, 528, -6272, 6272, -392, 392, -25088, 25088, -1568, 1568, -3136, 3136, -136, 136, -12544, 12544, -784, 784, -5760, 5760, -360, 360, -23040, 23040, -1440, 1440, -2880, 2880, -104, 104, -11520, 11520, -720, 720, -7808, 7808, -488, 488, -31232, 31232, -1952, 1952, -3904, 3904, -232, 232, -15616, 15616, -976, 976, -4736, 4736, -296, 296, -18944, 18944, -1184, 1184, -2368, 2368, -40, 40, -9472, 9472, -592, 592, -6784, 6784, -424, 424, -27136, 27136, -1696, 1696, -3392, 3392, -168, 168, -13568, 13568, -848, 848 }; static short capidtmf_expand_table_ulaw[0x0100] = { -32124, 32124, -1884, 1884, -7932, 7932, -372, 372, -15996, 15996, -876, 876, -3900, 3900, -120, 120, -23932, 23932, -1372, 1372, -5884, 5884, -244, 244, -11900, 11900, -620, 620, -2876, 2876, -56, 56, -28028, 28028, -1628, 1628, -6908, 6908, -308, 308, -13948, 13948, -748, 748, -3388, 3388, -88, 88, -19836, 19836, -1116, 1116, -4860, 4860, -180, 180, -9852, 9852, -492, 492, -2364, 2364, -24, 24, -30076, 30076, -1756, 1756, -7420, 7420, -340, 340, -14972, 14972, -812, 812, -3644, 3644, -104, 104, -21884, 21884, -1244, 1244, -5372, 5372, -212, 212, -10876, 10876, -556, 556, -2620, 2620, -40, 40, -25980, 25980, -1500, 1500, -6396, 6396, -276, 276, -12924, 12924, -684, 684, -3132, 3132, -72, 72, -17788, 17788, -988, 988, -4348, 4348, -148, 148, -8828, 8828, -428, 428, -2108, 2108, -8, 8, -31100, 31100, -1820, 1820, -7676, 7676, -356, 356, -15484, 15484, -844, 844, -3772, 3772, -112, 112, -22908, 22908, -1308, 1308, -5628, 5628, -228, 228, -11388, 11388, -588, 588, -2748, 2748, -48, 48, -27004, 27004, -1564, 1564, -6652, 6652, -292, 292, -13436, 13436, -716, 716, -3260, 3260, -80, 80, -18812, 18812, -1052, 1052, -4604, 4604, -164, 164, -9340, 9340, -460, 460, -2236, 2236, -16, 16, -29052, 29052, -1692, 1692, -7164, 7164, -324, 324, -14460, 14460, -780, 780, -3516, 3516, -96, 96, -20860, 20860, -1180, 1180, -5116, 5116, -196, 196, -10364, 10364, -524, 524, -2492, 2492, -32, 32, -24956, 24956, -1436, 1436, -6140, 6140, -260, 260, -12412, 12412, -652, 652, -3004, 3004, -64, 64, -16764, 16764, -924, 924, -4092, 4092, -132, 132, -8316, 8316, -396, 396, -1980, 1980, 0, 0 }; /*---------------------------------------------------------------------------*/ static short capidtmf_recv_window_function[CAPIDTMF_RECV_ACCUMULATE_CYCLES] = { -500L, -999L, -1499L, -1998L, -2496L, -2994L, -3491L, -3988L, -4483L, -4978L, -5471L, -5963L, -6454L, -6943L, -7431L, -7917L, -8401L, -8883L, -9363L, -9840L, -10316L, -10789L, -11259L, -11727L, -12193L, -12655L, -13115L, -13571L, -14024L, -14474L, -14921L, -15364L, -15804L, -16240L, -16672L, -17100L, -17524L, -17944L, -18360L, -18772L, -19180L, -19583L, -19981L, -20375L, -20764L, -21148L, -21527L, -21901L, -22270L, -22634L, -22993L, -23346L, -23694L, -24037L, -24374L, -24705L, -25030L, -25350L, -25664L, -25971L, -26273L, -26568L, -26858L, -27141L, -27418L, -27688L, -27952L, -28210L, -28461L, -28705L, -28943L, -29174L, -29398L, -29615L, -29826L, -30029L, -30226L, -30415L, -30598L, -30773L, -30941L, -31102L, -31256L, -31402L, -31541L, -31673L, -31797L, -31914L, -32024L, -32126L, -32221L, -32308L, -32388L, -32460L, -32524L, -32581L, -32631L, -32673L, -32707L, -32734L, -32753L, -32764L, -32768L, -32764L, -32753L, -32734L, -32707L, -32673L, -32631L, -32581L, -32524L, -32460L, -32388L, -32308L, -32221L, -32126L, -32024L, -31914L, -31797L, -31673L, -31541L, -31402L, -31256L, -31102L, -30941L, -30773L, -30598L, -30415L, -30226L, -30029L, -29826L, -29615L, -29398L, -29174L, -28943L, -28705L, -28461L, -28210L, -27952L, -27688L, -27418L, -27141L, -26858L, -26568L, -26273L, -25971L, -25664L, -25350L, -25030L, -24705L, -24374L, -24037L, -23694L, -23346L, -22993L, -22634L, -22270L, -21901L, -21527L, -21148L, -20764L, -20375L, -19981L, -19583L, -19180L, -18772L, -18360L, -17944L, -17524L, -17100L, -16672L, -16240L, -15804L, -15364L, -14921L, -14474L, -14024L, -13571L, -13115L, -12655L, -12193L, -11727L, -11259L, -10789L, -10316L, -9840L, -9363L, -8883L, -8401L, -7917L, -7431L, -6943L, -6454L, -5963L, -5471L, -4978L, -4483L, -3988L, -3491L, -2994L, -2496L, -1998L, -1499L, -999L, -500L, }; static byte capidtmf_leading_zeroes_table[0x100] = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #define capidtmf_byte_leading_zeroes(b) (capidtmf_leading_zeroes_table[(BYTE)(b)]) #define capidtmf_word_leading_zeroes(w) (((w) & 0xff00) ? capidtmf_leading_zeroes_table[(w) >> 8] : 8 + capidtmf_leading_zeroes_table[(w)]) #define capidtmf_dword_leading_zeroes(d) (((d) & 0xffff0000L) ? (((d) & 0xff000000L) ? capidtmf_leading_zeroes_table[(d) >> 24] : 8 + capidtmf_leading_zeroes_table[(d) >> 16]) : (((d) & 0xff00) ? 16 + capidtmf_leading_zeroes_table[(d) >> 8] : 24 + capidtmf_leading_zeroes_table[(d)])) /*---------------------------------------------------------------------------*/ static void capidtmf_goertzel_loop(long *buffer, long *coeffs, short *sample, long count) { int i, j; long c, d, q0, q1, q2; for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT - 1; i++) { q1 = buffer[i]; q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; d = coeffs[i] >> 1; c = d << 1; if (c >= 0) { for (j = 0; j < count; j++) { q0 = sample[j] - q2 + (c * (q1 >> 16)) + (((dword)(((dword) d) * ((dword)(q1 & 0xffff)))) >> 15); q2 = q1; q1 = q0; } } else { c = -c; d = -d; for (j = 0; j < count; j++) { q0 = sample[j] - q2 - ((c * (q1 >> 16)) + (((dword)(((dword) d) * ((dword)(q1 & 0xffff)))) >> 15)); q2 = q1; q1 = q0; } } buffer[i] = q1; buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = q2; } q1 = buffer[i]; q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; c = (coeffs[i] >> 1) << 1; if (c >= 0) { for (j = 0; j < count; j++) { q0 = sample[j] - q2 + (c * (q1 >> 16)) + (((dword)(((dword)(c >> 1)) * ((dword)(q1 & 0xffff)))) >> 15); q2 = q1; q1 = q0; c -= CAPIDTMF_RECV_FUNDAMENTAL_DECREMENT; } } else { c = -c; for (j = 0; j < count; j++) { q0 = sample[j] - q2 - ((c * (q1 >> 16)) + (((dword)(((dword)(c >> 1)) * ((dword)(q1 & 0xffff)))) >> 15)); q2 = q1; q1 = q0; c += CAPIDTMF_RECV_FUNDAMENTAL_DECREMENT; } } coeffs[i] = c; buffer[i] = q1; buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = q2; } static void capidtmf_goertzel_result(long *buffer, long *coeffs) { int i; long d, e, q1, q2, lo, mid, hi; dword k; for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) { q1 = buffer[i]; q2 = buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; d = coeffs[i] >> 1; if (d >= 0) d = ((d << 1) * (-q1 >> 16)) + (((dword)(((dword) d) * ((dword)(-q1 & 0xffff)))) >> 15); else d = ((-d << 1) * (-q1 >> 16)) + (((dword)(((dword) -d) * ((dword)(-q1 & 0xffff)))) >> 15); e = (q2 >= 0) ? q2 : -q2; if (d >= 0) { k = ((dword)(d & 0xffff)) * ((dword)(e & 0xffff)); lo = k & 0xffff; mid = k >> 16; k = ((dword)(d >> 16)) * ((dword)(e & 0xffff)); mid += k & 0xffff; hi = k >> 16; k = ((dword)(d & 0xffff)) * ((dword)(e >> 16)); mid += k & 0xffff; hi += k >> 16; hi += ((dword)(d >> 16)) * ((dword)(e >> 16)); } else { d = -d; k = ((dword)(d & 0xffff)) * ((dword)(e & 0xffff)); lo = -((long)(k & 0xffff)); mid = -((long)(k >> 16)); k = ((dword)(d >> 16)) * ((dword)(e & 0xffff)); mid -= k & 0xffff; hi = -((long)(k >> 16)); k = ((dword)(d & 0xffff)) * ((dword)(e >> 16)); mid -= k & 0xffff; hi -= k >> 16; hi -= ((dword)(d >> 16)) * ((dword)(e >> 16)); } if (q2 < 0) { lo = -lo; mid = -mid; hi = -hi; } d = (q1 >= 0) ? q1 : -q1; k = ((dword)(d & 0xffff)) * ((dword)(d & 0xffff)); lo += k & 0xffff; mid += k >> 16; k = ((dword)(d >> 16)) * ((dword)(d & 0xffff)); mid += (k & 0xffff) << 1; hi += (k >> 16) << 1; hi += ((dword)(d >> 16)) * ((dword)(d >> 16)); d = (q2 >= 0) ? q2 : -q2; k = ((dword)(d & 0xffff)) * ((dword)(d & 0xffff)); lo += k & 0xffff; mid += k >> 16; k = ((dword)(d >> 16)) * ((dword)(d & 0xffff)); mid += (k & 0xffff) << 1; hi += (k >> 16) << 1; hi += ((dword)(d >> 16)) * ((dword)(d >> 16)); mid += lo >> 16; hi += mid >> 16; buffer[i] = (lo & 0xffff) | (mid << 16); buffer[i + CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = hi; } } /*---------------------------------------------------------------------------*/ #define CAPIDTMF_RECV_GUARD_SNR_INDEX_697 0 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_770 1 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_852 2 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_941 3 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1209 4 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1336 5 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1477 6 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1633 7 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_635 8 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1010 9 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1140 10 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1272 11 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1405 12 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1555 13 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1715 14 #define CAPIDTMF_RECV_GUARD_SNR_INDEX_1875 15 #define CAPIDTMF_RECV_GUARD_SNR_DONTCARE 0xc000 #define CAPIDTMF_RECV_NO_DIGIT 0xff #define CAPIDTMF_RECV_TIME_GRANULARITY (CAPIDTMF_RECV_ACCUMULATE_CYCLES + 1) #define CAPIDTMF_RECV_INDICATION_DIGIT 0x0001 static long capidtmf_recv_goertzel_coef_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = { 0xda97L * 2, /* 697 Hz (Low group 697 Hz) */ 0xd299L * 2, /* 770 Hz (Low group 770 Hz) */ 0xc8cbL * 2, /* 852 Hz (Low group 852 Hz) */ 0xbd36L * 2, /* 941 Hz (Low group 941 Hz) */ 0x9501L * 2, /* 1209 Hz (High group 1209 Hz) */ 0x7f89L * 2, /* 1336 Hz (High group 1336 Hz) */ 0x6639L * 2, /* 1477 Hz (High group 1477 Hz) */ 0x48c6L * 2, /* 1633 Hz (High group 1633 Hz) */ 0xe14cL * 2, /* 630 Hz (Lower guard of low group 631 Hz) */ 0xb2e0L * 2, /* 1015 Hz (Upper guard of low group 1039 Hz) */ 0xa1a0L * 2, /* 1130 Hz (Lower guard of high group 1140 Hz) */ 0x8a87L * 2, /* 1272 Hz (Guard between 1209 Hz and 1336 Hz: 1271 Hz) */ 0x7353L * 2, /* 1405 Hz (2nd harmonics of 697 Hz and guard between 1336 Hz and 1477 Hz: 1405 Hz) */ 0x583bL * 2, /* 1552 Hz (2nd harmonics of 770 Hz and guard between 1477 Hz and 1633 Hz: 1553 Hz) */ 0x37d8L * 2, /* 1720 Hz (2nd harmonics of 852 Hz and upper guard of high group: 1715 Hz) */ 0x0000L * 2 /* 100-630 Hz (fundamentals) */ }; static word capidtmf_recv_guard_snr_low_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = { 14, /* Low group peak versus 697 Hz */ 14, /* Low group peak versus 770 Hz */ 16, /* Low group peak versus 852 Hz */ 16, /* Low group peak versus 941 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1209 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1336 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1477 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1633 Hz */ 14, /* Low group peak versus 635 Hz */ 16, /* Low group peak versus 1010 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1140 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* Low group peak versus 1272 Hz */ DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 8, /* Low group peak versus 1405 Hz */ DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 4, /* Low group peak versus 1555 Hz */ DSPDTMF_RX_HARMONICS_SEL_DEFAULT - 4, /* Low group peak versus 1715 Hz */ 12 /* Low group peak versus 100-630 Hz */ }; static word capidtmf_recv_guard_snr_high_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT] = { CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 697 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 770 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 852 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 941 Hz */ 20, /* High group peak versus 1209 Hz */ 20, /* High group peak versus 1336 Hz */ 20, /* High group peak versus 1477 Hz */ 20, /* High group peak versus 1633 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 635 Hz */ CAPIDTMF_RECV_GUARD_SNR_DONTCARE, /* High group peak versus 1010 Hz */ 16, /* High group peak versus 1140 Hz */ 4, /* High group peak versus 1272 Hz */ 6, /* High group peak versus 1405 Hz */ 8, /* High group peak versus 1555 Hz */ 16, /* High group peak versus 1715 Hz */ 12 /* High group peak versus 100-630 Hz */ }; /*---------------------------------------------------------------------------*/ static void capidtmf_recv_init(t_capidtmf_state *p_state) { p_state->recv.min_gap_duration = 1; p_state->recv.min_digit_duration = 1; p_state->recv.cycle_counter = 0; p_state->recv.current_digit_on_time = 0; p_state->recv.current_digit_off_time = 0; p_state->recv.current_digit_value = CAPIDTMF_RECV_NO_DIGIT; p_state->recv.digit_write_pos = 0; p_state->recv.digit_read_pos = 0; p_state->recv.indication_state = 0; p_state->recv.indication_state_ack = 0; p_state->recv.state = CAPIDTMF_RECV_STATE_IDLE; } void capidtmf_recv_enable(t_capidtmf_state *p_state, word min_digit_duration, word min_gap_duration) { p_state->recv.indication_state_ack &= CAPIDTMF_RECV_INDICATION_DIGIT; p_state->recv.min_digit_duration = (word)(((((dword) min_digit_duration) * 8) + ((dword)(CAPIDTMF_RECV_TIME_GRANULARITY / 2))) / ((dword) CAPIDTMF_RECV_TIME_GRANULARITY)); if (p_state->recv.min_digit_duration <= 1) p_state->recv.min_digit_duration = 1; else (p_state->recv.min_digit_duration)--; p_state->recv.min_gap_duration = (word)((((dword) min_gap_duration) * 8) / ((dword) CAPIDTMF_RECV_TIME_GRANULARITY)); if (p_state->recv.min_gap_duration <= 1) p_state->recv.min_gap_duration = 1; else (p_state->recv.min_gap_duration)--; p_state->recv.state |= CAPIDTMF_RECV_STATE_DTMF_ACTIVE; } void capidtmf_recv_disable(t_capidtmf_state *p_state) { p_state->recv.state &= ~CAPIDTMF_RECV_STATE_DTMF_ACTIVE; if (p_state->recv.state == CAPIDTMF_RECV_STATE_IDLE) capidtmf_recv_init(p_state); else { p_state->recv.cycle_counter = 0; p_state->recv.current_digit_on_time = 0; p_state->recv.current_digit_off_time = 0; p_state->recv.current_digit_value = CAPIDTMF_RECV_NO_DIGIT; } } word capidtmf_recv_indication(t_capidtmf_state *p_state, byte *buffer) { word i, j, k, flags; flags = p_state->recv.indication_state ^ p_state->recv.indication_state_ack; p_state->recv.indication_state_ack ^= flags & CAPIDTMF_RECV_INDICATION_DIGIT; if (p_state->recv.digit_write_pos != p_state->recv.digit_read_pos) { i = 0; k = p_state->recv.digit_write_pos; j = p_state->recv.digit_read_pos; do { buffer[i++] = p_state->recv.digit_buffer[j]; j = (j == CAPIDTMF_RECV_DIGIT_BUFFER_SIZE - 1) ? 0 : j + 1; } while (j != k); p_state->recv.digit_read_pos = k; return (i); } p_state->recv.indication_state_ack ^= flags; return (0); } #define CAPIDTMF_RECV_WINDOWED_SAMPLES 32 void capidtmf_recv_block(t_capidtmf_state *p_state, byte *buffer, word length) { byte result_digit; word sample_number, cycle_counter, n, i; word low_peak, high_peak; dword lo, hi; byte *p; short *q; byte goertzel_result_buffer[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT]; short windowed_sample_buffer[CAPIDTMF_RECV_WINDOWED_SAMPLES]; if (p_state->recv.state & CAPIDTMF_RECV_STATE_DTMF_ACTIVE) { cycle_counter = p_state->recv.cycle_counter; sample_number = 0; while (sample_number < length) { if (cycle_counter < CAPIDTMF_RECV_ACCUMULATE_CYCLES) { if (cycle_counter == 0) { for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) { p_state->recv.goertzel_buffer[0][i] = 0; p_state->recv.goertzel_buffer[1][i] = 0; } } n = CAPIDTMF_RECV_ACCUMULATE_CYCLES - cycle_counter; if (n > length - sample_number) n = length - sample_number; if (n > CAPIDTMF_RECV_WINDOWED_SAMPLES) n = CAPIDTMF_RECV_WINDOWED_SAMPLES; p = buffer + sample_number; q = capidtmf_recv_window_function + cycle_counter; if (p_state->ulaw) { for (i = 0; i < n; i++) { windowed_sample_buffer[i] = (short)((capidtmf_expand_table_ulaw[p[i]] * ((long)(q[i]))) >> 15); } } else { for (i = 0; i < n; i++) { windowed_sample_buffer[i] = (short)((capidtmf_expand_table_alaw[p[i]] * ((long)(q[i]))) >> 15); } } capidtmf_recv_goertzel_coef_table[CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT - 1] = CAPIDTMF_RECV_FUNDAMENTAL_OFFSET; capidtmf_goertzel_loop(p_state->recv.goertzel_buffer[0], capidtmf_recv_goertzel_coef_table, windowed_sample_buffer, n); cycle_counter += n; sample_number += n; } else { capidtmf_goertzel_result(p_state->recv.goertzel_buffer[0], capidtmf_recv_goertzel_coef_table); for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) { lo = (dword)(p_state->recv.goertzel_buffer[0][i]); hi = (dword)(p_state->recv.goertzel_buffer[1][i]); if (hi != 0) { n = capidtmf_dword_leading_zeroes(hi); hi = (hi << n) | (lo >> (32 - n)); } else { n = capidtmf_dword_leading_zeroes(lo); hi = lo << n; n += 32; } n = 195 - 3 * n; if (hi >= 0xcb300000L) n += 2; else if (hi >= 0xa1450000L) n++; goertzel_result_buffer[i] = (byte) n; } low_peak = DSPDTMF_RX_SENSITIVITY_LOW_DEFAULT; result_digit = CAPIDTMF_RECV_NO_DIGIT; for (i = 0; i < CAPIDTMF_LOW_GROUP_FREQUENCIES; i++) { if (goertzel_result_buffer[i] > low_peak) { low_peak = goertzel_result_buffer[i]; result_digit = (byte) i; } } high_peak = DSPDTMF_RX_SENSITIVITY_HIGH_DEFAULT; n = CAPIDTMF_RECV_NO_DIGIT; for (i = CAPIDTMF_LOW_GROUP_FREQUENCIES; i < CAPIDTMF_RECV_BASE_FREQUENCY_COUNT; i++) { if (goertzel_result_buffer[i] > high_peak) { high_peak = goertzel_result_buffer[i]; n = (i - CAPIDTMF_LOW_GROUP_FREQUENCIES) << 2; } } result_digit |= (byte) n; if (low_peak + DSPDTMF_RX_HIGH_EXCEEDING_LOW_DEFAULT < high_peak) result_digit = CAPIDTMF_RECV_NO_DIGIT; if (high_peak + DSPDTMF_RX_LOW_EXCEEDING_HIGH_DEFAULT < low_peak) result_digit = CAPIDTMF_RECV_NO_DIGIT; n = 0; for (i = 0; i < CAPIDTMF_RECV_TOTAL_FREQUENCY_COUNT; i++) { if ((((short)(low_peak - goertzel_result_buffer[i] - capidtmf_recv_guard_snr_low_table[i])) < 0) || (((short)(high_peak - goertzel_result_buffer[i] - capidtmf_recv_guard_snr_high_table[i])) < 0)) { n++; } } if (n != 2) result_digit = CAPIDTMF_RECV_NO_DIGIT; if (result_digit == CAPIDTMF_RECV_NO_DIGIT) { if (p_state->recv.current_digit_on_time != 0) { if (++(p_state->recv.current_digit_off_time) >= p_state->recv.min_gap_duration) { p_state->recv.current_digit_on_time = 0; p_state->recv.current_digit_off_time = 0; } } else { if (p_state->recv.current_digit_off_time != 0) (p_state->recv.current_digit_off_time)--; } } else { if ((p_state->recv.current_digit_on_time == 0) && (p_state->recv.current_digit_off_time != 0)) { (p_state->recv.current_digit_off_time)--; } else { n = p_state->recv.current_digit_off_time; if ((p_state->recv.current_digit_on_time != 0) && (result_digit != p_state->recv.current_digit_value)) { p_state->recv.current_digit_on_time = 0; n = 0; } p_state->recv.current_digit_value = result_digit; p_state->recv.current_digit_off_time = 0; if (p_state->recv.current_digit_on_time != 0xffff) { p_state->recv.current_digit_on_time += n + 1; if (p_state->recv.current_digit_on_time >= p_state->recv.min_digit_duration) { p_state->recv.current_digit_on_time = 0xffff; i = (p_state->recv.digit_write_pos == CAPIDTMF_RECV_DIGIT_BUFFER_SIZE - 1) ? 0 : p_state->recv.digit_write_pos + 1; if (i == p_state->recv.digit_read_pos) { trace(dprintf("%s,%d: Receive digit overrun", (char *)(FILE_), __LINE__)); } else { p_state->recv.digit_buffer[p_state->recv.digit_write_pos] = result_digit; p_state->recv.digit_write_pos = i; p_state->recv.indication_state = (p_state->recv.indication_state & ~CAPIDTMF_RECV_INDICATION_DIGIT) | (~p_state->recv.indication_state_ack & CAPIDTMF_RECV_INDICATION_DIGIT); } } } } } cycle_counter = 0; sample_number++; } } p_state->recv.cycle_counter = cycle_counter; } } void capidtmf_init(t_capidtmf_state *p_state, byte ulaw) { p_state->ulaw = ulaw; capidtmf_recv_init(p_state); } /*---------------------------------------------------------------------------*/
{ "pile_set_name": "Github" }
// go run mksyscall_aix_ppc64.go -aix -tags aix,ppc64 syscall_aix.go syscall_aix_ppc64.go // Code generated by the command above; see README.md. DO NOT EDIT. // +build aix,ppc64 // +build !gccgo package unix import ( "unsafe" ) //go:cgo_import_dynamic libc_utimes utimes "libc.a/shr_64.o" //go:cgo_import_dynamic libc_utimensat utimensat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getcwd getcwd "libc.a/shr_64.o" //go:cgo_import_dynamic libc_accept accept "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getdirent getdirent "libc.a/shr_64.o" //go:cgo_import_dynamic libc_wait4 wait4 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fcntl fcntl "libc.a/shr_64.o" //go:cgo_import_dynamic libc_acct acct "libc.a/shr_64.o" //go:cgo_import_dynamic libc_chdir chdir "libc.a/shr_64.o" //go:cgo_import_dynamic libc_chroot chroot "libc.a/shr_64.o" //go:cgo_import_dynamic libc_close close "libc.a/shr_64.o" //go:cgo_import_dynamic libc_dup dup "libc.a/shr_64.o" //go:cgo_import_dynamic libc_exit exit "libc.a/shr_64.o" //go:cgo_import_dynamic libc_faccessat faccessat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fchdir fchdir "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fchmod fchmod "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fchmodat fchmodat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fchownat fchownat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fdatasync fdatasync "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fsync fsync "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpgid getpgid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpgrp getpgrp "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpid getpid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getppid getppid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpriority getpriority "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getrusage getrusage "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getsid getsid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_kill kill "libc.a/shr_64.o" //go:cgo_import_dynamic libc_syslog syslog "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mkdir mkdir "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mkdirat mkdirat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mkfifo mkfifo "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mknod mknod "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mknodat mknodat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_nanosleep nanosleep "libc.a/shr_64.o" //go:cgo_import_dynamic libc_open64 open64 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_openat openat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_read read "libc.a/shr_64.o" //go:cgo_import_dynamic libc_readlink readlink "libc.a/shr_64.o" //go:cgo_import_dynamic libc_renameat renameat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setdomainname setdomainname "libc.a/shr_64.o" //go:cgo_import_dynamic libc_sethostname sethostname "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setpgid setpgid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setsid setsid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_settimeofday settimeofday "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setuid setuid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setgid setgid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setpriority setpriority "libc.a/shr_64.o" //go:cgo_import_dynamic libc_statx statx "libc.a/shr_64.o" //go:cgo_import_dynamic libc_sync sync "libc.a/shr_64.o" //go:cgo_import_dynamic libc_times times "libc.a/shr_64.o" //go:cgo_import_dynamic libc_umask umask "libc.a/shr_64.o" //go:cgo_import_dynamic libc_uname uname "libc.a/shr_64.o" //go:cgo_import_dynamic libc_unlink unlink "libc.a/shr_64.o" //go:cgo_import_dynamic libc_unlinkat unlinkat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_ustat ustat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_write write "libc.a/shr_64.o" //go:cgo_import_dynamic libc_dup2 dup2 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_posix_fadvise64 posix_fadvise64 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fchown fchown "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fstat fstat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fstatat fstatat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_fstatfs fstatfs "libc.a/shr_64.o" //go:cgo_import_dynamic libc_ftruncate ftruncate "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getegid getegid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_geteuid geteuid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getgid getgid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getuid getuid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_lchown lchown "libc.a/shr_64.o" //go:cgo_import_dynamic libc_listen listen "libc.a/shr_64.o" //go:cgo_import_dynamic libc_lstat lstat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_pause pause "libc.a/shr_64.o" //go:cgo_import_dynamic libc_pread64 pread64 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_pwrite64 pwrite64 "libc.a/shr_64.o" //go:cgo_import_dynamic libc_select select "libc.a/shr_64.o" //go:cgo_import_dynamic libc_pselect pselect "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setregid setregid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setreuid setreuid "libc.a/shr_64.o" //go:cgo_import_dynamic libc_shutdown shutdown "libc.a/shr_64.o" //go:cgo_import_dynamic libc_splice splice "libc.a/shr_64.o" //go:cgo_import_dynamic libc_stat stat "libc.a/shr_64.o" //go:cgo_import_dynamic libc_statfs statfs "libc.a/shr_64.o" //go:cgo_import_dynamic libc_truncate truncate "libc.a/shr_64.o" //go:cgo_import_dynamic libc_bind bind "libc.a/shr_64.o" //go:cgo_import_dynamic libc_connect connect "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getgroups getgroups "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setgroups setgroups "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getsockopt getsockopt "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setsockopt setsockopt "libc.a/shr_64.o" //go:cgo_import_dynamic libc_socket socket "libc.a/shr_64.o" //go:cgo_import_dynamic libc_socketpair socketpair "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getpeername getpeername "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getsockname getsockname "libc.a/shr_64.o" //go:cgo_import_dynamic libc_recvfrom recvfrom "libc.a/shr_64.o" //go:cgo_import_dynamic libc_sendto sendto "libc.a/shr_64.o" //go:cgo_import_dynamic libc_nrecvmsg nrecvmsg "libc.a/shr_64.o" //go:cgo_import_dynamic libc_nsendmsg nsendmsg "libc.a/shr_64.o" //go:cgo_import_dynamic libc_munmap munmap "libc.a/shr_64.o" //go:cgo_import_dynamic libc_madvise madvise "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mprotect mprotect "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mlock mlock "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mlockall mlockall "libc.a/shr_64.o" //go:cgo_import_dynamic libc_msync msync "libc.a/shr_64.o" //go:cgo_import_dynamic libc_munlock munlock "libc.a/shr_64.o" //go:cgo_import_dynamic libc_munlockall munlockall "libc.a/shr_64.o" //go:cgo_import_dynamic libc_pipe pipe "libc.a/shr_64.o" //go:cgo_import_dynamic libc_poll poll "libc.a/shr_64.o" //go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.a/shr_64.o" //go:cgo_import_dynamic libc_time time "libc.a/shr_64.o" //go:cgo_import_dynamic libc_utime utime "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o" //go:cgo_import_dynamic libc_umount umount "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getrlimit getrlimit "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setrlimit setrlimit "libc.a/shr_64.o" //go:cgo_import_dynamic libc_lseek lseek "libc.a/shr_64.o" //go:cgo_import_dynamic libc_mmap64 mmap64 "libc.a/shr_64.o" //go:linkname libc_utimes libc_utimes //go:linkname libc_utimensat libc_utimensat //go:linkname libc_getcwd libc_getcwd //go:linkname libc_accept libc_accept //go:linkname libc_getdirent libc_getdirent //go:linkname libc_wait4 libc_wait4 //go:linkname libc_ioctl libc_ioctl //go:linkname libc_fcntl libc_fcntl //go:linkname libc_acct libc_acct //go:linkname libc_chdir libc_chdir //go:linkname libc_chroot libc_chroot //go:linkname libc_close libc_close //go:linkname libc_dup libc_dup //go:linkname libc_exit libc_exit //go:linkname libc_faccessat libc_faccessat //go:linkname libc_fchdir libc_fchdir //go:linkname libc_fchmod libc_fchmod //go:linkname libc_fchmodat libc_fchmodat //go:linkname libc_fchownat libc_fchownat //go:linkname libc_fdatasync libc_fdatasync //go:linkname libc_fsync libc_fsync //go:linkname libc_getpgid libc_getpgid //go:linkname libc_getpgrp libc_getpgrp //go:linkname libc_getpid libc_getpid //go:linkname libc_getppid libc_getppid //go:linkname libc_getpriority libc_getpriority //go:linkname libc_getrusage libc_getrusage //go:linkname libc_getsid libc_getsid //go:linkname libc_kill libc_kill //go:linkname libc_syslog libc_syslog //go:linkname libc_mkdir libc_mkdir //go:linkname libc_mkdirat libc_mkdirat //go:linkname libc_mkfifo libc_mkfifo //go:linkname libc_mknod libc_mknod //go:linkname libc_mknodat libc_mknodat //go:linkname libc_nanosleep libc_nanosleep //go:linkname libc_open64 libc_open64 //go:linkname libc_openat libc_openat //go:linkname libc_read libc_read //go:linkname libc_readlink libc_readlink //go:linkname libc_renameat libc_renameat //go:linkname libc_setdomainname libc_setdomainname //go:linkname libc_sethostname libc_sethostname //go:linkname libc_setpgid libc_setpgid //go:linkname libc_setsid libc_setsid //go:linkname libc_settimeofday libc_settimeofday //go:linkname libc_setuid libc_setuid //go:linkname libc_setgid libc_setgid //go:linkname libc_setpriority libc_setpriority //go:linkname libc_statx libc_statx //go:linkname libc_sync libc_sync //go:linkname libc_times libc_times //go:linkname libc_umask libc_umask //go:linkname libc_uname libc_uname //go:linkname libc_unlink libc_unlink //go:linkname libc_unlinkat libc_unlinkat //go:linkname libc_ustat libc_ustat //go:linkname libc_write libc_write //go:linkname libc_dup2 libc_dup2 //go:linkname libc_posix_fadvise64 libc_posix_fadvise64 //go:linkname libc_fchown libc_fchown //go:linkname libc_fstat libc_fstat //go:linkname libc_fstatat libc_fstatat //go:linkname libc_fstatfs libc_fstatfs //go:linkname libc_ftruncate libc_ftruncate //go:linkname libc_getegid libc_getegid //go:linkname libc_geteuid libc_geteuid //go:linkname libc_getgid libc_getgid //go:linkname libc_getuid libc_getuid //go:linkname libc_lchown libc_lchown //go:linkname libc_listen libc_listen //go:linkname libc_lstat libc_lstat //go:linkname libc_pause libc_pause //go:linkname libc_pread64 libc_pread64 //go:linkname libc_pwrite64 libc_pwrite64 //go:linkname libc_select libc_select //go:linkname libc_pselect libc_pselect //go:linkname libc_setregid libc_setregid //go:linkname libc_setreuid libc_setreuid //go:linkname libc_shutdown libc_shutdown //go:linkname libc_splice libc_splice //go:linkname libc_stat libc_stat //go:linkname libc_statfs libc_statfs //go:linkname libc_truncate libc_truncate //go:linkname libc_bind libc_bind //go:linkname libc_connect libc_connect //go:linkname libc_getgroups libc_getgroups //go:linkname libc_setgroups libc_setgroups //go:linkname libc_getsockopt libc_getsockopt //go:linkname libc_setsockopt libc_setsockopt //go:linkname libc_socket libc_socket //go:linkname libc_socketpair libc_socketpair //go:linkname libc_getpeername libc_getpeername //go:linkname libc_getsockname libc_getsockname //go:linkname libc_recvfrom libc_recvfrom //go:linkname libc_sendto libc_sendto //go:linkname libc_nrecvmsg libc_nrecvmsg //go:linkname libc_nsendmsg libc_nsendmsg //go:linkname libc_munmap libc_munmap //go:linkname libc_madvise libc_madvise //go:linkname libc_mprotect libc_mprotect //go:linkname libc_mlock libc_mlock //go:linkname libc_mlockall libc_mlockall //go:linkname libc_msync libc_msync //go:linkname libc_munlock libc_munlock //go:linkname libc_munlockall libc_munlockall //go:linkname libc_pipe libc_pipe //go:linkname libc_poll libc_poll //go:linkname libc_gettimeofday libc_gettimeofday //go:linkname libc_time libc_time //go:linkname libc_utime libc_utime //go:linkname libc_getsystemcfg libc_getsystemcfg //go:linkname libc_umount libc_umount //go:linkname libc_getrlimit libc_getrlimit //go:linkname libc_setrlimit libc_setrlimit //go:linkname libc_lseek libc_lseek //go:linkname libc_mmap64 libc_mmap64 type syscallFunc uintptr var ( libc_utimes, libc_utimensat, libc_getcwd, libc_accept, libc_getdirent, libc_wait4, libc_ioctl, libc_fcntl, libc_acct, libc_chdir, libc_chroot, libc_close, libc_dup, libc_exit, libc_faccessat, libc_fchdir, libc_fchmod, libc_fchmodat, libc_fchownat, libc_fdatasync, libc_fsync, libc_getpgid, libc_getpgrp, libc_getpid, libc_getppid, libc_getpriority, libc_getrusage, libc_getsid, libc_kill, libc_syslog, libc_mkdir, libc_mkdirat, libc_mkfifo, libc_mknod, libc_mknodat, libc_nanosleep, libc_open64, libc_openat, libc_read, libc_readlink, libc_renameat, libc_setdomainname, libc_sethostname, libc_setpgid, libc_setsid, libc_settimeofday, libc_setuid, libc_setgid, libc_setpriority, libc_statx, libc_sync, libc_times, libc_umask, libc_uname, libc_unlink, libc_unlinkat, libc_ustat, libc_write, libc_dup2, libc_posix_fadvise64, libc_fchown, libc_fstat, libc_fstatat, libc_fstatfs, libc_ftruncate, libc_getegid, libc_geteuid, libc_getgid, libc_getuid, libc_lchown, libc_listen, libc_lstat, libc_pause, libc_pread64, libc_pwrite64, libc_select, libc_pselect, libc_setregid, libc_setreuid, libc_shutdown, libc_splice, libc_stat, libc_statfs, libc_truncate, libc_bind, libc_connect, libc_getgroups, libc_setgroups, libc_getsockopt, libc_setsockopt, libc_socket, libc_socketpair, libc_getpeername, libc_getsockname, libc_recvfrom, libc_sendto, libc_nrecvmsg, libc_nsendmsg, libc_munmap, libc_madvise, libc_mprotect, libc_mlock, libc_mlockall, libc_msync, libc_munlock, libc_munlockall, libc_pipe, libc_poll, libc_gettimeofday, libc_time, libc_utime, libc_getsystemcfg, libc_umount, libc_getrlimit, libc_setrlimit, libc_lseek, libc_mmap64 syscallFunc ) // Implemented in runtime/syscall_aix.go. func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callutimes(_p0 uintptr, times uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_utimes)), 2, _p0, times, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callutimensat(dirfd int, _p0 uintptr, times uintptr, flag int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_utimensat)), 4, uintptr(dirfd), _p0, times, uintptr(flag), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetcwd(_p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getcwd)), 2, _p0, uintptr(_lenp0), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callaccept(s int, rsa uintptr, addrlen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_accept)), 3, uintptr(s), rsa, addrlen, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetdirent(fd int, _p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getdirent)), 3, uintptr(fd), _p0, uintptr(_lenp0), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callwait4(pid int, status uintptr, options int, rusage uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_wait4)), 4, uintptr(pid), status, uintptr(options), rusage, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callioctl(fd int, req int, arg uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_ioctl)), 3, uintptr(fd), uintptr(req), arg, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfcntl(fd uintptr, cmd int, arg uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fcntl)), 3, fd, uintptr(cmd), arg, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callacct(_p0 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_acct)), 1, _p0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callchdir(_p0 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_chdir)), 1, _p0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callchroot(_p0 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_chroot)), 1, _p0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callclose(fd int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_close)), 1, uintptr(fd), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calldup(oldfd int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_dup)), 1, uintptr(oldfd), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callexit(code int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_exit)), 1, uintptr(code), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfaccessat(dirfd int, _p0 uintptr, mode uint32, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_faccessat)), 4, uintptr(dirfd), _p0, uintptr(mode), uintptr(flags), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfchdir(fd int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fchdir)), 1, uintptr(fd), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfchmod(fd int, mode uint32) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fchmod)), 2, uintptr(fd), uintptr(mode), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfchmodat(dirfd int, _p0 uintptr, mode uint32, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fchmodat)), 4, uintptr(dirfd), _p0, uintptr(mode), uintptr(flags), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfchownat(dirfd int, _p0 uintptr, uid int, gid int, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fchownat)), 5, uintptr(dirfd), _p0, uintptr(uid), uintptr(gid), uintptr(flags), 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfdatasync(fd int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fdatasync)), 1, uintptr(fd), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfsync(fd int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fsync)), 1, uintptr(fd), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetpgid(pid int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetpgrp() (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getpgrp)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetpid() (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getpid)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetppid() (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getppid)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetpriority(which int, who int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getpriority)), 2, uintptr(which), uintptr(who), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetrusage(who int, rusage uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getrusage)), 2, uintptr(who), rusage, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetsid(pid int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getsid)), 1, uintptr(pid), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callkill(pid int, sig int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_kill)), 2, uintptr(pid), uintptr(sig), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsyslog(typ int, _p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_syslog)), 3, uintptr(typ), _p0, uintptr(_lenp0), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmkdir(dirfd int, _p0 uintptr, mode uint32) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mkdir)), 3, uintptr(dirfd), _p0, uintptr(mode), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmkdirat(dirfd int, _p0 uintptr, mode uint32) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mkdirat)), 3, uintptr(dirfd), _p0, uintptr(mode), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmkfifo(_p0 uintptr, mode uint32) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mkfifo)), 2, _p0, uintptr(mode), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmknod(_p0 uintptr, mode uint32, dev int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mknod)), 3, _p0, uintptr(mode), uintptr(dev), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmknodat(dirfd int, _p0 uintptr, mode uint32, dev int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mknodat)), 4, uintptr(dirfd), _p0, uintptr(mode), uintptr(dev), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callnanosleep(time uintptr, leftover uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_nanosleep)), 2, time, leftover, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callopen64(_p0 uintptr, mode int, perm uint32) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_open64)), 3, _p0, uintptr(mode), uintptr(perm), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callopenat(dirfd int, _p0 uintptr, flags int, mode uint32) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_openat)), 4, uintptr(dirfd), _p0, uintptr(flags), uintptr(mode), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callread(fd int, _p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_read)), 3, uintptr(fd), _p0, uintptr(_lenp0), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callreadlink(_p0 uintptr, _p1 uintptr, _lenp1 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_readlink)), 3, _p0, _p1, uintptr(_lenp1), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callrenameat(olddirfd int, _p0 uintptr, newdirfd int, _p1 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_renameat)), 4, uintptr(olddirfd), _p0, uintptr(newdirfd), _p1, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetdomainname(_p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_setdomainname)), 2, _p0, uintptr(_lenp0), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsethostname(_p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_sethostname)), 2, _p0, uintptr(_lenp0), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetpgid(pid int, pgid int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setpgid)), 2, uintptr(pid), uintptr(pgid), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetsid() (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setsid)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsettimeofday(tv uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_settimeofday)), 1, tv, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetuid(uid int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_setuid)), 1, uintptr(uid), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetgid(uid int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_setgid)), 1, uintptr(uid), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetpriority(which int, who int, prio int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_setpriority)), 3, uintptr(which), uintptr(who), uintptr(prio), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callstatx(dirfd int, _p0 uintptr, flags int, mask int, stat uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_statx)), 5, uintptr(dirfd), _p0, uintptr(flags), uintptr(mask), stat, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsync() (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_sync)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calltimes(tms uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_times)), 1, tms, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callumask(mask int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_umask)), 1, uintptr(mask), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calluname(buf uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_uname)), 1, buf, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callunlink(_p0 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_unlink)), 1, _p0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callunlinkat(dirfd int, _p0 uintptr, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_unlinkat)), 3, uintptr(dirfd), _p0, uintptr(flags), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callustat(dev int, ubuf uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_ustat)), 2, uintptr(dev), ubuf, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callwrite(fd int, _p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_write)), 3, uintptr(fd), _p0, uintptr(_lenp0), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calldup2(oldfd int, newfd int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_dup2)), 2, uintptr(oldfd), uintptr(newfd), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callposix_fadvise64(fd int, offset int64, length int64, advice int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_posix_fadvise64)), 4, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfchown(fd int, uid int, gid int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fchown)), 3, uintptr(fd), uintptr(uid), uintptr(gid), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfstat(fd int, stat uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fstat)), 2, uintptr(fd), stat, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfstatat(dirfd int, _p0 uintptr, stat uintptr, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fstatat)), 4, uintptr(dirfd), _p0, stat, uintptr(flags), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callfstatfs(fd int, buf uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_fstatfs)), 2, uintptr(fd), buf, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callftruncate(fd int, length int64) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_ftruncate)), 2, uintptr(fd), uintptr(length), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetegid() (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getegid)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgeteuid() (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_geteuid)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetgid() (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getgid)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetuid() (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getuid)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calllchown(_p0 uintptr, uid int, gid int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_lchown)), 3, _p0, uintptr(uid), uintptr(gid), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calllisten(s int, n int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_listen)), 2, uintptr(s), uintptr(n), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calllstat(_p0 uintptr, stat uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_lstat)), 2, _p0, stat, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callpause() (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_pause)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callpread64(fd int, _p0 uintptr, _lenp0 int, offset int64) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_pread64)), 4, uintptr(fd), _p0, uintptr(_lenp0), uintptr(offset), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callpwrite64(fd int, _p0 uintptr, _lenp0 int, offset int64) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_pwrite64)), 4, uintptr(fd), _p0, uintptr(_lenp0), uintptr(offset), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callselect(nfd int, r uintptr, w uintptr, e uintptr, timeout uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_select)), 5, uintptr(nfd), r, w, e, timeout, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callpselect(nfd int, r uintptr, w uintptr, e uintptr, timeout uintptr, sigmask uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_pselect)), 6, uintptr(nfd), r, w, e, timeout, sigmask) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetregid(rgid int, egid int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setregid)), 2, uintptr(rgid), uintptr(egid), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetreuid(ruid int, euid int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setreuid)), 2, uintptr(ruid), uintptr(euid), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callshutdown(fd int, how int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_shutdown)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsplice(rfd int, roff uintptr, wfd int, woff uintptr, len int, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_splice)), 6, uintptr(rfd), roff, uintptr(wfd), woff, uintptr(len), uintptr(flags)) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callstat(_p0 uintptr, statptr uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_stat)), 2, _p0, statptr, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callstatfs(_p0 uintptr, buf uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_statfs)), 2, _p0, buf, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calltruncate(_p0 uintptr, length int64) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_truncate)), 2, _p0, uintptr(length), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callbind(s int, addr uintptr, addrlen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_bind)), 3, uintptr(s), addr, addrlen, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callconnect(s int, addr uintptr, addrlen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_connect)), 3, uintptr(s), addr, addrlen, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetgroups(n int, list uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getgroups)), 2, uintptr(n), list, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetgroups(n int, list uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setgroups)), 2, uintptr(n), list, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetsockopt(s int, level int, name int, val uintptr, vallen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), val, vallen, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetsockopt(s int, level int, name int, val uintptr, vallen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_setsockopt)), 5, uintptr(s), uintptr(level), uintptr(name), val, vallen, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsocket(domain int, typ int, proto int) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_socket)), 3, uintptr(domain), uintptr(typ), uintptr(proto), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsocketpair(domain int, typ int, proto int, fd uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_socketpair)), 4, uintptr(domain), uintptr(typ), uintptr(proto), fd, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetpeername(fd int, rsa uintptr, addrlen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getpeername)), 3, uintptr(fd), rsa, addrlen, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetsockname(fd int, rsa uintptr, addrlen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getsockname)), 3, uintptr(fd), rsa, addrlen, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callrecvfrom(fd int, _p0 uintptr, _lenp0 int, flags int, from uintptr, fromlen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_recvfrom)), 6, uintptr(fd), _p0, uintptr(_lenp0), uintptr(flags), from, fromlen) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsendto(s int, _p0 uintptr, _lenp0 int, flags int, to uintptr, addrlen uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_sendto)), 6, uintptr(s), _p0, uintptr(_lenp0), uintptr(flags), to, addrlen) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callnrecvmsg(s int, msg uintptr, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_nrecvmsg)), 3, uintptr(s), msg, uintptr(flags), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callnsendmsg(s int, msg uintptr, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_nsendmsg)), 3, uintptr(s), msg, uintptr(flags), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmunmap(addr uintptr, length uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_munmap)), 2, addr, length, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmadvise(_p0 uintptr, _lenp0 int, advice int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_madvise)), 3, _p0, uintptr(_lenp0), uintptr(advice), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmprotect(_p0 uintptr, _lenp0 int, prot int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mprotect)), 3, _p0, uintptr(_lenp0), uintptr(prot), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmlock(_p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mlock)), 2, _p0, uintptr(_lenp0), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmlockall(flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mlockall)), 1, uintptr(flags), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmsync(_p0 uintptr, _lenp0 int, flags int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_msync)), 3, _p0, uintptr(_lenp0), uintptr(flags), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmunlock(_p0 uintptr, _lenp0 int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_munlock)), 2, _p0, uintptr(_lenp0), 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmunlockall() (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_munlockall)), 0, 0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callpipe(p uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_pipe)), 1, p, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callpoll(fds uintptr, nfds int, timeout int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_poll)), 3, fds, uintptr(nfds), uintptr(timeout), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgettimeofday(tv uintptr, tzp uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_gettimeofday)), 2, tv, tzp, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calltime(t uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_time)), 1, t, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callutime(_p0 uintptr, buf uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_utime)), 2, _p0, buf, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetsystemcfg(label int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callumount(_p0 uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_umount)), 1, _p0, 0, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callgetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getrlimit)), 2, uintptr(resource), rlim, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callsetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_setrlimit)), 2, uintptr(resource), rlim, 0, 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func calllseek(fd int, offset int64, whence int) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_lseek)), 3, uintptr(fd), uintptr(offset), uintptr(whence), 0, 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func callmmap64(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (r1 uintptr, e1 Errno) { r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_mmap64)), 6, addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) return }
{ "pile_set_name": "Github" }
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import pytest from urllib.parse import unquote from pages.firefox.accounts import FirefoxAccountsPage @pytest.mark.nondestructive def test_account_form(base_url, selenium): page = FirefoxAccountsPage(selenium, base_url, params='').open() page.join_firefox_form.type_email('[email protected]') page.join_firefox_form.click_continue() url = unquote(selenium.current_url) assert '[email protected]' in url, 'Email address is not in URL' @pytest.mark.nondestructive @pytest.mark.skip_if_not_firefox(reason='Signed-in state is shown only to Firefox users.') def test_signed_in_call_to_action(base_url, selenium): page = FirefoxAccountsPage(selenium, base_url, params='?signed-in=true').open() assert not page.join_firefox_form.is_displayed assert page.is_firefox_monitor_button_displayed
{ "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. */ 'use strict'; // tslint:disable no-unused-expression import * as vscode from 'vscode'; import * as path from 'path'; import * as chai from 'chai'; import * as sinon from 'sinon'; import * as sinonChai from 'sinon-chai'; import { TestUtil } from '../TestUtil'; import { PackageTreeItem } from '../../extension/explorer/model/PackageTreeItem'; import { PackageRegistry } from '../../extension/registries/PackageRegistry'; import { PackageRegistryEntry } from '../../extension/registries/PackageRegistryEntry'; import { BlockchainTreeItem } from '../../extension/explorer/model/BlockchainTreeItem'; import { BlockchainPackageExplorerProvider } from '../../extension/explorer/packageExplorer'; import { UserInputUtil } from '../../extension/commands/UserInputUtil'; import { VSCodeBlockchainOutputAdapter } from '../../extension/logging/VSCodeBlockchainOutputAdapter'; import { LogType } from 'ibm-blockchain-platform-common'; import { ExtensionCommands } from '../../ExtensionCommands'; import { SettingConfigurations } from '../../configurations'; import { ExtensionUtil } from '../../extension/util/ExtensionUtil'; chai.should(); chai.use(sinonChai); describe('DeleteSmartContractPackageCommand', () => { let showConfirmationWarningMessageStub: sinon.SinonStub; const TEST_EXTENSION_DIRECTORY: string = path.join(path.dirname(__dirname), '../../test/data'); let mySandBox: sinon.SinonSandbox; before(async () => { mySandBox = sinon.createSandbox(); await TestUtil.setupTests(mySandBox); await vscode.workspace.getConfiguration().update(SettingConfigurations.EXTENSION_DIRECTORY, TEST_EXTENSION_DIRECTORY, vscode.ConfigurationTarget.Global); }); describe('deleteSmartContractPackage', () => { let _package: PackageRegistryEntry; let logStub: sinon.SinonStub; beforeEach(async () => { mySandBox.restore(); showConfirmationWarningMessageStub = mySandBox.stub(UserInputUtil, 'showConfirmationWarningMessage').resolves(true); const packagesStub: sinon.SinonStub = mySandBox.stub(PackageRegistry.instance(), 'getAll'); _package = new PackageRegistryEntry(); _package.name = 'myPackage'; _package.path = 'myPath'; _package.version = '0.0.1'; packagesStub.resolves([_package]); logStub = mySandBox.stub(VSCodeBlockchainOutputAdapter.instance(), 'log').resolves(); }); afterEach(async () => { mySandBox.restore(); }); it("should test a 'smart contract package' can be deleted from the command", async () => { const blockchainPackageExplorerProvider: BlockchainPackageExplorerProvider = ExtensionUtil.getBlockchainPackageExplorerProvider(); const onDidChangeTreeDataSpy: sinon.SinonSpy = mySandBox.spy(blockchainPackageExplorerProvider['_onDidChangeTreeData'], 'fire'); mySandBox.stub(UserInputUtil, 'showSmartContractPackagesQuickPickBox').resolves([{ label: '[email protected]', data: _package }]); // Execute the delete 'smart contract package' command const deleteStub: sinon.SinonStub = mySandBox.stub(PackageRegistry.instance(), 'delete').resolves(); await vscode.commands.executeCommand(ExtensionCommands.DELETE_SMART_CONTRACT); onDidChangeTreeDataSpy.should.have.been.called; deleteStub.should.have.been.calledOnceWithExactly(_package); logStub.getCall(0).should.have.been.calledWithExactly(LogType.INFO, undefined, `deleteSmartContractPackage`); logStub.getCall(1).should.have.been.calledWithExactly(LogType.SUCCESS, `Successfully deleted ${_package.name} package`); }); it(`should test multiple 'smart contract packages' can be deleted from the command`, async () => { const blockchainPackageExplorerProvider: BlockchainPackageExplorerProvider = ExtensionUtil.getBlockchainPackageExplorerProvider(); const onDidChangeTreeDataSpy: sinon.SinonSpy = mySandBox.spy(blockchainPackageExplorerProvider['_onDidChangeTreeData'], 'fire'); const packages: Array<PackageRegistryEntry> = await PackageRegistry.instance().getAll(); const dataOne: PackageRegistryEntry = packages[0]; const dataTwo: PackageRegistryEntry = packages[1]; mySandBox.stub(UserInputUtil, 'showSmartContractPackagesQuickPickBox').resolves([{ label: '[email protected]', data: dataOne }, { label: '[email protected]', data: dataTwo }]); // Execute the delete 'smart contract package' command const deleteStub: sinon.SinonStub = mySandBox.stub(PackageRegistry.instance(), 'delete').resolves(); await vscode.commands.executeCommand(ExtensionCommands.DELETE_SMART_CONTRACT); onDidChangeTreeDataSpy.should.have.been.called; deleteStub.should.have.been.calledTwice; deleteStub.should.have.been.calledWithExactly(dataOne); deleteStub.should.have.been.calledWithExactly(dataTwo); logStub.getCall(0).should.have.been.calledWithExactly(LogType.INFO, undefined, `deleteSmartContractPackage`); logStub.getCall(1).should.have.been.calledWithExactly(LogType.SUCCESS, `Successfully deleted packages`); }); it("should test a 'smart contract package' can be deleted from tree", async () => { const blockchainPackageExplorerProvider: BlockchainPackageExplorerProvider = ExtensionUtil.getBlockchainPackageExplorerProvider(); const initialPackages: Array<BlockchainTreeItem> = await blockchainPackageExplorerProvider.getChildren(); const onDidChangeTreeDataSpy: sinon.SinonSpy = mySandBox.spy(blockchainPackageExplorerProvider['_onDidChangeTreeData'], 'fire'); // This will be the 'DeleteThisDirectory' as its the first package alphabetically const packageToDelete: PackageTreeItem = initialPackages[0] as PackageTreeItem; const deleteStub: sinon.SinonStub = mySandBox.stub(PackageRegistry.instance(), 'delete').resolves(); await vscode.commands.executeCommand(ExtensionCommands.DELETE_SMART_CONTRACT, packageToDelete); onDidChangeTreeDataSpy.should.have.been.called; deleteStub.should.have.been.calledOnceWithExactly(packageToDelete.packageEntry); logStub.getCall(0).should.have.been.calledWithExactly(LogType.INFO, undefined, `deleteSmartContractPackage`); logStub.getCall(1).should.have.been.calledWithExactly(LogType.SUCCESS, `Successfully deleted ${_package.name} package`); }); it(`should test deleting smart contract package can be cancelled`, async () => { const blockchainPackageExplorerProvider: BlockchainPackageExplorerProvider = ExtensionUtil.getBlockchainPackageExplorerProvider(); const initialPackages: Array<BlockchainTreeItem> = await blockchainPackageExplorerProvider.getChildren(); const initialLength: number = initialPackages.length; mySandBox.stub(UserInputUtil, 'showSmartContractPackagesQuickPickBox').resolves(undefined); await vscode.commands.executeCommand(ExtensionCommands.DELETE_SMART_CONTRACT); const newPackageList: Array<BlockchainTreeItem> = await blockchainPackageExplorerProvider.getChildren(); newPackageList.length.should.equal(initialLength); newPackageList.should.deep.equal(initialPackages); logStub.should.have.been.calledOnceWithExactly(LogType.INFO, undefined, `deleteSmartContractPackage`); }); it('should stop if user doesn\'t select to continue', async () => { mySandBox.stub(UserInputUtil, 'showSmartContractPackagesQuickPickBox').resolves([{ label: '[email protected]', data: _package }]); showConfirmationWarningMessageStub.resolves(false); // Execute the delete 'smart contract package' command const deleteSpy: sinon.SinonSpy = mySandBox.spy(PackageRegistry.instance(), 'delete'); await vscode.commands.executeCommand(ExtensionCommands.DELETE_SMART_CONTRACT); deleteSpy.should.not.have.been.called; logStub.should.have.been.calledOnceWithExactly(LogType.INFO, undefined, `deleteSmartContractPackage`); }); it('should stop if user doesn\'t pass any smart contract packages to delete', async () => { mySandBox.stub(UserInputUtil, 'showSmartContractPackagesQuickPickBox').resolves([]); // Execute the delete 'smart contract package' command const deleteSpy: sinon.SinonSpy = mySandBox.spy(PackageRegistry.instance(), 'delete'); await vscode.commands.executeCommand(ExtensionCommands.DELETE_SMART_CONTRACT); deleteSpy.should.not.have.been.called; logStub.should.have.been.calledOnceWithExactly(LogType.INFO, undefined, `deleteSmartContractPackage`); }); }); });
{ "pile_set_name": "Github" }
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "lid_gid_key_comparator.h" #include "i_simple_document_meta_store.h" #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/common/idocumentmetastore.h> #include <vespa/searchlib/common/serialnum.h> #include <vespa/vespalib/btree/btree.h> #include <vespa/vespalib/btree/btreenodeallocator.h> namespace proton::documentmetastore { class OperationListener; } namespace proton { /** * Interface used to manage the documents that are contained * in a document sub database with related meta data. * * A document meta store will have storage of <lid, meta data> pairs * (local document id, meta data (including global document id)) and * mapping from lid -> meta data and gid -> lid. **/ struct IDocumentMetaStore : public search::IDocumentMetaStore, public ISimpleDocumentMetaStore { using search::IDocumentMetaStore::DocId; using search::IDocumentMetaStore::GlobalId; using search::IDocumentMetaStore::BucketId; using search::IDocumentMetaStore::Timestamp; // Typedef for the tree used to map from gid -> lid // Lids are stored as keys in the tree, sorted by their gid counterpart. // The LidGidKeyComparator class maps from lids -> metadata by using the metadata store. // TODO(geirst): move this typedef and iterator functions away from this interface. typedef vespalib::btree::BTree<DocId, vespalib::btree::BTreeNoLeafData, vespalib::btree::NoAggregated, const documentmetastore::LidGidKeyComparator &> TreeType; typedef TreeType::Iterator Iterator; typedef std::shared_ptr<IDocumentMetaStore> SP; virtual ~IDocumentMetaStore() {} /** * Constructs a new underlying free list for lids. * This should be done after a load() and calls to put() and remove(). **/ virtual void constructFreeList() = 0; virtual Iterator begin() const = 0; virtual Iterator lowerBound(const BucketId &bucketId) const = 0; virtual Iterator upperBound(const BucketId &bucketId) const = 0; virtual Iterator lowerBound(const GlobalId &gid) const = 0; virtual Iterator upperBound(const GlobalId &gid) const = 0; virtual void getLids(const BucketId &bucketId, std::vector<DocId> &lids) = 0; /* * Called by document db executor to hold unblocking of shrinking of lid * space after all outstanding holdLid() operations at the time of * compactLidSpace() call have been completed. */ virtual void holdUnblockShrinkLidSpace() = 0; // Functions that are also defined search::AttributeVector virtual void commit(search::SerialNum firstSerialNum, search::SerialNum lastSerialNum) = 0; virtual void removeAllOldGenerations() = 0; virtual bool canShrinkLidSpace() const = 0; virtual search::SerialNum getLastSerialNum() const = 0; /* * Adjust committedDocIdLimit downwards and prepare for shrinking * of lid space. * * NOTE: Must call unblockShrinkLidSpace() before lid space can * be shrunk. */ virtual void compactLidSpace(DocId wantedLidLimit) = 0; virtual void set_operation_listener(std::shared_ptr<documentmetastore::OperationListener> op_listener) = 0; }; } // namespace proton
{ "pile_set_name": "Github" }
source ${prefix}/func.sh; menuentry $"File Info (${grubfm_name})" --class info { configfile ${prefix}/rules/generic/info.sh; }
{ "pile_set_name": "Github" }
BEGIN:VCALENDAR CALSCALE:GREGORIAN PRODID:-//Apple Computer\, Inc//iCal 2.0//EN VERSION:2.0 BEGIN:VEVENT UID:C3189C32-1ED0-11D9-A5E0-000A958A3252 DTSTAMP:20041015T171054Z DTSTART;VALUE=DATE:20040222 DTEND;VALUE=DATE:20040223 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=2 SUMMARY:Washington's Birthday (actual) TRANSP:TRANSPARENT END:VEVENT END:VCALENDAR
{ "pile_set_name": "Github" }
<?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> </sectionGroup> </configSections> <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="Teapot.Web" /> </namespaces> </pages> </system.web.webPages.razor> <appSettings> <add key="webpages:Enabled" value="false" /> </appSettings> <system.webServer> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer> </configuration>
{ "pile_set_name": "Github" }
package com.dbflow5.annotation /** * Description: Creates a new database to use in the application. * * * If we specify one DB, then all models do not need to specify a DB. As soon as we specify two, then each * model needs to define what DB it points to. * * * * Models will specify which DB it belongs to, * but they currently can only belong to one DB. * */ @Target(AnnotationTarget.CLASS, AnnotationTarget.FILE) @Retention(AnnotationRetention.SOURCE) annotation class Database( /** * @return The current version of the DB. Increment it to trigger a DB update. */ val version: Int, @Deprecated("use DatabaseConfig.databaseName() to change the name.") val name: String = "", @Deprecated("use DatabaseConfig.extension() to change the extension.") val databaseExtension: String = "", @Deprecated("use DatabaseConfig.inMemoryBuilder() instead.") val inMemory: Boolean = false, /** * @return If true, SQLite will throw exceptions when [ForeignKey] constraints are not respected. * Default is false and will not throw exceptions. */ val foreignKeyConstraintsEnforced: Boolean = false, /** * @return Checks for consistency in the DB, if true it will recopy over the prepackage database. */ val consistencyCheckEnabled: Boolean = false, /** * @return Keeps a backup for whenever the database integrity fails a "PRAGMA quick_check(1)" that will * replace the corrupted DB */ val backupEnabled: Boolean = false, /** * @return Global default insert conflict that can be applied to any table when it leaves * its [ConflictAction] as NONE. */ val insertConflict: ConflictAction = ConflictAction.NONE, /** * @return Global update conflict that can be applied to any table when it leaves its * [ConflictAction] as NONE */ val updateConflict: ConflictAction = ConflictAction.NONE)
{ "pile_set_name": "Github" }
local mapServiceConfigs = asset.localResource("./../../map_service_configs") local globeIdentifier = asset.require("./../../mars").Mars.Identifier local layer = { Identifier = "CTX_Mosaic_Utah", Name = "CTX Mosaic [Utah]", FilePath = mapServiceConfigs .. "/Utah/CTX.wms", BlendMode = "Color" } asset.onInitialize(function () openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer) end) asset.export("layer", layer)
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/ic_launcher_background"/> <foreground android:drawable="@drawable/ic_launcher_foreground"/> </adaptive-icon>
{ "pile_set_name": "Github" }
package org.mockserver.model; import org.mockserver.serialization.ObjectMapperFactory; /** * @author jamesdbloom */ public abstract class ObjectWithJsonToString extends ObjectWithReflectiveEqualsHashCodeToString { private static final String ESCAPED_QUOTE = "\""; @Override public String toString() { try { String valueAsString = ObjectMapperFactory .createObjectMapper(true) .writeValueAsString(this); if (valueAsString.startsWith(ESCAPED_QUOTE) && valueAsString.endsWith(ESCAPED_QUOTE)) { valueAsString = valueAsString.substring(1, valueAsString.length() - 1); } return valueAsString; } catch (Exception e) { return super.toString(); } } }
{ "pile_set_name": "Github" }
using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; using GMap.NET; using GMap.NET.MapProviders; using PokemonGo.RocketAPI.Enums; using PokemonGo.RocketBot.Logic; using PokemonGo.RocketBot.Window.Helpers; using POGOProtos.Enums; namespace PokemonGo.RocketBot.Window.Forms { internal partial class SettingsForm : Form { private const int DefaultZoomLevel = 15; private static readonly string ConfigFolderPath = Path.Combine(Directory.GetCurrentDirectory(), "Config"); private static readonly string AuthFilePath = Path.Combine(ConfigFolderPath, "auth.json"); private static readonly string ConfigFilePath = Path.Combine(ConfigFolderPath, "config.json"); private static readonly string LanguagePath = Path.Combine(ConfigFolderPath, "Translations"); private readonly DeviceHelper _deviceHelper; private readonly List<DeviceInfo> _deviceInfos; private readonly GlobalSettings _setting; private TabPage _tabAdvSettingTab; public SettingsForm(ref GlobalSettings settings) { InitializeComponent(); _setting = settings; _deviceHelper = new DeviceHelper(); _deviceInfos = _deviceHelper.DeviceBucket; foreach ( var pokemon in Enum.GetValues(typeof(PokemonId)).Cast<PokemonId>().Where(id => id != PokemonId.Missingno)) { clbIgnore.Items.Add(pokemon); clbTransfer.Items.Add(pokemon); clbPowerUp.Items.Add(pokemon); clbEvolve.Items.Add(pokemon); } } private void SettingsForm_Load(object sender, EventArgs e) { var languageList = GetLanguageList(); var languageIndex = languageList.IndexOf(_setting.TranslationLanguageCode); cbLanguage.DataSource = languageList; cbLanguage.SelectedIndex = languageIndex == -1 ? 0 : languageIndex; #region Advanced Setting Init //proxy proxyGb.Visible = _setting.EnableAdvancedSettings; //advanced tab _tabAdvSettingTab = tabAdvSetting; enableAdvSettingCb.Checked = _setting.EnableAdvancedSettings; if (!enableAdvSettingCb.Checked) { tabControl.TabPages.Remove(_tabAdvSettingTab); } else { _tabAdvSettingTab.Enabled = true; } #endregion #region Login Type and info authTypeCb.Text = _setting.Auth.AuthType.ToString(); UserLoginBox.Text = _setting.Auth.AuthType == AuthType.Google ? _setting.Auth.GoogleUsername : _setting.Auth.PtcUsername; UserPasswordBox.Text = _setting.Auth.AuthType == AuthType.Google ? _setting.Auth.GooglePassword : _setting.Auth.PtcPassword; //google api GoogleApiBox.Text = _setting.Auth.GoogleApiKey; //proxy useProxyCb.Checked = _setting.Auth.UseProxy; useProxyAuthCb.Checked = _setting.Auth.UseProxy && _setting.Auth.UseProxyAuthentication; ToggleProxyCtrls(); #endregion #region Map Info //use google provider gMapCtrl.MapProvider = GoogleMapProvider.Instance; //get tiles from server only gMapCtrl.Manager.Mode = AccessMode.ServerOnly; //not use proxy GMapProvider.WebProxy = null; //center map on moscow gMapCtrl.Position = new PointLatLng(_setting.DefaultLatitude, _setting.DefaultLongitude); //zoom min/max; default both = 2 gMapCtrl.DragButton = MouseButtons.Left; gMapCtrl.CenterPen = new Pen(Color.Red, 2); gMapCtrl.MinZoom = trackBar.Maximum = 2; gMapCtrl.MaxZoom = trackBar.Maximum = 18; trackBar.Value = DefaultZoomLevel; //set zoom gMapCtrl.Zoom = trackBar.Value; //disable map focus gMapCtrl.DisableFocusOnMouseEnter = true; tbWalkingSpeed.Text = _setting.WalkingSpeedInKilometerPerHour.ToString(CultureInfo.InvariantCulture); #endregion #region Device Info //by default, select one from Necro's device dictionary DeviceIdTb.Text = _setting.Auth.DeviceId; AndroidBoardNameTb.Text = _setting.Auth.AndroidBoardName; AndroidBootloaderTb.Text = _setting.Auth.AndroidBootloader; DeviceBrandTb.Text = _setting.Auth.DeviceBrand; DeviceModelTb.Text = _setting.Auth.DeviceModel; DeviceModelIdentifierTb.Text = _setting.Auth.DeviceModelIdentifier; DeviceModelBootTb.Text = _setting.Auth.DeviceModelBoot; HardwareManufacturerTb.Text = _setting.Auth.HardwareManufacturer; HardwareModelTb.Text = _setting.Auth.HardwareModel; FirmwareBrandTb.Text = _setting.Auth.FirmwareBrand; FirmwareTagsTb.Text = _setting.Auth.FirmwareTags; FirmwareTypeTb.Text = _setting.Auth.FirmwareType; FirmwareFingerprintTb.Text = _setting.Auth.FirmwareFingerprint; deviceTypeCb.SelectedIndex = _setting.Auth.DeviceBrand.ToLower() == "apple" ? 0 : 1; #endregion #region Pokemon Info #region Catch cbCatchPoke.Checked = _setting.CatchPokemon; cbUseEggIncubators.Checked = _setting.UseEggIncubators; tBMaxBerriesToUsePerPokemon.Text = _setting.MaxBerriesToUsePerPokemon.ToString(); tbMaxPokeballsPerPokemon.Text = _setting.MaxPokeballsPerPokemon.ToString(); cbAutoFavoritePokemon.Checked = _setting.AutoFavoritePokemon; tbFavoriteMinIvPercentage.Text = _setting.FavoriteMinIvPercentage.ToString(CultureInfo.InvariantCulture); tbUseBerriesMinCp.Text = _setting.UseBerriesMinCp.ToString(); tbUseBerriesMinIv.Text = _setting.UseBerriesMinIv.ToString(CultureInfo.InvariantCulture); tbUseBerriesBelowCatchProbability.Text = _setting.UseBerriesBelowCatchProbability.ToString(CultureInfo.InvariantCulture); cbUseBerriesOperator.SelectedIndex = _setting.UseBerriesOperator == "and" ? 0 : 1; tbUseGreatBallAboveCp.Text = _setting.UseGreatBallAboveCp.ToString(); tbUseUltraBallAboveCp.Text = _setting.UseUltraBallAboveCp.ToString(); tbUseMasterBallAboveCp.Text = _setting.UseMasterBallAboveCp.ToString(); tbUseGreatBallAboveIv.Text = _setting.UseGreatBallAboveIv.ToString(CultureInfo.InvariantCulture); tbUseUltraBallAboveIv.Text = _setting.UseUltraBallAboveIv.ToString(CultureInfo.InvariantCulture); tbUseGreatBallBelowCatchProbability.Text = _setting.UseGreatBallBelowCatchProbability.ToString(CultureInfo.InvariantCulture); tbUseUltraBallBelowCatchProbability.Text = _setting.UseUltraBallBelowCatchProbability.ToString(CultureInfo.InvariantCulture); tbUseMasterBallBelowCatchProbability.Text = _setting.UseMasterBallBelowCatchProbability.ToString(CultureInfo.InvariantCulture); foreach (var poke in _setting.PokemonsToIgnore) { clbIgnore.SetItemChecked(clbIgnore.FindStringExact(poke.ToString()), true); } #endregion #region Transfer cbPrioritizeIvOverCp.Checked = _setting.PrioritizeIvOverCp; tbKeepMinCp.Text = _setting.KeepMinCp.ToString(); tbKeepMinIV.Text = _setting.KeepMinIvPercentage.ToString(CultureInfo.InvariantCulture); tbKeepMinLvl.Text = _setting.KeepMinLvl.ToString(); cbKeepMinOperator.SelectedIndex = _setting.KeepMinOperator.ToLowerInvariant() == "and" ? 0 : 1; cbTransferWeakPokemon.Checked = _setting.TransferWeakPokemon; cbTransferDuplicatePokemon.Checked = _setting.TransferDuplicatePokemon; cbTransferDuplicatePokemonOnCapture.Checked = _setting.TransferDuplicatePokemonOnCapture; tbKeepMinDuplicatePokemon.Text = _setting.KeepMinDuplicatePokemon.ToString(); cbUseKeepMinLvl.Checked = _setting.UseKeepMinLvl; foreach (var poke in _setting.PokemonsNotToTransfer) { clbTransfer.SetItemChecked(clbTransfer.FindStringExact(poke.ToString()), true); } #endregion #region Powerup //focuse to use filter list _setting.UseLevelUpList = true; cbAutoPowerUp.Checked = _setting.AutomaticallyLevelUpPokemon; cbPowerUpFav.Checked = _setting.OnlyUpgradeFavorites; cbPowerUpType.SelectedIndex = _setting.LevelUpByCPorIv == "iv" ? 0 : 1; cbPowerUpCondiction.SelectedIndex = _setting.UpgradePokemonMinimumStatsOperator == "and" ? 0 : 1; cbPowerUpMinStarDust.Text = _setting.GetMinStarDustForLevelUp.ToString(); tbPowerUpMinIV.Text = _setting.UpgradePokemonIvMinimum.ToString(CultureInfo.InvariantCulture); tbPowerUpMinCP.Text = _setting.UpgradePokemonCpMinimum.ToString(CultureInfo.InvariantCulture); foreach (var poke in _setting.PokemonsToLevelUp) { clbPowerUp.SetItemChecked(clbPowerUp.FindStringExact(poke.ToString()), true); } if (_setting.LevelUpByCPorIv == "iv") { label31.Visible = true; tbPowerUpMinIV.Visible = true; label30.Visible = false; tbPowerUpMinCP.Visible = false; } else { label31.Visible = false; tbPowerUpMinIV.Visible = false; label30.Visible = true; tbPowerUpMinCP.Visible = true; } #endregion #region Evo cbEvoAllAboveIV.Checked = _setting.EvolveAllPokemonAboveIv; tbEvoAboveIV.Text = _setting.EvolveAboveIvValue.ToString(CultureInfo.InvariantCulture); cbEvolveAllPokemonWithEnoughCandy.Checked = _setting.EvolveAllPokemonWithEnoughCandy; cbKeepPokemonsThatCanEvolve.Checked = _setting.KeepPokemonsThatCanEvolve; tbEvolveKeptPokemonsAtStorageUsagePercentage.Text = _setting.EvolveKeptPokemonsAtStorageUsagePercentage.ToString(CultureInfo.InvariantCulture); cbUseLuckyEggsWhileEvolving.Checked = _setting.UseLuckyEggsWhileEvolving; tbUseLuckyEggsMinPokemonAmount.Text = _setting.UseLuckyEggsMinPokemonAmount.ToString(); foreach (var poke in _setting.PokemonsToEvolve) { clbEvolve.SetItemChecked(clbEvolve.FindStringExact(poke.ToString()), true); } #endregion #endregion #region Item Info cbUseLuckyEggConstantly.Checked = _setting.UseLuckyEggConstantly; cbUseIncenseConstantly.Checked = _setting.UseIncenseConstantly; tbTotalAmountOfPokeballsToKeep.Text = _setting.TotalAmountOfPokeballsToKeep.ToString(); tbTotalAmountOfPotionsToKeep.Text = _setting.TotalAmountOfPotionsToKeep.ToString(); tbTotalAmountOfRevivesToKeep.Text = _setting.TotalAmountOfRevivesToKeep.ToString(); tbTotalAmountOfBerriesToKeep.Text = _setting.TotalAmountOfBerriesToKeep.ToString(); cbVerboseRecycling.Checked = _setting.VerboseRecycling; tbRecycleInventoryAtUsagePercentage.Text = _setting.RecycleInventoryAtUsagePercentage.ToString(CultureInfo.InvariantCulture); #endregion #region Advance Settings cbDisableHumanWalking.Checked = _setting.DisableHumanWalking; cbUseWalkingSpeedVariant.Checked = _setting.UseWalkingSpeedVariant; tbWalkingSpeedVariantInKilometerPerHour.Text = _setting.WalkingSpeedVariant.ToString(CultureInfo.InvariantCulture); cbShowWalkingSpeed.Checked = _setting.ShowVariantWalking; tbMaxSpawnLocationOffset.Text = _setting.MaxSpawnLocationOffset.ToString(); tbMaxTravelDistanceInMeters.Text = _setting.MaxTravelDistanceInMeters.ToString(); tbDelayBetweenPlayerActions.Text = _setting.DelayBetweenPlayerActions.ToString(); tbDelayBetweenPokemonCatch.Text = _setting.DelayBetweenPokemonCatch.ToString(); tbDelayBetweenRecycle.Text = _setting.DelayBetweenRecycle.ToString(); cbRandomizeRecycle.Checked = _setting.RandomizeRecycle; tbRandomRecycleValue.Text = _setting.RandomRecycleValue.ToString(); cbEnableHumanizedThrows.Checked = _setting.EnableHumanizedThrows; tbNiceThrowChance.Text = _setting.NiceThrowChance.ToString(); tbGreatThrowChance.Text = _setting.GreatThrowChance.ToString(); tbExcellentThrowChance.Text = _setting.ExcellentThrowChance.ToString(); tbCurveThrowChance.Text = _setting.CurveThrowChance.ToString(); tbForceGreatThrowOverIv.Text = _setting.ForceGreatThrowOverIv.ToString(CultureInfo.InvariantCulture); tbForceExcellentThrowOverIv.Text = _setting.ForceExcellentThrowOverIv.ToString(CultureInfo.InvariantCulture); tbForceGreatThrowOverCp.Text = _setting.ForceGreatThrowOverCp.ToString(); tbForceExcellentThrowOverCp.Text = _setting.ForceExcellentThrowOverCp.ToString(); #endregion } #region Help button for API key protected override void OnLoad(EventArgs e) { var btn = new Button {Size = new Size(25, GoogleApiBox.ClientSize.Height + 2)}; btn.Location = new Point(GoogleApiBox.ClientSize.Width - btn.Width, -1); btn.Cursor = Cursors.Default; btn.Image = ResourceHelper.GetImage("question"); btn.Click += googleapihep_click; GoogleApiBox.Controls.Add(btn); // Send EM_SETMARGINS to prevent text from disappearing underneath the button SendMessage(GoogleApiBox.Handle, 0xd3, (IntPtr) 2, (IntPtr) (btn.Width << 16)); base.OnLoad(e); } private void googleapihep_click(object sender, EventArgs e) { Process.Start("https://developers.google.com/maps/documentation/directions/get-api-key"); } [DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); #endregion #region private methods private static int ConvertStringToInt(string input) { var output = 0; int.TryParse(input, out output); return output; } private static float ConvertStringToFloat(string input) { float output = 0; float.TryParse(input, out output); return output; } private static double ConvertStringToDouble(string input) { double output = 0; double.TryParse(input, out output); return output; } private static List<PokemonId> ConvertClbToList(CheckedListBox input) { return input.CheckedItems.Cast<PokemonId>().ToList(); } /// <summary> /// Get languale list from Translations folder and populate it to combo box /// </summary> private List<string> GetLanguageList() { var languages = new List<string> {"en"}; var langFiles = Directory.GetFiles(LanguagePath, "*.json", SearchOption.TopDirectoryOnly); languages.AddRange(langFiles.Select( langFileName => Path.GetFileNameWithoutExtension(langFileName)?.Replace("translation.", "")) .Where(langCode => langCode != "en")); return languages; } /// <summary> /// Update location lat and lon to textboxes /// </summary> private void UpdateLocationInfo() { //not rounding it, need to have correct position to prevent map drifting tbLatitude.Text = gMapCtrl.Position.Lat.ToString(CultureInfo.InvariantCulture); tbLongitude.Text = gMapCtrl.Position.Lng.ToString(CultureInfo.InvariantCulture); //update trackbar trackBar.Value = (int) Math.Round(gMapCtrl.Zoom); } /// <summary> /// Update map location base on giving lng and lat /// </summary> /// <param name="lng"></param> /// <param name="lat"></param> private void UpdateMapLocation(double lat, double lng) { gMapCtrl.Position = new PointLatLng(lat, lng); } private void ToggleProxyCtrls() { if (useProxyCb.Checked) { proxyHostTb.Enabled = true; proxyHostTb.Text = _setting.Auth.UseProxyHost; proxyPortTb.Enabled = true; proxyPortTb.Text = _setting.Auth.UseProxyPort; useProxyAuthCb.Enabled = true; } else { proxyHostTb.Enabled = false; proxyHostTb.Text = _setting.Auth.UseProxyHost = ""; proxyPortTb.Enabled = false; proxyPortTb.Text = _setting.Auth.UseProxyPort = ""; useProxyAuthCb.Enabled = false; } if (useProxyAuthCb.Checked) { proxyUserTb.Enabled = true; proxyUserTb.Text = _setting.Auth.UseProxyUsername; proxyPwTb.Enabled = true; proxyPwTb.Text = _setting.Auth.UseProxyPassword; } else { proxyUserTb.Enabled = false; proxyUserTb.Text = _setting.Auth.UseProxyUsername = ""; proxyPwTb.Enabled = false; proxyPwTb.Text = _setting.Auth.UseProxyPassword = ""; } } private void PopulateDevice(int tabIndex = -1) { deviceTypeCb.SelectedIndex = tabIndex == -1 ? _deviceHelper.GetRandomIndex(2) : tabIndex; var candidateDevices = deviceTypeCb.SelectedIndex == 0 ? _deviceInfos.Where(d => d.DeviceBrand.ToLower() == "apple").ToList() : _deviceInfos.Where(d => d.DeviceBrand.ToLower() != "apple").ToList(); var selectIndex = _deviceHelper.GetRandomIndex(candidateDevices.Count); DeviceIdTb.Text = candidateDevices[selectIndex].DeviceId == "8525f5d8201f78b5" ? _deviceHelper.RandomString(16, "0123456789abcdef") : candidateDevices[selectIndex].DeviceId; AndroidBoardNameTb.Text = candidateDevices[selectIndex].AndroidBoardName; AndroidBootloaderTb.Text = candidateDevices[selectIndex].AndroidBootloader; DeviceBrandTb.Text = candidateDevices[selectIndex].DeviceBrand; DeviceModelTb.Text = candidateDevices[selectIndex].DeviceModel; DeviceModelIdentifierTb.Text = candidateDevices[selectIndex].DeviceModelIdentifier; DeviceModelBootTb.Text = candidateDevices[selectIndex].DeviceModelBoot; HardwareManufacturerTb.Text = candidateDevices[selectIndex].HardwareManufacturer; HardwareModelTb.Text = candidateDevices[selectIndex].HardwareModel; FirmwareBrandTb.Text = candidateDevices[selectIndex].FirmwareBrand; FirmwareTagsTb.Text = candidateDevices[selectIndex].FirmwareTags; FirmwareTypeTb.Text = candidateDevices[selectIndex].FirmwareType; FirmwareFingerprintTb.Text = candidateDevices[selectIndex].FirmwareFingerprint; } private static void ListSelectAllHandler(CheckedListBox targetList, bool setToValue) { for (var index = 0; index < targetList.Items.Count; index++) { targetList.SetItemChecked(index, setToValue); } } #endregion #region Events private void saveBtn_Click(object sender, EventArgs e) { if (UserLoginBox.Text.Length == 0 || UserPasswordBox.Text.Length == 0 || GoogleApiBox.Text.Length == 0) { MessageBox.Show( @"You haven't complete entering your basic information yet." + Environment.NewLine + @"Either Username, Password or Google API key is empty. Please complete them before saving.", @"Incomplete information", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { #region Auth Settings _setting.Auth.AuthType = authTypeCb.Text == @"Google" ? AuthType.Google : AuthType.Ptc; if (_setting.Auth.AuthType == AuthType.Google) { _setting.Auth.GoogleUsername = UserLoginBox.Text; _setting.Auth.GooglePassword = UserPasswordBox.Text; _setting.Auth.PtcUsername = ""; _setting.Auth.PtcPassword = ""; } else { _setting.Auth.GoogleUsername = ""; _setting.Auth.GooglePassword = ""; _setting.Auth.PtcUsername = UserLoginBox.Text; _setting.Auth.PtcPassword = UserPasswordBox.Text; } _setting.Auth.GoogleApiKey = GoogleApiBox.Text; _setting.Auth.UseProxy = useProxyCb.Checked; _setting.Auth.UseProxyHost = proxyHostTb.Text; _setting.Auth.UseProxyPort = proxyPortTb.Text; _setting.Auth.UseProxyAuthentication = useProxyAuthCb.Checked; _setting.Auth.UseProxyUsername = proxyUserTb.Text; _setting.Auth.UseProxyPassword = proxyPwTb.Text; _setting.Auth.DevicePackageName = "custom"; _setting.Auth.DeviceId = DeviceIdTb.Text; _setting.Auth.AndroidBoardName = AndroidBoardNameTb.Text; _setting.Auth.AndroidBootloader = AndroidBootloaderTb.Text; _setting.Auth.DeviceBrand = DeviceBrandTb.Text; _setting.Auth.DeviceModel = DeviceModelTb.Text; _setting.Auth.DeviceModelIdentifier = DeviceModelIdentifierTb.Text; _setting.Auth.DeviceModelBoot = DeviceModelBootTb.Text; _setting.Auth.HardwareManufacturer = HardwareManufacturerTb.Text; _setting.Auth.HardwareModel = HardwareModelTb.Text; _setting.Auth.FirmwareBrand = FirmwareBrandTb.Text; _setting.Auth.FirmwareTags = FirmwareTagsTb.Text; _setting.Auth.FirmwareType = FirmwareTypeTb.Text; _setting.Auth.FirmwareFingerprint = FirmwareFingerprintTb.Text; _setting.Auth.Save(AuthFilePath); #endregion #region Bot Settings _setting.TranslationLanguageCode = cbLanguage.Text; #region Location _setting.DefaultLatitude = ConvertStringToDouble(tbLatitude.Text); _setting.DefaultLongitude = ConvertStringToDouble(tbLongitude.Text); _setting.WalkingSpeedInKilometerPerHour = ConvertStringToInt(tbWalkingSpeed.Text); #endregion #region Pokemon #region Catch _setting.CatchPokemon = cbCatchPoke.Checked; _setting.UseEggIncubators = cbUseEggIncubators.Checked; _setting.MaxBerriesToUsePerPokemon = ConvertStringToInt(tBMaxBerriesToUsePerPokemon.Text); _setting.MaxPokeballsPerPokemon = ConvertStringToInt(tbMaxPokeballsPerPokemon.Text); _setting.PokemonsToIgnore = ConvertClbToList(clbIgnore); _setting.AutoFavoritePokemon = cbAutoFavoritePokemon.Checked; _setting.FavoriteMinIvPercentage = ConvertStringToFloat(tbFavoriteMinIvPercentage.Text); _setting.UseBerriesMinCp = ConvertStringToInt(tbUseBerriesMinCp.Text); _setting.UseBerriesMinIv = ConvertStringToFloat(tbUseBerriesMinIv.Text); _setting.UseBerriesBelowCatchProbability = ConvertStringToDouble(tbUseBerriesBelowCatchProbability.Text); _setting.UseBerriesOperator = cbUseBerriesOperator.SelectedIndex == 0 ? "and" : "or"; _setting.UseGreatBallAboveCp = ConvertStringToInt(tbUseGreatBallAboveCp.Text); _setting.UseUltraBallAboveCp = ConvertStringToInt(tbUseUltraBallAboveCp.Text); _setting.UseMasterBallAboveCp = ConvertStringToInt(tbUseMasterBallAboveCp.Text); _setting.UseGreatBallAboveIv = ConvertStringToDouble(tbUseGreatBallAboveIv.Text); _setting.UseUltraBallAboveIv = ConvertStringToDouble(tbUseUltraBallAboveIv.Text); _setting.UseGreatBallBelowCatchProbability = ConvertStringToDouble(tbUseGreatBallBelowCatchProbability.Text); _setting.UseUltraBallBelowCatchProbability = ConvertStringToDouble(tbUseUltraBallBelowCatchProbability.Text); _setting.UseMasterBallBelowCatchProbability = ConvertStringToDouble(tbUseMasterBallBelowCatchProbability.Text); #endregion #region Transfer _setting.PrioritizeIvOverCp = cbPrioritizeIvOverCp.Checked; _setting.KeepMinCp = ConvertStringToInt(tbKeepMinCp.Text); _setting.KeepMinIvPercentage = ConvertStringToFloat(tbKeepMinIV.Text); _setting.KeepMinLvl = ConvertStringToInt(tbKeepMinLvl.Text); _setting.KeepMinOperator = cbKeepMinOperator.SelectedIndex == 0 ? "and" : "or"; _setting.TransferWeakPokemon = cbTransferWeakPokemon.Checked; _setting.TransferDuplicatePokemon = cbTransferDuplicatePokemon.Checked; _setting.TransferDuplicatePokemonOnCapture = cbTransferDuplicatePokemonOnCapture.Checked; _setting.KeepMinDuplicatePokemon = ConvertStringToInt(tbKeepMinDuplicatePokemon.Text); _setting.UseKeepMinLvl = cbUseKeepMinLvl.Checked; _setting.PokemonsNotToTransfer = ConvertClbToList(clbTransfer); #endregion #region PowerUp _setting.UseLevelUpList = true; _setting.AutomaticallyLevelUpPokemon = cbAutoPowerUp.Checked; _setting.OnlyUpgradeFavorites = cbPowerUpFav.Checked; _setting.LevelUpByCPorIv = cbPowerUpType.SelectedIndex == 0 ? "iv" : "cp"; _setting.UpgradePokemonMinimumStatsOperator = cbPowerUpCondiction.SelectedIndex == 0 ? "and" : "or"; _setting.GetMinStarDustForLevelUp = ConvertStringToInt(cbPowerUpMinStarDust.Text); _setting.UpgradePokemonIvMinimum = ConvertStringToFloat(tbPowerUpMinIV.Text); _setting.UpgradePokemonCpMinimum = ConvertStringToFloat(tbPowerUpMinCP.Text); _setting.PokemonsToLevelUp = ConvertClbToList(clbPowerUp); #endregion #region Evo _setting.EvolveAllPokemonAboveIv = cbEvoAllAboveIV.Checked; _setting.EvolveAboveIvValue = ConvertStringToFloat(tbEvoAboveIV.Text); _setting.EvolveAllPokemonWithEnoughCandy = cbEvolveAllPokemonWithEnoughCandy.Checked; _setting.KeepPokemonsThatCanEvolve = cbKeepPokemonsThatCanEvolve.Checked; _setting.UseLuckyEggsWhileEvolving = cbUseLuckyEggsWhileEvolving.Checked; _setting.EvolveKeptPokemonsAtStorageUsagePercentage = ConvertStringToDouble(tbEvolveKeptPokemonsAtStorageUsagePercentage.Text); _setting.UseLuckyEggsMinPokemonAmount = ConvertStringToInt(tbUseLuckyEggsMinPokemonAmount.Text); _setting.PokemonsToEvolve = ConvertClbToList(clbEvolve); #endregion #endregion #region Item _setting.UseLuckyEggConstantly = cbUseLuckyEggConstantly.Checked; _setting.UseIncenseConstantly = cbUseIncenseConstantly.Checked; _setting.TotalAmountOfPokeballsToKeep = ConvertStringToInt(tbTotalAmountOfPokeballsToKeep.Text); _setting.TotalAmountOfPotionsToKeep = ConvertStringToInt(tbTotalAmountOfPotionsToKeep.Text); _setting.TotalAmountOfRevivesToKeep = ConvertStringToInt(tbTotalAmountOfRevivesToKeep.Text); _setting.TotalAmountOfBerriesToKeep = ConvertStringToInt(tbTotalAmountOfBerriesToKeep.Text); _setting.VerboseRecycling = cbVerboseRecycling.Checked; _setting.RecycleInventoryAtUsagePercentage = ConvertStringToDouble(tbRecycleInventoryAtUsagePercentage.Text); #endregion #region Advanced Settings _setting.DisableHumanWalking = cbDisableHumanWalking.Checked; _setting.UseWalkingSpeedVariant = cbUseWalkingSpeedVariant.Checked; _setting.WalkingSpeedVariant = ConvertStringToDouble(tbWalkingSpeedVariantInKilometerPerHour.Text); _setting.ShowVariantWalking = cbShowWalkingSpeed.Checked; _setting.MaxSpawnLocationOffset = ConvertStringToInt(tbMaxSpawnLocationOffset.Text); _setting.MaxTravelDistanceInMeters = ConvertStringToInt(tbMaxTravelDistanceInMeters.Text); _setting.DelayBetweenPlayerActions = ConvertStringToInt(tbDelayBetweenPlayerActions.Text); _setting.DelayBetweenPokemonCatch = ConvertStringToInt(tbDelayBetweenPokemonCatch.Text); _setting.DelayBetweenRecycle = ConvertStringToInt(tbDelayBetweenRecycle.Text); _setting.RandomizeRecycle = cbRandomizeRecycle.Checked; _setting.RandomRecycleValue = ConvertStringToInt(tbRandomRecycleValue.Text); _setting.EnableHumanizedThrows = cbEnableHumanizedThrows.Checked; _setting.NiceThrowChance = ConvertStringToInt(tbNiceThrowChance.Text); _setting.GreatThrowChance = ConvertStringToInt(tbGreatThrowChance.Text); _setting.ExcellentThrowChance = ConvertStringToInt(tbExcellentThrowChance.Text); _setting.CurveThrowChance = ConvertStringToInt(tbCurveThrowChance.Text); _setting.ForceGreatThrowOverIv = ConvertStringToDouble(tbForceGreatThrowOverIv.Text); _setting.ForceExcellentThrowOverIv = ConvertStringToDouble(tbForceExcellentThrowOverIv.Text); _setting.ForceGreatThrowOverCp = ConvertStringToInt(tbForceGreatThrowOverCp.Text); _setting.ForceExcellentThrowOverCp = ConvertStringToInt(tbForceExcellentThrowOverCp.Text); #endregion _setting.Save(ConfigFilePath); #endregion Application.Restart(); Close(); } } private void cancelBtn_Click(object sender, EventArgs e) { Close(); } private void trackBar_Scroll(object sender, EventArgs e) { gMapCtrl.Zoom = trackBar.Value; } private void gMapCtrl_MouseUp(object sender, MouseEventArgs e) { UpdateLocationInfo(); } private void gMapCtrl_OnMapZoomChanged() { UpdateLocationInfo(); } private void ResetLocationBtn_Click(object sender, EventArgs e) { gMapCtrl.Zoom = trackBar.Value = DefaultZoomLevel; UpdateMapLocation(_setting.DefaultLatitude, _setting.DefaultLongitude); } private void gMapCtrl_MouseClick(object sender, MouseEventArgs e) { var localCoordinates = e.Location; gMapCtrl.Position = gMapCtrl.FromLocalToLatLng(localCoordinates.X, localCoordinates.Y); } private void latitudeText_Leave(object sender, EventArgs e) { UpdateMapLocation(ConvertStringToDouble(tbLatitude.Text), ConvertStringToDouble(tbLongitude.Text)); } private void longitudeText_Leave(object sender, EventArgs e) { UpdateMapLocation(ConvertStringToDouble(tbLatitude.Text), ConvertStringToDouble(tbLongitude.Text)); } private void AdressBox_Enter(object sender, EventArgs e) { if (AdressBox.Text != @"Enter an address or a coordinate") { return; } AdressBox.Text = ""; } private void AdressBox_Leave(object sender, EventArgs e) { if (AdressBox.Text != string.Empty) { return; } AdressBox.Text = @"Enter an address or a coordinate"; } private void AdressBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != (char) Keys.Enter) { return; } gMapCtrl.SetPositionByKeywords(AdressBox.Text); gMapCtrl.Zoom = DefaultZoomLevel; UpdateLocationInfo(); } private void FindAdressBtn_Click(object sender, EventArgs e) { gMapCtrl.SetPositionByKeywords(AdressBox.Text); gMapCtrl.Zoom = DefaultZoomLevel; UpdateLocationInfo(); } private void RandomIDBtn_Click(object sender, EventArgs e) { DeviceIdTb.Text = _deviceHelper.RandomString(16, "0123456789abcdef"); } private void RandomDeviceBtn_Click(object sender, EventArgs e) { PopulateDevice(); } private void useProxyCb_CheckedChanged(object sender, EventArgs e) { ToggleProxyCtrls(); } private void useProxyAuthCb_CheckedChanged(object sender, EventArgs e) { ToggleProxyCtrls(); } private void deviceTypeCb_SelectionChangeCommitted(object sender, EventArgs e) { PopulateDevice(deviceTypeCb.SelectedIndex); } private void cbPowerUpAll_CheckedChanged(object sender, EventArgs e) { ListSelectAllHandler(clbPowerUp, cbPowerUpAll.Checked); } private void cbPowerUpType_SelectionChangeCommitted(object sender, EventArgs e) { if (cbPowerUpType.Text.ToLowerInvariant() == "iv") { label31.Visible = true; tbPowerUpMinIV.Visible = true; label30.Visible = false; tbPowerUpMinCP.Visible = false; } else { label31.Visible = false; tbPowerUpMinIV.Visible = false; label30.Visible = true; tbPowerUpMinCP.Visible = true; } } private void cbSelectAllEvolve_CheckedChanged(object sender, EventArgs e) { ListSelectAllHandler(clbEvolve, cbEvolveAll.Checked); } private void cbSelectAllCatch_CheckedChanged(object sender, EventArgs e) { ListSelectAllHandler(clbIgnore, cbIgnoreAll.Checked); } private void cbSelectAllTransfer_CheckedChanged(object sender, EventArgs e) { ListSelectAllHandler(clbTransfer, cbNotTransferAll.Checked); } private void enableAdvSettingCb_Click(object sender, EventArgs e) { proxyGb.Visible = _setting.EnableAdvancedSettings = enableAdvSettingCb.Checked; if (enableAdvSettingCb.Checked) { _tabAdvSettingTab.Enabled = true; tabControl.TabPages.Add(_tabAdvSettingTab); } else { _tabAdvSettingTab.Enabled = false; tabControl.TabPages.Remove(_tabAdvSettingTab); } } #endregion } }
{ "pile_set_name": "Github" }
#!/usr/bin/env python # -*- coding: utf-8 -*- # freeseer - vga/presentation capture software # # Copyright (C) 2011, 2013, 2014 Free and Open Source Software Learning Centre # http://fosslc.org # # This program 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. # # 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. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # For support, questions, suggestions or any other inquiries, visit: # http://wiki.github.com/Freeseer/freeseer/ import unittest from jsonschema import validate from jsonschema import ValidationError from freeseer.framework.config.options import IntegerOption from freeseer.tests.framework.config.options import OptionTest class TestIntegerOptionNoDefault(unittest.TestCase, OptionTest): """Tests IntegerOption without a default value.""" valid_success = range(-1000, 1000) encode_success = zip(valid_success, map(str, valid_success)) decode_success = zip(map(str, valid_success), valid_success) decode_failure = [ 'hello', '1world', 'test2', ] def setUp(self): self.option = IntegerOption() def test_schema(self): """Tests IntegerOption schema method.""" self.assertRaises(ValidationError, validate, 1.0, self.option.schema()) self.assertIsNone(validate(5, self.option.schema())) self.assertDictEqual(self.option.schema(), {'type': 'integer'}) class TestIntegerOptionWithDefault(TestIntegerOptionNoDefault): """Tests IntegerOption with a default value.""" def setUp(self): self.option = IntegerOption(1234) def test_default(self): """Tests that the default was set correctly.""" self.assertEqual(self.option.default, 1234) def test_schema(self): """Tests IntegerOption schema method.""" self.assertRaises(ValidationError, validate, 1.0, self.option.schema()) self.assertIsNone(validate(5, self.option.schema())) self.assertDictEqual(self.option.schema(), {'default': 1234, 'type': 'integer'})
{ "pile_set_name": "Github" }
package hex.tfidf; import water.fvec.Frame; import water.rapids.ast.prims.mungers.AstGroup; /** * Task class using map-reduce to compute term frequency values for words in given documents. */ public class TermFrequencyTask { /** * Column names to be used for output frame. */ private static final String[] OUTPUT_FRAME_COL_NAMES = new String[] { "DocID", "Word", "TF" }; /** * Computes term frequency values for given words in documents. * * @param wordFrame input frame of words for which term frequency * values should be computed. For exact format * see {@link TfIdfPreprocessorTask}. * * @return frame containing term frequency values for given words. */ public static Frame compute(final Frame wordFrame) { AstGroup.AGG[] aggs = new AstGroup.AGG[1]; aggs[0] = new AstGroup.AGG(AstGroup.FCN.nrow, 0, AstGroup.NAHandling.ALL, -1); int[] groupByColumns = new int[]{ 0, 1 }; Frame tfFrame = new AstGroup().performGroupingWithAggregations(wordFrame, groupByColumns, aggs).getFrame(); tfFrame.setNames(OUTPUT_FRAME_COL_NAMES); return tfFrame; } }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <!-- * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * 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 . --> <!DOCTYPE oor:component-schema SYSTEM "../../../../../component-schema.dtd"> <oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="DbTableWindowState" oor:package="org.openoffice.Office.UI" xml:lang="en-US"> <info> <desc>Contains state information of all dockable user interface elements based on a Window class which belongs to the database table module.</desc> </info> <import oor:component="org.openoffice.Office.UI.WindowState"/> <uses oor:component="org.openoffice.Office.UI.WindowState"/> <templates/> <component> <group oor:name="UIElements"> <info> <desc>Contains user interface element state data specific for the database table module."</desc> </info> <set oor:name="States" oor:node-type="WindowStateType" oor:component="org.openoffice.Office.UI.WindowState"> <info> <desc>Contains states of all known dockable user interface elements of the database table module."</desc> </info> </set> </group> </component> </oor:component-schema>
{ "pile_set_name": "Github" }
({ /******************************************************************************************************* * @description initialize our component, which is just creating an empty new address for our popup. */ doInit : function(component /* , event, helper */) { component.set('v.addrNew', {}); }, /******************************************************************************************************* * @description called whenever v.listAddr is modified, to update v.addrDefault. */ onChangeListAddr : function(component /* , event, helper */) { var listAddr = component.get('v.listAddr'); if (listAddr.length > 0) { // find the default address var iAddrDefault = 0; for (var i = 0; i < listAddr.length; i++) { if (listAddr[i].Default_Address__c) { iAddrDefault = i; break; } } component.set('v.addrDefault', listAddr[iAddrDefault]); } }, /******************************************************************************************************* * @description open the Change Address popup */ openChangeAddress : function(component /* , event, helper */) { component.set('v.showChangeAddressPopup', true); }, /******************************************************************************************************* * @description close the Change Address popup, making no changes. */ cancelChangeAddress : function(component /* , event, helper */) { component.set('v.showChangeAddressPopup', false); }, /******************************************************************************************************* * @description Save the new or existing address as the default, and close the Change Address popup */ saveChangeAddress : function(component, event, helper) { helper.setDefaultAddress(component); component.set('v.showChangeAddressPopup', false); component.set('v.addrNew', {}); component.set('v.isExistingAddrSectionOpen', true); }, /******************************************************************************************************* * @description tracks which existing address was last selected in the popup */ onPressAddrTile : function(component, event /* , helper */) { var iAddr = Number(event.currentTarget.getAttribute('data-iAddr')); component.set('v.iAddrSelected', iAddr); }, /******************************************************************************************************* * @description hides/shows the existing address/new address sections of the popup */ toggleAddrSection : function(component /* , event, helper */) { var isOpen = component.get('v.isExistingAddrSectionOpen'); component.set('v.isExistingAddrSectionOpen', !isOpen); }, })
{ "pile_set_name": "Github" }
import styled from '@emotion/styled'; import React from 'react'; import { useTranslation } from 'react-i18next'; import Box from 'verdaccio-ui/components/Box'; import Heading from 'verdaccio-ui/components/Heading'; import { Theme } from 'verdaccio-ui/design-tokens/theme'; interface Props { packageName: string; description?: string; version: string; isLatest: boolean; } const DetailSidebarTitle: React.FC<Props> = ({ description, packageName, version, isLatest }) => { const { t } = useTranslation(); return ( <Box className={'detail-info'} display="flex" flexDirection="column" marginBottom="8px"> <StyledHeading>{packageName}</StyledHeading> {description && <div>{description}</div>} <StyledBoxVersion> {isLatest ? t('sidebar.detail.latest-version', { version }) : t('sidebar.detail.version', { version })} </StyledBoxVersion> </Box> ); }; export default DetailSidebarTitle; const StyledHeading = styled(Heading)({ fontSize: '1rem', fontWeight: 700, }); const StyledBoxVersion = styled(Box)<{ theme?: Theme }>(({ theme }) => ({ color: theme && theme.palette.text.secondary, }));
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd"> <helpset version="2.0" xml:lang="ur-PK"> <title>Passive Scan Rules - Alpha | ZAP Extension</title> <maps> <homeID>top</homeID> <mapref location="map.jhm"/> </maps> <view> <name>TOC</name> <label>Contents</label> <type>org.zaproxy.zap.extension.help.ZapTocView</type> <data>toc.xml</data> </view> <view> <name>Index</name> <label>Index</label> <type>javax.help.IndexView</type> <data>index.xml</data> </view> <view> <name>Search</name> <label>Search</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> JavaHelpSearch </data> </view> <view> <name>Favorites</name> <label>Favorites</label> <type>javax.help.FavoritesView</type> </view> </helpset>
{ "pile_set_name": "Github" }
// fiber/future port originally written by Marcel Laverdet // https://gist.github.com/1131093 // I updated it to bring to feature parity with cb version. // The bugs are probably mine, not Marcel's. // -- isaacs var path = require('path') , fs = require('fs') , Future = require('fibers/future') // Create future-returning fs functions var fs2 = {} for (var ii in fs) { fs2[ii] = Future.wrap(fs[ii]) } // Return a future which just pauses for a certain amount of time function timer (ms) { var future = new Future setTimeout(function () { future.return() }, ms) return future } function realish (p) { return path.resolve(path.dirname(fs2.readlink(p))) } // for EMFILE backoff. var timeout = 0 , EMFILE_MAX = 1000 function rimraf_ (p, opts) { opts = opts || {} opts.maxBusyTries = opts.maxBusyTries || 3 if (opts.gently) opts.gently = path.resolve(opts.gently) var busyTries = 0 // exits by throwing or returning. // loops on handled errors. while (true) { try { var stat = fs2.lstat(p).wait() // check to make sure that symlinks are ours. if (opts.gently) { var rp = stat.isSymbolicLink() ? realish(p) : path.resolve(p) if (rp.indexOf(opts.gently) !== 0) { var er = new Error("Refusing to delete: "+p+" not in "+opts.gently) er.errno = require("constants").EEXIST er.code = "EEXIST" er.path = p throw er } } if (!stat.isDirectory()) return fs2.unlink(p).wait() var rimrafs = fs2.readdir(p).wait().map(function (file) { return rimraf(path.join(p, file), opts) }) Future.wait(rimrafs) fs2.rmdir(p).wait() timeout = 0 return } catch (er) { if (er.message.match(/^EMFILE/) && timeout < EMFILE_MAX) { timer(timeout++).wait() } else if (er.message.match(/^EBUSY/) && busyTries < opt.maxBusyTries) { timer(++busyTries * 100).wait() } else if (er.message.match(/^ENOENT/)) { // already gone return } else { throw er } } } } var rimraf = module.exports = rimraf_.future()
{ "pile_set_name": "Github" }
--- layout: post title: "CSS <strong>font properties</strong>" subtitle: "For <strong>bold</strong> and <em>italic</em> text" section: css --- ### font-size We've already covered **[CSS size units](/css-size-units.html)**, which are used to set the font size among other things. {% highlight css %} p{ font-size: 16px;} {% endhighlight %} Bear in mind that setting a font size of `16px` won't make each letter `16px` high. The _actual_ size of each letter depends on the font-family used. ### font-style This property can make your text _italic_: {% highlight css %} h2{ font-style: italic;} {% endhighlight %} Default value: `font-style: normal;`. Another possible value is `oblique` but is never used. ### font-weight This property can make your text **bold**: {% highlight css %} h2{ font-weight: bold;} {% endhighlight %} Default value: `font-weight: normal;`. Depending on the `font-family` used, there is a range of font weights available, from `100` to `900`: {% highlight css %} font-weight: 100; /* Thin */ font-weight: 200; /* Extra Light */ font-weight: 300; /* Light */ font-weight: 400; /* Which is like font-weight: normal; */ font-weight: 500; /* Medium */ font-weight: 600; /* Semi Bold */ font-weight: 700; /* Which is like font-weight: bold; */ font-weight: 800; /* Extra Bold */ font-weight: 900; /* Ultra Bold */ {% endhighlight %} Very few fonts provide all 9 weights. The [Exo font](https://www.google.com/fonts/specimen/Exo) is one of them. You'll mostly find 400 (normal) and 700 (bold), and sometimes 300 (light) and 500 (medium). ### font-variant This property turn your text into small caps: {% highlight css %} h2{ font-variant: small-caps;} {% endhighlight %} Default value: `font-variant: normal;`. It's not a widely used property.
{ "pile_set_name": "Github" }
@mod @mod_assign @assignfeedback @assignfeedback_editpdf @_file_upload Feature: In an assignment, teacher can view the feedback for a previous attempt. In order to see the history of attempts As a teacher I need to see the previous annotations. @javascript Scenario: Submit a PDF file as a student and annotate the PDF as a teacher, allowing another attempt Given ghostscript is installed And the following "courses" exist: | fullname | shortname | category | groupmode | | Course 1 | C1 | 0 | 1 | And the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | [email protected] | | student1 | Student | 1 | [email protected] | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add a "Assignment" to section "1" and I fill the form with: | Assignment name | Test assignment name | | Description | Submit your PDF file | | assignsubmission_file_enabled | 1 | | Maximum number of uploaded files | 2 | | Attempts reopened | Manually | | Maximum attempts | Unlimited | And I log out And I log in as "student1" And I am on "Course 1" course homepage And I follow "Test assignment name" And I press "Add submission" And I upload "mod/assign/feedback/editpdf/tests/fixtures/submission.pdf" file to "File submissions" filemanager And I upload "mod/assign/feedback/editpdf/tests/fixtures/testgs.pdf" file to "File submissions" filemanager And I press "Save changes" And I should see "Submitted for grading" And I should see "submission.pdf" And I should see "Not graded" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage And I follow "Test assignment name" And I navigate to "View all submissions" in current page administration And I click on "Grade" "link" in the "Submitted for grading" "table_row" And I should see "Page 1 of 3" And I click on ".navigate-next-button" "css_element" And I should see "Page 2 of 3" And I click on ".stampbutton" "css_element" And I draw on the pdf And I wait until the page is ready And I set the field "Allow another attempt" to "Yes" And I press "Save changes" And I wait until the page is ready And I should see "The changes to the grade and feedback were saved" And I press "OK" And I follow "View a different attempt" And I click on "Attempt 1" "radio" in the "View a different attempt" "dialogue" And I press "View" And I wait until the page is ready And I should see "You are editing the feedback for a previous attempt. This is attempt 1 out of 2." And I should see "Page 1 of 3"
{ "pile_set_name": "Github" }
--- title: Header 吸顶 order: 4 iframe: true width: 960 importStyle: true --- Header 固定(吸顶),其他区域滚动。 ````jsx import React, { Component } from 'react'; import ReactDOM from 'react-dom'; import Layout from '@icedesign/layout'; class App extends Component { render() { return ( <Layout fixable={true}> <Layout.Header style={{ height: 80, }} type="primary">Header</Layout.Header> <Layout.Section scrollable={true}> <Layout.Aside style={{ width: 200, }} type="primary"> <br /> Aside </Layout.Aside> <Layout.Main> <p>Main</p> <p style={{ height: 200 }}>内容可滚动</p> <p style={{ height: 200 }}>内容可滚动</p> <p style={{ height: 200 }}>内容可滚动</p> <p style={{ height: 200 }}>内容可滚动</p> <p style={{ height: 200 }}>内容可滚动</p> <p style={{ height: 200 }}>内容可滚动</p> <p style={{ height: 200 }}>内容可滚动</p> <p style={{ height: 200 }}>内容可滚动 end</p> <Layout.Footer>Footer</Layout.Footer> </Layout.Main> </Layout.Section> </Layout> ); } } ReactDOM.render(<App />, mountNode); ````
{ "pile_set_name": "Github" }
// Copyright 2012 YDN 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 Transaction queue. * * A transaction is used to crate non-overlapping transaction so that each * database methods are atomic and run in order. * * @author [email protected] (Kyaw Tun) */ goog.provide('ydn.db.tr.Serial'); goog.require('ydn.db.tr.Mutex'); goog.require('ydn.db.tr.Thread'); goog.require('ydn.debug.error.NotSupportedException'); /** * Create transaction queue providing methods to run in non-overlapping * transactions. * * @param {!ydn.db.tr.Storage} storage base storage. * @param {number} ptx_no transaction queue number. * @param {ydn.db.tr.Thread.Policy=} opt_policy transaction policy. * @param {!Array.<string>=} opt_store_names store names as scope. * @param {ydn.db.base.TransactionMode=} opt_mode mode as scope. * @param {number=} opt_max_tx_no limit number of transaction created. * @constructor * @extends {ydn.db.tr.Thread} * @struct */ ydn.db.tr.Serial = function(storage, ptx_no, opt_policy, opt_store_names, opt_mode, opt_max_tx_no) { goog.base(this, storage, ptx_no, opt_policy, opt_store_names, opt_mode, opt_max_tx_no); /** * @type {!Array.<{ * fnc: Function, * store_names: !Array.<string>, * mode: ydn.db.base.TransactionMode, * oncompleted: (function (ydn.db.base.TxEventTypes.<string>, *)|undefined) * }>} * @final * @private */ this.trQueue_ = []; /** * @final * @type {Array.<Function>} * @private */ this.completed_handlers_ = []; /** * Transaction object is sed when receiving a request before result df * callback and set null after that callback so that it can be aborted * in the callback. * In general, this tx may be different from running tx. * @type {ydn.db.base.Transaction} * @protected */ this.s_request_tx = null; /** * One database can have only one transaction. * @type {!ydn.db.tr.Mutex} * @private * @final */ this.mu_tx_ = new ydn.db.tr.Mutex(ptx_no); /** * @final * @private * @type {number} */ this.max_tx_no_ = opt_max_tx_no || 0; /** * A flag to indicate a transaction has been placed to the storage mechanism. * @type {boolean} * @private */ this.has_tx_started_ = false; }; goog.inherits(ydn.db.tr.Serial, ydn.db.tr.Thread); /** * @const * @type {boolean} */ ydn.db.tr.Serial.DEBUG = false; /** * @protected * @type {goog.debug.Logger} logger. */ ydn.db.tr.Serial.prototype.logger = goog.log.getLogger('ydn.db.tr.Serial'); /** * @protected * @return {ydn.db.tr.Mutex} mutex. */ ydn.db.tr.Serial.prototype.getMuTx = function() { return this.mu_tx_; }; /** * Obtain active consumable transaction object. * @return {ydn.db.tr.Mutex} transaction object if active and available. */ ydn.db.tr.Serial.prototype.getActiveTx = function() { return this.mu_tx_.isActiveAndAvailable() ? this.mu_tx_ : null; }; /** * * @return {boolean} true if trnasaction is active and available. */ ydn.db.tr.Serial.prototype.isActive = function() { return this.mu_tx_.isActiveAndAvailable(); }; /** * @param {!Array.<string>} store_names store names for scope. * @param {ydn.db.base.TransactionMode} mode tx mode. * @return {boolean} return true if given scope and mode is compatible with * active transaction and should be reuse. * @protected */ ydn.db.tr.Serial.prototype.reusedTx = function(store_names, mode) { if (this.policy == ydn.db.tr.Thread.Policy.MULTI) { return this.mu_tx_.subScope(store_names, mode); } else if (this.policy == ydn.db.tr.Thread.Policy.REPEAT) { return this.mu_tx_.sameScope(store_names, mode); } else if (this.policy == ydn.db.tr.Thread.Policy.ALL) { return true; } else { return false; // SINGLE and ATOMIC } }; /** * @return {ydn.db.base.Transaction} active transaction object. */ ydn.db.tr.Serial.prototype.getTx = function() { return this.mu_tx_.isActiveAndAvailable() ? this.mu_tx_.getTx() : null; }; /** * Transaction is explicitly set not to do next transaction. */ ydn.db.tr.Serial.prototype.lock = function() { this.mu_tx_.lock(); }; /** * @const * @type {number} maximun number of transaction queue. */ ydn.db.tr.Serial.MAX_QUEUE = 1000; /** * Run the first transaction task in the queue. DB must be ready to do the * transaction. * @private */ ydn.db.tr.Serial.prototype.popTxQueue_ = function() { var task = this.trQueue_.shift(); if (task) { if (ydn.db.tr.Serial.DEBUG) { goog.log.finest(this.logger, 'pop tx queue[' + this.trQueue_.length + ']'); } this.processTx(task.fnc, task.store_names, task.mode, task.oncompleted); } //this.last_queue_checkin_ = goog.now(); }; /** * * @return {Array.<string>} */ ydn.db.tr.Serial.prototype.peekScopes = function() { if (this.trQueue_.length > 0) { return this.trQueue_[0].store_names; } else { return null; } }; /** * @return {ydn.db.base.TransactionMode?} return next transaction mode. */ ydn.db.tr.Serial.prototype.peekMode = function() { if (this.trQueue_.length > 0) { return this.trQueue_[0].mode; } else { return null; } }; /** * Check next transaction. * @protected * @return {boolean} */ ydn.db.tr.Serial.prototype.isNextTxCompatible = function() { var scopes = this.peekScopes(); var mode = this.peekMode(); if (goog.isDefAndNotNull(scopes) && goog.isDefAndNotNull(mode)) { return this.reusedTx(scopes, mode); } else { return false; } }; /** * Push a transaction job to the queue. * @param {Function} trFn function that invoke in the transaction. * @param {!Array.<string>} store_names list of keys or * store name involved in the transaction. * @param {ydn.db.base.TransactionMode=} opt_mode mode, default to 'readonly'. * @param {function(ydn.db.base.TxEventTypes, *)=} opt_on_completed * handler. * @protected */ ydn.db.tr.Serial.prototype.pushTxQueue = function(trFn, store_names, opt_mode, opt_on_completed) { goog.log.finest(this.logger, 'push tx queue[' + this.trQueue_.length + ']'); this.trQueue_.push({ fnc: trFn, store_names: store_names, mode: opt_mode || ydn.db.base.TransactionMode.READ_ONLY, oncompleted: opt_on_completed }); }; /** * Abort an active transaction. */ ydn.db.tr.Serial.prototype.abort = function() { goog.log.finer(this.logger, this + ': aborting'); ydn.db.tr.Thread.abort(this.s_request_tx); }; /** * Create a new isolated transaction. After creating a transaction, use * {@link #getTx} to received an active transaction. If transaction is not * active, it return null. In this case a new transaction must re-create. * @param {Function} trFn function that invoke in the transaction. * @param {!Array.<string>} store_names list of keys or * store name involved in the transaction. * @param {ydn.db.base.TransactionMode=} opt_mode mode, default to 'readonly'. * @param {function(ydn.db.base.TxEventTypes, *)=} opt_on_completed * handler. */ ydn.db.tr.Serial.prototype.processTx = function(trFn, store_names, opt_mode, opt_on_completed) { var names = goog.isString(store_names) ? [store_names] : store_names; if (goog.DEBUG) { if (!goog.isArrayLike(names)) { // could be DOMStringList or Array throw new ydn.debug.error.ArgumentException( 'store names must be an array'); } else if (names.length == 0) { throw new ydn.debug.error.ArgumentException( 'number of store names must more than 0'); } else { for (var i = 0; i < names.length; i++) { if (!goog.isString(names[i])) { throw new ydn.debug.error.ArgumentException('store name at ' + i + ' must be string but found ' + names[i] + ' of type ' + typeof names[i]); } else if (this.scope_store_names_) { if (!goog.array.contains(this.scope_store_names_, names[i])) { throw new ydn.debug.error.ArgumentException('store name "' + i + names[i] + '" in scope of ' + this); } } else { // todo: check with auto schema /* if (!this.getStorage().hasStore(names[i])) { throw new ydn.debug.error.ArgumentException('store name "' + i + names[i] + '" in the schema.'); } */ } } } } var mode = goog.isDef(opt_mode) ? opt_mode : ydn.db.base.TransactionMode.READ_ONLY; var me = this; if (this.mu_tx_.isActive() || // we are serial, one tx at a time // if db is not ready and we already send one tx request, we keep // our tx request in our queue (!this.getStorage().isReady() && // if not ready this.has_tx_started_ // we put only one tx, to prevent overlap. )) { this.pushTxQueue(trFn, store_names, mode, opt_on_completed); } else { var label = this.getLabel(); var transaction_process = function(tx) { me.mu_tx_.up(tx, store_names, mode); label = me.getLabel(); goog.log.fine(me.logger, label + ' BEGIN ' + ydn.json.stringify(store_names) + ' ' + mode); // now execute transaction process trFn(me); trFn = null; me.mu_tx_.out(); // flag transaction callback scope is over. // transaction is still active and use in followup request handlers while (me.isNextTxCompatible()) { var task = me.trQueue_.shift(); if (task.oncompleted) { me.completed_handlers_.push(task.oncompleted); } goog.log.finest(me.logger, 'pop tx queue' + (me.trQueue_.length + 1) + ' reusing T' + me.getTxNo()); task.fnc(); } }; var completed_handler = function(type, event) { //console.log('transaction_process ' + scope_name + ' completed.'); goog.log.fine(me.logger, label + ' ' + type); me.mu_tx_.down(type, event); for (var j = 0; j < me.completed_handlers_.length; j++) { var fn = me.completed_handlers_[j]; fn(type, event); } me.completed_handlers_.length = 0; me.popTxQueue_(); me.r_no_ = 0; }; if (opt_on_completed) { this.completed_handlers_.push(opt_on_completed); } if (this.max_tx_no_ && this.getTxNo() >= this.max_tx_no_) { throw new ydn.debug.error.InvalidOperationException( 'Exceed maximum number of transactions of ' + this.max_tx_no_); } this.has_tx_started_ = true; this.getStorage().transaction(transaction_process, names, mode, completed_handler); } }; /** * * @return {string} return label. */ ydn.db.tr.Serial.prototype.getLabel = function() { return this.mu_tx_.getLabel(); }; /** * @inheritDoc */ ydn.db.tr.Serial.prototype.request = function(method, store_names, opt_mode, opt_on_complete) { var req = new ydn.db.Request(method); var mode = opt_mode || ydn.db.base.TransactionMode.READ_ONLY; var me = this; /** * @param {ydn.db.base.TxEventTypes} t * @param {*} e */ var onComplete = function(t, e) { req.removeTx(); if (opt_on_complete) { opt_on_complete(t, e); } }; if (this.mu_tx_.isActiveAndAvailable() && this.reusedTx(store_names, mode)) { //console.log(mu_tx.getScope() + ' continuing tx for ' + scope); // call within a transaction // continue to use existing transaction var tx = this.mu_tx_.getTx(); this.r_no_++; req.setTx(tx, this.getLabel() + 'R' + this.r_no_); this.completed_handlers_.push(onComplete); } else { // // /** * create a new transaction and close for invoke in non-transaction context * @param {Function} cb callback to process tx. */ var tx_callback = function(cb) { //console.log('tx running for ' + scope); // me.not_ready_ = true; // transaction should be active now var tx = me.mu_tx_.getTx(); me.r_no_++; req.setTx(tx, me.getLabel() + 'R' + me.r_no_); }; me.processTx(tx_callback, store_names, mode, onComplete); } return req; }; /** * @inheritDoc */ ydn.db.tr.Serial.prototype.exec = function(df, callback, store_names, opt_mode, on_complete) { var mode = opt_mode || ydn.db.base.TransactionMode.READ_ONLY; var me = this; var rq_label; if (me.mu_tx_.isActiveAndAvailable() && this.reusedTx(store_names, mode)) { //console.log(mu_tx.getScope() + ' continuing tx for ' + scope); // call within a transaction // continue to use existing transaction var tx = me.mu_tx_.getTx(); /** * @param {*} result result. * @param {boolean=} opt_is_error true if request has error. */ var resultCallback = function(result, opt_is_error) { me.s_request_tx = tx; // so that we can abort it. if (opt_is_error) { goog.log.finer(me.logger, rq_label + ' ERROR'); df.errback(result); } else { goog.log.finer(me.logger, rq_label + ' SUCCESS'); df.callback(result); } me.s_request_tx = null; }; me.r_no_++; rq_label = me.getLabel() + 'R' + me.r_no_; goog.log.finer(me.logger, rq_label + ' BEGIN'); callback(tx, rq_label, resultCallback); goog.log.finer(me.logger, rq_label + ' END'); callback = null; } else { // // /** * create a new transaction and close for invoke in non-transaction context * @param {Function} cb callback to process tx. */ var tx_callback = function(cb) { //console.log('tx running for ' + scope); // me.not_ready_ = true; // transaction should be active now var tx = me.mu_tx_.getTx(); /** * @param {*} result result. * @param {boolean=} opt_is_error true if request has error. */ var resultCallback2 = function(result, opt_is_error) { me.s_request_tx = tx; // so that we can abort it. if (opt_is_error) { goog.log.finer(me.logger, rq_label + ' ERROR'); df.errback(result); } else { goog.log.finer(me.logger, rq_label + ' SUCCESS'); df.callback(result); } me.s_request_tx = null; }; me.r_no_++; rq_label = me.getLabel() + 'R' + me.r_no_; goog.log.finer(me.logger, rq_label + ' BEGIN'); callback(tx, rq_label, resultCallback2); goog.log.finer(me.logger, rq_label + ' END'); callback = null; // we don't call again. }; me.processTx(tx_callback, store_names, mode, on_complete); } }; /** * @final * @return {string} database name. */ ydn.db.tr.Serial.prototype.getName = function() { return this.getStorage().getName(); }; if (goog.DEBUG) { /** @override */ ydn.db.tr.Serial.prototype.toString = function() { var s = !!this.s_request_tx ? '*' : ''; return 'Serial' + ':' + this.getLabel() + s; }; }
{ "pile_set_name": "Github" }
Clan Diamond Shark Frontline Infantry (WoRS) Clan Medium Battle Armor (Rabid), 1 Clan Medium Battle Armor (Rabid), 2 Clan Medium Battle Armor (Rabid), 3 Elemental Battle Armor [MG], 4 Elemental Battle Armor (Space) [MG], 5 Elemental Battle Armor [MG], 6 Elemental Battle Armor [MG], 5 Elemental Battle Armor [MG], 4 Salamander Battle Armor (Standard), 3 Gnome Battle Armor (Standard), 2 Gnome Battle Armor (Standard), 1
{ "pile_set_name": "Github" }
/** * TypeInfo support code. * * Copyright: Copyright Digital Mars 2004 - 2009. * License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Walter Bright */ /* Copyright Digital Mars 2004 - 2009. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at * http://www.boost.org/LICENSE_1_0.txt) */ module rt.typeinfo.ti_uint; // uint class TypeInfo_k : TypeInfo { @trusted: const: pure: nothrow: override string toString() const pure nothrow @safe { return "uint"; } override size_t getHash(scope const void* p) { return *cast(const uint *)p; } override bool equals(in void* p1, in void* p2) { return *cast(uint *)p1 == *cast(uint *)p2; } override int compare(in void* p1, in void* p2) { if (*cast(uint*) p1 < *cast(uint*) p2) return -1; else if (*cast(uint*) p1 > *cast(uint*) p2) return 1; return 0; } override @property size_t tsize() nothrow pure { return uint.sizeof; } override const(void)[] initializer() const @trusted { return (cast(void *)null)[0 .. uint.sizeof]; } override void swap(void *p1, void *p2) { int t; t = *cast(uint *)p1; *cast(uint *)p1 = *cast(uint *)p2; *cast(uint *)p2 = t; } }
{ "pile_set_name": "Github" }
fileFormatVersion: 2 guid: 348234aaa04337a4dbc75bc22cbd9ac8 folderAsset: yes timeCreated: 1498229871 licenseType: Pro DefaultImporter: userData: assetBundleName: assetBundleVariant:
{ "pile_set_name": "Github" }
package a { abstract class DeliteOp[B] abstract class DeliteCollection[A] abstract class Exp[T] { def Type: T } trait DeliteOpMap[A,B,C[X] <: DeliteCollection[X]] extends DeliteOp[C[B]] { val in: Exp[C[A]] val func: Exp[B] val alloc: Exp[C[B]] } object Test { def f(x: DeliteOp[_]) = x match { case map: DeliteOpMap[_,_,_] => map.alloc.Type } } } package b { object Test { def f(x: DeliteOp[_]) = x match { case map: DeliteOpMap[_,_,_] => map.alloc.Type } } abstract class DeliteOp[B] abstract class DeliteCollection[A] abstract class Exp[T] { def Type: T } trait DeliteOpMap[A,B,C[X] <: DeliteCollection[X]] extends DeliteOp[C[B]] { val in: Exp[C[A]] val func: Exp[B] val alloc: Exp[C[B]] } }
{ "pile_set_name": "Github" }
-- Vendors Elwynn Forest (19865) UPDATE `npc_vendor` SET `VerifiedBuild` = 19865 WHERE `entry` IN (6367, 74, 1213, 151, 295, 2046, 844, 1650, 384, 3935, 3937, 190); DELETE FROM `npc_vendor` WHERE `entry` IN (78, 955, 152, 958, 959, 894, 896, 1645, 1249, 1250, 54, 1198, 465, 66); INSERT INTO `npc_vendor` (`entry`, `item`, `slot`, `maxcount`, `ExtendedCost`, `Type`, `VerifiedBuild`) VALUES -- 78 (Janos Hammerknuckle) (78, 2131, 1, 0, 0, 1, 19865), (78, 1194, 2, 0, 0, 1, 19865), (78, 2134, 3, 0, 0, 1, 19865), (78, 2479, 4, 0, 0, 1, 19865), (78, 2130, 5, 0, 0, 1, 19865), (78, 2480, 6, 0, 0, 1, 19865), (78, 2139, 7, 0, 0, 1, 19865), (78, 2132, 8, 0, 0, 1, 19865), -- 955 (Sergeant De Vries) (955, 2723, 1, 0, 0, 1, 19865), (955, 2593, 2, 0, 0, 1, 19865), (955, 2596, 3, 0, 0, 1, 19865), (955, 2594, 4, 0, 0, 1, 19865), (955, 2595, 5, 0, 0, 1, 19865), (955, 83095, 6, 0, 0, 1, 19865), (955, 82343, 7, 0, 0, 1, 19865), (955, 83094, 8, 0, 0, 1, 19865), (955, 82344, 9, 0, 0, 1, 19865), (955, 159, 10, 0, 0, 1, 19865), (955, 1179, 11, 0, 0, 1, 19865), (955, 1205, 12, 0, 0, 1, 19865), (955, 1708, 13, 0, 0, 1, 19865), (955, 1645, 14, 0, 0, 1, 19865), (955, 8766, 15, 0, 0, 1, 19865), -- 152 (Brother Danil) (152, 4540, 1, 0, 0, 1, 19865), (152, 159, 2, 0, 0, 1, 19865), (152, 4496, 3, 0, 0, 1, 19865), -- 958 (958, 64670, 1, 0, 0, 1, 19865), (958, 63388, 2, 0, 0, 1, 19865), (958, 79249, 3, 0, 0, 1, 19865), (958, 3371, 4, 0, 0, 1, 19865), (958, 2455, 608, 2, 0, 1, 19865), (958, 3013, 609, 3, 0, 1, 19865), (958, 3012, 615, 1, 0, 1, 19865), (958, 1181, 610, 2, 0, 1, 19865), (958, 955, 611, 2, 0, 1, 19865), (958, 1180, 612, 2, 0, 1, 19865), (958, 954, 613, 2, 0, 1, 19865), (958, 858, 614, 3, 0, 1, 19865), -- 959 (959, 795, 1, 0, 0, 1, 19865), (959, 3602, 2, 0, 0, 1, 19865), (959, 794, 3, 0, 0, 1, 19865), (959, 792, 4, 0, 0, 1, 19865), (959, 3603, 5, 0, 0, 1, 19865), (959, 793, 6, 0, 0, 1, 19865), -- 894 (Homer Stonefield) (894, 4536, 1, 0, 0, 1, 19865), (894, 4537, 2, 0, 0, 1, 19865), (894, 4538, 3, 0, 0, 1, 19865), (894, 4539, 4, 0, 0, 1, 19865), (894, 4602, 5, 0, 0, 1, 19865), (894, 8953, 6, 0, 0, 1, 19865), -- 896 (Veldan Lightfoot) (896, 799, 1, 0, 0, 1, 19865), (896, 1839, 2, 0, 0, 1, 19865), (896, 798, 3, 0, 0, 1, 19865), (896, 796, 4, 0, 0, 1, 19865), (896, 1840, 5, 0, 0, 1, 19865), (896, 797, 6, 0, 0, 1, 19865), (896, 846, 7, 0, 0, 1, 19865), (896, 1843, 8, 0, 0, 1, 19865), (896, 845, 9, 0, 0, 1, 19865), (896, 843, 10, 0, 0, 1, 19865), (896, 1844, 11, 0, 0, 1, 19865), (896, 844, 12, 0, 0, 1, 19865), -- 1645 (Quartermaster Hicks) (1645, 2520, 1, 0, 0, 1, 19865), (1645, 2521, 2, 0, 0, 1, 19865), (1645, 2522, 3, 0, 0, 1, 19865), (1645, 2523, 4, 0, 0, 1, 19865), (1645, 2524, 5, 0, 0, 1, 19865), (1645, 2525, 6, 0, 0, 1, 19865), (1645, 2526, 7, 0, 0, 1, 19865), (1645, 2527, 8, 0, 0, 1, 19865), -- 1249 (Quartermaster Hudson) (1249, 2392, 1, 0, 0, 1, 19865), (1249, 2393, 2, 0, 0, 1, 19865), (1249, 2394, 3, 0, 0, 1, 19865), (1249, 2395, 4, 0, 0, 1, 19865), (1249, 2396, 5, 0, 0, 1, 19865), (1249, 2397, 6, 0, 0, 1, 19865), (1249, 17186, 7, 0, 0, 1, 19865), (1249, 1201, 8, 0, 0, 1, 19865), -- 1250 (1250, 159, 1, 0, 0, 1, 19865), (1250, 4540, 2, 0, 0, 1, 19865), (1250, 4496, 3, 0, 0, 1, 19865), (1250, 4498, 4, 0, 0, 1, 19865), (1250, 4470, 5, 0, 0, 1, 19865), (1250, 5042, 6, 0, 0, 1, 19865), (1250, 7005, 7, 0, 0, 1, 19865), (1250, 2901, 8, 0, 0, 1, 19865), (1250, 85663, 9, 0, 0, 1, 19865), (1250, 5956, 10, 0, 0, 1, 19865), (1250, 6256, 11, 0, 0, 1, 19865), (1250, 6217, 12, 0, 0, 1, 19865), (1250, 2678, 13, 0, 0, 1, 19865), (1250, 30817, 14, 0, 0, 1, 19865), (1250, 2320, 15, 0, 0, 1, 19865), (1250, 2880, 16, 0, 0, 1, 19865), (1250, 3371, 17, 0, 0, 1, 19865), (1250, 4289, 18, 0, 0, 1, 19865), (1250, 6529, 19, 0, 0, 1, 19865), (1250, 2604, 20, 0, 0, 1, 19865), (1250, 2324, 21, 0, 0, 1, 19865), (1250, 6260, 22, 0, 0, 1, 19865), (1250, 39354, 23, 0, 0, 1, 19865), (1250, 20815, 24, 0, 0, 1, 19865), (1250, 39505, 25, 0, 0, 1, 19865), (1250, 6272, 204, 1, 0, 1, 19865), -- 54 (Corina Steele) (54, 2489, 1, 0, 0, 1, 19865), (54, 2492, 2, 0, 0, 1, 19865), (54, 2491, 3, 0, 0, 1, 19865), (54, 2494, 4, 0, 0, 1, 19865), (54, 2495, 5, 0, 0, 1, 19865), (54, 2488, 6, 0, 0, 1, 19865), (54, 2490, 7, 0, 0, 1, 19865), (54, 2493, 8, 0, 0, 1, 19865), -- 1198 (1198, 2506, 1, 0, 0, 1, 19865), (1198, 2507, 2, 0, 0, 1, 19865), -- 465 (Barkeep Dobbins) (465, 1939, 1, 0, 0, 1, 19865), (465, 159, 2, 0, 0, 1, 19865), (465, 1179, 3, 0, 0, 1, 19865), (465, 1205, 4, 0, 0, 1, 19865), (465, 1708, 5, 0, 0, 1, 19865), (465, 1645, 6, 0, 0, 1, 19865), (465, 8766, 7, 0, 0, 1, 19865), (465, 2723, 8, 0, 0, 1, 19865), (465, 2593, 9, 0, 0, 1, 19865), (465, 2596, 10, 0, 0, 1, 19865), (465, 2594, 11, 0, 0, 1, 19865), (465, 2595, 12, 0, 0, 1, 19865), (465, 83095, 13, 0, 0, 1, 19865), (465, 82343, 14, 0, 0, 1, 19865), (465, 83094, 15, 0, 0, 1, 19865), (465, 82344, 16, 0, 0, 1, 19865), (465, 2070, 17, 0, 0, 1, 19865), (465, 414, 18, 0, 0, 1, 19865), (465, 422, 19, 0, 0, 1, 19865), (465, 1707, 20, 0, 0, 1, 19865), (465, 3927, 21, 0, 0, 1, 19865), (465, 8932, 22, 0, 0, 1, 19865), -- 66 (Tharynn Bouden) (66, 7005, 1, 0, 0, 1, 19865), (66, 2901, 2, 0, 0, 1, 19865), (66, 85663, 3, 0, 0, 1, 19865), (66, 5956, 4, 0, 0, 1, 19865), (66, 6256, 5, 0, 0, 1, 19865), (66, 6217, 6, 0, 0, 1, 19865), (66, 2678, 7, 0, 0, 1, 19865), (66, 30817, 8, 0, 0, 1, 19865), (66, 2320, 9, 0, 0, 1, 19865), (66, 2880, 10, 0, 0, 1, 19865), (66, 3371, 11, 0, 0, 1, 19865), (66, 4289, 12, 0, 0, 1, 19865), (66, 6529, 13, 0, 0, 1, 19865), (66, 2604, 14, 0, 0, 1, 19865), (66, 2324, 15, 0, 0, 1, 19865), (66, 6260, 16, 0, 0, 1, 19865), (66, 39354, 17, 0, 0, 1, 19865), (66, 20815, 18, 0, 0, 1, 19865), (66, 39505, 19, 0, 0, 1, 19865), (66, 6325, 20, 0, 0, 1, 19865), (66, 6328, 21, 0, 0, 1, 19865), (66, 6270, 184, 1, 0, 1, 19865); UPDATE `npc_vendor` SET `incrtime`=9000 WHERE `item`=6270; UPDATE `npc_vendor` SET `incrtime`=7200 WHERE `item`=6272; UPDATE `npc_vendor` SET `incrtime`=9000 WHERE `entry`=958 AND `item` IN (2455, 3013, 1181, 955, 1180, 954, 858, 3012);
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <!-- ====================================================================== --> <!-- Ant build file (http://ant.apache.org/) for Ant 1.6.2 or above. --> <!-- ====================================================================== --> <project name="commons-lang" default="package" basedir="."> <path id="build.test.classpath"> <pathelement location="${easymock.jar}" /> </path> <!-- ====================================================================== --> <!-- Import maven-build.xml into the current project --> <!-- ====================================================================== --> <import file="maven-build.xml"/> <!-- ====================================================================== --> <!-- Help target --> <!-- ====================================================================== --> <target name="help"> <echo message="Please run: $ant -projecthelp"/> </target> <path id="test.classpath"> <path refid="build.test.classpath"/> <pathelement location="${maven.build.outputDir}"/> <pathelement location="${maven.build.testOutputDir}"/> </path> <path id="compile.classpath"> <path refid="build.classpath"/> </path> <property name="test.home" value="${maven.build.testDir.0}"/> <property name="source.home" value="${maven.build.srcDir.0}"/> <property name="build.home" value="${maven.build.dir}"/> <target name="compile.tests" depends="compile-tests"/> </project>
{ "pile_set_name": "Github" }
import React from 'react'; import { render } from 'react-dom'; import { Provider } from 'react-redux'; import configureStore from './store/configureStore'; import './styles/main.less'; import '../node_modules/fixed-data-table/dist/fixed-data-table.min.css'; import DB from './db'; import BaseComponent from './components/Base/BaseComponent'; const store = configureStore(); render( <Provider store={store}> <BaseComponent /> </Provider>, document.getElementById('root') ); window.onbeforeunload = function closeWindow() { DB.disconnectDB(); };
{ "pile_set_name": "Github" }
require_relative '../../../spec_helper' require 'matrix' describe "Matrix::EigenvalueDecomposition#initialize" do it "raises an error if argument is not a matrix" do -> { Matrix::EigenvalueDecomposition.new([[]]) }.should raise_error(TypeError) -> { Matrix::EigenvalueDecomposition.new(42) }.should raise_error(TypeError) end it "raises an error if matrix is not square" do -> { Matrix::EigenvalueDecomposition.new(Matrix[[1, 2]]) }.should raise_error(Matrix::ErrDimensionMismatch) end it "never hangs" do m = Matrix[ [0,0,0,0,0], [0,0,0,0,1], [0,0,0,1,0], [1,1,0,0,1], [1,0,1,0,1] ] Matrix::EigenvalueDecomposition.new(m).should_not == "infinite loop" end end
{ "pile_set_name": "Github" }
describe("", function() { var rootEl; beforeEach(function() { rootEl = browser.rootEl; browser.get("build/docs/examples/example-radio-input-directive/index.html"); }); it('should change state', function() { var inputs = element.all(by.model('color.name')); var color = element(by.binding('color.name')); expect(color.getText()).toContain('blue'); inputs.get(0).click(); expect(color.getText()).toContain('red'); inputs.get(1).click(); expect(color.getText()).toContain('green'); }); });
{ "pile_set_name": "Github" }
#import <Foundation/Foundation.h> // Event Data Sources represent the metadata associated with specific events // A data source is constructed automatically for each event in /Library/Activator/Events @protocol LAEventDataSource <NSObject> @required - (NSString *)localizedTitleForEventName:(NSString *)eventName; - (NSString *)localizedGroupForEventName:(NSString *)eventName; - (NSString *)localizedDescriptionForEventName:(NSString *)eventName; @optional - (BOOL)eventWithNameIsHidden:(NSString *)eventName; - (BOOL)eventWithNameRequiresAssignment:(NSString *)eventName; - (BOOL)eventWithName:(NSString *)eventName isCompatibleWithMode:(NSString *)eventMode; - (BOOL)eventWithNameSupportsUnlockingDeviceToSend:(NSString *)eventName; - (BOOL)eventWithNameSupportsRemoval:(NSString *)eventName; - (void)removeEventWithName:(NSString *)eventName; - (NSString *)configurationViewControllerClassNameForEventWithName:(NSString *)eventName bundle:(NSBundle **)bundle; // LAEventConfigurationViewController - (id)configurationForEventWithName:(NSString *)eventName; - (void)eventWithName:(NSString *)eventName didSaveNewConfiguration:(id)configuration; @end
{ "pile_set_name": "Github" }
package com.thomsonreuters.upa.perftools.upajconsperf; import com.thomsonreuters.upa.codec.CodecReturnCodes; import com.thomsonreuters.upa.shared.CommandLine; import com.thomsonreuters.upa.transport.ConnectionTypes; /** Provides configuration that is not specific to any particular handler. */ public class ConsPerfConfig { private String _configString; private static final int DEFAULT_THREAD_COUNT = 1; private int _maxThreads; /* APPLICATION configuration */ private int _steadyStateTime; /* Time application runs before exiting. */ private int _ticksPerSec; /* Main loop ticks per second */ private int _threadCount; /* Number of threads that handle connections. */ private String _itemFilename; /* File of names to use when requesting items. */ private String _msgFilename; /* File of data to use for message payloads. */ private boolean _logLatencyToFile; /* Whether to log update latency information to a file. */ private String _latencyLogFilename; /* Name of the latency log file. */ private String _summaryFilename; /* Name of the summary log file. */ private String _statsFilename; /* Name of the statistics log file. */ private int _writeStatsInterval; /* Controls how often statistics are written. */ private boolean _displayStats; /* Controls whether stats appear on the screen. */ private int _itemRequestsPerSec; /* Rate at which the consumer will send out item requests. */ /* CONNECTION configuration */ private int _connectionType; /* Type of connection. */ private String _hostName; /* hostName, if using Transport.connect(). */ private String _portNo; /* Port number. */ private String _interfaceName; /* Name of interface. */ private int _guaranteedOutputBuffers; /* Guaranteed Output Buffers. */ private int _numInputBuffers; /* Input Buffers. */ private int _sendBufSize; /* System Send Buffer Size. */ private int _recvBufSize; /* System Receive Buffer Size. */ private int _highWaterMark; /* sets the point which will cause UPA to automatically flush */ private boolean _tcpNoDelay; /* Enable/Disable Nagle's algorithm. */ private boolean _requestSnapshots; /* Whether to request all items as snapshots. */ private String _username; /* Username used when logging in. */ private String _serviceName; /* Name of service to request items from. */ private int _itemRequestCount; /* Number of items to request. See -itemCount. */ private int _commonItemCount; /* Number of items common to all connections, if using multiple connections. */ private int _postsPerSec; /* Number of posts to send per second. */ private int _latencyPostsPerSec; /* Number of latency posts to send per second. */ private int _genMsgsPerSec; /* Number of generic msgs to send per second. */ private int _latencyGenMsgsPerSec; /* Number of latency generic msgs to send per second. */ private int _requestsPerTick; /* Number of requests to send per tick */ private int _requestsPerTickRemainder; /* The remainder of number of requests to send per tick */ private boolean _primeJVM; /* At startup, prime the JVM to optimize code by requesting a snapshot of all items before opening the streaming items. */ private boolean _useReactor; /* Use the VA Reactor instead of the UPA Channel for sending and receiving. */ private boolean _useWatchlist; /* Use the VA Reactor watchlist instead of the UPA Channel for sending and receiving. */ private boolean _useTunnel; /* Use the VA Reactor tunnel stream instead of the UPA Channel for sending and receiving. */ private boolean _tunnelAuth; /* Use to request authentication when opening a tunnel stream. */ private int _tunnelStreamOutputBuffers; /* Tunnel Stream Guaranteed Output Buffers. */ private boolean _tunnelStreamBufsUsed; /* Control whether to print tunnel Stream buffers usage. */ private boolean _busyRead; /* If set, the application will continually read rather than using notification. */ { CommandLine.programName("upajConsPerf"); CommandLine.addOption("steadyStateTime", 300, "Time consumer will run the steady-state portion of the test. Also used as a timeout during the startup-state portion"); CommandLine.addOption("tickRate", 1000, "Ticks per second"); CommandLine.addOption("threads", DEFAULT_THREAD_COUNT, "Number of threads that handle connections"); CommandLine.addOption("itemFile", "350k.xml", "Name of the file to get item names from"); CommandLine.addOption("msgFile", "MsgData.xml", "Name of the file that specifies the data content in messages"); CommandLine.addOption("latencyFile", "", "Base name of file for logging latency"); CommandLine.addOption("summaryFile", "ConsSummary.out", "Name of file for logging summary info"); CommandLine.addOption("statsFile", "ConsStats", "Base name of file for logging periodic statistics"); CommandLine.addOption("writeStatsInterval", 5, "Controls how often stats are written to the file"); CommandLine.addOption("noDisplayStats", false, "Stop printout of stats to screen"); CommandLine.addOption("requestRate", 500000, "Rate at which to request items"); CommandLine.addOption("connType", "socket", "Type of connection"); CommandLine.addOption("h", "localhost", "Name of host to connect to"); CommandLine.addOption("p", "14002", "Port number to connect to"); CommandLine.addOption("if", "", "Name of network interface to use"); CommandLine.addOption("outputBufs", 5000, "Number of output buffers(configures guaranteedOutputBuffers in UPA connection)"); CommandLine.addOption("inputBufs", 15, "Number of input buffers(configures numInputBufs in UPA connection)"); CommandLine.addOption("sendBufSize", 0, "System Send Buffer Size(configures sysSendBufSize in ConnectOptions)"); CommandLine.addOption("recvBufSize", 0, "System Receive Buffer Size(configures sysRecvBufSize in ConnectOptions)"); CommandLine.addOption("highWaterMark", 0, "Sets the point that causes UPA to automatically flush"); CommandLine.addOption("tcpDelay", false, "Turns off tcp_nodelay in BindOptions, enabling Nagle's"); CommandLine.addOption("snapshot", false, "Snapshot test, request all items as non-streaming"); CommandLine.addOption("uname", "", "Username to use in login request"); CommandLine.addOption("serviceName", "DIRECT_FEED", "Name of service to request items from"); CommandLine.addOption("itemCount", 100000, "Number of items to request"); CommandLine.addOption("commonItemCount", 0, "Number of items common to all consumers, if using multiple connections"); CommandLine.addOption("postingRate", 0, "Rate at which to send post messages"); CommandLine.addOption("postingLatencyRate", 0, "Rate at which to send latency post messages"); CommandLine.addOption("genericMsgRate", 0, "Rate at which to send generic messages"); CommandLine.addOption("genericMsgLatencyRate", 0, "Rate at which to send latency generic messages"); CommandLine.addOption("primeJVM", false, "At startup, prime the JVM to optimize code by requesting a snapshot of all items before opening the streaming items"); CommandLine.addOption("reactor", false, "Use the VA Reactor instead of the UPA Channel for sending and receiving"); CommandLine.addOption("watchlist", false, "Use the VA Reactor watchlist instead of the UPA Channel for sending and receiving"); CommandLine.addOption("tunnel", false, "Use the VA Reactor tunnel stream instead of the UPA Channel for sending and receiving"); CommandLine.addOption("tunnelAuth", false, "If set, consumer to request authentication when opening a tunnel stream"); CommandLine.addOption("tunnelStreamOutputBufs", 5000, "Number of output buffers(configures guaranteedOutputBuffers in Tunnel Stream)"); CommandLine.addOption("tunnelStreamBuffersUsed", false, "Print stats of buffers used by tunnel stream"); CommandLine.addOption("busyRead", false, "If set, the application will continually read rather than using notification."); } /** * Parses command-line arguments to fill in the application's configuration structures. * * @param args the args * @param maxThreads the max threads */ public void init (String[] args, int maxThreads) { try { CommandLine.parseArgs(args); } catch (IllegalArgumentException ile) { System.err.println("Error loading command line arguments:\t"); System.err.println(ile.getMessage()); System.err.println(); System.err.println(CommandLine.optionHelpString()); System.exit(CodecReturnCodes.FAILURE); } _maxThreads = maxThreads; _msgFilename = CommandLine.value("msgFile"); _itemFilename = CommandLine.value("itemFile"); _logLatencyToFile = false; _latencyLogFilename = CommandLine.value("latencyFile"); _summaryFilename = CommandLine.value("summaryFile"); _statsFilename = CommandLine.value("statsFile"); _hostName = CommandLine.value("h"); _portNo = CommandLine.value("p"); _interfaceName = CommandLine.value("if"); _username = CommandLine.value("uname"); _serviceName = CommandLine.value("serviceName"); _displayStats = !CommandLine.booleanValue("noDisplayStats"); _tcpNoDelay = !CommandLine.booleanValue("tcpDelay"); _requestSnapshots = CommandLine.booleanValue("snapshot"); _primeJVM = CommandLine.booleanValue("primeJVM"); _useReactor = CommandLine.booleanValue("reactor"); _useWatchlist = CommandLine.booleanValue("watchlist"); _useTunnel = CommandLine.booleanValue("tunnel"); _tunnelAuth = CommandLine.booleanValue("tunnelAuth"); _busyRead = CommandLine.booleanValue("busyRead"); _tunnelStreamOutputBuffers = CommandLine.intValue("tunnelStreamOutputBufs"); _tunnelStreamBufsUsed = CommandLine.booleanValue("tunnelStreamBuffersUsed"); try { _steadyStateTime = CommandLine.intValue("steadyStateTime"); _ticksPerSec = CommandLine.intValue("tickRate"); _threadCount = CommandLine.intValue("threads"); _writeStatsInterval = CommandLine.intValue("writeStatsInterval"); _itemRequestsPerSec = CommandLine.intValue("requestRate"); if("socket".equals(CommandLine.value("connType"))) { _connectionType = ConnectionTypes.SOCKET; } else { System.err.println("Config Error: Only socket connection type is supported.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } _guaranteedOutputBuffers = CommandLine.intValue("outputBufs"); _numInputBuffers = CommandLine.intValue("inputBufs"); _sendBufSize = CommandLine.intValue("sendBufSize"); _recvBufSize = CommandLine.intValue("recvBufSize"); _highWaterMark = CommandLine.intValue("highWaterMark"); _itemRequestCount = CommandLine.intValue("itemCount"); _commonItemCount = CommandLine.intValue("commonItemCount"); _postsPerSec = CommandLine.intValue("postingRate"); _latencyPostsPerSec = CommandLine.intValue("postingLatencyRate"); _genMsgsPerSec = CommandLine.intValue("genericMsgRate"); _latencyGenMsgsPerSec = CommandLine.intValue("genericMsgLatencyRate"); } catch (NumberFormatException ile) { System.err.println("Invalid argument, number expected.\t"); System.err.println(ile.getMessage()); System.err.println(); System.err.println(CommandLine.optionHelpString()); System.exit(-1); } if (_connectionType != ConnectionTypes.SOCKET) { System.err.println("Config Error: Application only supports SOCKET connection type.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_ticksPerSec < 1) { System.err.println("Config Error: Tick rate cannot be less than 1."); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_itemRequestsPerSec < _ticksPerSec) { System.err.println("Config Error: Item Request Rate cannot be less than tick rate.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_postsPerSec < _ticksPerSec && _postsPerSec != 0) { System.err.println("Config Error: Post Rate cannot be less than tick rate(unless it is zero).\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_latencyPostsPerSec > _postsPerSec) { System.err.println("Config Error: Latency Post Rate cannot be greater than total posting rate.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_latencyPostsPerSec > _ticksPerSec) { System.err.println("Config Error: Latency Post Rate cannot be greater than tick rate.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_postsPerSec > 0 && _requestSnapshots) { System.err.println("Config Error: Configured to post while requesting snapshots.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_genMsgsPerSec < _ticksPerSec && _genMsgsPerSec != 0) { System.err.println("Config Error: Generic Msg Rate cannot be less than tick rate(unless it is zero).\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_latencyGenMsgsPerSec > _genMsgsPerSec) { System.err.println("Config Error: Latency Generic Msg Rate cannot be greater than total generic msg rate.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_latencyGenMsgsPerSec > _ticksPerSec) { System.err.println("Config Error: Latency Generic Msg Rate cannot be greater than tick rate.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_genMsgsPerSec > 0 && _requestSnapshots) { System.err.println("Config Error: Configured to send generic msgs while requesting snapshots.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_commonItemCount > _itemRequestCount) { System.err.println("Config Error: Common item count is greater than total item count.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_writeStatsInterval < 1) { System.err.println("Config error: Write Stats Interval cannot be less than 1.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if (_threadCount > _maxThreads) { System.err.println("Config error: Thread count cannot be greater than " + _maxThreads + ".\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } if(_useTunnel && !_useReactor) { System.err.println("Config error: The -reactor must be set in order to send and receive messages via tunnel stream.\n"); System.out.println(CommandLine.optionHelpString()); System.exit(-1); } _requestsPerTick = _itemRequestsPerSec / _ticksPerSec; _requestsPerTickRemainder = _itemRequestsPerSec % _ticksPerSec; createConfigString(); } /* Create config string. */ private void createConfigString() { String reactorWatchlistUsageString; if (_useWatchlist) { reactorWatchlistUsageString = "Reactor and Watchlist"; } else if (_useReactor) { reactorWatchlistUsageString = "Reactor"; } else { reactorWatchlistUsageString = "None"; } _configString = "--- TEST INPUTS ---\n\n" + " Steady State Time: " + _steadyStateTime + " sec\n" + " Connection Type: " + ConnectionTypes.toString(_connectionType) + "\n" + " Hostname: " + _hostName + "\n" + " Port: " + _portNo + "\n" + " Service: " + _serviceName + "\n" + " Thread Count: " + _threadCount + "\n" + " Output Buffers: " + _guaranteedOutputBuffers + "\n" + " Input Buffers: " + _numInputBuffers + "\n" + " Send Buffer Size: " + _sendBufSize + ((_sendBufSize > 0) ? " bytes" : "(use default)") + "\n" + " Recv Buffer Size: " + _recvBufSize + ((_recvBufSize > 0) ? " bytes" : "(use default)") + "\n" + " High Water Mark: " + _highWaterMark + ((_highWaterMark > 0) ? " bytes" : "(use default)") + "\n" + " Interface Name: " + (_interfaceName.length() > 0 ? _interfaceName : "(use default)") + "\n" + " Tcp_NoDelay: " + (_tcpNoDelay ? "Yes" : "No") + "\n" + " Username: " + (_username.length() > 0 ? _username : "(use system login name)") + "\n" + " Item Count: " + _itemRequestCount + "\n" + " Common Item Count: " + _commonItemCount + "\n" + " Request Rate: " + _itemRequestsPerSec + "\n" + " Request Snapshots: " + (_requestSnapshots ? "Yes" : "No") + "\n" + " Posting Rate: " + _postsPerSec + "\n" + " Latency Posting Rate: " + _latencyPostsPerSec + "\n" + " Generic Msg Rate: " + _genMsgsPerSec + "\n" + " Generic Msg Latency Rate: " + _latencyGenMsgsPerSec + "\n" + " Item File: " + _itemFilename + "\n" + " Data File: " + _msgFilename + "\n" + " Summary File: " + _summaryFilename + "\n" + " Stats File: " + _statsFilename + "\n" + " Latency Log File: " + (_latencyLogFilename.length() > 0 ? _latencyLogFilename : "(none)") + "\n" + " Tick Rate: " + _ticksPerSec + "\n" + " Prime JVM: " + (_primeJVM ? "Yes" : "No") + "\n" + " Reactor/Watchlist Usage: " + reactorWatchlistUsageString + "\n" + " Tunnel Stream: " + (_useTunnel ? "Yes" : "No") + "\n" + " Tunnel Authentication: " + (_tunnelAuth ? "Yes" : "No") + "\n" + "TunnelStream Output Buffers: " + _tunnelStreamOutputBuffers + "\n" + "Print TunnelStream Bufs Used: " + (_tunnelStreamBufsUsed ? "Yes" : "No") + "\n" + " Busy Read: " + (_busyRead ? "Yes" : "No") + "\n"; } /* APPLICATION configuration */ /** * Time application runs before exiting. * * @return the int */ public int steadyStateTime() { return _steadyStateTime; } /** * Main loop ticks per second. * * @return the int */ public int ticksPerSec() { return _ticksPerSec; } /** * Number of threads that handle connections. * * @return the int */ public int threadCount() { return _threadCount; } /** * File of names to use when requesting items. * * @return the string */ public String itemFilename() { return _itemFilename; } /** * File of data to use for message payloads. * * @return the string */ public String msgFilename() { return _msgFilename; } /** * Whether to log update latency information to a file. * * @return true, if successful */ public boolean logLatencyToFile() { _logLatencyToFile = (_latencyLogFilename.length() > 0 ? true : false); return _logLatencyToFile; } /** * Name of the latency log file. * * @return the string */ public String latencyLogFilename() { return _latencyLogFilename; } /** * Name of the summary log file. * * @return the string */ public String summaryFilename() { return _summaryFilename; } /** * Name of the statistics log file. * * @return the string */ public String statsFilename() { return _statsFilename; } /** * Controls how often statistics are written. * * @return the int */ public int writeStatsInterval() { return _writeStatsInterval; } /** * Controls whether stats appear on the screen. * * @return true, if successful */ public boolean displayStats() { return _displayStats; } /** * Rate at which the consumer will send out item requests. * * @return the int */ public int itemRequestsPerSec() { return _itemRequestsPerSec; } /* CONNECTION configuration */ /** * Type of connection. * * @return the int */ public int connectionType() { return _connectionType; } /** * hostName, if using Channel.connect(). * * @return the string */ public String hostName() { return _hostName; } /** * Port number. * * @return the string */ public String portNo() { return _portNo; } /** * Name of interface. * * @return the string */ public String interfaceName() { return _interfaceName; } /** * Guaranteed Output Buffers. * * @return the int */ public int guaranteedOutputBuffers() { return _guaranteedOutputBuffers; } /** * TunnelStream Guaranteed Output Buffers. * * @return the int */ public int tunnelStreamGuaranteedOutputBuffers() { return _tunnelStreamOutputBuffers; } /** * Control to print TunnelStream Usage Buffers. * * @return the boolean */ public boolean tunnelStreamBufsUsed() { return _tunnelStreamBufsUsed; } /** * Input Buffers. * * @return the int */ public int numInputBuffers() { return _numInputBuffers; } /** * System Send Buffer Size. * * @return the int */ public int sendBufSize() { return _sendBufSize; } /** * System Receive Buffer Size. * * @return the int */ public int recvBufSize() { return _recvBufSize; } /** * Sets the point that causes UPA to automatically flush. * * @return the int */ public int highWaterMark() { return _highWaterMark; } /** * Enable/Disable Nagle's algorithm. * * @return true, if successful */ public boolean tcpNoDelay() { return _tcpNoDelay; } /** * Whether to request all items as snapshots. * * @return true, if successful */ public boolean requestSnapshots() { return _requestSnapshots; } /** * Username used when logging in. * * @return the string */ public String username() { return _username; } /** * Name of service to request items from. * * @return the string */ public String serviceName() { return _serviceName; } /** * Number of items to request. * * @return the int */ public int itemRequestCount() { return _itemRequestCount; } /** * Number of items common to all connections, if using multiple connections. * * @return the int */ public int commonItemCount() { return _commonItemCount; } /** * Number of posts to send per second. * * @return the int */ public int postsPerSec() { return _postsPerSec; } /** * Number of latency posts to send per second. * * @return the int */ public int latencyPostsPerSec() { return _latencyPostsPerSec; } /** * Number of generic messages to send per second. * * @return the int */ public int genMsgsPerSec() { return _genMsgsPerSec; } /** * Number of latency generic messages to send per second. * * @return the int */ public int latencyGenMsgsPerSec() { return _latencyGenMsgsPerSec; } /** * Number of requests to send per tick. * * @return the int */ public int requestsPerTick() { return _requestsPerTick; } /** * The remainder of number of requests to send per tick. * * @return the int */ public int requestsPerTickRemainder() { return _requestsPerTickRemainder; } /** * At startup, prime the JVM to optimize code by requesting a snapshot of all items before opening the streaming items. * * @return true, if successful */ public boolean primeJVM() { return _primeJVM; } /** * Converts configuration parameters to a string. * * @return the string */ public String toString() { return _configString; } /** * Use the VA Reactor instead of the UPA Channel for sending and receiving. * * @return true, if successful */ public boolean useReactor() { return _useReactor; } /** * Use the VA Reactor watchlist instead of the UPA Channel for sending and receiving. * * @return true, if successful */ public boolean useWatchlist() { return _useWatchlist; } /** * Use the VA Reactor tunnel stream instead of the UPA Channel for sending and receiving. * * @return true, if successful */ public boolean useTunnel() { return _useTunnel; } /** * Use to request authentication when opening a tunnel stream. * * @return true, if successful */ public boolean tunnelAuth() { return _tunnelAuth; } /** * If set, the application will continually read rather than using notification. * * @return true, if successful */ public boolean busyRead() { return _busyRead; } }
{ "pile_set_name": "Github" }
<!--pages/invitation/index.wxml--> <view class="container"> <!-- 展示官方 --> <view wx:if="{{isOfficial}}"> <image src='/image/inv.png' class='inv'></image> <image src='{{bgImg}}' class='cover' mode='aspectFill'></image> <view class='datetime' animation="{{animationData}}"> <view class='box'> <view class="name css13610f7ae66601"> <span class="fl">{{inviteName}}</span> </view> <view class="date css13610f7ae66601"> <view>{{inviteDateOne}}</view> <view>{{inviteDateTwo}}</view> <view bindtap="markertap">{{inviteAddress}}</view> <view>恭请您的光临</view> </view> </view> </view> </view> <!-- 正在创建自己的小程序 --> <view wx:else> <image bindtap="editBg" class='edit_bg' style='width:20px;height:20px;margin-left:5px;' src="{{editImg}}"></image> <image src='/image/inv.png' class='inv'></image> <image src='{{bgImg}}' class='cover' mode='aspectFill'></image> <view class='datetime' animation="{{animationData}}"> <view class='box'> <view bindtap="btnName" class="name css13610f7ae66601"> <span class="fl">{{inviteName}}</span> <image style='width:15px;height:15px;margin-left:5px;' src="{{editImg}}"></image> </view> <view class="date css13610f7ae66601"> <view bindtap="btnDateOne">{{inviteDateOne}} <image style='width:15px;height:15px;margin-left:5px;' src="{{editImg}}"></image> </view> <view bindtap="btnDateTwo">{{inviteDateTwo}} <image style='width:15px;height:15px;margin-left:5px;' src="{{editImg}}"></image> </view> <view bindtap="btnAddress">{{inviteAddress}} <image style='width:15px;height:15px;margin-left:5px;' src="{{editImg}}"></image> </view> </view> </view> </view> <!--弹窗--> <view class="modal-mask" bindtap="hideModal" catchtouchmove="preventTouchMove" wx:if="{{showModal}}"></view> <view class="modal-dialog" wx:if="{{showModal}}"> <view class="modal-title">请填写</view> <view class="modal-content"> <view class="modal-input"> <input id="{{editId}}" placeholder-class="input-holder" bindblur="inputChange" class="input" placeholder="{{editName}}"></input> </view> <view wx:if="{{isAddress}}"> <view class="modal-input"> <input placeholder-class="input-holder" bindblur="inputChangeJd" class="input" placeholder="经度"></input> </view> <view class="modal-input"> <input placeholder-class="input-holder" bindblur="inputChangeWd" class="input" placeholder="纬度"></input> </view> </view> </view> <view class="modal-footer"> <view class="btn-cancel" bindtap="onCancel" data-status="cancel">取消</view> <view class="btn-confirm" bindtap="onConfirm" data-status="confirm">确定</view> </view> </view> </view> </view>
{ "pile_set_name": "Github" }
import sys import unittest from datetime import datetime from isodate import datetime_isoformat, UTC from isodate.isostrf import DATE_EXT_COMPLETE, TZ_EXT from rdflib.term import URIRef from rdflib.term import Literal from rdflib.namespace import XSD class TestRelativeBase(unittest.TestCase): def test_equality(self): x = Literal( "2008-12-01T18:02:00Z", datatype=URIRef("http://www.w3.org/2001/XMLSchema#dateTime"), ) self.assertEqual(x == x, True) def test_microseconds(self): dt1 = datetime(2009, 6, 15, 23, 37, 6, 522630) l = Literal(dt1) # datetime with microseconds should be cast as a literal with using # XML Schema dateTime as the literal datatype self.assertEqual(str(l), "2009-06-15T23:37:06.522630") self.assertEqual(l.datatype, XSD.dateTime) dt2 = l.toPython() self.assertEqual(dt2, dt1) def test_to_python(self): dt = "2008-12-01T18:02:00" l = Literal(dt, datatype=URIRef("http://www.w3.org/2001/XMLSchema#dateTime")) self.assertTrue(isinstance(l.toPython(), datetime)) self.assertEqual(l.toPython().isoformat(), dt) def test_timezone_z(self): dt = "2008-12-01T18:02:00.522630Z" l = Literal(dt, datatype=URIRef("http://www.w3.org/2001/XMLSchema#dateTime")) self.assertTrue(isinstance(l.toPython(), datetime)) self.assertEqual( datetime_isoformat( l.toPython(), DATE_EXT_COMPLETE + "T" + "%H:%M:%S.%f" + TZ_EXT ), dt, ) self.assertEqual(l.toPython().isoformat(), "2008-12-01T18:02:00.522630+00:00") def test_timezone_offset(self): dt = "2010-02-10T12:36:00+03:00" l = Literal(dt, datatype=URIRef("http://www.w3.org/2001/XMLSchema#dateTime")) self.assertTrue(isinstance(l.toPython(), datetime)) self.assertEqual(l.toPython().isoformat(), dt) def test_timezone_offset_to_utc(self): dt = "2010-02-10T12:36:00+03:00" l = Literal(dt, datatype=URIRef("http://www.w3.org/2001/XMLSchema#dateTime")) utc_dt = l.toPython().astimezone(UTC) self.assertEqual(datetime_isoformat(utc_dt), "2010-02-10T09:36:00Z") def test_timezone_offset_millisecond(self): dt = "2011-01-16T19:39:18.239743+01:00" l = Literal(dt, datatype=URIRef("http://www.w3.org/2001/XMLSchema#dateTime")) self.assertTrue(isinstance(l.toPython(), datetime)) self.assertEqual(l.toPython().isoformat(), dt) if __name__ == "__main__": unittest.main()
{ "pile_set_name": "Github" }
#include "CCBAnimationManager.h" #include "CCBSequence.h" #include "CCBSequenceProperty.h" #include "CCBReader.h" #include "CCBKeyframe.h" #include "CCNode+CCBRelativePositioning.h" #include "audio/include/SimpleAudioEngine.h" #include "CCBSelectorResolver.h" #include <string> #include <sstream> #include <set> using namespace cocos2d; using namespace std; using namespace cocos2d::extension; namespace cocosbuilder { // Implementation of CCBAinmationManager CCBAnimationManager::CCBAnimationManager() : _jsControlled(false) , _owner(nullptr) , _autoPlaySequenceId(0) , _rootNode(nullptr) , _rootContainerSize(Size::ZERO) , _delegate(nullptr) , _runningSequence(nullptr) { init(); } bool CCBAnimationManager::init() { _target = nullptr; _animationCompleteCallbackFunc = nullptr; return true; } CCBAnimationManager::~CCBAnimationManager() { // DictElement *pElement = nullptr; // CCDICT_FOREACH(_nodeSequences, pElement) // { // Node *node = (Node*)pElement->getIntKey(); // node->release(); // } // // CCDICT_FOREACH(_baseValues, pElement) // { // Node *node = (Node*)pElement->getIntKey(); // node->release(); // } if (_rootNode) { _rootNode->stopAllActions(); } setRootNode(nullptr); setDelegate(nullptr); for (auto iter = _objects.begin(); iter != _objects.end(); ++iter) { for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2) { iter2->second->release(); } } CC_SAFE_RELEASE(_target); } Vector<CCBSequence*>& CCBAnimationManager::getSequences() { return _sequences; } void CCBAnimationManager::setSequences(const Vector<CCBSequence*>& seq) { _sequences = seq; } int CCBAnimationManager::getAutoPlaySequenceId() { return _autoPlaySequenceId; } void CCBAnimationManager::setAutoPlaySequenceId(int autoPlaySequenceId) { _autoPlaySequenceId = autoPlaySequenceId; } Node* CCBAnimationManager::getRootNode() { return _rootNode; } void CCBAnimationManager::setRootNode(Node *pRootNode) { _rootNode = pRootNode; } void CCBAnimationManager::setDocumentControllerName(const std::string &name) { _documentControllerName = name; } std::string CCBAnimationManager::getDocumentControllerName() { return _documentControllerName; } void CCBAnimationManager::addDocumentCallbackNode(Node *node) { _documentCallbackNodes.pushBack(node); } void CCBAnimationManager::addDocumentCallbackName(std::string name) { _documentCallbackNames.push_back(Value(name)); } void CCBAnimationManager::addDocumentCallbackControlEvents(Control::EventType eventType) { _documentCallbackControlEvents.push_back(Value(static_cast<int>(eventType))); } ValueVector& CCBAnimationManager::getDocumentCallbackNames() { return _documentCallbackNames; } Vector<Node*>& CCBAnimationManager::getDocumentCallbackNodes() { return _documentCallbackNodes; } ValueVector& CCBAnimationManager::getDocumentCallbackControlEvents() { return _documentCallbackControlEvents; } void CCBAnimationManager::addDocumentOutletNode(Node *node) { _documentOutletNodes.pushBack(node); } void CCBAnimationManager::addDocumentOutletName(std::string name) { _documentOutletNames.push_back(Value(name)); } ValueVector& CCBAnimationManager::getDocumentOutletNames() { return _documentOutletNames; } Vector<Node*>& CCBAnimationManager::getDocumentOutletNodes() { return _documentOutletNodes; } std::string CCBAnimationManager::getLastCompletedSequenceName() { return _lastCompletedSequenceName; } ValueVector& CCBAnimationManager::getKeyframeCallbacks() { return _keyframeCallbacks; } const Size& CCBAnimationManager::getRootContainerSize() { return _rootContainerSize; } void CCBAnimationManager::setRootContainerSize(const Size &rootContainerSize) { _rootContainerSize.setSize(rootContainerSize.width, rootContainerSize.height); } CCBAnimationManagerDelegate* CCBAnimationManager::getDelegate() { return _delegate; } void CCBAnimationManager::setDelegate(CCBAnimationManagerDelegate *pDelegate) { CC_SAFE_RELEASE(dynamic_cast<Ref*>(_delegate)); _delegate = pDelegate; CC_SAFE_RETAIN(dynamic_cast<Ref*>(_delegate)); } const char* CCBAnimationManager::getRunningSequenceName() { if (_runningSequence) { return _runningSequence->getName(); } return nullptr; } const Size& CCBAnimationManager::getContainerSize(Node *pNode) { if (pNode) { return pNode->getContentSize(); } else { return _rootContainerSize; } } // refer to CCBReader::readNodeGraph() for data structure of pSeq void CCBAnimationManager::addNode(Node *pNode, const std::unordered_map<int, Map<std::string, CCBSequenceProperty*>>& seq) { // pNode->retain(); _nodeSequences[pNode] = seq; } void CCBAnimationManager::setBaseValue(const Value& value, Node *pNode, const std::string& propName) { auto& props = _baseValues[pNode]; props[propName] = value; } const Value& CCBAnimationManager::getBaseValue(Node *pNode, const std::string& propName) { auto& props = _baseValues[pNode]; return props[propName]; } void CCBAnimationManager::setObject(Ref* obj, Node *pNode, const std::string& propName) { auto& props = _objects[pNode]; auto iter = props.find(propName); if (iter != props.end()) iter->second->release(); props[propName] = obj; obj->retain(); } Ref* CCBAnimationManager::getObject(Node *pNode, const std::string& propName) { auto& props = _objects[pNode]; auto iter = props.find(propName); if (iter != props.end()) return iter->second; return nullptr; } int CCBAnimationManager::getSequenceId(const char* pSequenceName) { string seqName(pSequenceName); for (auto& seq : _sequences) { if (seqName.compare(seq->getName()) == 0) { return seq->getSequenceId(); } } return -1; } CCBSequence* CCBAnimationManager::getSequence(int nSequenceId) { for (auto& seq : _sequences) { if (seq->getSequenceId() == nSequenceId) { return seq; } } return nullptr; } float CCBAnimationManager::getSequenceDuration(const char *pSequenceName) { int id = getSequenceId(pSequenceName); if (id != -1) return getSequence(id)->getDuration(); return 0; } void CCBAnimationManager::moveAnimationsFromNode(Node* fromNode, Node* toNode) { // Move base values auto baseValueIter = _baseValues.find(fromNode); if(baseValueIter != _baseValues.end()) { _baseValues[toNode] = baseValueIter->second; _baseValues.erase(baseValueIter); // fromNode->release(); // toNode->retain(); } auto objIter = _objects.find(fromNode); if (objIter != _objects.end()) { _objects[toNode] = objIter->second; _objects.erase(objIter); } // Move seqs auto seqsIter = _nodeSequences.find(fromNode); if (seqsIter != _nodeSequences.end()) { _nodeSequences[toNode] = seqsIter->second; _nodeSequences.erase(seqsIter); // fromNode->release(); // toNode->retain(); } } // Refer to CCBReader::readKeyframe() for the real type of value ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const std::string& propName, Node *pNode) { float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0); if (propName == "rotationX") { return CCBRotateXTo::create(duration, pKeyframe1->getValue().asFloat()); } else if (propName == "rotationY") { return CCBRotateYTo::create(duration, pKeyframe1->getValue().asFloat()); } else if (propName == "rotation") { return CCBRotateTo::create(duration, pKeyframe1->getValue().asFloat()); } else if (propName == "opacity") { return FadeTo::create(duration, pKeyframe1->getValue().asByte()); } else if (propName == "color") { auto c = pKeyframe1->getValue().asValueMap(); unsigned char r = c["r"].asByte(); unsigned char g = c["g"].asByte(); unsigned char b = c["b"].asByte(); return TintTo::create(duration, r, g, b); } else if (propName == "visible") { if (pKeyframe1->getValue().asBool()) { return Sequence::createWithTwoActions(DelayTime::create(duration), Show::create()); } else { return Sequence::createWithTwoActions(DelayTime::create(duration), Hide::create()); } } else if (propName == "displayFrame") { return Sequence::createWithTwoActions(DelayTime::create(duration), CCBSetSpriteFrame::create(static_cast<SpriteFrame*>(pKeyframe1->getObject()))); } else if (propName == "position") { // Get position type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::PositionType type = (CCBReader::PositionType)array[2].asInt(); // Get relative position auto value = pKeyframe1->getValue().asValueVector(); float x = value[0].asFloat(); float y = value[1].asFloat(); Size containerSize = getContainerSize(pNode->getParent()); Vec2 absPos = getAbsolutePosition(Vec2(x,y), type, containerSize, propName); return MoveTo::create(duration, absPos); } else if (propName == "scale") { // Get position type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::ScaleType type = (CCBReader::ScaleType)array[2].asInt(); // Get relative scale auto value = pKeyframe1->getValue().asValueVector(); float x = value[0].asFloat(); float y = value[1].asFloat(); if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION) { float resolutionScale = CCBReader::getResolutionScale(); x *= resolutionScale; y *= resolutionScale; } return ScaleTo::create(duration, x, y); } else if (propName == "skew") { // Get relative skew auto& value = pKeyframe1->getValue().asValueVector(); float x = value[0].asFloat(); float y = value[1].asFloat(); return SkewTo::create(duration, x, y); } else { log("CCBReader: Failed to create animation for property: %s", propName.c_str()); } return nullptr; } void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node *pNode, const Value& value, Ref* obj, float fTweenDuration) { if (fTweenDuration > 0) { // Create a fake keyframe to generate the action from CCBKeyframe *kf1 = new CCBKeyframe(); kf1->autorelease(); kf1->setObject(obj); kf1->setValue(value); kf1->setTime(fTweenDuration); kf1->setEasingType(CCBKeyframe::EasingType::LINEAR); // Animate ActionInterval *tweenAction = getAction(nullptr, kf1, propName, pNode); pNode->runAction(tweenAction); } else { // Just set the value if (propName == "position") { // Get position type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::PositionType type = (CCBReader::PositionType)array[2].asInt(); // Get relative position auto& valueVector = value.asValueVector(); float x = valueVector[0].asFloat(); float y = valueVector[1].asFloat(); pNode->setPosition(getAbsolutePosition(Vec2(x,y), type, getContainerSize(pNode->getParent()), propName)); } else if (propName == "scale") { // Get scale type auto& array = getBaseValue(pNode, propName).asValueVector(); CCBReader::ScaleType type = (CCBReader::ScaleType)array[2].asInt(); // Get relative scale auto& valueVector = value.asValueVector(); float x = valueVector[0].asFloat(); float y = valueVector[1].asFloat(); setRelativeScale(pNode, x, y, type, propName); } else if(propName == "skew") { // Get relative scale auto& valueVector = value.asValueVector(); float x = valueVector[0].asFloat(); float y = valueVector[1].asFloat(); pNode->setSkewX(x); pNode->setSkewY(y); } else { // [node setValue:value forKey:name]; // TODO only handle rotation, opacity, displayFrame, color if (propName == "rotation") { float rotate = value.asFloat(); pNode->setRotation(rotate); } else if(propName == "rotationX") { float rotate = value.asFloat(); pNode->setRotationSkewX(rotate); }else if(propName == "rotationY") { float rotate = value.asFloat(); pNode->setRotationSkewY(rotate); } else if (propName == "opacity") { unsigned char opacity = value.asByte(); pNode->setOpacity(opacity); } else if (propName == "displayFrame") { static_cast<Sprite*>(pNode)->setSpriteFrame(static_cast<SpriteFrame*>(obj)); } else if (propName == "color") { auto c = value.asValueMap(); unsigned char r = c["r"].asByte(); unsigned char g = c["g"].asByte(); unsigned char b = c["b"].asByte(); pNode->setColor(Color3B(r, g, b)); } else if (propName == "visible") { bool visible = value.asBool(); pNode->setVisible(visible); } else { log("unsupported property name is %s", propName.c_str()); CCASSERT(false, "unsupported property now"); } } } } void CCBAnimationManager::setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration) { auto& keyframes = pSeqProp->getKeyframes(); if (keyframes.empty()) { // Use base value (no animation) auto& baseValue = getBaseValue(pNode, pSeqProp->getName()); auto obj = getObject(pNode, pSeqProp->getName()); CCASSERT(!baseValue.isNull(), "No baseValue found for property"); setAnimatedProperty(pSeqProp->getName(), pNode, baseValue, obj, fTweenDuration); } else { // Use first keyframe CCBKeyframe *keyframe = keyframes.at(0); setAnimatedProperty(pSeqProp->getName(), pNode, keyframe->getValue(), keyframe->getObject(), fTweenDuration); } } ActionInterval* CCBAnimationManager::getEaseAction(ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt) { if (dynamic_cast<Sequence*>(pAction)) { return pAction; } if (easingType == CCBKeyframe::EasingType::LINEAR) { return pAction; } else if (easingType == CCBKeyframe::EasingType::INSTANT) { return CCBEaseInstant::create(pAction); } else if (easingType == CCBKeyframe::EasingType::CUBIC_IN) { return EaseIn::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::CUBIC_OUT) { return EaseOut::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::CUBIC_INOUT) { return EaseInOut::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::BACK_IN) { return EaseBackIn::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BACK_OUT) { return EaseBackOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BACK_INOUT) { return EaseBackInOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BOUNCE_IN) { return EaseBounceIn::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BOUNCE_OUT) { return EaseBounceOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::BOUNCE_INOUT) { return EaseBounceInOut::create(pAction); } else if (easingType == CCBKeyframe::EasingType::ELASTIC_IN) { return EaseElasticIn::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::ELASTIC_OUT) { return EaseElasticOut::create(pAction, fEasingOpt); } else if (easingType == CCBKeyframe::EasingType::ELASTIC_INOUT) { return EaseElasticInOut::create(pAction, fEasingOpt); } else { log("CCBReader: Unkown easing type %d", easingType); return pAction; } } Sequence* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* channel) { float lastKeyframeTime = 0; Vector<FiniteTimeAction*> actions; auto& keyframes = channel->getKeyframes(); ssize_t numKeyframes = keyframes.size(); for (long i = 0; i < numKeyframes; ++i) { CCBKeyframe *keyframe = keyframes.at(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { actions.pushBack(DelayTime::create(timeSinceLastKeyframe)); } auto& keyVal = keyframe->getValue().asValueVector(); std::string selectorName = keyVal[0].asString(); CCBReader::TargetType selectorTarget = (CCBReader::TargetType)keyVal[1].asInt(); if(_jsControlled) { std::stringstream callbackName; callbackName << static_cast<int>(selectorTarget); callbackName << ":" + selectorName; auto callback = _keyframeCallFuncs.at(callbackName.str()); if (nullptr != callback) { CallFunc* callbackClone = callback->clone(); if (callbackClone != nullptr) { actions.pushBack(callbackClone); } } } else { Ref* target = nullptr; if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) target = _rootNode; else if (selectorTarget == CCBReader::TargetType::OWNER) target = _owner; if(target != nullptr) { if(selectorName.length() > 0) { SEL_CallFuncN selCallFunc = 0; CCBSelectorResolver* targetAsCCBSelectorResolver = dynamic_cast<CCBSelectorResolver *>(target); if(targetAsCCBSelectorResolver != nullptr) { selCallFunc = targetAsCCBSelectorResolver->onResolveCCBCCCallFuncSelector(target, selectorName.c_str ()); } if(selCallFunc == 0) { CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); } else { auto savedTarget = std::make_shared<Vector<Ref*>>(); savedTarget->pushBack(target); auto callback = CallFuncN::create([savedTarget, selCallFunc](Node* sender){ auto t = savedTarget->at(0); (t->*selCallFunc)(sender); }); actions.pushBack(callback); } } else { CCLOG("Unexpected empty selector."); } } } } if(actions.size() < 1) return nullptr; return Sequence::create(actions); } Sequence* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel) { float lastKeyframeTime = 0; Vector<FiniteTimeAction*> actions; auto& keyframes = channel->getKeyframes(); ssize_t numKeyframes = keyframes.size(); for (int i = 0; i < numKeyframes; ++i) { CCBKeyframe *keyframe = keyframes.at(i); float timeSinceLastKeyframe = keyframe->getTime() - lastKeyframeTime; lastKeyframeTime = keyframe->getTime(); if(timeSinceLastKeyframe > 0) { actions.pushBack(DelayTime::create(timeSinceLastKeyframe)); } stringstream ss (stringstream::in | stringstream::out); auto& keyVal = keyframe->getValue().asValueVector(); std::string soundFile = keyVal[0].asString(); float pitch, pan, gain; ss << keyVal[1].asString(); ss >> pitch; ss.flush(); ss << keyVal[2].asString(); ss >> pan; ss.flush(); ss << keyVal[3].asString(); ss >> gain; ss.flush(); actions.pushBack(CCBSoundEffect::actionWithSoundFile(soundFile, pitch, pan, gain)); } if(actions.size() < 1) return nullptr; return Sequence::create(actions); } void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration) { auto& keyframes = pSeqProp->getKeyframes(); ssize_t numKeyframes = keyframes.size(); if (numKeyframes > 1) { // Make an animation! Vector<FiniteTimeAction*> actions; CCBKeyframe *keyframeFirst = keyframes.at(0); float timeFirst = keyframeFirst->getTime() + fTweenDuration; if (timeFirst > 0) { actions.pushBack(DelayTime::create(timeFirst)); } for (ssize_t i = 0; i < numKeyframes - 1; ++i) { CCBKeyframe *kf0 = keyframes.at(i); CCBKeyframe *kf1 = keyframes.at(i+1); ActionInterval *action = getAction(kf0, kf1, pSeqProp->getName(), pNode); if (action) { // Apply easing action = getEaseAction(action, kf0->getEasingType(), kf0->getEasingOpt()); actions.pushBack(action); } } auto seq = Sequence::create(actions); pNode->runAction(seq); } } void CCBAnimationManager::runAnimations(const char *pName, float fTweenDuration) { runAnimationsForSequenceNamedTweenDuration(pName, fTweenDuration); } void CCBAnimationManager::runAnimations(const char *pName) { runAnimationsForSequenceNamed(pName); } void CCBAnimationManager::runAnimations(int nSeqId, float fTweenDuraiton) { runAnimationsForSequenceIdTweenDuration(nSeqId, fTweenDuraiton); } void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuration) { CCASSERT(nSeqId != -1, "Sequence id couldn't be found"); _rootNode->stopAllActions(); for (auto nodeSeqIter = _nodeSequences.begin(); nodeSeqIter != _nodeSequences.end(); ++nodeSeqIter) { Node *node = nodeSeqIter->first; node->stopAllActions(); // Refer to CCBReader::readKeyframe() for the real type of value auto seqs = nodeSeqIter->second; auto seqNodeProps = seqs[nSeqId]; std::set<std::string> seqNodePropNames; if (!seqNodeProps.empty()) { // Reset nodes that have sequence node properties, and run actions on them for (auto iter = seqNodeProps.begin(); iter != seqNodeProps.end(); ++iter) { const std::string propName = iter->first; CCBSequenceProperty *seqProp = iter->second; seqNodePropNames.insert(propName); setFirstFrame(node, seqProp, fTweenDuration); runAction(node, seqProp, fTweenDuration); } } // Reset the nodes that may have been changed by other timelines auto& nodeBaseValues = _baseValues[node]; if (!nodeBaseValues.empty()) { for (auto iter = nodeBaseValues.begin(); iter != nodeBaseValues.end(); ++iter) { if (seqNodePropNames.find(iter->first) == seqNodePropNames.end()) { setAnimatedProperty(iter->first, node, iter->second, nullptr, fTweenDuration); } } } auto& nodeObject = _objects[node]; if (!nodeObject.empty()) { for (auto iter = nodeObject.begin(); iter != nodeObject.end(); ++iter) { if (seqNodePropNames.find(iter->first) == seqNodePropNames.end()) { setAnimatedProperty(iter->first, node, Value(), iter->second, fTweenDuration); } } } } // Make callback at end of sequence CCBSequence *seq = getSequence(nSeqId); Action *completeAction = Sequence::createWithTwoActions(DelayTime::create(seq->getDuration() + fTweenDuration), CallFunc::create( CC_CALLBACK_0(CCBAnimationManager::sequenceCompleted,this))); _rootNode->runAction(completeAction); // Set the running scene if(seq->getCallbackChannel() != nullptr) { Action* action = (Action *)actionForCallbackChannel(seq->getCallbackChannel()); if(action != nullptr) { _rootNode->runAction(action); } } if(seq->getSoundChannel() != nullptr) { Action* action = (Action *)actionForSoundChannel(seq->getSoundChannel()); if(action != nullptr) { _rootNode->runAction(action); } } _runningSequence = getSequence(nSeqId); } void CCBAnimationManager::runAnimationsForSequenceNamedTweenDuration(const char *pName, float fTweenDuration) { int seqId = getSequenceId(pName); runAnimationsForSequenceIdTweenDuration(seqId, fTweenDuration); } void CCBAnimationManager::runAnimationsForSequenceNamed(const char *pName) { runAnimationsForSequenceNamedTweenDuration(pName, 0); } void CCBAnimationManager::debug() { } void CCBAnimationManager::setAnimationCompletedCallback(Ref *target, SEL_CallFunc callbackFunc) { if (target) { target->retain(); } if (_target) { _target->release(); } _target = target; _animationCompleteCallbackFunc = callbackFunc; } void CCBAnimationManager::setCallFunc(CallFunc* callFunc, const std::string &callbackNamed) { _keyframeCallFuncs.insert(callbackNamed, callFunc); } void CCBAnimationManager::sequenceCompleted() { const char *runningSequenceName = _runningSequence->getName(); int nextSeqId = _runningSequence->getChainedSequenceId(); _runningSequence = nullptr; if(_lastCompletedSequenceName != runningSequenceName) { _lastCompletedSequenceName = runningSequenceName; } if (nextSeqId != -1) { runAnimationsForSequenceIdTweenDuration(nextSeqId, 0); } if (_delegate) { // There may be another runAnimation() call in this delegate method // which will assign _runningSequence _delegate->completedAnimationSequenceNamed(runningSequenceName); } if (_target && _animationCompleteCallbackFunc) { (_target->*_animationCompleteCallbackFunc)(); } } // Custom actions /************************************************************ CCBSetSpriteFrame ************************************************************/ CCBSetSpriteFrame* CCBSetSpriteFrame::create(SpriteFrame *pSpriteFrame) { CCBSetSpriteFrame *ret = new CCBSetSpriteFrame(); if (ret) { if (ret->initWithSpriteFrame(pSpriteFrame)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBSetSpriteFrame::initWithSpriteFrame(SpriteFrame *pSpriteFrame) { _spriteFrame = pSpriteFrame; CC_SAFE_RETAIN(_spriteFrame); return true; } CCBSetSpriteFrame::~CCBSetSpriteFrame() { CC_SAFE_RELEASE_NULL(_spriteFrame); } CCBSetSpriteFrame* CCBSetSpriteFrame::clone() const { // no copy constructor auto a = new CCBSetSpriteFrame(); a->initWithSpriteFrame(_spriteFrame); a->autorelease(); return a; } CCBSetSpriteFrame* CCBSetSpriteFrame::reverse() const { // returns a copy of itself return this->clone(); } void CCBSetSpriteFrame::update(float time) { static_cast<Sprite*>(_target)->setSpriteFrame(_spriteFrame); } /************************************************************ CCBSoundEffect ************************************************************/ CCBSoundEffect* CCBSoundEffect::actionWithSoundFile(const std::string &filename, float pitch, float pan, float gain) { CCBSoundEffect* pRet = new CCBSoundEffect(); if (pRet != nullptr && pRet->initWithSoundFile(filename, pitch, pan, gain)) { pRet->autorelease(); } else { CC_SAFE_DELETE(pRet); } return pRet; } CCBSoundEffect::~CCBSoundEffect() { } bool CCBSoundEffect::initWithSoundFile(const std::string &filename, float pitch, float pan, float gain) { _soundFile = filename; _pitch = pitch; _pan = pan; _gain = gain; return true; } CCBSoundEffect* CCBSoundEffect::clone() const { // no copy constructor auto a = new CCBSoundEffect(); a->initWithSoundFile(_soundFile, _pitch, _pan, _gain); a->autorelease(); return a; } CCBSoundEffect* CCBSoundEffect::reverse() const { // returns a copy of itself return this->clone(); } void CCBSoundEffect::update(float time) { CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(_soundFile.c_str()); } /************************************************************ CCBRotateTo ************************************************************/ CCBRotateTo* CCBRotateTo::create(float fDuration, float fAngle) { CCBRotateTo *ret = new CCBRotateTo(); if (ret) { if (ret->initWithDuration(fDuration, fAngle)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBRotateTo::initWithDuration(float fDuration, float fAngle) { if (ActionInterval::initWithDuration(fDuration)) { _dstAngle = fAngle; return true; } else { return false; } } CCBRotateTo* CCBRotateTo::clone() const { // no copy constructor auto a = new CCBRotateTo(); a->initWithDuration(_duration, _dstAngle); a->autorelease(); return a; } CCBRotateTo* CCBRotateTo::reverse() const { CCASSERT(false, "reverse() is not supported in CCBRotateTo"); return nullptr; } void CCBRotateTo::startWithTarget(Node *pNode) { ActionInterval::startWithTarget(pNode); _startAngle = _target->getRotation(); _diffAngle = _dstAngle - _startAngle; } void CCBRotateTo::update(float time) { _target->setRotation(_startAngle + (_diffAngle * time)) ; } /************************************************************ CCBRotateXTO ************************************************************/ CCBRotateXTo* CCBRotateXTo::create(float fDuration, float fAngle) { CCBRotateXTo *ret = new CCBRotateXTo(); if (ret) { if (ret->initWithDuration(fDuration, fAngle)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBRotateXTo::initWithDuration(float fDuration, float fAngle) { if (ActionInterval::initWithDuration(fDuration)) { _dstAngle = fAngle; return true; } else { return false; } } void CCBRotateXTo::startWithTarget(Node *pNode) { //CCActionInterval::startWithTarget(pNode); _originalTarget = pNode; _target = pNode; _elapsed = 0.0f; _firstTick = true; _startAngle = _target->getRotationSkewX(); _diffAngle = _dstAngle - _startAngle; } CCBRotateXTo* CCBRotateXTo::clone() const { // no copy constructor auto a = new CCBRotateXTo(); a->initWithDuration(_duration, _dstAngle); a->autorelease(); return a; } CCBRotateXTo* CCBRotateXTo::reverse() const { CCASSERT(false, "reverse() is not supported in CCBRotateXTo"); return nullptr; } void CCBRotateXTo::update(float time) { _target->setRotationSkewX(_startAngle + (_diffAngle * time)); } /************************************************************ CCBRotateYTO ************************************************************/ CCBRotateYTo* CCBRotateYTo::create(float fDuration, float fAngle) { CCBRotateYTo *ret = new CCBRotateYTo(); if (ret) { if (ret->initWithDuration(fDuration, fAngle)) { ret->autorelease(); } else { CC_SAFE_DELETE(ret); } } return ret; } bool CCBRotateYTo::initWithDuration(float fDuration, float fAngle) { if (ActionInterval::initWithDuration(fDuration)) { _dstAngle = fAngle; return true; } else { return false; } } CCBRotateYTo* CCBRotateYTo::clone() const { // no copy constructor auto a = new CCBRotateYTo(); a->initWithDuration(_duration, _dstAngle); a->autorelease(); return a; } CCBRotateYTo* CCBRotateYTo::reverse() const { CCASSERT(false, "reverse() is not supported in CCBRotateXTo"); return nullptr; } void CCBRotateYTo::startWithTarget(Node *pNode) { // ActionInterval::startWithTarget(pNode); _originalTarget = pNode; _target = pNode; _elapsed = 0.0f; _firstTick = true; _startAngle = _target->getRotationSkewY(); _diffAngle = _dstAngle - _startAngle; } void CCBRotateYTo::update(float time) { _target->setRotationSkewY(_startAngle + (_diffAngle * time)); } /************************************************************ CCBEaseInstant ************************************************************/ CCBEaseInstant* CCBEaseInstant::create(ActionInterval *pAction) { CCBEaseInstant *pRet = new CCBEaseInstant(); if (pRet && pRet->initWithAction(pAction)) { pRet->autorelease(); } else { CC_SAFE_RELEASE_NULL(pRet); } return pRet; } CCBEaseInstant* CCBEaseInstant::clone() const { // no copy constructor auto a = new CCBEaseInstant(); a->initWithAction(_inner); a->autorelease(); return a; } CCBEaseInstant* CCBEaseInstant::reverse() const { return CCBEaseInstant::create(_inner->reverse()); } void CCBEaseInstant::update(float dt) { if (dt < 0) { _inner->update(0); } else { _inner->update(1); } } }
{ "pile_set_name": "Github" }
%YAML 1.1 %TAG !u! tag:unity3d.com,2011: --- !u!84 &8400000 RenderTexture: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: TAA_RT_FP16 m_ImageContentsHash: serializedVersion: 2 Hash: 00000000000000000000000000000000 m_ForcedFallbackFormat: 4 m_DownscaleFallback: 0 serializedVersion: 3 m_Width: 512 m_Height: 512 m_AntiAliasing: 1 m_MipCount: -1 m_DepthFormat: 2 m_ColorFormat: 48 m_MipMap: 0 m_GenerateMips: 0 m_SRGB: 0 m_UseDynamicScale: 0 m_BindMS: 0 m_EnableCompatibleFormat: 1 m_TextureSettings: serializedVersion: 2 m_FilterMode: 1 m_Aniso: 0 m_MipBias: 0 m_WrapU: 1 m_WrapV: 1 m_WrapW: 1 m_Dimension: 2 m_VolumeDepth: 1
{ "pile_set_name": "Github" }
// LockedStream.cpp
{ "pile_set_name": "Github" }
{ "CVE_data_meta": { "ASSIGNER": "[email protected]", "ID": "CVE-2018-3612", "STATE": "PUBLIC" }, "affects": { "vendor": { "vendor_data": [ { "product": { "product_data": [ { "product_name": "n/a", "version": { "version_data": [ { "version_value": "n/a" } ] } } ] }, "vendor_name": "n/a" } ] } }, "data_format": "MITRE", "data_type": "CVE", "data_version": "4.0", "description": { "description_data": [ { "lang": "eng", "value": "Intel NUC kits with insufficient input validation in system firmware, potentially allows a local attacker to elevate privileges to System Management Mode (SMM)." } ] }, "problemtype": { "problemtype_data": [ { "description": [ { "lang": "eng", "value": "n/a" } ] } ] }, "references": { "reference_data": [ { "name": "https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00110.html", "refsource": "CONFIRM", "url": "https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00110.html" } ] } }
{ "pile_set_name": "Github" }
/* ----------------------------------------------------------------------------- * Copyright (c) 2013-2014 ARM Ltd. * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from * the use of this software. Permission is granted to anyone to use this * software for any purpose, including commercial applications, and to alter * it and redistribute it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software in * a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. * * * $Date: 24. April 2014 * $Revision: V1.00 * * Project: GPDMA Driver for NXP LPC18xx * -------------------------------------------------------------------------- */ #include "LPC18xx.h" #include "GPDMA_LPC18xx.h" // GPDMA Channel register block structure typedef struct { __IO uint32_t SRCADDR; // DMA Channel Source Address Register __IO uint32_t DESTADDR; // DMA Channel Destination Address Register __IO uint32_t LLI; // DMA Channel Linked List Item Register __IO uint32_t CONTROL; // DMA Channel Control Register __IO uint32_t CONFIG; // DMA Channel Configuration Register __I uint32_t RESERVED1[3]; } GPDMA_CHANNEL_REG; // GPDMA Callback pointers static GPDMA_SignalEvent_t GPDMA_cb_event[GPDMA_NUMBER_OF_CHANNELS]; static uint32_t Channel_active = 0; #define GPDMA_CHANNEL(n) ((GPDMA_CHANNEL_REG *) (&(LPC_GPDMA->C0SRCADDR) + (n * 8))) /** \fn int32_t Set_Channel_active_flag (uint8_t ch) \brief Protected set of channel active flag \param[in] ch Channel number (0..7) \returns - \b 0: function succeeded - \b -1: function failed */ static int32_t Set_Channel_active_flag (uint8_t ch) { uint32_t val; do { val = __LDREXW (&Channel_active); if (val & (1 << ch)) { __CLREX (); return -1; } } while (__STREXW (val | (1 << ch), &Channel_active)); return 0; } /** \fn void Clear_Channel_active_flag (uint8_t ch) \brief Protected clear of channel active flag \param[in] ch Channel number (0..7) */ static void Clear_Channel_active_flag (uint8_t ch) { while(__STREXW((__LDREXW(&Channel_active) & ~(1 << ch)), &Channel_active)); } /** \fn int32_t GPDMA_Initialize (void) \brief Initialize GPDMA peripheral \returns - \b 0: function succeeded - \b -1: function failed */ int32_t GPDMA_Initialize (void) { uint32_t ch_num; // Enable DMA clock LPC_CCU1->CLK_M3_DMA_CFG |= 1; while ((LPC_CCU1->CLK_M3_DMA_STAT & 1) == 0); // Reset DMA LPC_RGU->RESET_CTRL0 = (1 << 19); // Reset all DMA channels for (ch_num = 0; ch_num < GPDMA_NUMBER_OF_CHANNELS; ch_num++) GPDMA_CHANNEL(ch_num)->CONFIG = 0; // Clear all DMA interrupt flags LPC_GPDMA->INTTCCLEAR = 0xFF; LPC_GPDMA->INTERRCLR = 0xFF; // Clear and Enable DMA IRQ NVIC_ClearPendingIRQ(DMA_IRQn); NVIC_EnableIRQ(DMA_IRQn); return 0; } /** \fn int32_t GPDMA_Uninitialize (void) \brief De-initialize GPDMA peripheral \returns - \b 0: function succeeded - \b -1: function failed */ int32_t GPDMA_Uninitialize (void) { // Disable DMA clock LPC_CCU1->CLK_M3_DMA_CFG &= ~1; // Disable and Clear DMA IRQ NVIC_DisableIRQ(DMA_IRQn); NVIC_ClearPendingIRQ(DMA_IRQn); return 0; } /** \fn int32_t GPDMA_PeripheralSelect (uint8_t peri, uint8_t sel) \brief Configure GPDMA multiplexer \param[in] peri GPDMA peripheral (0..15) \param[in] sel GPDMA multiplexer peripheral selection (0..3) \returns - \b 0: function succeeded - \b -1: function failed */ int32_t GPDMA_PeripheralSelect (uint8_t peri, uint8_t sel) { if ((peri > 15) || (sel > 3)) return -1; LPC_CREG->DMAMUX &= ~(3 << (2 * peri)); LPC_CREG->DMAMUX |= (sel << (2 * peri)); return 0; } /** \fn int32_t GPDMA_ChannelConfigure (uint8_t ch, uint32_t src_addr, uint32_t dest_addr, uint32_t control, uint32_t config, GPDMA_SignalEvent_t cb_event) \brief Configure GPDMA channel for next transfer \param[in] ch Channel number (0..7) \param[in] src_addr Source address \param[in] dest_addr Destination address \param[in] control Channel control \param[in] config Channel configuration \param[in] cb_event Channel callback pointer \returns - \b 0: function succeeded - \b -1: function failed */ int32_t GPDMA_ChannelConfigure (uint8_t ch, uint32_t src_addr, uint32_t dest_addr, uint32_t control, uint32_t config, GPDMA_SignalEvent_t cb_event) { GPDMA_CHANNEL_REG * dma_ch; // Check if channel is valid if (ch >= GPDMA_NUMBER_OF_CHANNELS) return -1; // Set Channel active flag if (Set_Channel_active_flag (ch) == -1) return -1; // Save callback pointer GPDMA_cb_event[ch] = cb_event; dma_ch = GPDMA_CHANNEL(ch); // Reset DMA Channel configuration dma_ch->CONFIG = 0; dma_ch->CONTROL = 0; // Clear DMA interrupts LPC_GPDMA->INTTCCLEAR = (1 << ch); LPC_GPDMA->INTERRCLR = (1 << ch); // Linker list not supported dma_ch->LLI = 0; // Enable DMA Channels, little endian LPC_GPDMA->CONFIG = GPDMA_CONFIG_E; while ((LPC_GPDMA->CONFIG & GPDMA_CONFIG_E) == 0); // Set Source and destination address dma_ch->SRCADDR = src_addr; dma_ch->DESTADDR = dest_addr; dma_ch->CONTROL = control; dma_ch->CONFIG = config; if ((config & GPDMA_CONFIG_E) == 0) { // Clear Channel active flag Clear_Channel_active_flag (ch); } return 0; } /** \fn int32_t GPDMA_ChannelEnable (uint8_t ch) \brief Enable GPDMA channel \param[in] ch Channel number (0..7) \returns - \b 0: function succeeded - \b -1: function failed */ int32_t GPDMA_ChannelEnable (uint8_t ch) { // Check if channel is valid if (ch >= GPDMA_NUMBER_OF_CHANNELS) return -1; // Set Channel active flag if (Set_Channel_active_flag (ch) == -1) return -1; GPDMA_CHANNEL(ch)->CONFIG |= GPDMA_CH_CONFIG_E; return 0; } /** \fn int32_t GPDMA_ChannelDisable (uint8_t ch) \brief Disable GPDMA channel \param[in] ch Channel number (0..7) \returns - \b 0: function succeeded - \b -1: function failed */ int32_t GPDMA_ChannelDisable (uint8_t ch) { // Check if channel is valid if (ch >= GPDMA_NUMBER_OF_CHANNELS) return -1; // Clear Channel active flag Clear_Channel_active_flag (ch); GPDMA_CHANNEL(ch)->CONFIG &= ~GPDMA_CH_CONFIG_E; return 0; } /** \fn uint32_t GPDMA_ChannelGetStatus (uint8_t ch) \brief Check if GPDMA channel is enabled or disabled \param[in] ch Channel number (0..7) \returns Channel status - \b 1: channel enabled - \b 0: channel disabled */ uint32_t GPDMA_ChannelGetStatus (uint8_t ch) { // Check if channel is valid if (ch >= GPDMA_NUMBER_OF_CHANNELS) return 0; if (Channel_active & (1 << ch)) return 1; else return 0; } /** \fn void DMA_IRQHandler (void) \brief DMA interrupt handler */ void DMA_IRQHandler (void) { uint32_t ch, event; for (ch = 0; ch < GPDMA_NUMBER_OF_CHANNELS; ch++) { if (LPC_GPDMA->INTSTAT & (1 << ch)) { event = 0; // Terminal count request interrupt if (LPC_GPDMA->INTTCSTAT & (1 << ch)) { event |= GPDMA_EVENT_TERMINAL_COUNT_REQUEST; LPC_GPDMA->INTTCCLEAR = (1 << ch); } // DMA error interrupt if (LPC_GPDMA->INTERRSTAT & (1 << ch)) { event |= GPDMA_EVENT_ERROR; LPC_GPDMA->INTERRCLR = (1 << ch); } // Clear Channel active flag Clear_Channel_active_flag (ch); // Signal Event if (GPDMA_cb_event[ch]) GPDMA_cb_event[ch](event); } } }
{ "pile_set_name": "Github" }
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: nginx replicas: 4 # Update the replicas from 2 to 4 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80
{ "pile_set_name": "Github" }
.class Landroid/support/v4/net/ConnectivityManagerCompat$GingerbreadConnectivityManagerCompatImpl; .super Ljava/lang/Object; # interfaces .implements Landroid/support/v4/net/ConnectivityManagerCompat$ConnectivityManagerCompatImpl; # direct methods .method constructor <init>()V .locals 0 invoke-direct {p0}, Ljava/lang/Object;-><init>()V return-void .end method # virtual methods .method public isActiveNetworkMetered(Landroid/net/ConnectivityManager;)Z .locals 1 invoke-static {p1}, Landroid/support/v4/net/ConnectivityManagerCompatGingerbread;->isActiveNetworkMetered(Landroid/net/ConnectivityManager;)Z move-result v0 return v0 .end method
{ "pile_set_name": "Github" }
using AElf.Standards.ACS1; using AElf.Standards.ACS3; using AElf.Contracts.MultiToken; using AElf.Sdk.CSharp; using AElf.Types; using Google.Protobuf.WellKnownTypes; namespace AElf.Contracts.Configuration { public partial class ConfigurationContract { #region Views public override MethodFees GetMethodFee(StringValue input) { return State.TransactionFees[input.Value]; } public override AuthorityInfo GetMethodFeeController(Empty input) { RequiredMethodFeeControllerSet(); return State.MethodFeeController.Value; } #endregion public override Empty SetMethodFee(MethodFees input) { foreach (var methodFee in input.Fees) { AssertValidToken(methodFee.Symbol, methodFee.BasicFee); } RequiredMethodFeeControllerSet(); Assert(Context.Sender == State.MethodFeeController.Value.OwnerAddress, "Unauthorized to set method fee."); State.TransactionFees[input.MethodName] = input; return new Empty(); } public override Empty ChangeMethodFeeController(AuthorityInfo input) { RequiredMethodFeeControllerSet(); AssertSenderAddressWith(State.MethodFeeController.Value.OwnerAddress); var organizationExist = CheckOrganizationExist(input); Assert(organizationExist, "Invalid authority input."); State.MethodFeeController.Value = input; return new Empty(); } #region private methods private void RequiredMethodFeeControllerSet() { if (State.MethodFeeController.Value != null) return; if (State.ParliamentContract.Value == null) { State.ParliamentContract.Value = Context.GetContractAddressByName(SmartContractConstants.ParliamentContractSystemName); } var defaultAuthority = new AuthorityInfo { OwnerAddress = State.ParliamentContract.GetDefaultOrganizationAddress.Call(new Empty()), ContractAddress = State.ParliamentContract.Value }; State.MethodFeeController.Value = defaultAuthority; } private void AssertSenderAddressWith(Address address) { Assert(Context.Sender == address, "Unauthorized behavior."); } private bool CheckOrganizationExist(AuthorityInfo authorityInfo) { return Context.Call<BoolValue>(authorityInfo.ContractAddress, nameof(AuthorizationContractContainer.AuthorizationContractReferenceState.ValidateOrganizationExist), authorityInfo.OwnerAddress).Value; } private void AssertValidToken(string symbol, long amount) { Assert(amount >= 0, "Invalid amount."); if (State.TokenContract.Value == null) { State.TokenContract.Value = Context.GetContractAddressByName(SmartContractConstants.TokenContractSystemName); } var tokenInfoInput = new GetTokenInfoInput {Symbol = symbol}; var tokenInfo = State.TokenContract.GetTokenInfo.Call(tokenInfoInput); Assert(tokenInfo != null && !string.IsNullOrEmpty(tokenInfo.Symbol), $"Token is not found. {symbol}"); } #endregion } }
{ "pile_set_name": "Github" }
Templates ------------
{ "pile_set_name": "Github" }
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> </resources>
{ "pile_set_name": "Github" }
# # SConscript build file for an stm32plus example. Called automatically by the SConstruct # in the parent directory # import os # import everything exported in SConstruct Import('*') # get a copy of the environment env=env.Clone() # verify that this example is compatible with the selected MCU sconscriptFile=(lambda x:x).func_code.co_filename sconscriptDir=os.path.dirname(sconscriptFile) compatFile=os.path.join(sconscriptDir,"compat.txt"); supported=True if os.path.exists(compatFile): supported=False for line in open(compatFile,"r"): line=line.rstrip() if not line.startswith("#") and line==mcu: supported=True break if supported: # get all the sources matches=[] matches.append(Glob("*.cpp")) matches.append(Glob("*.c")) matches.append(Glob("*.asm")) matches.append("system/LibraryHacks.cpp") # handle MCU differences if mcu.startswith("f4"): matches.append("system/f407_168_8/Startup.asm") matches.append("system/f407_168_8/System.c") linkerscript="examples/"+example+"/system/f407_168_8/Linker.ld" elif mcu=="f1hd": matches.append("system/f1hd_72_8/Startup.asm") matches.append("system/f1hd_72_8/System.c") linkerscript="examples/"+example+"/system/f1hd_72_8/Linker.ld" elif mcu=="f1cle": matches.append("system/f107_72_8/Startup.asm") matches.append("system/f107_72_8/System.c") linkerscript="examples/"+example+"/system/f107_72_8/Linker.ld" elif mcu=="f1md": matches.append("system/f1md/Startup.asm") matches.append("system/f1md/System.c") linkerscript="examples/"+example+"/system/f1md/Linker.ld" elif mcu=="f1mdvl": matches.append("system/f1mdvl_24_8/Startup.asm") matches.append("system/f1mdvl_24_8/System.c") linkerscript="examples/"+example+"/system/f1mdvl_24_8/Linker.ld" elif mcu=="f042": matches.append("system/f042_48_8/Startup.asm") matches.append("system/f042_48_8/System.c") linkerscript="examples/"+example+"/system/f042_48_8/Linker.ld" elif mcu=="f051": matches.append("system/f051_48_8/Startup.asm") matches.append("system/f051_48_8/System.c") linkerscript="examples/"+example+"/system/f051_48_8/Linker.ld" elif mcu=="f030": matches.append("system/f030_48_8/Startup.asm") matches.append("system/f030_48_8/System.c") linkerscript="examples/"+example+"/system/f030_48_8/Linker.ld" buildoutdir="examples/"+example+"/build/"+systemprefix # set the additional linker flags env.Append(LINKFLAGS=["-T"+linkerscript,"-Wl,-wrap,__aeabi_unwind_cpp_pr0","-Wl,-wrap,__aeabi_unwind_cpp_pr1","-Wl,-wrap,__aeabi_unwind_cpp_pr2","-Wl,-wrap,atexit"]) # additional include directory for the graphics env.Append(ASFLAGS="-Iexamples/"+example) # unique additions for this example env.Append(CPPPATH="#examples/"+example) # trigger a build with the correct library name elf=env.Program(example+".elf",matches) hex=env.Command(example+".hex",elf,"arm-none-eabi-objcopy -O ihex "+buildoutdir+"/"+example+".elf "+buildoutdir+"/"+example+".hex") bin=env.Command(example+".bin",elf,"arm-none-eabi-objcopy -O binary "+buildoutdir+"/"+example+".elf "+buildoutdir+"/"+example+".bin") lst=env.Command(example+".lst",elf,"arm-none-eabi-objdump -h -S "+buildoutdir+"/"+example+".elf > "+buildoutdir+"/"+example+".lst") size=env.Command(example+".size",elf,"arm-none-eabi-size --format=berkeley "+buildoutdir+"/"+example+".elf | tee "+buildoutdir+"/"+example+".size") # install the library if the user gave the install option EXAMPLEINSTALLDIR=INSTALLDIR+"/examples/"+example+"/"+systemprefix env.Alias("install",env.Install(EXAMPLEINSTALLDIR,[elf,hex,bin,lst,size]))
{ "pile_set_name": "Github" }
/* crypto/cast/cast_s.h */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * 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 ([email protected]). * * 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 ([email protected])" * 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 ([email protected])" * * 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.] */ OPENSSL_GLOBAL const CAST_LONG CAST_S_table0[256]={ 0x30fb40d4,0x9fa0ff0b,0x6beccd2f,0x3f258c7a, 0x1e213f2f,0x9c004dd3,0x6003e540,0xcf9fc949, 0xbfd4af27,0x88bbbdb5,0xe2034090,0x98d09675, 0x6e63a0e0,0x15c361d2,0xc2e7661d,0x22d4ff8e, 0x28683b6f,0xc07fd059,0xff2379c8,0x775f50e2, 0x43c340d3,0xdf2f8656,0x887ca41a,0xa2d2bd2d, 0xa1c9e0d6,0x346c4819,0x61b76d87,0x22540f2f, 0x2abe32e1,0xaa54166b,0x22568e3a,0xa2d341d0, 0x66db40c8,0xa784392f,0x004dff2f,0x2db9d2de, 0x97943fac,0x4a97c1d8,0x527644b7,0xb5f437a7, 0xb82cbaef,0xd751d159,0x6ff7f0ed,0x5a097a1f, 0x827b68d0,0x90ecf52e,0x22b0c054,0xbc8e5935, 0x4b6d2f7f,0x50bb64a2,0xd2664910,0xbee5812d, 0xb7332290,0xe93b159f,0xb48ee411,0x4bff345d, 0xfd45c240,0xad31973f,0xc4f6d02e,0x55fc8165, 0xd5b1caad,0xa1ac2dae,0xa2d4b76d,0xc19b0c50, 0x882240f2,0x0c6e4f38,0xa4e4bfd7,0x4f5ba272, 0x564c1d2f,0xc59c5319,0xb949e354,0xb04669fe, 0xb1b6ab8a,0xc71358dd,0x6385c545,0x110f935d, 0x57538ad5,0x6a390493,0xe63d37e0,0x2a54f6b3, 0x3a787d5f,0x6276a0b5,0x19a6fcdf,0x7a42206a, 0x29f9d4d5,0xf61b1891,0xbb72275e,0xaa508167, 0x38901091,0xc6b505eb,0x84c7cb8c,0x2ad75a0f, 0x874a1427,0xa2d1936b,0x2ad286af,0xaa56d291, 0xd7894360,0x425c750d,0x93b39e26,0x187184c9, 0x6c00b32d,0x73e2bb14,0xa0bebc3c,0x54623779, 0x64459eab,0x3f328b82,0x7718cf82,0x59a2cea6, 0x04ee002e,0x89fe78e6,0x3fab0950,0x325ff6c2, 0x81383f05,0x6963c5c8,0x76cb5ad6,0xd49974c9, 0xca180dcf,0x380782d5,0xc7fa5cf6,0x8ac31511, 0x35e79e13,0x47da91d0,0xf40f9086,0xa7e2419e, 0x31366241,0x051ef495,0xaa573b04,0x4a805d8d, 0x548300d0,0x00322a3c,0xbf64cddf,0xba57a68e, 0x75c6372b,0x50afd341,0xa7c13275,0x915a0bf5, 0x6b54bfab,0x2b0b1426,0xab4cc9d7,0x449ccd82, 0xf7fbf265,0xab85c5f3,0x1b55db94,0xaad4e324, 0xcfa4bd3f,0x2deaa3e2,0x9e204d02,0xc8bd25ac, 0xeadf55b3,0xd5bd9e98,0xe31231b2,0x2ad5ad6c, 0x954329de,0xadbe4528,0xd8710f69,0xaa51c90f, 0xaa786bf6,0x22513f1e,0xaa51a79b,0x2ad344cc, 0x7b5a41f0,0xd37cfbad,0x1b069505,0x41ece491, 0xb4c332e6,0x032268d4,0xc9600acc,0xce387e6d, 0xbf6bb16c,0x6a70fb78,0x0d03d9c9,0xd4df39de, 0xe01063da,0x4736f464,0x5ad328d8,0xb347cc96, 0x75bb0fc3,0x98511bfb,0x4ffbcc35,0xb58bcf6a, 0xe11f0abc,0xbfc5fe4a,0xa70aec10,0xac39570a, 0x3f04442f,0x6188b153,0xe0397a2e,0x5727cb79, 0x9ceb418f,0x1cacd68d,0x2ad37c96,0x0175cb9d, 0xc69dff09,0xc75b65f0,0xd9db40d8,0xec0e7779, 0x4744ead4,0xb11c3274,0xdd24cb9e,0x7e1c54bd, 0xf01144f9,0xd2240eb1,0x9675b3fd,0xa3ac3755, 0xd47c27af,0x51c85f4d,0x56907596,0xa5bb15e6, 0x580304f0,0xca042cf1,0x011a37ea,0x8dbfaadb, 0x35ba3e4a,0x3526ffa0,0xc37b4d09,0xbc306ed9, 0x98a52666,0x5648f725,0xff5e569d,0x0ced63d0, 0x7c63b2cf,0x700b45e1,0xd5ea50f1,0x85a92872, 0xaf1fbda7,0xd4234870,0xa7870bf3,0x2d3b4d79, 0x42e04198,0x0cd0ede7,0x26470db8,0xf881814c, 0x474d6ad7,0x7c0c5e5c,0xd1231959,0x381b7298, 0xf5d2f4db,0xab838653,0x6e2f1e23,0x83719c9e, 0xbd91e046,0x9a56456e,0xdc39200c,0x20c8c571, 0x962bda1c,0xe1e696ff,0xb141ab08,0x7cca89b9, 0x1a69e783,0x02cc4843,0xa2f7c579,0x429ef47d, 0x427b169c,0x5ac9f049,0xdd8f0f00,0x5c8165bf, }; OPENSSL_GLOBAL const CAST_LONG CAST_S_table1[256]={ 0x1f201094,0xef0ba75b,0x69e3cf7e,0x393f4380, 0xfe61cf7a,0xeec5207a,0x55889c94,0x72fc0651, 0xada7ef79,0x4e1d7235,0xd55a63ce,0xde0436ba, 0x99c430ef,0x5f0c0794,0x18dcdb7d,0xa1d6eff3, 0xa0b52f7b,0x59e83605,0xee15b094,0xe9ffd909, 0xdc440086,0xef944459,0xba83ccb3,0xe0c3cdfb, 0xd1da4181,0x3b092ab1,0xf997f1c1,0xa5e6cf7b, 0x01420ddb,0xe4e7ef5b,0x25a1ff41,0xe180f806, 0x1fc41080,0x179bee7a,0xd37ac6a9,0xfe5830a4, 0x98de8b7f,0x77e83f4e,0x79929269,0x24fa9f7b, 0xe113c85b,0xacc40083,0xd7503525,0xf7ea615f, 0x62143154,0x0d554b63,0x5d681121,0xc866c359, 0x3d63cf73,0xcee234c0,0xd4d87e87,0x5c672b21, 0x071f6181,0x39f7627f,0x361e3084,0xe4eb573b, 0x602f64a4,0xd63acd9c,0x1bbc4635,0x9e81032d, 0x2701f50c,0x99847ab4,0xa0e3df79,0xba6cf38c, 0x10843094,0x2537a95e,0xf46f6ffe,0xa1ff3b1f, 0x208cfb6a,0x8f458c74,0xd9e0a227,0x4ec73a34, 0xfc884f69,0x3e4de8df,0xef0e0088,0x3559648d, 0x8a45388c,0x1d804366,0x721d9bfd,0xa58684bb, 0xe8256333,0x844e8212,0x128d8098,0xfed33fb4, 0xce280ae1,0x27e19ba5,0xd5a6c252,0xe49754bd, 0xc5d655dd,0xeb667064,0x77840b4d,0xa1b6a801, 0x84db26a9,0xe0b56714,0x21f043b7,0xe5d05860, 0x54f03084,0x066ff472,0xa31aa153,0xdadc4755, 0xb5625dbf,0x68561be6,0x83ca6b94,0x2d6ed23b, 0xeccf01db,0xa6d3d0ba,0xb6803d5c,0xaf77a709, 0x33b4a34c,0x397bc8d6,0x5ee22b95,0x5f0e5304, 0x81ed6f61,0x20e74364,0xb45e1378,0xde18639b, 0x881ca122,0xb96726d1,0x8049a7e8,0x22b7da7b, 0x5e552d25,0x5272d237,0x79d2951c,0xc60d894c, 0x488cb402,0x1ba4fe5b,0xa4b09f6b,0x1ca815cf, 0xa20c3005,0x8871df63,0xb9de2fcb,0x0cc6c9e9, 0x0beeff53,0xe3214517,0xb4542835,0x9f63293c, 0xee41e729,0x6e1d2d7c,0x50045286,0x1e6685f3, 0xf33401c6,0x30a22c95,0x31a70850,0x60930f13, 0x73f98417,0xa1269859,0xec645c44,0x52c877a9, 0xcdff33a6,0xa02b1741,0x7cbad9a2,0x2180036f, 0x50d99c08,0xcb3f4861,0xc26bd765,0x64a3f6ab, 0x80342676,0x25a75e7b,0xe4e6d1fc,0x20c710e6, 0xcdf0b680,0x17844d3b,0x31eef84d,0x7e0824e4, 0x2ccb49eb,0x846a3bae,0x8ff77888,0xee5d60f6, 0x7af75673,0x2fdd5cdb,0xa11631c1,0x30f66f43, 0xb3faec54,0x157fd7fa,0xef8579cc,0xd152de58, 0xdb2ffd5e,0x8f32ce19,0x306af97a,0x02f03ef8, 0x99319ad5,0xc242fa0f,0xa7e3ebb0,0xc68e4906, 0xb8da230c,0x80823028,0xdcdef3c8,0xd35fb171, 0x088a1bc8,0xbec0c560,0x61a3c9e8,0xbca8f54d, 0xc72feffa,0x22822e99,0x82c570b4,0xd8d94e89, 0x8b1c34bc,0x301e16e6,0x273be979,0xb0ffeaa6, 0x61d9b8c6,0x00b24869,0xb7ffce3f,0x08dc283b, 0x43daf65a,0xf7e19798,0x7619b72f,0x8f1c9ba4, 0xdc8637a0,0x16a7d3b1,0x9fc393b7,0xa7136eeb, 0xc6bcc63e,0x1a513742,0xef6828bc,0x520365d6, 0x2d6a77ab,0x3527ed4b,0x821fd216,0x095c6e2e, 0xdb92f2fb,0x5eea29cb,0x145892f5,0x91584f7f, 0x5483697b,0x2667a8cc,0x85196048,0x8c4bacea, 0x833860d4,0x0d23e0f9,0x6c387e8a,0x0ae6d249, 0xb284600c,0xd835731d,0xdcb1c647,0xac4c56ea, 0x3ebd81b3,0x230eabb0,0x6438bc87,0xf0b5b1fa, 0x8f5ea2b3,0xfc184642,0x0a036b7a,0x4fb089bd, 0x649da589,0xa345415e,0x5c038323,0x3e5d3bb9, 0x43d79572,0x7e6dd07c,0x06dfdf1e,0x6c6cc4ef, 0x7160a539,0x73bfbe70,0x83877605,0x4523ecf1, }; OPENSSL_GLOBAL const CAST_LONG CAST_S_table2[256]={ 0x8defc240,0x25fa5d9f,0xeb903dbf,0xe810c907, 0x47607fff,0x369fe44b,0x8c1fc644,0xaececa90, 0xbeb1f9bf,0xeefbcaea,0xe8cf1950,0x51df07ae, 0x920e8806,0xf0ad0548,0xe13c8d83,0x927010d5, 0x11107d9f,0x07647db9,0xb2e3e4d4,0x3d4f285e, 0xb9afa820,0xfade82e0,0xa067268b,0x8272792e, 0x553fb2c0,0x489ae22b,0xd4ef9794,0x125e3fbc, 0x21fffcee,0x825b1bfd,0x9255c5ed,0x1257a240, 0x4e1a8302,0xbae07fff,0x528246e7,0x8e57140e, 0x3373f7bf,0x8c9f8188,0xa6fc4ee8,0xc982b5a5, 0xa8c01db7,0x579fc264,0x67094f31,0xf2bd3f5f, 0x40fff7c1,0x1fb78dfc,0x8e6bd2c1,0x437be59b, 0x99b03dbf,0xb5dbc64b,0x638dc0e6,0x55819d99, 0xa197c81c,0x4a012d6e,0xc5884a28,0xccc36f71, 0xb843c213,0x6c0743f1,0x8309893c,0x0feddd5f, 0x2f7fe850,0xd7c07f7e,0x02507fbf,0x5afb9a04, 0xa747d2d0,0x1651192e,0xaf70bf3e,0x58c31380, 0x5f98302e,0x727cc3c4,0x0a0fb402,0x0f7fef82, 0x8c96fdad,0x5d2c2aae,0x8ee99a49,0x50da88b8, 0x8427f4a0,0x1eac5790,0x796fb449,0x8252dc15, 0xefbd7d9b,0xa672597d,0xada840d8,0x45f54504, 0xfa5d7403,0xe83ec305,0x4f91751a,0x925669c2, 0x23efe941,0xa903f12e,0x60270df2,0x0276e4b6, 0x94fd6574,0x927985b2,0x8276dbcb,0x02778176, 0xf8af918d,0x4e48f79e,0x8f616ddf,0xe29d840e, 0x842f7d83,0x340ce5c8,0x96bbb682,0x93b4b148, 0xef303cab,0x984faf28,0x779faf9b,0x92dc560d, 0x224d1e20,0x8437aa88,0x7d29dc96,0x2756d3dc, 0x8b907cee,0xb51fd240,0xe7c07ce3,0xe566b4a1, 0xc3e9615e,0x3cf8209d,0x6094d1e3,0xcd9ca341, 0x5c76460e,0x00ea983b,0xd4d67881,0xfd47572c, 0xf76cedd9,0xbda8229c,0x127dadaa,0x438a074e, 0x1f97c090,0x081bdb8a,0x93a07ebe,0xb938ca15, 0x97b03cff,0x3dc2c0f8,0x8d1ab2ec,0x64380e51, 0x68cc7bfb,0xd90f2788,0x12490181,0x5de5ffd4, 0xdd7ef86a,0x76a2e214,0xb9a40368,0x925d958f, 0x4b39fffa,0xba39aee9,0xa4ffd30b,0xfaf7933b, 0x6d498623,0x193cbcfa,0x27627545,0x825cf47a, 0x61bd8ba0,0xd11e42d1,0xcead04f4,0x127ea392, 0x10428db7,0x8272a972,0x9270c4a8,0x127de50b, 0x285ba1c8,0x3c62f44f,0x35c0eaa5,0xe805d231, 0x428929fb,0xb4fcdf82,0x4fb66a53,0x0e7dc15b, 0x1f081fab,0x108618ae,0xfcfd086d,0xf9ff2889, 0x694bcc11,0x236a5cae,0x12deca4d,0x2c3f8cc5, 0xd2d02dfe,0xf8ef5896,0xe4cf52da,0x95155b67, 0x494a488c,0xb9b6a80c,0x5c8f82bc,0x89d36b45, 0x3a609437,0xec00c9a9,0x44715253,0x0a874b49, 0xd773bc40,0x7c34671c,0x02717ef6,0x4feb5536, 0xa2d02fff,0xd2bf60c4,0xd43f03c0,0x50b4ef6d, 0x07478cd1,0x006e1888,0xa2e53f55,0xb9e6d4bc, 0xa2048016,0x97573833,0xd7207d67,0xde0f8f3d, 0x72f87b33,0xabcc4f33,0x7688c55d,0x7b00a6b0, 0x947b0001,0x570075d2,0xf9bb88f8,0x8942019e, 0x4264a5ff,0x856302e0,0x72dbd92b,0xee971b69, 0x6ea22fde,0x5f08ae2b,0xaf7a616d,0xe5c98767, 0xcf1febd2,0x61efc8c2,0xf1ac2571,0xcc8239c2, 0x67214cb8,0xb1e583d1,0xb7dc3e62,0x7f10bdce, 0xf90a5c38,0x0ff0443d,0x606e6dc6,0x60543a49, 0x5727c148,0x2be98a1d,0x8ab41738,0x20e1be24, 0xaf96da0f,0x68458425,0x99833be5,0x600d457d, 0x282f9350,0x8334b362,0xd91d1120,0x2b6d8da0, 0x642b1e31,0x9c305a00,0x52bce688,0x1b03588a, 0xf7baefd5,0x4142ed9c,0xa4315c11,0x83323ec5, 0xdfef4636,0xa133c501,0xe9d3531c,0xee353783, }; OPENSSL_GLOBAL const CAST_LONG CAST_S_table3[256]={ 0x9db30420,0x1fb6e9de,0xa7be7bef,0xd273a298, 0x4a4f7bdb,0x64ad8c57,0x85510443,0xfa020ed1, 0x7e287aff,0xe60fb663,0x095f35a1,0x79ebf120, 0xfd059d43,0x6497b7b1,0xf3641f63,0x241e4adf, 0x28147f5f,0x4fa2b8cd,0xc9430040,0x0cc32220, 0xfdd30b30,0xc0a5374f,0x1d2d00d9,0x24147b15, 0xee4d111a,0x0fca5167,0x71ff904c,0x2d195ffe, 0x1a05645f,0x0c13fefe,0x081b08ca,0x05170121, 0x80530100,0xe83e5efe,0xac9af4f8,0x7fe72701, 0xd2b8ee5f,0x06df4261,0xbb9e9b8a,0x7293ea25, 0xce84ffdf,0xf5718801,0x3dd64b04,0xa26f263b, 0x7ed48400,0x547eebe6,0x446d4ca0,0x6cf3d6f5, 0x2649abdf,0xaea0c7f5,0x36338cc1,0x503f7e93, 0xd3772061,0x11b638e1,0x72500e03,0xf80eb2bb, 0xabe0502e,0xec8d77de,0x57971e81,0xe14f6746, 0xc9335400,0x6920318f,0x081dbb99,0xffc304a5, 0x4d351805,0x7f3d5ce3,0xa6c866c6,0x5d5bcca9, 0xdaec6fea,0x9f926f91,0x9f46222f,0x3991467d, 0xa5bf6d8e,0x1143c44f,0x43958302,0xd0214eeb, 0x022083b8,0x3fb6180c,0x18f8931e,0x281658e6, 0x26486e3e,0x8bd78a70,0x7477e4c1,0xb506e07c, 0xf32d0a25,0x79098b02,0xe4eabb81,0x28123b23, 0x69dead38,0x1574ca16,0xdf871b62,0x211c40b7, 0xa51a9ef9,0x0014377b,0x041e8ac8,0x09114003, 0xbd59e4d2,0xe3d156d5,0x4fe876d5,0x2f91a340, 0x557be8de,0x00eae4a7,0x0ce5c2ec,0x4db4bba6, 0xe756bdff,0xdd3369ac,0xec17b035,0x06572327, 0x99afc8b0,0x56c8c391,0x6b65811c,0x5e146119, 0x6e85cb75,0xbe07c002,0xc2325577,0x893ff4ec, 0x5bbfc92d,0xd0ec3b25,0xb7801ab7,0x8d6d3b24, 0x20c763ef,0xc366a5fc,0x9c382880,0x0ace3205, 0xaac9548a,0xeca1d7c7,0x041afa32,0x1d16625a, 0x6701902c,0x9b757a54,0x31d477f7,0x9126b031, 0x36cc6fdb,0xc70b8b46,0xd9e66a48,0x56e55a79, 0x026a4ceb,0x52437eff,0x2f8f76b4,0x0df980a5, 0x8674cde3,0xedda04eb,0x17a9be04,0x2c18f4df, 0xb7747f9d,0xab2af7b4,0xefc34d20,0x2e096b7c, 0x1741a254,0xe5b6a035,0x213d42f6,0x2c1c7c26, 0x61c2f50f,0x6552daf9,0xd2c231f8,0x25130f69, 0xd8167fa2,0x0418f2c8,0x001a96a6,0x0d1526ab, 0x63315c21,0x5e0a72ec,0x49bafefd,0x187908d9, 0x8d0dbd86,0x311170a7,0x3e9b640c,0xcc3e10d7, 0xd5cad3b6,0x0caec388,0xf73001e1,0x6c728aff, 0x71eae2a1,0x1f9af36e,0xcfcbd12f,0xc1de8417, 0xac07be6b,0xcb44a1d8,0x8b9b0f56,0x013988c3, 0xb1c52fca,0xb4be31cd,0xd8782806,0x12a3a4e2, 0x6f7de532,0x58fd7eb6,0xd01ee900,0x24adffc2, 0xf4990fc5,0x9711aac5,0x001d7b95,0x82e5e7d2, 0x109873f6,0x00613096,0xc32d9521,0xada121ff, 0x29908415,0x7fbb977f,0xaf9eb3db,0x29c9ed2a, 0x5ce2a465,0xa730f32c,0xd0aa3fe8,0x8a5cc091, 0xd49e2ce7,0x0ce454a9,0xd60acd86,0x015f1919, 0x77079103,0xdea03af6,0x78a8565e,0xdee356df, 0x21f05cbe,0x8b75e387,0xb3c50651,0xb8a5c3ef, 0xd8eeb6d2,0xe523be77,0xc2154529,0x2f69efdf, 0xafe67afb,0xf470c4b2,0xf3e0eb5b,0xd6cc9876, 0x39e4460c,0x1fda8538,0x1987832f,0xca007367, 0xa99144f8,0x296b299e,0x492fc295,0x9266beab, 0xb5676e69,0x9bd3ddda,0xdf7e052f,0xdb25701c, 0x1b5e51ee,0xf65324e6,0x6afce36c,0x0316cc04, 0x8644213e,0xb7dc59d0,0x7965291f,0xccd6fd43, 0x41823979,0x932bcdf6,0xb657c34d,0x4edfd282, 0x7ae5290c,0x3cb9536b,0x851e20fe,0x9833557e, 0x13ecf0b0,0xd3ffb372,0x3f85c5c1,0x0aef7ed2, }; OPENSSL_GLOBAL const CAST_LONG CAST_S_table4[256]={ 0x7ec90c04,0x2c6e74b9,0x9b0e66df,0xa6337911, 0xb86a7fff,0x1dd358f5,0x44dd9d44,0x1731167f, 0x08fbf1fa,0xe7f511cc,0xd2051b00,0x735aba00, 0x2ab722d8,0x386381cb,0xacf6243a,0x69befd7a, 0xe6a2e77f,0xf0c720cd,0xc4494816,0xccf5c180, 0x38851640,0x15b0a848,0xe68b18cb,0x4caadeff, 0x5f480a01,0x0412b2aa,0x259814fc,0x41d0efe2, 0x4e40b48d,0x248eb6fb,0x8dba1cfe,0x41a99b02, 0x1a550a04,0xba8f65cb,0x7251f4e7,0x95a51725, 0xc106ecd7,0x97a5980a,0xc539b9aa,0x4d79fe6a, 0xf2f3f763,0x68af8040,0xed0c9e56,0x11b4958b, 0xe1eb5a88,0x8709e6b0,0xd7e07156,0x4e29fea7, 0x6366e52d,0x02d1c000,0xc4ac8e05,0x9377f571, 0x0c05372a,0x578535f2,0x2261be02,0xd642a0c9, 0xdf13a280,0x74b55bd2,0x682199c0,0xd421e5ec, 0x53fb3ce8,0xc8adedb3,0x28a87fc9,0x3d959981, 0x5c1ff900,0xfe38d399,0x0c4eff0b,0x062407ea, 0xaa2f4fb1,0x4fb96976,0x90c79505,0xb0a8a774, 0xef55a1ff,0xe59ca2c2,0xa6b62d27,0xe66a4263, 0xdf65001f,0x0ec50966,0xdfdd55bc,0x29de0655, 0x911e739a,0x17af8975,0x32c7911c,0x89f89468, 0x0d01e980,0x524755f4,0x03b63cc9,0x0cc844b2, 0xbcf3f0aa,0x87ac36e9,0xe53a7426,0x01b3d82b, 0x1a9e7449,0x64ee2d7e,0xcddbb1da,0x01c94910, 0xb868bf80,0x0d26f3fd,0x9342ede7,0x04a5c284, 0x636737b6,0x50f5b616,0xf24766e3,0x8eca36c1, 0x136e05db,0xfef18391,0xfb887a37,0xd6e7f7d4, 0xc7fb7dc9,0x3063fcdf,0xb6f589de,0xec2941da, 0x26e46695,0xb7566419,0xf654efc5,0xd08d58b7, 0x48925401,0xc1bacb7f,0xe5ff550f,0xb6083049, 0x5bb5d0e8,0x87d72e5a,0xab6a6ee1,0x223a66ce, 0xc62bf3cd,0x9e0885f9,0x68cb3e47,0x086c010f, 0xa21de820,0xd18b69de,0xf3f65777,0xfa02c3f6, 0x407edac3,0xcbb3d550,0x1793084d,0xb0d70eba, 0x0ab378d5,0xd951fb0c,0xded7da56,0x4124bbe4, 0x94ca0b56,0x0f5755d1,0xe0e1e56e,0x6184b5be, 0x580a249f,0x94f74bc0,0xe327888e,0x9f7b5561, 0xc3dc0280,0x05687715,0x646c6bd7,0x44904db3, 0x66b4f0a3,0xc0f1648a,0x697ed5af,0x49e92ff6, 0x309e374f,0x2cb6356a,0x85808573,0x4991f840, 0x76f0ae02,0x083be84d,0x28421c9a,0x44489406, 0x736e4cb8,0xc1092910,0x8bc95fc6,0x7d869cf4, 0x134f616f,0x2e77118d,0xb31b2be1,0xaa90b472, 0x3ca5d717,0x7d161bba,0x9cad9010,0xaf462ba2, 0x9fe459d2,0x45d34559,0xd9f2da13,0xdbc65487, 0xf3e4f94e,0x176d486f,0x097c13ea,0x631da5c7, 0x445f7382,0x175683f4,0xcdc66a97,0x70be0288, 0xb3cdcf72,0x6e5dd2f3,0x20936079,0x459b80a5, 0xbe60e2db,0xa9c23101,0xeba5315c,0x224e42f2, 0x1c5c1572,0xf6721b2c,0x1ad2fff3,0x8c25404e, 0x324ed72f,0x4067b7fd,0x0523138e,0x5ca3bc78, 0xdc0fd66e,0x75922283,0x784d6b17,0x58ebb16e, 0x44094f85,0x3f481d87,0xfcfeae7b,0x77b5ff76, 0x8c2302bf,0xaaf47556,0x5f46b02a,0x2b092801, 0x3d38f5f7,0x0ca81f36,0x52af4a8a,0x66d5e7c0, 0xdf3b0874,0x95055110,0x1b5ad7a8,0xf61ed5ad, 0x6cf6e479,0x20758184,0xd0cefa65,0x88f7be58, 0x4a046826,0x0ff6f8f3,0xa09c7f70,0x5346aba0, 0x5ce96c28,0xe176eda3,0x6bac307f,0x376829d2, 0x85360fa9,0x17e3fe2a,0x24b79767,0xf5a96b20, 0xd6cd2595,0x68ff1ebf,0x7555442c,0xf19f06be, 0xf9e0659a,0xeeb9491d,0x34010718,0xbb30cab8, 0xe822fe15,0x88570983,0x750e6249,0xda627e55, 0x5e76ffa8,0xb1534546,0x6d47de08,0xefe9e7d4, }; OPENSSL_GLOBAL const CAST_LONG CAST_S_table5[256]={ 0xf6fa8f9d,0x2cac6ce1,0x4ca34867,0xe2337f7c, 0x95db08e7,0x016843b4,0xeced5cbc,0x325553ac, 0xbf9f0960,0xdfa1e2ed,0x83f0579d,0x63ed86b9, 0x1ab6a6b8,0xde5ebe39,0xf38ff732,0x8989b138, 0x33f14961,0xc01937bd,0xf506c6da,0xe4625e7e, 0xa308ea99,0x4e23e33c,0x79cbd7cc,0x48a14367, 0xa3149619,0xfec94bd5,0xa114174a,0xeaa01866, 0xa084db2d,0x09a8486f,0xa888614a,0x2900af98, 0x01665991,0xe1992863,0xc8f30c60,0x2e78ef3c, 0xd0d51932,0xcf0fec14,0xf7ca07d2,0xd0a82072, 0xfd41197e,0x9305a6b0,0xe86be3da,0x74bed3cd, 0x372da53c,0x4c7f4448,0xdab5d440,0x6dba0ec3, 0x083919a7,0x9fbaeed9,0x49dbcfb0,0x4e670c53, 0x5c3d9c01,0x64bdb941,0x2c0e636a,0xba7dd9cd, 0xea6f7388,0xe70bc762,0x35f29adb,0x5c4cdd8d, 0xf0d48d8c,0xb88153e2,0x08a19866,0x1ae2eac8, 0x284caf89,0xaa928223,0x9334be53,0x3b3a21bf, 0x16434be3,0x9aea3906,0xefe8c36e,0xf890cdd9, 0x80226dae,0xc340a4a3,0xdf7e9c09,0xa694a807, 0x5b7c5ecc,0x221db3a6,0x9a69a02f,0x68818a54, 0xceb2296f,0x53c0843a,0xfe893655,0x25bfe68a, 0xb4628abc,0xcf222ebf,0x25ac6f48,0xa9a99387, 0x53bddb65,0xe76ffbe7,0xe967fd78,0x0ba93563, 0x8e342bc1,0xe8a11be9,0x4980740d,0xc8087dfc, 0x8de4bf99,0xa11101a0,0x7fd37975,0xda5a26c0, 0xe81f994f,0x9528cd89,0xfd339fed,0xb87834bf, 0x5f04456d,0x22258698,0xc9c4c83b,0x2dc156be, 0x4f628daa,0x57f55ec5,0xe2220abe,0xd2916ebf, 0x4ec75b95,0x24f2c3c0,0x42d15d99,0xcd0d7fa0, 0x7b6e27ff,0xa8dc8af0,0x7345c106,0xf41e232f, 0x35162386,0xe6ea8926,0x3333b094,0x157ec6f2, 0x372b74af,0x692573e4,0xe9a9d848,0xf3160289, 0x3a62ef1d,0xa787e238,0xf3a5f676,0x74364853, 0x20951063,0x4576698d,0xb6fad407,0x592af950, 0x36f73523,0x4cfb6e87,0x7da4cec0,0x6c152daa, 0xcb0396a8,0xc50dfe5d,0xfcd707ab,0x0921c42f, 0x89dff0bb,0x5fe2be78,0x448f4f33,0x754613c9, 0x2b05d08d,0x48b9d585,0xdc049441,0xc8098f9b, 0x7dede786,0xc39a3373,0x42410005,0x6a091751, 0x0ef3c8a6,0x890072d6,0x28207682,0xa9a9f7be, 0xbf32679d,0xd45b5b75,0xb353fd00,0xcbb0e358, 0x830f220a,0x1f8fb214,0xd372cf08,0xcc3c4a13, 0x8cf63166,0x061c87be,0x88c98f88,0x6062e397, 0x47cf8e7a,0xb6c85283,0x3cc2acfb,0x3fc06976, 0x4e8f0252,0x64d8314d,0xda3870e3,0x1e665459, 0xc10908f0,0x513021a5,0x6c5b68b7,0x822f8aa0, 0x3007cd3e,0x74719eef,0xdc872681,0x073340d4, 0x7e432fd9,0x0c5ec241,0x8809286c,0xf592d891, 0x08a930f6,0x957ef305,0xb7fbffbd,0xc266e96f, 0x6fe4ac98,0xb173ecc0,0xbc60b42a,0x953498da, 0xfba1ae12,0x2d4bd736,0x0f25faab,0xa4f3fceb, 0xe2969123,0x257f0c3d,0x9348af49,0x361400bc, 0xe8816f4a,0x3814f200,0xa3f94043,0x9c7a54c2, 0xbc704f57,0xda41e7f9,0xc25ad33a,0x54f4a084, 0xb17f5505,0x59357cbe,0xedbd15c8,0x7f97c5ab, 0xba5ac7b5,0xb6f6deaf,0x3a479c3a,0x5302da25, 0x653d7e6a,0x54268d49,0x51a477ea,0x5017d55b, 0xd7d25d88,0x44136c76,0x0404a8c8,0xb8e5a121, 0xb81a928a,0x60ed5869,0x97c55b96,0xeaec991b, 0x29935913,0x01fdb7f1,0x088e8dfa,0x9ab6f6f5, 0x3b4cbf9f,0x4a5de3ab,0xe6051d35,0xa0e1d855, 0xd36b4cf1,0xf544edeb,0xb0e93524,0xbebb8fbd, 0xa2d762cf,0x49c92f54,0x38b5f331,0x7128a454, 0x48392905,0xa65b1db8,0x851c97bd,0xd675cf2f, }; OPENSSL_GLOBAL const CAST_LONG CAST_S_table6[256]={ 0x85e04019,0x332bf567,0x662dbfff,0xcfc65693, 0x2a8d7f6f,0xab9bc912,0xde6008a1,0x2028da1f, 0x0227bce7,0x4d642916,0x18fac300,0x50f18b82, 0x2cb2cb11,0xb232e75c,0x4b3695f2,0xb28707de, 0xa05fbcf6,0xcd4181e9,0xe150210c,0xe24ef1bd, 0xb168c381,0xfde4e789,0x5c79b0d8,0x1e8bfd43, 0x4d495001,0x38be4341,0x913cee1d,0x92a79c3f, 0x089766be,0xbaeeadf4,0x1286becf,0xb6eacb19, 0x2660c200,0x7565bde4,0x64241f7a,0x8248dca9, 0xc3b3ad66,0x28136086,0x0bd8dfa8,0x356d1cf2, 0x107789be,0xb3b2e9ce,0x0502aa8f,0x0bc0351e, 0x166bf52a,0xeb12ff82,0xe3486911,0xd34d7516, 0x4e7b3aff,0x5f43671b,0x9cf6e037,0x4981ac83, 0x334266ce,0x8c9341b7,0xd0d854c0,0xcb3a6c88, 0x47bc2829,0x4725ba37,0xa66ad22b,0x7ad61f1e, 0x0c5cbafa,0x4437f107,0xb6e79962,0x42d2d816, 0x0a961288,0xe1a5c06e,0x13749e67,0x72fc081a, 0xb1d139f7,0xf9583745,0xcf19df58,0xbec3f756, 0xc06eba30,0x07211b24,0x45c28829,0xc95e317f, 0xbc8ec511,0x38bc46e9,0xc6e6fa14,0xbae8584a, 0xad4ebc46,0x468f508b,0x7829435f,0xf124183b, 0x821dba9f,0xaff60ff4,0xea2c4e6d,0x16e39264, 0x92544a8b,0x009b4fc3,0xaba68ced,0x9ac96f78, 0x06a5b79a,0xb2856e6e,0x1aec3ca9,0xbe838688, 0x0e0804e9,0x55f1be56,0xe7e5363b,0xb3a1f25d, 0xf7debb85,0x61fe033c,0x16746233,0x3c034c28, 0xda6d0c74,0x79aac56c,0x3ce4e1ad,0x51f0c802, 0x98f8f35a,0x1626a49f,0xeed82b29,0x1d382fe3, 0x0c4fb99a,0xbb325778,0x3ec6d97b,0x6e77a6a9, 0xcb658b5c,0xd45230c7,0x2bd1408b,0x60c03eb7, 0xb9068d78,0xa33754f4,0xf430c87d,0xc8a71302, 0xb96d8c32,0xebd4e7be,0xbe8b9d2d,0x7979fb06, 0xe7225308,0x8b75cf77,0x11ef8da4,0xe083c858, 0x8d6b786f,0x5a6317a6,0xfa5cf7a0,0x5dda0033, 0xf28ebfb0,0xf5b9c310,0xa0eac280,0x08b9767a, 0xa3d9d2b0,0x79d34217,0x021a718d,0x9ac6336a, 0x2711fd60,0x438050e3,0x069908a8,0x3d7fedc4, 0x826d2bef,0x4eeb8476,0x488dcf25,0x36c9d566, 0x28e74e41,0xc2610aca,0x3d49a9cf,0xbae3b9df, 0xb65f8de6,0x92aeaf64,0x3ac7d5e6,0x9ea80509, 0xf22b017d,0xa4173f70,0xdd1e16c3,0x15e0d7f9, 0x50b1b887,0x2b9f4fd5,0x625aba82,0x6a017962, 0x2ec01b9c,0x15488aa9,0xd716e740,0x40055a2c, 0x93d29a22,0xe32dbf9a,0x058745b9,0x3453dc1e, 0xd699296e,0x496cff6f,0x1c9f4986,0xdfe2ed07, 0xb87242d1,0x19de7eae,0x053e561a,0x15ad6f8c, 0x66626c1c,0x7154c24c,0xea082b2a,0x93eb2939, 0x17dcb0f0,0x58d4f2ae,0x9ea294fb,0x52cf564c, 0x9883fe66,0x2ec40581,0x763953c3,0x01d6692e, 0xd3a0c108,0xa1e7160e,0xe4f2dfa6,0x693ed285, 0x74904698,0x4c2b0edd,0x4f757656,0x5d393378, 0xa132234f,0x3d321c5d,0xc3f5e194,0x4b269301, 0xc79f022f,0x3c997e7e,0x5e4f9504,0x3ffafbbd, 0x76f7ad0e,0x296693f4,0x3d1fce6f,0xc61e45be, 0xd3b5ab34,0xf72bf9b7,0x1b0434c0,0x4e72b567, 0x5592a33d,0xb5229301,0xcfd2a87f,0x60aeb767, 0x1814386b,0x30bcc33d,0x38a0c07d,0xfd1606f2, 0xc363519b,0x589dd390,0x5479f8e6,0x1cb8d647, 0x97fd61a9,0xea7759f4,0x2d57539d,0x569a58cf, 0xe84e63ad,0x462e1b78,0x6580f87e,0xf3817914, 0x91da55f4,0x40a230f3,0xd1988f35,0xb6e318d2, 0x3ffa50bc,0x3d40f021,0xc3c0bdae,0x4958c24c, 0x518f36b2,0x84b1d370,0x0fedce83,0x878ddada, 0xf2a279c7,0x94e01be8,0x90716f4b,0x954b8aa3, }; OPENSSL_GLOBAL const CAST_LONG CAST_S_table7[256]={ 0xe216300d,0xbbddfffc,0xa7ebdabd,0x35648095, 0x7789f8b7,0xe6c1121b,0x0e241600,0x052ce8b5, 0x11a9cfb0,0xe5952f11,0xece7990a,0x9386d174, 0x2a42931c,0x76e38111,0xb12def3a,0x37ddddfc, 0xde9adeb1,0x0a0cc32c,0xbe197029,0x84a00940, 0xbb243a0f,0xb4d137cf,0xb44e79f0,0x049eedfd, 0x0b15a15d,0x480d3168,0x8bbbde5a,0x669ded42, 0xc7ece831,0x3f8f95e7,0x72df191b,0x7580330d, 0x94074251,0x5c7dcdfa,0xabbe6d63,0xaa402164, 0xb301d40a,0x02e7d1ca,0x53571dae,0x7a3182a2, 0x12a8ddec,0xfdaa335d,0x176f43e8,0x71fb46d4, 0x38129022,0xce949ad4,0xb84769ad,0x965bd862, 0x82f3d055,0x66fb9767,0x15b80b4e,0x1d5b47a0, 0x4cfde06f,0xc28ec4b8,0x57e8726e,0x647a78fc, 0x99865d44,0x608bd593,0x6c200e03,0x39dc5ff6, 0x5d0b00a3,0xae63aff2,0x7e8bd632,0x70108c0c, 0xbbd35049,0x2998df04,0x980cf42a,0x9b6df491, 0x9e7edd53,0x06918548,0x58cb7e07,0x3b74ef2e, 0x522fffb1,0xd24708cc,0x1c7e27cd,0xa4eb215b, 0x3cf1d2e2,0x19b47a38,0x424f7618,0x35856039, 0x9d17dee7,0x27eb35e6,0xc9aff67b,0x36baf5b8, 0x09c467cd,0xc18910b1,0xe11dbf7b,0x06cd1af8, 0x7170c608,0x2d5e3354,0xd4de495a,0x64c6d006, 0xbcc0c62c,0x3dd00db3,0x708f8f34,0x77d51b42, 0x264f620f,0x24b8d2bf,0x15c1b79e,0x46a52564, 0xf8d7e54e,0x3e378160,0x7895cda5,0x859c15a5, 0xe6459788,0xc37bc75f,0xdb07ba0c,0x0676a3ab, 0x7f229b1e,0x31842e7b,0x24259fd7,0xf8bef472, 0x835ffcb8,0x6df4c1f2,0x96f5b195,0xfd0af0fc, 0xb0fe134c,0xe2506d3d,0x4f9b12ea,0xf215f225, 0xa223736f,0x9fb4c428,0x25d04979,0x34c713f8, 0xc4618187,0xea7a6e98,0x7cd16efc,0x1436876c, 0xf1544107,0xbedeee14,0x56e9af27,0xa04aa441, 0x3cf7c899,0x92ecbae6,0xdd67016d,0x151682eb, 0xa842eedf,0xfdba60b4,0xf1907b75,0x20e3030f, 0x24d8c29e,0xe139673b,0xefa63fb8,0x71873054, 0xb6f2cf3b,0x9f326442,0xcb15a4cc,0xb01a4504, 0xf1e47d8d,0x844a1be5,0xbae7dfdc,0x42cbda70, 0xcd7dae0a,0x57e85b7a,0xd53f5af6,0x20cf4d8c, 0xcea4d428,0x79d130a4,0x3486ebfb,0x33d3cddc, 0x77853b53,0x37effcb5,0xc5068778,0xe580b3e6, 0x4e68b8f4,0xc5c8b37e,0x0d809ea2,0x398feb7c, 0x132a4f94,0x43b7950e,0x2fee7d1c,0x223613bd, 0xdd06caa2,0x37df932b,0xc4248289,0xacf3ebc3, 0x5715f6b7,0xef3478dd,0xf267616f,0xc148cbe4, 0x9052815e,0x5e410fab,0xb48a2465,0x2eda7fa4, 0xe87b40e4,0xe98ea084,0x5889e9e1,0xefd390fc, 0xdd07d35b,0xdb485694,0x38d7e5b2,0x57720101, 0x730edebc,0x5b643113,0x94917e4f,0x503c2fba, 0x646f1282,0x7523d24a,0xe0779695,0xf9c17a8f, 0x7a5b2121,0xd187b896,0x29263a4d,0xba510cdf, 0x81f47c9f,0xad1163ed,0xea7b5965,0x1a00726e, 0x11403092,0x00da6d77,0x4a0cdd61,0xad1f4603, 0x605bdfb0,0x9eedc364,0x22ebe6a8,0xcee7d28a, 0xa0e736a0,0x5564a6b9,0x10853209,0xc7eb8f37, 0x2de705ca,0x8951570f,0xdf09822b,0xbd691a6c, 0xaa12e4f2,0x87451c0f,0xe0f6a27a,0x3ada4819, 0x4cf1764f,0x0d771c2b,0x67cdb156,0x350d8384, 0x5938fa0f,0x42399ef3,0x36997b07,0x0e84093d, 0x4aa93e61,0x8360d87b,0x1fa98b0c,0x1149382c, 0xe97625a5,0x0614d1b7,0x0e25244b,0x0c768347, 0x589e8d82,0x0d2059d1,0xa466bb1e,0xf8da0a82, 0x04f19130,0xba6e4ec0,0x99265164,0x1ee7230d, 0x50b2ad80,0xeaee6801,0x8db2a283,0xea8bf59e, };
{ "pile_set_name": "Github" }
//===-- AMDGPUBaseInfo.cpp - AMDGPU Base encoding information--------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "AMDGPUBaseInfo.h" #include "AMDGPU.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalValue.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/SubtargetFeature.h" #define GET_SUBTARGETINFO_ENUM #include "AMDGPUGenSubtargetInfo.inc" #undef GET_SUBTARGETINFO_ENUM #define GET_REGINFO_ENUM #include "AMDGPUGenRegisterInfo.inc" #undef GET_REGINFO_ENUM namespace llvm { namespace AMDGPU { IsaVersion getIsaVersion(const FeatureBitset &Features) { if (Features.test(FeatureISAVersion7_0_0)) return {7, 0, 0}; if (Features.test(FeatureISAVersion7_0_1)) return {7, 0, 1}; if (Features.test(FeatureISAVersion8_0_0)) return {8, 0, 0}; if (Features.test(FeatureISAVersion8_0_1)) return {8, 0, 1}; if (Features.test(FeatureISAVersion8_0_3)) return {8, 0, 3}; return {0, 0, 0}; } void initDefaultAMDKernelCodeT(amd_kernel_code_t &Header, const FeatureBitset &Features) { IsaVersion ISA = getIsaVersion(Features); memset(&Header, 0, sizeof(Header)); Header.amd_kernel_code_version_major = 1; Header.amd_kernel_code_version_minor = 0; Header.amd_machine_kind = 1; // AMD_MACHINE_KIND_AMDGPU Header.amd_machine_version_major = ISA.Major; Header.amd_machine_version_minor = ISA.Minor; Header.amd_machine_version_stepping = ISA.Stepping; Header.kernel_code_entry_byte_offset = sizeof(Header); // wavefront_size is specified as a power of 2: 2^6 = 64 threads. Header.wavefront_size = 6; // These alignment values are specified in powers of two, so alignment = // 2^n. The minimum alignment is 2^4 = 16. Header.kernarg_segment_alignment = 4; Header.group_segment_alignment = 4; Header.private_segment_alignment = 4; } MCSection *getHSATextSection(MCContext &Ctx) { return Ctx.getELFSection(".hsatext", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_EXECINSTR | ELF::SHF_AMDGPU_HSA_AGENT | ELF::SHF_AMDGPU_HSA_CODE); } MCSection *getHSADataGlobalAgentSection(MCContext &Ctx) { return Ctx.getELFSection(".hsadata_global_agent", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_AMDGPU_HSA_GLOBAL | ELF::SHF_AMDGPU_HSA_AGENT); } MCSection *getHSADataGlobalProgramSection(MCContext &Ctx) { return Ctx.getELFSection(".hsadata_global_program", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_AMDGPU_HSA_GLOBAL); } MCSection *getHSARodataReadonlyAgentSection(MCContext &Ctx) { return Ctx.getELFSection(".hsarodata_readonly_agent", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_AMDGPU_HSA_READONLY | ELF::SHF_AMDGPU_HSA_AGENT); } bool isGroupSegment(const GlobalValue *GV) { return GV->getType()->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS; } bool isGlobalSegment(const GlobalValue *GV) { return GV->getType()->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS; } bool isReadOnlySegment(const GlobalValue *GV) { return GV->getType()->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS; } int getIntegerAttribute(const Function &F, StringRef Name, int Default) { Attribute A = F.getFnAttribute(Name); int Result = Default; if (A.isStringAttribute()) { StringRef Str = A.getValueAsString(); if (Str.getAsInteger(0, Result)) { LLVMContext &Ctx = F.getContext(); Ctx.emitError("can't parse integer attribute " + Name); } } return Result; } unsigned getMaximumWorkGroupSize(const Function &F) { return getIntegerAttribute(F, "amdgpu-max-work-group-size", 256); } unsigned getInitialPSInputAddr(const Function &F) { return getIntegerAttribute(F, "InitialPSInputAddr", 0); } bool isShader(CallingConv::ID cc) { switch(cc) { case CallingConv::AMDGPU_VS: case CallingConv::AMDGPU_GS: case CallingConv::AMDGPU_PS: case CallingConv::AMDGPU_CS: return true; default: return false; } } bool isCompute(CallingConv::ID cc) { return !isShader(cc) || cc == CallingConv::AMDGPU_CS; } bool isSI(const MCSubtargetInfo &STI) { return STI.getFeatureBits()[AMDGPU::FeatureSouthernIslands]; } bool isCI(const MCSubtargetInfo &STI) { return STI.getFeatureBits()[AMDGPU::FeatureSeaIslands]; } bool isVI(const MCSubtargetInfo &STI) { return STI.getFeatureBits()[AMDGPU::FeatureVolcanicIslands]; } unsigned getMCReg(unsigned Reg, const MCSubtargetInfo &STI) { switch(Reg) { default: break; case AMDGPU::FLAT_SCR: assert(!isSI(STI)); return isCI(STI) ? AMDGPU::FLAT_SCR_ci : AMDGPU::FLAT_SCR_vi; case AMDGPU::FLAT_SCR_LO: assert(!isSI(STI)); return isCI(STI) ? AMDGPU::FLAT_SCR_LO_ci : AMDGPU::FLAT_SCR_LO_vi; case AMDGPU::FLAT_SCR_HI: assert(!isSI(STI)); return isCI(STI) ? AMDGPU::FLAT_SCR_HI_ci : AMDGPU::FLAT_SCR_HI_vi; } return Reg; } } // End namespace AMDGPU } // End namespace llvm
{ "pile_set_name": "Github" }
--- http_interactions: - request: method: post uri: http://ps.pndsn.com/publish/pub-a-mock-key/sub-a-mock-key/0/demo/0?auth=ruby-test-auth-client-one&ortt=%7B%22t%22:14660947580714822%7D&pnsdk=PubNub-Ruby/4.1.0beta2&seqn=1&uuid=ruby-test-uuid-client-one body: encoding: UTF-8 string: '"wdjzGfMFLREacKDtVrgDgA=="' headers: User-Agent: - HTTPClient/1.0 (2.8.0, ruby 2.3.0 (2015-12-25)) Accept: - "*/*" Date: - Thu, 16 Jun 2016 16:32:38 GMT Content-Type: - application/x-www-form-urlencoded response: status: code: 200 message: OK headers: Date: - Thu, 16 Jun 2016 16:32:38 GMT Content-Type: - text/javascript; charset="UTF-8" Content-Length: - '30' Connection: - keep-alive Cache-Control: - no-cache Access-Control-Allow-Origin: - "*" Access-Control-Allow-Methods: - GET body: encoding: UTF-8 string: '[1,"Sent","14660947581703640"]' http_version: recorded_at: Thu, 16 Jun 2016 16:32:38 GMT recorded_with: VCR 3.0.1
{ "pile_set_name": "Github" }
/* ssl/tls1.h */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * 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 ([email protected]). * * 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 ([email protected])" * 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 ([email protected])" * * 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-2006 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 * [email protected]. * * 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 * ([email protected]). This product includes software written by Tim * Hudson ([email protected]). * */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * * ECC cipher suite support in OpenSSL originally written by * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. * */ /* ==================================================================== * Copyright 2005 Nokia. All rights reserved. * * The portions of the attached software ("Contribution") is developed by * Nokia Corporation and is licensed pursuant to the OpenSSL open source * license. * * The Contribution, originally written by Mika Kousa and Pasi Eronen of * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites * support (see RFC 4279) to OpenSSL. * * No patent licenses or other rights except those expressly stated in * the OpenSSL open source license shall be deemed granted or received * expressly, by implication, estoppel, or otherwise. * * No assurances are provided by Nokia that the Contribution does not * infringe the patent or other intellectual property rights of any third * party or that the license provides you with all the necessary rights * to make use of the Contribution. * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR * OTHERWISE. */ #ifndef HEADER_TLS1_H # define HEADER_TLS1_H # include <openssl/buffer.h> #ifdef __cplusplus extern "C" { #endif # define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0 # define TLS1_VERSION 0x0301 # define TLS1_1_VERSION 0x0302 # define TLS1_2_VERSION 0x0303 # define TLS_MAX_VERSION TLS1_2_VERSION # define TLS1_VERSION_MAJOR 0x03 # define TLS1_VERSION_MINOR 0x01 # define TLS1_1_VERSION_MAJOR 0x03 # define TLS1_1_VERSION_MINOR 0x02 # define TLS1_2_VERSION_MAJOR 0x03 # define TLS1_2_VERSION_MINOR 0x03 # define TLS1_get_version(s) \ ((s->version >> 8) == TLS1_VERSION_MAJOR ? s->version : 0) # define TLS1_get_client_version(s) \ ((s->client_version >> 8) == TLS1_VERSION_MAJOR ? s->client_version : 0) # define TLS1_AD_DECRYPTION_FAILED 21 # define TLS1_AD_RECORD_OVERFLOW 22 # define TLS1_AD_UNKNOWN_CA 48/* fatal */ # define TLS1_AD_ACCESS_DENIED 49/* fatal */ # define TLS1_AD_DECODE_ERROR 50/* fatal */ # define TLS1_AD_DECRYPT_ERROR 51 # define TLS1_AD_EXPORT_RESTRICTION 60/* fatal */ # define TLS1_AD_PROTOCOL_VERSION 70/* fatal */ # define TLS1_AD_INSUFFICIENT_SECURITY 71/* fatal */ # define TLS1_AD_INTERNAL_ERROR 80/* fatal */ # define TLS1_AD_INAPPROPRIATE_FALLBACK 86/* fatal */ # define TLS1_AD_USER_CANCELLED 90 # define TLS1_AD_NO_RENEGOTIATION 100 /* codes 110-114 are from RFC3546 */ # define TLS1_AD_UNSUPPORTED_EXTENSION 110 # define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111 # define TLS1_AD_UNRECOGNIZED_NAME 112 # define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113 # define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114 # define TLS1_AD_UNKNOWN_PSK_IDENTITY 115/* fatal */ /* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */ # define TLSEXT_TYPE_server_name 0 # define TLSEXT_TYPE_max_fragment_length 1 # define TLSEXT_TYPE_client_certificate_url 2 # define TLSEXT_TYPE_trusted_ca_keys 3 # define TLSEXT_TYPE_truncated_hmac 4 # define TLSEXT_TYPE_status_request 5 /* ExtensionType values from RFC4681 */ # define TLSEXT_TYPE_user_mapping 6 /* ExtensionType values from RFC5878 */ # define TLSEXT_TYPE_client_authz 7 # define TLSEXT_TYPE_server_authz 8 /* ExtensionType values from RFC6091 */ # define TLSEXT_TYPE_cert_type 9 /* ExtensionType values from RFC4492 */ # define TLSEXT_TYPE_elliptic_curves 10 # define TLSEXT_TYPE_ec_point_formats 11 /* ExtensionType value from RFC5054 */ # define TLSEXT_TYPE_srp 12 /* ExtensionType values from RFC5246 */ # define TLSEXT_TYPE_signature_algorithms 13 /* ExtensionType value from RFC5764 */ # define TLSEXT_TYPE_use_srtp 14 /* ExtensionType value from RFC5620 */ # define TLSEXT_TYPE_heartbeat 15 /* ExtensionType value from RFC7301 */ # define TLSEXT_TYPE_application_layer_protocol_negotiation 16 /* * ExtensionType value for TLS padding extension. * http://tools.ietf.org/html/draft-agl-tls-padding */ # define TLSEXT_TYPE_padding 21 /* ExtensionType value from RFC4507 */ # define TLSEXT_TYPE_session_ticket 35 /* ExtensionType value from draft-rescorla-tls-opaque-prf-input-00.txt */ # if 0 /* * will have to be provided externally for now , * i.e. build with -DTLSEXT_TYPE_opaque_prf_input=38183 * using whatever extension number you'd like to try */ # define TLSEXT_TYPE_opaque_prf_input ?? # endif /* Temporary extension type */ # define TLSEXT_TYPE_renegotiate 0xff01 # ifndef OPENSSL_NO_NEXTPROTONEG /* This is not an IANA defined extension number */ # define TLSEXT_TYPE_next_proto_neg 13172 # endif /* NameType value from RFC3546 */ # define TLSEXT_NAMETYPE_host_name 0 /* status request value from RFC3546 */ # define TLSEXT_STATUSTYPE_ocsp 1 /* ECPointFormat values from RFC4492 */ # define TLSEXT_ECPOINTFORMAT_first 0 # define TLSEXT_ECPOINTFORMAT_uncompressed 0 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 # define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 # define TLSEXT_ECPOINTFORMAT_last 2 /* Signature and hash algorithms from RFC5246 */ # define TLSEXT_signature_anonymous 0 # define TLSEXT_signature_rsa 1 # define TLSEXT_signature_dsa 2 # define TLSEXT_signature_ecdsa 3 /* Total number of different signature algorithms */ # define TLSEXT_signature_num 4 # define TLSEXT_hash_none 0 # define TLSEXT_hash_md5 1 # define TLSEXT_hash_sha1 2 # define TLSEXT_hash_sha224 3 # define TLSEXT_hash_sha256 4 # define TLSEXT_hash_sha384 5 # define TLSEXT_hash_sha512 6 /* TASS HSM OPENSSL INTERFACE : China TLSv1.1 */ # ifndef OPENSSL_NO_SM2 # define TLSEXT_hash_sm3 7 /* Total number of different digest algorithms */ # define TLSEXT_hash_num 8 # else # define TLSEXT_hash_num 7 # endif /* TASS HSM OPENSSL INTERFACE : China TLSv1.1 -- end */ /* Flag set for unrecognised algorithms */ # define TLSEXT_nid_unknown 0x1000000 /* ECC curves */ # define TLSEXT_curve_P_256 23 # define TLSEXT_curve_P_384 24 # ifndef OPENSSL_NO_TLSEXT # define TLSEXT_MAXLEN_host_name 255 const char *SSL_get_servername(const SSL *s, const int type); int SSL_get_servername_type(const SSL *s); /* * SSL_export_keying_material exports a value derived from the master secret, * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and * optional context. (Since a zero length context is allowed, the |use_context| * flag controls whether a context is included.) It returns 1 on success and * zero otherwise. */ int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, const char *label, size_t llen, const unsigned char *p, size_t plen, int use_context); int SSL_get_sigalgs(SSL *s, int idx, int *psign, int *phash, int *psignandhash, unsigned char *rsig, unsigned char *rhash); int SSL_get_shared_sigalgs(SSL *s, int idx, int *psign, int *phash, int *psignandhash, unsigned char *rsig, unsigned char *rhash); int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain); # define SSL_set_tlsext_host_name(s,name) \ SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name) # define SSL_set_tlsext_debug_callback(ssl, cb) \ SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb) # define SSL_set_tlsext_debug_arg(ssl, arg) \ SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg) # define SSL_set_tlsext_status_type(ssl, type) \ SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL) # define SSL_get_tlsext_status_exts(ssl, arg) \ SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg) # define SSL_set_tlsext_status_exts(ssl, arg) \ SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg) # define SSL_get_tlsext_status_ids(ssl, arg) \ SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg) # define SSL_set_tlsext_status_ids(ssl, arg) \ SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg) # define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \ SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg) # define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \ SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg) # define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \ SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb) # define SSL_TLSEXT_ERR_OK 0 # define SSL_TLSEXT_ERR_ALERT_WARNING 1 # define SSL_TLSEXT_ERR_ALERT_FATAL 2 # define SSL_TLSEXT_ERR_NOACK 3 # define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg) # define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \ SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLSEXT_TICKET_KEYS,(keylen),(keys)) # define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \ SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLSEXT_TICKET_KEYS,(keylen),(keys)) # define SSL_CTX_set_tlsext_status_cb(ssl, cb) \ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb) # define SSL_CTX_set_tlsext_status_arg(ssl, arg) \ SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg) # define SSL_set_tlsext_opaque_prf_input(s, src, len) \ SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT, len, src) # define SSL_CTX_set_tlsext_opaque_prf_input_callback(ctx, cb) \ SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB, (void (*)(void))cb) # define SSL_CTX_set_tlsext_opaque_prf_input_callback_arg(ctx, arg) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG, 0, arg) # define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) # ifndef OPENSSL_NO_HEARTBEATS # define SSL_TLSEXT_HB_ENABLED 0x01 # define SSL_TLSEXT_HB_DONT_SEND_REQUESTS 0x02 # define SSL_TLSEXT_HB_DONT_RECV_REQUESTS 0x04 # define SSL_get_tlsext_heartbeat_pending(ssl) \ SSL_ctrl((ssl),SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING,0,NULL) # define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \ SSL_ctrl((ssl),SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL) # endif # endif /* PSK ciphersuites from 4279 */ # define TLS1_CK_PSK_WITH_RC4_128_SHA 0x0300008A # define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008B # define TLS1_CK_PSK_WITH_AES_128_CBC_SHA 0x0300008C # define TLS1_CK_PSK_WITH_AES_256_CBC_SHA 0x0300008D /* * Additional TLS ciphersuites from expired Internet Draft * draft-ietf-tls-56-bit-ciphersuites-01.txt (available if * TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see s3_lib.c). We * actually treat them like SSL 3.0 ciphers, which we probably shouldn't. * Note that the first two are actually not in the IDs. */ # define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060/* not in * ID */ # define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061/* not in * ID */ # define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 # define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 # define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 # define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 # define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 /* AES ciphersuites from RFC3268 */ # define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F # define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 # define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 # define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 # define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 # define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 # define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 # define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 # define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 # define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 # define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 # define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A /* TLS v1.2 ciphersuites */ # define TLS1_CK_RSA_WITH_NULL_SHA256 0x0300003B # define TLS1_CK_RSA_WITH_AES_128_SHA256 0x0300003C # define TLS1_CK_RSA_WITH_AES_256_SHA256 0x0300003D # define TLS1_CK_DH_DSS_WITH_AES_128_SHA256 0x0300003E # define TLS1_CK_DH_RSA_WITH_AES_128_SHA256 0x0300003F # define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 0x03000040 /* Camellia ciphersuites from RFC4132 */ # define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 # define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 # define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 # define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 # define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 # define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 /* TLS v1.2 ciphersuites */ # define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256 0x03000067 # define TLS1_CK_DH_DSS_WITH_AES_256_SHA256 0x03000068 # define TLS1_CK_DH_RSA_WITH_AES_256_SHA256 0x03000069 # define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256 0x0300006A # define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256 0x0300006B # define TLS1_CK_ADH_WITH_AES_128_SHA256 0x0300006C # define TLS1_CK_ADH_WITH_AES_256_SHA256 0x0300006D /* Camellia ciphersuites from RFC4132 */ # define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 # define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 # define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 # define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 # define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 # define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 /* SEED ciphersuites from RFC4162 */ # define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096 # define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097 # define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098 # define TLS1_CK_DHE_DSS_WITH_SEED_SHA 0x03000099 # define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A # define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B /* TLS v1.2 GCM ciphersuites from RFC5288 */ # define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 0x0300009C # define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 0x0300009D # define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 0x0300009E # define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384 0x0300009F # define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256 0x030000A0 # define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384 0x030000A1 # define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256 0x030000A2 # define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384 0x030000A3 # define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256 0x030000A4 # define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384 0x030000A5 # define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 0x030000A6 # define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 0x030000A7 /* * ECC ciphersuites from draft-ietf-tls-ecc-12.txt with changes soon to be in * draft 13 */ # define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 # define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 # define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 # define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 # define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 # define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 # define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 # define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 # define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 # define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A # define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B # define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C # define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D # define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E # define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F # define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 # define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 # define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 # define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 # define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 # define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 # define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 # define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 # define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 # define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 /* SRP ciphersuites from RFC 5054 */ # define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA 0x0300C01A # define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA 0x0300C01B # define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA 0x0300C01C # define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA 0x0300C01D # define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA 0x0300C01E # define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA 0x0300C01F # define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA 0x0300C020 # define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 0x0300C021 # define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 0x0300C022 /* ECDH HMAC based ciphersuites from RFC5289 */ # define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 0x0300C023 # define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 0x0300C024 # define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256 0x0300C025 # define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384 0x0300C026 # define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256 0x0300C027 # define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384 0x0300C028 # define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 0x0300C029 # define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 0x0300C02A /* ECDH GCM based ciphersuites from RFC5289 */ # define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02B # define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02C # define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02D # define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02E # define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0x0300C02F # define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0x0300C030 # define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 0x0300C031 # define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 0x0300C032 /* TASS HSM INTERFACE : China SSL VPN Technology Specification : TLSv1.1 */ # ifndef OPENSSL_NO_SM2 # define TLS1_CK_ECDHE_WITH_SM1_SM3 0x0300E001 # define TLS1_CK_ECC_WITH_SM1_SM3 0x0300E003 # define TLS1_CK_IBSDH_WITH_SM1_SM3 0x0300E005 # define TLS1_CK_IBC_WITH_SM1_SM3 0x0300E007 # define TLS1_CK_RSA_WITH_SM1_SM3 0x0300E009 # define TLS1_CK_RSA_WITH_SM1_SHA1 0x0300E00A # define TLS1_CK_ECDHE_WITH_SM4_SM3 0x0300E011 # define TLS1_CK_ECC_WITH_SM4_SM3 0x0300E013 # define TLS1_CK_IBSDH_WITH_SM4_SM3 0x0300E015 # define TLS1_CK_IBC_WITH_SM4_SM3 0x0300E017 # define TLS1_CK_RSA_WITH_SM4_SM3 0x0300E019 # define TLS1_CK_RSA_WITH_SM4_SHA1 0x0300E01A # endif /* TASS HSM OPENSSL INTERFACE : China TLSv1.1 -- end */ /* * XXX * Backward compatibility alert: + * Older versions of OpenSSL gave * some DHE ciphers names with "EDH" + * instead of "DHE". Going forward, we * should be using DHE + * everywhere, though we may indefinitely maintain * aliases for users + * or configurations that used "EDH" + */ /* TASS HSM INTERFACE : China SSL VPN Technology Specification: TLSv1.1 Text Information start */ # ifndef OPENSSL_NO_SM2 # define TLS1_TXT_ECDHE_WITH_SM1_SM3 "ECDHE-SM1-SM3" # define TLS1_TXT_ECC_WITH_SM1_SM3 "ECC-SM1-SM3" # define TLS1_TXT_IBSDH_WITH_SM1_SM3 "IBSDH-SM1-SM3" # define TLS1_TXT_IBC_WITH_SM1_SM3 "IBC-SM1-SM3" # define TLS1_TXT_RSA_WITH_SM1_SM3 "RSA-SM1-SM3" # define TLS1_TXT_RSA_WITH_SM1_SHA1 "RSA-SM1-SHA1" # define TLS1_TXT_ECDHE_WITH_SM4_SM3 "ECDHE-SM4-SM3" # define TLS1_TXT_ECC_WITH_SM4_SM3 "ECC-SM4-SM3" # define TLS1_TXT_IBSDH_WITH_SM4_SM3 "IBSDH-SM4-SM3" # define TLS1_TXT_IBC_WITH_SM4_SM3 "IBC-SM4-SM3" # define TLS1_TXT_RSA_WITH_SM4_SM3 "RSA-SM4-SM3" # define TLS1_TXT_RSA_WITH_SM4_SHA1 "RSA-SM4-SHA1" # endif /* TASS HSM INTERFACE : China SSL VPN Technology Specification: TLSv1.1 Text Information end */ # define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" # define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" # define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" # define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA" # define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" # define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" # define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" /* AES ciphersuites from RFC3268 */ # define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" # define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" # define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" # define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" # define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" # define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" # define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" # define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" # define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" # define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" # define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" # define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" /* ECC ciphersuites from RFC4492 */ # define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" # define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" # define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" # define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" # define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" # define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" # define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" # define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" # define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" # define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" # define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" # define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" # define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" # define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" # define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" # define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" # define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" # define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" # define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" # define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" # define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" # define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" /* PSK ciphersuites from RFC 4279 */ # define TLS1_TXT_PSK_WITH_RC4_128_SHA "PSK-RC4-SHA" # define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA "PSK-3DES-EDE-CBC-SHA" # define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA "PSK-AES128-CBC-SHA" # define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA "PSK-AES256-CBC-SHA" /* SRP ciphersuite from RFC 5054 */ # define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA "SRP-3DES-EDE-CBC-SHA" # define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "SRP-RSA-3DES-EDE-CBC-SHA" # define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "SRP-DSS-3DES-EDE-CBC-SHA" # define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA "SRP-AES-128-CBC-SHA" # define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "SRP-RSA-AES-128-CBC-SHA" # define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "SRP-DSS-AES-128-CBC-SHA" # define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA "SRP-AES-256-CBC-SHA" # define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "SRP-RSA-AES-256-CBC-SHA" # define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "SRP-DSS-AES-256-CBC-SHA" /* Camellia ciphersuites from RFC4132 */ # define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" # define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" # define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" # define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" # define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" # define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" # define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" # define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" # define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" # define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" # define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" # define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" /* SEED ciphersuites from RFC4162 */ # define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA" # define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA" # define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA" # define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA" # define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA" # define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA" /* TLS v1.2 ciphersuites */ # define TLS1_TXT_RSA_WITH_NULL_SHA256 "NULL-SHA256" # define TLS1_TXT_RSA_WITH_AES_128_SHA256 "AES128-SHA256" # define TLS1_TXT_RSA_WITH_AES_256_SHA256 "AES256-SHA256" # define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 "DH-DSS-AES128-SHA256" # define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 "DH-RSA-AES128-SHA256" # define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 "DHE-DSS-AES128-SHA256" # define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 "DHE-RSA-AES128-SHA256" # define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 "DH-DSS-AES256-SHA256" # define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 "DH-RSA-AES256-SHA256" # define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 "DHE-DSS-AES256-SHA256" # define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 "DHE-RSA-AES256-SHA256" # define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256" # define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256" /* TLS v1.2 GCM ciphersuites from RFC5288 */ # define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256" # define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384" # define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 "DHE-RSA-AES128-GCM-SHA256" # define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384 "DHE-RSA-AES256-GCM-SHA384" # define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256 "DH-RSA-AES128-GCM-SHA256" # define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384 "DH-RSA-AES256-GCM-SHA384" # define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256 "DHE-DSS-AES128-GCM-SHA256" # define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384 "DHE-DSS-AES256-GCM-SHA384" # define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256 "DH-DSS-AES128-GCM-SHA256" # define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384 "DH-DSS-AES256-GCM-SHA384" # define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 "ADH-AES128-GCM-SHA256" # define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 "ADH-AES256-GCM-SHA384" /* ECDH HMAC based ciphersuites from RFC5289 */ # define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 "ECDHE-ECDSA-AES128-SHA256" # define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 "ECDHE-ECDSA-AES256-SHA384" # define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256 "ECDH-ECDSA-AES128-SHA256" # define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384 "ECDH-ECDSA-AES256-SHA384" # define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256 "ECDHE-RSA-AES128-SHA256" # define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384 "ECDHE-RSA-AES256-SHA384" # define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 "ECDH-RSA-AES128-SHA256" # define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384" /* ECDH GCM based ciphersuites from RFC5289 */ # define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "ECDHE-ECDSA-AES128-GCM-SHA256" # define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "ECDHE-ECDSA-AES256-GCM-SHA384" # define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 "ECDH-ECDSA-AES128-GCM-SHA256" # define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 "ECDH-ECDSA-AES256-GCM-SHA384" # define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "ECDHE-RSA-AES128-GCM-SHA256" # define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "ECDHE-RSA-AES256-GCM-SHA384" # define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 "ECDH-RSA-AES128-GCM-SHA256" # define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384 "ECDH-RSA-AES256-GCM-SHA384" # define TLS_CT_RSA_SIGN 1 # define TLS_CT_DSS_SIGN 2 # define TLS_CT_RSA_FIXED_DH 3 # define TLS_CT_DSS_FIXED_DH 4 # define TLS_CT_ECDSA_SIGN 64 # define TLS_CT_RSA_FIXED_ECDH 65 # define TLS_CT_ECDSA_FIXED_ECDH 66 # define TLS_CT_GOST94_SIGN 21 # define TLS_CT_GOST01_SIGN 22 /* * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see * comment there) */ # define TLS_CT_NUMBER 9 # define TLS1_FINISH_MAC_LENGTH 12 # define TLS_MD_MAX_CONST_SIZE 20 # define TLS_MD_CLIENT_FINISH_CONST "client finished" # define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 # define TLS_MD_SERVER_FINISH_CONST "server finished" # define TLS_MD_SERVER_FINISH_CONST_SIZE 15 # define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" # define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 # define TLS_MD_KEY_EXPANSION_CONST "key expansion" # define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 # define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" # define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 # define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" # define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 # define TLS_MD_IV_BLOCK_CONST "IV block" # define TLS_MD_IV_BLOCK_CONST_SIZE 8 # define TLS_MD_MASTER_SECRET_CONST "master secret" # define TLS_MD_MASTER_SECRET_CONST_SIZE 13 # ifdef CHARSET_EBCDIC # undef TLS_MD_CLIENT_FINISH_CONST /* * client finished */ # define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" # undef TLS_MD_SERVER_FINISH_CONST /* * server finished */ # define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" # undef TLS_MD_SERVER_WRITE_KEY_CONST /* * server write key */ # define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" # undef TLS_MD_KEY_EXPANSION_CONST /* * key expansion */ # define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" # undef TLS_MD_CLIENT_WRITE_KEY_CONST /* * client write key */ # define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" # undef TLS_MD_SERVER_WRITE_KEY_CONST /* * server write key */ # define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" # undef TLS_MD_IV_BLOCK_CONST /* * IV block */ # define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" # undef TLS_MD_MASTER_SECRET_CONST /* * master secret */ # define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" # endif /* TLS Session Ticket extension struct */ struct tls_session_ticket_ext_st { unsigned short length; void *data; }; #ifdef __cplusplus } #endif #endif
{ "pile_set_name": "Github" }
from littleballoffur.dataset import * from littleballoffur.sampler import Sampler from littleballoffur.backend import NetworKitBackEnd, NetworkXBackEnd from littleballoffur.node_sampling import * from littleballoffur.edge_sampling import * from littleballoffur.exploration_sampling import * __all__ = [ 'littleballoffur', ]
{ "pile_set_name": "Github" }
include_rules = [ '+libxml', ]
{ "pile_set_name": "Github" }
3.0 (quilt)
{ "pile_set_name": "Github" }
;;; smime.el --- S/MIME support library ;; Copyright (C) 2000-2017 Free Software Foundation, Inc. ;; Author: Simon Josefsson <[email protected]> ;; Keywords: SMIME X.509 PEM OpenSSL ;; This file is part of GNU Emacs. ;; GNU Emacs 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. ;; GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Commentary: ;; This library perform S/MIME operations from within Emacs. ;; ;; Functions for fetching certificates from public repositories are ;; provided, currently from DNS and LDAP. ;; ;; It uses OpenSSL (tested with version 0.9.5a and 0.9.6) for signing, ;; encryption and decryption. ;; ;; Some general knowledge of S/MIME, X.509, PKCS#12, PEM etc is ;; probably required to use this library in any useful way. ;; Especially, don't expect this library to buy security for you. If ;; you don't understand what you are doing, you're as likely to lose ;; security than gain any by using this library. ;; ;; This library is not intended to provide a "raw" API for S/MIME, ;; PKCSx or similar, it's intended to perform common operations ;; done on messages encoded in these formats. The terminology chosen ;; reflect this. ;; ;; The home of this file is in Gnus, but also available from ;; http://josefsson.org/smime.html. ;;; Quick introduction: ;; Get your S/MIME certificate from VeriSign or someplace. I used ;; Netscape to generate the key and certificate request and stuff, and ;; Netscape can export the key into PKCS#12 format. ;; ;; Enter OpenSSL. To be able to use this library, it need to have the ;; SMIME key readable in PEM format. OpenSSL is used to convert the ;; key: ;; ;; $ openssl pkcs12 -in mykey.p12 -clcerts -nodes > mykey.pem ;; ... ;; ;; Now, use M-x customize-variable smime-keys and add mykey.pem as ;; a key. ;; ;; Now you should be able to sign messages! Create a buffer and write ;; something and run M-x smime-sign-buffer RET RET and you should see ;; your message MIME armored and a signature. Encryption, M-x ;; smime-encrypt-buffer, should also work. ;; ;; To be able to verify messages you need to build up trust with ;; someone. Perhaps you trust the CA that issued your certificate, at ;; least I did, so I export it's certificates from my PKCS#12 ;; certificate with: ;; ;; $ openssl pkcs12 -in mykey.p12 -cacerts -nodes > cacert.pem ;; ... ;; ;; Now, use M-x customize-variable smime-CAs and add cacert.pem as a ;; CA certificate. ;; ;; You should now be able to sign messages, and even verify messages ;; sent by others that use the same CA as you. ;; Bugs: ;; ;; Don't complain that this package doesn't do encrypted PEM files, ;; submit a patch instead. I store my keys in a safe place, so I ;; didn't need the encryption. Also, programming was made easier by ;; that decision. One might think that this even influenced were I ;; store my keys, and one would probably be right. :-) ;; ;; Update: Mathias Herberts sent the patch. However, it uses ;; environment variables to pass the password to OpenSSL, which is ;; slightly insecure. Hence a new todo: use a better -passin method. ;; ;; Cache password for e.g. 1h ;; ;; Suggestions and comments are appreciated, mail me at [email protected]. ;; begin rant ;; ;; I would include pointers to introductory text on concepts used in ;; this library here, but the material I've read are so horrible I ;; don't want to recommend them. ;; ;; Why can't someone write a simple introduction to all this stuff? ;; Until then, much of this resemble security by obscurity. ;; ;; Also, I'm not going to mention anything about the wonders of ;; cryptopolitics. Oops, I just did. ;; ;; end rant ;;; Revision history: ;; 2000-06-05 initial version, committed to Gnus CVS contrib/ ;; 2000-10-28 retrieve certificates via DNS CERT RRs ;; 2001-10-14 posted to gnu.emacs.sources ;; 2005-02-13 retrieve certificates via LDAP ;;; Code: (require 'dig) (if (locate-library "password-cache") (require 'password-cache) (require 'password)) (eval-when-compile (require 'cl)) (eval-and-compile (cond ((fboundp 'replace-in-string) (defalias 'smime-replace-in-string 'replace-in-string)) ((fboundp 'replace-regexp-in-string) (defun smime-replace-in-string (string regexp newtext &optional literal) "Replace all matches for REGEXP with NEWTEXT in STRING. If LITERAL is non-nil, insert NEWTEXT literally. Return a new string containing the replacements. This is a compatibility function for different Emacsen." (replace-regexp-in-string regexp newtext string nil literal))))) (defgroup smime nil "S/MIME configuration." :group 'mime) (defcustom smime-keys nil "*Map mail addresses to a file containing Certificate (and private key). The file is assumed to be in PEM format. You can also associate additional certificates to be sent with every message to each address." :type '(repeat (list (string :tag "Mail address") (file :tag "File name") (repeat :tag "Additional certificate files" (file :tag "File name")))) :group 'smime) (defcustom smime-CA-directory nil "*Directory containing certificates for CAs you trust. Directory should contain files (in PEM format) named to the X.509 hash of the certificate. This can be done using OpenSSL such as: $ ln -s ca.pem \\=`openssl x509 -noout -hash -in ca.pem\\=`.0 where `ca.pem' is the file containing a PEM encoded X.509 CA certificate." :type '(choice (const :tag "none" nil) directory) :group 'smime) (defcustom smime-CA-file nil "*Files containing certificates for CAs you trust. File should contain certificates in PEM format." :version "22.1" :type '(choice (const :tag "none" nil) file) :group 'smime) (defcustom smime-certificate-directory "~/Mail/certs/" "*Directory containing other people's certificates. It should contain files named to the X.509 hash of the certificate, and the files themselves should be in PEM format." ;The S/MIME library provide simple functionality for fetching ;certificates into this directory, so there is no need to populate it ;manually. :type 'directory :group 'smime) (defcustom smime-openssl-program (and (condition-case () (eq 0 (call-process "openssl" nil nil nil "version")) (error nil)) "openssl") "*Name of OpenSSL binary." :type 'string :group 'smime) ;; OpenSSL option to select the encryption cipher (defcustom smime-encrypt-cipher "-des3" "*Cipher algorithm used for encryption." :version "22.1" :type '(choice (const :tag "Triple DES" "-des3") (const :tag "DES" "-des") (const :tag "RC2 40 bits" "-rc2-40") (const :tag "RC2 64 bits" "-rc2-64") (const :tag "RC2 128 bits" "-rc2-128")) :group 'smime) (defcustom smime-crl-check nil "*Check revocation status of signers certificate using CRLs. Enabling this will have OpenSSL check the signers certificate against a certificate revocation list (CRL). For this to work the CRL must be up-to-date and since they are normally updated quite often (i.e., several times a day) you probably need some tool to keep them up-to-date. Unfortunately Gnus cannot do this for you. The CRL should either be appended (in PEM format) to your `smime-CA-file' or be located in a file (also in PEM format) in your `smime-certificate-directory' named to the X.509 hash of the certificate with .r0 as file name extension. At least OpenSSL version 0.9.7 is required for this to work." :type '(choice (const :tag "No check" nil) (const :tag "Check certificate" "-crl_check") (const :tag "Check certificate chain" "-crl_check_all")) :group 'smime) (defcustom smime-dns-server nil "*DNS server to query certificates from. If nil, use system defaults." :version "22.1" :type '(choice (const :tag "System defaults") string) :group 'smime) (defcustom smime-ldap-host-list nil "A list of LDAP hosts with S/MIME user certificates. If needed search base, binddn, passwd, etc. for the LDAP host must be set in `ldap-host-parameters-alist'." :type '(repeat (string :tag "Host name")) :version "23.1" ;; No Gnus :group 'smime) (defvar smime-details-buffer "*OpenSSL output*") ;; Use mm-util? (eval-and-compile (defalias 'smime-make-temp-file (if (fboundp 'make-temp-file) 'make-temp-file (lambda (prefix &optional dir-flag) ;; Simple implementation (expand-file-name (make-temp-name prefix) (if (fboundp 'temp-directory) (temp-directory) temporary-file-directory)))))) ;; Password dialog function (declare-function password-read-and-add "password-cache" (prompt &optional key)) (defun smime-ask-passphrase (&optional cache-key) "Asks the passphrase to unlock the secret key. If `cache-key' and `password-cache' is non-nil then cache the password under `cache-key'." (let ((passphrase (password-read-and-add "Passphrase for secret key (RET for no passphrase): " cache-key))) (if (string= passphrase "") nil passphrase))) ;; OpenSSL wrappers. (defun smime-call-openssl-region (b e buf &rest args) (case (apply 'call-process-region b e smime-openssl-program nil buf nil args) (0 t) (1 (message "OpenSSL: An error occurred parsing the command options.") nil) (2 (message "OpenSSL: One of the input files could not be read.") nil) (3 (message "OpenSSL: An error occurred creating the PKCS#7 file or when reading the MIME message.") nil) (4 (message "OpenSSL: An error occurred decrypting or verifying the message.") nil) (t (error "Unknown OpenSSL exitcode") nil))) (defun smime-make-certfiles (certfiles) (if certfiles (append (list "-certfile" (expand-file-name (car certfiles))) (smime-make-certfiles (cdr certfiles))))) ;; Sign+encrypt region (defun smime-sign-region (b e keyfile) "Sign region with certified key in KEYFILE. If signing fails, the buffer is not modified. Region is assumed to have proper MIME tags. KEYFILE is expected to contain a PEM encoded private key and certificate as its car, and a list of additional certificates to include in its caar. If no additional certificates is included, KEYFILE may be the file containing the PEM encoded private key and certificate itself." (smime-new-details-buffer) (let* ((certfiles (and (cdr-safe keyfile) (cadr keyfile))) (keyfile (or (car-safe keyfile) keyfile)) (buffer (generate-new-buffer " *smime*")) (passphrase (smime-ask-passphrase (expand-file-name keyfile))) (tmpfile (smime-make-temp-file "smime"))) (if passphrase (setenv "GNUS_SMIME_PASSPHRASE" passphrase)) (prog1 (when (prog1 (apply 'smime-call-openssl-region b e (list buffer tmpfile) "smime" "-sign" "-signer" (expand-file-name keyfile) (append (smime-make-certfiles certfiles) (if passphrase (list "-passin" "env:GNUS_SMIME_PASSPHRASE")))) (if passphrase (setenv "GNUS_SMIME_PASSPHRASE" "" t)) (with-current-buffer smime-details-buffer (insert-file-contents tmpfile) (delete-file tmpfile))) (delete-region b e) (insert-buffer-substring buffer) (goto-char b) (when (looking-at "^MIME-Version: 1.0$") (delete-region (point) (progn (forward-line 1) (point)))) t) (with-current-buffer smime-details-buffer (goto-char (point-max)) (insert-buffer-substring buffer)) (kill-buffer buffer)))) (defun smime-encrypt-region (b e certfiles) "Encrypt region for recipients specified in CERTFILES. If encryption fails, the buffer is not modified. Region is assumed to have proper MIME tags. CERTFILES is a list of filenames, each file is expected to contain of a PEM encoded certificate." (smime-new-details-buffer) (let ((buffer (generate-new-buffer " *smime*")) (tmpfile (smime-make-temp-file "smime"))) (prog1 (when (prog1 (apply 'smime-call-openssl-region b e (list buffer tmpfile) "smime" "-encrypt" smime-encrypt-cipher (mapcar 'expand-file-name certfiles)) (with-current-buffer smime-details-buffer (insert-file-contents tmpfile) (delete-file tmpfile))) (delete-region b e) (insert-buffer-substring buffer) (goto-char b) (when (looking-at "^MIME-Version: 1.0$") (delete-region (point) (progn (forward-line 1) (point)))) t) (with-current-buffer smime-details-buffer (goto-char (point-max)) (insert-buffer-substring buffer)) (kill-buffer buffer)))) ;; Sign+encrypt buffer (defun smime-sign-buffer (&optional keyfile buffer) "S/MIME sign BUFFER with key in KEYFILE. KEYFILE should contain a PEM encoded key and certificate." (interactive) (with-current-buffer (or buffer (current-buffer)) (unless (smime-sign-region (point-min) (point-max) (if keyfile keyfile (smime-get-key-with-certs-by-email (gnus-completing-read "Sign using key" smime-keys nil (car-safe (car-safe smime-keys)))))) (error "Signing failed")))) (defun smime-encrypt-buffer (&optional certfiles buffer) "S/MIME encrypt BUFFER for recipients specified in CERTFILES. CERTFILES is a list of filenames, each file is expected to consist of a PEM encoded key and certificate. Uses current buffer if BUFFER is nil." (interactive) (with-current-buffer (or buffer (current-buffer)) (unless (smime-encrypt-region (point-min) (point-max) (or certfiles (list (read-file-name "Recipient's S/MIME certificate: " smime-certificate-directory nil)))) (error "Encryption failed")))) ;; Verify+decrypt region (defun smime-verify-region (b e) "Verify S/MIME message in region between B and E. Returns non-nil on success. Any details (stdout and stderr) are left in the buffer specified by `smime-details-buffer'." (smime-new-details-buffer) (let ((CAs (append (if smime-CA-file (list "-CAfile" (expand-file-name smime-CA-file))) (if smime-CA-directory (list "-CApath" (expand-file-name smime-CA-directory)))))) (unless CAs (error "No CA configured")) (if smime-crl-check (add-to-list 'CAs smime-crl-check)) (if (apply 'smime-call-openssl-region b e (list smime-details-buffer t) "smime" "-verify" "-out" "/dev/null" CAs) t (insert-buffer-substring smime-details-buffer) nil))) (defun smime-noverify-region (b e) "Verify integrity of S/MIME message in region between B and E. Returns non-nil on success. Any details (stdout and stderr) are left in the buffer specified by `smime-details-buffer'." (smime-new-details-buffer) (if (apply 'smime-call-openssl-region b e (list smime-details-buffer t) "smime" "-verify" "-noverify" "-out" '("/dev/null")) t (insert-buffer-substring smime-details-buffer) nil)) (defun smime-decrypt-region (b e keyfile &optional from) "Decrypt S/MIME message in region between B and E with key in KEYFILE. Optional FROM specifies sender's mail address. On success, replaces region with decrypted data and return non-nil. Any details (stderr on success, stdout and stderr on error) are left in the buffer specified by `smime-details-buffer'." (smime-new-details-buffer) (let ((buffer (generate-new-buffer " *smime*")) CAs (passphrase (smime-ask-passphrase (expand-file-name keyfile))) (tmpfile (smime-make-temp-file "smime"))) (if passphrase (setenv "GNUS_SMIME_PASSPHRASE" passphrase)) (if (prog1 (apply 'smime-call-openssl-region b e (list buffer tmpfile) "smime" "-decrypt" "-recip" (expand-file-name keyfile) (if passphrase (list "-passin" "env:GNUS_SMIME_PASSPHRASE"))) (if passphrase (setenv "GNUS_SMIME_PASSPHRASE" "" t)) (with-current-buffer smime-details-buffer (insert-file-contents tmpfile) (delete-file tmpfile))) (progn (delete-region b e) (when from (insert "From: " from "\n")) (insert-buffer-substring buffer) (kill-buffer buffer) t) (with-current-buffer smime-details-buffer (insert-buffer-substring buffer)) (kill-buffer buffer) (delete-region b e) (insert-buffer-substring smime-details-buffer) nil))) ;; Verify+Decrypt buffer (defun smime-verify-buffer (&optional buffer) "Verify integrity of S/MIME message in BUFFER. Uses current buffer if BUFFER is nil. Returns non-nil on success. Any details (stdout and stderr) are left in the buffer specified by `smime-details-buffer'." (interactive) (with-current-buffer (or buffer (current-buffer)) (smime-verify-region (point-min) (point-max)))) (defun smime-noverify-buffer (&optional buffer) "Verify integrity of S/MIME message in BUFFER. Does NOT verify validity of certificate (only message integrity). Uses current buffer if BUFFER is nil. Returns non-nil on success. Any details (stdout and stderr) are left in the buffer specified by `smime-details-buffer'." (interactive) (with-current-buffer (or buffer (current-buffer)) (smime-noverify-region (point-min) (point-max)))) (defun smime-decrypt-buffer (&optional buffer keyfile) "Decrypt S/MIME message in BUFFER using KEYFILE. Uses current buffer if BUFFER is nil, and query user of KEYFILE if it's nil. On success, replaces data in buffer and return non-nil. Any details (stderr on success, stdout and stderr on error) are left in the buffer specified by `smime-details-buffer'." (interactive) (with-current-buffer (or buffer (current-buffer)) (smime-decrypt-region (point-min) (point-max) (expand-file-name (or keyfile (smime-get-key-by-email (gnus-completing-read "Decipher using key" smime-keys nil (car-safe (car-safe smime-keys))))))))) ;; Various operations (defun smime-new-details-buffer () (with-current-buffer (get-buffer-create smime-details-buffer) (erase-buffer))) (defun smime-pkcs7-region (b e) "Convert S/MIME message between points B and E into a PKCS7 message." (smime-new-details-buffer) (when (smime-call-openssl-region b e smime-details-buffer "smime" "-pk7out") (delete-region b e) (insert-buffer-substring smime-details-buffer) t)) (defun smime-pkcs7-certificates-region (b e) "Extract any certificates enclosed in PKCS7 message between points B and E." (smime-new-details-buffer) (when (smime-call-openssl-region b e smime-details-buffer "pkcs7" "-print_certs" "-text") (delete-region b e) (insert-buffer-substring smime-details-buffer) t)) (defun smime-pkcs7-email-region (b e) "Get email addresses contained in certificate between points B and E. A string or a list of strings is returned." (smime-new-details-buffer) (when (smime-call-openssl-region b e smime-details-buffer "x509" "-email" "-noout") (delete-region b e) (insert-buffer-substring smime-details-buffer) t)) ;; Utility functions (defun smime-get-certfiles (keyfile keys) (if keys (let ((curkey (car keys)) (otherkeys (cdr keys))) (if (string= keyfile (cadr curkey)) (caddr curkey) (smime-get-certfiles keyfile otherkeys))))) (defun smime-buffer-as-string-region (b e) "Return each line in region between B and E as a list of strings." (save-excursion (goto-char b) (let (res) (while (< (point) e) (let ((str (buffer-substring (point) (point-at-eol)))) (unless (string= "" str) (push str res))) (forward-line)) res))) ;; Find certificates (defun smime-mail-to-domain (mailaddr) (if (string-match "@" mailaddr) (replace-match "." 'fixedcase 'literal mailaddr) mailaddr)) (defun smime-cert-by-dns (mail) "Find certificate via DNS for address MAIL." (let* ((dig-dns-server smime-dns-server) (digbuf (dig-invoke (smime-mail-to-domain mail) "cert" nil nil "+vc")) (retbuf (generate-new-buffer (format "*certificate for %s*" mail))) (certrr (with-current-buffer digbuf (dig-extract-rr (smime-mail-to-domain mail) "cert"))) (cert (and certrr (dig-rr-get-pkix-cert certrr)))) (if cert (with-current-buffer retbuf (insert "-----BEGIN CERTIFICATE-----\n") (let ((i 0) (len (length cert))) (while (> (- len 64) i) (insert (substring cert i (+ i 64)) "\n") (setq i (+ i 64))) (insert (substring cert i len) "\n")) (insert "-----END CERTIFICATE-----\n")) (kill-buffer retbuf) (setq retbuf nil)) (kill-buffer digbuf) retbuf)) (declare-function ldap-search "ldap" (filter &optional host attributes attrsonly withdn)) (defun smime-cert-by-ldap-1 (mail host) "Get certificate for MAIL from the ldap server at HOST." (let ((ldapresult (funcall (if (featurep 'xemacs) (progn (require 'smime-ldap) 'smime-ldap-search) (progn (require 'ldap) 'ldap-search)) (concat "mail=" mail) host '("userCertificate") nil)) (retbuf (generate-new-buffer (format "*certificate for %s*" mail))) cert) (if (and (>= (length ldapresult) 1) (> (length (cadaar ldapresult)) 0)) (with-current-buffer retbuf ;; Certificates on LDAP servers _should_ be in DER format, ;; but there are some servers out there that distributes the ;; certificates in PEM format (with or without ;; header/footer) so we try to handle them anyway. (if (or (string= (substring (cadaar ldapresult) 0 27) "-----BEGIN CERTIFICATE-----") (string= (substring (cadaar ldapresult) 0 3) "MII")) (setq cert (smime-replace-in-string (cadaar ldapresult) (concat "\\(\n\\|\r\\|-----BEGIN CERTIFICATE-----\\|" "-----END CERTIFICATE-----\\)") "" t)) (setq cert (base64-encode-string (cadaar ldapresult) t))) (insert "-----BEGIN CERTIFICATE-----\n") (let ((i 0) (len (length cert))) (while (> (- len 64) i) (insert (substring cert i (+ i 64)) "\n") (setq i (+ i 64))) (insert (substring cert i len) "\n")) (insert "-----END CERTIFICATE-----\n")) (kill-buffer retbuf) (setq retbuf nil)) retbuf)) (defun smime-cert-by-ldap (mail) "Find certificate via LDAP for address MAIL." (if smime-ldap-host-list (catch 'certbuf (dolist (host smime-ldap-host-list) (let ((retbuf (smime-cert-by-ldap-1 mail host))) (when retbuf (throw 'certbuf retbuf))))))) ;; User interface. (defvar smime-buffer "*SMIME*") (defvar smime-mode-map (let ((map (make-sparse-keymap))) (suppress-keymap map) (define-key map "q" 'smime-exit) (define-key map "f" 'smime-certificate-info) map)) (autoload 'gnus-completing-read "gnus-util") (put 'smime-mode 'mode-class 'special) (define-derived-mode smime-mode fundamental-mode ;special-mode "SMIME" "Major mode for browsing, viewing and fetching certificates. All normal editing commands are switched off. \\<smime-mode-map> The following commands are available: \\{smime-mode-map}" (setq mode-line-process nil) (buffer-disable-undo) (setq truncate-lines t) (setq buffer-read-only t)) (defun smime-certificate-info (certfile) (interactive "fCertificate file: ") (let ((buffer (get-buffer-create (format "*certificate %s*" certfile)))) (switch-to-buffer buffer) (erase-buffer) (call-process smime-openssl-program nil buffer 'display "x509" "-in" (expand-file-name certfile) "-text") (fundamental-mode) (set-buffer-modified-p nil) (setq buffer-read-only t) (goto-char (point-min)))) (defun smime-draw-buffer () (with-current-buffer smime-buffer (let (buffer-read-only) (erase-buffer) (insert "\nYour keys:\n") (dolist (key smime-keys) (insert (format "\t\t%s: %s\n" (car key) (cadr key)))) (insert "\nTrusted Certificate Authorities:\n") (insert "\nKnown Certificates:\n")))) (defun smime () "Go to the SMIME buffer." (interactive) (unless (get-buffer smime-buffer) (with-current-buffer (get-buffer-create smime-buffer) (smime-mode))) (smime-draw-buffer) (switch-to-buffer smime-buffer)) (defun smime-exit () "Quit the S/MIME buffer." (interactive) (kill-buffer (current-buffer))) ;; Other functions (defun smime-get-key-by-email (email) (cadr (assoc email smime-keys))) (defun smime-get-key-with-certs-by-email (email) (cdr (assoc email smime-keys))) (provide 'smime) ;;; smime.el ends here
{ "pile_set_name": "Github" }
// // ExampleTableViewController.m // RBQFetchedResultsControllerExample // // Created by Adam Fish on 1/5/15. // Copyright (c) 2015 Roobiq. All rights reserved. // #import "ExampleTableViewController.h" #import "TestObject.h" #import <RBQFetchedResultsController/RBQFRC.h> #import <Realm/Realm.h> id NULL_IF_NIL(id x) {return x ? x : NSNull.null;} @interface ExampleTableViewController () <RBQFetchedResultsControllerDelegate> @property (strong, nonatomic) RBQFetchedResultsController *fetchedResultsController; @end @implementation ExampleTableViewController - (void)viewDidLoad { [super viewDidLoad]; RLMRealm *realm = [RLMRealm defaultRealm]; [realm beginWriteTransaction]; [realm deleteAllObjects]; for (NSUInteger i = 0; i < 1000; i++) { NSString *title = [NSString stringWithFormat:@"Cell %lu", (unsigned long)i]; TestObject *object = [TestObject testObjectWithTitle:title sortIndex:i inTable:YES]; if (i < 10) { object.sectionName = @"First Section"; } else { object.sectionName = @"Second Section"; } [realm addObject:object]; } [realm commitWriteTransaction]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"inTable = YES"]; RBQFetchRequest *fetchRequest = [RBQFetchRequest fetchRequestWithEntityName:@"TestObject" inRealm:realm predicate:predicate]; RLMSortDescriptor *sortDescriptor = [RLMSortDescriptor sortDescriptorWithProperty:@"sortIndex" ascending:YES]; RLMSortDescriptor *sortDescriptorSection = [RLMSortDescriptor sortDescriptorWithProperty:@"sectionName" ascending:YES]; fetchRequest.sortDescriptors = @[sortDescriptorSection,sortDescriptor]; self.fetchedResultsController = [[RBQFetchedResultsController alloc] initWithFetchRequest:fetchRequest sectionNameKeyPath:@"sectionName" cacheName:@"testCache"]; self.fetchedResultsController.delegate = self; [self.fetchedResultsController performFetch]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return [self.fetchedResultsController numberOfSections]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.fetchedResultsController numberOfRowsForSectionIndex:section]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [self.fetchedResultsController titleForHeaderInSection:section]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"customCell" forIndexPath:indexPath]; // Configure the cell... TestObject *objectForCell = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.textLabel.text = objectForCell.title; return cell; } // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } // Override to support editing the table view. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source [self deleteObjectAtIndexPath:indexPath]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view [self insertObject]; } } #pragma mark - <RBQFetchedResultsControllerDelegate> - (void)controllerWillChangeContent:(RBQFetchedResultsController *)controller { NSLog(@"Beginning updates"); [self.tableView beginUpdates]; } - (void)controller:(RBQFetchedResultsController *)controller didChangeObject:(RBQSafeRealmObject *)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { UITableView *tableView = self.tableView; switch(type) { case NSFetchedResultsChangeInsert: { NSLog(@"Inserting at path %@", newIndexPath); [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; break; } case NSFetchedResultsChangeDelete: { NSLog(@"Deleting at path %ld", (long)indexPath.row); [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; break; } case NSFetchedResultsChangeUpdate: NSLog(@"Updating at path %@", indexPath); if ([[tableView indexPathsForVisibleRows] containsObject:indexPath]) { [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; } break; case NSFetchedResultsChangeMove: NSLog(@"Moving from path %@ to %@", indexPath, newIndexPath); [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; break; } } - (void)controller:(RBQFetchedResultsController *)controller didChangeSection:(RBQFetchedResultsSectionInfo *)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type { UITableView *tableView = self.tableView; if (type == NSFetchedResultsChangeInsert) { NSLog(@"Inserting section at %lu", (unsigned long)sectionIndex); NSIndexSet *insertedSection = [NSIndexSet indexSetWithIndex:sectionIndex]; [tableView insertSections:insertedSection withRowAnimation:UITableViewRowAnimationFade]; } else if (type == NSFetchedResultsChangeDelete) { NSLog(@"Deleting section at %lu", (unsigned long)sectionIndex); NSIndexSet *deletedSection = [NSIndexSet indexSetWithIndex:sectionIndex]; [tableView deleteSections:deletedSection withRowAnimation:UITableViewRowAnimationFade]; } } - (void)controllerDidChangeContent:(RBQFetchedResultsController *)controller { NSLog(@"Ending updates"); NSLog(@"Fetched %ld Items After Change", (unsigned long)self.fetchedResultsController.fetchedObjects.count); @try { [self.tableView endUpdates]; } @catch (NSException *ex) { NSLog(@"RBQFecthResultsTVC caught exception updating table view: %@. Falling back to reload.", ex); [self.fetchedResultsController reset]; [self.tableView reloadData]; } } #pragma mark - UIBarButton Actions - (IBAction)didClickDeleteButton:(UIBarButtonItem *)sender { // Delete the object in the first row // NSIndexPath *firstObjectIndexPath = [NSIndexPath indexPathForRow:0 inSection:0]; // [self deleteObjectAtIndexPath:firstObjectIndexPath]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ NSLog(@"DID BEGIN DELETE"); // Test deleting a section (comment out above to test) RLMResults *objectInFirstSection = [TestObject objectsWhere:@"%K == %@",@"sectionName",@"First Section"]; RLMRealm *realm = [RLMRealm defaultRealm]; [realm beginWriteTransaction]; [realm deleteObjects:objectInFirstSection]; [realm commitWriteTransaction]; NSLog(@"DID END DELETE"); }); } - (IBAction)didClickInsertButton:(UIBarButtonItem *)sender { NSLog(@"DID BEGIN INSERT"); NSLog(@"Fetched %ld Items Before Insert", (unsigned long)self.fetchedResultsController.fetchedObjects.count); [self insertObject]; NSLog(@"DID END INSERT"); } #pragma mark - Private - (void)deleteObjectAtIndexPath:(NSIndexPath *)indexPath { TestObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath]; if (!object) { return; } RLMRealm *realm = [RLMRealm defaultRealm]; [realm beginWriteTransaction]; [realm deleteObject:object]; [realm commitWriteTransaction]; } - (void)insertObject { RLMRealm *realm = [RLMRealm defaultRealm]; NSIndexPath *indexPathFirstRow = [NSIndexPath indexPathForRow:0 inSection:0]; TestObject *object = [self.fetchedResultsController objectAtIndexPath:indexPathFirstRow]; if (object.sortIndex > 0) { [realm beginWriteTransaction]; NSInteger sortIndex = object.sortIndex - 1; NSString *title = [NSString stringWithFormat:@"Cell %lu", (unsigned long)sortIndex]; TestObject *newObject = [TestObject objectInRealm:realm forPrimaryKey:[NSString stringWithFormat:@"%@%ld",title, (long)sortIndex]]; if (!newObject) { newObject = [[TestObject alloc] init]; newObject.title = title; newObject.sortIndex = sortIndex; newObject.sectionName = @"First Section"; newObject.key = [NSString stringWithFormat:@"%@%ld",title, (long)sortIndex]; newObject.inTable = YES; [realm addObject:newObject]; } else { newObject.inTable = YES; } [realm commitWriteTransaction]; } // Test Moves else { [realm beginWriteTransaction]; NSIndexPath *indexPathFifthRow = [NSIndexPath indexPathForRow:5 inSection:0]; NSIndexPath *indexPathThirdRow = [NSIndexPath indexPathForRow:3 inSection:0]; NSIndexPath *indexPathSixthRow = [NSIndexPath indexPathForRow:6 inSection:0]; NSIndexPath *indexPathFirstRow = [NSIndexPath indexPathForRow:0 inSection:0]; TestObject *firstObject = [self.fetchedResultsController objectAtIndexPath:indexPathFirstRow]; TestObject *thirdObject = [self.fetchedResultsController objectAtIndexPath:indexPathThirdRow]; TestObject *fifthObject = [self.fetchedResultsController objectAtIndexPath:indexPathFifthRow]; TestObject *sixthObject = [self.fetchedResultsController objectAtIndexPath:indexPathSixthRow]; RLMResults *ninthObject = [TestObject objectsInRealm:realm where:@"%K == %@",@"title",@"Cell 9"]; fifthObject.sortIndex += 1; sixthObject.sortIndex -= 1; firstObject.inTable = NO; thirdObject.title = @"Testing Move And Update"; if (ninthObject.firstObject) { TestObject *object = ninthObject.firstObject; if ([object.sectionName isEqualToString:@"First Section"]) { object.sectionName = @"Second Section"; } else { object.sectionName = @"First Section"; } } //Test an inserted section that's not first // TestObject *extraObjectInSection = [TestObject testObjectWithTitle:@"Test Section" sortIndex:3 inTable:YES]; // extraObjectInSection.sectionName = @"Middle Section"; // [realm addObject:extraObjectInSection]; // // [[RBQRealmNotificationManager defaultManager] didAddObjects:@[extraObjectInSection] // willDeleteObjects:nil // didChangeObjects:@[NULL_IF_NIL(fifthObject), // NULL_IF_NIL(sixthObject), // NULL_IF_NIL(firstObject), // NULL_IF_NIL(thirdObject)]]; [realm commitWriteTransaction]; } } @end
{ "pile_set_name": "Github" }
namespace Easy.Common.Extensions { using System; /// <summary> /// Extensions for DateTime /// </summary> public static class DateTimeExtensions { /// <summary> /// Epoch represented as DateTime /// </summary> internal static readonly DateTime Epoch; static DateTimeExtensions() => Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); /// <summary> /// Converts a given <see cref="DateTime"/> to milliseconds from Epoch. /// </summary> /// <param name="dateTime">A given <see cref="DateTime"/></param> /// <returns>Milliseconds since Epoch</returns> public static long ToEpochMilliseconds(this DateTime dateTime) => (long)dateTime.ToUniversalTime().Subtract(Epoch).TotalMilliseconds; /// <summary> /// Converts a given <see cref="DateTime"/> to seconds from Epoch. /// </summary> /// <param name="dateTime">A given <see cref="DateTime"/></param> /// <returns>The Unix time stamp</returns> public static long ToEpochSeconds(this DateTime dateTime) => dateTime.ToEpochMilliseconds() / 1000; /// <summary> /// Checks the given date is between the two provided dates /// </summary> public static bool IsBetween(this DateTime date, DateTime startDate, DateTime endDate, bool compareTime = false) => compareTime ? date >= startDate && date <= endDate : date.Date >= startDate.Date && date.Date <= endDate.Date; /// <summary> /// Returns whether the given date is the last day of the month /// </summary> public static bool IsLastDayOfTheMonth(this DateTime dateTime) => dateTime == new DateTime(dateTime.Year, dateTime.Month, 1).AddMonths(1).AddDays(-1); /// <summary> /// Returns whether the given date falls in a weekend /// </summary> public static bool IsWeekend(this DateTime value) => value.DayOfWeek == DayOfWeek.Sunday || value.DayOfWeek == DayOfWeek.Saturday; /// <summary> /// Determines if a given year is a LeapYear or not. /// </summary> public static bool IsLeapYear(this DateTime value) => DateTime.DaysInMonth(value.Year, 2) == 29; /// <summary> /// Returns the age based on <paramref name="birthDay"/>. /// </summary> /// <param name="birthDay">The birthday for which age should be calculated</param> public static int Age(this DateTime birthDay) { var today = DateTime.Today; var age = today.Year - birthDay.Year; if (birthDay > today.AddYears(-age)) { age--; } return age; } /// <summary> /// Convert DateTime to Shamsi Date (YYYY/MM/DD) /// </summary> public static string ToShamsiDateYmd(this DateTime date) { var persianCalendar = new System.Globalization.PersianCalendar(); var intYear = persianCalendar.GetYear(date); var intMonth = persianCalendar.GetMonth(date); var intDay = persianCalendar.GetDayOfMonth(date); return intYear.ToString() + "/" + intMonth.ToString() + "/" + intDay.ToString(); } /// <summary> /// Convert DateTime to Shamsi Date (DD/MM/YYYY) /// </summary> public static string ToShamsiDateDmy(this DateTime date) { var persianCalendar = new System.Globalization.PersianCalendar(); var intYear = persianCalendar.GetYear(date); var intMonth = persianCalendar.GetMonth(date); var intDay = persianCalendar.GetDayOfMonth(date); return intDay.ToString() + "/" + intMonth.ToString() + "/" + intYear.ToString(); } /// <summary> /// Convert DateTime to Shamsi String /// </summary> public static string ToShamsiDate(this DateTime date) { var persianCalendar = new System.Globalization.PersianCalendar(); var intYear = persianCalendar.GetYear(date); var intMonth = persianCalendar.GetMonth(date); var intDayOfMonth = persianCalendar.GetDayOfMonth(date); var enDayOfWeek = persianCalendar.GetDayOfWeek(date); string strMonthName, strDayName; switch (intMonth) { case 1: strMonthName = "فروردین"; break; case 2: strMonthName = "اردیبهشت"; break; case 3: strMonthName = "خرداد"; break; case 4: strMonthName = "تیر"; break; case 5: strMonthName = "مرداد"; break; case 6: strMonthName = "شهریور"; break; case 7: strMonthName = "مهر"; break; case 8: strMonthName = "آبان"; break; case 9: strMonthName = "آذر"; break; case 10: strMonthName = "دی"; break; case 11: strMonthName = "بهمن"; break; case 12: strMonthName = "اسفند"; break; default: strMonthName = ""; break; } switch (enDayOfWeek) { case DayOfWeek.Friday: strDayName = "جمعه"; break; case DayOfWeek.Monday: strDayName = "دوشنبه"; break; case DayOfWeek.Saturday: strDayName = "شنبه"; break; case DayOfWeek.Sunday: strDayName = "یکشنبه"; break; case DayOfWeek.Thursday: strDayName = "پنجشنبه"; break; case DayOfWeek.Tuesday: strDayName = "سه شنبه"; break; case DayOfWeek.Wednesday: strDayName = "چهارشنبه"; break; default: strDayName = ""; break; } return $"{strDayName} {intDayOfMonth.ToString()} {strMonthName} {intYear.ToString()}"; } } }
{ "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. namespace Microsoft.CodeAnalysis.EditAndContinue { internal enum ProjectReadOnlyReason { /// <summary> /// Project module was successfully loaded into the debuggee process when edit session started and is editable. /// </summary> None, /// <summary> /// Project hasn't been built at the time debugging session started (or the binary is unreadable). /// </summary> MetadataNotAvailable, /// <summary> /// One of the following reasons /// - Module wasn't loaded into the debuggee process when edit session started. /// - The debugger has been attached to an already running process. /// - The code being debugged was optimized at build or runtime. /// - The assembly being debugged is loaded as domain-neutral. /// - The assembly being debugged is runtime-generated (Reflection.Emit). /// - IntelliTrace is enabled. /// </summary> NotLoaded, } }
{ "pile_set_name": "Github" }
/* * Copyright (c) 2019-2020 Free Software Foundation, Inc. * * This file is part of Wget * * Wget 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. * * Wget 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 Wget If not, see <https://www.gnu.org/licenses/>. * * * Testing --ignore-length * * */ #include <config.h> #include <stdlib.h> // exit() #include "libtest.h" int main(void) { wget_test_url_t urls[]={ { .name = "/index.html", .code = "200 Dontcare", .body = "<html><head><title>Main Page</title><body><p>A link to a" \ " <A href=\"http://localhost:{{port}}/secondpage.html\">second page</a>." \ " <a href=\"/subdir1/subpage1.html?query&param#frag\">page in subdir1</a>." \ " <a href=\"./subdir1/subpage2.html\">page in subdir1</a>." \ "</p></body></html>", .headers = { "Content-Type: text/html", "Content-Length: 140", } }, { .name = "/secondpage.html", .code = "200 Dontcare", .body = "<html><head><title>Main Page</title><base href=\"/subdir2/\"></head><body><p>A link to a" \ " <A href=\"../secondpage.html\">second page</a>." \ " <a href=\"subpage1.html?query&param#frag\">page in subdir2</a>." \ " <a href=\"./subpage2.html\">page in subdir2</a>." \ "</p></body></html>", .headers = { "Content-Type: text/html", "Content-Length: 300", } }, }; // functions won't come back if an error occurs wget_test_start_server( WGET_TEST_RESPONSE_URLS, &urls, countof(urls), WGET_TEST_FEATURE_MHD, 0); // with --ignore-length no warning should pop up in log and return should be 0 // without --ignore-length return 10 wget_test( WGET_TEST_OPTIONS, "--ignore-length", WGET_TEST_REQUEST_URLS, "index.html", "secondpage.html", NULL, WGET_TEST_EXPECTED_ERROR_CODE, 0, WGET_TEST_EXPECTED_FILES, &(wget_test_file_t []) { { urls[0].name + 1, urls[0].body }, { urls[1].name + 1, urls[1].body }, { NULL } }, 0); exit(EXIT_SUCCESS); }
{ "pile_set_name": "Github" }
/* ---------------------------------------------------------------------------- * ATMEL Microcontroller Software Support * ---------------------------------------------------------------------------- * Copyright (c) 2008, Atmel Corporation * 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 of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * Atmel's name may not 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 * HOLDER 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. * ---------------------------------------------------------------------------- */ //------------------------------------------------------------------------------ /// \unit /// /// !Purpose /// /// Implementation of several stdio.h methods, such as printf(), sprintf() and /// so on. This reduces the memory footprint of the binary when using those /// methods, compared to the libc implementation. /// /// !Usage /// /// Adds stdio.c to the list of file to compile for the project. This will /// automatically replace libc methods by the custom ones. //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // Headers //------------------------------------------------------------------------------ #include <stdio.h> #include <stdarg.h> //------------------------------------------------------------------------------ // Local Definitions //------------------------------------------------------------------------------ // Maximum string size allowed (in bytes). #define MAX_STRING_SIZE 100 //------------------------------------------------------------------------------ // Global Variables //------------------------------------------------------------------------------ // Required for proper compilation. struct _reent r = {0, (FILE *) 0, (FILE *) 1, (FILE *) 0}; struct _reent *_impure_ptr = &r; //------------------------------------------------------------------------------ // Local Functions //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ // Writes a character inside the given string. Returns 1. // \param pStr Storage string. // \param c Character to write. //------------------------------------------------------------------------------ signed int PutChar(char *pStr, char c) { *pStr = c; return 1; } //------------------------------------------------------------------------------ // Writes a string inside the given string. // Returns the size of the written // string. // \param pStr Storage string. // \param pSource Source string. //------------------------------------------------------------------------------ signed int PutString(char *pStr, const char *pSource) { signed int num = 0; while (*pSource != 0) { *pStr++ = *pSource++; num++; } return num; } //------------------------------------------------------------------------------ // Writes an unsigned int inside the given string, using the provided fill & // width parameters. // Returns the size in characters of the written integer. // \param pStr Storage string. // \param fill Fill character. // \param width Minimum integer width. // \param value Integer value. //------------------------------------------------------------------------------ signed int PutUnsignedInt( char *pStr, char fill, signed int width, unsigned int value) { signed int num = 0; // Take current digit into account when calculating width width--; // Recursively write upper digits if ((value / 10) > 0) { num = PutUnsignedInt(pStr, fill, width, value / 10); pStr += num; } // Write filler characters else { while (width > 0) { PutChar(pStr, fill); pStr++; num++; width--; } } // Write lower digit num += PutChar(pStr, (value % 10) + '0'); return num; } //------------------------------------------------------------------------------ // Writes a signed int inside the given string, using the provided fill & width // parameters. // Returns the size of the written integer. // \param pStr Storage string. // \param fill Fill character. // \param width Minimum integer width. // \param value Signed integer value. //------------------------------------------------------------------------------ signed int PutSignedInt( char *pStr, char fill, signed int width, signed int value) { signed int num = 0; unsigned int absolute; // Compute absolute value if (value < 0) { absolute = -value; } else { absolute = value; } // Take current digit into account when calculating width width--; // Recursively write upper digits if ((absolute / 10) > 0) { if (value < 0) { num = PutSignedInt(pStr, fill, width, -(absolute / 10)); } else { num = PutSignedInt(pStr, fill, width, absolute / 10); } pStr += num; } else { // Reserve space for sign if (value < 0) { width--; } // Write filler characters while (width > 0) { PutChar(pStr, fill); pStr++; num++; width--; } // Write sign if (value < 0) { num += PutChar(pStr, '-'); pStr++; } } // Write lower digit num += PutChar(pStr, (absolute % 10) + '0'); return num; } //------------------------------------------------------------------------------ // Writes an hexadecimal value into a string, using the given fill, width & // capital parameters. // Returns the number of char written. // \param pStr Storage string. // \param fill Fill character. // \param width Minimum integer width. // \param maj Indicates if the letters must be printed in lower- or upper-case. // \param value Hexadecimal value. //------------------------------------------------------------------------------ signed int PutHexa( char *pStr, char fill, signed int width, unsigned char maj, unsigned int value) { signed int num = 0; // Decrement width width--; // Recursively output upper digits if ((value >> 4) > 0) { num += PutHexa(pStr, fill, width, maj, value >> 4); pStr += num; } // Write filler chars else { while (width > 0) { PutChar(pStr, fill); pStr++; num++; width--; } } // Write current digit if ((value & 0xF) < 10) { PutChar(pStr, (value & 0xF) + '0'); } else if (maj) { PutChar(pStr, (value & 0xF) - 10 + 'A'); } else { PutChar(pStr, (value & 0xF) - 10 + 'a'); } num++; return num; } //------------------------------------------------------------------------------ // Global Functions //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ /// Stores the result of a formatted string into another string. Format /// arguments are given in a va_list instance. /// Return the number of characters written. /// \param pStr Destination string. /// \param length Length of Destination string. /// \param pFormat Format string. /// \param ap Argument list. //------------------------------------------------------------------------------ signed int vsnprintf(char *pStr, size_t length, const char *pFormat, va_list ap) { char fill; unsigned char width; signed int num = 0; signed int size = 0; // Clear the string if (pStr) { *pStr = 0; } // Phase string while (*pFormat != 0 && size < length) { // Normal character if (*pFormat != '%') { *pStr++ = *pFormat++; size++; } // Escaped '%' else if (*(pFormat+1) == '%') { *pStr++ = '%'; pFormat += 2; size++; } // Token delimiter else { fill = ' '; width = 0; pFormat++; // Parse filler if (*pFormat == '0') { fill = '0'; pFormat++; } // Parse width while ((*pFormat >= '0') && (*pFormat <= '9')) { width = (width*10) + *pFormat-'0'; pFormat++; } // Check if there is enough space if (size + width > length) { width = length - size; } // Parse type switch (*pFormat) { case 'd': case 'i': num = PutSignedInt(pStr, fill, width, va_arg(ap, signed int)); break; case 'u': num = PutUnsignedInt(pStr, fill, width, va_arg(ap, unsigned int)); break; case 'x': num = PutHexa(pStr, fill, width, 0, va_arg(ap, unsigned int)); break; case 'X': num = PutHexa(pStr, fill, width, 1, va_arg(ap, unsigned int)); break; case 's': num = PutString(pStr, va_arg(ap, char *)); break; case 'c': num = PutChar(pStr, va_arg(ap, unsigned int)); break; default: return EOF; } pFormat++; pStr += num; size += num; } } // NULL-terminated (final \0 is not counted) if (size < length) { *pStr = 0; } else { *(--pStr) = 0; size--; } return size; } //------------------------------------------------------------------------------ /// Stores the result of a formatted string into another string. Format /// arguments are given in a va_list instance. /// Return the number of characters written. /// \param pString Destination string. /// \param length Length of Destination string. /// \param pFormat Format string. /// \param ... Other arguments //------------------------------------------------------------------------------ signed int snprintf(char *pString, size_t length, const char *pFormat, ...) { va_list ap; signed int rc; va_start(ap, pFormat); rc = vsnprintf(pString, length, pFormat, ap); va_end(ap); return rc; } //------------------------------------------------------------------------------ /// Stores the result of a formatted string into another string. Format /// arguments are given in a va_list instance. /// Return the number of characters written. /// \param pString Destination string. /// \param pFormat Format string. /// \param ap Argument list. //------------------------------------------------------------------------------ signed int vsprintf(char *pString, const char *pFormat, va_list ap) { return vsnprintf(pString, MAX_STRING_SIZE, pFormat, ap); } //------------------------------------------------------------------------------ /// Outputs a formatted string on the given stream. Format arguments are given /// in a va_list instance. /// \param pStream Output stream. /// \param pFormat Format string /// \param ap Argument list. //------------------------------------------------------------------------------ signed int vfprintf(FILE *pStream, const char *pFormat, va_list ap) { char pStr[MAX_STRING_SIZE]; char pError[] = "stdio.c: increase MAX_STRING_SIZE\n\r"; // Write formatted string in buffer if (vsprintf(pStr, pFormat, ap) >= MAX_STRING_SIZE) { fputs(pError, stderr); while (1); // Increase MAX_STRING_SIZE } // Display string return fputs(pStr, pStream); } //------------------------------------------------------------------------------ /// Outputs a formatted string on the DBGU stream. Format arguments are given /// in a va_list instance. /// \param pFormat Format string /// \param ap Argument list. //------------------------------------------------------------------------------ signed int vprintf(const char *pFormat, va_list ap) { return vfprintf(stdout, pFormat, ap); } //------------------------------------------------------------------------------ /// Outputs a formatted string on the given stream, using a variable number of /// arguments. /// \param pStream Output stream. /// \param pFormat Format string. //------------------------------------------------------------------------------ signed int fprintf(FILE *pStream, const char *pFormat, ...) { va_list ap; signed int result; // Forward call to vfprintf va_start(ap, pFormat); result = vfprintf(pStream, pFormat, ap); va_end(ap); return result; } //------------------------------------------------------------------------------ /// Outputs a formatted string on the DBGU stream, using a variable number of /// arguments. /// \param pFormat Format string. //------------------------------------------------------------------------------ signed int printf(const char *pFormat, ...) { va_list ap; signed int result; // Forward call to vprintf va_start(ap, pFormat); result = vprintf(pFormat, ap); va_end(ap); return result; } //------------------------------------------------------------------------------ /// Writes a formatted string inside another string. /// \param pStr Storage string. /// \param pFormat Format string. //------------------------------------------------------------------------------ signed int sprintf(char *pStr, const char *pFormat, ...) { va_list ap; signed int result; // Forward call to vsprintf va_start(ap, pFormat); result = vsprintf(pStr, pFormat, ap); va_end(ap); return result; } //------------------------------------------------------------------------------ /// Outputs a string on stdout. /// \param pStr String to output. //------------------------------------------------------------------------------ signed int puts(const char *pStr) { return fputs(pStr, stdout); }
{ "pile_set_name": "Github" }
/* * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.security.x509; import java.io.IOException; import java.io.OutputStream; import java.util.Enumeration; import sun.security.util.*; /** * This class represents the Inhibit Any-Policy Extension. * * <p>The inhibit any-policy extension can be used in certificates issued * to CAs. The inhibit any-policy indicates that the special any-policy * OID, with the value {2 5 29 32 0}, is not considered an explicit * match for other certificate policies. The value indicates the number * of additional certificates that may appear in the path before any- * policy is no longer permitted. For example, a value of one indicates * that any-policy may be processed in certificates issued by the sub- * ject of this certificate, but not in additional certificates in the * path. * <p> * This extension MUST be critical. * <p> * The ASN.1 syntax for this extension is: * <pre>{@code * id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } * * InhibitAnyPolicy ::= SkipCerts * * SkipCerts ::= INTEGER (0..MAX) * }</pre> * @author Anne Anderson * @see CertAttrSet * @see Extension */ public class InhibitAnyPolicyExtension extends Extension implements CertAttrSet<String> { private static final Debug debug = Debug.getInstance("certpath"); /** * Identifier for this attribute, to be used with the * get, set, delete methods of Certificate, x509 type. */ public static final String IDENT = "x509.info.extensions.InhibitAnyPolicy"; /** * Object identifier for "any-policy" */ public static ObjectIdentifier AnyPolicy_Id = ObjectIdentifier.of(KnownOIDs.CE_CERT_POLICIES_ANY); /** * Attribute names. */ public static final String NAME = "InhibitAnyPolicy"; public static final String SKIP_CERTS = "skip_certs"; // Private data members private int skipCerts = Integer.MAX_VALUE; // Encode this extension value private void encodeThis() throws IOException { DerOutputStream out = new DerOutputStream(); out.putInteger(skipCerts); this.extensionValue = out.toByteArray(); } /** * Default constructor for this object. * * @param skipCerts specifies the depth of the certification path. * Use value of -1 to request unlimited depth. */ public InhibitAnyPolicyExtension(int skipCerts) throws IOException { if (skipCerts < -1) throw new IOException("Invalid value for skipCerts"); if (skipCerts == -1) this.skipCerts = Integer.MAX_VALUE; else this.skipCerts = skipCerts; this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id; critical = true; encodeThis(); } /** * Create the extension from the passed DER encoded value of the same. * * @param critical criticality flag to use. Must be true for this * extension. * @param value a byte array holding the DER-encoded extension value. * @exception ClassCastException if value is not an array of bytes * @exception IOException on error. */ public InhibitAnyPolicyExtension(Boolean critical, Object value) throws IOException { this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id; if (!critical.booleanValue()) throw new IOException("Criticality cannot be false for " + "InhibitAnyPolicy"); this.critical = critical.booleanValue(); this.extensionValue = (byte[]) value; DerValue val = new DerValue(this.extensionValue); if (val.tag != DerValue.tag_Integer) throw new IOException("Invalid encoding of InhibitAnyPolicy: " + "data not integer"); if (val.data == null) throw new IOException("Invalid encoding of InhibitAnyPolicy: " + "null data"); int skipCertsValue = val.getInteger(); if (skipCertsValue < -1) throw new IOException("Invalid value for skipCerts"); if (skipCertsValue == -1) { this.skipCerts = Integer.MAX_VALUE; } else { this.skipCerts = skipCertsValue; } } /** * Return user readable form of extension. */ public String toString() { String s = super.toString() + "InhibitAnyPolicy: " + skipCerts + "\n"; return s; } /** * Encode this extension value to the output stream. * * @param out the DerOutputStream to encode the extension to. */ public void encode(OutputStream out) throws IOException { DerOutputStream tmp = new DerOutputStream(); if (extensionValue == null) { this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id; critical = true; encodeThis(); } super.encode(tmp); out.write(tmp.toByteArray()); } /** * Set the attribute value. * * @param name name of attribute to set. Must be SKIP_CERTS. * @param obj value to which attribute is to be set. Must be Integer * type. * @throws IOException on error */ public void set(String name, Object obj) throws IOException { if (name.equalsIgnoreCase(SKIP_CERTS)) { if (!(obj instanceof Integer)) throw new IOException("Attribute value should be of type Integer."); int skipCertsValue = ((Integer)obj).intValue(); if (skipCertsValue < -1) throw new IOException("Invalid value for skipCerts"); if (skipCertsValue == -1) { skipCerts = Integer.MAX_VALUE; } else { skipCerts = skipCertsValue; } } else throw new IOException("Attribute name not recognized by " + "CertAttrSet:InhibitAnyPolicy."); encodeThis(); } /** * Get the attribute value. * * @param name name of attribute to get. Must be SKIP_CERTS. * @return value of the attribute. In this case it will be of type * Integer. * @throws IOException on error */ public Integer get(String name) throws IOException { if (name.equalsIgnoreCase(SKIP_CERTS)) return (skipCerts); else throw new IOException("Attribute name not recognized by " + "CertAttrSet:InhibitAnyPolicy."); } /** * Delete the attribute value. * * @param name name of attribute to delete. Must be SKIP_CERTS. * @throws IOException on error. In this case, IOException will always be * thrown, because the only attribute, SKIP_CERTS, is * required. */ public void delete(String name) throws IOException { if (name.equalsIgnoreCase(SKIP_CERTS)) throw new IOException("Attribute " + SKIP_CERTS + " may not be deleted."); else throw new IOException("Attribute name not recognized by " + "CertAttrSet:InhibitAnyPolicy."); } /** * Return an enumeration of names of attributes existing within this * attribute. * * @return enumeration of elements */ public Enumeration<String> getElements() { AttributeNameEnumeration elements = new AttributeNameEnumeration(); elements.addElement(SKIP_CERTS); return (elements.elements()); } /** * Return the name of this attribute. * * @return name of attribute. */ public String getName() { return (NAME); } }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file original="extensions/agent/out/dialogs/scheduleDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="scheduleDialog.newSchedule"> <source xml:lang="en">New Schedule</source> <target state="translated">Nuova pianificazione</target> </trans-unit> <trans-unit id="scheduleDialog.ok"> <source xml:lang="en">OK</source> <target state="translated">OK</target> </trans-unit> <trans-unit id="scheduleDialog.cancel"> <source xml:lang="en">Cancel</source> <target state="translated">Annulla</target> </trans-unit> <trans-unit id="scheduleDialog.scheduleName"> <source xml:lang="en">Schedule Name</source> <target state="translated">Nome della pianificazione</target> </trans-unit> <trans-unit id="scheduleDialog.schedules"> <source xml:lang="en">Schedules</source> <target state="translated">Pianificazioni</target> </trans-unit> </body> </file> <file original="extensions/agent/out/dialogs/proxyDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="createProxy.createProxy"> <source xml:lang="en">Create Proxy</source> <target state="translated">Crea proxy</target> </trans-unit> <trans-unit id="createProxy.editProxy"> <source xml:lang="en">Edit Proxy</source> <target state="translated">Modifica proxy</target> </trans-unit> <trans-unit id="createProxy.General"> <source xml:lang="en">General</source> <target state="translated">Generale</target> </trans-unit> <trans-unit id="createProxy.ProxyName"> <source xml:lang="en">Proxy name</source> <target state="translated">Nome del proxy</target> </trans-unit> <trans-unit id="createProxy.CredentialName"> <source xml:lang="en">Credential name</source> <target state="translated">Nome della credenziale</target> </trans-unit> <trans-unit id="createProxy.Description"> <source xml:lang="en">Description</source> <target state="translated">Descrizione</target> </trans-unit> <trans-unit id="createProxy.SubsystemName"> <source xml:lang="en">Subsystem</source> <target state="translated">Sottosistema</target> </trans-unit> <trans-unit id="createProxy.OperatingSystem"> <source xml:lang="en">Operating system (CmdExec)</source> <target state="translated">Sistema operativo (CmdExec)</target> </trans-unit> <trans-unit id="createProxy.ReplicationSnapshot"> <source xml:lang="en">Replication Snapshot</source> <target state="translated">Snapshot repliche</target> </trans-unit> <trans-unit id="createProxy.ReplicationTransactionLog"> <source xml:lang="en">Replication Transaction-Log Reader</source> <target state="translated">Lettura log delle transazioni di replica</target> </trans-unit> <trans-unit id="createProxy.ReplicationDistributor"> <source xml:lang="en">Replication Distributor</source> <target state="translated">Database di distribuzione repliche</target> </trans-unit> <trans-unit id="createProxy.ReplicationMerge"> <source xml:lang="en">Replication Merge</source> <target state="translated">Merge repliche</target> </trans-unit> <trans-unit id="createProxy.ReplicationQueueReader"> <source xml:lang="en">Replication Queue Reader</source> <target state="translated">Lettore coda di repliche</target> </trans-unit> <trans-unit id="createProxy.SSASQueryLabel"> <source xml:lang="en">SQL Server Analysis Services Query</source> <target state="translated">Query di SQL Server Analysis Services</target> </trans-unit> <trans-unit id="createProxy.SSASCommandLabel"> <source xml:lang="en">SQL Server Analysis Services Command</source> <target state="translated">Comando di SQL Server Analysis Services</target> </trans-unit> <trans-unit id="createProxy.SSISPackage"> <source xml:lang="en">SQL Server Integration Services Package</source> <target state="translated">Pacchetto SQL Server Integration Services</target> </trans-unit> <trans-unit id="createProxy.PowerShell"> <source xml:lang="en">PowerShell</source> <target state="translated">PowerShell</target> </trans-unit> <trans-unit id="createProxy.subSystemHeading"> <source xml:lang="en">Active to the following subsytems</source> <target state="translated">Attivo nei sottosistemi seguenti</target> </trans-unit> </body> </file> <file original="extensions/agent/out/dialogs/pickScheduleDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="pickSchedule.jobSchedules"> <source xml:lang="en">Job Schedules</source> <target state="translated">Pianificazioni processi</target> </trans-unit> <trans-unit id="pickSchedule.ok"> <source xml:lang="en">OK</source> <target state="translated">OK</target> </trans-unit> <trans-unit id="pickSchedule.cancel"> <source xml:lang="en">Cancel</source> <target state="translated">Annulla</target> </trans-unit> <trans-unit id="pickSchedule.availableSchedules"> <source xml:lang="en">Available Schedules:</source> <target state="translated">Pianificazioni disponibili:</target> </trans-unit> <trans-unit id="pickSchedule.scheduleName"> <source xml:lang="en">Name</source> <target state="translated">Nome</target> </trans-unit> <trans-unit id="pickSchedule.scheduleID"> <source xml:lang="en">ID</source> <target state="translated">ID</target> </trans-unit> <trans-unit id="pickSchedule.description"> <source xml:lang="en">Description</source> <target state="translated">Descrizione</target> </trans-unit> </body> </file> <file original="extensions/agent/out/dialogs/operatorDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="createOperator.createOperator"> <source xml:lang="en">Create Operator</source> <target state="translated">Crea operatore</target> </trans-unit> <trans-unit id="createOperator.editOperator"> <source xml:lang="en">Edit Operator</source> <target state="translated">Modifica operatore</target> </trans-unit> <trans-unit id="createOperator.General"> <source xml:lang="en">General</source> <target state="translated">Generale</target> </trans-unit> <trans-unit id="createOperator.Notifications"> <source xml:lang="en">Notifications</source> <target state="translated">Notifiche</target> </trans-unit> <trans-unit id="createOperator.Name"> <source xml:lang="en">Name</source> <target state="translated">Nome</target> </trans-unit> <trans-unit id="createOperator.Enabled"> <source xml:lang="en">Enabled</source> <target state="translated">Abilitato</target> </trans-unit> <trans-unit id="createOperator.EmailName"> <source xml:lang="en">E-mail Name</source> <target state="translated">Indirizzo di posta elettronica</target> </trans-unit> <trans-unit id="createOperator.PagerEmailName"> <source xml:lang="en">Pager E-mail Name</source> <target state="translated">Indirizzo cercapersone</target> </trans-unit> <trans-unit id="createOperator.PagerMondayCheckBox"> <source xml:lang="en">Monday</source> <target state="translated">Lunedì</target> </trans-unit> <trans-unit id="createOperator.PagerTuesdayCheckBox"> <source xml:lang="en">Tuesday</source> <target state="translated">Martedì</target> </trans-unit> <trans-unit id="createOperator.PagerWednesdayCheckBox"> <source xml:lang="en">Wednesday</source> <target state="translated">Mercoledì</target> </trans-unit> <trans-unit id="createOperator.PagerThursdayCheckBox"> <source xml:lang="en">Thursday</source> <target state="translated">Giovedì</target> </trans-unit> <trans-unit id="createOperator.PagerFridayCheckBox"> <source xml:lang="en">Friday </source> <target state="translated">Venerdì</target> </trans-unit> <trans-unit id="createOperator.PagerSaturdayCheckBox"> <source xml:lang="en">Saturday</source> <target state="translated">Sabato</target> </trans-unit> <trans-unit id="createOperator.PagerSundayCheckBox"> <source xml:lang="en">Sunday</source> <target state="translated">Domenica</target> </trans-unit> <trans-unit id="createOperator.workdayBegin"> <source xml:lang="en">Workday begin</source> <target state="translated">Inizio della giornata lavorativa</target> </trans-unit> <trans-unit id="createOperator.workdayEnd"> <source xml:lang="en">Workday end</source> <target state="translated">Fine della giornata lavorativa</target> </trans-unit> <trans-unit id="createOperator.PagerDutySchedule"> <source xml:lang="en">Pager on duty schedule</source> <target state="translated">Pianificazione cercapersone per operatore in servizio</target> </trans-unit> <trans-unit id="createOperator.AlertListHeading"> <source xml:lang="en">Alert list</source> <target state="translated">Elenco avvisi</target> </trans-unit> <trans-unit id="createOperator.AlertNameColumnLabel"> <source xml:lang="en">Alert name</source> <target state="translated">Nome dell'avviso</target> </trans-unit> <trans-unit id="createOperator.AlertEmailColumnLabel"> <source xml:lang="en">E-mail</source> <target state="translated">Posta elettronica</target> </trans-unit> <trans-unit id="createOperator.AlertPagerColumnLabel"> <source xml:lang="en">Pager</source> <target state="translated">Cercapersone</target> </trans-unit> </body> </file> <file original="extensions/agent/out/dialogs/jobStepDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="jobStepDialog.fileBrowserTitle"> <source xml:lang="en">Locate Database Files - </source> <target state="translated">Trova file di database - </target> </trans-unit> <trans-unit id="jobStepDialog.ok"> <source xml:lang="en">OK</source> <target state="translated">OK</target> </trans-unit> <trans-unit id="jobStepDialog.cancel"> <source xml:lang="en">Cancel</source> <target state="translated">Annulla</target> </trans-unit> <trans-unit id="jobStepDialog.general"> <source xml:lang="en">General</source> <target state="translated">Generale</target> </trans-unit> <trans-unit id="jobStepDialog.advanced"> <source xml:lang="en">Advanced</source> <target state="translated">Avanzate</target> </trans-unit> <trans-unit id="jobStepDialog.open"> <source xml:lang="en">Open...</source> <target state="translated">Apri...</target> </trans-unit> <trans-unit id="jobStepDialog.parse"> <source xml:lang="en">Parse</source> <target state="translated">Analizza</target> </trans-unit> <trans-unit id="jobStepDialog.successParse"> <source xml:lang="en">The command was successfully parsed.</source> <target state="translated">Il comando è stato analizzato.</target> </trans-unit> <trans-unit id="jobStepDialog.failParse"> <source xml:lang="en">The command failed.</source> <target state="translated">Il comando non è riuscito.</target> </trans-unit> <trans-unit id="jobStepDialog.blankStepName"> <source xml:lang="en">The step name cannot be left blank</source> <target state="translated">Il nome del passaggio non può essere lasciato vuoto</target> </trans-unit> <trans-unit id="jobStepDialog.processExitCode"> <source xml:lang="en">Process exit code of a successful command:</source> <target state="translated">Codice di uscita processo di un comando riuscito:</target> </trans-unit> <trans-unit id="jobStepDialog.stepNameLabel"> <source xml:lang="en">Step Name</source> <target state="translated">Nome del passaggio</target> </trans-unit> <trans-unit id="jobStepDialog.typeLabel"> <source xml:lang="en">Type</source> <target state="translated">Tipo</target> </trans-unit> <trans-unit id="jobStepDialog.runAsLabel"> <source xml:lang="en">Run as</source> <target state="translated">Esegui come</target> </trans-unit> <trans-unit id="jobStepDialog.databaseLabel"> <source xml:lang="en">Database</source> <target state="translated">Database</target> </trans-unit> <trans-unit id="jobStepDialog.commandLabel"> <source xml:lang="en">Command</source> <target state="translated">Comando</target> </trans-unit> <trans-unit id="jobStepDialog.successAction"> <source xml:lang="en">On success action</source> <target state="translated">Azione in caso di operazione riuscita</target> </trans-unit> <trans-unit id="jobStepDialog.failureAction"> <source xml:lang="en">On failure action</source> <target state="translated">Azione in caso di errore</target> </trans-unit> <trans-unit id="jobStepDialog.runAsUser"> <source xml:lang="en">Run as user</source> <target state="translated">Esegui come utente</target> </trans-unit> <trans-unit id="jobStepDialog.retryAttempts"> <source xml:lang="en">Retry Attempts</source> <target state="translated">Numero di tentativi</target> </trans-unit> <trans-unit id="jobStepDialog.retryInterval"> <source xml:lang="en">Retry Interval (minutes)</source> <target state="translated">Intervallo tra tentativi (minuti)</target> </trans-unit> <trans-unit id="jobStepDialog.logToTable"> <source xml:lang="en">Log to table</source> <target state="translated">Registra nella tabella</target> </trans-unit> <trans-unit id="jobStepDialog.appendExistingTableEntry"> <source xml:lang="en">Append output to exisiting entry in table</source> <target state="translated">Accoda output a voce esistente nella tabella</target> </trans-unit> <trans-unit id="jobStepDialog.includeStepOutputHistory"> <source xml:lang="en">Include step output in history</source> <target state="translated">Includi output del passaggio nella cronologia</target> </trans-unit> <trans-unit id="jobStepDialog.outputFile"> <source xml:lang="en">Output File</source> <target state="translated">File di output</target> </trans-unit> <trans-unit id="jobStepDialog.appendOutputToFile"> <source xml:lang="en">Append output to existing file</source> <target state="translated">Accoda output a file esistente</target> </trans-unit> <trans-unit id="jobStepDialog.selectedPath"> <source xml:lang="en">Selected path</source> <target state="translated">Percorso selezionato</target> </trans-unit> <trans-unit id="jobStepDialog.filesOfType"> <source xml:lang="en">Files of type</source> <target state="translated">File di tipo</target> </trans-unit> <trans-unit id="jobStepDialog.fileName"> <source xml:lang="en">File name</source> <target state="translated">Nome file</target> </trans-unit> <trans-unit id="jobStepDialog.allFiles"> <source xml:lang="en">All Files (*)</source> <target state="translated">Tutti i file (*)</target> </trans-unit> <trans-unit id="jobStepDialog.newJobStep"> <source xml:lang="en">New Job Step</source> <target state="translated">Nuovo passaggio del processo</target> </trans-unit> <trans-unit id="jobStepDialog.editJobStep"> <source xml:lang="en">Edit Job Step</source> <target state="translated">Modifica passaggio del processo</target> </trans-unit> <trans-unit id="jobStepDialog.TSQL"> <source xml:lang="en">Transact-SQL script (T-SQL)</source> <target state="translated">Script Transact-SQL (T-SQL)</target> </trans-unit> <trans-unit id="jobStepDialog.powershell"> <source xml:lang="en">PowerShell</source> <target state="translated">PowerShell</target> </trans-unit> <trans-unit id="jobStepDialog.CmdExec"> <source xml:lang="en">Operating system (CmdExec)</source> <target state="translated">Sistema operativo (CmdExec)</target> </trans-unit> <trans-unit id="jobStepDialog.replicationDistribution"> <source xml:lang="en">Replication Distributor</source> <target state="translated">Database di distribuzione repliche</target> </trans-unit> <trans-unit id="jobStepDialog.replicationMerge"> <source xml:lang="en">Replication Merge</source> <target state="translated">Merge repliche</target> </trans-unit> <trans-unit id="jobStepDialog.replicationQueueReader"> <source xml:lang="en">Replication Queue Reader</source> <target state="translated">Lettore coda di repliche</target> </trans-unit> <trans-unit id="jobStepDialog.replicationSnapshot"> <source xml:lang="en">Replication Snapshot</source> <target state="translated">Snapshot repliche</target> </trans-unit> <trans-unit id="jobStepDialog.replicationTransactionLogReader"> <source xml:lang="en">Replication Transaction-Log Reader</source> <target state="translated">Lettura log delle transazioni di replica</target> </trans-unit> <trans-unit id="jobStepDialog.analysisCommand"> <source xml:lang="en">SQL Server Analysis Services Command</source> <target state="translated">Comando di SQL Server Analysis Services</target> </trans-unit> <trans-unit id="jobStepDialog.analysisQuery"> <source xml:lang="en">SQL Server Analysis Services Query</source> <target state="translated">Query di SQL Server Analysis Services</target> </trans-unit> <trans-unit id="jobStepDialog.servicesPackage"> <source xml:lang="en">SQL Server Integration Service Package</source> <target state="translated">Pacchetto SQL Server Integration Services</target> </trans-unit> <trans-unit id="jobStepDialog.agentServiceAccount"> <source xml:lang="en">SQL Server Agent Service Account</source> <target state="translated">Account del servizio SQL Server Agent</target> </trans-unit> <trans-unit id="jobStepDialog.nextStep"> <source xml:lang="en">Go to the next step</source> <target state="translated">Vai al passaggio successivo</target> </trans-unit> <trans-unit id="jobStepDialog.quitJobSuccess"> <source xml:lang="en">Quit the job reporting success</source> <target state="translated">Termina il processo segnalandone la riuscita</target> </trans-unit> <trans-unit id="jobStepDialog.quitJobFailure"> <source xml:lang="en">Quit the job reporting failure</source> <target state="translated">Termina il processo segnalandone un errore</target> </trans-unit> </body> </file> <file original="extensions/agent/out/dialogs/jobDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="jobDialog.general"> <source xml:lang="en">General</source> <target state="translated">Generale</target> </trans-unit> <trans-unit id="jobDialog.steps"> <source xml:lang="en">Steps</source> <target state="translated">Passaggi</target> </trans-unit> <trans-unit id="jobDialog.schedules"> <source xml:lang="en">Schedules</source> <target state="translated">Pianificazioni</target> </trans-unit> <trans-unit id="jobDialog.alerts"> <source xml:lang="en">Alerts</source> <target state="translated">Avvisi</target> </trans-unit> <trans-unit id="jobDialog.notifications"> <source xml:lang="en">Notifications</source> <target state="translated">Notifiche</target> </trans-unit> <trans-unit id="jobDialog.blankJobNameError"> <source xml:lang="en">The name of the job cannot be blank.</source> <target state="translated">Il nome del processo non può essere vuoto.</target> </trans-unit> <trans-unit id="jobDialog.name"> <source xml:lang="en">Name</source> <target state="translated">Nome</target> </trans-unit> <trans-unit id="jobDialog.owner"> <source xml:lang="en">Owner</source> <target state="translated">Proprietario</target> </trans-unit> <trans-unit id="jobDialog.category"> <source xml:lang="en">Category</source> <target state="translated">Categoria</target> </trans-unit> <trans-unit id="jobDialog.description"> <source xml:lang="en">Description</source> <target state="translated">Descrizione</target> </trans-unit> <trans-unit id="jobDialog.enabled"> <source xml:lang="en">Enabled</source> <target state="translated">Abilitato</target> </trans-unit> <trans-unit id="jobDialog.jobStepList"> <source xml:lang="en">Job step list</source> <target state="translated">Elenco dei passaggi del processo</target> </trans-unit> <trans-unit id="jobDialog.step"> <source xml:lang="en">Step</source> <target state="translated">Passaggio</target> </trans-unit> <trans-unit id="jobDialog.type"> <source xml:lang="en">Type</source> <target state="translated">Tipo</target> </trans-unit> <trans-unit id="jobDialog.onSuccess"> <source xml:lang="en">On Success</source> <target state="translated">In caso di riuscita</target> </trans-unit> <trans-unit id="jobDialog.onFailure"> <source xml:lang="en">On Failure</source> <target state="translated">In caso di errore</target> </trans-unit> <trans-unit id="jobDialog.new"> <source xml:lang="en">New Step</source> <target state="translated">Nuovo passaggio</target> </trans-unit> <trans-unit id="jobDialog.edit"> <source xml:lang="en">Edit Step</source> <target state="translated">Modifica passaggio</target> </trans-unit> <trans-unit id="jobDialog.delete"> <source xml:lang="en">Delete Step</source> <target state="translated">Elimina passaggio</target> </trans-unit> <trans-unit id="jobDialog.moveUp"> <source xml:lang="en">Move Step Up</source> <target state="translated">Sposta passaggio su</target> </trans-unit> <trans-unit id="jobDialog.moveDown"> <source xml:lang="en">Move Step Down</source> <target state="translated">Sposta passaggio giù</target> </trans-unit> <trans-unit id="jobDialog.startStepAt"> <source xml:lang="en">Start step</source> <target state="translated">Passaggio iniziale</target> </trans-unit> <trans-unit id="jobDialog.notificationsTabTop"> <source xml:lang="en">Actions to perform when the job completes</source> <target state="translated">Azioni da eseguire quando il processo viene completato</target> </trans-unit> <trans-unit id="jobDialog.email"> <source xml:lang="en">Email</source> <target state="translated">Messaggio di posta elettronica</target> </trans-unit> <trans-unit id="jobDialog.page"> <source xml:lang="en">Page</source> <target state="translated">Pagina</target> </trans-unit> <trans-unit id="jobDialog.eventLogCheckBoxLabel"> <source xml:lang="en">Write to the Windows Application event log</source> <target state="translated">Scrivi nel log eventi dell'applicazione di Windows</target> </trans-unit> <trans-unit id="jobDialog.deleteJobLabel"> <source xml:lang="en">Automatically delete job</source> <target state="translated">Elimina automaticamente il processo</target> </trans-unit> <trans-unit id="jobDialog.schedulesaLabel"> <source xml:lang="en">Schedules list</source> <target state="translated">Elenco pianificazioni</target> </trans-unit> <trans-unit id="jobDialog.pickSchedule"> <source xml:lang="en">Pick Schedule</source> <target state="translated">Seleziona pianificazione</target> </trans-unit> <trans-unit id="jobDialog.scheduleNameLabel"> <source xml:lang="en">Schedule Name</source> <target state="translated">Nome della pianificazione</target> </trans-unit> <trans-unit id="jobDialog.alertsList"> <source xml:lang="en">Alerts list</source> <target state="translated">Elenco avvisi</target> </trans-unit> <trans-unit id="jobDialog.newAlert"> <source xml:lang="en">New Alert</source> <target state="translated">Nuovo avviso</target> </trans-unit> <trans-unit id="jobDialog.alertNameLabel"> <source xml:lang="en">Alert Name</source> <target state="translated">Nome dell'avviso</target> </trans-unit> <trans-unit id="jobDialog.alertEnabledLabel"> <source xml:lang="en">Enabled</source> <target state="translated">Abilitato</target> </trans-unit> <trans-unit id="jobDialog.alertTypeLabel"> <source xml:lang="en">Type</source> <target state="translated">Tipo</target> </trans-unit> <trans-unit id="jobDialog.newJob"> <source xml:lang="en">New Job</source> <target state="translated">Nuovo processo</target> </trans-unit> <trans-unit id="jobDialog.editJob"> <source xml:lang="en">Edit Job</source> <target state="translated">Modifica processo</target> </trans-unit> </body> </file> <file original="extensions/agent/out/dialogs/alertDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="alertDialog.createAlert"> <source xml:lang="en">Create Alert</source> <target state="translated">Crea avviso</target> </trans-unit> <trans-unit id="alertDialog.editAlert"> <source xml:lang="en">Edit Alert</source> <target state="translated">Modifica avviso</target> </trans-unit> <trans-unit id="alertDialog.General"> <source xml:lang="en">General</source> <target state="translated">Generale</target> </trans-unit> <trans-unit id="alertDialog.Response"> <source xml:lang="en">Response</source> <target state="translated">Risposta</target> </trans-unit> <trans-unit id="alertDialog.Options"> <source xml:lang="en">Options</source> <target state="translated">Opzioni</target> </trans-unit> <trans-unit id="alertDialog.eventAlert"> <source xml:lang="en">Event alert definition</source> <target state="translated">Definizione di avviso di evento</target> </trans-unit> <trans-unit id="alertDialog.Name"> <source xml:lang="en">Name</source> <target state="translated">Nome</target> </trans-unit> <trans-unit id="alertDialog.Type"> <source xml:lang="en">Type</source> <target state="translated">Tipo</target> </trans-unit> <trans-unit id="alertDialog.Enabled"> <source xml:lang="en">Enabled</source> <target state="translated">Abilitato</target> </trans-unit> <trans-unit id="alertDialog.DatabaseName"> <source xml:lang="en">Database name</source> <target state="translated">Nome del database</target> </trans-unit> <trans-unit id="alertDialog.ErrorNumber"> <source xml:lang="en">Error number</source> <target state="translated">Numero di errore</target> </trans-unit> <trans-unit id="alertDialog.Severity"> <source xml:lang="en">Severity</source> <target state="translated">Gravità</target> </trans-unit> <trans-unit id="alertDialog.RaiseAlertContains"> <source xml:lang="en">Raise alert when message contains</source> <target state="translated">Genera un avviso quando il messaggio contiene</target> </trans-unit> <trans-unit id="alertDialog.MessageText"> <source xml:lang="en">Message text</source> <target state="translated">Testo del messaggio</target> </trans-unit> <trans-unit id="alertDialog.Severity001"> <source xml:lang="en">001 - Miscellaneous System Information</source> <target state="translated">001 - Informazioni di sistema varie</target> </trans-unit> <trans-unit id="alertDialog.Severity002"> <source xml:lang="en">002 - Reserved</source> <target state="translated">002 - Riservato</target> </trans-unit> <trans-unit id="alertDialog.Severity003"> <source xml:lang="en">003 - Reserved</source> <target state="translated">003 - Riservato</target> </trans-unit> <trans-unit id="alertDialog.Severity004"> <source xml:lang="en">004 - Reserved</source> <target state="translated">004 - Riservato</target> </trans-unit> <trans-unit id="alertDialog.Severity005"> <source xml:lang="en">005 - Reserved</source> <target state="translated">005 - Riservato</target> </trans-unit> <trans-unit id="alertDialog.Severity006"> <source xml:lang="en">006 - Reserved</source> <target state="translated">006 - Riservato</target> </trans-unit> <trans-unit id="alertDialog.Severity007"> <source xml:lang="en">007 - Notification: Status Information</source> <target state="translated">007 - Notifica: informazioni sullo stato</target> </trans-unit> <trans-unit id="alertDialog.Severity008"> <source xml:lang="en">008 - Notification: User Intervention Required</source> <target state="translated">008 - Notifica: richiesto intervento dell'utente</target> </trans-unit> <trans-unit id="alertDialog.Severity009"> <source xml:lang="en">009 - User Defined</source> <target state="translated">009 - Definito dall'utente</target> </trans-unit> <trans-unit id="alertDialog.Severity010"> <source xml:lang="en">010 - Information</source> <target state="translated">010 - Informazioni</target> </trans-unit> <trans-unit id="alertDialog.Severity011"> <source xml:lang="en">011 - Specified Database Object Not Found</source> <target state="translated">011 - Oggetto di database specificato non trovato</target> </trans-unit> <trans-unit id="alertDialog.Severity012"> <source xml:lang="en">012 - Unused</source> <target state="translated">012 - Inutilizzato</target> </trans-unit> <trans-unit id="alertDialog.Severity013"> <source xml:lang="en">013 - User Transaction Syntax Error</source> <target state="translated">013 - Errore di sintassi nella transazione utente</target> </trans-unit> <trans-unit id="alertDialog.Severity014"> <source xml:lang="en">014 - Insufficient Permission</source> <target state="translated">014 - Autorizzazioni insufficienti</target> </trans-unit> <trans-unit id="alertDialog.Severity015"> <source xml:lang="en">015 - Syntax Error in SQL Statements</source> <target state="translated">015 - Errore di sintassi nelle istruzioni SQL</target> </trans-unit> <trans-unit id="alertDialog.Severity016"> <source xml:lang="en">016 - Miscellaneous User Error</source> <target state="translated">016 - Errore dell'utente</target> </trans-unit> <trans-unit id="alertDialog.Severity017"> <source xml:lang="en">017 - Insufficient Resources</source> <target state="translated">017 - Risorse insufficienti</target> </trans-unit> <trans-unit id="alertDialog.Severity018"> <source xml:lang="en">018 - Nonfatal Internal Error</source> <target state="translated">018 - Errore interno non irreversibile</target> </trans-unit> <trans-unit id="alertDialog.Severity019"> <source xml:lang="en">019 - Fatal Error in Resource</source> <target state="translated">019 - Errore irreversibile nella risorsa</target> </trans-unit> <trans-unit id="alertDialog.Severity020"> <source xml:lang="en">020 - Fatal Error in Current Process</source> <target state="translated">020 - Errore irreversibile nel processo corrente</target> </trans-unit> <trans-unit id="alertDialog.Severity021"> <source xml:lang="en">021 - Fatal Error in Database Processes</source> <target state="translated">021 - Errore irreversibile nei processi di database</target> </trans-unit> <trans-unit id="alertDialog.Severity022"> <source xml:lang="en">022 - Fatal Error: Table Integrity Suspect</source> <target state="translated">022 - Errore irreversibile: integrità tabella sospetta</target> </trans-unit> <trans-unit id="alertDialog.Severity023"> <source xml:lang="en">023 - Fatal Error: Database Integrity Suspect</source> <target state="translated">023 - Errore irreversibile: integrità database sospetta</target> </trans-unit> <trans-unit id="alertDialog.Severity024"> <source xml:lang="en">024 - Fatal Error: Hardware Error</source> <target state="translated">024 - Errore irreversibile: errore hardware</target> </trans-unit> <trans-unit id="alertDialog.Severity025"> <source xml:lang="en">025 - Fatal Error</source> <target state="translated">025 - Errore irreversibile</target> </trans-unit> <trans-unit id="alertDialog.AllDatabases"> <source xml:lang="en">&lt;all databases&gt;</source> <target state="translated">&lt;tutti i database&gt;</target> </trans-unit> <trans-unit id="alertDialog.ExecuteJob"> <source xml:lang="en">Execute Job</source> <target state="translated">Esegui processo</target> </trans-unit> <trans-unit id="alertDialog.ExecuteJobName"> <source xml:lang="en">Job Name</source> <target state="translated">Nome del processo</target> </trans-unit> <trans-unit id="alertDialog.NotifyOperators"> <source xml:lang="en">Notify Operators</source> <target state="translated">Invia notifica a operatori</target> </trans-unit> <trans-unit id="alertDialog.NewJob"> <source xml:lang="en">New Job</source> <target state="translated">Nuovo processo</target> </trans-unit> <trans-unit id="alertDialog.OperatorList"> <source xml:lang="en">Operator List</source> <target state="translated">Elenco operatori</target> </trans-unit> <trans-unit id="alertDialog.OperatorName"> <source xml:lang="en">Operator</source> <target state="translated">Operatore</target> </trans-unit> <trans-unit id="alertDialog.OperatorEmail"> <source xml:lang="en">E-mail</source> <target state="translated">Posta elettronica</target> </trans-unit> <trans-unit id="alertDialog.OperatorPager"> <source xml:lang="en">Pager</source> <target state="translated">Cercapersone</target> </trans-unit> <trans-unit id="alertDialog.NewOperator"> <source xml:lang="en">New Operator</source> <target state="translated">Nuovo operatore</target> </trans-unit> <trans-unit id="alertDialog.IncludeErrorInEmail"> <source xml:lang="en">Include alert error text in e-mail</source> <target state="translated">Includi testo dell'avviso in messaggi inviati tramite posta elettronica</target> </trans-unit> <trans-unit id="alertDialog.IncludeErrorInPager"> <source xml:lang="en">Include alert error text in pager</source> <target state="translated">Includi testo dell'avviso in messaggi inviati tramite cercapersone</target> </trans-unit> <trans-unit id="alertDialog.AdditionalNotification"> <source xml:lang="en">Additional notification message to send</source> <target state="translated">Messaggio di notifica aggiuntivo da inviare</target> </trans-unit> <trans-unit id="alertDialog.DelayBetweenResponse"> <source xml:lang="en">Delay between responses</source> <target state="translated">Ritardo tra le risposte</target> </trans-unit> <trans-unit id="alertDialog.DelayMinutes"> <source xml:lang="en">Delay Minutes</source> <target state="translated">Ritardo in minuti</target> </trans-unit> <trans-unit id="alertDialog.DelaySeconds"> <source xml:lang="en">Delay Seconds</source> <target state="translated">Ritardo in secondi</target> </trans-unit> </body> </file> <file original="extensions/agent/out/dialogs/agentDialog" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="agentDialog.OK"> <source xml:lang="en">OK</source> <target state="translated">OK</target> </trans-unit> <trans-unit id="agentDialog.Cancel"> <source xml:lang="en">Cancel</source> <target state="translated">Annulla</target> </trans-unit> </body> </file> <file original="extensions/agent/out/data/proxyData" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="proxyData.saveErrorMessage"> <source xml:lang="en">Proxy update failed '{0}'</source> <target state="translated">L'aggiornamento del proxy non è riuscito: '{0}'</target> </trans-unit> <trans-unit id="proxyData.saveSucessMessage"> <source xml:lang="en">Proxy '{0}' updated successfully</source> <target state="translated">Il proxy '{0}' è stato aggiornato</target> </trans-unit> <trans-unit id="proxyData.newJobSuccessMessage"> <source xml:lang="en">Proxy '{0}' created successfully</source> <target state="translated">Il proxy '{0}' è stato creato</target> </trans-unit> </body> </file> <file original="extensions/agent/out/data/jobStepData" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="jobStepData.saveErrorMessage"> <source xml:lang="en">Step update failed '{0}'</source> <target state="translated">L'aggiornamento del passaggio non è riuscito: '{0}'</target> </trans-unit> <trans-unit id="stepData.jobNameRequired"> <source xml:lang="en">Job name must be provided</source> <target state="translated">È necessario specificare il nome del processo</target> </trans-unit> <trans-unit id="stepData.stepNameRequired"> <source xml:lang="en">Step name must be provided</source> <target state="translated">È necessario specificare il nome del passaggio</target> </trans-unit> </body> </file> <file original="extensions/agent/out/data/jobData" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="jobData.whenJobCompletes"> <source xml:lang="en">When the job completes</source> <target state="translated">Al termine del processo</target> </trans-unit> <trans-unit id="jobData.whenJobFails"> <source xml:lang="en">When the job fails</source> <target state="translated">Se il processo non riesce</target> </trans-unit> <trans-unit id="jobData.whenJobSucceeds"> <source xml:lang="en">When the job succeeds</source> <target state="translated">Se il processo riesce</target> </trans-unit> <trans-unit id="jobData.jobNameRequired"> <source xml:lang="en">Job name must be provided</source> <target state="translated">È necessario specificare il nome del processo</target> </trans-unit> <trans-unit id="jobData.saveErrorMessage"> <source xml:lang="en">Job update failed '{0}'</source> <target state="translated">L'aggiornamento del processo non è riuscito: '{0}'</target> </trans-unit> <trans-unit id="jobData.newJobErrorMessage"> <source xml:lang="en">Job creation failed '{0}'</source> <target state="translated">La creazione del processo non è riuscita: '{0}'</target> </trans-unit> <trans-unit id="jobData.saveSucessMessage"> <source xml:lang="en">Job '{0}' updated successfully</source> <target state="translated">Il processo '{0}' è stato aggiornato</target> </trans-unit> <trans-unit id="jobData.newJobSuccessMessage"> <source xml:lang="en">Job '{0}' created successfully</source> <target state="translated">Il processo '{0}' è stato creato</target> </trans-unit> </body> </file> <file original="extensions/agent/out/data/alertData" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="alertData.saveErrorMessage"> <source xml:lang="en">Alert update failed '{0}'</source> <target state="translated">L'aggiornamento dell'avviso non è riuscito: '{0}'</target> </trans-unit> <trans-unit id="alertData.DefaultAlertTypString"> <source xml:lang="en">SQL Server event alert</source> <target state="translated">Avviso per evento di SQL Server</target> </trans-unit> <trans-unit id="alertDialog.PerformanceCondition"> <source xml:lang="en">SQL Server performance condition alert</source> <target state="translated">Avviso relativo alle prestazioni di SQL Server</target> </trans-unit> <trans-unit id="alertDialog.WmiEvent"> <source xml:lang="en">WMI event alert</source> <target state="translated">Avviso per evento WMI</target> </trans-unit> </body> </file> <file original="extensions/agent/out/mainController" source-language="en" datatype="plaintext" target-language="it"> <body> <trans-unit id="mainController.notImplemented"> <source xml:lang="en">This feature is under development. Check-out the latest insiders build if you'd like to try out the most recent changes!</source> <target state="translated">Questa funzionalità è in fase di sviluppo. Per provare le ultime novità, vedere la build più recente per utenti Insider.</target> </trans-unit> </body> </file> </xliff>
{ "pile_set_name": "Github" }
(:name globrep :description "Search for and replace strings in multiple files" :type emacsmirror :depends query)
{ "pile_set_name": "Github" }
package com.dianping.cat.status; import java.util.Map; public interface StatusExtension { /** * just the description of status extension * * @return */ public String getDescription(); /** * set the uniq id ,such as cat-message-queue * * @return */ public String getId(); /** * if value is double type , cat will build graph per minute in heartbeat report * * if value is string type , cat will record the lastest key value in heartbeat report * * make sure it will not block the thread * * @return */ public Map<String, String> getProperties(); }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>kie-server-services</artifactId> <groupId>org.kie.server</groupId> <version>7.44.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>kie-server-services-case-mgmt</artifactId> <name>KIE :: Execution Server :: Services :: Case Management Extension</name> <description>KIE Case Management Execution Server Extension</description> <properties> <java.module.name>org.kie.server.services.casemgmt</java.module.name> </properties> <dependencies> <dependency> <groupId>org.kie</groupId> <artifactId>kie-api</artifactId> </dependency> <dependency> <groupId>org.kie</groupId> <artifactId>kie-internal</artifactId> </dependency> <dependency> <groupId>org.drools</groupId> <artifactId>drools-core</artifactId> </dependency> <dependency> <groupId>org.drools</groupId> <artifactId>drools-compiler</artifactId> </dependency> <dependency> <groupId>org.kie.server</groupId> <artifactId>kie-server-api</artifactId> </dependency> <dependency> <groupId>org.kie.server</groupId> <artifactId>kie-server-services-common</artifactId> </dependency> <dependency> <groupId>org.kie.server</groupId> <artifactId>kie-server-common</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-flow</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-flow-builder</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-persistence-api</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-persistence-jpa</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-runtime-manager</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-shared-services</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-services-api</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-kie-services</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <!-- case management dependencies --> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-case-mgmt-api</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-case-mgmt-impl</artifactId> </dependency> </dependencies> </project>
{ "pile_set_name": "Github" }
// Tests that we properly serialize/deserialize spans from transitive dependencies // (e.g. imported SourceFiles) // // The order of these next lines is important, since we need // transitive_dep_two.rs to be able to reference transitive_dep_three.rs // // aux-build: transitive_dep_three.rs // aux-build: transitive_dep_two.rs // compile-flags: -Z macro-backtrace extern crate transitive_dep_two; transitive_dep_two::parse_error!(); //~ ERROR expected one of fn main() {}
{ "pile_set_name": "Github" }
// Copyright 2002 The Trustees of Indiana University. // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Boost.MultiArray Library // Authors: Ronald Garcia // Jeremy Siek // Andrew Lumsdaine // See http://www.boost.org/libs/multi_array for documentation. #ifndef BOOST_INDEX_GEN_RG071801_HPP #define BOOST_INDEX_GEN_RG071801_HPP #include "boost/array.hpp" #include "boost/multi_array/index_range.hpp" #include "boost/multi_array/range_list.hpp" #include "boost/multi_array/types.hpp" #include <algorithm> #include <cstddef> namespace boost { namespace detail { namespace multi_array { template <int NumRanges, int NumDims> struct index_gen { private: typedef ::boost::detail::multi_array::index index; typedef ::boost::detail::multi_array::size_type size_type; typedef index_range<index,size_type> range; public: template <int Dims, int Ranges> struct gen_type { typedef index_gen<Ranges,Dims> type; }; typedef typename range_list_generator<range,NumRanges>::type range_list; range_list ranges_; index_gen() { } template <int ND> explicit index_gen(const index_gen<NumRanges-1,ND>& rhs, const range& r) { std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin()); *ranges_.rbegin() = r; } index_gen<NumRanges+1,NumDims+1> operator[](const range& r) const { index_gen<NumRanges+1,NumDims+1> tmp; std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin()); *tmp.ranges_.rbegin() = r; return tmp; } index_gen<NumRanges+1,NumDims> operator[](index idx) const { index_gen<NumRanges+1,NumDims> tmp; std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin()); *tmp.ranges_.rbegin() = range(idx); return tmp; } static index_gen<0,0> indices() { return index_gen<0,0>(); } }; } // namespace multi_array } // namespace detail } // namespace boost #endif // BOOST_INDEX_GEN_RG071801_HPP
{ "pile_set_name": "Github" }
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "pkcs11.h" #ifndef DEVM_H #include "devm.h" #endif /* DEVM_H */ #ifndef CKHELPER_H #include "ckhelper.h" #endif /* CKHELPER_H */ #include "pk11func.h" #include "dev3hack.h" #include "secerr.h" extern const NSSError NSS_ERROR_NOT_FOUND; extern const NSSError NSS_ERROR_INVALID_ARGUMENT; extern const NSSError NSS_ERROR_PKCS11; /* The number of object handles to grab during each call to C_FindObjects */ #define OBJECT_STACK_SIZE 16 NSS_IMPLEMENT PRStatus nssToken_Destroy( NSSToken *tok) { if (tok) { if (PR_ATOMIC_DECREMENT(&tok->base.refCount) == 0) { PK11_FreeSlot(tok->pk11slot); PZ_DestroyLock(tok->base.lock); nssTokenObjectCache_Destroy(tok->cache); /* We're going away, let the nssSlot know in case it's held * alive by someone else. Usually we should hold the last ref. */ nssSlot_EnterMonitor(tok->slot); tok->slot->token = NULL; nssSlot_ExitMonitor(tok->slot); (void)nssSlot_Destroy(tok->slot); return nssArena_Destroy(tok->base.arena); } } return PR_SUCCESS; } NSS_IMPLEMENT void nssToken_Remove( NSSToken *tok) { nssTokenObjectCache_Clear(tok->cache); } NSS_IMPLEMENT void NSSToken_Destroy( NSSToken *tok) { (void)nssToken_Destroy(tok); } NSS_IMPLEMENT NSSToken * nssToken_AddRef( NSSToken *tok) { PR_ATOMIC_INCREMENT(&tok->base.refCount); return tok; } NSS_IMPLEMENT NSSSlot * nssToken_GetSlot( NSSToken *tok) { return nssSlot_AddRef(tok->slot); } NSS_IMPLEMENT void * nssToken_GetCryptokiEPV( NSSToken *token) { return nssSlot_GetCryptokiEPV(token->slot); } NSS_IMPLEMENT nssSession * nssToken_GetDefaultSession( NSSToken *token) { return token->defaultSession; } NSS_IMPLEMENT NSSUTF8 * nssToken_GetName( NSSToken *tok) { if (tok == NULL) { return ""; } if (tok->base.name[0] == 0) { (void)nssSlot_IsTokenPresent(tok->slot); } return tok->base.name; } NSS_IMPLEMENT NSSUTF8 * NSSToken_GetName( NSSToken *token) { return nssToken_GetName(token); } NSS_IMPLEMENT PRBool nssToken_IsLoginRequired( NSSToken *token) { return (token->ckFlags & CKF_LOGIN_REQUIRED); } NSS_IMPLEMENT PRBool nssToken_NeedsPINInitialization( NSSToken *token) { return (!(token->ckFlags & CKF_USER_PIN_INITIALIZED)); } NSS_IMPLEMENT PRStatus nssToken_DeleteStoredObject( nssCryptokiObject *instance) { CK_RV ckrv; PRStatus status; PRBool createdSession = PR_FALSE; NSSToken *token = instance->token; nssSession *session = NULL; void *epv = nssToken_GetCryptokiEPV(instance->token); if (token->cache) { nssTokenObjectCache_RemoveObject(token->cache, instance); } if (instance->isTokenObject) { if (token->defaultSession && nssSession_IsReadWrite(token->defaultSession)) { session = token->defaultSession; } else { session = nssSlot_CreateSession(token->slot, NULL, PR_TRUE); createdSession = PR_TRUE; } } if (session == NULL) { return PR_FAILURE; } nssSession_EnterMonitor(session); ckrv = CKAPI(epv)->C_DestroyObject(session->handle, instance->handle); nssSession_ExitMonitor(session); if (createdSession) { nssSession_Destroy(session); } status = PR_SUCCESS; if (ckrv != CKR_OK) { status = PR_FAILURE; /* use the error stack to pass the PKCS #11 error out */ nss_SetError(ckrv); nss_SetError(NSS_ERROR_PKCS11); } return status; } static nssCryptokiObject * import_object( NSSToken *tok, nssSession *sessionOpt, CK_ATTRIBUTE_PTR objectTemplate, CK_ULONG otsize) { nssSession *session = NULL; PRBool createdSession = PR_FALSE; nssCryptokiObject *object = NULL; CK_OBJECT_HANDLE handle; CK_RV ckrv; void *epv = nssToken_GetCryptokiEPV(tok); if (nssCKObject_IsTokenObjectTemplate(objectTemplate, otsize)) { if (sessionOpt) { if (!nssSession_IsReadWrite(sessionOpt)) { nss_SetError(NSS_ERROR_INVALID_ARGUMENT); return NULL; } session = sessionOpt; } else if (tok->defaultSession && nssSession_IsReadWrite(tok->defaultSession)) { session = tok->defaultSession; } else { session = nssSlot_CreateSession(tok->slot, NULL, PR_TRUE); createdSession = PR_TRUE; } } else { session = (sessionOpt) ? sessionOpt : tok->defaultSession; } if (session == NULL) { nss_SetError(NSS_ERROR_INVALID_ARGUMENT); return NULL; } nssSession_EnterMonitor(session); ckrv = CKAPI(epv)->C_CreateObject(session->handle, objectTemplate, otsize, &handle); nssSession_ExitMonitor(session); if (ckrv == CKR_OK) { object = nssCryptokiObject_Create(tok, session, handle); } else { nss_SetError(ckrv); nss_SetError(NSS_ERROR_PKCS11); } if (createdSession) { nssSession_Destroy(session); } return object; } static nssCryptokiObject ** create_objects_from_handles( NSSToken *tok, nssSession *session, CK_OBJECT_HANDLE *handles, PRUint32 numH) { nssCryptokiObject **objects; objects = nss_ZNEWARRAY(NULL, nssCryptokiObject *, numH + 1); if (objects) { PRInt32 i; for (i = 0; i < (PRInt32)numH; i++) { objects[i] = nssCryptokiObject_Create(tok, session, handles[i]); if (!objects[i]) { for (--i; i > 0; --i) { nssCryptokiObject_Destroy(objects[i]); } nss_ZFreeIf(objects); objects = NULL; break; } } } return objects; } static nssCryptokiObject ** find_objects( NSSToken *tok, nssSession *sessionOpt, CK_ATTRIBUTE_PTR obj_template, CK_ULONG otsize, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_RV ckrv = CKR_OK; CK_ULONG count; CK_OBJECT_HANDLE *objectHandles = NULL; CK_OBJECT_HANDLE staticObjects[OBJECT_STACK_SIZE]; PRUint32 arraySize, numHandles; void *epv = nssToken_GetCryptokiEPV(tok); nssCryptokiObject **objects; nssSession *session = (sessionOpt) ? sessionOpt : tok->defaultSession; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { ckrv = CKR_SESSION_HANDLE_INVALID; goto loser; } /* the arena is only for the array of object handles */ if (maximumOpt > 0) { arraySize = maximumOpt; } else { arraySize = OBJECT_STACK_SIZE; } numHandles = 0; if (arraySize <= OBJECT_STACK_SIZE) { objectHandles = staticObjects; } else { objectHandles = nss_ZNEWARRAY(NULL, CK_OBJECT_HANDLE, arraySize); } if (!objectHandles) { ckrv = CKR_HOST_MEMORY; goto loser; } nssSession_EnterMonitor(session); /* ==== session lock === */ /* Initialize the find with the template */ ckrv = CKAPI(epv)->C_FindObjectsInit(session->handle, obj_template, otsize); if (ckrv != CKR_OK) { nssSession_ExitMonitor(session); goto loser; } while (PR_TRUE) { /* Issue the find for up to arraySize - numHandles objects */ ckrv = CKAPI(epv)->C_FindObjects(session->handle, objectHandles + numHandles, arraySize - numHandles, &count); if (ckrv != CKR_OK) { nssSession_ExitMonitor(session); goto loser; } /* bump the number of found objects */ numHandles += count; if (maximumOpt > 0 || numHandles < arraySize) { /* When a maximum is provided, the search is done all at once, * so the search is finished. If the number returned was less * than the number sought, the search is finished. */ break; } /* the array is filled, double it and continue */ arraySize *= 2; if (objectHandles == staticObjects) { objectHandles = nss_ZNEWARRAY(NULL, CK_OBJECT_HANDLE, arraySize); if (objectHandles) { PORT_Memcpy(objectHandles, staticObjects, OBJECT_STACK_SIZE * sizeof(objectHandles[1])); } } else { objectHandles = nss_ZREALLOCARRAY(objectHandles, CK_OBJECT_HANDLE, arraySize); } if (!objectHandles) { nssSession_ExitMonitor(session); ckrv = CKR_HOST_MEMORY; goto loser; } } ckrv = CKAPI(epv)->C_FindObjectsFinal(session->handle); nssSession_ExitMonitor(session); /* ==== end session lock === */ if (ckrv != CKR_OK) { goto loser; } if (numHandles > 0) { objects = create_objects_from_handles(tok, session, objectHandles, numHandles); } else { nss_SetError(NSS_ERROR_NOT_FOUND); objects = NULL; } if (objectHandles && objectHandles != staticObjects) { nss_ZFreeIf(objectHandles); } if (statusOpt) *statusOpt = PR_SUCCESS; return objects; loser: if (objectHandles && objectHandles != staticObjects) { nss_ZFreeIf(objectHandles); } /* * These errors should be treated the same as if the objects just weren't * found.. */ if ((ckrv == CKR_ATTRIBUTE_TYPE_INVALID) || (ckrv == CKR_ATTRIBUTE_VALUE_INVALID) || (ckrv == CKR_DATA_INVALID) || (ckrv == CKR_DATA_LEN_RANGE) || (ckrv == CKR_FUNCTION_NOT_SUPPORTED) || (ckrv == CKR_TEMPLATE_INCOMPLETE) || (ckrv == CKR_TEMPLATE_INCONSISTENT)) { nss_SetError(NSS_ERROR_NOT_FOUND); if (statusOpt) *statusOpt = PR_SUCCESS; } else { nss_SetError(ckrv); nss_SetError(NSS_ERROR_PKCS11); if (statusOpt) *statusOpt = PR_FAILURE; } return (nssCryptokiObject **)NULL; } NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindObjectsByTemplate( NSSToken *token, nssSession *sessionOpt, CK_ATTRIBUTE_PTR obj_template, CK_ULONG otsize, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_OBJECT_CLASS objclass = (CK_OBJECT_CLASS)-1; nssCryptokiObject **objects = NULL; PRUint32 i; if (!token) { PORT_SetError(SEC_ERROR_NO_TOKEN); if (statusOpt) *statusOpt = PR_FAILURE; return NULL; } for (i = 0; i < otsize; i++) { if (obj_template[i].type == CKA_CLASS) { objclass = *(CK_OBJECT_CLASS *)obj_template[i].pValue; break; } } PR_ASSERT(i < otsize); if (i == otsize) { PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); if (statusOpt) *statusOpt = PR_FAILURE; return NULL; } /* If these objects are being cached, try looking there first */ if (token->cache && nssTokenObjectCache_HaveObjectClass(token->cache, objclass)) { PRStatus status; objects = nssTokenObjectCache_FindObjectsByTemplate(token->cache, objclass, obj_template, otsize, maximumOpt, &status); if (status == PR_SUCCESS) { if (statusOpt) *statusOpt = status; return objects; } } /* Either they are not cached, or cache failed; look on token. */ objects = find_objects(token, sessionOpt, obj_template, otsize, maximumOpt, statusOpt); return objects; } extern const NSSError NSS_ERROR_INVALID_CERTIFICATE; NSS_IMPLEMENT nssCryptokiObject * nssToken_ImportCertificate( NSSToken *tok, nssSession *sessionOpt, NSSCertificateType certType, NSSItem *id, const NSSUTF8 *nickname, NSSDER *encoding, NSSDER *issuer, NSSDER *subject, NSSDER *serial, NSSASCII7 *email, PRBool asTokenObject) { PRStatus status; CK_CERTIFICATE_TYPE cert_type; CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE cert_tmpl[10]; CK_ULONG ctsize; nssTokenSearchType searchType; nssCryptokiObject *rvObject = NULL; if (!tok) { PORT_SetError(SEC_ERROR_NO_TOKEN); return NULL; } if (certType == NSSCertificateType_PKIX) { cert_type = CKC_X_509; } else { return (nssCryptokiObject *)NULL; } NSS_CK_TEMPLATE_START(cert_tmpl, attr, ctsize); if (asTokenObject) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); searchType = nssTokenSearchType_TokenOnly; } else { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); searchType = nssTokenSearchType_SessionOnly; } NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_CERTIFICATE_TYPE, cert_type); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ID, id); NSS_CK_SET_ATTRIBUTE_UTF8(attr, CKA_LABEL, nickname); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_VALUE, encoding); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ISSUER, issuer); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SUBJECT, subject); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SERIAL_NUMBER, serial); if (email) { NSS_CK_SET_ATTRIBUTE_UTF8(attr, CKA_NSS_EMAIL, email); } NSS_CK_TEMPLATE_FINISH(cert_tmpl, attr, ctsize); /* see if the cert is already there */ rvObject = nssToken_FindCertificateByIssuerAndSerialNumber(tok, sessionOpt, issuer, serial, searchType, NULL); if (rvObject) { NSSItem existingDER; NSSSlot *slot = nssToken_GetSlot(tok); nssSession *session = nssSlot_CreateSession(slot, NULL, PR_TRUE); if (!session) { nssCryptokiObject_Destroy(rvObject); nssSlot_Destroy(slot); return (nssCryptokiObject *)NULL; } /* Reject any attempt to import a new cert that has the same * issuer/serial as an existing cert, but does not have the * same encoding */ NSS_CK_TEMPLATE_START(cert_tmpl, attr, ctsize); NSS_CK_SET_ATTRIBUTE_NULL(attr, CKA_VALUE); NSS_CK_TEMPLATE_FINISH(cert_tmpl, attr, ctsize); status = nssCKObject_GetAttributes(rvObject->handle, cert_tmpl, ctsize, NULL, session, slot); NSS_CK_ATTRIBUTE_TO_ITEM(cert_tmpl, &existingDER); if (status == PR_SUCCESS) { if (!nssItem_Equal(encoding, &existingDER, NULL)) { nss_SetError(NSS_ERROR_INVALID_CERTIFICATE); status = PR_FAILURE; } nss_ZFreeIf(existingDER.data); } if (status == PR_FAILURE) { nssCryptokiObject_Destroy(rvObject); nssSession_Destroy(session); nssSlot_Destroy(slot); return (nssCryptokiObject *)NULL; } /* according to PKCS#11, label, ID, issuer, and serial number * may change after the object has been created. For PKIX, the * last two attributes can't change, so for now we'll only worry * about the first two. */ NSS_CK_TEMPLATE_START(cert_tmpl, attr, ctsize); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ID, id); if (!rvObject->label && nickname) { NSS_CK_SET_ATTRIBUTE_UTF8(attr, CKA_LABEL, nickname); } NSS_CK_TEMPLATE_FINISH(cert_tmpl, attr, ctsize); /* reset the mutable attributes on the token */ nssCKObject_SetAttributes(rvObject->handle, cert_tmpl, ctsize, session, slot); if (!rvObject->label && nickname) { rvObject->label = nssUTF8_Duplicate(nickname, NULL); } nssSession_Destroy(session); nssSlot_Destroy(slot); } else { /* Import the certificate onto the token */ rvObject = import_object(tok, sessionOpt, cert_tmpl, ctsize); } if (rvObject && tok->cache) { /* The cache will overwrite the attributes if the object already * exists. */ nssTokenObjectCache_ImportObject(tok->cache, rvObject, CKO_CERTIFICATE, cert_tmpl, ctsize); } return rvObject; } /* traverse all objects of the given class - this should only happen * if the token has been marked as "traversable" */ NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindObjects( NSSToken *token, nssSession *sessionOpt, CK_OBJECT_CLASS objclass, nssTokenSearchType searchType, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE obj_template[2]; CK_ULONG obj_size; nssCryptokiObject **objects; NSS_CK_TEMPLATE_START(obj_template, attr, obj_size); /* Set the search to token/session only if provided */ if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly || searchType == nssTokenSearchType_TokenForced) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_CLASS, objclass); NSS_CK_TEMPLATE_FINISH(obj_template, attr, obj_size); if (searchType == nssTokenSearchType_TokenForced) { objects = find_objects(token, sessionOpt, obj_template, obj_size, maximumOpt, statusOpt); } else { objects = nssToken_FindObjectsByTemplate(token, sessionOpt, obj_template, obj_size, maximumOpt, statusOpt); } return objects; } NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindCertificatesBySubject( NSSToken *token, nssSession *sessionOpt, NSSDER *subject, nssTokenSearchType searchType, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE subj_template[3]; CK_ULONG stsize; nssCryptokiObject **objects; NSS_CK_TEMPLATE_START(subj_template, attr, stsize); /* Set the search to token/session only if provided */ if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SUBJECT, subject); NSS_CK_TEMPLATE_FINISH(subj_template, attr, stsize); /* now locate the token certs matching this template */ objects = nssToken_FindObjectsByTemplate(token, sessionOpt, subj_template, stsize, maximumOpt, statusOpt); return objects; } NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindCertificatesByNickname( NSSToken *token, nssSession *sessionOpt, const NSSUTF8 *name, nssTokenSearchType searchType, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE nick_template[3]; CK_ULONG ntsize; nssCryptokiObject **objects; NSS_CK_TEMPLATE_START(nick_template, attr, ntsize); NSS_CK_SET_ATTRIBUTE_UTF8(attr, CKA_LABEL, name); /* Set the search to token/session only if provided */ if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_TEMPLATE_FINISH(nick_template, attr, ntsize); /* now locate the token certs matching this template */ objects = nssToken_FindObjectsByTemplate(token, sessionOpt, nick_template, ntsize, maximumOpt, statusOpt); if (!objects) { /* This is to workaround the fact that PKCS#11 doesn't specify * whether the '\0' should be included. XXX Is that still true? * im - this is not needed by the current softoken. However, I'm * leaving it in until I have surveyed more tokens to see if it needed. * well, its needed by the builtin token... */ nick_template[0].ulValueLen++; objects = nssToken_FindObjectsByTemplate(token, sessionOpt, nick_template, ntsize, maximumOpt, statusOpt); } return objects; } /* XXX * This function *does not* use the token object cache, because not even * the softoken will return a value for CKA_NSS_EMAIL from a call * to GetAttributes. The softoken does allow searches with that attribute, * it just won't return a value for it. */ NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindCertificatesByEmail( NSSToken *token, nssSession *sessionOpt, NSSASCII7 *email, nssTokenSearchType searchType, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE email_template[3]; CK_ULONG etsize; nssCryptokiObject **objects; NSS_CK_TEMPLATE_START(email_template, attr, etsize); NSS_CK_SET_ATTRIBUTE_UTF8(attr, CKA_NSS_EMAIL, email); /* Set the search to token/session only if provided */ if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_TEMPLATE_FINISH(email_template, attr, etsize); /* now locate the token certs matching this template */ objects = find_objects(token, sessionOpt, email_template, etsize, maximumOpt, statusOpt); if (!objects) { /* This is to workaround the fact that PKCS#11 doesn't specify * whether the '\0' should be included. XXX Is that still true? * im - this is not needed by the current softoken. However, I'm * leaving it in until I have surveyed more tokens to see if it needed. * well, its needed by the builtin token... */ email_template[0].ulValueLen++; objects = find_objects(token, sessionOpt, email_template, etsize, maximumOpt, statusOpt); } return objects; } NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindCertificatesByID( NSSToken *token, nssSession *sessionOpt, NSSItem *id, nssTokenSearchType searchType, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE id_template[3]; CK_ULONG idtsize; nssCryptokiObject **objects; NSS_CK_TEMPLATE_START(id_template, attr, idtsize); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ID, id); /* Set the search to token/session only if provided */ if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_TEMPLATE_FINISH(id_template, attr, idtsize); /* now locate the token certs matching this template */ objects = nssToken_FindObjectsByTemplate(token, sessionOpt, id_template, idtsize, maximumOpt, statusOpt); return objects; } /* * decode the serial item and return our result. * NOTE serialDecode's data is really stored in serial. Don't free it. */ static PRStatus nssToken_decodeSerialItem(NSSItem *serial, NSSItem *serialDecode) { unsigned char *data = (unsigned char *)serial->data; int data_left, data_len, index; if ((serial->size >= 3) && (data[0] == 0x2)) { /* remove the der encoding of the serial number before generating the * key.. */ data_left = serial->size - 2; data_len = data[1]; index = 2; /* extended length ? (not very likely for a serial number) */ if (data_len & 0x80) { int len_count = data_len & 0x7f; data_len = 0; data_left -= len_count; if (data_left > 0) { while (len_count--) { data_len = (data_len << 8) | data[index++]; } } } /* XXX leaving any leading zeros on the serial number for backwards * compatibility */ /* not a valid der, must be just an unlucky serial number value */ if (data_len == data_left) { serialDecode->size = data_len; serialDecode->data = &data[index]; return PR_SUCCESS; } } return PR_FAILURE; } NSS_IMPLEMENT nssCryptokiObject * nssToken_FindCertificateByIssuerAndSerialNumber( NSSToken *token, nssSession *sessionOpt, NSSDER *issuer, NSSDER *serial, nssTokenSearchType searchType, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE_PTR serialAttr; CK_ATTRIBUTE cert_template[4]; CK_ULONG ctsize; nssCryptokiObject **objects; nssCryptokiObject *rvObject = NULL; NSS_CK_TEMPLATE_START(cert_template, attr, ctsize); if (!token) { PORT_SetError(SEC_ERROR_NO_TOKEN); if (statusOpt) *statusOpt = PR_FAILURE; return NULL; } /* Set the search to token/session only if provided */ if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if ((searchType == nssTokenSearchType_TokenOnly) || (searchType == nssTokenSearchType_TokenForced)) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } /* Set the unique id */ NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ISSUER, issuer); serialAttr = attr; NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SERIAL_NUMBER, serial); NSS_CK_TEMPLATE_FINISH(cert_template, attr, ctsize); /* get the object handle */ if (searchType == nssTokenSearchType_TokenForced) { objects = find_objects(token, sessionOpt, cert_template, ctsize, 1, statusOpt); } else { objects = nssToken_FindObjectsByTemplate(token, sessionOpt, cert_template, ctsize, 1, statusOpt); } if (objects) { rvObject = objects[0]; nss_ZFreeIf(objects); } /* * NSS used to incorrectly store serial numbers in their decoded form. * because of this old tokens have decoded serial numbers. */ if (!objects) { NSSItem serialDecode; PRStatus status; status = nssToken_decodeSerialItem(serial, &serialDecode); if (status != PR_SUCCESS) { return NULL; } NSS_CK_SET_ATTRIBUTE_ITEM(serialAttr, CKA_SERIAL_NUMBER, &serialDecode); if (searchType == nssTokenSearchType_TokenForced) { objects = find_objects(token, sessionOpt, cert_template, ctsize, 1, statusOpt); } else { objects = nssToken_FindObjectsByTemplate(token, sessionOpt, cert_template, ctsize, 1, statusOpt); } if (objects) { rvObject = objects[0]; nss_ZFreeIf(objects); } } return rvObject; } NSS_IMPLEMENT nssCryptokiObject * nssToken_FindCertificateByEncodedCertificate( NSSToken *token, nssSession *sessionOpt, NSSBER *encodedCertificate, nssTokenSearchType searchType, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE cert_template[3]; CK_ULONG ctsize; nssCryptokiObject **objects; nssCryptokiObject *rvObject = NULL; NSS_CK_TEMPLATE_START(cert_template, attr, ctsize); /* Set the search to token/session only if provided */ if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_VALUE, encodedCertificate); NSS_CK_TEMPLATE_FINISH(cert_template, attr, ctsize); /* get the object handle */ objects = nssToken_FindObjectsByTemplate(token, sessionOpt, cert_template, ctsize, 1, statusOpt); if (objects) { rvObject = objects[0]; nss_ZFreeIf(objects); } return rvObject; } NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindPrivateKeys( NSSToken *token, nssSession *sessionOpt, nssTokenSearchType searchType, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE key_template[2]; CK_ULONG ktsize; nssCryptokiObject **objects; NSS_CK_TEMPLATE_START(key_template, attr, ktsize); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_privkey); if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_TEMPLATE_FINISH(key_template, attr, ktsize); objects = nssToken_FindObjectsByTemplate(token, sessionOpt, key_template, ktsize, maximumOpt, statusOpt); return objects; } /* XXX ?there are no session cert objects, so only search token objects */ NSS_IMPLEMENT nssCryptokiObject * nssToken_FindPrivateKeyByID( NSSToken *token, nssSession *sessionOpt, NSSItem *keyID) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE key_template[3]; CK_ULONG ktsize; nssCryptokiObject **objects; nssCryptokiObject *rvKey = NULL; NSS_CK_TEMPLATE_START(key_template, attr, ktsize); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_privkey); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ID, keyID); NSS_CK_TEMPLATE_FINISH(key_template, attr, ktsize); objects = nssToken_FindObjectsByTemplate(token, sessionOpt, key_template, ktsize, 1, NULL); if (objects) { rvKey = objects[0]; nss_ZFreeIf(objects); } return rvKey; } /* XXX ?there are no session cert objects, so only search token objects */ NSS_IMPLEMENT nssCryptokiObject * nssToken_FindPublicKeyByID( NSSToken *token, nssSession *sessionOpt, NSSItem *keyID) { CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE key_template[3]; CK_ULONG ktsize; nssCryptokiObject **objects; nssCryptokiObject *rvKey = NULL; NSS_CK_TEMPLATE_START(key_template, attr, ktsize); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_pubkey); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ID, keyID); NSS_CK_TEMPLATE_FINISH(key_template, attr, ktsize); objects = nssToken_FindObjectsByTemplate(token, sessionOpt, key_template, ktsize, 1, NULL); if (objects) { rvKey = objects[0]; nss_ZFreeIf(objects); } return rvKey; } static void sha1_hash(NSSItem *input, NSSItem *output) { NSSAlgorithmAndParameters *ap; PK11SlotInfo *internal = PK11_GetInternalSlot(); NSSToken *token = PK11Slot_GetNSSToken(internal); ap = NSSAlgorithmAndParameters_CreateSHA1Digest(NULL); (void)nssToken_Digest(token, NULL, ap, input, output, NULL); PK11_FreeSlot(token->pk11slot); nss_ZFreeIf(ap); } static void md5_hash(NSSItem *input, NSSItem *output) { NSSAlgorithmAndParameters *ap; PK11SlotInfo *internal = PK11_GetInternalSlot(); NSSToken *token = PK11Slot_GetNSSToken(internal); ap = NSSAlgorithmAndParameters_CreateMD5Digest(NULL); (void)nssToken_Digest(token, NULL, ap, input, output, NULL); PK11_FreeSlot(token->pk11slot); nss_ZFreeIf(ap); } static CK_TRUST get_ck_trust( nssTrustLevel nssTrust) { CK_TRUST t; switch (nssTrust) { case nssTrustLevel_NotTrusted: t = CKT_NSS_NOT_TRUSTED; break; case nssTrustLevel_TrustedDelegator: t = CKT_NSS_TRUSTED_DELEGATOR; break; case nssTrustLevel_ValidDelegator: t = CKT_NSS_VALID_DELEGATOR; break; case nssTrustLevel_Trusted: t = CKT_NSS_TRUSTED; break; case nssTrustLevel_MustVerify: t = CKT_NSS_MUST_VERIFY_TRUST; break; case nssTrustLevel_Unknown: default: t = CKT_NSS_TRUST_UNKNOWN; break; } return t; } NSS_IMPLEMENT nssCryptokiObject * nssToken_ImportTrust( NSSToken *tok, nssSession *sessionOpt, NSSDER *certEncoding, NSSDER *certIssuer, NSSDER *certSerial, nssTrustLevel serverAuth, nssTrustLevel clientAuth, nssTrustLevel codeSigning, nssTrustLevel emailProtection, PRBool stepUpApproved, PRBool asTokenObject) { nssCryptokiObject *object; CK_OBJECT_CLASS tobjc = CKO_NSS_TRUST; CK_TRUST ckSA, ckCA, ckCS, ckEP; CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE trust_tmpl[11]; CK_ULONG tsize; PRUint8 sha1[20]; /* this is cheating... */ PRUint8 md5[16]; NSSItem sha1_result, md5_result; sha1_result.data = sha1; sha1_result.size = sizeof sha1; md5_result.data = md5; md5_result.size = sizeof md5; sha1_hash(certEncoding, &sha1_result); md5_hash(certEncoding, &md5_result); ckSA = get_ck_trust(serverAuth); ckCA = get_ck_trust(clientAuth); ckCS = get_ck_trust(codeSigning); ckEP = get_ck_trust(emailProtection); NSS_CK_TEMPLATE_START(trust_tmpl, attr, tsize); if (asTokenObject) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } else { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_CLASS, tobjc); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ISSUER, certIssuer); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SERIAL_NUMBER, certSerial); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CERT_SHA1_HASH, &sha1_result); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CERT_MD5_HASH, &md5_result); /* now set the trust values */ NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_TRUST_SERVER_AUTH, ckSA); NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_TRUST_CLIENT_AUTH, ckCA); NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_TRUST_CODE_SIGNING, ckCS); NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_TRUST_EMAIL_PROTECTION, ckEP); if (stepUpApproved) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TRUST_STEP_UP_APPROVED, &g_ck_true); } else { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TRUST_STEP_UP_APPROVED, &g_ck_false); } NSS_CK_TEMPLATE_FINISH(trust_tmpl, attr, tsize); /* import the trust object onto the token */ object = import_object(tok, sessionOpt, trust_tmpl, tsize); if (object && tok->cache) { nssTokenObjectCache_ImportObject(tok->cache, object, tobjc, trust_tmpl, tsize); } return object; } NSS_IMPLEMENT nssCryptokiObject * nssToken_FindTrustForCertificate( NSSToken *token, nssSession *sessionOpt, NSSDER *certEncoding, NSSDER *certIssuer, NSSDER *certSerial, nssTokenSearchType searchType) { CK_OBJECT_CLASS tobjc = CKO_NSS_TRUST; CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE tobj_template[5]; CK_ULONG tobj_size; nssSession *session = sessionOpt ? sessionOpt : token->defaultSession; nssCryptokiObject *object = NULL, **objects; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_NO_TOKEN); return object; } NSS_CK_TEMPLATE_START(tobj_template, attr, tobj_size); if (searchType == nssTokenSearchType_TokenOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_CLASS, tobjc); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_ISSUER, certIssuer); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SERIAL_NUMBER, certSerial); NSS_CK_TEMPLATE_FINISH(tobj_template, attr, tobj_size); objects = nssToken_FindObjectsByTemplate(token, session, tobj_template, tobj_size, 1, NULL); if (objects) { object = objects[0]; nss_ZFreeIf(objects); } return object; } NSS_IMPLEMENT nssCryptokiObject * nssToken_ImportCRL( NSSToken *token, nssSession *sessionOpt, NSSDER *subject, NSSDER *encoding, PRBool isKRL, NSSUTF8 *url, PRBool asTokenObject) { nssCryptokiObject *object; CK_OBJECT_CLASS crlobjc = CKO_NSS_CRL; CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE crl_tmpl[6]; CK_ULONG crlsize; NSS_CK_TEMPLATE_START(crl_tmpl, attr, crlsize); if (asTokenObject) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } else { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_CLASS, crlobjc); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SUBJECT, subject); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_VALUE, encoding); NSS_CK_SET_ATTRIBUTE_UTF8(attr, CKA_NSS_URL, url); if (isKRL) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_NSS_KRL, &g_ck_true); } else { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_NSS_KRL, &g_ck_false); } NSS_CK_TEMPLATE_FINISH(crl_tmpl, attr, crlsize); /* import the crl object onto the token */ object = import_object(token, sessionOpt, crl_tmpl, crlsize); if (object && token->cache) { nssTokenObjectCache_ImportObject(token->cache, object, crlobjc, crl_tmpl, crlsize); } return object; } NSS_IMPLEMENT nssCryptokiObject ** nssToken_FindCRLsBySubject( NSSToken *token, nssSession *sessionOpt, NSSDER *subject, nssTokenSearchType searchType, PRUint32 maximumOpt, PRStatus *statusOpt) { CK_OBJECT_CLASS crlobjc = CKO_NSS_CRL; CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE crlobj_template[3]; CK_ULONG crlobj_size; nssCryptokiObject **objects = NULL; nssSession *session = sessionOpt ? sessionOpt : token->defaultSession; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_NO_TOKEN); return objects; } NSS_CK_TEMPLATE_START(crlobj_template, attr, crlobj_size); if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly || searchType == nssTokenSearchType_TokenForced) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_VAR(attr, CKA_CLASS, crlobjc); NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_SUBJECT, subject); NSS_CK_TEMPLATE_FINISH(crlobj_template, attr, crlobj_size); objects = nssToken_FindObjectsByTemplate(token, session, crlobj_template, crlobj_size, maximumOpt, statusOpt); return objects; } NSS_IMPLEMENT PRStatus nssToken_GetCachedObjectAttributes( NSSToken *token, NSSArena *arenaOpt, nssCryptokiObject *object, CK_OBJECT_CLASS objclass, CK_ATTRIBUTE_PTR atemplate, CK_ULONG atlen) { if (!token->cache) { return PR_FAILURE; } return nssTokenObjectCache_GetObjectAttributes(token->cache, arenaOpt, object, objclass, atemplate, atlen); } NSS_IMPLEMENT NSSItem * nssToken_Digest( NSSToken *tok, nssSession *sessionOpt, NSSAlgorithmAndParameters *ap, NSSItem *data, NSSItem *rvOpt, NSSArena *arenaOpt) { CK_RV ckrv; CK_ULONG digestLen; CK_BYTE_PTR digest; NSSItem *rvItem = NULL; void *epv = nssToken_GetCryptokiEPV(tok); nssSession *session = (sessionOpt) ? sessionOpt : tok->defaultSession; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_NO_TOKEN); return rvItem; } nssSession_EnterMonitor(session); ckrv = CKAPI(epv)->C_DigestInit(session->handle, &ap->mechanism); if (ckrv != CKR_OK) { nssSession_ExitMonitor(session); return NULL; } #if 0 /* XXX the standard says this should work, but it doesn't */ ckrv = CKAPI(epv)->C_Digest(session->handle, NULL, 0, NULL, &digestLen); if (ckrv != CKR_OK) { nssSession_ExitMonitor(session); return NULL; } #endif digestLen = 0; /* XXX for now */ digest = NULL; if (rvOpt) { if (rvOpt->size > 0 && rvOpt->size < digestLen) { nssSession_ExitMonitor(session); /* the error should be bad args */ return NULL; } if (rvOpt->data) { digest = rvOpt->data; } digestLen = rvOpt->size; } if (!digest) { digest = (CK_BYTE_PTR)nss_ZAlloc(arenaOpt, digestLen); if (!digest) { nssSession_ExitMonitor(session); return NULL; } } ckrv = CKAPI(epv)->C_Digest(session->handle, (CK_BYTE_PTR)data->data, (CK_ULONG)data->size, (CK_BYTE_PTR)digest, &digestLen); nssSession_ExitMonitor(session); if (ckrv != CKR_OK) { nss_ZFreeIf(digest); return NULL; } if (!rvOpt) { rvItem = nssItem_Create(arenaOpt, NULL, digestLen, (void *)digest); } return rvItem; } NSS_IMPLEMENT PRStatus nssToken_BeginDigest( NSSToken *tok, nssSession *sessionOpt, NSSAlgorithmAndParameters *ap) { CK_RV ckrv; void *epv = nssToken_GetCryptokiEPV(tok); nssSession *session = (sessionOpt) ? sessionOpt : tok->defaultSession; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_NO_TOKEN); return PR_FAILURE; } nssSession_EnterMonitor(session); ckrv = CKAPI(epv)->C_DigestInit(session->handle, &ap->mechanism); nssSession_ExitMonitor(session); return (ckrv == CKR_OK) ? PR_SUCCESS : PR_FAILURE; } NSS_IMPLEMENT PRStatus nssToken_ContinueDigest( NSSToken *tok, nssSession *sessionOpt, NSSItem *item) { CK_RV ckrv; void *epv = nssToken_GetCryptokiEPV(tok); nssSession *session = (sessionOpt) ? sessionOpt : tok->defaultSession; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_NO_TOKEN); return PR_FAILURE; } nssSession_EnterMonitor(session); ckrv = CKAPI(epv)->C_DigestUpdate(session->handle, (CK_BYTE_PTR)item->data, (CK_ULONG)item->size); nssSession_ExitMonitor(session); return (ckrv == CKR_OK) ? PR_SUCCESS : PR_FAILURE; } NSS_IMPLEMENT NSSItem * nssToken_FinishDigest( NSSToken *tok, nssSession *sessionOpt, NSSItem *rvOpt, NSSArena *arenaOpt) { CK_RV ckrv; CK_ULONG digestLen; CK_BYTE_PTR digest; NSSItem *rvItem = NULL; void *epv = nssToken_GetCryptokiEPV(tok); nssSession *session = (sessionOpt) ? sessionOpt : tok->defaultSession; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_NO_TOKEN); return NULL; } nssSession_EnterMonitor(session); ckrv = CKAPI(epv)->C_DigestFinal(session->handle, NULL, &digestLen); if (ckrv != CKR_OK || digestLen == 0) { nssSession_ExitMonitor(session); return NULL; } digest = NULL; if (rvOpt) { if (rvOpt->size > 0 && rvOpt->size < digestLen) { nssSession_ExitMonitor(session); /* the error should be bad args */ return NULL; } if (rvOpt->data) { digest = rvOpt->data; } digestLen = rvOpt->size; } if (!digest) { digest = (CK_BYTE_PTR)nss_ZAlloc(arenaOpt, digestLen); if (!digest) { nssSession_ExitMonitor(session); return NULL; } } ckrv = CKAPI(epv)->C_DigestFinal(session->handle, digest, &digestLen); nssSession_ExitMonitor(session); if (ckrv != CKR_OK) { nss_ZFreeIf(digest); return NULL; } if (!rvOpt) { rvItem = nssItem_Create(arenaOpt, NULL, digestLen, (void *)digest); } return rvItem; } NSS_IMPLEMENT PRBool nssToken_IsPresent( NSSToken *token) { return nssSlot_IsTokenPresent(token->slot); } /* Sigh. The methods to find objects declared above cause problems with * the low-level object cache in the softoken -- the objects are found in * toto, then one wave of GetAttributes is done, then another. Having a * large number of objects causes the cache to be thrashed, as the objects * are gone before there's any chance to ask for their attributes. * So, for now, bringing back traversal methods for certs. This way all of * the cert's attributes can be grabbed immediately after finding it, * increasing the likelihood that the cache takes care of it. */ NSS_IMPLEMENT PRStatus nssToken_TraverseCertificates( NSSToken *token, nssSession *sessionOpt, nssTokenSearchType searchType, PRStatus (*callback)(nssCryptokiObject *instance, void *arg), void *arg) { CK_RV ckrv; CK_ULONG count; CK_OBJECT_HANDLE *objectHandles; CK_ATTRIBUTE_PTR attr; CK_ATTRIBUTE cert_template[2]; CK_ULONG ctsize; NSSArena *arena; PRUint32 arraySize, numHandles; nssCryptokiObject **objects; void *epv = nssToken_GetCryptokiEPV(token); nssSession *session = (sessionOpt) ? sessionOpt : token->defaultSession; /* Don't ask the module to use an invalid session handle. */ if (!session || session->handle == CK_INVALID_SESSION) { PORT_SetError(SEC_ERROR_NO_TOKEN); return PR_FAILURE; } /* template for all certs */ NSS_CK_TEMPLATE_START(cert_template, attr, ctsize); if (searchType == nssTokenSearchType_SessionOnly) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_false); } else if (searchType == nssTokenSearchType_TokenOnly || searchType == nssTokenSearchType_TokenForced) { NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_TOKEN, &g_ck_true); } NSS_CK_SET_ATTRIBUTE_ITEM(attr, CKA_CLASS, &g_ck_class_cert); NSS_CK_TEMPLATE_FINISH(cert_template, attr, ctsize); /* the arena is only for the array of object handles */ arena = nssArena_Create(); if (!arena) { return PR_FAILURE; } arraySize = OBJECT_STACK_SIZE; numHandles = 0; objectHandles = nss_ZNEWARRAY(arena, CK_OBJECT_HANDLE, arraySize); if (!objectHandles) { goto loser; } nssSession_EnterMonitor(session); /* ==== session lock === */ /* Initialize the find with the template */ ckrv = CKAPI(epv)->C_FindObjectsInit(session->handle, cert_template, ctsize); if (ckrv != CKR_OK) { nssSession_ExitMonitor(session); goto loser; } while (PR_TRUE) { /* Issue the find for up to arraySize - numHandles objects */ ckrv = CKAPI(epv)->C_FindObjects(session->handle, objectHandles + numHandles, arraySize - numHandles, &count); if (ckrv != CKR_OK) { nssSession_ExitMonitor(session); goto loser; } /* bump the number of found objects */ numHandles += count; if (numHandles < arraySize) { break; } /* the array is filled, double it and continue */ arraySize *= 2; objectHandles = nss_ZREALLOCARRAY(objectHandles, CK_OBJECT_HANDLE, arraySize); if (!objectHandles) { nssSession_ExitMonitor(session); goto loser; } } ckrv = CKAPI(epv)->C_FindObjectsFinal(session->handle); nssSession_ExitMonitor(session); /* ==== end session lock === */ if (ckrv != CKR_OK) { goto loser; } if (numHandles > 0) { objects = create_objects_from_handles(token, session, objectHandles, numHandles); if (objects) { nssCryptokiObject **op; for (op = objects; *op; op++) { (void)(*callback)(*op, arg); } nss_ZFreeIf(objects); } } nssArena_Destroy(arena); return PR_SUCCESS; loser: nssArena_Destroy(arena); return PR_FAILURE; } NSS_IMPLEMENT PRBool nssToken_IsPrivateKeyAvailable( NSSToken *token, NSSCertificate *c, nssCryptokiObject *instance) { CK_OBJECT_CLASS theClass; if (token == NULL) return PR_FALSE; if (c == NULL) return PR_FALSE; theClass = CKO_PRIVATE_KEY; if (!nssSlot_IsLoggedIn(token->slot)) { theClass = CKO_PUBLIC_KEY; } if (PK11_MatchItem(token->pk11slot, instance->handle, theClass) != CK_INVALID_HANDLE) { return PR_TRUE; } return PR_FALSE; }
{ "pile_set_name": "Github" }
<?php /* * Copyright 2014 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ class Google_Service_Replicapool_ReplicasDeleteRequest extends Google_Model { public $abandonInstance; public function setAbandonInstance($abandonInstance) { $this->abandonInstance = $abandonInstance; } public function getAbandonInstance() { return $this->abandonInstance; } }
{ "pile_set_name": "Github" }
/* * Generated by class-dump 3.3.4 (64 bit). * * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard. */ #import "NSObject.h" #import "NSCoding-Protocol.h" @class NSDictionary, NSString; // Not exported @interface SKBitmapFont : NSObject <NSCoding> { NSString *_fontName; NSString *_filePath; double _lineHeight; double _baseLine; NSDictionary *_characterSprites; NSDictionary *_characterAdvances; NSDictionary *_characterKerning; BOOL _internal; NSString *_fileName; } + (id)fontWithTexture:(id)arg1 fontDataString:(id)arg2; + (id)fontForFileNamed:(id)arg1; + (id)_fontForFileNamed:(id)arg1; - (void).cxx_destruct; - (double)kerningForCharacterNamed:(id)arg1 followedBy:(id)arg2; - (double)advanceForCharacterNamed:(id)arg1; - (double)lineHeight; - (id)spriteForCharacterNamed:(id)arg1; - (BOOL)loadFontWithTexture:(id)arg1 fontDataString:(id)arg2; - (void)encodeWithCoder:(id)arg1; - (id)initWithCoder:(id)arg1; - (id)init; - (id)fontName; @end
{ "pile_set_name": "Github" }
<Canvas> <Kind>42</Kind> <Name>BgSettings</Name> <IsMinified>1</IsMinified> <XPosition>1.000000000</XPosition> <YPosition>118.000000000</YPosition> </Canvas> <Widget> <Kind>2</Kind> <Name>GRAD</Name> <Value>0</Value> </Widget> <Widget> <Kind>2</Kind> <Name>BAR GRAD</Name> <Value>0</Value> </Widget> <Widget> <Kind>2</Kind> <Name>WASH GRAD</Name> <Value>0</Value> </Widget> <Widget> <Kind>4</Kind> <Name>EXPONENT</Name> <Value>1.000000000</Value> </Widget> <Widget> <Kind>4</Kind> <Name>HUE</Name> <Value>0.000000000</Value> </Widget> <Widget> <Kind>4</Kind> <Name>SAT</Name> <Value>0.000000000</Value> </Widget> <Widget> <Kind>4</Kind> <Name>BRI</Name> <Value>0.000000000</Value> </Widget> <Widget> <Kind>4</Kind> <Name>HUE2</Name> <Value>255.000000000</Value> </Widget> <Widget> <Kind>4</Kind> <Name>SAT2</Name> <Value>99.236457825</Value> </Widget> <Widget> <Kind>4</Kind> <Name>BRI2</Name> <Value>255.000000000</Value> </Widget>
{ "pile_set_name": "Github" }
1 00:00:00,280 --> 00:00:01,330 In the last video, we gave 2 00:00:01,570 --> 00:00:03,540 a mathematical definition of how 3 00:00:03,700 --> 00:00:04,990 to represent or how to 4 00:00:05,090 --> 00:00:07,160 compute the hypotheses used by Neural Network. 5 00:00:08,420 --> 00:00:09,620 In this video, I like 6 00:00:09,730 --> 00:00:11,280 show you how to actually 7 00:00:11,450 --> 00:00:14,040 carry out that computation efficiently, and 8 00:00:14,710 --> 00:00:16,050 that is show you a vector rise implementation. 9 00:00:17,660 --> 00:00:18,930 And second, and more importantly, I want 10 00:00:19,100 --> 00:00:21,110 to start giving you intuition about 11 00:00:21,390 --> 00:00:22,590 why these neural network representations 12 00:00:23,360 --> 00:00:24,640 might be a good idea and how 13 00:00:25,010 --> 00:00:27,290 they can help us to learn complex nonlinear hypotheses. 14 00:00:28,970 --> 00:00:29,880 Consider this neural network. 15 00:00:30,520 --> 00:00:31,720 Previously we said that 16 00:00:32,010 --> 00:00:33,070 the sequence of steps that we 17 00:00:33,170 --> 00:00:34,090 need in order to compute 18 00:00:34,650 --> 00:00:35,850 the output of a hypotheses 19 00:00:36,320 --> 00:00:37,780 is these equations given on 20 00:00:37,950 --> 00:00:38,770 the left where we compute 21 00:00:39,540 --> 00:00:41,330 the activation values of the 22 00:00:41,450 --> 00:00:43,220 three hidden uses and then 23 00:00:43,420 --> 00:00:44,580 we use those to compute the 24 00:00:44,650 --> 00:00:45,710 final output of our hypotheses 25 00:00:46,680 --> 00:00:48,410 h of x. Now, I'm going 26 00:00:48,480 --> 00:00:50,200 to define a few extra terms. 27 00:00:50,570 --> 00:00:52,210 So, this term that I'm 28 00:00:52,410 --> 00:00:54,090 underlining here, I'm going to 29 00:00:54,180 --> 00:00:55,560 define that to be 30 00:00:56,230 --> 00:00:58,410 z superscript 2 subscript 1. 31 00:00:58,790 --> 00:00:59,830 So that we have that 32 00:01:00,650 --> 00:01:02,310 a(2)1, which is this 33 00:01:02,470 --> 00:01:03,930 term is equal to 34 00:01:04,170 --> 00:01:06,020 g of z to 1. 35 00:01:06,130 --> 00:01:08,100 And by the 36 00:01:08,180 --> 00:01:09,750 way, these superscript 2, you 37 00:01:10,570 --> 00:01:11,580 know, what that means is that 38 00:01:11,870 --> 00:01:12,960 the z2 and this a2 39 00:01:13,080 --> 00:01:14,140 as well, the superscript 40 00:01:14,840 --> 00:01:16,450 2 in parentheses means that these 41 00:01:16,740 --> 00:01:18,330 are values associated with layer 42 00:01:18,570 --> 00:01:19,810 2, that is with the hidden 43 00:01:20,100 --> 00:01:21,390 layer in the neural network. 44 00:01:22,820 --> 00:01:25,200 Now this term here 45 00:01:25,990 --> 00:01:27,640 I'm going to similarly define as 46 00:01:29,530 --> 00:01:30,140 z(2)2. 47 00:01:30,490 --> 00:01:31,860 And finally, this last 48 00:01:32,170 --> 00:01:33,100 term here that I'm underlining, 49 00:01:34,160 --> 00:01:37,040 let me define that as z(2)3. 50 00:01:37,090 --> 00:01:38,710 So that similarly we have a(2)3 51 00:01:38,850 --> 00:01:43,200 equals g of 52 00:01:44,990 --> 00:01:45,360 z(2)3. 53 00:01:45,480 --> 00:01:46,760 So these z values are just 54 00:01:47,290 --> 00:01:48,940 a linear combination, a weighted 55 00:01:49,360 --> 00:01:51,200 linear combination, of the 56 00:01:51,490 --> 00:01:52,800 input values x0, x1, 57 00:01:53,060 --> 00:01:55,350 x2, x3 that go into a particular neuron. 58 00:01:57,090 --> 00:01:58,260 Now if you look at 59 00:01:58,900 --> 00:02:00,470 this block of numbers, 60 00:02:01,990 --> 00:02:03,310 you may notice that that block 61 00:02:03,490 --> 00:02:05,880 of numbers corresponds suspiciously similar 62 00:02:06,950 --> 00:02:08,330 to the matrix vector 63 00:02:08,800 --> 00:02:10,260 operation, matrix vector multiplication 64 00:02:11,070 --> 00:02:12,710 of x1 times the 65 00:02:12,790 --> 00:02:14,840 vector x. Using this observation 66 00:02:15,580 --> 00:02:18,730 we're going to be able to vectorize this computation 67 00:02:19,700 --> 00:02:20,280 of the neural network. 68 00:02:21,470 --> 00:02:23,510 Concretely, let's define the 69 00:02:23,680 --> 00:02:24,810 feature vector x as usual 70 00:02:25,290 --> 00:02:27,020 to be the vector of x0, x1, 71 00:02:27,260 --> 00:02:28,550 x2, x3 where x0 72 00:02:29,010 --> 00:02:30,280 as usual is always equal 73 00:02:30,610 --> 00:02:31,860 1 and that defines 74 00:02:32,390 --> 00:02:33,420 z2 to be the vector 75 00:02:34,360 --> 00:02:37,250 of these z-values, you know, of z(2)1 z(2)2, z(2)3. 76 00:02:38,560 --> 00:02:40,210 And notice that, there, z2 this 77 00:02:40,440 --> 00:02:42,500 is a three dimensional vector. 78 00:02:43,910 --> 00:02:47,200 We can now vectorize the computation 79 00:02:48,270 --> 00:02:48,860 of a(2)1, a(2)2, a(2)3 as follows. 80 00:02:49,490 --> 00:02:50,690 We can just write this in two steps. 81 00:02:51,500 --> 00:02:53,400 We can compute z2 as theta 82 00:02:53,950 --> 00:02:55,490 1 times x and that 83 00:02:55,790 --> 00:02:57,020 would give us this vector z2; 84 00:02:57,400 --> 00:02:59,360 and then a2 is 85 00:02:59,860 --> 00:03:02,180 g of z2 and just 86 00:03:02,440 --> 00:03:03,860 to be clear z2 here, This 87 00:03:04,200 --> 00:03:05,880 is a three-dimensional vector and 88 00:03:06,060 --> 00:03:08,150 a2 is also a three-dimensional 89 00:03:08,810 --> 00:03:10,410 vector and thus this 90 00:03:10,690 --> 00:03:12,680 activation g. This applies the 91 00:03:12,950 --> 00:03:15,290 sigmoid function element-wise to each 92 00:03:15,550 --> 00:03:18,290 of the z2's elements. And 93 00:03:18,380 --> 00:03:19,270 by the way, to make our notation 94 00:03:19,950 --> 00:03:21,260 a little more consistent with 95 00:03:21,440 --> 00:03:23,330 what we'll do later, in this 96 00:03:23,590 --> 00:03:24,600 input layer we have the 97 00:03:24,670 --> 00:03:25,840 inputs x, but we 98 00:03:25,960 --> 00:03:26,950 can also thing it is 99 00:03:27,300 --> 00:03:29,270 as in activations of the first layers. 100 00:03:29,680 --> 00:03:30,430 So, if I defined a1 to 101 00:03:30,470 --> 00:03:32,510 be equal to x. So, 102 00:03:32,660 --> 00:03:34,270 the a1 is vector, I can 103 00:03:34,500 --> 00:03:35,520 now take this x here 104 00:03:36,230 --> 00:03:38,850 and replace this with z2 equals theta1 105 00:03:39,570 --> 00:03:40,680 times a1 just by defining 106 00:03:41,410 --> 00:03:43,350 a1 to be activations in my input layer. 107 00:03:44,990 --> 00:03:46,000 Now, with what I've written 108 00:03:46,280 --> 00:03:47,500 so far I've now gotten 109 00:03:47,900 --> 00:03:49,940 myself the values for a1, 110 00:03:50,820 --> 00:03:52,690 a2, a3, and really 111 00:03:52,780 --> 00:03:53,980 I should put the 112 00:03:54,290 --> 00:03:55,600 superscripts there as well. 113 00:03:56,430 --> 00:03:57,530 But I need one more 114 00:03:57,940 --> 00:03:59,810 value, which is I also want this a(0)2 115 00:04:00,050 --> 00:04:02,050 and that corresponds to 116 00:04:02,250 --> 00:04:04,350 a bias unit in the 117 00:04:04,550 --> 00:04:06,420 hidden layer that goes to the output there. 118 00:04:06,990 --> 00:04:07,780 Of course, there was a 119 00:04:07,810 --> 00:04:08,850 bias unit here too that, 120 00:04:09,000 --> 00:04:10,060 you know, it just didn't draw 121 00:04:10,270 --> 00:04:11,820 under here but to 122 00:04:11,970 --> 00:04:13,100 take care of this extra bias unit, 123 00:04:13,870 --> 00:04:15,650 what we're going to do is add 124 00:04:16,320 --> 00:04:18,720 an extra a0 superscript 2, 125 00:04:18,890 --> 00:04:20,870 that's equal to one, and after 126 00:04:21,010 --> 00:04:21,990 taking this step we now have 127 00:04:22,290 --> 00:04:23,860 that a2 is going to 128 00:04:24,010 --> 00:04:25,390 be a four dimensional feature 129 00:04:25,690 --> 00:04:26,820 vector because we just added 130 00:04:27,300 --> 00:04:28,490 this extra, you know, 131 00:04:28,620 --> 00:04:30,260 a0 which is equal to 132 00:04:30,500 --> 00:04:31,700 1 corresponding to the bias unit 133 00:04:32,080 --> 00:04:33,550 in the hidden layer. And finally, 134 00:04:35,080 --> 00:04:37,620 to compute the actual 135 00:04:38,070 --> 00:04:40,100 value output of our hypotheses, we 136 00:04:40,250 --> 00:04:41,190 then simply need to compute 137 00:04:42,470 --> 00:04:44,980 z3. So z3 is 138 00:04:45,350 --> 00:04:47,940 equal to this term here that I'm just underlining. 139 00:04:48,800 --> 00:04:51,450 This inner term there is z3. 140 00:04:53,980 --> 00:04:55,160 And z3 is stated 141 00:04:55,500 --> 00:04:57,120 2 times a2 and finally 142 00:04:57,810 --> 00:04:59,560 my hypotheses output h of x which 143 00:04:59,750 --> 00:05:01,210 is a3 that is 144 00:05:01,360 --> 00:05:03,910 the activation of my 145 00:05:04,750 --> 00:05:06,040 one and only unit in 146 00:05:06,290 --> 00:05:09,500 the output layer. So, that's just the real number. You can write it as a3 147 00:05:10,050 --> 00:05:12,390 or as a(3)1 and that's g of z3. 148 00:05:13,240 --> 00:05:15,020 This process of computing h of x 149 00:05:15,940 --> 00:05:18,110 is also called forward propagation 150 00:05:19,130 --> 00:05:20,440 and is called that because we 151 00:05:20,550 --> 00:05:21,310 start of with the activations 152 00:05:22,010 --> 00:05:24,400 of the input-units and then 153 00:05:24,940 --> 00:05:26,770 we sort of forward-propagate that to the 154 00:05:26,860 --> 00:05:29,390 hidden layer and compute the activations of the 155 00:05:29,580 --> 00:05:30,400 hidden layer and then we 156 00:05:30,540 --> 00:05:32,040 sort of forward propagate that 157 00:05:32,760 --> 00:05:36,270 and compute the activations of 158 00:05:37,480 --> 00:05:39,170 the output layer, but this process of computing the activations from the input then 159 00:05:39,290 --> 00:05:40,400 the hidden then the output layer, 160 00:05:40,940 --> 00:05:42,030 and that's also called forward propagation 161 00:05:43,320 --> 00:05:44,150 and what we just did is 162 00:05:44,310 --> 00:05:45,370 we just worked out a vector 163 00:05:45,740 --> 00:05:47,140 wise implementation of this 164 00:05:47,280 --> 00:05:48,890 procedure. So, if you 165 00:05:48,970 --> 00:05:50,260 implement it using these equations 166 00:05:50,800 --> 00:05:51,740 that we have on the right, these 167 00:05:51,850 --> 00:05:53,280 would give you an efficient way 168 00:05:53,460 --> 00:05:54,980 or both of the efficient way of 169 00:05:55,120 --> 00:05:56,130 computing h of x. 170 00:05:58,250 --> 00:05:59,860 This forward propagation view also 171 00:06:00,860 --> 00:06:02,270 helps us to understand what 172 00:06:02,550 --> 00:06:03,640 Neural Networks might be doing 173 00:06:04,110 --> 00:06:05,290 and why they might help us to 174 00:06:05,510 --> 00:06:07,170 learn interesting nonlinear hypotheses. 175 00:06:08,670 --> 00:06:09,760 Consider the following neural network 176 00:06:10,500 --> 00:06:11,820 and let's say I cover up 177 00:06:12,040 --> 00:06:13,810 the left path of this picture for now. 178 00:06:14,650 --> 00:06:16,170 If you look at what's left in this picture. 179 00:06:17,030 --> 00:06:18,020 This looks a lot like 180 00:06:18,260 --> 00:06:19,520 logistic regression where what 181 00:06:19,660 --> 00:06:20,570 we're doing is we're using 182 00:06:20,990 --> 00:06:22,000 that note, that's just the 183 00:06:22,130 --> 00:06:23,770 logistic regression unit and we're 184 00:06:24,120 --> 00:06:26,060 using that to make a 185 00:06:26,380 --> 00:06:28,290 prediction h of x. And concretely, 186 00:06:28,440 --> 00:06:30,340 what the hypotheses is outputting 187 00:06:30,710 --> 00:06:31,830 is h of x is going 188 00:06:31,890 --> 00:06:33,760 to be equal to g which 189 00:06:33,980 --> 00:06:38,110 is my sigmoid activation function times theta 0 190 00:06:38,560 --> 00:06:40,450 times a0 is equal 191 00:06:41,270 --> 00:06:43,380 to 1 plus theta 1 192 00:06:45,220 --> 00:06:49,080 plus theta 2 193 00:06:49,260 --> 00:06:52,090 times a2 plus theta 194 00:06:52,830 --> 00:06:55,180 3 times a3 whether 195 00:06:55,370 --> 00:06:56,910 values a1, a2, a3 196 00:06:57,050 --> 00:06:59,860 are those given by these three given units. 197 00:07:01,060 --> 00:07:02,790 Now, to be actually consistent 198 00:07:03,490 --> 00:07:05,000 to my early notation. Actually, we 199 00:07:05,170 --> 00:07:06,360 need to, you know, fill in 200 00:07:06,470 --> 00:07:10,700 these superscript 2's here everywhere 201 00:07:12,260 --> 00:07:13,920 and I also have these 202 00:07:14,160 --> 00:07:16,800 indices 1 there because I 203 00:07:16,930 --> 00:07:20,610 have only one output unit, but if you focus on the blue parts of the notation. 204 00:07:20,930 --> 00:07:21,900 This is, you know, this looks 205 00:07:22,150 --> 00:07:23,680 awfully like the standard logistic 206 00:07:23,870 --> 00:07:25,530 regression model, except that 207 00:07:25,600 --> 00:07:28,060 I now have a capital theta instead of lower case theta. 208 00:07:29,170 --> 00:07:30,690 And what this is 209 00:07:30,850 --> 00:07:32,520 doing is just logistic regression. 210 00:07:33,660 --> 00:07:35,240 But where the features fed into 211 00:07:35,590 --> 00:07:37,250 logistic regression are these 212 00:07:38,200 --> 00:07:40,170 values computed by the hidden layer. 213 00:07:41,340 --> 00:07:42,690 Just to say that again, what 214 00:07:42,910 --> 00:07:44,420 this neural network is doing is 215 00:07:45,130 --> 00:07:47,050 just like logistic regression, except 216 00:07:47,440 --> 00:07:48,900 that rather than using the 217 00:07:49,110 --> 00:07:50,770 original features x1, x2, x3, 218 00:07:52,400 --> 00:07:54,260 is using these new features a1, a2, a3. 219 00:07:54,440 --> 00:07:56,810 Again, we'll put the superscripts 220 00:07:58,130 --> 00:08:00,380 there, you know, to be consistent with the notation. 221 00:08:02,820 --> 00:08:04,610 And the cool thing about this, 222 00:08:05,040 --> 00:08:06,220 is that the features a1, a2, 223 00:08:06,720 --> 00:08:08,310 a3, they themselves are learned 224 00:08:08,760 --> 00:08:09,930 as functions of the input. 225 00:08:10,960 --> 00:08:12,640 Concretely, the function mapping from 226 00:08:13,320 --> 00:08:14,540 layer 1 to layer 2, 227 00:08:14,810 --> 00:08:16,390 that is determined by some 228 00:08:16,750 --> 00:08:18,550 other set of parameters, theta 1. 229 00:08:19,380 --> 00:08:20,210 So it's as if the 230 00:08:20,270 --> 00:08:22,030 neural network, instead of being 231 00:08:22,240 --> 00:08:24,050 constrained to feed the 232 00:08:24,120 --> 00:08:25,760 features x1, x2, x3 to logistic regression. 233 00:08:26,210 --> 00:08:27,440 It gets to 234 00:08:27,720 --> 00:08:29,320 learn its own features, a1, 235 00:08:29,810 --> 00:08:32,010 a2, a3, to feed into the 236 00:08:32,130 --> 00:08:33,950 logistic regression and as 237 00:08:34,650 --> 00:08:36,270 you can imagine depending on 238 00:08:36,360 --> 00:08:37,690 what parameters it chooses for 239 00:08:37,900 --> 00:08:39,880 theta 1. You can learn some pretty interesting 240 00:08:40,390 --> 00:08:42,460 and complex features and therefore 241 00:08:43,780 --> 00:08:44,830 you can end up with a 242 00:08:45,050 --> 00:08:46,650 better hypotheses than if 243 00:08:46,840 --> 00:08:47,870 you were constrained to use 244 00:08:48,020 --> 00:08:50,520 the raw features x1, x2 or x3 or if 245 00:08:50,640 --> 00:08:52,530 you will constrain to say choose the 246 00:08:52,620 --> 00:08:53,730 polynomial terms, you know, 247 00:08:53,920 --> 00:08:55,550 x1, x2, x3, and so on. 248 00:08:55,790 --> 00:08:57,250 But instead, this algorithm has 249 00:08:57,530 --> 00:08:59,130 the flexibility to try 250 00:08:59,420 --> 00:09:01,990 to learn whatever features at once, using 251 00:09:02,680 --> 00:09:03,990 these a1, a2, a3 in 252 00:09:04,110 --> 00:09:05,190 order to feed into this 253 00:09:05,510 --> 00:09:07,830 last unit that's essentially 254 00:09:09,240 --> 00:09:11,920 a logistic regression here. I realized 255 00:09:12,550 --> 00:09:13,970 this example is described as 256 00:09:14,060 --> 00:09:15,500 a somewhat high level and so 257 00:09:15,750 --> 00:09:16,520 I'm not sure if this intuition 258 00:09:17,440 --> 00:09:18,870 of the neural network, you know, having 259 00:09:19,720 --> 00:09:21,420 more complex features will quite 260 00:09:21,630 --> 00:09:23,120 make sense yet, but if 261 00:09:23,210 --> 00:09:24,440 it doesn't yet in the next 262 00:09:24,810 --> 00:09:25,860 two videos I'm going to 263 00:09:25,970 --> 00:09:27,300 go through a specific example 264 00:09:28,250 --> 00:09:29,590 of how a neural network can 265 00:09:29,830 --> 00:09:30,860 use this hidden there to compute 266 00:09:31,250 --> 00:09:32,880 more complex features to feed 267 00:09:33,130 --> 00:09:34,520 into this final output layer 268 00:09:35,060 --> 00:09:37,100 and how that can learn more complex hypotheses. 269 00:09:37,920 --> 00:09:39,120 So, in case what I'm 270 00:09:39,180 --> 00:09:40,090 saying here doesn't quite make 271 00:09:40,230 --> 00:09:41,650 sense, stick with me 272 00:09:41,810 --> 00:09:42,960 for the next two videos and 273 00:09:43,190 --> 00:09:44,370 hopefully out there working through 274 00:09:44,580 --> 00:09:46,690 those examples this explanation will 275 00:09:47,030 --> 00:09:48,640 make a little bit more sense. 276 00:09:49,020 --> 00:09:49,740 But just the point O. You 277 00:09:49,820 --> 00:09:51,120 can have neural networks with 278 00:09:51,470 --> 00:09:52,990 other types of diagrams as 279 00:09:53,080 --> 00:09:54,270 well, and the way that 280 00:09:54,450 --> 00:09:58,000 neural networks are connected, that's called the architecture. 281 00:09:58,390 --> 00:10:00,150 So the term architecture refers to 282 00:10:00,490 --> 00:10:02,380 how the different neurons are connected to each other. 283 00:10:03,220 --> 00:10:04,180 This is an example 284 00:10:04,840 --> 00:10:06,300 of a different neural network architecture 285 00:10:07,480 --> 00:10:08,750 and once again you may 286 00:10:09,260 --> 00:10:10,770 be able to get this intuition of 287 00:10:10,940 --> 00:10:12,180 how the second layer, 288 00:10:12,900 --> 00:10:14,120 here we have three heading units 289 00:10:14,910 --> 00:10:16,200 that are computing some complex 290 00:10:16,660 --> 00:10:17,900 function maybe of the 291 00:10:17,990 --> 00:10:19,530 input layer, and then the 292 00:10:19,730 --> 00:10:20,750 third layer can take the 293 00:10:20,840 --> 00:10:22,260 second layer's features and compute 294 00:10:22,550 --> 00:10:24,070 even more complex features in layer three 295 00:10:24,980 --> 00:10:25,880 so that by the time you get 296 00:10:25,960 --> 00:10:27,160 to the output layer, layer four, 297 00:10:27,900 --> 00:10:29,130 you can have even more 298 00:10:29,370 --> 00:10:30,690 complex features of what 299 00:10:30,860 --> 00:10:32,040 you are able to compute in 300 00:10:32,280 --> 00:10:34,710 layer three and so get very interesting nonlinear hypotheses. 301 00:10:36,730 --> 00:10:37,580 By the way, in a network 302 00:10:37,810 --> 00:10:38,980 like this, layer one, this is 303 00:10:39,130 --> 00:10:40,670 called an input layer. Layer four 304 00:10:41,360 --> 00:10:43,170 is still our output layer, and 305 00:10:43,340 --> 00:10:45,040 this network has two hidden layers. 306 00:10:46,000 --> 00:10:47,440 So anything that's not an 307 00:10:48,000 --> 00:10:49,020 input layer or an output 308 00:10:49,340 --> 00:10:50,590 layer is called a hidden layer. 309 00:10:53,390 --> 00:10:54,470 So, hopefully from this video 310 00:10:54,760 --> 00:10:55,840 you've gotten a sense of 311 00:10:56,140 --> 00:10:58,360 how the feed forward propagation step 312 00:10:58,830 --> 00:11:00,230 in a neural network works where you 313 00:11:00,390 --> 00:11:01,670 start from the activations of 314 00:11:01,720 --> 00:11:03,150 the input layer and forward 315 00:11:03,450 --> 00:11:04,480 propagate that to the 316 00:11:04,570 --> 00:11:05,560 first hidden layer, then the second 317 00:11:06,070 --> 00:11:08,200 hidden layer, and then finally the output layer. 318 00:11:08,990 --> 00:11:10,250 And you also saw how 319 00:11:10,560 --> 00:11:12,010 we can vectorize that computation. 320 00:11:13,660 --> 00:11:14,830 In the next, I realized 321 00:11:15,240 --> 00:11:16,680 that some of the intuitions in this 322 00:11:16,850 --> 00:11:19,220 video of how, you know, other certain 323 00:11:19,550 --> 00:11:22,570 layers are computing complex features of the early layers. 324 00:11:22,910 --> 00:11:23,540 I realized some of that intuition 325 00:11:24,190 --> 00:11:26,660 may be still slightly abstract and kind of a high level. 326 00:11:27,450 --> 00:11:28,240 And so what I would like 327 00:11:28,350 --> 00:11:29,460 to do in the two videos 328 00:11:30,210 --> 00:11:31,540 is work through a detailed example 329 00:11:32,510 --> 00:11:33,810 of how a neural network can 330 00:11:33,960 --> 00:11:35,740 be used to compute nonlinear 331 00:11:36,710 --> 00:11:38,030 functions of the input and 332 00:11:38,330 --> 00:11:39,450 hope that will give you a 333 00:11:39,540 --> 00:11:40,860 good sense of the sorts of 334 00:11:41,010 --> 00:11:44,630 complex nonlinear hypotheses we can get out of Neural Networks.
{ "pile_set_name": "Github" }
/* * Copyright 2014 astamuse company,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. * */ package com.astamuse.asta4d.util.annotation; public @interface AnnotatedProperty { String name() default ""; }
{ "pile_set_name": "Github" }
# Copyright 2012 Citrix Systems, Inc. Licensed under the # Apache License, Version 2.0 (the "License"); you may not use this # file except in compliance with the License. Citrix Systems, Inc. # reserves all rights not expressly granted by 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. # # Automatically generated by addcopyright.py at 04/03/2012 SET foreign_key_checks = 0; -- -- Schema upgrade from 2.0 to 2.1 -- CREATE TABLE `cloud`.`cluster` ( `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id', `name` varchar(255) NOT NULL COMMENT 'name for the cluster', `pod_id` bigint unsigned NOT NULL COMMENT 'pod id', `data_center_id` bigint unsigned NOT NULL COMMENT 'data center id', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`ext_lun_alloc` ( `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id', `size` bigint unsigned NOT NULL COMMENT 'virtual size', `portal` varchar(255) NOT NULL COMMENT 'ip or host name to the storage server', `target_iqn` varchar(255) NOT NULL COMMENT 'target iqn', `data_center_id` bigint unsigned NOT NULL COMMENT 'data center id this belongs to', `lun` int NOT NULL COMMENT 'lun', `taken` datetime COMMENT 'time occupied', `volume_id` bigint unsigned COMMENT 'vm taking this lun', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`ext_lun_details` ( `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id', `ext_lun_id` bigint unsigned NOT NULL COMMENT 'lun id', `tag` varchar(255) COMMENT 'tags associated with this vm', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`storage_pool_details` ( `id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id', `pool_id` bigint unsigned NOT NULL COMMENT 'pool the detail is related to', `name` varchar(255) NOT NULL COMMENT 'name of the detail', `value` varchar(255) NOT NULL COMMENT 'value of the detail', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`network_group` ( `id` bigint unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, `description` varchar(4096) NULL, `domain_id` bigint unsigned NOT NULL, `account_id` bigint unsigned NOT NULL, `account_name` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`network_ingress_rule` ( `id` bigint unsigned NOT NULL auto_increment, `network_group_id` bigint unsigned NOT NULL, `start_port` varchar(10) default NULL, `end_port` varchar(10) default NULL, `protocol` varchar(16) NOT NULL default 'TCP', `allowed_network_id` bigint unsigned, `allowed_network_group` varchar(255) COMMENT 'data duplicated from network_group table to avoid lots of joins when listing rules (the name of the group should be displayed rather than just id)', `allowed_net_grp_acct` varchar(100) COMMENT 'data duplicated from network_group table to avoid lots of joins when listing rules (the name of the group owner should be displayed)', `allowed_ip_cidr` varchar(44), `create_status` varchar(32) COMMENT 'rule creation status', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`network_group_vm_map` ( `id` bigint unsigned NOT NULL auto_increment, `network_group_id` bigint unsigned NOT NULL, `instance_id` bigint unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_nwgrp_work` ( `id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id', `instance_id` bigint unsigned NOT NULL COMMENT 'vm instance that needs rules to be synced.', `mgmt_server_id` bigint unsigned COMMENT 'management server that has taken up the work of doing rule sync', `created` datetime NOT NULL COMMENT 'time the entry was requested', `taken` datetime COMMENT 'time it was taken by the management server', `step` varchar(32) NOT NULL COMMENT 'Step in the work', `seq_no` bigint unsigned COMMENT 'seq number to be sent to agent, uniquely identifies ruleset update', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_vm_ruleset_log` ( `id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id', `instance_id` bigint unsigned NOT NULL COMMENT 'vm instance that needs rules to be synced.', `created` datetime NOT NULL COMMENT 'time the entry was requested', `logsequence` bigint unsigned COMMENT 'seq number to be sent to agent, uniquely identifies ruleset update', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`account_vlan_map` ( `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT, `account_id` bigint unsigned NOT NULL COMMENT 'account id. foreign key to account table', `vlan_db_id` bigint unsigned NOT NULL COMMENT 'database id of vlan. foreign key to vlan table', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_dc_link_local_ip_address_alloc` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary key', `ip_address` varchar(15) NOT NULL COMMENT 'ip address', `data_center_id` bigint unsigned NOT NULL COMMENT 'data center it belongs to', `pod_id` bigint unsigned NOT NULL COMMENT 'pod it belongs to', `instance_id` bigint unsigned NULL COMMENT 'instance id', `taken` datetime COMMENT 'Date taken', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `cloud`.`op_lock` MODIFY COLUMN `key` varchar(128) NOT NULL UNIQUE; -- add UNIQUE constraint ALTER TABLE `cloud`.`op_lock` MODIFY COLUMN `thread` varchar(255) NOT NULL; -- change from varchar(256) to varchar(255) ALTER TABLE `cloud`.`volumes` DROP COLUMN `name_label`; ALTER TABLE `cloud`.`volumes` DROP COLUMN `template_name`; ALTER TABLE `cloud`.`volumes` ADD COLUMN `pool_type` varchar(64); ALTER TABLE `cloud`.`volumes` ADD COLUMN `recreatable` tinyint(1) unsigned NOT NULL DEFAULT 0; ALTER TABLE `cloud`.`volumes` ADD COLUMN `device_id` bigint unsigned NULL; -- -- after we have data migrated, we can then enforce this at postprocess-20to21.sql -- ALTER TABLE `cloud`.`volumes` MODIFY COLUMN `disk_offering_id` bigint unsigned NOT NULL; -- add NOT NULL constraint ALTER TABLE `cloud`.`vlan` DROP COLUMN `vlan_name`; ALTER TABLE `cloud`.`host` ADD COLUMN `cluster_id` bigint unsigned; -- -- enforced in postporcess-20to21.sql ALTER TABLE `cloud`.`host_pod_ref` ADD COLUMN `gateway` varchar(255); -- need to migrage data with user input ALTER TABLE `cloud`.`service_offering` ADD COLUMN `recreatable` tinyint(1) unsigned NOT NULL DEFAULT 0; ALTER TABLE `cloud`.`service_offering` ADD COLUMN `tags` varchar(255); ALTER TABLE `cloud`.`user_vm` MODIFY COLUMN `domain_router_id` bigint unsigned; -- change from NOT NULL to NULL ALTER TABLE `cloud`.`event` ADD COLUMN `state` varchar(32) NOT NULL DEFAULT 'Completed'; ALTER TABLE `cloud`.`event` ADD COLUMN `start_id` bigint unsigned NOT NULL DEFAULT 0; ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `tags` varchar(4096); ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `created` datetime; -- will fill it with the oldest time in old data base ALTER TABLE `cloud`.`storage_pool` ADD COLUMN `cluster_id` bigint unsigned; -- need to setup default cluster for pods ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `last_host_id` bigint unsigned; ALTER TABLE `cloud`.`console_proxy` MODIFY COLUMN `gateway` varchar(15); -- remove NOT NULL constraint ALTER TABLE `cloud`.`console_proxy` MODIFY COLUMN `public_netmask` varchar(15); -- remove NOT NULL constraint ALTER TABLE `cloud`.`console_proxy` ADD COLUMN `guest_mac_address` varchar(17); -- NOT NULL UNIQUE constraint will be added in postprocess ALTER TABLE `cloud`.`console_proxy` ADD COLUMN `guest_ip_address` varchar(15); ALTER TABLE `cloud`.`console_proxy` ADD COLUMN `guest_netmask` varchar(15); ALTER TABLE `cloud`.`secondary_storage_vm` MODIFY COLUMN `gateway` varchar(15); -- remove NOT NULL constraint ALTER TABLE `cloud`.`secondary_storage_vm` MODIFY COLUMN `public_netmask` varchar(15); -- remove NOT NULL constrait ALTER TABLE `cloud`.`secondary_storage_vm` ADD COLUMN `guest_mac_address` varchar(17); -- NOT NULL unique constrait will be added in postprocess ALTER TABLE `cloud`.`secondary_storage_vm` ADD COLUMN `guest_ip_address` varchar(15) UNIQUE; ALTER TABLE `cloud`.`secondary_storage_vm` ADD COLUMN `guest_netmask` varchar(15); CREATE TABLE `cloud`.`service_offering_21` ( `id` bigint unsigned NOT NULL, `cpu` int(10) unsigned NOT NULL COMMENT '# of cores', `speed` int(10) unsigned NOT NULL COMMENT 'speed per core in mhz', `ram_size` bigint unsigned NOT NULL, `nw_rate` smallint unsigned default 200 COMMENT 'network rate throttle mbits/s', `mc_rate` smallint unsigned default 10 COMMENT 'mcast rate throttle mbits/s', `ha_enabled` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Enable HA', `guest_ip_type` varchar(255) NOT NULL DEFAULT 'Virtualized' COMMENT 'Type of guest network -- direct or virtualized', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`disk_offering_21` ( `id` bigint unsigned NOT NULL auto_increment, `domain_id` bigint unsigned, `name` varchar(255) NOT NULL, `display_text` varchar(4096) NULL COMMENT 'Description text set by the admin for display purpose only', `disk_size` bigint unsigned NOT NULL COMMENT 'disk space in mbs', `mirrored` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT 'Enable mirroring?', `type` varchar(32) COMMENT 'inheritted by who?', `tags` varchar(4096) COMMENT 'comma separated tags about the disk_offering', `recreatable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'The root disk is always recreatable', `use_local_storage` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Indicates whether local storage pools should be used', `unique_name` varchar(32) UNIQUE COMMENT 'unique name', `removed` datetime COMMENT 'date removed', `created` datetime COMMENT 'date the disk offering was created', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
{ "pile_set_name": "Github" }
import random def make(): # prevent circular imports from .common import db, action from py4web.utils.populate import populate if db(db.auth_user).count() == 1: populate(db.auth_user, 10, contents={"is_active": True}) populate(db.feed_item, 100, contents={"is_active": True, "parent_id": 0}) # populate(db.item_like, 1000, contents={"is_active": True}) ids = [r.id for r in db(db.auth_user).select() if r.id > 1] for k in ids[:3]: db.friend_request.insert(to_user=1, from_user=k, status="accepted") db.friend_request.insert(to_user=k, from_user=1, status="accepted") for k in ids[3:6]: db.friend_request.insert(to_user=1, from_user=k, status="pending") for k in ids[6:9]: db.friend_request.insert(to_user=1, from_user=k, status="rejected")
{ "pile_set_name": "Github" }
/* * re_*exec and friends - match REs * * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved. * * Development of this software was funded, in part, by Cray Research Inc., * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics * Corporation, none of whom are responsible for the results. The author * thanks all of them. * * Redistribution and use in source and binary forms -- with or without * modification -- are permitted for any purpose, provided that * redistributions in source form retain this entire copyright notice and * indicate the origin and nature of any modifications. * * I'd appreciate being given credit for this package in the documentation of * software which uses it, but that is not a requirement. * * THIS SOFTWARE IS PROVIDED ``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 * HENRY SPENCER 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 "regguts.h" /* * Lazy-DFA representation. */ struct arcp { /* "pointer" to an outarc */ struct sset *ss; color co; }; struct sset { /* state set */ unsigned *states; /* pointer to bitvector */ unsigned hash; /* hash of bitvector */ #define HASH(bv, nw) (((nw) == 1) ? *(bv) : hash(bv, nw)) #define HIT(h,bv,ss,nw) ((ss)->hash == (h) && ((nw) == 1 || \ memcmp(VS(bv), VS((ss)->states), (nw)*sizeof(unsigned)) == 0)) int flags; #define STARTER 01 /* the initial state set */ #define POSTSTATE 02 /* includes the goal state */ #define LOCKED 04 /* locked in cache */ #define NOPROGRESS 010 /* zero-progress state set */ struct arcp ins; /* chain of inarcs pointing here */ chr *lastseen; /* last entered on arrival here */ struct sset **outs; /* outarc vector indexed by color */ struct arcp *inchain; /* chain-pointer vector for outarcs */ }; struct dfa { int nssets; /* size of cache */ int nssused; /* how many entries occupied yet */ int nstates; /* number of states */ int ncolors; /* length of outarc and inchain vectors */ int wordsper; /* length of state-set bitvectors */ struct sset *ssets; /* state-set cache */ unsigned *statesarea; /* bitvector storage */ unsigned *work; /* pointer to work area within statesarea */ struct sset **outsarea; /* outarc-vector storage */ struct arcp *incarea; /* inchain storage */ struct cnfa *cnfa; struct colormap *cm; chr *lastpost; /* location of last cache-flushed success */ chr *lastnopr; /* location of last cache-flushed NOPROGRESS */ struct sset *search; /* replacement-search-pointer memory */ int cptsmalloced; /* were the areas individually malloced? */ char *mallocarea; /* self, or master malloced area, or NULL */ }; #define WORK 1 /* number of work bitvectors needed */ /* * Setup for non-malloc allocation for small cases. */ #define FEWSTATES 20 /* must be less than UBITS */ #define FEWCOLORS 15 struct smalldfa { struct dfa dfa; struct sset ssets[FEWSTATES*2]; unsigned statesarea[FEWSTATES*2 + WORK]; struct sset *outsarea[FEWSTATES*2 * FEWCOLORS]; struct arcp incarea[FEWSTATES*2 * FEWCOLORS]; }; #define DOMALLOC ((struct smalldfa *)NULL) /* force malloc */ /* * Internal variables, bundled for easy passing around. */ struct vars { regex_t *re; struct guts *g; int eflags; /* copies of arguments */ size_t nmatch; regmatch_t *pmatch; rm_detail_t *details; chr *start; /* start of string */ chr *stop; /* just past end of string */ int err; /* error code if any (0 none) */ struct dfa **subdfas; /* per-subre DFAs */ struct smalldfa dfa1; struct smalldfa dfa2; }; #define VISERR(vv) ((vv)->err != 0) /* have we seen an error yet? */ #define ISERR() VISERR(v) #define VERR(vv,e) ((vv)->err = ((vv)->err ? (vv)->err : (e))) #define ERR(e) VERR(v, e) /* record an error */ #define NOERR() {if (ISERR()) return v->err;} /* if error seen, return it */ #define OFF(p) ((p) - v->start) #define LOFF(p) ((long)OFF(p)) /* * forward declarations */ /* =====^!^===== begin forwards =====^!^===== */ /* automatically gathered by fwd; do not hand-edit */ /* === regexec.c === */ int exec(regex_t *, const chr *, size_t, rm_detail_t *, size_t, regmatch_t [], int); static struct dfa *getsubdfa(struct vars *, struct subre *); static int simpleFind(struct vars *const, struct cnfa *const, struct colormap *const); static int complicatedFind(struct vars *const, struct cnfa *const, struct colormap *const); static int complicatedFindLoop(struct vars *const, struct cnfa *const, struct colormap *const, struct dfa *const, struct dfa *const, chr **const); static void zapallsubs(regmatch_t *const, const size_t); static void zaptreesubs(struct vars *const, struct subre *const); static void subset(struct vars *const, struct subre *const, chr *const, chr *const); static int cdissect(struct vars *, struct subre *, chr *, chr *); static int ccondissect(struct vars *, struct subre *, chr *, chr *); static int crevcondissect(struct vars *, struct subre *, chr *, chr *); static int cbrdissect(struct vars *, struct subre *, chr *, chr *); static int caltdissect(struct vars *, struct subre *, chr *, chr *); static int citerdissect(struct vars *, struct subre *, chr *, chr *); static int creviterdissect(struct vars *, struct subre *, chr *, chr *); /* === rege_dfa.c === */ static chr *longest(struct vars *const, struct dfa *const, chr *const, chr *const, int *const); static chr *shortest(struct vars *const, struct dfa *const, chr *const, chr *const, chr *const, chr **const, int *const); static chr *lastCold(struct vars *const, struct dfa *const); static struct dfa *newDFA(struct vars *const, struct cnfa *const, struct colormap *const, struct smalldfa *); static void freeDFA(struct dfa *const); static unsigned hash(unsigned *const, const int); static struct sset *initialize(struct vars *const, struct dfa *const, chr *const); static struct sset *miss(struct vars *const, struct dfa *const, struct sset *const, const pcolor, chr *const, chr *const); static int checkLAConstraint(struct vars *const, struct cnfa *const, chr *const, const pcolor); static struct sset *getVacantSS(struct vars *const, struct dfa *const, chr *const, chr *const); static struct sset *pickNextSS(struct vars *const, struct dfa *const, chr *const, chr *const); /* automatically gathered by fwd; do not hand-edit */ /* =====^!^===== end forwards =====^!^===== */ /* - exec - match regular expression ^ int exec(regex_t *, const chr *, size_t, rm_detail_t *, ^ size_t, regmatch_t [], int); */ int exec( regex_t *re, const chr *string, size_t len, rm_detail_t *details, size_t nmatch, regmatch_t pmatch[], int flags) { AllocVars(v); int st, backref; size_t n; size_t i; #define LOCALMAT 20 regmatch_t mat[LOCALMAT]; #define LOCALDFAS 40 struct dfa *subdfas[LOCALDFAS]; /* * Sanity checks. */ if (re == NULL || string == NULL || re->re_magic != REMAGIC) { FreeVars(v); return REG_INVARG; } if (re->re_csize != sizeof(chr)) { FreeVars(v); return REG_MIXED; } /* * Setup. */ v->re = re; v->g = (struct guts *)re->re_guts; if ((v->g->cflags&REG_EXPECT) && details == NULL) { FreeVars(v); return REG_INVARG; } if (v->g->info&REG_UIMPOSSIBLE) { FreeVars(v); return REG_NOMATCH; } backref = (v->g->info&REG_UBACKREF) ? 1 : 0; v->eflags = flags; if (v->g->cflags&REG_NOSUB) { nmatch = 0; /* override client */ } v->nmatch = nmatch; if (backref) { /* * Need work area. */ if (v->g->nsub + 1 <= LOCALMAT) { v->pmatch = mat; } else { v->pmatch = (regmatch_t *) MALLOC((v->g->nsub + 1) * sizeof(regmatch_t)); } if (v->pmatch == NULL) { FreeVars(v); return REG_ESPACE; } v->nmatch = v->g->nsub + 1; } else { v->pmatch = pmatch; } v->details = details; v->start = (chr *)string; v->stop = (chr *)string + len; v->err = 0; assert(v->g->ntree >= 0); n = (size_t) v->g->ntree; if (n <= LOCALDFAS) v->subdfas = subdfas; else v->subdfas = (struct dfa **) MALLOC(n * sizeof(struct dfa *)); if (v->subdfas == NULL) { if (v->pmatch != pmatch && v->pmatch != mat) FREE(v->pmatch); FreeVars(v); return REG_ESPACE; } for (i = 0; i < n; i++) v->subdfas[i] = NULL; /* * Do it. */ assert(v->g->tree != NULL); if (backref) { st = complicatedFind(v, &v->g->tree->cnfa, &v->g->cmap); } else { st = simpleFind(v, &v->g->tree->cnfa, &v->g->cmap); } /* * Copy (portion of) match vector over if necessary. */ if (st == REG_OKAY && v->pmatch != pmatch && nmatch > 0) { zapallsubs(pmatch, nmatch); n = (nmatch < v->nmatch) ? nmatch : v->nmatch; memcpy(VS(pmatch), VS(v->pmatch), n*sizeof(regmatch_t)); } /* * Clean up. */ if (v->pmatch != pmatch && v->pmatch != mat) { FREE(v->pmatch); } n = (size_t) v->g->ntree; for (i = 0; i < n; i++) { if (v->subdfas[i] != NULL) freeDFA(v->subdfas[i]); } if (v->subdfas != subdfas) FREE(v->subdfas); FreeVars(v); return st; } /* - getsubdfa - create or re-fetch the DFA for a subre node * We only need to create the DFA once per overall regex execution. * The DFA will be freed by the cleanup step in exec(). */ static struct dfa * getsubdfa(struct vars * v, struct subre * t) { if (v->subdfas[t->id] == NULL) { v->subdfas[t->id] = newDFA(v, &t->cnfa, &v->g->cmap, DOMALLOC); if (ISERR()) return NULL; } return v->subdfas[t->id]; } /* - simpleFind - find a match for the main NFA (no-complications case) ^ static int simpleFind(struct vars *, struct cnfa *, struct colormap *); */ static int simpleFind( struct vars *const v, struct cnfa *const cnfa, struct colormap *const cm) { struct dfa *s, *d; chr *begin, *end = NULL; chr *cold; chr *open, *close; /* Open and close of range of possible * starts */ int hitend; int shorter = (v->g->tree->flags&SHORTER) ? 1 : 0; /* * First, a shot with the search RE. */ s = newDFA(v, &v->g->search, cm, &v->dfa1); assert(!(ISERR() && s != NULL)); NOERR(); MDEBUG(("\nsearch at %ld\n", LOFF(v->start))); cold = NULL; close = shortest(v, s, v->start, v->start, v->stop, &cold, NULL); freeDFA(s); NOERR(); if (v->g->cflags&REG_EXPECT) { assert(v->details != NULL); if (cold != NULL) { v->details->rm_extend.rm_so = OFF(cold); } else { v->details->rm_extend.rm_so = OFF(v->stop); } v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */ } if (close == NULL) { /* not found */ return REG_NOMATCH; } if (v->nmatch == 0) { /* found, don't need exact location */ return REG_OKAY; } /* * Find starting point and match. */ assert(cold != NULL); open = cold; cold = NULL; MDEBUG(("between %ld and %ld\n", LOFF(open), LOFF(close))); d = newDFA(v, cnfa, cm, &v->dfa1); assert(!(ISERR() && d != NULL)); NOERR(); for (begin = open; begin <= close; begin++) { MDEBUG(("\nfind trying at %ld\n", LOFF(begin))); if (shorter) { end = shortest(v, d, begin, begin, v->stop, NULL, &hitend); } else { end = longest(v, d, begin, v->stop, &hitend); } if (ISERR()) { freeDFA(d); return v->err; } if (hitend && cold == NULL) { cold = begin; } if (end != NULL) { break; /* NOTE BREAK OUT */ } } assert(end != NULL); /* search RE succeeded so loop should */ freeDFA(d); /* * And pin down details. */ assert(v->nmatch > 0); v->pmatch[0].rm_so = OFF(begin); v->pmatch[0].rm_eo = OFF(end); if (v->g->cflags&REG_EXPECT) { if (cold != NULL) { v->details->rm_extend.rm_so = OFF(cold); } else { v->details->rm_extend.rm_so = OFF(v->stop); } v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */ } if (v->nmatch == 1) { /* no need for submatches */ return REG_OKAY; } /* * Find submatches. */ zapallsubs(v->pmatch, v->nmatch); return cdissect(v, v->g->tree, begin, end); } /* - complicatedFind - find a match for the main NFA (with complications) ^ static int complicatedFind(struct vars *, struct cnfa *, struct colormap *); */ static int complicatedFind( struct vars *const v, struct cnfa *const cnfa, struct colormap *const cm) { struct dfa *s, *d; chr *cold = NULL; /* silence gcc 4 warning */ int ret; s = newDFA(v, &v->g->search, cm, &v->dfa1); NOERR(); d = newDFA(v, cnfa, cm, &v->dfa2); if (ISERR()) { assert(d == NULL); freeDFA(s); return v->err; } ret = complicatedFindLoop(v, cnfa, cm, d, s, &cold); freeDFA(d); freeDFA(s); NOERR(); if (v->g->cflags&REG_EXPECT) { assert(v->details != NULL); if (cold != NULL) { v->details->rm_extend.rm_so = OFF(cold); } else { v->details->rm_extend.rm_so = OFF(v->stop); } v->details->rm_extend.rm_eo = OFF(v->stop); /* unknown */ } return ret; } /* - complicatedFindLoop - the heart of complicatedFind ^ static int complicatedFindLoop(struct vars *, struct cnfa *, struct colormap *, ^ struct dfa *, struct dfa *, chr **); */ static int complicatedFindLoop( struct vars *const v, struct cnfa *const cnfa, struct colormap *const cm, struct dfa *const d, struct dfa *const s, chr **const coldp) /* where to put coldstart pointer */ { chr *begin, *end; chr *cold; chr *open, *close; /* Open and close of range of possible * starts */ chr *estart, *estop; int er, hitend; int shorter = v->g->tree->flags&SHORTER; assert(d != NULL && s != NULL); cold = NULL; close = v->start; do { MDEBUG(("\ncsearch at %ld\n", LOFF(close))); close = shortest(v, s, close, close, v->stop, &cold, NULL); if (close == NULL) { break; /* NOTE BREAK */ } assert(cold != NULL); open = cold; cold = NULL; MDEBUG(("cbetween %ld and %ld\n", LOFF(open), LOFF(close))); for (begin = open; begin <= close; begin++) { MDEBUG(("\ncomplicatedFind trying at %ld\n", LOFF(begin))); estart = begin; estop = v->stop; for (;;) { if (shorter) { end = shortest(v, d, begin, estart, estop, NULL, &hitend); } else { end = longest(v, d, begin, estop, &hitend); } if (hitend && cold == NULL) { cold = begin; } if (end == NULL) { break; /* NOTE BREAK OUT */ } MDEBUG(("tentative end %ld\n", LOFF(end))); zapallsubs(v->pmatch, v->nmatch); er = cdissect(v, v->g->tree, begin, end); if (er == REG_OKAY) { if (v->nmatch > 0) { v->pmatch[0].rm_so = OFF(begin); v->pmatch[0].rm_eo = OFF(end); } *coldp = cold; return REG_OKAY; } if (er != REG_NOMATCH) { ERR(er); *coldp = cold; return er; } if ((shorter) ? end == estop : end == begin) { break; } /* * Go around and try again */ if (shorter) { estart = end + 1; } else { estop = end - 1; } } } } while (close < v->stop); *coldp = cold; return REG_NOMATCH; } /* - zapallsubs - initialize all subexpression matches to "no match" ^ static void zapallsubs(regmatch_t *, size_t); */ static void zapallsubs( regmatch_t *const p, const size_t n) { size_t i; for (i = n-1; i > 0; i--) { p[i].rm_so = -1; p[i].rm_eo = -1; } } /* - zaptreesubs - initialize subexpressions within subtree to "no match" ^ static void zaptreesubs(struct vars *, struct subre *); */ static void zaptreesubs( struct vars *const v, struct subre *const t) { if (t->op == '(') { int n = t->subno; assert(n > 0); if ((size_t) n < v->nmatch) { v->pmatch[n].rm_so = -1; v->pmatch[n].rm_eo = -1; } } if (t->left != NULL) { zaptreesubs(v, t->left); } if (t->right != NULL) { zaptreesubs(v, t->right); } } /* - subset - set subexpression match data for a successful subre ^ static void subset(struct vars *, struct subre *, chr *, chr *); */ static void subset( struct vars *const v, struct subre *const sub, chr *const begin, chr *const end) { int n = sub->subno; assert(n > 0); if ((size_t)n >= v->nmatch) { return; } MDEBUG(("setting %d\n", n)); v->pmatch[n].rm_so = OFF(begin); v->pmatch[n].rm_eo = OFF(end); } /* - cdissect - check backrefs and determine subexpression matches * cdissect recursively processes a subre tree to check matching of backrefs * and/or identify submatch boundaries for capture nodes. The proposed match * runs from "begin" to "end" (not including "end"), and we are basically * "dissecting" it to see where the submatches are. * Before calling any level of cdissect, the caller must have run the node's * DFA and found that the proposed substring satisfies the DFA. (We make * the caller do that because in concatenation and iteration nodes, it's * much faster to check all the substrings against the child DFAs before we * recurse.) Also, caller must have cleared subexpression match data via * zaptreesubs (or zapallsubs at the top level). ^ static int cdissect(struct vars *, struct subre *, chr *, chr *); */ static int /* regexec return code */ cdissect( struct vars *v, struct subre *t, chr *begin, /* beginning of relevant substring */ chr *end) /* end of same */ { int er; assert(t != NULL); MDEBUG(("cdissect %ld-%ld %c\n", LOFF(begin), LOFF(end), t->op)); switch (t->op) { case '=': /* terminal node */ assert(t->left == NULL && t->right == NULL); er = REG_OKAY; /* no action, parent did the work */ break; case 'b': /* back reference */ assert(t->left == NULL && t->right == NULL); er = cbrdissect(v, t, begin, end); break; case '.': /* concatenation */ assert(t->left != NULL && t->right != NULL); if (t->left->flags & SHORTER) /* reverse scan */ er = crevcondissect(v, t, begin, end); else er = ccondissect(v, t, begin, end); break; case '|': /* alternation */ assert(t->left != NULL); er = caltdissect(v, t, begin, end); break; case '*': /* iteration */ assert(t->left != NULL); if (t->left->flags & SHORTER) /* reverse scan */ er = creviterdissect(v, t, begin, end); else er = citerdissect(v, t, begin, end); break; case '(': /* capturing */ assert(t->left != NULL && t->right == NULL); assert(t->subno > 0); er = cdissect(v, t->left, begin, end); if (er == REG_OKAY) { subset(v, t, begin, end); } break; default: er = REG_ASSERT; break; } /* * We should never have a match failure unless backrefs lurk below; * otherwise, either caller failed to check the DFA, or there's some * inconsistency between the DFA and the node's innards. */ assert(er != REG_NOMATCH || (t->flags & BACKR)); return er; } /* - ccondissect - dissect match for concatenation node ^ static int ccondissect(struct vars *, struct subre *, chr *, chr *); */ static int /* regexec return code */ ccondissect( struct vars *v, struct subre *t, chr *begin, /* beginning of relevant substring */ chr *end) /* end of same */ { struct dfa *d, *d2; chr *mid; assert(t->op == '.'); assert(t->left != NULL && t->left->cnfa.nstates > 0); assert(t->right != NULL && t->right->cnfa.nstates > 0); assert(!(t->left->flags & SHORTER)); d = getsubdfa(v, t->left); NOERR(); d2 = getsubdfa(v, t->right); NOERR(); MDEBUG(("cConcat %d\n", t->id)); /* * Pick a tentative midpoint. */ mid = longest(v, d, begin, end, (int *) NULL); if (mid == NULL) { return REG_NOMATCH; } MDEBUG(("tentative midpoint %ld\n", LOFF(mid))); /* * Iterate until satisfaction or failure. */ for (;;) { /* * Try this midpoint on for size. */ if (longest(v, d2, mid, end, NULL) == end) { int er = cdissect(v, t->left, begin, mid); if (er == REG_OKAY) { er = cdissect(v, t->right, mid, end); if (er == REG_OKAY) { /* * Satisfaction. */ MDEBUG(("successful\n")); return REG_OKAY; } } if (er != REG_NOMATCH) { return er; } } /* * That midpoint didn't work, find a new one. */ if (mid == begin) { /* * All possibilities exhausted. */ MDEBUG(("%d no midpoint\n", t->id)); return REG_NOMATCH; } mid = longest(v, d, begin, mid-1, NULL); if (mid == NULL) { /* * Failed to find a new one. */ MDEBUG(("%d failed midpoint\n", t->id)); return REG_NOMATCH; } MDEBUG(("%d: new midpoint %ld\n", t->id, LOFF(mid))); zaptreesubs(v, t->left); zaptreesubs(v, t->right); } } /* - crevcondissect - dissect match for concatenation node, shortest-first ^ static int crevcondissect(struct vars *, struct subre *, chr *, chr *); */ static int /* regexec return code */ crevcondissect( struct vars *v, struct subre *t, chr *begin, /* beginning of relevant substring */ chr *end) /* end of same */ { struct dfa *d, *d2; chr *mid; assert(t->op == '.'); assert(t->left != NULL && t->left->cnfa.nstates > 0); assert(t->right != NULL && t->right->cnfa.nstates > 0); assert(t->left->flags&SHORTER); d = getsubdfa(v, t->left); NOERR(); d2 = getsubdfa(v, t->right); NOERR(); MDEBUG(("crevcon %d\n", t->id)); /* * Pick a tentative midpoint. */ mid = shortest(v, d, begin, begin, end, (chr **) NULL, (int *) NULL); if (mid == NULL) { return REG_NOMATCH; } MDEBUG(("tentative midpoint %ld\n", LOFF(mid))); /* * Iterate until satisfaction or failure. */ for (;;) { /* * Try this midpoint on for size. */ if (longest(v, d2, mid, end, NULL) == end) { int er = cdissect(v, t->left, begin, mid); if (er == REG_OKAY) { er = cdissect(v, t->right, mid, end); if (er == REG_OKAY) { /* * Satisfaction. */ MDEBUG(("successful\n")); return REG_OKAY; } } if (er != REG_NOMATCH) { return er; } } /* * That midpoint didn't work, find a new one. */ if (mid == end) { /* * All possibilities exhausted. */ MDEBUG(("%d no midpoint\n", t->id)); return REG_NOMATCH; } mid = shortest(v, d, begin, mid+1, end, NULL, NULL); if (mid == NULL) { /* * Failed to find a new one. */ MDEBUG(("%d failed midpoint\n", t->id)); return REG_NOMATCH; } MDEBUG(("%d: new midpoint %ld\n", t->id, LOFF(mid))); zaptreesubs(v, t->left); zaptreesubs(v, t->right); } } /* - cbrdissect - dissect match for backref node ^ static int cbrdissect(struct vars *, struct subre *, chr *, chr *); */ static int /* regexec return code */ cbrdissect( struct vars *v, struct subre *t, chr *begin, /* beginning of relevant substring */ chr *end) /* end of same */ { int n = t->subno, min = t->min, max = t->max; size_t numreps; size_t tlen; size_t brlen; chr *brstring; chr *p; assert(t != NULL); assert(t->op == 'b'); assert(n >= 0); assert((size_t)n < v->nmatch); MDEBUG(("cbackref n%d %d{%d-%d}\n", t->id, n, min, max)); /* get the backreferenced string */ if (v->pmatch[n].rm_so == -1) { return REG_NOMATCH; } brstring = v->start + v->pmatch[n].rm_so; brlen = v->pmatch[n].rm_eo - v->pmatch[n].rm_so; /* special cases for zero-length strings */ if (brlen == 0) { /* * matches only if target is zero length, but any number of * repetitions can be considered to be present */ if (begin == end && min <= max) { MDEBUG(("cbackref matched trivially\n")); return REG_OKAY; } return REG_NOMATCH; } if (begin == end) { /* matches only if zero repetitions are okay */ if (min == 0) { MDEBUG(("cbackref matched trivially\n")); return REG_OKAY; } return REG_NOMATCH; } /* * check target length to see if it could possibly be an allowed number of * repetitions of brstring */ assert(end > begin); tlen = end - begin; if (tlen % brlen != 0) return REG_NOMATCH; numreps = tlen / brlen; if (numreps < (size_t)min || (numreps > (size_t)max && max != DUPINF)) return REG_NOMATCH; /* okay, compare the actual string contents */ p = begin; while (numreps-- > 0) { if ((*v->g->compare) (brstring, p, brlen) != 0) return REG_NOMATCH; p += brlen; } MDEBUG(("cbackref matched\n")); return REG_OKAY; } /* - caltdissect - dissect match for alternation node ^ static int caltdissect(struct vars *, struct subre *, chr *, chr *); */ static int /* regexec return code */ caltdissect( struct vars *v, struct subre *t, chr *begin, /* beginning of relevant substring */ chr *end) /* end of same */ { struct dfa *d; int er; /* We loop, rather than tail-recurse, to handle a chain of alternatives */ while (t != NULL) { assert(t->op == '|'); assert(t->left != NULL && t->left->cnfa.nstates > 0); MDEBUG(("calt n%d\n", t->id)); d = getsubdfa(v, t->left); NOERR(); if (longest(v, d, begin, end, (int *) NULL) == end) { MDEBUG(("calt matched\n")); er = cdissect(v, t->left, begin, end); if (er != REG_NOMATCH) { return er; } } t = t->right; } return REG_NOMATCH; } /* - citerdissect - dissect match for iteration node ^ static int citerdissect(struct vars *, struct subre *, chr *, chr *); */ static int /* regexec return code */ citerdissect(struct vars * v, struct subre * t, chr *begin, /* beginning of relevant substring */ chr *end) /* end of same */ { struct dfa *d; chr **endpts; chr *limit; int min_matches; size_t max_matches; int nverified; int k; int i; int er; assert(t->op == '*'); assert(t->left != NULL && t->left->cnfa.nstates > 0); assert(!(t->left->flags & SHORTER)); assert(begin <= end); /* * If zero matches are allowed, and target string is empty, just declare * victory. OTOH, if target string isn't empty, zero matches can't work * so we pretend the min is 1. */ min_matches = t->min; if (min_matches <= 0) { if (begin == end) return REG_OKAY; min_matches = 1; } /* * We need workspace to track the endpoints of each sub-match. Normally * we consider only nonzero-length sub-matches, so there can be at most * end-begin of them. However, if min is larger than that, we will also * consider zero-length sub-matches in order to find enough matches. * * For convenience, endpts[0] contains the "begin" pointer and we store * sub-match endpoints in endpts[1..max_matches]. */ max_matches = end - begin; if (max_matches > (size_t)t->max && t->max != DUPINF) max_matches = t->max; if (max_matches < (size_t)min_matches) max_matches = min_matches; endpts = (chr **) MALLOC((max_matches + 1) * sizeof(chr *)); if (endpts == NULL) return REG_ESPACE; endpts[0] = begin; d = getsubdfa(v, t->left); if (ISERR()) { FREE(endpts); return v->err; } MDEBUG(("citer %d\n", t->id)); /* * Our strategy is to first find a set of sub-match endpoints that are * valid according to the child node's DFA, and then recursively dissect * each sub-match to confirm validity. If any validity check fails, * backtrack the last sub-match and try again. And, when we next try for * a validity check, we need not recheck any successfully verified * sub-matches that we didn't move the endpoints of. nverified remembers * how many sub-matches are currently known okay. */ /* initialize to consider first sub-match */ nverified = 0; k = 1; limit = end; /* iterate until satisfaction or failure */ while (k > 0) { /* try to find an endpoint for the k'th sub-match */ endpts[k] = longest(v, d, endpts[k - 1], limit, (int *) NULL); if (endpts[k] == NULL) { /* no match possible, so see if we can shorten previous one */ k--; goto backtrack; } MDEBUG(("%d: working endpoint %d: %ld\n", t->id, k, LOFF(endpts[k]))); /* k'th sub-match can no longer be considered verified */ if (nverified >= k) nverified = k - 1; if (endpts[k] != end) { /* haven't reached end yet, try another iteration if allowed */ if ((size_t)k >= max_matches) { /* must try to shorten some previous match */ k--; goto backtrack; } /* reject zero-length match unless necessary to achieve min */ if (endpts[k] == endpts[k - 1] && (k >= min_matches || min_matches - k < end - endpts[k])) goto backtrack; k++; limit = end; continue; } /* * We've identified a way to divide the string into k sub-matches * that works so far as the child DFA can tell. If k is an allowed * number of matches, start the slow part: recurse to verify each * sub-match. We always have k <= max_matches, needn't check that. */ if (k < min_matches) goto backtrack; MDEBUG(("%d: verifying %d..%d\n", t->id, nverified + 1, k)); for (i = nverified + 1; i <= k; i++) { zaptreesubs(v, t->left); er = cdissect(v, t->left, endpts[i - 1], endpts[i]); if (er == REG_OKAY) { nverified = i; continue; } if (er == REG_NOMATCH) break; /* oops, something failed */ FREE(endpts); return er; } if (i > k) { /* satisfaction */ MDEBUG(("%d successful\n", t->id)); FREE(endpts); return REG_OKAY; } /* match failed to verify, so backtrack */ backtrack: /* * Must consider shorter versions of the current sub-match. However, * we'll only ask for a zero-length match if necessary. */ while (k > 0) { chr *prev_end = endpts[k - 1]; if (endpts[k] > prev_end) { limit = endpts[k] - 1; if (limit > prev_end || (k < min_matches && min_matches - k >= end - prev_end)) { /* break out of backtrack loop, continue the outer one */ break; } } /* can't shorten k'th sub-match any more, consider previous one */ k--; } } /* all possibilities exhausted */ MDEBUG(("%d failed\n", t->id)); FREE(endpts); return REG_NOMATCH; } /* - creviterdissect - dissect match for iteration node, shortest-first ^ static int creviterdissect(struct vars *, struct subre *, chr *, chr *); */ static int /* regexec return code */ creviterdissect(struct vars * v, struct subre * t, chr *begin, /* beginning of relevant substring */ chr *end) /* end of same */ { struct dfa *d; chr **endpts; chr *limit; int min_matches; size_t max_matches; int nverified; int k; int i; int er; assert(t->op == '*'); assert(t->left != NULL && t->left->cnfa.nstates > 0); assert(t->left->flags & SHORTER); assert(begin <= end); /* * If zero matches are allowed, and target string is empty, just declare * victory. OTOH, if target string isn't empty, zero matches can't work * so we pretend the min is 1. */ min_matches = t->min; if (min_matches <= 0) { if (begin == end) return REG_OKAY; min_matches = 1; } /* * We need workspace to track the endpoints of each sub-match. Normally * we consider only nonzero-length sub-matches, so there can be at most * end-begin of them. However, if min is larger than that, we will also * consider zero-length sub-matches in order to find enough matches. * * For convenience, endpts[0] contains the "begin" pointer and we store * sub-match endpoints in endpts[1..max_matches]. */ max_matches = end - begin; if (max_matches > (size_t)t->max && t->max != DUPINF) max_matches = t->max; if (max_matches < (size_t)min_matches) max_matches = min_matches; endpts = (chr **) MALLOC((max_matches + 1) * sizeof(chr *)); if (endpts == NULL) return REG_ESPACE; endpts[0] = begin; d = getsubdfa(v, t->left); if (ISERR()) { FREE(endpts); return v->err; } MDEBUG(("creviter %d\n", t->id)); /* * Our strategy is to first find a set of sub-match endpoints that are * valid according to the child node's DFA, and then recursively dissect * each sub-match to confirm validity. If any validity check fails, * backtrack the last sub-match and try again. And, when we next try for * a validity check, we need not recheck any successfully verified * sub-matches that we didn't move the endpoints of. nverified remembers * how many sub-matches are currently known okay. */ /* initialize to consider first sub-match */ nverified = 0; k = 1; limit = begin; /* iterate until satisfaction or failure */ while (k > 0) { /* disallow zero-length match unless necessary to achieve min */ if (limit == endpts[k - 1] && limit != end && (k >= min_matches || min_matches - k < end - limit)) limit++; /* if this is the last allowed sub-match, it must reach to the end */ if ((size_t)k >= max_matches) limit = end; /* try to find an endpoint for the k'th sub-match */ endpts[k] = shortest(v, d, endpts[k - 1], limit, end, (chr **) NULL, (int *) NULL); if (endpts[k] == NULL) { /* no match possible, so see if we can lengthen previous one */ k--; goto backtrack; } MDEBUG(("%d: working endpoint %d: %ld\n", t->id, k, LOFF(endpts[k]))); /* k'th sub-match can no longer be considered verified */ if (nverified >= k) nverified = k - 1; if (endpts[k] != end) { /* haven't reached end yet, try another iteration if allowed */ if ((size_t)k >= max_matches) { /* must try to lengthen some previous match */ k--; goto backtrack; } k++; limit = endpts[k - 1]; continue; } /* * We've identified a way to divide the string into k sub-matches * that works so far as the child DFA can tell. If k is an allowed * number of matches, start the slow part: recurse to verify each * sub-match. We always have k <= max_matches, needn't check that. */ if (k < min_matches) goto backtrack; MDEBUG(("%d: verifying %d..%d\n", t->id, nverified + 1, k)); for (i = nverified + 1; i <= k; i++) { zaptreesubs(v, t->left); er = cdissect(v, t->left, endpts[i - 1], endpts[i]); if (er == REG_OKAY) { nverified = i; continue; } if (er == REG_NOMATCH) break; /* oops, something failed */ FREE(endpts); return er; } if (i > k) { /* satisfaction */ MDEBUG(("%d successful\n", t->id)); FREE(endpts); return REG_OKAY; } /* match failed to verify, so backtrack */ backtrack: /* * Must consider longer versions of the current sub-match. */ while (k > 0) { if (endpts[k] < end) { limit = endpts[k] + 1; /* break out of backtrack loop, continue the outer one */ break; } /* can't lengthen k'th sub-match any more, consider previous one */ k--; } } /* all possibilities exhausted */ MDEBUG(("%d failed\n", t->id)); FREE(endpts); return REG_NOMATCH; } #include "rege_dfa.c" /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */
{ "pile_set_name": "Github" }
// SPDX-License-Identifier: GPL-2.0-or-later /* * conmakehash.c * * Create arrays for initializing the kernel folded tables (using a hash * table turned out to be to limiting...) Unfortunately we can't simply * preinitialize the tables at compile time since kfree() cannot accept * memory not allocated by kmalloc(), and doing our own memory management * just for this seems like massive overkill. * * Copyright (C) 1995-1997 H. Peter Anvin */ #include <stdio.h> #include <stdlib.h> #include <sysexits.h> #include <string.h> #include <ctype.h> #define MAX_FONTLEN 256 typedef unsigned short unicode; static void usage(char *argv0) { fprintf(stderr, "Usage: \n" " %s chartable [hashsize] [hashstep] [maxhashlevel]\n", argv0); exit(EX_USAGE); } static int getunicode(char **p0) { char *p = *p0; while (*p == ' ' || *p == '\t') p++; if (*p != 'U' || p[1] != '+' || !isxdigit(p[2]) || !isxdigit(p[3]) || !isxdigit(p[4]) || !isxdigit(p[5]) || isxdigit(p[6])) return -1; *p0 = p+6; return strtol(p+2,0,16); } unicode unitable[MAX_FONTLEN][255]; /* Massive overkill, but who cares? */ int unicount[MAX_FONTLEN]; static void addpair(int fp, int un) { int i; if ( un <= 0xfffe ) { /* Check it isn't a duplicate */ for ( i = 0 ; i < unicount[fp] ; i++ ) if ( unitable[fp][i] == un ) return; /* Add to list */ if ( unicount[fp] > 254 ) { fprintf(stderr, "ERROR: Only 255 unicodes/glyph permitted!\n"); exit(EX_DATAERR); } unitable[fp][unicount[fp]] = un; unicount[fp]++; } /* otherwise: ignore */ } int main(int argc, char *argv[]) { FILE *ctbl; char *tblname; char buffer[65536]; int fontlen; int i, nuni, nent; int fp0, fp1, un0, un1; char *p, *p1; if ( argc < 2 || argc > 5 ) usage(argv[0]); if ( !strcmp(argv[1],"-") ) { ctbl = stdin; tblname = "stdin"; } else { ctbl = fopen(tblname = argv[1], "r"); if ( !ctbl ) { perror(tblname); exit(EX_NOINPUT); } } /* For now we assume the default font is always 256 characters. */ fontlen = 256; /* Initialize table */ for ( i = 0 ; i < fontlen ; i++ ) unicount[i] = 0; /* Now we come to the tricky part. Parse the input table. */ while ( fgets(buffer, sizeof(buffer), ctbl) != NULL ) { if ( (p = strchr(buffer, '\n')) != NULL ) *p = '\0'; else fprintf(stderr, "%s: Warning: line too long\n", tblname); p = buffer; /* * Syntax accepted: * <fontpos> <unicode> <unicode> ... * <range> idem * <range> <unicode range> * * where <range> ::= <fontpos>-<fontpos> * and <unicode> ::= U+<h><h><h><h> * and <h> ::= <hexadecimal digit> */ while (*p == ' ' || *p == '\t') p++; if (!*p || *p == '#') continue; /* skip comment or blank line */ fp0 = strtol(p, &p1, 0); if (p1 == p) { fprintf(stderr, "Bad input line: %s\n", buffer); exit(EX_DATAERR); } p = p1; while (*p == ' ' || *p == '\t') p++; if (*p == '-') { p++; fp1 = strtol(p, &p1, 0); if (p1 == p) { fprintf(stderr, "Bad input line: %s\n", buffer); exit(EX_DATAERR); } p = p1; } else fp1 = 0; if ( fp0 < 0 || fp0 >= fontlen ) { fprintf(stderr, "%s: Glyph number (0x%x) larger than font length\n", tblname, fp0); exit(EX_DATAERR); } if ( fp1 && (fp1 < fp0 || fp1 >= fontlen) ) { fprintf(stderr, "%s: Bad end of range (0x%x)\n", tblname, fp1); exit(EX_DATAERR); } if (fp1) { /* we have a range; expect the word "idem" or a Unicode range of the same length */ while (*p == ' ' || *p == '\t') p++; if (!strncmp(p, "idem", 4)) { for (i=fp0; i<=fp1; i++) addpair(i,i); p += 4; } else { un0 = getunicode(&p); while (*p == ' ' || *p == '\t') p++; if (*p != '-') { fprintf(stderr, "%s: Corresponding to a range of font positions, there should be a Unicode range\n", tblname); exit(EX_DATAERR); } p++; un1 = getunicode(&p); if (un0 < 0 || un1 < 0) { fprintf(stderr, "%s: Bad Unicode range corresponding to font position range 0x%x-0x%x\n", tblname, fp0, fp1); exit(EX_DATAERR); } if (un1 - un0 != fp1 - fp0) { fprintf(stderr, "%s: Unicode range U+%x-U+%x not of the same length as font position range 0x%x-0x%x\n", tblname, un0, un1, fp0, fp1); exit(EX_DATAERR); } for(i=fp0; i<=fp1; i++) addpair(i,un0-fp0+i); } } else { /* no range; expect a list of unicode values for a single font position */ while ( (un0 = getunicode(&p)) >= 0 ) addpair(fp0, un0); } while (*p == ' ' || *p == '\t') p++; if (*p && *p != '#') fprintf(stderr, "%s: trailing junk (%s) ignored\n", tblname, p); } /* Okay, we hit EOF, now output hash table */ fclose(ctbl); /* Compute total size of Unicode list */ nuni = 0; for ( i = 0 ; i < fontlen ; i++ ) nuni += unicount[i]; printf("\ /*\n\ * Do not edit this file; it was automatically generated by\n\ *\n\ * conmakehash %s > [this file]\n\ *\n\ */\n\ \n\ #include <linux/types.h>\n\ \n\ u8 dfont_unicount[%d] = \n\ {\n\t", argv[1], fontlen); for ( i = 0 ; i < fontlen ; i++ ) { printf("%3d", unicount[i]); if ( i == fontlen-1 ) printf("\n};\n"); else if ( i % 8 == 7 ) printf(",\n\t"); else printf(", "); } printf("\nu16 dfont_unitable[%d] = \n{\n\t", nuni); fp0 = 0; nent = 0; for ( i = 0 ; i < nuni ; i++ ) { while ( nent >= unicount[fp0] ) { fp0++; nent = 0; } printf("0x%04x", unitable[fp0][nent++]); if ( i == nuni-1 ) printf("\n};\n"); else if ( i % 8 == 7 ) printf(",\n\t"); else printf(", "); } exit(EX_OK); }
{ "pile_set_name": "Github" }