code
stringlengths
4
991k
repo_name
stringlengths
6
116
path
stringlengths
4
249
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
4
991k
input_ids
listlengths
502
502
token_type_ids
listlengths
502
502
attention_mask
listlengths
502
502
labels
listlengths
502
502
<?php /* * * ____ _ _ __ __ _ __ __ ____ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * This program 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 3 of the License, or * (at your option) any later version. * * @author PocketMine Team * @link http://www.pocketmine.net/ * * */ namespace pocketmine\utils; use LogLevel; use pocketmine\Thread; use pocketmine\Worker; class MainLogger extends \AttachableThreadedLogger{ protected $logFile; protected $logStream; protected $shutdown; protected $logDebug; private $logResource; /** @var MainLogger */ public static $logger = null; /** * @param string $logFile * @param bool $logDebug * * @throws \RuntimeException */ public function __construct($logFile, $logDebug = false){ parent::__construct(); if(static::$logger instanceof MainLogger){ throw new \RuntimeException("MainLogger has been already created"); } static::$logger = $this; $this->logStream = new \Threaded; $this->start(); } /** * @return MainLogger */ public static function getLogger(){ return static::$logger; } /** * Assigns the MainLogger instance to the {@link MainLogger#logger} static property. * * WARNING: Because static properties are thread-local, this MUST be called from the body of every Thread if you * want the logger to be accessible via {@link MainLogger#getLogger}. */ public function registerStatic(){ if(static::$logger === null){ static::$logger = $this; } } public function emergency($message){ $this->send($message, \LogLevel::EMERGENCY, "EMERGENCY", TextFormat::RED); } public function alert($message){ $this->send($message, \LogLevel::ALERT, "ALERT", TextFormat::RED); } public function critical($message){ $this->send($message, \LogLevel::CRITICAL, "CRITICAL", TextFormat::RED); } public function error($message){ $this->send($message, \LogLevel::ERROR, "ERROR", TextFormat::DARK_RED); } public function warning($message){ $this->send($message, \LogLevel::WARNING, "WARNING", TextFormat::YELLOW); } public function notice($message){ $this->send($message, \LogLevel::NOTICE, "NOTICE", TextFormat::AQUA); } public function info($message){ $this->send($message, \LogLevel::INFO, "INFO", TextFormat::WHITE); } public function debug($message){ if($this->logDebug === false){ return; } $this->send($message, \LogLevel::DEBUG, "DEBUG", TextFormat::GRAY); } /** * @param bool $logDebug */ public function setLogDebug($logDebug){ $this->logDebug = (bool) $logDebug; } public function logException(\Throwable $e, $trace = null){ if($trace === null){ $trace = $e->getTrace(); } $errstr = $e->getMessage(); $errfile = $e->getFile(); $errno = $e->getCode(); $errline = $e->getLine(); $errorConversion = [ 0 => "EXCEPTION", E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_PARSE => "E_PARSE", E_NOTICE => "E_NOTICE", E_CORE_ERROR => "E_CORE_ERROR", E_CORE_WARNING => "E_CORE_WARNING", E_COMPILE_ERROR => "E_COMPILE_ERROR", E_COMPILE_WARNING => "E_COMPILE_WARNING", E_USER_ERROR => "E_USER_ERROR", E_USER_WARNING => "E_USER_WARNING", E_USER_NOTICE => "E_USER_NOTICE", E_STRICT => "E_STRICT", E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", E_DEPRECATED => "E_DEPRECATED", E_USER_DEPRECATED => "E_USER_DEPRECATED", ]; if($errno === 0){ $type = LogLevel::CRITICAL; }else{ $type = ($errno === E_ERROR or $errno === E_USER_ERROR) ? LogLevel::ERROR : (($errno === E_USER_WARNING or $errno === E_WARNING) ? LogLevel::WARNING : LogLevel::NOTICE); } $errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno; if(($pos = strpos($errstr, "\n")) !== false){ $errstr = substr($errstr, 0, $pos); } $errfile = \pocketmine\cleanPath($errfile); $this->log($type, get_class($e) . ": \"$errstr\" ($errno) in \"$errfile\" at line $errline"); foreach(@\pocketmine\getTrace(1, $trace) as $i => $line){ $this->debug($line); } } public function log($level, $message){ switch($level){ case LogLevel::EMERGENCY: $this->emergency($message); break; case LogLevel::ALERT: $this->alert($message); break; case LogLevel::CRITICAL: $this->critical($message); break; case LogLevel::ERROR: $this->error($message); break; case LogLevel::WARNING: $this->warning($message); break; case LogLevel::NOTICE: $this->notice($message); break; case LogLevel::INFO: $this->info($message); break; case LogLevel::DEBUG: $this->debug($message); break; } } public function shutdown(){ $this->shutdown = true; } protected function send($message, $level, $prefix, $color){ $now = time(); $thread = \Thread::getCurrentThread(); if($thread === null){ $threadName = "Server thread"; }elseif($thread instanceof Thread or $thread instanceof Worker){ $threadName = $thread->getThreadName() . " thread"; }else{ $threadName = (new \ReflectionClass($thread))->getShortName() . " thread"; } $message = TextFormat::toANSI(TextFormat::AQUA . "[" . date("H:i:s", $now) . "] ". TextFormat::RESET . $color ."[" . $threadName . "/" . $prefix . "]:" . " " . $message . TextFormat::RESET); $cleanMessage = TextFormat::clean($message); if(!Terminal::hasFormattingCodes()){ echo $cleanMessage . PHP_EOL; }else{ echo $message . PHP_EOL; } if($this->attachment instanceof \ThreadedLoggerAttachment){ $this->attachment->call($level, $message); } $this->logStream[] = date("Y-m-d", $now) . " " . $cleanMessage . "\n"; if($this->logStream->count() === 1){ $this->synchronized(function(){ $this->notify(); }); } } public function run(){ $this->shutdown = false; } }
ConflictPE/Extropy
src/pocketmine/utils/MainLogger.php
PHP
lgpl-3.0
6,162
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1008, 1064, 1035, 1032, 1035, 1035, 1035, 1035, 1035, 1035, 1064, 1064, 10...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <title>Source code</title> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> </head> <body> <div class="sourceContainer"> <pre><span class="sourceLineNo">001</span>/* ========================================================================<a name="line.1"></a> <span class="sourceLineNo">002</span> * JCommon : a free general purpose class library for the Java(tm) platform<a name="line.2"></a> <span class="sourceLineNo">003</span> * ========================================================================<a name="line.3"></a> <span class="sourceLineNo">004</span> *<a name="line.4"></a> <span class="sourceLineNo">005</span> * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.<a name="line.5"></a> <span class="sourceLineNo">006</span> * <a name="line.6"></a> <span class="sourceLineNo">007</span> * Project Info: http://www.jfree.org/jcommon/index.html<a name="line.7"></a> <span class="sourceLineNo">008</span> *<a name="line.8"></a> <span class="sourceLineNo">009</span> * This library is free software; you can redistribute it and/or modify it <a name="line.9"></a> <span class="sourceLineNo">010</span> * under the terms of the GNU Lesser General Public License as published by <a name="line.10"></a> <span class="sourceLineNo">011</span> * the Free Software Foundation; either version 2.1 of the License, or <a name="line.11"></a> <span class="sourceLineNo">012</span> * (at your option) any later version.<a name="line.12"></a> <span class="sourceLineNo">013</span> *<a name="line.13"></a> <span class="sourceLineNo">014</span> * This library is distributed in the hope that it will be useful, but <a name="line.14"></a> <span class="sourceLineNo">015</span> * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY <a name="line.15"></a> <span class="sourceLineNo">016</span> * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public <a name="line.16"></a> <span class="sourceLineNo">017</span> * License for more details.<a name="line.17"></a> <span class="sourceLineNo">018</span> *<a name="line.18"></a> <span class="sourceLineNo">019</span> * You should have received a copy of the GNU Lesser General Public<a name="line.19"></a> <span class="sourceLineNo">020</span> * License along with this library; if not, write to the Free Software<a name="line.20"></a> <span class="sourceLineNo">021</span> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, <a name="line.21"></a> <span class="sourceLineNo">022</span> * USA. <a name="line.22"></a> <span class="sourceLineNo">023</span> *<a name="line.23"></a> <span class="sourceLineNo">024</span> * [Java is a trademark or registered trademark of Sun Microsystems, Inc. <a name="line.24"></a> <span class="sourceLineNo">025</span> * in the United States and other countries.]<a name="line.25"></a> <span class="sourceLineNo">026</span> * <a name="line.26"></a> <span class="sourceLineNo">027</span> * -------------------------<a name="line.27"></a> <span class="sourceLineNo">028</span> * LongAttributeHandler.java<a name="line.28"></a> <span class="sourceLineNo">029</span> * -------------------------<a name="line.29"></a> <span class="sourceLineNo">030</span> * (C)opyright 2003, 2004, by Thomas Morgner and Contributors.<a name="line.30"></a> <span class="sourceLineNo">031</span> *<a name="line.31"></a> <span class="sourceLineNo">032</span> * Original Author: Thomas Morgner;<a name="line.32"></a> <span class="sourceLineNo">033</span> * Contributor(s): David Gilbert (for Object Refinery Limited);<a name="line.33"></a> <span class="sourceLineNo">034</span> *<a name="line.34"></a> <span class="sourceLineNo">035</span> * $Id: LongAttributeHandler.java,v 1.2 2005/10/18 13:30:16 mungady Exp $<a name="line.35"></a> <span class="sourceLineNo">036</span> *<a name="line.36"></a> <span class="sourceLineNo">037</span> * Changes <a name="line.37"></a> <span class="sourceLineNo">038</span> * -------<a name="line.38"></a> <span class="sourceLineNo">039</span> * 24.09.2003 : Initial version<a name="line.39"></a> <span class="sourceLineNo">040</span> * <a name="line.40"></a> <span class="sourceLineNo">041</span> */<a name="line.41"></a> <span class="sourceLineNo">042</span><a name="line.42"></a> <span class="sourceLineNo">043</span>package org.jfree.xml.attributehandlers;<a name="line.43"></a> <span class="sourceLineNo">044</span><a name="line.44"></a> <span class="sourceLineNo">045</span>/**<a name="line.45"></a> <span class="sourceLineNo">046</span> * A class that handles the conversion of {@link Long} attributes to and from an appropriate<a name="line.46"></a> <span class="sourceLineNo">047</span> * {@link String} representation.<a name="line.47"></a> <span class="sourceLineNo">048</span> */<a name="line.48"></a> <span class="sourceLineNo">049</span>public class LongAttributeHandler implements AttributeHandler {<a name="line.49"></a> <span class="sourceLineNo">050</span><a name="line.50"></a> <span class="sourceLineNo">051</span> /**<a name="line.51"></a> <span class="sourceLineNo">052</span> * Creates a new attribute handler.<a name="line.52"></a> <span class="sourceLineNo">053</span> */<a name="line.53"></a> <span class="sourceLineNo">054</span> public LongAttributeHandler() {<a name="line.54"></a> <span class="sourceLineNo">055</span> super();<a name="line.55"></a> <span class="sourceLineNo">056</span> }<a name="line.56"></a> <span class="sourceLineNo">057</span><a name="line.57"></a> <span class="sourceLineNo">058</span> /**<a name="line.58"></a> <span class="sourceLineNo">059</span> * Converts the attribute to a string.<a name="line.59"></a> <span class="sourceLineNo">060</span> * <a name="line.60"></a> <span class="sourceLineNo">061</span> * @param o the attribute ({@link Long} expected).<a name="line.61"></a> <span class="sourceLineNo">062</span> * <a name="line.62"></a> <span class="sourceLineNo">063</span> * @return A string representing the {@link Long} value.<a name="line.63"></a> <span class="sourceLineNo">064</span> */<a name="line.64"></a> <span class="sourceLineNo">065</span> public String toAttributeValue(final Object o) {<a name="line.65"></a> <span class="sourceLineNo">066</span> final Long in = (Long) o;<a name="line.66"></a> <span class="sourceLineNo">067</span> return in.toString();<a name="line.67"></a> <span class="sourceLineNo">068</span> }<a name="line.68"></a> <span class="sourceLineNo">069</span><a name="line.69"></a> <span class="sourceLineNo">070</span> /**<a name="line.70"></a> <span class="sourceLineNo">071</span> * Converts a string to a {@link Long}.<a name="line.71"></a> <span class="sourceLineNo">072</span> * <a name="line.72"></a> <span class="sourceLineNo">073</span> * @param s the string.<a name="line.73"></a> <span class="sourceLineNo">074</span> * <a name="line.74"></a> <span class="sourceLineNo">075</span> * @return a {@link Long}.<a name="line.75"></a> <span class="sourceLineNo">076</span> */<a name="line.76"></a> <span class="sourceLineNo">077</span> public Object toPropertyValue(final String s) {<a name="line.77"></a> <span class="sourceLineNo">078</span> return new Long(s);<a name="line.78"></a> <span class="sourceLineNo">079</span> }<a name="line.79"></a> <span class="sourceLineNo">080</span> <a name="line.80"></a> <span class="sourceLineNo">081</span>}<a name="line.81"></a> </pre> </div> </body> </html>
GliderWinchItems/GliderWinchj2
lib/JCommon-1.0.21/jcommon-1.0/javadoc/src-html/org/jfree/xml/attributehandlers/LongAttributeHandler.html
HTML
unlicense
7,709
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#region License Header /* * QUANTLER.COM - Quant Fund Development Platform * Quantler Core Trading Engine. Copyright 2018 Quantler B.V. * * 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. */ #endregion License Header using Quantler.Exchanges; using System; using System.Linq; namespace Quantler.Scheduler { /// <summary> /// Date composition /// </summary> /// <seealso cref="DateComposite" /> public class DateFunc : DateComposite { #region Private Fields /// <summary> /// The next date function /// </summary> private readonly Func<DateTime, DateTime> _nextDateFunc; /// <summary> /// The previous date, in case we need to remember this /// </summary> private DateTime _previousDate = DateTime.MinValue; #endregion Private Fields #region Public Constructors /// <summary> /// Initializes a new instance of the <see cref="DateFunc"/> class. /// </summary> public DateFunc() { } #endregion Public Constructors #region Private Constructors /// <summary> /// Initializes a new instance of the <see cref="DateFunc"/> class. /// </summary> /// <param name="nextdatefunc">The next date function.</param> /// <param name="name"></param> private DateFunc(Func<DateTime, DateTime> nextdatefunc, string name) { _nextDateFunc = nextdatefunc; Name = name; } #endregion Private Constructors #region Public Properties /// <summary> /// Name of the composite, for easier logging /// </summary> public string Name { get; } #endregion Public Properties #region Public Methods /// <summary> /// Last trading day of each month /// </summary> /// <param name="exchangeModel">The exchangeModel.</param> /// <returns></returns> public DateComposite EndOfMonth(ExchangeModel exchangeModel) => new DateFunc(x => { //Derive the next date var derived = x.ConvertTo(TimeZone.Utc, exchangeModel.TimeZone).AddMonths(2).DoWhile(n => n.AddDays(-1), i => !exchangeModel.IsOpenOnDate(i) && x.Month != i.Month + 1); //return return derived.ConvertTo(exchangeModel.TimeZone, TimeZone.Utc); }, "End-Of-Every-Month"); /// <summary> /// Last trading day of specified month /// </summary> /// <param name="exchangeModel">The exchangeModel.</param> /// <param name="month">The month.</param> /// <returns></returns> public DateComposite EndOfMonth(ExchangeModel exchangeModel, int month) => new DateFunc(x => { //Get the correct timezone for this exchange (input is utc) x = x.ConvertTo(TimeZone.Utc, exchangeModel.TimeZone); //Derive next date var derived = new DateTime( x.Month > month || (!exchangeModel.IsOpenOnDate(x) && x.Month == month) ? x.Year + 1 : x.Year, 12, 31) .DoWhile(n => n.AddDays(-1), i => !exchangeModel.IsOpenOnDate(i) && i.Month != month); //return return derived.ConvertTo(exchangeModel.TimeZone, TimeZone.Utc); }, $"End-Of-Month-{month}"); /// <summary> /// Last trading day of each week /// </summary> /// <param name="exchangeModel">The exchangeModel.</param> /// <returns></returns> public DateComposite EndOfWeek(ExchangeModel exchangeModel) => new DateFunc(x => { //Get the correct timezone for this exchange (input is utc) x = x.ConvertTo(TimeZone.Utc, exchangeModel.TimeZone); //Derive next date var derived = x.AddDays(7 - ((int) x.DayOfWeek + 1 > 0 ? (int) x.DayOfWeek + 2 : 0)) .DoWhile(n => n.AddDays(-1), n => !exchangeModel.IsOpenOnDate(n)); //return return derived.ConvertTo(exchangeModel.TimeZone, TimeZone.Utc); }, "End-Of-Week"); /// <summary> /// Every day. /// </summary> /// <returns></returns> public DateComposite EveryDay() => new DateFunc(x => { //Set previous date if (_previousDate.Date != x.Date) { _previousDate = x.Date.AddDays(1); return _previousDate; } else return x; }, "Every-Day"); /// <summary> /// Every day. /// </summary> /// <returns></returns> public DateComposite EveryTradingDay(ExchangeModel exchangeModel) => new DateFunc(x => { //Get the correct timezone for this exchange (input is utc) x = x.ConvertTo(TimeZone.Utc, exchangeModel.TimeZone); //Set previous date var derived = x; if (_previousDate.Date != x.Date) { _previousDate = _previousDate.DoWhile(n => n.AddDays(1), n => !exchangeModel.IsOpenOnDate(n)); derived = _previousDate; } //return return derived.ConvertTo(exchangeModel.TimeZone, TimeZone.Utc); }, "Every-TradingDay"); /// <summary> /// Get the next date and time to execute this event /// </summary> /// <param name="dateutc">Current date in utc.</param> /// <returns></returns> public DateTime NextDate(DateTime dateutc) => _nextDateFunc(dateutc); /// <summary> /// On a specific year, month and day /// </summary> /// <param name="year">The year.</param> /// <param name="month">The month.</param> /// <param name="day">The day.</param> /// <returns></returns> public DateComposite On(int year, int month, int day) => new DateFunc(x => new DateTime(year, month, day), $"At-Date-{year}-{month}-{day}"); /// <summary> /// On specified days /// </summary> /// <param name="dates">The dates.</param> /// <returns></returns> public DateComposite On(params DateTime[] dates) => new DateFunc(x => x.DoWhile(n => n.AddDays(1), n => dates.Count(i => i.Day == n.Day && i.Month == n.Month) == 0), $"On-Dates-{string.Join("-", dates)}"); /// <summary> /// On the specified days of the week /// </summary> /// <param name="days">The days.</param> /// <returns></returns> public DateComposite On(params DayOfWeek[] days) => new DateFunc(x => x.DoWhile(n => n.AddDays(1), n => !days.Contains(n.DayOfWeek)), $"On-Day-Of-Week-{string.Join("-", days)}"); /// <summary> /// On the first trading day of the month /// </summary> /// <param name="exchangeModel">The exchangeModel.</param> /// <returns></returns> public DateComposite StartOfMonth(ExchangeModel exchangeModel) => new DateFunc(x => { //Get the correct timezone for this exchange (input is utc) x = x.ConvertTo(TimeZone.Utc, exchangeModel.TimeZone); //Derive next date var derived = new DateTime(x.Year, x.Month, 1).AddMonths(1) .DoWhile(n => n.AddDays(1), i => !exchangeModel.IsOpenOnDate(i)); //return return derived.ConvertTo(exchangeModel.TimeZone, TimeZone.Utc); }, "Start-Of-Every-Month"); /// <summary> /// On the first trading day of the specified month /// </summary> /// <param name="exchangeModel">The exchangeModel.</param> /// <param name="month">The month.</param> /// <returns></returns> public DateComposite StartOfMonth(ExchangeModel exchangeModel, int month) => new DateFunc(x => { //Get the correct timezone for this exchange (input is utc) x = x.ConvertTo(TimeZone.Utc, exchangeModel.TimeZone); //Derive next date var derived = new DateTime(x.Month >= month ? x.Year + 1 : x.Year, 1, 1) .DoWhile(n => n.AddDays(1), i => !exchangeModel.IsOpenOnDate(i) && i.Month != month); //return return derived.ConvertTo(exchangeModel.TimeZone, TimeZone.Utc); }, $"Start-Of-{month}-Month"); /// <summary> /// On the first trading day of the week /// </summary> /// <param name="exchangeModel">The exchangeModel.</param> /// <returns></returns> public DateComposite StartOfWeek(ExchangeModel exchangeModel) => new DateFunc(x => { //Get the correct timezone for this exchange (input is utc) x = x.ConvertTo(TimeZone.Utc, exchangeModel.TimeZone); //Derive next date var derived = x.AddDays(7).AddDays(DayOfWeek.Monday - x.DayOfWeek) .DoWhile(n => n.AddDays(1), n => !exchangeModel.IsOpenOnDate(n)); //return return derived.ConvertTo(exchangeModel.TimeZone, TimeZone.Utc); }, "Start-Of-Every-Week"); #endregion Public Methods } }
Quantler/Core
Quantler/Scheduler/DateFunc.cs
C#
apache-2.0
10,177
[ 30522, 1001, 2555, 6105, 20346, 1013, 1008, 1008, 24110, 25091, 1012, 4012, 1011, 24110, 2102, 4636, 2458, 4132, 1008, 24110, 25091, 4563, 6202, 3194, 1012, 9385, 2760, 24110, 25091, 1038, 1012, 1058, 1012, 1008, 1008, 7000, 2104, 1996, 158...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the 2-clause BSD license. * See license.txt in the OpenLayers distribution or repository for the * full text of the license. */ /** * @requires OpenLayers/Control.js * @requires OpenLayers/Handler/Click.js * @requires OpenLayers/Handler/Hover.js * @requires OpenLayers/Request.js * @requires OpenLayers/Format/WMSGetFeatureInfo.js */ /** * Class: OpenLayers.Control.WMTSGetFeatureInfo * The WMTSGetFeatureInfo control uses a WMTS query to get information about a * point on the map. The information may be in a display-friendly format * such as HTML, or a machine-friendly format such as GML, depending on the * server's capabilities and the client's configuration. This control * handles click or hover events, attempts to parse the results using an * OpenLayers.Format, and fires a 'getfeatureinfo' event for each layer * queried. * * Inherits from: * - <OpenLayers.Control> */ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { /** * APIProperty: hover * {Boolean} Send GetFeatureInfo requests when mouse stops moving. * Default is false. */ hover: false, /** * Property: requestEncoding * {String} One of "KVP" or "REST". Only KVP encoding is supported at this * time. */ requestEncoding: "KVP", /** * APIProperty: drillDown * {Boolean} Drill down over all WMTS layers in the map. When * using drillDown mode, hover is not possible. A getfeatureinfo event * will be fired for each layer queried. */ drillDown: false, /** * APIProperty: maxFeatures * {Integer} Maximum number of features to return from a WMTS query. This * sets the feature_count parameter on WMTS GetFeatureInfo * requests. */ maxFeatures: 10, /** APIProperty: clickCallback * {String} The click callback to register in the * {<OpenLayers.Handler.Click>} object created when the hover * option is set to false. Default is "click". */ clickCallback: "click", /** * Property: layers * {Array(<OpenLayers.Layer.WMTS>)} The layers to query for feature info. * If omitted, all map WMTS layers will be considered. */ layers: null, /** * APIProperty: queryVisible * {Boolean} Filter out hidden layers when searching the map for layers to * query. Default is true. */ queryVisible: true, /** * Property: infoFormat * {String} The mimetype to request from the server */ infoFormat: 'text/html', /** * Property: vendorParams * {Object} Additional parameters that will be added to the request, for * WMTS implementations that support them. This could e.g. look like * (start code) * { * radius: 5 * } * (end) */ vendorParams: {}, /** * Property: format * {<OpenLayers.Format>} A format for parsing GetFeatureInfo responses. * Default is <OpenLayers.Format.WMSGetFeatureInfo>. */ format: null, /** * Property: formatOptions * {Object} Optional properties to set on the format (if one is not provided * in the <format> property. */ formatOptions: null, /** * APIProperty: handlerOptions * {Object} Additional options for the handlers used by this control, e.g. * (start code) * { * "click": {delay: 100}, * "hover": {delay: 300} * } * (end) */ /** * Property: handler * {Object} Reference to the <OpenLayers.Handler> for this control */ handler: null, /** * Property: hoverRequest * {<OpenLayers.Request>} contains the currently running hover request * (if any). */ hoverRequest: null, /** * APIProperty: events * {<OpenLayers.Events>} Events instance for listeners and triggering * control specific events. * * Register a listener for a particular event with the following syntax: * (code) * control.events.register(type, obj, listener); * (end) * * Supported event types (in addition to those from <OpenLayers.Control.events>): * beforegetfeatureinfo - Triggered before each request is sent. * The event object has an *xy* property with the position of the * mouse click or hover event that triggers the request and a *layer* * property referencing the layer about to be queried. If a listener * returns false, the request will not be issued. * getfeatureinfo - Triggered when a GetFeatureInfo response is received. * The event object has a *text* property with the body of the * response (String), a *features* property with an array of the * parsed features, an *xy* property with the position of the mouse * click or hover event that triggered the request, a *layer* property * referencing the layer queried and a *request* property with the * request itself. If drillDown is set to true, one event will be fired * for each layer queried. * exception - Triggered when a GetFeatureInfo request fails (with a * status other than 200) or whenparsing fails. Listeners will receive * an event with *request*, *xy*, and *layer* properties. In the case * of a parsing error, the event will also contain an *error* property. */ /** * Property: pending * {Number} The number of pending requests. */ pending: 0, /** * Constructor: <OpenLayers.Control.WMTSGetFeatureInfo> * * Parameters: * options - {Object} */ initialize: function(options) { options = options || {}; options.handlerOptions = options.handlerOptions || {}; OpenLayers.Control.prototype.initialize.apply(this, [options]); if (!this.format) { this.format = new OpenLayers.Format.WMSGetFeatureInfo( options.formatOptions ); } if (this.drillDown === true) { this.hover = false; } if (this.hover) { this.handler = new OpenLayers.Handler.Hover( this, { move: this.cancelHover, pause: this.getInfoForHover }, OpenLayers.Util.extend( this.handlerOptions.hover || {}, {delay: 250} ) ); } else { var callbacks = {}; callbacks[this.clickCallback] = this.getInfoForClick; this.handler = new OpenLayers.Handler.Click( this, callbacks, this.handlerOptions.click || {} ); } }, /** * Method: getInfoForClick * Called on click * * Parameters: * evt - {<OpenLayers.Event>} */ getInfoForClick: function(evt) { this.request(evt.xy, {}); }, /** * Method: getInfoForHover * Pause callback for the hover handler * * Parameters: * evt - {Object} */ getInfoForHover: function(evt) { this.request(evt.xy, {hover: true}); }, /** * Method: cancelHover * Cancel callback for the hover handler */ cancelHover: function() { if (this.hoverRequest) { --this.pending; if (this.pending <= 0) { OpenLayers.Element.removeClass(this.map.viewPortDiv, "olCursorWait"); this.pending = 0; } this.hoverRequest.abort(); this.hoverRequest = null; } }, /** * Method: findLayers * Internal method to get the layers, independent of whether we are * inspecting the map or using a client-provided array */ findLayers: function() { var candidates = this.layers || this.map.layers; var layers = []; var layer; for (var i=candidates.length-1; i>=0; --i) { layer = candidates[i]; if (layer instanceof OpenLayers.Layer.WMTS && layer.requestEncoding === this.requestEncoding && (!this.queryVisible || layer.getVisibility())) { layers.push(layer); if (!this.drillDown || this.hover) { break; } } } return layers; }, /** * Method: buildRequestOptions * Build an object with the relevant options for the GetFeatureInfo request. * * Parameters: * layer - {<OpenLayers.Layer.WMTS>} A WMTS layer. * xy - {<OpenLayers.Pixel>} The position on the map where the * mouse event occurred. */ buildRequestOptions: function(layer, xy) { var loc = this.map.getLonLatFromPixel(xy); var getTileUrl = layer.getURL( new OpenLayers.Bounds(loc.lon, loc.lat, loc.lon, loc.lat) ); var params = OpenLayers.Util.getParameters(getTileUrl); var tileInfo = layer.getTileInfo(loc); OpenLayers.Util.extend(params, { service: "WMTS", version: layer.version, request: "GetFeatureInfo", infoFormat: this.infoFormat, i: tileInfo.i, j: tileInfo.j }); OpenLayers.Util.applyDefaults(params, this.vendorParams); return { url: OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url, params: OpenLayers.Util.upperCaseObject(params), callback: function(request) { this.handleResponse(xy, request, layer); }, scope: this }; }, /** * Method: request * Sends a GetFeatureInfo request to the WMTS * * Parameters: * xy - {<OpenLayers.Pixel>} The position on the map where the mouse event * occurred. * options - {Object} additional options for this method. * * Valid options: * - *hover* {Boolean} true if we do the request for the hover handler */ request: function(xy, options) { options = options || {}; var layers = this.findLayers(); if (layers.length > 0) { var issue, layer; for (var i=0, len=layers.length; i<len; i++) { layer = layers[i]; issue = this.events.triggerEvent("beforegetfeatureinfo", { xy: xy, layer: layer }); if (issue !== false) { ++this.pending; var requestOptions = this.buildRequestOptions(layer, xy); var request = OpenLayers.Request.GET(requestOptions); if (options.hover === true) { this.hoverRequest = request; } } } if (this.pending > 0) { OpenLayers.Element.addClass(this.map.viewPortDiv, "olCursorWait"); } } }, /** * Method: handleResponse * Handler for the GetFeatureInfo response. * * Parameters: * xy - {<OpenLayers.Pixel>} The position on the map where the mouse event * occurred. * request - {XMLHttpRequest} The request object. * layer - {<OpenLayers.Layer.WMTS>} The queried layer. */ handleResponse: function(xy, request, layer) { --this.pending; if (this.pending <= 0) { OpenLayers.Element.removeClass(this.map.viewPortDiv, "olCursorWait"); this.pending = 0; } if (request.status && (request.status < 200 || request.status >= 300)) { this.events.triggerEvent("exception", { xy: xy, request: request, layer: layer }); } else { var doc = request.responseXML; if (!doc || !doc.documentElement) { doc = request.responseText; } var features, except; try { features = this.format.read(doc); } catch (error) { except = true; this.events.triggerEvent("exception", { xy: xy, request: request, error: error, layer: layer }); } if (!except) { this.events.triggerEvent("getfeatureinfo", { text: request.responseText, features: features, request: request, xy: xy, layer: layer }); } } }, CLASS_NAME: "OpenLayers.Control.WMTSGetFeatureInfo" });
savchukoleksii/beaversteward
www/settings/tools/mysql/js/openlayers/src/openlayers/lib/OpenLayers/Control/WMTSGetFeatureInfo.js
JavaScript
mit
13,040
[ 30522, 1013, 1008, 9385, 1006, 1039, 1007, 2294, 1011, 2286, 2011, 2330, 24314, 2015, 16884, 1006, 2156, 6048, 1012, 19067, 2102, 2005, 1008, 2440, 2862, 1997, 16884, 1007, 1012, 2405, 2104, 1996, 1016, 1011, 11075, 18667, 2094, 6105, 1012,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
Photos = new orion.collection('photos', { singularName: 'photo', pluralName: 'photos', link: { title: 'Photos' }, tabular: { columns: [ {data: 'title', title: 'Title'}, {data: 'state', title: 'State'}, //ToDo: Thumbnail orion.attributeColumn('markdown', 'body', 'Content'), orion.attributeColumn('createdAt', 'createdAt', 'Created At'), orion.attributeColumn('createdBy', 'createdBy', 'Created By') ] } }); Photos.attachSchema(new SimpleSchema({ title: {type: String}, state: { type: String, allowedValues: [ "draft", "published", "archived" ], label: "State" }, userId: orion.attribute('hasOne', { type: String, label: 'Author', optional: false }, { collection: Meteor.users, // the key whose value you want to show for each Post document on the Update form titleField: 'profile.name', publicationName: 'PB_Photos_Author', }), image: orion.attribute('image', { optional: true, label: 'Image' }), body: orion.attribute('markdown', { label: 'Body' }), createdBy: orion.attribute('createdBy', { label: 'Created By' }), createdAt: orion.attribute('createdAt', { label: 'Created At' }), lockedBy: { type: String, autoform: { type: 'hidden' }, optional: true } }));
JavaScript-NZ/javascript-website-v2
app/lib/collections/2_photos.js
JavaScript
mit
1,358
[ 30522, 7760, 1027, 2047, 18747, 1012, 3074, 1006, 1005, 7760, 1005, 1010, 1063, 13048, 18442, 1024, 1005, 6302, 1005, 1010, 13994, 18442, 1024, 1005, 7760, 1005, 1010, 4957, 1024, 1063, 2516, 1024, 1005, 7760, 1005, 1065, 1010, 21628, 7934,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// The translations in this file are added by default. 'use strict'; module.exports = { counterpart: { names: require('date-names/en'), pluralize: require('pluralizers/en'), formats: { date: { default: '%a, %e %b %Y', long: '%A, %B %o, %Y', short: '%b %e', }, time: { default: '%H:%M', long: '%H:%M:%S %z', short: '%H:%M', }, datetime: { default: '%a, %e %b %Y %H:%M', long: '%A, %B %o, %Y %H:%M:%S %z', short: '%e %b %H:%M', }, }, }, };
TimCliff/steemit.com
src/app/locales/counterpart/zh.js
JavaScript
mit
699
[ 30522, 1013, 1013, 1996, 11913, 1999, 2023, 5371, 2024, 2794, 2011, 12398, 1012, 1005, 2224, 9384, 1005, 1025, 11336, 1012, 14338, 1027, 1063, 13637, 1024, 1063, 3415, 1024, 5478, 1006, 1005, 3058, 1011, 3415, 1013, 4372, 1005, 1007, 1010, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package org.openbase.bco.dal.test.layer.unit.location; /*- * #%L * BCO DAL Test * %% * Copyright (C) 2014 - 2021 openbase.org * %% * This program 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 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 Lesser Public License for more details. * * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. * #L% */ import lombok.extern.slf4j.Slf4j; import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.jupiter.api.AfterEach; import org.openbase.bco.dal.control.layer.unit.device.DeviceManagerLauncher; import org.openbase.bco.dal.control.layer.unit.user.UserManagerLauncher; import org.openbase.bco.dal.lib.layer.unit.UnitController; import org.openbase.bco.dal.test.AbstractBCOTest; import org.openbase.bco.dal.control.layer.unit.location.LocationManagerLauncher; import org.openbase.bco.dal.test.layer.unit.device.AbstractBCODeviceManagerTest; import org.openbase.jul.exception.CouldNotPerformException; import org.openbase.jul.exception.printer.ExceptionPrinter; import org.slf4j.LoggerFactory; /** * * @author <a href="mailto:pLeminoq@openbase.org">Tamino Huxohl</a> */ @Slf4j public class AbstractBCOLocationManagerTest extends AbstractBCOTest { private static final org.slf4j.Logger logger = LoggerFactory.getLogger(AbstractBCOLocationManagerTest.class); protected static DeviceManagerLauncher deviceManagerLauncher; protected static LocationManagerLauncher locationManagerLauncher; protected static UserManagerLauncher userManagerLauncher; @BeforeClass public static void setUpClass() throws Throwable { try { AbstractBCOTest.setUpClass(); deviceManagerLauncher = new DeviceManagerLauncher(); deviceManagerLauncher.launch().get(); userManagerLauncher = new UserManagerLauncher(); userManagerLauncher.launch().get(); locationManagerLauncher = new LocationManagerLauncher(); locationManagerLauncher.launch().get(); } catch (Throwable ex) { throw ExceptionPrinter.printHistoryAndReturnThrowable(ex, logger); } } @AfterClass public static void tearDownClass() throws Throwable { try { if (userManagerLauncher != null) { userManagerLauncher.shutdown(); } if (deviceManagerLauncher != null) { deviceManagerLauncher.shutdown(); } if (locationManagerLauncher != null) { locationManagerLauncher.shutdown(); } AbstractBCOTest.tearDownClass(); } catch (Throwable ex) { throw ExceptionPrinter.printHistoryAndReturnThrowable(ex, logger); } } /** * Method is for unit tests where one has to make sure that all actions are removed from the action stack in order to minimize influence of other tests. * * @throws InterruptedException is thrown if the thread was externally interrupted */ @AfterEach @After public void cancelAllOngoingActions() throws InterruptedException { log.info("Cancel all ongoing actions..."); try { for (UnitController<?, ?> deviceController : deviceManagerLauncher.getLaunchable().getUnitControllerRegistry().getEntries()) { deviceController.cancelAllActions(); } } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not cancel all ongoing actions!", ex, log); } } }
DivineCooperation/bco.dal
test/src/test/java/org/openbase/bco/dal/test/layer/unit/location/AbstractBCOLocationManagerTest.java
Java
gpl-3.0
4,041
[ 30522, 7427, 8917, 1012, 2330, 15058, 1012, 4647, 2080, 1012, 17488, 1012, 3231, 1012, 6741, 1012, 30524, 1008, 9385, 1006, 1039, 1007, 2297, 1011, 25682, 2330, 15058, 1012, 8917, 1008, 1003, 1003, 1008, 2023, 2565, 2003, 2489, 4007, 1024, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>OR-Tools</title> <meta http-equiv="Content-Type" content="text/html;"/> <meta charset="utf-8"/> <!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>--> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="styleSheet.tmp.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="banner-container"> <div id="banner"> <span id="sfml">Google OR-Tools 9.2</span> </div> </div> <div id="content" style="width: 100%; overflow: hidden;"> <div style="margin-left: 15px; margin-top: 5px; float: left; color: #145A32;"> <h2>Java Reference</h2> <ul> <li><a href="../java/namespacecom_1_1google_1_1ortools_1_1sat.html">CP-SAT</a></li> <li><a href="../java/namespacecom_1_1google_1_1ortools_1_1graph.html">Graph</a></li> <li><a href="../java/namespacecom_1_1google_1_1ortools_1_1algorithms.html">Knapsack solver</a></li> <li><a href="../java/namespacecom_1_1google_1_1ortools_1_1linearsolver.html">Linear solver</a></li> <li><a href="../java/namespacecom_1_1google_1_1ortools_1_1constraintsolver.html">Routing</a></li> <li><a href="../java/namespacecom_1_1google_1_1ortools_1_1util.html">Util</a></li> </ul> </div> <div id="content"> <div align="center"> <h1 style="color: #145A32;">Java Reference</h1> </div> <!-- Generated by Doxygen 1.9.2 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */ var searchBox = new SearchBox("searchBox", "search",'Search','.html'); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */ </script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */ $(document).ready(function(){initNavTree('interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html',''); initResizable(); }); /* @license-end */ </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="summary"> <a href="#pub-methods">Public Member Functions</a> &#124; <a href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder-members.html">List of all members</a> </div> <div class="headertitle"><div class="title">IntervalConstraintProtoOrBuilder</div></div> </div><!--header--> <div class="contents"> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"> <p class="definition">Definition at line <a class="el" href="IntervalConstraintProtoOrBuilder_8java_source.html#l00006">6</a> of file <a class="el" href="IntervalConstraintProtoOrBuilder_8java_source.html">IntervalConstraintProtoOrBuilder.java</a>.</p> </div><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr class="memitem:af9618a9e1f1a516f3afe9accf2f68e9e"><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#af9618a9e1f1a516f3afe9accf2f68e9e">hasStart</a> ()</td></tr> <tr class="separator:af9618a9e1f1a516f3afe9accf2f68e9e"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a8471b7bf1bceb8a6b370d0b4f61cc6da"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProto.html">com.google.ortools.sat.LinearExpressionProto</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a8471b7bf1bceb8a6b370d0b4f61cc6da">getStart</a> ()</td></tr> <tr class="separator:a8471b7bf1bceb8a6b370d0b4f61cc6da"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a5e52f9711ecacca9fc2b3b02f0a524bf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProtoOrBuilder.html">com.google.ortools.sat.LinearExpressionProtoOrBuilder</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a5e52f9711ecacca9fc2b3b02f0a524bf">getStartOrBuilder</a> ()</td></tr> <tr class="separator:a5e52f9711ecacca9fc2b3b02f0a524bf"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a9b0197a2b2718c7b0061d19d4b1fbcb4"><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a9b0197a2b2718c7b0061d19d4b1fbcb4">hasEnd</a> ()</td></tr> <tr class="memdesc:a9b0197a2b2718c7b0061d19d4b1fbcb4"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>.operations_research.sat.LinearExpressionProto end = 5;</code> <a href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a9b0197a2b2718c7b0061d19d4b1fbcb4">More...</a><br /></td></tr> <tr class="separator:a9b0197a2b2718c7b0061d19d4b1fbcb4"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a13b3a6bdbc3183c45d0197e8d7171849"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProto.html">com.google.ortools.sat.LinearExpressionProto</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a13b3a6bdbc3183c45d0197e8d7171849">getEnd</a> ()</td></tr> <tr class="memdesc:a13b3a6bdbc3183c45d0197e8d7171849"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>.operations_research.sat.LinearExpressionProto end = 5;</code> <a href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a13b3a6bdbc3183c45d0197e8d7171849">More...</a><br /></td></tr> <tr class="separator:a13b3a6bdbc3183c45d0197e8d7171849"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:aac9907139f4212fc3afeb8db5d2c6645"><td class="memItemLeft" align="right" valign="top"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProtoOrBuilder.html">com.google.ortools.sat.LinearExpressionProtoOrBuilder</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#aac9907139f4212fc3afeb8db5d2c6645">getEndOrBuilder</a> ()</td></tr> <tr class="memdesc:aac9907139f4212fc3afeb8db5d2c6645"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>.operations_research.sat.LinearExpressionProto end = 5;</code> <a href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#aac9907139f4212fc3afeb8db5d2c6645">More...</a><br /></td></tr> <tr class="separator:aac9907139f4212fc3afeb8db5d2c6645"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a3ad38ce6c081e909851785725d3c4f8a"><td class="memItemLeft" align="right" valign="top">boolean&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a3ad38ce6c081e909851785725d3c4f8a">hasSize</a> ()</td></tr> <tr class="memdesc:a3ad38ce6c081e909851785725d3c4f8a"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>.operations_research.sat.LinearExpressionProto size = 6;</code> <a href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a3ad38ce6c081e909851785725d3c4f8a">More...</a><br /></td></tr> <tr class="separator:a3ad38ce6c081e909851785725d3c4f8a"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:aa15366d92d2522f2c4bbb87ccbda5047"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProto.html">com.google.ortools.sat.LinearExpressionProto</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#aa15366d92d2522f2c4bbb87ccbda5047">getSize</a> ()</td></tr> <tr class="memdesc:aa15366d92d2522f2c4bbb87ccbda5047"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>.operations_research.sat.LinearExpressionProto size = 6;</code> <a href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#aa15366d92d2522f2c4bbb87ccbda5047">More...</a><br /></td></tr> <tr class="separator:aa15366d92d2522f2c4bbb87ccbda5047"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:a237a9bec82dc82d4048ff2ab810601e2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProtoOrBuilder.html">com.google.ortools.sat.LinearExpressionProtoOrBuilder</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a237a9bec82dc82d4048ff2ab810601e2">getSizeOrBuilder</a> ()</td></tr> <tr class="memdesc:a237a9bec82dc82d4048ff2ab810601e2"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>.operations_research.sat.LinearExpressionProto size = 6;</code> <a href="interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html#a237a9bec82dc82d4048ff2ab810601e2">More...</a><br /></td></tr> <tr class="separator:a237a9bec82dc82d4048ff2ab810601e2"><td class="memSeparator" colspan="2">&#160;</td></tr> </table> <h2 class="groupheader">Member Function Documentation</h2> <a id="a13b3a6bdbc3183c45d0197e8d7171849" name="a13b3a6bdbc3183c45d0197e8d7171849"></a> <h2 class="memtitle"><span class="permalink"><a href="#a13b3a6bdbc3183c45d0197e8d7171849">&#9670;&nbsp;</a></span>getEnd()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProto.html">com.google.ortools.sat.LinearExpressionProto</a> getEnd </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p><code>.operations_research.sat.LinearExpressionProto end = 5;</code> </p> <dl class="section return"><dt>Returns</dt><dd>The end. </dd></dl> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#ac9171ca504d921151aeb477411c3b87d">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#a13b3a6bdbc3183c45d0197e8d7171849">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="aac9907139f4212fc3afeb8db5d2c6645" name="aac9907139f4212fc3afeb8db5d2c6645"></a> <h2 class="memtitle"><span class="permalink"><a href="#aac9907139f4212fc3afeb8db5d2c6645">&#9670;&nbsp;</a></span>getEndOrBuilder()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProtoOrBuilder.html">com.google.ortools.sat.LinearExpressionProtoOrBuilder</a> getEndOrBuilder </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p><code>.operations_research.sat.LinearExpressionProto end = 5;</code> </p> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#ab7d75ba562819ebaf4f3174a34bae7c1">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#aac9907139f4212fc3afeb8db5d2c6645">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="aa15366d92d2522f2c4bbb87ccbda5047" name="aa15366d92d2522f2c4bbb87ccbda5047"></a> <h2 class="memtitle"><span class="permalink"><a href="#aa15366d92d2522f2c4bbb87ccbda5047">&#9670;&nbsp;</a></span>getSize()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProto.html">com.google.ortools.sat.LinearExpressionProto</a> getSize </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p><code>.operations_research.sat.LinearExpressionProto size = 6;</code> </p> <dl class="section return"><dt>Returns</dt><dd>The size. </dd></dl> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#aaf089b475af5c0506025e946bb3cb054">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#aa15366d92d2522f2c4bbb87ccbda5047">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="a237a9bec82dc82d4048ff2ab810601e2" name="a237a9bec82dc82d4048ff2ab810601e2"></a> <h2 class="memtitle"><span class="permalink"><a href="#a237a9bec82dc82d4048ff2ab810601e2">&#9670;&nbsp;</a></span>getSizeOrBuilder()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProtoOrBuilder.html">com.google.ortools.sat.LinearExpressionProtoOrBuilder</a> getSizeOrBuilder </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p><code>.operations_research.sat.LinearExpressionProto size = 6;</code> </p> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#aa3cd3b64451c6eb1510d64b4802d78e3">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#a237a9bec82dc82d4048ff2ab810601e2">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="a8471b7bf1bceb8a6b370d0b4f61cc6da" name="a8471b7bf1bceb8a6b370d0b4f61cc6da"></a> <h2 class="memtitle"><span class="permalink"><a href="#a8471b7bf1bceb8a6b370d0b4f61cc6da">&#9670;&nbsp;</a></span>getStart()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProto.html">com.google.ortools.sat.LinearExpressionProto</a> getStart </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <pre> IMPORTANT: For now, this constraint do not enforce any relations on the view, and a linear constraint must be added together with this to enforce enforcement =&gt; start + size == end. An enforcement =&gt; size &gt;=0 might also be needed. IMPORTANT: For now, we just support affine relation. We could easily create an intermediate variable to support full linear expression, but this isn't done currently. </pre><p ><code>.operations_research.sat.LinearExpressionProto start = 4;</code> </p><dl class="section return"><dt>Returns</dt><dd>The start. </dd></dl> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#a2c4b3e0b0fbe2599af27edb00d47b759">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#a8471b7bf1bceb8a6b370d0b4f61cc6da">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="a5e52f9711ecacca9fc2b3b02f0a524bf" name="a5e52f9711ecacca9fc2b3b02f0a524bf"></a> <h2 class="memtitle"><span class="permalink"><a href="#a5e52f9711ecacca9fc2b3b02f0a524bf">&#9670;&nbsp;</a></span>getStartOrBuilder()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpressionProtoOrBuilder.html">com.google.ortools.sat.LinearExpressionProtoOrBuilder</a> getStartOrBuilder </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <pre> IMPORTANT: For now, this constraint do not enforce any relations on the view, and a linear constraint must be added together with this to enforce enforcement =&gt; start + size == end. An enforcement =&gt; size &gt;=0 might also be needed. IMPORTANT: For now, we just support affine relation. We could easily create an intermediate variable to support full linear expression, but this isn't done currently. </pre><p ><code>.operations_research.sat.LinearExpressionProto start = 4;</code> </p> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#a3e71ab24003723fe61b18d77f826c001">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#a5e52f9711ecacca9fc2b3b02f0a524bf">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="a9b0197a2b2718c7b0061d19d4b1fbcb4" name="a9b0197a2b2718c7b0061d19d4b1fbcb4"></a> <h2 class="memtitle"><span class="permalink"><a href="#a9b0197a2b2718c7b0061d19d4b1fbcb4">&#9670;&nbsp;</a></span>hasEnd()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">boolean hasEnd </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p><code>.operations_research.sat.LinearExpressionProto end = 5;</code> </p> <dl class="section return"><dt>Returns</dt><dd>Whether the end field is set. </dd></dl> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#adb53e4a8cf21af1718b697ba52ee1a15">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#a9b0197a2b2718c7b0061d19d4b1fbcb4">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="a3ad38ce6c081e909851785725d3c4f8a" name="a3ad38ce6c081e909851785725d3c4f8a"></a> <h2 class="memtitle"><span class="permalink"><a href="#a3ad38ce6c081e909851785725d3c4f8a">&#9670;&nbsp;</a></span>hasSize()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">boolean hasSize </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p><code>.operations_research.sat.LinearExpressionProto size = 6;</code> </p> <dl class="section return"><dt>Returns</dt><dd>Whether the size field is set. </dd></dl> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#aae9643420ff88cb4c38c8e9181dd35ac">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#a3ad38ce6c081e909851785725d3c4f8a">IntervalConstraintProto.Builder</a>.</p> </div> </div> <a id="af9618a9e1f1a516f3afe9accf2f68e9e" name="af9618a9e1f1a516f3afe9accf2f68e9e"></a> <h2 class="memtitle"><span class="permalink"><a href="#af9618a9e1f1a516f3afe9accf2f68e9e">&#9670;&nbsp;</a></span>hasStart()</h2> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">boolean hasStart </td> <td>(</td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <pre> IMPORTANT: For now, this constraint do not enforce any relations on the view, and a linear constraint must be added together with this to enforce enforcement =&gt; start + size == end. An enforcement =&gt; size &gt;=0 might also be needed. IMPORTANT: For now, we just support affine relation. We could easily create an intermediate variable to support full linear expression, but this isn't done currently. </pre><p ><code>.operations_research.sat.LinearExpressionProto start = 4;</code> </p><dl class="section return"><dt>Returns</dt><dd>Whether the start field is set. </dd></dl> <p>Implemented in <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto.html#af42348e54b4d3cb22d8020f260aa886c">IntervalConstraintProto</a>, and <a class="el" href="classcom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProto_1_1Builder.html#af9618a9e1f1a516f3afe9accf2f68e9e">IntervalConstraintProto.Builder</a>.</p> </div> </div> <hr/>The documentation for this interface was generated from the following file:<ul> <li><a class="el" href="IntervalConstraintProtoOrBuilder_8java_source.html">IntervalConstraintProtoOrBuilder.java</a></li> </ul> </div><!-- contents --> </div><!-- doc-content --> </div> </div> <div id="footer-container"> <div id="footer"> </div> </div> </body> </html>
google/or-tools
docs/java/interfacecom_1_1google_1_1ortools_1_1sat_1_1IntervalConstraintProtoOrBuilder.html
HTML
apache-2.0
23,010
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, 19968, 1015, 1012, 1014, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
reverseStr(s string, k int) string { bs := []byte(s) for i := 0; i < len(bs); i += 2 * k { if (i+k-1) >= len(bs) { reverse(&bs, i, len(bs)-1) }else{ reverse(&bs, i, i+k-1) } } return string(bs[:]) } func reverse(s *[]byte, start int, end int) { for i, j := start, end; i < j; i, j = i+1, j-1 { (*s)[i], (*s)[j] = (*s)[j], (*s)[i] } }
MingfeiPan/leetcode
string/541.go
GO
apache-2.0
436
[ 30522, 7901, 3367, 2099, 1006, 1055, 5164, 1010, 1047, 20014, 1007, 5164, 1063, 18667, 1024, 1027, 1031, 1033, 24880, 1006, 1055, 1007, 2005, 1045, 1024, 1027, 1014, 1025, 1045, 1026, 18798, 1006, 18667, 1007, 1025, 1045, 1009, 1027, 1016, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# frozen_string_literal: true module Thredded class MessageboardPolicy # The scope of readable messageboards class Scope # @param user [Thredded.user_class] # @param scope [ActiveRecord::Relation<Thredded::Messageboard>] def initialize(user, scope) @user = user @scope = scope end # @return [ActiveRecord::Relation<Thredded::Messageboards>] def resolve readable = @user.thredded_can_read_messageboards if readable == Thredded::Messageboard.all @scope else @scope.merge(readable) end end end # @param user [Thredded.user_class] # @param messageboard [Thredded::Messageboard] def initialize(user, messageboard) @user = user @messageboard = messageboard end def create? @user.thredded_admin? end def read? @user.thredded_admin? || @user.thredded_can_read_messageboard?(@messageboard) end def update? @user.thredded_admin? end def destroy? @user.thredded_admin? end def post? @user.thredded_admin? || (!@messageboard.locked? || moderate?) && @user.thredded_can_write_messageboards.include?(@messageboard) end def moderate? @user.thredded_admin? || @user.thredded_can_moderate_messageboard?(@messageboard) end end end
thredded/thredded
app/policies/thredded/messageboard_policy.rb
Ruby
mit
1,378
[ 30522, 1001, 7708, 1035, 5164, 1035, 18204, 1024, 2995, 11336, 30524, 16215, 5596, 5732, 1012, 5310, 1035, 2465, 1033, 1001, 1030, 11498, 2213, 9531, 1031, 3161, 2890, 27108, 2094, 1024, 1024, 7189, 1026, 16215, 5596, 5732, 1024, 1024, 4471...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; namespace KKMono1 { /// <summary> /// This is the main type for your game. /// </summary> public class GameBubbles : Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D imageKK; public GameBubbles() { graphics = new GraphicsDeviceManager(this); graphics.SynchronizeWithVerticalRetrace = true; graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; graphics.GraphicsProfile = GraphicsProfile.HiDef; graphics.HardwareModeSwitch = false; Content.RootDirectory = "Content"; } /// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here Window.Title = "Bubbles"; base.Initialize(); } /// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here var path = @"Images\Ball"; imageKK = Content.Load<Texture2D>(path); } /// <summary> /// UnloadContent will be called once per game and is the place to unload /// game-specific content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here } private KeyboardState keysLast = new KeyboardState(); /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit(); //count++; var keys = Keyboard.GetState(); if (keys.IsKeyDown(Keys.LeftAlt) && keys.IsKeyDown(Keys.Enter) && keysLast.IsKeyUp(Keys.Enter)) graphics.ToggleFullScreen(); keysLast = keys; // TODO: Add your update logic here base.Update(gameTime); } private int count = 0; /// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { count++; GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here spriteBatch.Begin(); /*spriteBatch.Draw(imageKK, Vector2.Zero, Color.White); spriteBatch.Draw(imageKK, position: new Vector2(500, 0), effects: SpriteEffects.FlipHorizontally); spriteBatch.Draw(imageKK, position: new Vector2(500, 0), rotation: 1, scale: new Vector2(0.1f, 0.1f));*/ var randpos = new Random(0); for (int i = 0; i < 10000; i++) { var color = new Color((float)randpos.NextDouble(), (float)randpos.NextDouble(), (float)randpos.NextDouble()); var position = new Vector2((float)randpos.NextDouble() * 1920, (float)randpos.NextDouble() * 1080); position += new Vector2((float)(20 * Math.Cos((count + randpos.NextDouble() * 1000) / 15f)), (float)(20 * Math.Sin((count + randpos.NextDouble() * 1000) / 25f))); var size = (float)(0.8 + 0.4 * randpos.NextDouble()); var rotation = (randpos.NextDouble() + (double)count / 100) * 2 * Math.PI; //spriteBatch.Draw(imageKK, position: position, rotation: (float)rotation, scale: new Vector2(size, size), origin: new Vector2(32, 32), color: color); spriteBatch.Draw(imageKK, position: position, rotation: (float)rotation, scale: new Vector2(size, size), origin: new Vector2(32, 32), color: new Color(color, 0.5f)); } spriteBatch.End(); // 3D //graphics.GraphicsDevice.DrawUserPrimitives base.Draw(gameTime); } } }
Kaskelot/Monolot
KKMono1/GameBubbles.cs
C#
gpl-2.0
5,054
[ 30522, 2478, 2291, 1025, 2478, 7513, 1012, 1060, 2532, 1012, 7705, 1025, 2478, 7513, 1012, 1060, 2532, 1012, 7705, 1012, 8389, 1025, 2478, 7513, 1012, 1060, 2532, 1012, 7705, 1012, 7953, 1025, 3415, 15327, 1047, 22287, 17175, 2487, 1063, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Kernel thread helper functions. * Copyright (C) 2004 IBM Corporation, Rusty Russell. * * Creation is done via kthreadd, so that we get a clean environment * even if we're invoked from userspace (think modprobe, hotplug cpu, * etc.). */ #include <linux/sched.h> #include <linux/kthread.h> #include <linux/completion.h> #include <linux/err.h> #include <linux/cpuset.h> #include <linux/unistd.h> #include <linux/file.h> #include <linux/export.h> #include <linux/mutex.h> #include <linux/slab.h> #include <linux/freezer.h> #include <linux/ptrace.h> #include <linux/uaccess.h> #include <trace/events/sched.h> static DEFINE_SPINLOCK(kthread_create_lock); static LIST_HEAD(kthread_create_list); struct task_struct *kthreadd_task; struct kthread_create_info { /* Information passed to kthread() from kthreadd. */ int (*threadfn)(void *data); void *data; int node; /* Result passed back to kthread_create() from kthreadd. */ struct task_struct *result; struct completion *done; struct list_head list; }; struct kthread { unsigned long flags; unsigned int cpu; void *data; struct completion parked; struct completion exited; }; enum KTHREAD_BITS { KTHREAD_IS_PER_CPU = 0, KTHREAD_SHOULD_STOP, KTHREAD_SHOULD_PARK, KTHREAD_IS_PARKED, }; #define __to_kthread(vfork) \ container_of(vfork, struct kthread, exited) static inline struct kthread *to_kthread(struct task_struct *k) { return __to_kthread(k->vfork_done); } static struct kthread *to_live_kthread(struct task_struct *k) { struct completion *vfork = ACCESS_ONCE(k->vfork_done); if (likely(vfork)) return __to_kthread(vfork); return NULL; } /** * kthread_should_stop - should this kthread return now? * * When someone calls kthread_stop() on your kthread, it will be woken * and this will return true. You should then return, and your return * value will be passed through to kthread_stop(). */ bool kthread_should_stop(void) { return test_bit(KTHREAD_SHOULD_STOP, &to_kthread(current)->flags); } EXPORT_SYMBOL(kthread_should_stop); /** * kthread_should_park - should this kthread park now? * * When someone calls kthread_park() on your kthread, it will be woken * and this will return true. You should then do the necessary * cleanup and call kthread_parkme() * * Similar to kthread_should_stop(), but this keeps the thread alive * and in a park position. kthread_unpark() "restarts" the thread and * calls the thread function again. */ bool kthread_should_park(void) { return test_bit(KTHREAD_SHOULD_PARK, &to_kthread(current)->flags); } /** * kthread_freezable_should_stop - should this freezable kthread return now? * @was_frozen: optional out parameter, indicates whether %current was frozen * * kthread_should_stop() for freezable kthreads, which will enter * refrigerator if necessary. This function is safe from kthread_stop() / * freezer deadlock and freezable kthreads should use this function instead * of calling try_to_freeze() directly. */ bool kthread_freezable_should_stop(bool *was_frozen) { bool frozen = false; might_sleep(); if (unlikely(freezing(current))) frozen = __refrigerator(true); if (was_frozen) *was_frozen = frozen; return kthread_should_stop(); } EXPORT_SYMBOL_GPL(kthread_freezable_should_stop); /** * kthread_data - return data value specified on kthread creation * @task: kthread task in question * * Return the data value specified when kthread @task was created. * The caller is responsible for ensuring the validity of @task when * calling this function. */ void *kthread_data(struct task_struct *task) { return to_kthread(task)->data; } /** * probe_kthread_data - speculative version of kthread_data() * @task: possible kthread task in question * * @task could be a kthread task. Return the data value specified when it * was created if accessible. If @task isn't a kthread task or its data is * inaccessible for any reason, %NULL is returned. This function requires * that @task itself is safe to dereference. */ void *probe_kthread_data(struct task_struct *task) { struct kthread *kthread = to_kthread(task); void *data = NULL; probe_kernel_read(&data, &kthread->data, sizeof(data)); return data; } static void __kthread_parkme(struct kthread *self) { __set_current_state(TASK_PARKED); while (test_bit(KTHREAD_SHOULD_PARK, &self->flags)) { if (!test_and_set_bit(KTHREAD_IS_PARKED, &self->flags)) complete(&self->parked); schedule(); __set_current_state(TASK_PARKED); } clear_bit(KTHREAD_IS_PARKED, &self->flags); __set_current_state(TASK_RUNNING); } void kthread_parkme(void) { __kthread_parkme(to_kthread(current)); } static int kthread(void *_create) { /* Copy data: it's on kthread's stack */ struct kthread_create_info *create = _create; int (*threadfn)(void *data) = create->threadfn; void *data = create->data; struct completion *done; struct kthread self; int ret; self.flags = 0; self.data = data; init_completion(&self.exited); init_completion(&self.parked); current->vfork_done = &self.exited; /* If user was SIGKILLed, I release the structure. */ done = xchg(&create->done, NULL); if (!done) { kfree(create); do_exit(-EINTR); } /* OK, tell user we're spawned, wait for stop or wakeup */ __set_current_state(TASK_UNINTERRUPTIBLE); create->result = current; complete(done); schedule(); ret = -EINTR; if (!test_bit(KTHREAD_SHOULD_STOP, &self.flags)) { __kthread_parkme(&self); ret = threadfn(data); } /* we can't just return, we must preserve "self" on stack */ do_exit(ret); } /* called from do_fork() to get node information for about to be created task */ int tsk_fork_get_node(struct task_struct *tsk) { #ifdef CONFIG_NUMA if (tsk == kthreadd_task) return tsk->pref_node_fork; #endif return NUMA_NO_NODE; } static void create_kthread(struct kthread_create_info *create) { int pid; #ifdef CONFIG_NUMA current->pref_node_fork = create->node; #endif /* We want our own signal handler (we take no signals by default). */ pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD); if (pid < 0) { /* If user was SIGKILLed, I release the structure. */ struct completion *done = xchg(&create->done, NULL); if (!done) { kfree(create); return; } create->result = ERR_PTR(pid); complete(done); } } /** * kthread_create_on_node - create a kthread. * @threadfn: the function to run until signal_pending(current). * @data: data ptr for @threadfn. * @node: memory node number. * @namefmt: printf-style name for the thread. * * Description: This helper function creates and names a kernel * thread. The thread will be stopped: use wake_up_process() to start * it. See also kthread_run(). * * If thread is going to be bound on a particular cpu, give its node * in @node, to get NUMA affinity for kthread stack, or else give -1. * When woken, the thread will run @threadfn() with @data as its * argument. @threadfn() can either call do_exit() directly if it is a * standalone thread for which no one will call kthread_stop(), or * return when 'kthread_should_stop()' is true (which means * kthread_stop() has been called). The return value should be zero * or a negative error number; it will be passed to kthread_stop(). * * Returns a task_struct or ERR_PTR(-ENOMEM). */ struct task_struct *kthread_create_on_node(int (*threadfn)(void *data), void *data, int node, const char namefmt[], ...) { DECLARE_COMPLETION_ONSTACK(done); struct task_struct *task; struct kthread_create_info *create = kmalloc(sizeof(*create), GFP_KERNEL); if (!create) return ERR_PTR(-ENOMEM); create->threadfn = threadfn; create->data = data; create->node = node; create->done = &done; spin_lock(&kthread_create_lock); list_add_tail(&create->list, &kthread_create_list); spin_unlock(&kthread_create_lock); wake_up_process(kthreadd_task); /* * Wait for completion in killable state, for I might be chosen by * the OOM killer while kthreadd is trying to allocate memory for * new kernel thread. */ if (unlikely(wait_for_completion_killable(&done))) { /* * If I was SIGKILLed before kthreadd (or new kernel thread) * calls complete(), leave the cleanup of this structure to * that thread. */ if (xchg(&create->done, NULL)) return ERR_PTR(-ENOMEM); /* * kthreadd (or new kernel thread) will call complete() * shortly. */ wait_for_completion(&done); } task = create->result; if (!IS_ERR(task)) { static const struct sched_param param = { .sched_priority = 0 }; va_list args; va_start(args, namefmt); vsnprintf(task->comm, sizeof(task->comm), namefmt, args); va_end(args); /* * root may have changed our (kthreadd's) priority or CPU mask. * The kernel thread should not inherit these properties. */ sched_setscheduler_nocheck(task, SCHED_NORMAL, &param); set_cpus_allowed_ptr(task, cpu_all_mask); } kfree(create); return task; } EXPORT_SYMBOL(kthread_create_on_node); static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state) { /* Must have done schedule() in kthread() before we set_task_cpu */ if (!wait_task_inactive(p, state)) { WARN_ON(1); return; } /* It's safe because the task is inactive. */ do_set_cpus_allowed(p, cpumask_of(cpu)); p->flags |= PF_NO_SETAFFINITY; } /** * kthread_bind - bind a just-created kthread to a cpu. * @p: thread created by kthread_create(). * @cpu: cpu (might not be online, must be possible) for @k to run on. * * Description: This function is equivalent to set_cpus_allowed(), * except that @cpu doesn't need to be online, and the thread must be * stopped (i.e., just returned from kthread_create()). */ void kthread_bind(struct task_struct *p, unsigned int cpu) { __kthread_bind(p, cpu, TASK_UNINTERRUPTIBLE); } EXPORT_SYMBOL(kthread_bind); /** * kthread_create_on_cpu - Create a cpu bound kthread * @threadfn: the function to run until signal_pending(current). * @data: data ptr for @threadfn. * @cpu: The cpu on which the thread should be bound, * @namefmt: printf-style name for the thread. Format is restricted * to "name.*%u". Code fills in cpu number. * * Description: This helper function creates and names a kernel thread * The thread will be woken and put into park mode. */ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data), void *data, unsigned int cpu, const char *namefmt) { struct task_struct *p; p = kthread_create_on_node(threadfn, data, cpu_to_mem(cpu), namefmt, cpu); if (IS_ERR(p)) return p; set_bit(KTHREAD_IS_PER_CPU, &to_kthread(p)->flags); to_kthread(p)->cpu = cpu; /* Park the thread to get it out of TASK_UNINTERRUPTIBLE state */ kthread_park(p); return p; } static void __kthread_unpark(struct task_struct *k, struct kthread *kthread) { clear_bit(KTHREAD_SHOULD_PARK, &kthread->flags); /* * We clear the IS_PARKED bit here as we don't wait * until the task has left the park code. So if we'd * park before that happens we'd see the IS_PARKED bit * which might be about to be cleared. */ if (test_and_clear_bit(KTHREAD_IS_PARKED, &kthread->flags)) { if (test_bit(KTHREAD_IS_PER_CPU, &kthread->flags)) __kthread_bind(k, kthread->cpu, TASK_PARKED); wake_up_state(k, TASK_PARKED); } } /** * kthread_unpark - unpark a thread created by kthread_create(). * @k: thread created by kthread_create(). * * Sets kthread_should_park() for @k to return false, wakes it, and * waits for it to return. If the thread is marked percpu then its * bound to the cpu again. */ void kthread_unpark(struct task_struct *k) { struct kthread *kthread = to_live_kthread(k); if (kthread) __kthread_unpark(k, kthread); } /** * kthread_park - park a thread created by kthread_create(). * @k: thread created by kthread_create(). * * Sets kthread_should_park() for @k to return true, wakes it, and * waits for it to return. This can also be called after kthread_create() * instead of calling wake_up_process(): the thread will park without * calling threadfn(). * * Returns 0 if the thread is parked, -ENOSYS if the thread exited. * If called by the kthread itself just the park bit is set. */ int kthread_park(struct task_struct *k) { struct kthread *kthread = to_live_kthread(k); int ret = -ENOSYS; if (kthread) { if (!test_bit(KTHREAD_IS_PARKED, &kthread->flags)) { set_bit(KTHREAD_SHOULD_PARK, &kthread->flags); if (k != current) { wake_up_process(k); wait_for_completion(&kthread->parked); } } ret = 0; } return ret; } /** * kthread_stop - stop a thread created by kthread_create(). * @k: thread created by kthread_create(). * * Sets kthread_should_stop() for @k to return true, wakes it, and * waits for it to exit. This can also be called after kthread_create() * instead of calling wake_up_process(): the thread will exit without * calling threadfn(). * * If threadfn() may call do_exit() itself, the caller must ensure * task_struct can't go away. * * Returns the result of threadfn(), or %-EINTR if wake_up_process() * was never called. */ int kthread_stop(struct task_struct *k) { struct kthread *kthread; int ret; trace_sched_kthread_stop(k); get_task_struct(k); kthread = to_live_kthread(k); if (kthread) { set_bit(KTHREAD_SHOULD_STOP, &kthread->flags); __kthread_unpark(k, kthread); wake_up_process(k); wait_for_completion(&kthread->exited); } ret = k->exit_code; put_task_struct(k); trace_sched_kthread_stop_ret(ret); return ret; } EXPORT_SYMBOL(kthread_stop); int kthreadd(void *unused) { struct task_struct *tsk = current; /* Setup a clean context for our children to inherit. */ set_task_comm(tsk, "kthreadd"); ignore_signals(tsk); set_cpus_allowed_ptr(tsk, cpu_all_mask); set_mems_allowed(node_states[N_MEMORY]); current->flags |= PF_NOFREEZE; for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (list_empty(&kthread_create_list)) schedule(); __set_current_state(TASK_RUNNING); spin_lock(&kthread_create_lock); while (!list_empty(&kthread_create_list)) { struct kthread_create_info *create; create = list_entry(kthread_create_list.next, struct kthread_create_info, list); list_del_init(&create->list); spin_unlock(&kthread_create_lock); create_kthread(create); spin_lock(&kthread_create_lock); } spin_unlock(&kthread_create_lock); } return 0; } void __init_kthread_worker(struct kthread_worker *worker, const char *name, struct lock_class_key *key) { spin_lock_init(&worker->lock); lockdep_set_class_and_name(&worker->lock, key, name); INIT_LIST_HEAD(&worker->work_list); worker->task = NULL; } EXPORT_SYMBOL_GPL(__init_kthread_worker); /** * kthread_worker_fn - kthread function to process kthread_worker * @worker_ptr: pointer to initialized kthread_worker * * This function can be used as @threadfn to kthread_create() or * kthread_run() with @worker_ptr argument pointing to an initialized * kthread_worker. The started kthread will process work_list until * the it is stopped with kthread_stop(). A kthread can also call * this function directly after extra initialization. * * Different kthreads can be used for the same kthread_worker as long * as there's only one kthread attached to it at any given time. A * kthread_worker without an attached kthread simply collects queued * kthread_works. */ int kthread_worker_fn(void *worker_ptr) { struct kthread_worker *worker = worker_ptr; struct kthread_work *work; WARN_ON(worker->task); worker->task = current; repeat: set_current_state(TASK_INTERRUPTIBLE); /* mb paired w/ kthread_stop */ if (kthread_should_stop()) { __set_current_state(TASK_RUNNING); spin_lock_irq(&worker->lock); worker->task = NULL; spin_unlock_irq(&worker->lock); return 0; } work = NULL; spin_lock_irq(&worker->lock); if (!list_empty(&worker->work_list)) { work = list_first_entry(&worker->work_list, struct kthread_work, node); list_del_init(&work->node); } worker->current_work = work; spin_unlock_irq(&worker->lock); if (work) { __set_current_state(TASK_RUNNING); work->func(work); } else if (!freezing(current)) schedule(); try_to_freeze(); goto repeat; } EXPORT_SYMBOL_GPL(kthread_worker_fn); /* insert @work before @pos in @worker */ static void insert_kthread_work(struct kthread_worker *worker, struct kthread_work *work, struct list_head *pos) { lockdep_assert_held(&worker->lock); list_add_tail(&work->node, pos); work->worker = worker; if (likely(worker->task)) wake_up_process(worker->task); } /** * queue_kthread_work - queue a kthread_work * @worker: target kthread_worker * @work: kthread_work to queue * * Queue @work to work processor @task for async execution. @task * must have been created with kthread_worker_create(). Returns %true * if @work was successfully queued, %false if it was already pending. */ bool queue_kthread_work(struct kthread_worker *worker, struct kthread_work *work) { bool ret = false; unsigned long flags; spin_lock_irqsave(&worker->lock, flags); if (list_empty(&work->node)) { insert_kthread_work(worker, work, &worker->work_list); ret = true; } spin_unlock_irqrestore(&worker->lock, flags); return ret; } EXPORT_SYMBOL_GPL(queue_kthread_work); struct kthread_flush_work { struct kthread_work work; struct completion done; }; static void kthread_flush_work_fn(struct kthread_work *work) { struct kthread_flush_work *fwork = container_of(work, struct kthread_flush_work, work); complete(&fwork->done); } /** * flush_kthread_work - flush a kthread_work * @work: work to flush * * If @work is queued or executing, wait for it to finish execution. */ void flush_kthread_work(struct kthread_work *work) { struct kthread_flush_work fwork = { KTHREAD_WORK_INIT(fwork.work, kthread_flush_work_fn), COMPLETION_INITIALIZER_ONSTACK(fwork.done), }; struct kthread_worker *worker; bool noop = false; retry: worker = work->worker; if (!worker) return; spin_lock_irq(&worker->lock); if (work->worker != worker) { spin_unlock_irq(&worker->lock); goto retry; } if (!list_empty(&work->node)) insert_kthread_work(worker, &fwork.work, work->node.next); else if (worker->current_work == work) insert_kthread_work(worker, &fwork.work, worker->work_list.next); else noop = true; spin_unlock_irq(&worker->lock); if (!noop) wait_for_completion(&fwork.done); } EXPORT_SYMBOL_GPL(flush_kthread_work); /** * flush_kthread_worker - flush all current works on a kthread_worker * @worker: worker to flush * * Wait until all currently executing or pending works on @worker are * finished. */ void flush_kthread_worker(struct kthread_worker *worker) { struct kthread_flush_work fwork = { KTHREAD_WORK_INIT(fwork.work, kthread_flush_work_fn), COMPLETION_INITIALIZER_ONSTACK(fwork.done), }; queue_kthread_work(worker, &fwork.work); wait_for_completion(&fwork.done); } EXPORT_SYMBOL_GPL(flush_kthread_worker);
iwinoto/v4l-media_build-devel
media/kernel/kthread.c
C
gpl-2.0
18,999
[ 30522, 1013, 1008, 16293, 11689, 2393, 2121, 4972, 1012, 1008, 9385, 1006, 1039, 1007, 2432, 9980, 3840, 1010, 13174, 5735, 1012, 1008, 1008, 4325, 2003, 2589, 3081, 1047, 2705, 16416, 14141, 1010, 2061, 2008, 2057, 2131, 1037, 4550, 4044, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>flocq: Not compatible</title> <link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" /> <link href="../../../../../bootstrap.min.css" rel="stylesheet"> <link href="../../../../../bootstrap-custom.css" rel="stylesheet"> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> <script src="../../../../../moment.min.js"></script> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container"> <div class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="../../../../.."><i class="fa fa-lg fa-flag-checkered"></i> Coq bench</a> </div> <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li><a href="../..">clean / released</a></li> <li class="active"><a href="">8.12.1 / flocq - 2.3.0</a></li> </ul> </div> </div> </div> <div class="article"> <div class="row"> <div class="col-md-12"> <a href="../..">« Up</a> <h1> flocq <small> 2.3.0 <span class="label label-info">Not compatible</span> </small> </h1> <p><em><script>document.write(moment("2021-04-16 14:57:06 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2021-04-16 14:57:06 UTC)</em><p> <h2>Context</h2> <pre># Packages matching: installed # Name # Installed # Synopsis base-bigarray base base-threads base base-unix base conf-findutils 1 Virtual package relying on findutils coq 8.12.1 Formal proof management system num 1.4 The legacy Num library for arbitrary-precision integer and rational arithmetic ocaml 4.10.1 The OCaml compiler (virtual package) ocaml-base-compiler 4.10.1 Official release 4.10.1 ocaml-config 1 OCaml Switch Configuration ocamlfind 1.9.1 A library manager for OCaml # opam file: opam-version: &quot;2.0&quot; maintainer: &quot;guillaume.melquiond@inria.fr&quot; homepage: &quot;http://flocq.gforge.inria.fr/&quot; dev-repo: &quot;git+https://gitlab.inria.fr/flocq/flocq&quot; bug-reports: &quot;https://gitlab.inria.fr/flocq/flocq/issues&quot; license: &quot;LGPL 3&quot; build: [ [&quot;./configure&quot; &quot;--libdir&quot; &quot;%{lib}%/coq/user-contrib/Flocq&quot;] [&quot;./remake&quot; &quot;-j%{jobs}%&quot;] ] install: [&quot;./remake&quot; &quot;install&quot;] remove: [&quot;rm&quot; &quot;-R&quot; &quot;%{lib}%/coq/user-contrib/Flocq&quot;] depends: [ &quot;ocaml&quot; &quot;coq&quot; {&gt;= &quot;8.4pl4&quot; &amp; &lt; &quot;8.5~&quot;} ] tags: [ &quot;keyword:floating-point arithmetic&quot; ] authors: [ &quot;Sylvie Boldo &lt;sylvie.boldo@inria.fr&gt;&quot; &quot;Guillaume Melquiond &lt;guillaume.melquiond@inria.fr&gt;&quot; ] synopsis: &quot;A floating-point formalization for the Coq system&quot; flags: light-uninstall url { src: &quot;https://gforge.inria.fr/frs/download.php/33502/flocq-2.3.0.tar.gz&quot; checksum: &quot;md5=0dc9fb2a46f9d8ffcce17f287fc3bd8b&quot; } </pre> <h2>Lint</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>true</code></dd> <dt>Return code</dt> <dd>0</dd> </dl> <h2>Dry install</h2> <p>Dry install with the current Coq version:</p> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>opam install -y --show-action coq-flocq.2.3.0 coq.8.12.1</code></dd> <dt>Return code</dt> <dd>5120</dd> <dt>Output</dt> <dd><pre>[NOTE] Package coq is already installed (current version is 8.12.1). The following dependencies couldn&#39;t be met: - coq-flocq -&gt; coq &lt; 8.5~ -&gt; ocaml &lt; 4.03.0 base of this switch (use `--unlock-base&#39; to force) No solution found, exiting </pre></dd> </dl> <p>Dry install without Coq/switch base, to test if the problem was incompatibility with the current Coq/OCaml version:</p> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>opam remove -y coq; opam install -y --show-action --unlock-base coq-flocq.2.3.0</code></dd> <dt>Return code</dt> <dd>0</dd> </dl> <h2>Install dependencies</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>true</code></dd> <dt>Return code</dt> <dd>0</dd> <dt>Duration</dt> <dd>0 s</dd> </dl> <h2>Install</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>true</code></dd> <dt>Return code</dt> <dd>0</dd> <dt>Duration</dt> <dd>0 s</dd> </dl> <h2>Installation size</h2> <p>No files were installed.</p> <h2>Uninstall</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>true</code></dd> <dt>Return code</dt> <dd>0</dd> <dt>Missing removes</dt> <dd> none </dd> <dt>Wrong removes</dt> <dd> none </dd> </dl> </div> </div> </div> <hr/> <div class="footer"> <p class="text-center"> <small>Sources are on <a href="https://github.com/coq-bench">GitHub</a>. © Guillaume Claret.</small> </p> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="../../../../../bootstrap.min.js"></script> </body> </html>
coq-bench/coq-bench.github.io
clean/Linux-x86_64-4.10.1-2.0.6/released/8.12.1/flocq/2.3.0.html
HTML
mit
6,643
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 2171, 1027, 1000, 3193, 6442, 1000, 418...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
"use strict"; var Response = (function () { function Response(result, childWork) { this.result = result; this.childWork = childWork; } return Response; }()); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Response; //# sourceMappingURL=response.js.map
colinmathews/node-workhorse
dist/lib/models/response.js
JavaScript
mit
313
[ 30522, 1000, 2224, 9384, 1000, 1025, 13075, 3433, 1027, 1006, 3853, 1006, 1007, 1063, 3853, 3433, 1006, 2765, 1010, 2775, 6198, 1007, 1063, 2023, 1012, 2765, 1027, 2765, 1025, 2023, 1012, 2775, 6198, 1027, 2775, 6198, 1025, 1065, 2709, 34...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.youthclub.model.support; import org.codehaus.jackson.annotate.JsonAutoDetect; import org.codehaus.jackson.annotate.JsonProperty; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; /** * @author Frank <frank@baileyroberts.com.au> */ @JsonAutoDetect(creatorVisibility = NONE, fieldVisibility = NONE, getterVisibility = NONE, isGetterVisibility = NONE, setterVisibility = NONE) public interface RestfulEnum { @JsonProperty String getLabel(); }
taopmindray/server
data/src/main/java/com/youthclub/model/support/RestfulEnum.java
Java
gpl-2.0
524
[ 30522, 7427, 4012, 1012, 3360, 20464, 12083, 1012, 2944, 1012, 2490, 1025, 12324, 8917, 1012, 3642, 13821, 1012, 4027, 1012, 5754, 17287, 2618, 1012, 1046, 3385, 4887, 3406, 3207, 26557, 2102, 1025, 12324, 8917, 1012, 3642, 13821, 1012, 402...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * $Header:$ */ package org.apache.beehive.netui.util; import java.util.Map; import java.util.List; import java.lang.reflect.Array; import org.apache.beehive.netui.util.logging.Logger; /** * This class is used by NetUI tags that use parameters. */ public class ParamHelper { private static final Logger logger = Logger.getInstance(ParamHelper.class); /** * Add a new parameter or update an existing parameter's list of values. * <p/> * <em>Implementation Note:</em> in the case that a Map was provided for * the <code>value</code> parameter, the this returns without doing * anything; in any other case, params is updated (even in * <code>value</code> is null). * </p> * <p/> * If value is some object (not an array or list), the string * representation of that object is added as a value for name. If the * value is a list (or array) of objects, then the string representation * of each element is added as a value for name. When there are multiple * values for a name, then an array of Strings is used in Map. * </p> * * @param params an existing Map of names and values to update * @param name the name of the parameter to add or update * @param value an item or list of items to put into the map * @throws IllegalArgumentException in the case that either the params * <p/> * or name given was null */ public static void addParam(Map params, String name, Object value) { if (params == null) throw new IllegalArgumentException("Parameter map cannot be null"); if (name == null) throw new IllegalArgumentException("Parameter name cannot be null"); if (value instanceof Map) { logger.warn(Bundle.getString("Tags_BadParameterType", name)); return; } if (value == null) value = ""; // check to see if we are adding a new element // or if this is an existing element Object o = params.get(name); int length = 0; if (o != null) { assert (o instanceof String || o instanceof String[]); if (o.getClass().isArray()) { length = Array.getLength(o); } else { length++; } } // check how much size the output needs to be if (value.getClass().isArray()) { length += Array.getLength(value); } else if (value instanceof List) { length += ((List) value).size(); } else { length++; } if (length == 0) return; //System.err.println("Number of vaues:" + length); // if there is only a single value push it to the parameter table if (length == 1) { if (value.getClass().isArray()) { Object val = Array.get(value, 0); if (val != null) params.put(name,val.toString()); else params.put(name,""); } else if (value instanceof List) { List list = (List) value; Object val = list.get(0); if (val != null) params.put(name,val.toString()); else params.put(name,""); } else params.put(name,value.toString()); return; } // allocate the string for the multiple values String[] values = new String[length]; int offset = 0; // if we had old values, push them to the new array if (o != null) { if (o.getClass().isArray()) { String[] obs = (String[]) o; for (;offset<obs.length;offset++) { values[offset] = obs[offset]; } } else { values[0] = o.toString(); offset = 1; } } // now move the new values to the array starting at the offset // position if (value.getClass().isArray()) { //need to convert this array into a String[] int size = Array.getLength(value); for (int i=0; i < size; i++) { Object val = Array.get(value, i); if (val != null) values[i+offset] = val.toString(); else values[i+offset] = ""; } } else if (value instanceof List) { List list = (List) value; int size = list.size(); for (int i=0; i < size; i++) { if (list.get(i) != null) values[i+offset] = list.get(i).toString(); else values[i+offset] = ""; } } else { values[offset] = value.toString(); } // store the new values array params.put(name, values); } }
moparisthebest/beehive
beehive-netui-core/src/main/java/org/apache/beehive/netui/util/ParamHelper.java
Java
apache-2.0
5,988
[ 30522, 1013, 1008, 1008, 7000, 2000, 1996, 15895, 4007, 3192, 1006, 2004, 2546, 1007, 2104, 2028, 2030, 2062, 1008, 12130, 6105, 10540, 1012, 2156, 1996, 5060, 5371, 5500, 2007, 1008, 2023, 2147, 2005, 3176, 2592, 4953, 9385, 6095, 1012, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import cs50 import sys def main(): if len(sys.argv) != 2: print("You should provide cmd line arguments!") exit(1) #if sys.argv[1].isalpha() == False: #print("You should provide valid key!") #exit(1) kplainText = int(sys.argv[1]) cipher = [] plainText = cs50.get_string() for symbol in plainText: if symbol.isalpha(): cipher.append(caesar(symbol, kplainText)) else: cipher.append(symbol) print("".join(cipher)) exit(0) def caesar(char, kplainText): if char.isupper(): return chr(((ord(char) - 65 + kplainText) % 26) + 65) else: return chr(((ord(char) - 97 + kplainText) % 26) + 97) if __name__ == "__main__": main() # #include <ctype.h> # #include <string.h> # #include <cs50.h> # #include <stdio.h> # #include <stdlib.h> # //define my caesarCipher # void caesarCipher(char* plainText,int key); # def int main(int argc, char* argv[]): # //{//????????????????/char* # if argc is not 2: # # { # print("Usage: ./caesar k\n") # #return 1 # #} # #//printf(" %s\n", argv[1]); # int key = atoi(sys.argv[1]) # char plainText[101] # print("plaintext: ")#;//ask user # fgets(plainText, sizeof(plainText), stdin);//get user input & store it in planText var++++++++ # print("ciphertext: ")#;//print the ciphered text # caesarCipher(plainText,key) # //system(pause);//connect out if not use wind---------------------------??????????????? # # return 0; # #} # void caesarCipher(char* plainText, int key){//key pomen mestami on first plaiiiiiiiiiin # int i = 0 # char cipher # int cipherValue # while plainText[i] != '\0' and strlen(plainText) -1 > i :break#// for(int i=1,len=strlen(name);i<len;i++) # if isalpha(plainText[i]) and islower(plainText[i]): # cipherValue = ((int)((plainText[i]) - 97 + key) % 26 + 97) # cipher = (char)(cipherValue);printf("%c", cipher) # i++ # else: # if isalpha(plainText[i]) and isupper(plainText[i]):# // if isaph char # cipherValue = ((int)(plainText[i] - 65 + key) % 26 + 65) # cipher = (char)(cipherValue) # print("%c", cipher) # i++ # else: #//if not isaplha low or up # print("%c", plainText[i]) # i++ # print("\n") #}
DInnaD/CS50
pset6/caesar.py
Python
apache-2.0
2,532
[ 30522, 12324, 20116, 12376, 12324, 25353, 2015, 13366, 2364, 1006, 1007, 1024, 2065, 18798, 1006, 25353, 2015, 1012, 12098, 2290, 2615, 1007, 999, 1027, 1016, 1024, 6140, 1006, 1000, 2017, 2323, 3073, 4642, 2094, 2240, 9918, 999, 1000, 1007...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
module MobileEnhancements VERSION = "0.0.5" end
ryantownsend/mobile-enhancements
lib/mobile_enhancements/version.rb
Ruby
mit
50
[ 30522, 11336, 4684, 2368, 4819, 3401, 8163, 2544, 1027, 1000, 1014, 1012, 1014, 1012, 1019, 1000, 2203, 102, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>basic_deadline_timer::basic_deadline_timer (1 of 4 overloads)</title> <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> <link rel="home" href="../../../../boost_asio.html" title="Boost.Asio"> <link rel="up" href="../basic_deadline_timer.html" title="basic_deadline_timer::basic_deadline_timer"> <link rel="prev" href="../basic_deadline_timer.html" title="basic_deadline_timer::basic_deadline_timer"> <link rel="next" href="overload2.html" title="basic_deadline_timer::basic_deadline_timer (2 of 4 overloads)"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table cellpadding="2" width="100%"><tr> <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> <td align="center"><a href="../../../../../../index.html">Home</a></td> <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> <td align="center"><a href="../../../../../../more/index.htm">More</a></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="../basic_deadline_timer.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../basic_deadline_timer.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../boost_asio.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="overload2.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> </div> <div class="section"> <div class="titlepage"><div><div><h5 class="title"> <a name="boost_asio.reference.basic_deadline_timer.basic_deadline_timer.overload1"></a><a class="link" href="overload1.html" title="basic_deadline_timer::basic_deadline_timer (1 of 4 overloads)">basic_deadline_timer::basic_deadline_timer (1 of 4 overloads)</a> </h5></div></div></div> <p> Constructor. </p> <pre class="programlisting">basic_deadline_timer( boost::asio::io_context &amp; io_context); </pre> <p> This constructor creates a timer without setting an expiry time. The <code class="computeroutput">expires_at()</code> or <code class="computeroutput">expires_from_now()</code> functions must be called to set an expiry time before the timer can be waited on. </p> <h6> <a name="boost_asio.reference.basic_deadline_timer.basic_deadline_timer.overload1.h0"></a> <span class="phrase"><a name="boost_asio.reference.basic_deadline_timer.basic_deadline_timer.overload1.parameters"></a></span><a class="link" href="overload1.html#boost_asio.reference.basic_deadline_timer.basic_deadline_timer.overload1.parameters">Parameters</a> </h6> <div class="variablelist"> <p class="title"><b></b></p> <dl class="variablelist"> <dt><span class="term">io_context</span></dt> <dd><p> The <a class="link" href="../../io_context.html" title="io_context"><code class="computeroutput">io_context</code></a> object that the timer will use to dispatch handlers for any asynchronous operations performed on the timer. </p></dd> </dl> </div> </div> <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> <td align="left"></td> <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2018 Christopher M. Kohlhoff<p> Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) </p> </div></td> </tr></table> <hr> <div class="spirit-nav"> <a accesskey="p" href="../basic_deadline_timer.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../basic_deadline_timer.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../boost_asio.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="overload2.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> </div> </body> </html>
vslavik/poedit
deps/boost/doc/html/boost_asio/reference/basic_deadline_timer/basic_deadline_timer/overload1.html
HTML
mit
4,542
[ 30522, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828, 1000, 4180, 1027, 1000, 3793, 1013, 16129, 1025, 25869, 13462, 1027, 2149, 1011, 2004, 6895, 2072, 1000, 1028, 1026, 2516,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Buff to buff example - Test program for the lzlib library Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz. This program is free software: you have unlimited permission to copy, distribute and modify it. Usage is: bbexample filename This program is an example of how buffer-to-buffer compression/decompression can be implemented using lzlib. */ #ifndef __cplusplus #include <stdbool.h> #endif #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "lzlib.h" /* Compresses 'size' bytes from 'data'. Returns the address of a malloc'd buffer containing the compressed data and its size in '*out_sizep'. In case of error, returns 0 and does not modify '*out_sizep'. */ uint8_t * bbcompress( const uint8_t * const data, const int size, int * const out_sizep ) { struct LZ_Encoder * encoder; uint8_t * new_data; const int match_len_limit = 36; const unsigned long long member_size = INT64_MAX; int delta_size, new_data_size; int new_pos = 0; int written = 0; bool error = false; int dict_size = 8 << 20; /* 8 MiB */ if( dict_size > size ) dict_size = size; /* saves memory */ if( dict_size < LZ_min_dictionary_size() ) dict_size = LZ_min_dictionary_size(); encoder = LZ_compress_open( dict_size, match_len_limit, member_size ); if( !encoder || LZ_compress_errno( encoder ) != LZ_ok ) { LZ_compress_close( encoder ); return 0; } delta_size = (size < 256) ? 64 : size / 4; /* size may be zero */ new_data_size = delta_size; /* initial size */ new_data = (uint8_t *)malloc( new_data_size ); if( !new_data ) { LZ_compress_close( encoder ); return 0; } while( true ) { int rd; if( LZ_compress_write_size( encoder ) > 0 ) { if( written < size ) { const int wr = LZ_compress_write( encoder, data + written, size - written ); if( wr < 0 ) { error = true; break; } written += wr; } if( written >= size ) LZ_compress_finish( encoder ); } rd = LZ_compress_read( encoder, new_data + new_pos, new_data_size - new_pos ); if( rd < 0 ) { error = true; break; } new_pos += rd; if( LZ_compress_finished( encoder ) == 1 ) break; if( new_pos >= new_data_size ) { uint8_t * const tmp = (uint8_t *)realloc( new_data, new_data_size + delta_size ); if( !tmp ) { error = true; break; } new_data = tmp; new_data_size += delta_size; } } if( LZ_compress_close( encoder ) < 0 ) error = true; if( error ) { free( new_data ); return 0; } *out_sizep = new_pos; return new_data; } /* Decompresses 'size' bytes from 'data'. Returns the address of a malloc'd buffer containing the decompressed data and its size in '*out_sizep'. In case of error, returns 0 and does not modify '*out_sizep'. */ uint8_t * bbdecompress( const uint8_t * const data, const int size, int * const out_sizep ) { struct LZ_Decoder * const decoder = LZ_decompress_open(); uint8_t * new_data; const int delta_size = size; /* size must be > zero */ int new_data_size = delta_size; /* initial size */ int new_pos = 0; int written = 0; bool error = false; if( !decoder || LZ_decompress_errno( decoder ) != LZ_ok ) { LZ_decompress_close( decoder ); return 0; } new_data = (uint8_t *)malloc( new_data_size ); if( !new_data ) { LZ_decompress_close( decoder ); return 0; } while( true ) { int rd; if( LZ_decompress_write_size( decoder ) > 0 ) { if( written < size ) { const int wr = LZ_decompress_write( decoder, data + written, size - written ); if( wr < 0 ) { error = true; break; } written += wr; } if( written >= size ) LZ_decompress_finish( decoder ); } rd = LZ_decompress_read( decoder, new_data + new_pos, new_data_size - new_pos ); if( rd < 0 ) { error = true; break; } new_pos += rd; if( LZ_decompress_finished( decoder ) == 1 ) break; if( new_pos >= new_data_size ) { uint8_t * const tmp = (uint8_t *)realloc( new_data, new_data_size + delta_size ); if( !tmp ) { error = true; break; } new_data = tmp; new_data_size += delta_size; } } if( LZ_decompress_close( decoder ) < 0 ) error = true; if( error ) { free( new_data ); return 0; } *out_sizep = new_pos; return new_data; } int main( const int argc, const char * const argv[] ) { FILE * file; uint8_t * in_buffer, * mid_buffer, * out_buffer; const int in_buffer_size = 1 << 20; int in_size, mid_size = 0, out_size = 0; if( argc < 2 ) { fprintf( stderr, "Usage: bbexample filename\n" ); return 1; } file = fopen( argv[1], "rb" ); if( !file ) { fprintf( stderr, "bbexample: Can't open file '%s' for reading\n", argv[1] ); return 1; } in_buffer = (uint8_t *)malloc( in_buffer_size ); if( !in_buffer ) { fprintf( stderr, "bbexample: Not enough memory.\n" ); return 1; } in_size = fread( in_buffer, 1, in_buffer_size, file ); if( in_size >= in_buffer_size ) { fprintf( stderr, "bbexample: Input file '%s' is too big.\n", argv[1] ); return 1; } fclose( file ); mid_buffer = bbcompress( in_buffer, in_size, &mid_size ); if( !mid_buffer ) { fprintf( stderr, "bbexample: Not enough memory or compress error.\n" ); return 1; } out_buffer = bbdecompress( mid_buffer, mid_size, &out_size ); if( !out_buffer ) { fprintf( stderr, "bbexample: Not enough memory or decompress error.\n" ); return 1; } if( in_size != out_size || ( in_size > 0 && memcmp( in_buffer, out_buffer, in_size ) != 0 ) ) { fprintf( stderr, "bbexample: Decompressed data differs from original.\n" ); return 1; } free( out_buffer ); free( mid_buffer ); free( in_buffer ); return 0; }
tom42/txtvc
lzlib/bbexample.c
C
gpl-3.0
6,116
[ 30522, 1013, 1008, 23176, 2000, 23176, 2742, 1011, 3231, 2565, 2005, 1996, 1048, 2480, 29521, 3075, 9385, 1006, 1039, 1007, 2230, 1010, 2249, 1010, 2262, 1010, 2286, 4980, 12526, 12526, 1012, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2031, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/usr/bin/env bash PGPASSWORD=postgres psql -U postgres <<EOF drop database if exists geodesydb; drop database if exists geodesy_baseline_db; drop role if exists geodesy; create user geodesy with password 'geodesypw'; create database geodesydb owner geodesy; create database geodesy_baseline_db owner geodesy; EOF PGPASSWORD=postgres psql -U postgres geodesydb <<EOF create extension postgis; create schema geodesy authorization geodesy; EOF PGPASSWORD=postgres psql -U postgres geodesy_baseline_db <<EOF create extension postgis; create schema geodesy authorization geodesy; EOF
lbodor/geodesy-domain-model
src/test/docker/database/setup-database.sh
Shell
bsd-3-clause
584
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 24234, 18720, 15194, 18351, 1027, 2695, 17603, 2015, 8827, 4160, 2140, 1011, 1057, 2695, 17603, 2015, 1026, 1026, 1041, 11253, 4530, 7809, 2065, 6526, 20248, 6155, 25688, 249...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php require_once("../../../globals.inc.php"); require_once(dir_code_lib("bdd_mysql.class.php")); require_once(dir_include("config.inc")); ?>
Ced-le-pingouin/esprit-mirror
src/admin/utilitaires/transfert/globals.inc.php
PHP
gpl-2.0
142
[ 30522, 1026, 1029, 25718, 5478, 1035, 2320, 1006, 1000, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 3795, 2015, 1012, 4297, 1012, 25718, 1000, 1007, 1025, 5478, 1035, 2320, 1006, 16101, 1035, 3642, 1035, 5622, 2497, 1006, 1000, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package io.subutai.core.peer.impl; public class PeerInitializationError extends RuntimeException { public PeerInitializationError( final String message, final Throwable cause ) { super( message, cause ); } }
subutai-io/Subutai
management/server/core/peer-manager/peer-manager-impl/src/main/java/io/subutai/core/peer/impl/PeerInitializationError.java
Java
apache-2.0
230
[ 30522, 7427, 22834, 1012, 4942, 13210, 2072, 1012, 4563, 1012, 8152, 1012, 17727, 2140, 1025, 2270, 2465, 8152, 5498, 20925, 3989, 2121, 29165, 8908, 2448, 7292, 10288, 24422, 1063, 2270, 8152, 5498, 20925, 3989, 2121, 29165, 1006, 2345, 51...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*================================================================================ code generated by: java2cpp author: Zoran Angelov, mailto://baldzar@gmail.com class: java.io.WriteAbortedException ================================================================================*/ #ifndef J2CPP_INCLUDE_IMPLEMENTATION #ifndef J2CPP_JAVA_IO_WRITEABORTEDEXCEPTION_HPP_DECL #define J2CPP_JAVA_IO_WRITEABORTEDEXCEPTION_HPP_DECL namespace j2cpp { namespace java { namespace lang { class Exception; } } } namespace j2cpp { namespace java { namespace lang { class String; } } } namespace j2cpp { namespace java { namespace lang { class Throwable; } } } namespace j2cpp { namespace java { namespace lang { class Object; } } } namespace j2cpp { namespace java { namespace io { class IOException; } } } namespace j2cpp { namespace java { namespace io { class Serializable; } } } namespace j2cpp { namespace java { namespace io { class ObjectStreamException; } } } #include <java/io/IOException.hpp> #include <java/io/ObjectStreamException.hpp> #include <java/io/Serializable.hpp> #include <java/lang/Exception.hpp> #include <java/lang/Object.hpp> #include <java/lang/String.hpp> #include <java/lang/Throwable.hpp> namespace j2cpp { namespace java { namespace io { class WriteAbortedException; class WriteAbortedException : public object<WriteAbortedException> { public: J2CPP_DECLARE_CLASS J2CPP_DECLARE_METHOD(0) J2CPP_DECLARE_METHOD(1) J2CPP_DECLARE_METHOD(2) J2CPP_DECLARE_FIELD(0) explicit WriteAbortedException(jobject jobj) : object<WriteAbortedException>(jobj) , detail(jobj) { } operator local_ref<java::lang::Exception>() const; operator local_ref<java::lang::Throwable>() const; operator local_ref<java::lang::Object>() const; operator local_ref<java::io::IOException>() const; operator local_ref<java::io::Serializable>() const; operator local_ref<java::io::ObjectStreamException>() const; WriteAbortedException(local_ref< java::lang::String > const&, local_ref< java::lang::Exception > const&); local_ref< java::lang::String > getMessage(); local_ref< java::lang::Throwable > getCause(); field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(0), J2CPP_FIELD_SIGNATURE(0), local_ref< java::lang::Exception > > detail; }; //class WriteAbortedException } //namespace io } //namespace java } //namespace j2cpp #endif //J2CPP_JAVA_IO_WRITEABORTEDEXCEPTION_HPP_DECL #else //J2CPP_INCLUDE_IMPLEMENTATION #ifndef J2CPP_JAVA_IO_WRITEABORTEDEXCEPTION_HPP_IMPL #define J2CPP_JAVA_IO_WRITEABORTEDEXCEPTION_HPP_IMPL namespace j2cpp { java::io::WriteAbortedException::operator local_ref<java::lang::Exception>() const { return local_ref<java::lang::Exception>(get_jobject()); } java::io::WriteAbortedException::operator local_ref<java::lang::Throwable>() const { return local_ref<java::lang::Throwable>(get_jobject()); } java::io::WriteAbortedException::operator local_ref<java::lang::Object>() const { return local_ref<java::lang::Object>(get_jobject()); } java::io::WriteAbortedException::operator local_ref<java::io::IOException>() const { return local_ref<java::io::IOException>(get_jobject()); } java::io::WriteAbortedException::operator local_ref<java::io::Serializable>() const { return local_ref<java::io::Serializable>(get_jobject()); } java::io::WriteAbortedException::operator local_ref<java::io::ObjectStreamException>() const { return local_ref<java::io::ObjectStreamException>(get_jobject()); } java::io::WriteAbortedException::WriteAbortedException(local_ref< java::lang::String > const &a0, local_ref< java::lang::Exception > const &a1) : object<java::io::WriteAbortedException>( call_new_object< java::io::WriteAbortedException::J2CPP_CLASS_NAME, java::io::WriteAbortedException::J2CPP_METHOD_NAME(0), java::io::WriteAbortedException::J2CPP_METHOD_SIGNATURE(0) >(a0, a1) ) , detail(get_jobject()) { } local_ref< java::lang::String > java::io::WriteAbortedException::getMessage() { return call_method< java::io::WriteAbortedException::J2CPP_CLASS_NAME, java::io::WriteAbortedException::J2CPP_METHOD_NAME(1), java::io::WriteAbortedException::J2CPP_METHOD_SIGNATURE(1), local_ref< java::lang::String > >(get_jobject()); } local_ref< java::lang::Throwable > java::io::WriteAbortedException::getCause() { return call_method< java::io::WriteAbortedException::J2CPP_CLASS_NAME, java::io::WriteAbortedException::J2CPP_METHOD_NAME(2), java::io::WriteAbortedException::J2CPP_METHOD_SIGNATURE(2), local_ref< java::lang::Throwable > >(get_jobject()); } J2CPP_DEFINE_CLASS(java::io::WriteAbortedException,"java/io/WriteAbortedException") J2CPP_DEFINE_METHOD(java::io::WriteAbortedException,0,"<init>","(Ljava/lang/String;Ljava/lang/Exception;)V") J2CPP_DEFINE_METHOD(java::io::WriteAbortedException,1,"getMessage","()Ljava/lang/String;") J2CPP_DEFINE_METHOD(java::io::WriteAbortedException,2,"getCause","()Ljava/lang/Throwable;") J2CPP_DEFINE_FIELD(java::io::WriteAbortedException,0,"detail","Ljava/lang/Exception;") } //namespace j2cpp #endif //J2CPP_JAVA_IO_WRITEABORTEDEXCEPTION_HPP_IMPL #endif //J2CPP_INCLUDE_IMPLEMENTATION
hyEvans/ph-open
proj.android/jni/puzzleHero/platforms/android-9/java/io/WriteAbortedException.hpp
C++
mit
5,303
[ 30522, 1013, 1008, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 102...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="id"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="generator" content="Gogon ngeBlog"> <title>Tag: freebsd - Gogon ngeBlog</title> <meta name="author" content="Gogon"> <link rel="alternate" type="application/atom+xml" title="RSS" href="/atom.xml"> <script type="application/ld+json">{}</script> <meta name="description" content="Bukan Gogon Srimulat • Pengguna KDE • Progremer Gagal :|"> <meta property="og:type" content="blog"> <meta property="og:title" content="Gogon ngeBlog"> <meta property="og:url" content="http://go2n.github.io/tags/freebsd/index.html"> <meta property="og:site_name" content="Gogon ngeBlog"> <meta property="og:description" content="Bukan Gogon Srimulat • Pengguna KDE • Progremer Gagal :|"> <meta property="og:locale" content="id_ID"> <meta property="article:author" content="Gogon"> <meta name="twitter:card" content="summary"> <meta property="og:image" content="http://go2n.github.io/assets/images/go2n.jpg"/> <!--STYLES--> <link rel="stylesheet" href="/assets/css/style-cr6ygx2eptouictmr9m09oubvsh1xi4qunn2yz2xg7umzw0l9spayiq1geeo.min.css"> <!--STYLES END--> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-41394739-3"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-41394739-3'); </script> </head> <body> <div id="blog"> <!-- Define author's picture --> <header id="header" data-behavior="2"> <i id="btn-open-sidebar" class="fa fa-lg fa-bars"></i> <div class="header-title"> <a class="header-title-link" href="/%20" aria-label="" > Gogon ngeBlog </a> </div> <a class="header-right-picture " href="#about" aria-label="Öffne den Link: /#about" > <img class="header-picture" src="/assets/images/go2n.jpg" alt="Penulis"/> </a> </header> <!-- Define author's picture --> <nav id="sidebar" data-behavior="2"> <div class="sidebar-container"> <div class="sidebar-profile"> <a href="/#about" aria-label="Lesen Sie mehr über den Autor" > <img class="sidebar-profile-picture" src="/assets/images/go2n.jpg" alt="Penulis"/> </a> <h4 class="sidebar-profile-name">Gogon</h4> <h5 class="sidebar-profile-bio"><p>Bukan Gogon Srimulat • Suka dengan KDE • Programmer Gagal 😐</p> </h5> </div> <ul class="sidebar-buttons"> <li class="sidebar-button"> <a class="sidebar-button-link " href="/" rel="noopener" title="Beranda" > <i class="sidebar-button-icon fa fa-home" aria-hidden="true"></i> <span class="sidebar-button-desc">Beranda</span> </a> </li> <li class="sidebar-button"> <a class="sidebar-button-link " href="/all-categories" rel="noopener" title="Kategori" > <i class="sidebar-button-icon fa fa-bookmark" aria-hidden="true"></i> <span class="sidebar-button-desc">Kategori</span> </a> </li> <li class="sidebar-button"> <a class="sidebar-button-link " href="/all-tags" rel="noopener" title="Tag" > <i class="sidebar-button-icon fa fa-tags" aria-hidden="true"></i> <span class="sidebar-button-desc">Tag</span> </a> </li> <li class="sidebar-button"> <a class="sidebar-button-link " href="/all-archives" rel="noopener" title="Arsip" > <i class="sidebar-button-icon fa fa-archive" aria-hidden="true"></i> <span class="sidebar-button-desc">Arsip</span> </a> </li> <li class="sidebar-button"> <a class="sidebar-button-link open-algolia-search" href="#search" rel="noopener" title="Cari" > <i class="sidebar-button-icon fa fa-search" aria-hidden="true"></i> <span class="sidebar-button-desc">Cari</span> </a> </li> <li class="sidebar-button"> <a class="sidebar-button-link " href="/about" rel="noopener" title="Tentang" > <i class="sidebar-button-icon fa fa-question" aria-hidden="true"></i> <span class="sidebar-button-desc">Tentang</span> </a> </li> </ul> <ul class="sidebar-buttons"> </ul> <ul class="sidebar-buttons"> <li class="sidebar-button"> <a class="sidebar-button-link " href="/atom.xml" rel="noopener" title="RSS" > <i class="sidebar-button-icon fa fa-rss" aria-hidden="true"></i> <span class="sidebar-button-desc">RSS</span> </a> </li> </ul> </div> </nav> <div id="main" data-behavior="2" class=" hasCoverMetaIn "> <section class="postShorten-group main-content-wrap"> <article class="postShorten postShorten--thumbnailimg-right"> <div class="postShorten-wrap"> <div class="postShorten-header"> <h1 class="postShorten-title"> <a class="link-unstyled" href="/2016/01/05/menambahkan-user-ke-dalam-group-di-freebsd/" aria-label=": Menambahkan user ke dalam group di FreeBSD" > Menambahkan user ke dalam group di FreeBSD </a> </h1> <div class="postShorten-meta"> <time datetime="2016-01-05T00:00:00+07:00"> 05 Januari 2016 </time> <span> | </span> <a class="category-link" href="/categories/notes/">notes</a>, <a class="category-link" href="/categories/notes/freebsd/">freebsd</a> </div> </div> <div class="postShorten-excerpt"> <blockquote> <p><em>Sebuah catatan biar nggak lupa perintah menambahkan user ke dalam group di mesin FreeBSD.</em></p> </blockquote> <p>Saat selesai setup server FreeBSD saya sering lupa menambahkan user ke dalam group wheel. Masalah datang pas ngremot server dan mau pindah sebagai user root nggak bisa. Telo!</p> <a href="/2016/01/05/menambahkan-user-ke-dalam-group-di-freebsd/" class="postShorten-excerpt_link link" aria-label=": Menambahkan user ke dalam group di FreeBSD" > Selengkapnya </a> </div> </div> <a href="/2016/01/05/menambahkan-user-ke-dalam-group-di-freebsd/" aria-label=": Menambahkan user ke dalam group di FreeBSD" > <div class="postShorten-thumbnailimg"> <img alt="" src="https://go2n.github.io/2015/03/12/lupa-password-mysql-di-freebsd/dhemit.png"/> </div> </a> </article> <article class="postShorten postShorten--thumbnailimg-right"> <div class="postShorten-wrap"> <div class="postShorten-header"> <h1 class="postShorten-title"> <a class="link-unstyled" href="/2015/03/12/lupa-password-mysql-di-freebsd/" aria-label=": Lupa Password Root MySQL di FreeBSD" > Lupa Password Root MySQL di FreeBSD </a> </h1> <div class="postShorten-meta"> <time datetime="2015-03-12T00:00:00+07:00"> 12 Maret 2015 </time> <span> | </span> <a class="category-link" href="/categories/notes/">notes</a>, <a class="category-link" href="/categories/notes/freebsd/">freebsd</a> </div> </div> <div class="postShorten-excerpt"> <blockquote> <p><em>Sekedar catatan saja saat lupa password root MySQL di mesin FreeBSD.</em></p> </blockquote> <p>Ubah /etc/rc.conf, buka komentar pada mysql_args, restart MySQL dan login. Dengan asumsi isi dari mysql_args adalah <code>&quot;--skip-grant-tables --skip-networking&quot;</code></p> <a href="/2015/03/12/lupa-password-mysql-di-freebsd/" class="postShorten-excerpt_link link" aria-label=": Lupa Password Root MySQL di FreeBSD" > Selengkapnya </a> </div> </div> <a href="/2015/03/12/lupa-password-mysql-di-freebsd/" aria-label=": Lupa Password Root MySQL di FreeBSD" > <div class="postShorten-thumbnailimg"> <img alt="" src="http://go2n.github.io/2015/03/12/lupa-password-mysql-di-freebsd/dhemit.png"/> </div> </a> </article> <article class="postShorten postShorten--thumbnailimg-right"> <div class="postShorten-wrap"> <div class="postShorten-header"> <h1 class="postShorten-title"> <a class="link-unstyled" href="/2015/02/27/pc-bsd-di-hari-yang-selo/" aria-label=": PC-BSD di hari yang selo" > PC-BSD di hari yang selo </a> </h1> <div class="postShorten-meta"> <time datetime="2015-02-27T00:00:00+07:00"> 27 Februari 2015 </time> <span> | </span> <a class="category-link" href="/categories/freebsd/">freebsd</a> </div> </div> <div class="postShorten-excerpt"> <p>Wahihihi… Sebenarnya sudah lama punya wacana buat pasang PC-BSD, tapi baru hari rabu kemarin saya selo buat memasang PC-BSD di komputer kantor. Sempat gagal update gara-gara paket <code>gnupg</code> yang konflik, tapi sekarang sudah beres. Hhe 😁</p> <a href="/2015/02/27/pc-bsd-di-hari-yang-selo/" class="postShorten-excerpt_link link" aria-label=": PC-BSD di hari yang selo" > Selengkapnya </a> </div> </div> <a href="/2015/02/27/pc-bsd-di-hari-yang-selo/" aria-label=": PC-BSD di hari yang selo" > <div class="postShorten-thumbnailimg"> <img alt="" src="https://go2n.github.io/2015/02/27/pc-bsd-di-hari-yang-selo/pc-bsd-di-hari-yang-selo.png"/> </div> </a> </article> <article class="postShorten postShorten--thumbnailimg-right"> <div class="postShorten-wrap"> <div class="postShorten-header"> <h1 class="postShorten-title"> <a class="link-unstyled" href="/2014/09/10/mengatasi-barcode-generator-slims-di-freebsd/" aria-label=": Mengatasi masalah barcode generator SLiMS di Mesin FreeBSD 9.1" > Mengatasi masalah barcode generator SLiMS di Mesin FreeBSD 9.1 </a> </h1> <div class="postShorten-meta"> <time datetime="2014-09-10T00:00:00+07:00"> 10 September 2014 </time> <span> | </span> <a class="category-link" href="/categories/freebsd/">freebsd</a> </div> </div> <div class="postShorten-excerpt"> <p>Halo…</p> <p>Ada yang pernah mengalami barcode generator <a target="_blank" rel="noopener" href="http://slims.web.id/">SLiMS</a> yang nge-blank di mesin FreeBSD ndak? Begini permasalahannya, pustakawan Fakultas Teknik meminta saya untuk mengatur masalah barcode yang nge-blank di mesin server dhemit alias FreeBSD. Jadi beliau pada saat mau generate barcode melalui menu <strong>System &gt; Barcode Generator</strong>, SLiMS tidak menampilkan barcode sama sekali.</p> <a href="/2014/09/10/mengatasi-barcode-generator-slims-di-freebsd/" class="postShorten-excerpt_link link" aria-label=": Mengatasi masalah barcode generator SLiMS di Mesin FreeBSD 9.1" > Selengkapnya </a> </div> </div> <a href="/2014/09/10/mengatasi-barcode-generator-slims-di-freebsd/" aria-label=": Mengatasi masalah barcode generator SLiMS di Mesin FreeBSD 9.1" > <div class="postShorten-thumbnailimg"> <img alt="" src="https://go2n.github.io/2015/03/12/lupa-password-mysql-di-freebsd/dhemit.png"/> </div> </a> </article> <div class="pagination-bar"> <ul class="pagination"> <li class="pagination-number">hal 1 / 1</li> </ul> </div> </section> <footer id="footer" class="main-content-wrap"> <span class="copyrights"> Copyrights &copy; 2020 Gogon. All Rights Reserved. </span> </footer> </div> </div> <div id="about"> <div id="about-card"> <div id="about-btn-close"> <i class="fa fa-times"></i> </div> <img id="about-card-picture" src="/assets/images/go2n.jpg" alt="Penulis"/> <h4 id="about-card-name">Gogon</h4> <div id="about-card-bio"><p>Bukan Gogon Srimulat • Suka dengan KDE • Programmer Gagal 😐</p> </div> <div id="about-card-job"> <i class="fa fa-briefcase"></i> <br/> <p>Janitor</p> </div> <div id="about-card-location"> <i class="fa fa-map-marker-alt"></i> <br/> Indonesia </div> </div> </div> <div id="algolia-search-modal" class="modal-container"> <div class="modal"> <div class="modal-header"> <span class="close-button"><i class="fa fa-times"></i></span> <a href="https://algolia.com" target="_blank" rel="noopener" class="searchby-algolia text-color-light link-unstyled"> <span class="searchby-algolia-text text-color-light text-small">by</span> <img class="searchby-algolia-logo" src="/assets/images/logo-algolia-nebula-blue-full.svg"> </a> <i class="search-icon fa fa-search"></i> <form id="algolia-search-form"> <input type="text" id="algolia-search-input" name="search" class="form-control input--large search-input" placeholder="Search " /> </form> </div> <div class="modal-body"> <div class="no-result text-color-light text-center">0 post ditemukan</div> <div class="results"> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2008/11/29/membuat-kamus-dengan-bahasa-c/" aria-label=": Membuat kamus dengan bahasa C" > <img class="media-image" src="http://go2n.github.io/2008/11/29/membuat-kamus-dengan-bahasa-c/./kamus.c.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2008/11/29/membuat-kamus-dengan-bahasa-c/" aria-label=": Membuat kamus dengan bahasa C" > <h3 class="media-heading">Membuat kamus dengan bahasa C</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 29 Nov 2008 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Membuat kamus sendiri? Mungkin nggak ya…? Jawabannya adalah mungkin. Dengan memanfaatkan bahasa C, kompiler GCC dan SQLite 3 beserta pustakanya, kita bisa membuat kamus sendiri. Tak perlu interface yang canggih dan keren, yang penting kamus yang dibuat berguna. Pada contoh ini kamus yang dibuat berjalan pada modus command line. Source code pada contoh ini berdasarkan pada dokumentasi <a target="_blank" rel="noopener" href="http://www.sqlite.org/">SQLite</a>.</p></div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2011/12/11/wicd-kde-plasmoid/" aria-label=": Wicd KDE Plasmoid!" > <img class="media-image" src="http://go2n.github.io/2011/12/11/wicd-kde-plasmoid/./snapshot11.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2011/12/11/wicd-kde-plasmoid/" aria-label=": Wicd KDE Plasmoid!" > <h3 class="media-heading">Wicd KDE Plasmoid!</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 11 Des 2011 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Tadi pagi membaca feed dari <a target="_blank" rel="noopener" href="https://kde-apps.org">https://kde-apps.org</a>, ada berita bahwa Wicd KDE 0.3.0 telah dirilis. Wicd KDE adalah Wicd klien untuk KDE Platform. Apa yang baru dengan Wicd KDE 0.3.0? Pada rilis yang sekarang ini Wicd KDE adalah sebuah plasmoid. Iseng-iseng saya update Wicd KDE melalui AUR, namun ternyata paket dari AUR sudah out of dated. 😦</p></div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2012/01/07/oxygen-font-kde-desktop-font/" aria-label=": Oxygen Font: KDE Desktop Font" > <img class="media-image" src="http://go2n.github.io/2012/01/07/oxygen-font-kde-desktop-font/oxygen1.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/01/07/oxygen-font-kde-desktop-font/" aria-label=": Oxygen Font: KDE Desktop Font" > <h3 class="media-heading">Oxygen Font: KDE Desktop Font</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 7 Jan 2012 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Pagi ini membuka akregator dan membaca feeds yang ada. Ada 2 feed yang judulnya menarik perhatian saya:</p></div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2012/04/06/upgrade-kde-dengan-delta-update-di-arch-linux/" aria-label=": Upgrade KDE dengan Delta Update di Arch Linux" > <img class="media-image" src="http://go2n.github.io/2012/04/06/upgrade-kde-dengan-delta-update-di-arch-linux/snapshot29.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/04/06/upgrade-kde-dengan-delta-update-di-arch-linux/" aria-label=": Upgrade KDE dengan Delta Update di Arch Linux" > <h3 class="media-heading">Upgrade KDE dengan Delta Update di Arch Linux</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 6 Apr 2012 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Waah ternyata lumayan lama juga saya ndak nulis di blog ini. Kali ini saya akan berbagi tulisan mengenai pengalaman saya meng-<em>upgrade</em> <a target="_blank" rel="noopener" href="http://www.archlinux.org/">Arch Linux</a> dengan <a target="_blank" rel="noopener" href="https://wiki.archlinux.org/index.php/Deltup">delta update</a>. Pada awalnya saya sempat ragu menggunakan delta karena delta update sendiri belum didukung secara <em>official</em>. Selain itu mirror yang menyediakan paket delta baru 1 yaitu <a target="_blank" rel="noopener" href="http://delta.archlinux.fr/">http://delta.archlinux.fr/</a>. Namun pada akhirnya saya nekat saja, kalau ndak nekat kapan saya punya pengalaman upgrade menggunakan delta? 😁</p></div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2012/06/18/mencoba-kde-4-9-beta2-4-8-90/" aria-label=": Mencoba KDE 4.9 Beta2 (4.8.90)" > <img class="media-image" src="http://go2n.github.io/2012/06/18/mencoba-kde-4-9-beta2-4-8-90/./snapshot50.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/06/18/mencoba-kde-4-9-beta2-4-8-90/" aria-label=": Mencoba KDE 4.9 Beta2 (4.8.90)" > <h3 class="media-heading">Mencoba KDE 4.9 Beta2 (4.8.90)</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 18 Jun 2012 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Gara-gara komentar di <a target="_blank" rel="noopener" href="https://www.facebook.com/walesa/posts/4007252307182">status</a> Facebooknya om Walesa jadi kepengin menjajal <a target="_blank" rel="noopener" href="http://www.kde.org/announcements/announce-4.9-beta2.php">KDE 4.9 Beta2</a>. Setelah semalaman ketiduran menunggu upgrade KDE, baru pagi ini saya punya kesempatan menjajalnya.</p></div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2012/06/29/kde-4-9-rc1-4-8-95/" aria-label=": KDE 4.9 RC1 (4.8.95)" > <img class="media-image" src="http://go2n.github.io/2012/06/29/kde-4-9-rc1-4-8-95/snapshot56.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/06/29/kde-4-9-rc1-4-8-95/" aria-label=": KDE 4.9 RC1 (4.8.95)" > <h3 class="media-heading">KDE 4.9 RC1 (4.8.95)</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 29 Jun 2012 </span> </span> <div class="media-content hide-xs font-merryweather"><p>27 Juni 2012 kemarin KDE mengumumkan tersedianya <a target="_blank" rel="noopener" href="http://www.kde.org/announcements/announce-4.9-rc1.php">KDE 4.8.95 alias KDE 4.9 RC1</a>, dan semalam saya mengupgrade desktop KDE saya dari 4.8.90 (4.9 beta2) menjadi 4.8.95 (4.9 RC1). Ritual upgrade dengan <code>pacman -Syu</code> berjalan lantjar djaja dan tidak ada masalah sama sekali ketika masuk ke desktop.</p></div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2012/07/07/menerjemahkan-kata-atau-kalimat-dari-commandline/" aria-label=": Menerjemahkan kata atau kalimat dari commandline" > <img class="media-image" src="https://www.akashtrehan.com/assets/images/emoji/terminal.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/07/07/menerjemahkan-kata-atau-kalimat-dari-commandline/" aria-label=": Menerjemahkan kata atau kalimat dari commandline" > <h3 class="media-heading">Menerjemahkan kata atau kalimat dari commandline</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 7 Jul 2012 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Mungkin tidak kita menerjemahkan kata atau kalimat menggunakan dari commandline?</div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/10/09/arch-linux-with-kde-4-9-2/" aria-label=": Arch Linux ❤ KDE 4.9.2" > <h3 class="media-heading">Arch Linux ❤ KDE 4.9.2</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 9 Okt 2012 </span> </span> <div class="media-content hide-xs font-merryweather"></div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2012/10/10/tidak-ada-lagi-aif/" aria-label=": Tidak ada lagi AIF 😭" > <img class="media-image" src="https://i.imgur.com/xGdmDKR.jpg" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/10/10/tidak-ada-lagi-aif/" aria-label=": Tidak ada lagi AIF 😭" > <h3 class="media-heading">Tidak ada lagi AIF 😭</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 10 Okt 2012 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Pagi ini saya iseng untuk coba memasang Arch Linux dengan installer terbaru (2012.10.06) di PC tempat saya mburuh. Saya agak terkejut dengan tidak disertakannya AIF - Arch Installation Framework di media instalasi tersebut.</div> </div> <div style="clear:both;"></div> <hr> </div> <div class="media"> <div class="media-left"> <a class="link-unstyled" href="http://go2n.github.io/2012/10/11/akhirnya/" aria-label=": Akhirnya…" > <img class="media-image" src="http://go2n.github.io/2012/10/11/akhirnya/xfce.png" width="90" height="90"/> </a> </div> <div class="media-body"> <a class="link-unstyled" href="http://go2n.github.io/2012/10/11/akhirnya/" aria-label=": Akhirnya…" > <h3 class="media-heading">Akhirnya…</h3> </a> <span class="media-meta"> <span class="media-date text-small"> 11 Okt 2012 </span> </span> <div class="media-content hide-xs font-merryweather"><p>Di tulisan yang <a href="https://go2n.github.io/2012/10/10/tidak-ada-lagi-aif/">sebelumnya</a> saya sempat mengeluh mengenai ribetnya instalasi Arch Linux tanpa AIF (Arch Installation Framework). Saya akui, memang tidak mengenakkan alias tidak manusiawi memasang Arch Linux tanpa AIF tersebut, ditambah dengan tidak adanya jaringan internet untuk PC saya. 😐</p></div> </div> <div style="clear:both;"></div> <hr> </div> </div> </div> <div class="modal-footer"> <p class="results-count text-medium" data-message-zero="0 post ditemukan" data-message-one="1 post ditemukan" data-message-other="{n} post ditemukan"> 44 post ditemukan </p> </div> </div> </div> <div id="cover" style="background-image:url('/assets/images/cover.jpg');"></div> <!--SCRIPTS--> <script src="/assets/js/script-xl9xkv7botefhpdv5tsehll2rt0wmqq4ptsnspylwkopq9efag494tpe3gpd.min.js"></script> <!--SCRIPTS END--> <script src="/assets/js/moment-with-locales.js"></script> <script src="/assets/js/algoliasearch.js"></script> <script> var algoliaClient = algoliasearch('AKI0Y37EA1', '9b0084f5343d3a80d8e0e1c7f04851e2'); var algoliaIndex = algoliaClient.initIndex('Goblog'); </script> </body> </html>
go2n/go2n.github.io
tags/freebsd/index.html
HTML
mit
38,117
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 8909, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 2171, 1027, 1000, 3193, 6442, 1000, 418...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
const should = require('should'), sinon = require('sinon'), _ = require('lodash'), settingsCache = require('../../../../server/services/settings/cache'), common = require('../../../../server/lib/common'), controllers = require('../../../../server/services/routing/controllers'), TaxonomyRouter = require('../../../../server/services/routing/TaxonomyRouter'), RESOURCE_CONFIG = require('../../../../server/services/routing/assets/resource-config'), sandbox = sinon.sandbox.create(); describe('UNIT - services/routing/TaxonomyRouter', function () { let req, res, next; beforeEach(function () { sandbox.stub(settingsCache, 'get').withArgs('permalinks').returns('/:slug/'); sandbox.stub(common.events, 'emit'); sandbox.stub(common.events, 'on'); sandbox.spy(TaxonomyRouter.prototype, 'mountRoute'); sandbox.spy(TaxonomyRouter.prototype, 'mountRouter'); req = sandbox.stub(); res = sandbox.stub(); next = sandbox.stub(); res.locals = {}; }); afterEach(function () { sandbox.restore(); }); it('instantiate', function () { const taxonomyRouter = new TaxonomyRouter('tag', '/tag/:slug/'); should.exist(taxonomyRouter.router); should.exist(taxonomyRouter.rssRouter); taxonomyRouter.taxonomyKey.should.eql('tag'); taxonomyRouter.getPermalinks().getValue().should.eql('/tag/:slug/'); common.events.emit.calledOnce.should.be.true(); common.events.emit.calledWith('router.created', taxonomyRouter).should.be.true(); taxonomyRouter.mountRouter.callCount.should.eql(1); taxonomyRouter.mountRouter.args[0][0].should.eql('/tag/:slug/'); taxonomyRouter.mountRouter.args[0][1].should.eql(taxonomyRouter.rssRouter.router()); taxonomyRouter.mountRoute.callCount.should.eql(3); // permalink route taxonomyRouter.mountRoute.args[0][0].should.eql('/tag/:slug/'); taxonomyRouter.mountRoute.args[0][1].should.eql(controllers.channel); // pagination feature taxonomyRouter.mountRoute.args[1][0].should.eql('/tag/:slug/page/:page(\\d+)'); taxonomyRouter.mountRoute.args[1][1].should.eql(controllers.channel); // edit feature taxonomyRouter.mountRoute.args[2][0].should.eql('/tag/:slug/edit'); taxonomyRouter.mountRoute.args[2][1].should.eql(taxonomyRouter._redirectEditOption.bind(taxonomyRouter)); }); it('fn: _prepareContext', function () { const taxonomyRouter = new TaxonomyRouter('tag', '/tag/:slug/'); taxonomyRouter._prepareContext(req, res, next); next.calledOnce.should.eql(true); res.locals.routerOptions.should.eql({ name: 'tag', permalinks: '/tag/:slug/', type: RESOURCE_CONFIG.QUERY.tag.resource, data: {tag: _.omit(RESOURCE_CONFIG.QUERY.tag, 'alias')}, filter: RESOURCE_CONFIG.TAXONOMIES.tag.filter, context: ['tag'], slugTemplate: true, identifier: taxonomyRouter.identifier }); res._route.type.should.eql('channel'); }); });
dbalders/Ghost
core/test/unit/services/routing/TaxonomyRouter_spec.js
JavaScript
mit
3,184
[ 30522, 9530, 3367, 2323, 1027, 5478, 1006, 1005, 2323, 1005, 1007, 1010, 19432, 2078, 1027, 5478, 1006, 1005, 19432, 2078, 1005, 1007, 1010, 1035, 1027, 5478, 1006, 1005, 8840, 8883, 2232, 1005, 1007, 1010, 10906, 3540, 5403, 1027, 5478, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Clase 12 ### Testing (Metodologías) - [Test Driven Development (TDD)](https://www.wikiwand.com/es/Desarrollo_guiado_por_pruebas) - [Behavior Driven Development (BDD)](http://www.wikiwand.com/es/Desarrollo_guiado_por_comportamiento) ### Frameworks - [QUnit](https://api.qunitjs.com/) - [Mocha](https://mochajs.org/) - [Chai](http://chaijs.com/) ### QUnit **Más información:** - [API Doc](http://api.qunitjs.com/) - [Cookbook](http://qunitjs.com/cookbook/) - [Plugins](https://qunitjs.com/plugins/) - [Ninja Theme](https://github.com/Krinkle/qunit-theme-ninja) - [SpecIt A QUnit-based API for bdd-style testing](https://github.com/joshuaclayton/specit) - [Html](https://github.com/JamesMGreene/qunit-assert-html) **API:** - [Assert](http://api.qunitjs.com/category/assert/) - [assert.async()](http://api.qunitjs.com/async/) - [assert.deepEqual()](http://api.qunitjs.com/deepEqual/) - [assert.equal()](http://api.qunitjs.com/equal/) - [assert.expect()](http://api.qunitjs.com/expect/) - [assert.notDeepEqual()](http://api.qunitjs.com/notDeepEqual/) - [assert.notEqual()](http://api.qunitjs.com/notEqual/) - [assert.notOk()](http://api.qunitjs.com/notOk/) - [assert.notPropEqual()](http://api.qunitjs.com/notPropEqual/) - [assert.notStrictEqual()](http://api.qunitjs.com/notStrictEqual/) - [assert.ok()](http://api.qunitjs.com/ok/) - [assert.propEqual()](http://api.qunitjs.com/propEqual/) - [assert.push()](http://api.qunitjs.com/push/) - [assert.strictEqual()](http://api.qunitjs.com/strictEqual/) - [assert.throws()](http://api.qunitjs.com/throws/) - [Callbacks](http://api.qunitjs.com/category/callbacks/) - [QUnit.begin()](http://api.qunitjs.com/QUnit.begin/) - [QUnit.done()](http://api.qunitjs.com/QUnit.done/) - [QUnit.log()](http://api.qunitjs.com/QUnit.log/) - [QUnit.moduleDone()](http://api.qunitjs.com/QUnit.moduleDone/) - [QUnit.moduleStart()](http://api.qunitjs.com/QUnit.moduleStart/) - [QUnit.testDone()](http://api.qunitjs.com/QUnit.testDone/) - [QUnit.testStart()](http://api.qunitjs.com/QUnit.testStart/) - [Utilidades y configuración](http://api.qunitjs.com/category/config/) - [QUnit.assert](http://api.qunitjs.com/QUnit.assert/) - [QUnit.config](http://api.qunitjs.com/QUnit.config/) - [QUnit.dump.parse()](http://api.qunitjs.com/QUnit.dump.parse/) - [QUnit.extend()](http://api.qunitjs.com/QUnit.extend/) - [QUnit.stack()](http://api.qunitjs.com/QUnit.stack/) - [Test](http://api.qunitjs.com/category/test/) - [QUnit.module()](http://api.qunitjs.com/QUnit.module/) - [QUnit.only()](http://api.qunitjs.com/QUnit.only/) - [QUnit.skip()](http://api.qunitjs.com/QUnit.skip/) - [QUnit.test()](http://api.qunitjs.com/QUnit.test/)
Fictizia/Curso-JS-para-desarrolladores-web_ed8
recursos/dia12.md
Markdown
gpl-3.0
2,710
[ 30522, 1001, 18856, 11022, 2260, 1001, 1001, 1001, 5604, 1006, 2777, 7716, 12898, 10440, 2015, 1007, 1011, 1031, 3231, 5533, 2458, 1006, 14595, 2094, 1007, 1033, 1006, 16770, 1024, 1013, 1013, 7479, 1012, 15536, 3211, 7447, 2094, 1012, 4012...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/******************************************************************************\ | | | package-version-file-types-view.js | | | |******************************************************************************| | | | This defines an dialog that is used to select directories within | | package versions. | | | |******************************************************************************| | Copyright (c) 2013 SWAMP - Software Assurance Marketplace | \******************************************************************************/ define([ 'jquery', 'underscore', 'backbone', 'marionette', 'text!templates/packages/info/versions/info/source/dialogs/package-version-file-types.tpl', 'scripts/registry', 'scripts/views/dialogs/error-view', 'scripts/views/files/file-types-list/file-types-list-view' ], function($, _, Backbone, Marionette, Template, Registry, ErrorView, FileTypesListView) { return Backbone.Marionette.LayoutView.extend({ // // attributes // regions: { fileTypes: '#file-types' }, events: { 'click #ok': 'onClickOk', 'keypress': 'onKeyPress' }, // // rendering methods // template: function() { return _.template(Template, { title: this.options.title, packagePath: this.options.packagePath }); }, onRender: function() { this.showFileTypes(); }, showFileTypes: function() { // fetch package version file types // var self = this; this.model.fetchFileTypes({ data: { 'dirname': this.options.packagePath }, // callbacks // success: function(data) { var collection = new Backbone.Collection(); for (var key in data) { collection.add(new Backbone.Model({ 'extension': key, 'count': data[key] })); } self.fileTypes.show( new FileTypesListView({ collection: collection }) ); }, error: function() { // show error dialog // Registry.application.modal.show( new ErrorView({ message: "Could not fetch file types for this package version." }) ); } }); }, // // event handling methods // onClickOk: function() { // apply callback // if (this.options.accept) { this.options.accept(); } }, onKeyPress: function(event) { // respond to enter key press // if (event.keyCode === 13) { this.onClickOk(); this.hide(); } } }); });
OWASP/open-swamp
registry-web-server/var/www/html/scripts/views/packages/info/versions/info/source/dialogs/package-version-file-types-view.js
JavaScript
apache-2.0
2,896
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# # Copyright 2017 Advanced Micro Devices, Inc. # # 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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. # # # Makefile for the 'audio' sub-component of DAL. # It provides the control and status of HW adapter resources, # that are global for the ASIC and sharable between pipes. IRQ = irq_service.o AMD_DAL_IRQ = $(addprefix $(AMDDALPATH)/dc/irq/,$(IRQ)) AMD_DISPLAY_FILES += $(AMD_DAL_IRQ) ############################################################################### # DCE 8x ############################################################################### IRQ_DCE80 = irq_service_dce80.o AMD_DAL_IRQ_DCE80 = $(addprefix $(AMDDALPATH)/dc/irq/dce80/,$(IRQ_DCE80)) AMD_DISPLAY_FILES += $(AMD_DAL_IRQ_DCE80) ############################################################################### # DCE 11x ############################################################################### IRQ_DCE11 = irq_service_dce110.o AMD_DAL_IRQ_DCE11 = $(addprefix $(AMDDALPATH)/dc/irq/dce110/,$(IRQ_DCE11)) AMD_DISPLAY_FILES += $(AMD_DAL_IRQ_DCE11) ############################################################################### # DCE 12x ############################################################################### IRQ_DCE12 = irq_service_dce120.o AMD_DAL_IRQ_DCE12 = $(addprefix $(AMDDALPATH)/dc/irq/dce120/,$(IRQ_DCE12)) AMD_DISPLAY_FILES += $(AMD_DAL_IRQ_DCE12) ############################################################################### # DCN 1x ############################################################################### ifdef CONFIG_DRM_AMD_DC_DCN1_0 IRQ_DCN1 = irq_service_dcn10.o AMD_DAL_IRQ_DCN1 = $(addprefix $(AMDDALPATH)/dc/irq/dcn10/,$(IRQ_DCN1)) AMD_DISPLAY_FILES += $(AMD_DAL_IRQ_DCN1) endif
BPI-SINOVOIP/BPI-Mainline-kernel
linux-4.19/drivers/gpu/drm/amd/display/dc/irq/Makefile
Makefile
gpl-2.0
2,718
[ 30522, 1001, 1001, 9385, 2418, 3935, 12702, 5733, 1010, 4297, 1012, 1001, 1001, 6656, 2003, 2182, 3762, 4379, 1010, 2489, 1997, 3715, 1010, 2000, 2151, 2711, 11381, 1037, 1001, 6100, 1997, 2023, 4007, 1998, 3378, 12653, 6764, 1006, 1996, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.avro.generic; import java.nio.ByteBuffer; import java.util.AbstractList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.Map; import org.apache.avro.AvroRuntimeException; import org.apache.avro.AvroTypeException; import org.apache.avro.Schema; import org.apache.avro.Schema.Field; import org.apache.avro.Schema.Type; import org.apache.avro.UnresolvedUnionException; import org.apache.avro.io.BinaryData; import org.apache.avro.util.Utf8; /** Utilities for generic Java data. */ public class GenericData { private static final GenericData INSTANCE = new GenericData(); /** Return the singleton instance. */ public static GenericData get() { return INSTANCE; } protected GenericData() {} /** Default implementation of {@link GenericRecord}. */ public static class Record implements GenericRecord, Comparable<Record> { private final Schema schema; private final Object[] values; public Record(Schema schema) { if (schema == null || !Type.RECORD.equals(schema.getType())) throw new AvroRuntimeException("Not a record schema: "+schema); this.schema = schema; this.values = new Object[schema.getFields().size()]; } @Override public Schema getSchema() { return schema; } @Override public void put(String key, Object value) { values[schema.getField(key).pos()] = value; } @Override public void put(int i, Object v) { values[i] = v; } @Override public Object get(String key) { Field field = schema.getField(key); if (field == null) return null; return values[field.pos()]; } @Override public Object get(int i) { return values[i]; } @Override public boolean equals(Object o) { if (o == this) return true; // identical object if (!(o instanceof Record)) return false; // not a record Record that = (Record)o; if (!schema.getFullName().equals(that.schema.getFullName())) return false; // not the same schema return this.compareTo(that) == 0; } @Override public int hashCode() { return GenericData.get().hashCode(this, schema); } @Override public int compareTo(Record that) { return GenericData.get().compare(this, that, schema); } @Override public String toString() { return GenericData.get().toString(this); } } /** Default implementation of an array. */ @SuppressWarnings(value="unchecked") public static class Array<T> extends AbstractList<T> implements GenericArray<T>, Comparable<GenericArray<T>> { private static final Object[] EMPTY = new Object[0]; private final Schema schema; private int size; private Object[] elements = EMPTY; public Array(int capacity, Schema schema) { if (schema == null || !Type.ARRAY.equals(schema.getType())) throw new AvroRuntimeException("Not an array schema: "+schema); this.schema = schema; if (capacity != 0) elements = new Object[capacity]; } public Schema getSchema() { return schema; } @Override public int size() { return size; } @Override public void clear() { size = 0; } @Override public Iterator<T> iterator() { return new Iterator<T>() { private int position = 0; public boolean hasNext() { return position < size; } public T next() { return (T)elements[position++]; } public void remove() { throw new UnsupportedOperationException(); } }; } @Override public T get(int i) { if (i >= size) throw new IndexOutOfBoundsException("Index " + i + " out of bounds."); return (T)elements[i]; } @Override public boolean add(T o) { if (size == elements.length) { Object[] newElements = new Object[(size * 3)/2 + 1]; System.arraycopy(elements, 0, newElements, 0, size); elements = newElements; } elements[size++] = o; return true; } public T peek() { return (size < elements.length) ? (T)elements[size] : null; } @Override public int hashCode() { return GenericData.get().hashCode(this, schema); } @Override public boolean equals(Object o) { if (o == this) return true; // identical object if (!(o instanceof Array)) return false; // not an array Array that = (Array)o; if (!schema.equals(that.schema)) return false; // not the same schema return this.compareTo(that) == 0; } public int compareTo(GenericArray<T> that) { return GenericData.get().compare(this, that, this.getSchema()); } public void reverse() { int left = 0; int right = elements.length - 1; while (left < right) { Object tmp = elements[left]; elements[left] = elements[right]; elements[right] = tmp; left++; right--; } } @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("["); int count = 0; for (T e : this) { buffer.append(e==null ? "null" : e.toString()); if (++count < size()) buffer.append(", "); } buffer.append("]"); return buffer.toString(); } } /** Default implementation of {@link GenericFixed}. */ public static class Fixed implements GenericFixed, Comparable<Fixed> { private byte[] bytes; public Fixed(Schema schema) { bytes(new byte[schema.getFixedSize()]); } public Fixed(byte[] bytes) { bytes(bytes); } protected Fixed() {} public void bytes(byte[] bytes) { this.bytes = bytes; } public byte[] bytes() { return bytes; } @Override public boolean equals(Object o) { if (o == this) return true; return o instanceof GenericFixed && Arrays.equals(bytes, ((GenericFixed)o).bytes()); } @Override public int hashCode() { return Arrays.hashCode(bytes); } @Override public String toString() { return Arrays.toString(bytes); } public int compareTo(Fixed that) { return BinaryData.compareBytes(this.bytes, 0, this.bytes.length, that.bytes, 0, that.bytes.length); } } /** Default implementation of {@link GenericEnumSymbol}. */ public static class EnumSymbol implements GenericEnumSymbol { private String symbol; public EnumSymbol(String symbol) { this.symbol = symbol; } @Override public boolean equals(Object o) { if (o == this) return true; return o instanceof GenericEnumSymbol && symbol.equals(o.toString()); } @Override public int hashCode() { return symbol.hashCode(); } @Override public String toString() { return symbol; } } /** Returns true if a Java datum matches a schema. */ public boolean validate(Schema schema, Object datum) { switch (schema.getType()) { case RECORD: if (!(datum instanceof IndexedRecord)) return false; IndexedRecord fields = (IndexedRecord)datum; for (Field f : schema.getFields()) { if (!validate(f.schema(), fields.get(f.pos()))) return false; } return true; case ENUM: return schema.getEnumSymbols().contains(datum.toString()); case ARRAY: if (!(datum instanceof Collection)) return false; for (Object element : (Collection<?>)datum) if (!validate(schema.getElementType(), element)) return false; return true; case MAP: if (!(datum instanceof Map)) return false; @SuppressWarnings(value="unchecked") Map<Object,Object> map = (Map<Object,Object>)datum; for (Map.Entry<Object,Object> entry : map.entrySet()) if (!validate(schema.getValueType(), entry.getValue())) return false; return true; case UNION: for (Schema type : schema.getTypes()) if (validate(type, datum)) return true; return false; case FIXED: return datum instanceof GenericFixed && ((GenericFixed)datum).bytes().length==schema.getFixedSize(); case STRING: return isString(datum); case BYTES: return isBytes(datum); case INT: return datum instanceof Integer; case LONG: return datum instanceof Long; case FLOAT: return datum instanceof Float; case DOUBLE: return datum instanceof Double; case BOOLEAN: return datum instanceof Boolean; case NULL: return datum == null; default: return false; } } /** Renders a Java datum as <a href="http://www.json.org/">JSON</a>. */ public String toString(Object datum) { StringBuilder buffer = new StringBuilder(); toString(datum, buffer); return buffer.toString(); } /** Renders a Java datum as <a href="http://www.json.org/">JSON</a>. */ protected void toString(Object datum, StringBuilder buffer) { if (datum instanceof IndexedRecord) { buffer.append("{"); int count = 0; IndexedRecord record = (IndexedRecord)datum; for (Field f : record.getSchema().getFields()) { toString(f.name(), buffer); buffer.append(": "); toString(record.get(f.pos()), buffer); if (++count < record.getSchema().getFields().size()) buffer.append(", "); } buffer.append("}"); } else if (datum instanceof Collection) { Collection<?> array = (Collection<?>)datum; buffer.append("["); long last = array.size()-1; int i = 0; for (Object element : array) { toString(element, buffer); if (i++ < last) buffer.append(", "); } buffer.append("]"); } else if (datum instanceof Map) { buffer.append("{"); int count = 0; @SuppressWarnings(value="unchecked") Map<Object,Object> map = (Map<Object,Object>)datum; for (Map.Entry<Object,Object> entry : map.entrySet()) { toString(entry.getKey(), buffer); buffer.append(": "); toString(entry.getValue(), buffer); if (++count < map.size()) buffer.append(", "); } buffer.append("}"); } else if (datum instanceof CharSequence || datum instanceof GenericEnumSymbol) { buffer.append("\""); writeEscapedString(datum.toString(), buffer); buffer.append("\""); } else if (datum instanceof ByteBuffer) { buffer.append("{\"bytes\": \""); ByteBuffer bytes = (ByteBuffer)datum; for (int i = bytes.position(); i < bytes.limit(); i++) buffer.append((char)bytes.get(i)); buffer.append("\"}"); } else { buffer.append(datum); } } /* Adapted from http://code.google.com/p/json-simple */ private void writeEscapedString(String string, StringBuilder builder) { for(int i = 0; i < string.length(); i++){ char ch = string.charAt(i); switch(ch){ case '"': builder.append("\\\""); break; case '\\': builder.append("\\\\"); break; case '\b': builder.append("\\b"); break; case '\f': builder.append("\\f"); break; case '\n': builder.append("\\n"); break; case '\r': builder.append("\\r"); break; case '\t': builder.append("\\t"); break; case '/': builder.append("\\/"); break; default: // Reference: http://www.unicode.org/versions/Unicode5.1.0/ if((ch>='\u0000' && ch<='\u001F') || (ch>='\u007F' && ch<='\u009F') || (ch>='\u2000' && ch<='\u20FF')){ String hex = Integer.toHexString(ch); builder.append("\\u"); for(int j = 0; j < 4-builder.length(); j++) builder.append('0'); builder.append(string.toUpperCase()); } else { builder.append(ch); } } } } /** Create a schema given an example datum. */ public Schema induce(Object datum) { if (datum instanceof IndexedRecord) { return ((IndexedRecord)datum).getSchema(); } else if (datum instanceof Collection) { Schema elementType = null; for (Object element : (Collection<?>)datum) { if (elementType == null) { elementType = induce(element); } else if (!elementType.equals(induce(element))) { throw new AvroTypeException("No mixed type arrays."); } } if (elementType == null) { throw new AvroTypeException("Empty array: "+datum); } return Schema.createArray(elementType); } else if (datum instanceof Map) { @SuppressWarnings(value="unchecked") Map<Object,Object> map = (Map<Object,Object>)datum; Schema value = null; for (Map.Entry<Object,Object> entry : map.entrySet()) { if (value == null) { value = induce(entry.getValue()); } else if (!value.equals(induce(entry.getValue()))) { throw new AvroTypeException("No mixed type map values."); } } if (value == null) { throw new AvroTypeException("Empty map: "+datum); } return Schema.createMap(value); } else if (datum instanceof GenericFixed) { return Schema.createFixed(null, null, null, ((GenericFixed)datum).bytes().length); } else if (datum instanceof CharSequence) return Schema.create(Type.STRING); else if (datum instanceof ByteBuffer) return Schema.create(Type.BYTES); else if (datum instanceof Integer) return Schema.create(Type.INT); else if (datum instanceof Long) return Schema.create(Type.LONG); else if (datum instanceof Float) return Schema.create(Type.FLOAT); else if (datum instanceof Double) return Schema.create(Type.DOUBLE); else if (datum instanceof Boolean) return Schema.create(Type.BOOLEAN); else if (datum == null) return Schema.create(Type.NULL); else throw new AvroTypeException("Can't create schema for: "+datum); } /** Called by {@link GenericDatumReader#readRecord} to set a record fields * value to a record instance. The default implementation is for {@link * IndexedRecord}.*/ public void setField(Object record, String name, int position, Object o) { ((IndexedRecord)record).put(position, o); } /** Called by {@link GenericDatumReader#readRecord} to retrieve a record * field value from a reused instance. The default implementation is for * {@link IndexedRecord}.*/ public Object getField(Object record, String name, int position) { return ((IndexedRecord)record).get(position); } /** Return the index for a datum within a union. Implemented with {@link * #instanceOf(Schema,Object)}.*/ public int resolveUnion(Schema union, Object datum) { int i = 0; for (Schema type : union.getTypes()) { if (instanceOf(type, datum)) return i; i++; } throw new UnresolvedUnionException(union, datum); } /** Called by {@link #resolveUnion(Schema,Object)}. May be overridden for alternate data representations.*/ protected boolean instanceOf(Schema schema, Object datum) { switch (schema.getType()) { case RECORD: if (!isRecord(datum)) return false; return (schema.getName() == null) || schema.getName().equals(getRecordSchema(datum).getName()); case ENUM: return isEnum(datum); case ARRAY: return isArray(datum); case MAP: return isMap(datum); case FIXED: return isFixed(datum); case STRING: return isString(datum); case BYTES: return isBytes(datum); case INT: return datum instanceof Integer; case LONG: return datum instanceof Long; case FLOAT: return datum instanceof Float; case DOUBLE: return datum instanceof Double; case BOOLEAN: return datum instanceof Boolean; case NULL: return datum == null; default: throw new AvroRuntimeException("Unexpected type: " +schema); } } /** Called by the default implementation of {@link #instanceOf}.*/ protected boolean isArray(Object datum) { return datum instanceof Collection; } /** Called by the default implementation of {@link #instanceOf}.*/ protected boolean isRecord(Object datum) { return datum instanceof IndexedRecord; } /** Called to obtain the schema of a record. By default calls * {GenericContainer#getSchema(). May be overridden for alternate record * representations. */ protected Schema getRecordSchema(Object record) { return ((GenericContainer)record).getSchema(); } /** Called by the default implementation of {@link #instanceOf}.*/ protected boolean isEnum(Object datum) { return datum instanceof GenericEnumSymbol; } /** Called by the default implementation of {@link #instanceOf}.*/ protected boolean isMap(Object datum) { return datum instanceof Map; } /** Called by the default implementation of {@link #instanceOf}.*/ protected boolean isFixed(Object datum) { return datum instanceof GenericFixed; } /** Called by the default implementation of {@link #instanceOf}.*/ protected boolean isString(Object datum) { return datum instanceof CharSequence; } /** Called by the default implementation of {@link #instanceOf}.*/ protected boolean isBytes(Object datum) { return datum instanceof ByteBuffer; } /** Compute a hash code according to a schema, consistent with {@link * #compare(Object,Object,Schema)}. */ public int hashCode(Object o, Schema s) { if (o == null) return 0; // incomplete datum int hashCode = 1; switch (s.getType()) { case RECORD: IndexedRecord r = (IndexedRecord)o; for (Field f : s.getFields()) { if (f.order() == Field.Order.IGNORE) continue; hashCode = hashCodeAdd(hashCode, r.get(f.pos()), f.schema()); } return hashCode; case ARRAY: Collection<?> a = (Collection<?>)o; Schema elementType = s.getElementType(); for (Object e : a) hashCode = hashCodeAdd(hashCode, e, elementType); return hashCode; case UNION: return hashCode(o, s.getTypes().get(resolveUnion(s, o))); case ENUM: return s.getEnumOrdinal(o.toString()); case NULL: return 0; case STRING: return (o instanceof Utf8 ? o : new Utf8(o.toString())).hashCode(); default: return o.hashCode(); } } /** Add the hash code for an object into an accumulated hash code. */ protected int hashCodeAdd(int hashCode, Object o, Schema s) { return 31*hashCode + hashCode(o, s); } /** Compare objects according to their schema. If equal, return zero. If * greater-than, return 1, if less than return -1. Order is consistent with * that of {@link BinaryData#compare(byte[], int, byte[], int, Schema)}. */ @SuppressWarnings(value="unchecked") public int compare(Object o1, Object o2, Schema s) { if (o1 == o2) return 0; switch (s.getType()) { case RECORD: for (Field f : s.getFields()) { if (f.order() == Field.Order.IGNORE) continue; // ignore this field int pos = f.pos(); String name = f.name(); int compare = compare(getField(o1, name, pos), getField(o2, name, pos), f.schema()); if (compare != 0) // not equal return f.order() == Field.Order.DESCENDING ? -compare : compare; } return 0; case ENUM: return s.getEnumOrdinal(o1.toString()) - s.getEnumOrdinal(o2.toString()); case ARRAY: Collection a1 = (Collection)o1; Collection a2 = (Collection)o2; Iterator e1 = a1.iterator(); Iterator e2 = a2.iterator(); Schema elementType = s.getElementType(); while(e1.hasNext() && e2.hasNext()) { int compare = compare(e1.next(), e2.next(), elementType); if (compare != 0) return compare; } return e1.hasNext() ? 1 : (e2.hasNext() ? -1 : 0); case MAP: throw new AvroRuntimeException("Can't compare maps!"); case UNION: int i1 = resolveUnion(s, o1); int i2 = resolveUnion(s, o2); return (i1 == i2) ? compare(o1, o2, s.getTypes().get(i1)) : i1 - i2; case NULL: return 0; case STRING: Utf8 u1 = o1 instanceof Utf8 ? (Utf8)o1 : new Utf8(o1.toString()); Utf8 u2 = o2 instanceof Utf8 ? (Utf8)o2 : new Utf8(o2.toString()); return u1.compareTo(u2); default: return ((Comparable)o1).compareTo(o2); } } }
cloudera/avro
lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
Java
apache-2.0
21,455
[ 30522, 1013, 1008, 1008, 1008, 7000, 2000, 1996, 15895, 4007, 3192, 1006, 2004, 2546, 1007, 2104, 2028, 1008, 2030, 2062, 12130, 6105, 10540, 1012, 2156, 1996, 5060, 5371, 1008, 5500, 2007, 2023, 2147, 2005, 3176, 2592, 1008, 4953, 9385, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>fullclient</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <h1 class="toc">Module fullclient</h1> <hr /> <h2 class="toc">Variables</h2> <a target="mainFrame" href="caldavclientlibrary.client.fullclient-module.html#__package__" >__package__</a><br /><hr /> <span class="options">[<a href="javascript:void(0);" class="privatelink" onclick="toggle_private();">hide&nbsp;private</a>]</span> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie(); // --> </script> </body> </html>
skarra/CalDAVClientLibrary
html/toc-caldavclientlibrary.client.fullclient-module.html
HTML
apache-2.0
1,128
[ 30522, 1026, 1029, 20950, 2544, 1027, 1000, 1015, 1012, 1014, 1000, 17181, 1027, 1000, 2004, 6895, 2072, 1000, 1029, 1028, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/********************************************************************************* * * Inviwo - Interactive Visualization Workshop * * Copyright (c) 2012-2021 Inviwo Foundation * 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. * * 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. * *********************************************************************************/ #pragma once #include <inviwo/qt/editor/inviwoqteditordefine.h> #include <inviwo/qt/editor/inviwomainwindow.h> #include <modules/qtwidgets/inviwodockwidget.h> class QObject; class QHelpEngineCore; class QResizeEvent; namespace inviwo { class QCHFileObserver; class HelpBrowser; class IVW_QTEDITOR_API HelpWidget : public InviwoDockWidget { public: HelpWidget(InviwoMainWindow* parent); virtual ~HelpWidget(); HelpWidget(const HelpWidget&) = delete; HelpWidget& operator=(const HelpWidget&) = delete; void showDocForClassName(std::string className); void registerQCHFiles(); protected: virtual void resizeEvent(QResizeEvent* event) override; private: void updateDoc(); InviwoMainWindow* mainwindow_; QHelpEngineCore* helpEngine_; HelpBrowser* helpBrowser_; std::string requested_; std::string current_; std::unique_ptr<QCHFileObserver> fileObserver_; // Called after modules have been registered std::shared_ptr<std::function<void()>> onModulesDidRegister_; // Called before modules have been unregistered std::shared_ptr<std::function<void()>> onModulesWillUnregister_; }; } // namespace inviwo
inviwo/inviwo
include/inviwo/qt/editor/helpwidget.h
C
bsd-2-clause
2,764
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> Singapore Gurkhas 070216 Gcspf Gurkha Contingent Archives Kkg 23</title> <!-- URL Structures --> <link rel="canonical" href="http://sgpm-generator.github.io/singapore-gurkha-photography-museum/singapore-gurkhas-070216-gcspf-gurkha-contingent-archives-kkg-23.html"> <link rel="alternate" type="application/rss+xml" title="Singapore Gurkha Photography Museum" href="http://sgpm-generator.github.io/feed.xml"> <!-- OPENGRAPH tags for Social Media linking --> <meta content="Singapore Gurkha Photography Museum" property="og:site_name"> <meta content=" Singapore Gurkhas 070216 Gcspf Gurkha Contingent Archives Kkg 23" property="og:title"> <meta content="article" property="og:type"> <meta name="description" content=" &lt;h1&gt;&lt;/h1&gt; {"1950s"=&gt;[#&lt;Jekyll::Document _posts/2014-10-11--singapore-gurkhas-050116-gcspf-gurkha-contingent-archives-kbg-26.md collect..." property="og:description"> <meta content="http://sgpm-generator.github.io/singapore-gurkha-photography-museum/singapore-gurkhas-070216-gcspf-gurkha-contingent-archives-kkg-23.html" property="og:url"> <meta content="2014-10-07T00:00:00+08:00" property="article:published_time"> <meta content="http://sgpm-generator.github.io/about/" property="article:author"> <meta content="" property="og:image"> <meta content="singapore-gurkha-photography-museum" property="article:section"> <meta content="1950s" property="article:tag"> <meta content="1960s" property="article:tag"> <meta content="1970s" property="article:tag"> <meta content="1980s" property="article:tag"> <meta content="1990s" property="article:tag"> <meta content="bhairahawa" property="article:tag"> <meta content="dharan" property="article:tag"> <meta content="gurkhas" property="article:tag"> <meta content="kathmandu" property="article:tag"> <meta content="nepal" property="article:tag"> <meta content="pokhara" property="article:tag"> <meta content="singapore" property="article:tag"> <meta content="singapore gurkha archive" property="article:tag"> <meta content="singapore gurkha old photographs" property="article:tag"> <meta content="singapore gurkha photography museum" property="article:tag"> <meta content="singapore gurkhas" property="article:tag"> <!-- OPENGRAPH tags end --> <!-- CSS --> <link rel="stylesheet" href="/css/bootstrap.min.css"> <link rel="stylesheet" href="/css/bootstrap-theme.min.css"> <!-- Custom CSS --> <style> @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700italic,700,400italic); .sgpm-title a { color: #030303; } .main-gallery > ul { margin-bottom:1.414em; padding-left:0; } .no-bullets { list-style:none; padding-left:0; } .no-bullets > ul { list-style:none; padding-left:0; } body {min-width:420px;} footer { margin-top:2.84em; padding-top:1.414em; border-top:0.3px solid #aaa ; } header { margin-bottom:2.84em; } main { display:block; clear:both; } </style> </head> <body class="container"> <header class="row"> <!-- masthead --> <div class="col-xs-4" style="display:table-block;"> <h1 class="sgpm-title hidden-xs hidden-sm"><strong><a class="site-title" href="/">Singapore Gurkha Photography Museum</a></strong></h1> <h2 class="sgpm-title visible-sm"><strong><a class="site-title" href="/">Singapore Gurkha Photography Museum</a></strong></h2> <h3 class="sgpm-title visible-xs"><strong><a class="site-title" href="/">Singapore Gurkha Photography Museum</a></strong></h3> <!-- searchbar--> <div class=""> <div class="input-group"> <input type="text" class="form-control" placeholder="Search for..."> <span class="input-group-btn"> <button class="btn btn-default" type="button"><span class="hidden-xs">Search</span><span class="visible-xs">Go</span></button> </span> </div> </div> <!-- searchbar end --> </div> <!-- masthead end --> <nav class="col-xs-4 col-xs-offset-2 col-sm-offset-1"> <ul class="nav col-xs-12" style="padding-top:1.41em;border-left:solid 0.3px #aaa" > <!-- navlinks --> <li class="active"> <a href="/about.html">About</a> </li> <li class="active"> <a href="/archive.html">Archive</a> </li> <li class="active"> <a href="/articles.html">Articles</a> </li> <li class="active"> <a href="/contact.html">Contact</a> </li> <!-- navlinks end--> <!-- dev links --> <li class="small">(these are links for development)</li> <li class="active"> <a href="/sgpm-list.html">Brute Force List</a> </li> <li class="active"> <a href="/basic-generator.html">Brute Generator</a> </li> <!-- dev links end--> </ul> </nav> </header> <main class="row"> <section class="col-sm-6 col-xs-12"> <a href="../img/singapore-gurkhas-070216-gcspf-gurkha-contingent-archives-kkg-23.jpg"> <img class="img-responsive" src="../img/singapore-gurkhas-070216-gcspf-gurkha-contingent-archives-kkg-23.jpg" /> </a> </section> <section class="col-sm-6 col-xs-12"> <ul style="list-style:none;margin-left:0;"> <li><h3>Photo from: KishoreKumarGurung-SingaporeGurkhaPhotographyMuseum</h3></li> <li> Was at Pasir Ris annual picnic, Nar Bahadur Gurung (4910). Lifeguard at Penguin swimming pool, Pokhara. Date: Late 1970s. </li> <a href="/tags/1950s" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> 1950s </li></a> <a href="/tags/1960s" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> 1960s </li></a> <a href="/tags/1970s" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> 1970s </li></a> <a href="/tags/1980s" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> 1980s </li></a> <a href="/tags/1990s" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> 1990s </li></a> <a href="/tags/bhairahawa" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> bhairahawa </li></a> <a href="/tags/dharan" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> dharan </li></a> <a href="/tags/gurkhas" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> gurkhas </li></a> <a href="/tags/kathmandu" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> kathmandu </li></a> <a href="/tags/nepal" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> nepal </li></a> <a href="/tags/pokhara" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> pokhara </li></a> <a href="/tags/singapore" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> singapore </li></a> <a href="/tags/singapore gurkha archive" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> singapore gurkha archive </li></a> <a href="/tags/singapore gurkha old photographs" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> singapore gurkha old photographs </li></a> <a href="/tags/singapore gurkha photography museum" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> singapore gurkha photography museum </li></a> <a href="/tags/singapore gurkhas" style="padding:3px; display:inline-block; background:#eee; margin-bottom:2px;"><li> singapore gurkhas </li></a> </ul> </section> </main> <footer class="row"> <div class="col-sm-4"> <h5 style="margin:0;font-weight:600;">©2016 Singapore Gurkha Photography Museum</h5> </div> <div class="col-sm-4"> <ul class="no-bullets"> <!-- contact --> <li><strong>email: </strong><a href="mailto:mail@zakariazainal.com">mail@zakariazainal.com</a></li> <!-- social media --> </ul> </div> <div class="col-sm-4"> <p class="small">The Singapore Gurkha Photography Museum project is an online archive of photographs and documents contributed by former members of the Singapore Gurkhas. </p> </div> </footer> <!-- jQuery --> <script src="/js/jquery.js"></script> <!-- Bootstrap Core JavaScript --> <script src="/js/bootstrap.min.js"></script> </body> </html>
sgpm-generator/sgpm-generator
singapore-gurkha-photography-museum/singapore-gurkhas-070216-gcspf-gurkha-contingent-archives-kkg-23.html
HTML
mit
8,711
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 1060, 1011, 25423, 1011, 11...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
glue ==== Quick modular web app prototyping ##TODO: Write something better here. ##Usage: First, define your views in .html files. Any scripts or css files you need to include specifically for that view, include them directly in the html (they will be extracted into the document's <head> later). * To load a view, just include an element with the `view` attribute, like this: ```html <div id="this_div" view="path/to/your/file.html"/> ``` View files are regular html, and can have nested views declared inside. Just remember that the view paths must be relative to the main html file (usually, your index.html). * To have links changing your views, include a link with the `load-view` attribute and, optionally, a target element (by `id`) with the `on` attribute: ```html <a href="#" load-view="path/to/that/other/file.html" on="that_other_div"> Load the other view </a> ``` When this link is clicked, the target div (in this case, the one whose id is `that_other_div`) will have its content replaced with html in the specified file. If no target is specified, Glue will climb up the DOM hierarchy from the `<a>` tag up, trying to find the first element with a `view` attribute. If one is found, the view is loaded in it. Otherwise, nothing happens. This means that if you only have one view at a time, you don't need to worry about specifying a target (although you probably should).
Darchangel/glue
README.md
Markdown
mit
1,403
[ 30522, 25238, 1027, 1027, 1027, 1027, 4248, 19160, 4773, 10439, 15053, 3723, 4691, 1001, 1001, 28681, 2080, 1024, 4339, 2242, 2488, 2182, 1012, 1001, 1001, 8192, 1024, 2034, 1010, 9375, 2115, 5328, 1999, 1012, 16129, 6764, 1012, 2151, 14546...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * DAWN OF LIGHT - The first free open source DAoC server emulator * * 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 * 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ using System; using DOL.GS; using DOL.GS.PacketHandler; using DOL.GS.Effects; namespace DOL.GS.Spells { [SpellHandlerAttribute("Tartaros")] public class Tartaros : LifedrainSpellHandler { public override int CalculateSpellResistChance(GameLiving target) { return 0; } /// <summary> /// Uses percent of damage to heal the caster /// </summary> public override void StealLife(AttackData ad) { if (ad == null) return; if (!Caster.IsAlive) return; int heal = (ad.Damage + ad.CriticalDamage) * 35 / 100; int mana = (ad.Damage + ad.CriticalDamage) * 21 / 100; int endu = (ad.Damage + ad.CriticalDamage) * 14 / 100; if (Caster.IsDiseased) { MessageToCaster("You are diseased!", eChatType.CT_SpellResisted); heal >>= 1; } if (heal <= 0) return; heal = Caster.ChangeHealth(Caster, GameLiving.eHealthChangeType.Spell, heal); if (heal > 0) { MessageToCaster("You drain " + heal + " hit point" + (heal == 1 ? "." : "s."), eChatType.CT_Spell); } else { MessageToCaster("You cannot absorb any more life.", eChatType.CT_SpellResisted); } if (mana <=0) return; mana = Caster.ChangeMana(Caster,GameLiving.eManaChangeType.Spell,mana); if (mana > 0) { MessageToCaster("You drain " + mana + " power point" + (mana == 1 ? "." : "s."), eChatType.CT_Spell); } else { MessageToCaster("You cannot absorb any more power.", eChatType.CT_SpellResisted); } if (endu <=0) return; endu = Caster.ChangeEndurance(Caster,GameLiving.eEnduranceChangeType.Spell,endu); if (heal > 0) { MessageToCaster("You drain " + endu + " endurance point" + (endu == 1 ? "." : "s."), eChatType.CT_Spell); } else { MessageToCaster("You cannot absorb any more endurance.", eChatType.CT_SpellResisted); } } public Tartaros(GameLiving caster, Spell spell, SpellLine line) : base(caster, spell, line) { } } }
Dawn-of-Light/DOLSharp
GameServer/spells/Artifacts/TartarosGift.cs
C#
gpl-2.0
3,289
[ 30522, 1013, 1008, 1008, 6440, 1997, 2422, 1011, 1996, 2034, 2489, 2330, 3120, 4830, 10085, 8241, 7861, 20350, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 1008, 19933, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright © 2013-2018 camunda services GmbH and various authors (info@camunda.com) * * 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 org.camunda.bpm.container.impl.jboss.deployment.processor; import static org.jboss.as.server.deployment.Attachments.MODULE; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import org.camunda.bpm.application.ProcessApplication; import org.camunda.bpm.application.impl.metadata.ProcessesXmlParser; import org.camunda.bpm.application.impl.metadata.spi.ProcessesXml; import org.camunda.bpm.container.impl.jboss.deployment.marker.ProcessApplicationAttachments; import org.camunda.bpm.container.impl.jboss.util.ProcessesXmlWrapper; import org.camunda.bpm.engine.ProcessEngineException; import org.camunda.bpm.engine.impl.util.IoUtil; import org.jboss.as.ee.component.ComponentDescription; import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; import org.jboss.modules.Module; import org.jboss.vfs.VFS; import org.jboss.vfs.VirtualFile; /** * <p>Detects and processes all <em>META-INF/processes.xml</em> files that are visible from the module * classloader of the {@link DeploymentUnit}.</p> * * <p>This is POST_MODULE so we can take into account module visibility in case of composite deployments * (EARs)</p> * * @author Daniel Meyer * */ public class ProcessesXmlProcessor implements DeploymentUnitProcessor { public static final String PROCESSES_XML = "META-INF/processes.xml"; public static final int PRIORITY = 0x0000; // this can happen ASAP in the POST_MODULE Phase public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) { return; } final Module module = deploymentUnit.getAttachment(MODULE); // read @ProcessApplication annotation of PA-component String[] deploymentDescriptors = getDeploymentDescriptors(deploymentUnit); // load all processes.xml files List<URL> deploymentDescriptorURLs = getDeploymentDescriptorUrls(module, deploymentDescriptors); for (URL processesXmlResource : deploymentDescriptorURLs) { VirtualFile processesXmlFile = getFile(processesXmlResource); // parse processes.xml metadata. ProcessesXml processesXml = null; if(isEmptyFile(processesXmlResource)) { processesXml = ProcessesXml.EMPTY_PROCESSES_XML; } else { processesXml = parseProcessesXml(processesXmlResource); } // add the parsed metadata to the attachment list ProcessApplicationAttachments.addProcessesXml(deploymentUnit, new ProcessesXmlWrapper(processesXml, processesXmlFile)); } } protected List<URL> getDeploymentDescriptorUrls(final Module module, String[] deploymentDescriptors) throws DeploymentUnitProcessingException { List<URL> deploymentDescriptorURLs = new ArrayList<URL>(); for (String deploymentDescriptor : deploymentDescriptors) { Enumeration<URL> resources = null; try { resources = module.getClassLoader().getResources(deploymentDescriptor); } catch (IOException e) { throw new DeploymentUnitProcessingException("Could not load processes.xml resource: ", e); } while (resources.hasMoreElements()) { deploymentDescriptorURLs.add((URL) resources.nextElement()); } } return deploymentDescriptorURLs; } protected String[] getDeploymentDescriptors(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final ComponentDescription processApplicationComponent = ProcessApplicationAttachments.getProcessApplicationComponent(deploymentUnit); final String paClassName = processApplicationComponent.getComponentClassName(); String[] deploymentDescriptorResourceNames = null; Module module = deploymentUnit.getAttachment(MODULE); Class<?> paClass = null; try { paClass = (Class<?>) module.getClassLoader().loadClass(paClassName); } catch (ClassNotFoundException e) { throw new DeploymentUnitProcessingException("Unable to load process application class '"+paClassName+"'."); } ProcessApplication annotation = paClass.getAnnotation(ProcessApplication.class); if(annotation == null) { deploymentDescriptorResourceNames = new String[]{ PROCESSES_XML }; } else { deploymentDescriptorResourceNames = annotation.deploymentDescriptors(); } return deploymentDescriptorResourceNames; } protected Enumeration<URL> getProcessesXmlResources(Module module, String[] deploymentDescriptors) throws DeploymentUnitProcessingException { try { return module.getClassLoader().getResources(PROCESSES_XML); } catch (IOException e) { throw new DeploymentUnitProcessingException(e); } } protected VirtualFile getFile(URL processesXmlResource) throws DeploymentUnitProcessingException { try { return VFS.getChild(processesXmlResource.toURI()); } catch(Exception e) { throw new DeploymentUnitProcessingException(e); } } protected boolean isEmptyFile(URL url) { InputStream inputStream = null; try { inputStream = url.openStream(); return inputStream.available() == 0; } catch (IOException e) { throw new ProcessEngineException("Could not open stream for " + url, e); } finally { IoUtil.closeSilently(inputStream); } } protected ProcessesXml parseProcessesXml(URL url) { final ProcessesXmlParser processesXmlParser = new ProcessesXmlParser(); ProcessesXml processesXml = processesXmlParser.createParse() .sourceUrl(url) .execute() .getProcessesXml(); return processesXml; } public void undeploy(DeploymentUnit context) { } }
xasx/camunda-bpm-platform
distro/wildfly8/subsystem/src/main/java/org/camunda/bpm/container/impl/jboss/deployment/processor/ProcessesXmlProcessor.java
Java
apache-2.0
6,632
[ 30522, 1013, 1008, 1008, 9385, 1075, 2286, 1011, 2760, 11503, 18426, 2578, 18289, 1998, 2536, 6048, 1006, 18558, 1030, 11503, 18426, 1012, 4012, 1007, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* ======================================== * File Name : B.cpp * Creation Date : 16-11-2020 * Last Modified : Po 16. listopadu 2020, 01:03:10 * Created By : Karel Ha <mathemage@gmail.com> * URL : https://codeforces.com/problemset/problem/1296/B * Points Gained (in case of online contest) : AC ==========================================*/ #include <bits/stdc++.h> using namespace std; #define REP(I,N) FOR(I,0,N) #define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define ALL(A) (A).begin(), (A).end() #define MSG(a) cout << #a << " == " << (a) << endl; const int CLEAN = -1; template <typename T> string NumberToString ( T Number ) { ostringstream ss; ss << Number; return ss.str(); } #define ERR(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); } vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)) v.emplace_back(x); return move(v); } void err(vector<string>::iterator it) {} template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) { cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << endl; err(++it, args...); } int solve(int s) { if (s < 10) { return s; } int x = s - s % 10; return x + solve(s - x + x / 10); } int main() { int t; cin >> t; while (t--) { int s; cin >> s; cout << solve(s) << endl; } return 0; }
mathemage/CompetitiveProgramming
codeforces/div3/1296/B/B.cpp
C++
mit
1,574
[ 30522, 1013, 1008, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 102...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
$Public = @(Get-ChildItem -Recurse -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue) $Private = @(Get-ChildItem -Recurse -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue) foreach ($import in @($Public + $Private)) { try { . $import.fullname } catch { Write-Error -Message "Failed to import function $($import.fullname): $_" } } Export-ModuleMember -Function $Public.Basename
DomBros/DomBrosTools
DomBrosTools/DomBrosTools.psm1
PowerShell
mit
438
[ 30522, 1002, 2270, 1027, 1030, 1006, 2131, 1011, 2775, 4221, 2213, 1011, 28667, 28393, 1011, 4130, 1002, 8827, 22483, 3217, 4140, 1032, 2270, 1032, 1008, 1012, 8827, 2487, 1011, 7561, 18908, 3258, 8601, 8663, 7629, 5657, 1007, 1002, 2797, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
html{ background: #FCFDE7; } body{ color: #433; display: inline-block; background-color: #F7D8A2; margin:0; padding: 0; border: 1px solid #F5F5F5; box-shadow: 1px 1px 2px rgba(0,0,0,0.1); padding-left: 20px; font-family: Tahoma, Trebuchet MS; } article#main-content{ height: 600px; float: left; } #meta-box { float: left; background: #442304; color: #B98D3D; height: 100px; width:170px; padding: 5px 20px 10px; position: relative; box-shadow: 1px 1px 2px rgba(0,0,0,0.1); } #meta-box a{ color: #d8aa76; } footer{ position: absolute; bottom: 0; padding: 10px 0; } .clear{ clear: both; } #play-box .cover{ position: absolute; left: 0; top:0; width: 100%; height: 100%; z-index: 10000; background: rgba(255,255,255,0.05); text-align: center; cursor: pointer; } #play-box .cover.active{ cursor: default; background: rgba(255,255,255,0.01); } #start-btn{ color: #FFFB94; text-shadow: 4px 4px 6px rgba(0, 0, 0, 0.8), 1px 1px 1px rgba(185, 178, 36, 1); font-size: 4em; margin: 120px 20px 0; display: inline-block; font-weight: bold; cursor: pointer; } #play-box.highlight .board[data-message=you] .frame-bar[data-dir=bottom]:after{ color: #FFF; }
okunishinishi/ChessTek
css/index.css
CSS
mit
1,320
[ 30522, 16129, 1063, 4281, 1024, 1001, 4429, 2546, 3207, 2581, 1025, 1065, 2303, 1063, 3609, 1024, 1001, 4724, 2509, 1025, 4653, 1024, 23881, 1011, 3796, 1025, 4281, 1011, 3609, 1024, 1001, 1042, 2581, 2094, 2620, 2050, 2475, 1025, 7785, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package run_test import ( "fmt" "net/url" "strings" "testing" "time" ) var tests Tests // Load all shared tests func init() { tests = make(map[string]Test) tests["database_commands"] = Test{ queries: []*Query{ &Query{ name: "create database should succeed", command: `CREATE DATABASE db0`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "create database with retention duration should succeed", command: `CREATE DATABASE db0_r WITH DURATION 24h REPLICATION 2 NAME db0_r_policy`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "create database with retention policy should fail with invalid name", command: `CREATE DATABASE db1 WITH NAME "."`, exp: `{"results":[{"statement_id":0,"error":"invalid name"}]}`, once: true, }, &Query{ name: "create database should error with some unquoted names", command: `CREATE DATABASE 0xdb0`, exp: `{"error":"error parsing query: found 0xdb0, expected identifier at line 1, char 17"}`, }, &Query{ name: "create database should error with invalid characters", command: `CREATE DATABASE "."`, exp: `{"results":[{"statement_id":0,"error":"invalid name"}]}`, }, &Query{ name: "create database with retention duration should error with bad retention duration", command: `CREATE DATABASE db0 WITH DURATION xyz`, exp: `{"error":"error parsing query: found xyz, expected duration at line 1, char 35"}`, }, &Query{ name: "create database with retention replication should error with bad retention replication number", command: `CREATE DATABASE db0 WITH REPLICATION xyz`, exp: `{"error":"error parsing query: found xyz, expected integer at line 1, char 38"}`, }, &Query{ name: "create database with retention name should error with missing retention name", command: `CREATE DATABASE db0 WITH NAME`, exp: `{"error":"error parsing query: found EOF, expected identifier at line 1, char 31"}`, }, &Query{ name: "show database should succeed", command: `SHOW DATABASES`, exp: `{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["db0"],["db0_r"]]}]}]}`, }, &Query{ name: "create database should not error with existing database", command: `CREATE DATABASE db0`, exp: `{"results":[{"statement_id":0}]}`, }, &Query{ name: "create database should create non-existing database", command: `CREATE DATABASE db1`, exp: `{"results":[{"statement_id":0}]}`, }, &Query{ name: "create database with retention duration should error if retention policy is different", command: `CREATE DATABASE db1 WITH DURATION 24h`, exp: `{"results":[{"statement_id":0,"error":"retention policy conflicts with an existing policy"}]}`, }, &Query{ name: "create database should error with bad retention duration", command: `CREATE DATABASE db1 WITH DURATION xyz`, exp: `{"error":"error parsing query: found xyz, expected duration at line 1, char 35"}`, }, &Query{ name: "show database should succeed", command: `SHOW DATABASES`, exp: `{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["db0"],["db0_r"],["db1"]]}]}]}`, }, &Query{ name: "drop database db0 should succeed", command: `DROP DATABASE db0`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "drop database db0_r should succeed", command: `DROP DATABASE db0_r`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "drop database db1 should succeed", command: `DROP DATABASE db1`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "drop database should not error if it does not exists", command: `DROP DATABASE db1`, exp: `{"results":[{"statement_id":0}]}`, }, &Query{ name: "drop database should not error with non-existing database db1", command: `DROP DATABASE db1`, exp: `{"results":[{"statement_id":0}]}`, }, &Query{ name: "show database should have no results", command: `SHOW DATABASES`, exp: `{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"]}]}]}`, }, &Query{ name: "create database with shard group duration should succeed", command: `CREATE DATABASE db0 WITH SHARD DURATION 61m`, exp: `{"results":[{"statement_id":0}]}`, }, &Query{ name: "create database with shard group duration and duration should succeed", command: `CREATE DATABASE db1 WITH DURATION 60m SHARD DURATION 30m`, exp: `{"results":[{"statement_id":0}]}`, }, }, } tests["drop_and_recreate_database"] = Test{ db: "db0", rp: "rp0", writes: Writes{ &Write{data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano())}, }, queries: []*Query{ &Query{ name: "Drop database after data write", command: `DROP DATABASE db0`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "Recreate database", command: `CREATE DATABASE db0`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "Recreate retention policy", command: `CREATE RETENTION POLICY rp0 ON db0 DURATION 365d REPLICATION 1 DEFAULT`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "Show measurements after recreate", command: `SHOW MEASUREMENTS`, exp: `{"results":[{"statement_id":0}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Query data after recreate", command: `SELECT * FROM cpu`, exp: `{"results":[{"statement_id":0}]}`, params: url.Values{"db": []string{"db0"}}, }, }, } tests["drop_database_isolated"] = Test{ db: "db0", rp: "rp0", writes: Writes{ &Write{data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano())}, }, queries: []*Query{ &Query{ name: "Query data from 1st database", command: `SELECT * FROM cpu`, exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","columns":["time","host","region","val"],"values":[["2000-01-01T00:00:00Z","serverA","uswest",23.2]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Query data from 1st database with GROUP BY *", command: `SELECT * FROM cpu GROUP BY *`, exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","tags":{"host":"serverA","region":"uswest"},"columns":["time","val"],"values":[["2000-01-01T00:00:00Z",23.2]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Drop other database", command: `DROP DATABASE db1`, once: true, exp: `{"results":[{"statement_id":0}]}`, }, &Query{ name: "Query data from 1st database and ensure it's still there", command: `SELECT * FROM cpu`, exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","columns":["time","host","region","val"],"values":[["2000-01-01T00:00:00Z","serverA","uswest",23.2]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Query data from 1st database and ensure it's still there with GROUP BY *", command: `SELECT * FROM cpu GROUP BY *`, exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","tags":{"host":"serverA","region":"uswest"},"columns":["time","val"],"values":[["2000-01-01T00:00:00Z",23.2]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, }, } tests["delete_series"] = Test{ db: "db0", rp: "rp0", writes: Writes{ &Write{data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano())}, &Write{data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=100 %d`, mustParseTime(time.RFC3339Nano, "2000-01-02T00:00:00Z").UnixNano())}, &Write{data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=200 %d`, mustParseTime(time.RFC3339Nano, "2000-01-03T00:00:00Z").UnixNano())}, &Write{db: "db1", data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano())}, }, queries: []*Query{ &Query{ name: "Show series is present", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["cpu,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Delete series", command: `DELETE FROM cpu WHERE time < '2000-01-03T00:00:00Z'`, exp: `{"results":[{"statement_id":0}]}`, params: url.Values{"db": []string{"db0"}}, once: true, }, &Query{ name: "Show series still exists", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["cpu,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Make sure last point still exists", command: `SELECT * FROM cpu`, exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","columns":["time","host","region","val"],"values":[["2000-01-03T00:00:00Z","serverA","uswest",200]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Make sure data wasn't deleted from other database.", command: `SELECT * FROM cpu`, exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","columns":["time","host","region","val"],"values":[["2000-01-01T00:00:00Z","serverA","uswest",23.2]]}]}]}`, params: url.Values{"db": []string{"db1"}}, }, }, } tests["drop_and_recreate_series"] = Test{ db: "db0", rp: "rp0", writes: Writes{ &Write{data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano())}, &Write{db: "db1", data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano())}, }, queries: []*Query{ &Query{ name: "Show series is present", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["cpu,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Drop series after data write", command: `DROP SERIES FROM cpu`, exp: `{"results":[{"statement_id":0}]}`, params: url.Values{"db": []string{"db0"}}, once: true, }, &Query{ name: "Show series is gone", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Make sure data wasn't deleted from other database.", command: `SELECT * FROM cpu`, exp: `{"results":[{"statement_id":0,"series":[{"name":"cpu","columns":["time","host","region","val"],"values":[["2000-01-01T00:00:00Z","serverA","uswest",23.2]]}]}]}`, params: url.Values{"db": []string{"db1"}}, }, }, } tests["drop_and_recreate_series_retest"] = Test{ db: "db0", rp: "rp0", writes: Writes{ &Write{data: fmt.Sprintf(`cpu,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano())}, }, queries: []*Query{ &Query{ name: "Show series is present again after re-write", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["cpu,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, }, } tests["drop_series_from_regex"] = Test{ db: "db0", rp: "rp0", writes: Writes{ &Write{data: strings.Join([]string{ fmt.Sprintf(`a,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano()), fmt.Sprintf(`aa,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano()), fmt.Sprintf(`b,host=serverA,region=uswest val=23.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano()), fmt.Sprintf(`c,host=serverA,region=uswest val=30.2 %d`, mustParseTime(time.RFC3339Nano, "2000-01-01T00:00:00Z").UnixNano()), }, "\n")}, }, queries: []*Query{ &Query{ name: "Show series is present", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["a,host=serverA,region=uswest"],["aa,host=serverA,region=uswest"],["b,host=serverA,region=uswest"],["c,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Drop series after data write", command: `DROP SERIES FROM /a.*/`, exp: `{"results":[{"statement_id":0}]}`, params: url.Values{"db": []string{"db0"}}, once: true, }, &Query{ name: "Show series is gone", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["b,host=serverA,region=uswest"],["c,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Drop series from regex that matches no measurements", command: `DROP SERIES FROM /a.*/`, exp: `{"results":[{"statement_id":0}]}`, params: url.Values{"db": []string{"db0"}}, once: true, }, &Query{ name: "make sure DROP SERIES doesn't delete anything when regex doesn't match", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["b,host=serverA,region=uswest"],["c,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Drop series with WHERE field should error", command: `DROP SERIES FROM c WHERE val > 50.0`, exp: `{"results":[{"statement_id":0,"error":"fields not supported in WHERE clause during deletion"}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "make sure DROP SERIES with field in WHERE didn't delete data", command: `SHOW SERIES`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["key"],"values":[["b,host=serverA,region=uswest"],["c,host=serverA,region=uswest"]]}]}]}`, params: url.Values{"db": []string{"db0"}}, }, &Query{ name: "Drop series with WHERE time should error", command: `DROP SERIES FROM c WHERE time > now() - 1d`, exp: `{"results":[{"statement_id":0,"error":"DROP SERIES doesn't support time in WHERE clause"}]}`, params: url.Values{"db": []string{"db0"}}, }, }, } tests["retention_policy_commands"] = Test{ db: "db0", queries: []*Query{ &Query{ name: "create retention policy with invalid name should return an error", command: `CREATE RETENTION POLICY "." ON db0 DURATION 1d REPLICATION 1`, exp: `{"results":[{"statement_id":0,"error":"invalid name"}]}`, once: true, }, &Query{ name: "create retention policy should succeed", command: `CREATE RETENTION POLICY rp0 ON db0 DURATION 1h REPLICATION 1`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "show retention policy should succeed", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["rp0","1h0m0s","1h0m0s",1,false]]}]}]}`, }, &Query{ name: "alter retention policy should succeed", command: `ALTER RETENTION POLICY rp0 ON db0 DURATION 2h REPLICATION 3 DEFAULT`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "show retention policy should have new altered information", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["rp0","2h0m0s","1h0m0s",3,true]]}]}]}`, }, &Query{ name: "show retention policy should still show policy", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["rp0","2h0m0s","1h0m0s",3,true]]}]}]}`, }, &Query{ name: "create a second non-default retention policy", command: `CREATE RETENTION POLICY rp2 ON db0 DURATION 1h REPLICATION 1`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "show retention policy should show both", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["rp0","2h0m0s","1h0m0s",3,true],["rp2","1h0m0s","1h0m0s",1,false]]}]}]}`, }, &Query{ name: "dropping non-default retention policy succeed", command: `DROP RETENTION POLICY rp2 ON db0`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "create a third non-default retention policy", command: `CREATE RETENTION POLICY rp3 ON db0 DURATION 1h REPLICATION 1 SHARD DURATION 30m`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "create retention policy with default on", command: `CREATE RETENTION POLICY rp3 ON db0 DURATION 1h REPLICATION 1 SHARD DURATION 30m DEFAULT`, exp: `{"results":[{"statement_id":0,"error":"retention policy conflicts with an existing policy"}]}`, once: true, }, &Query{ name: "show retention policy should show both with custom shard", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["rp0","2h0m0s","1h0m0s",3,true],["rp3","1h0m0s","1h0m0s",1,false]]}]}]}`, }, &Query{ name: "dropping non-default custom shard retention policy succeed", command: `DROP RETENTION POLICY rp3 ON db0`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "show retention policy should show just default", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["rp0","2h0m0s","1h0m0s",3,true]]}]}]}`, }, &Query{ name: "Ensure retention policy with unacceptable retention cannot be created", command: `CREATE RETENTION POLICY rp4 ON db0 DURATION 1s REPLICATION 1`, exp: `{"results":[{"statement_id":0,"error":"retention policy duration must be at least 1h0m0s"}]}`, once: true, }, &Query{ name: "Check error when deleting retention policy on non-existent database", command: `DROP RETENTION POLICY rp1 ON mydatabase`, exp: `{"results":[{"statement_id":0}]}`, }, &Query{ name: "Ensure retention policy for non existing db is not created", command: `CREATE RETENTION POLICY rp0 ON nodb DURATION 1h REPLICATION 1`, exp: `{"results":[{"statement_id":0,"error":"database not found: nodb"}]}`, once: true, }, &Query{ name: "drop rp0", command: `DROP RETENTION POLICY rp0 ON db0`, exp: `{"results":[{"statement_id":0}]}`, }, // INF Shard Group Duration will normalize to the Retention Policy Duration Default &Query{ name: "create retention policy with inf shard group duration", command: `CREATE RETENTION POLICY rpinf ON db0 DURATION INF REPLICATION 1 SHARD DURATION 0s`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, // 0s Shard Group Duration will normalize to the Replication Policy Duration &Query{ name: "create retention policy with 0s shard group duration", command: `CREATE RETENTION POLICY rpzero ON db0 DURATION 1h REPLICATION 1 SHARD DURATION 0s`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, // 1s Shard Group Duration will normalize to the MinDefaultRetentionPolicyDuration &Query{ name: "create retention policy with 1s shard group duration", command: `CREATE RETENTION POLICY rponesecond ON db0 DURATION 2h REPLICATION 1 SHARD DURATION 1s`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "show retention policy: validate normalized shard group durations are working", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["rpinf","0s","168h0m0s",1,false],["rpzero","1h0m0s","1h0m0s",1,false],["rponesecond","2h0m0s","1h0m0s",1,false]]}]}]}`, }, }, } tests["retention_policy_auto_create"] = Test{ queries: []*Query{ &Query{ name: "create database should succeed", command: `CREATE DATABASE db0`, exp: `{"results":[{"statement_id":0}]}`, once: true, }, &Query{ name: "show retention policies should return auto-created policy", command: `SHOW RETENTION POLICIES ON db0`, exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["autogen","0s","168h0m0s",1,true]]}]}]}`, }, }, } } func (tests Tests) load(t *testing.T, key string) Test { test, ok := tests[key] if !ok { t.Fatalf("no test %q", key) } return test.duplicate() }
swhsiang/pathfinder
vendor/github.com/influxdata/influxdb/cmd/influxd/run/server_suite_test.go
GO
mit
21,973
[ 30522, 7427, 2448, 1035, 3231, 12324, 1006, 1000, 4718, 2102, 1000, 1000, 5658, 1013, 24471, 2140, 1000, 1000, 7817, 1000, 1000, 5604, 1000, 1000, 2051, 1000, 1007, 13075, 5852, 5852, 1013, 1013, 7170, 2035, 4207, 5852, 4569, 2278, 1999, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2014-2016 CyberVision, 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. */ #include <string.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include "kaa_status.h" #include "kaa_test.h" #include "kaa_context.h" #include "kaa_status.h" #include "utilities/kaa_mem.h" #include "utilities/kaa_log.h" #include "kaa_context.h" #include "kaa_profile.h" #include "kaa_defaults.h" #include "gen/kaa_profile_gen.h" #include "kaa_platform_utils.h" #include "platform/ext_status.h" #include "platform/ext_sha.h" #include "platform/ext_key_utils.h" #include "platform/sock.h" #include "platform/ext_transport_channel.h" #include "kaa_channel_manager.h" #include "kaa_private.h" static kaa_context_t kaa_context; static kaa_logger_t *logger = NULL; static kaa_status_t *status = NULL; static kaa_channel_manager_t *channel_manager = NULL; static kaa_profile_manager_t *profile_manager = NULL; #define TEST_PUB_KEY_SIZE 20 static const uint8_t test_ep_key[TEST_PUB_KEY_SIZE] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14}; void kaa_read_status_ext(char **buffer, size_t *buffer_size, bool *needs_deallocation) { (void)buffer; (void)buffer_size; (void)needs_deallocation; } void kaa_store_status_ext(const char *buffer, size_t buffer_size) { (void)buffer; (void)buffer_size; } void kaa_get_endpoint_public_key(char **buffer, size_t *buffer_size, bool *needs_deallocation) { *buffer = (char *) KAA_MALLOC(TEST_PUB_KEY_SIZE * sizeof(char)); if (*buffer) { memcpy(*buffer, test_ep_key, TEST_PUB_KEY_SIZE); *buffer_size = TEST_PUB_KEY_SIZE; *needs_deallocation = true; } else { *buffer_size = 0; *needs_deallocation = false; } } /*----------------------------------------------------------------------------*/ /* Mock transport channel */ /* Flag to check that sync handler is actually called */ static int mock_sync_handler_called; static kaa_error_t init_channel(void *ctx, kaa_transport_context_t *tctx) { (void)ctx; (void)tctx; return KAA_ERR_NONE; } static kaa_error_t set_access_point(void *ctx, kaa_access_point_t *ap) { (void)ctx; (void)ap; return KAA_ERR_NONE; } static kaa_error_t get_protocol_id(void *ctx, kaa_transport_protocol_id_t *id) { (void)ctx; id->id = 0; id->version = 0; return KAA_ERR_NONE; } static kaa_error_t get_services(void *ctx, const kaa_extension_id **supported_list, size_t *count) { (void)ctx; /* Only profile service is "supported" by this mock */ static const kaa_extension_id services[] = { KAA_EXTENSION_PROFILE }; *supported_list = services; *count = 1; return KAA_ERR_NONE; } static kaa_error_t sync_handler(void *ctx, const kaa_extension_id services[], size_t count) { (void)ctx; ASSERT_EQUAL(1, count); ASSERT_EQUAL(KAA_EXTENSION_PROFILE, services[0]); mock_sync_handler_called = 1; return KAA_ERR_NONE; } static kaa_transport_channel_interface_t channel = { .context = NULL, .destroy = NULL, .sync_handler = sync_handler, .init = init_channel, .set_access_point = set_access_point, .get_protocol_id = get_protocol_id, .get_supported_services = get_services, }; /*----------------------------------------------------------------------------*/ void test_profile_is_set(void **state) { (void)state; #if KAA_PROFILE_SCHEMA_VERSION > 0 ASSERT_FALSE(kaa_profile_manager_is_profile_set(profile_manager)); kaa_profile_t *profile = kaa_profile_basic_endpoint_profile_test_create(); profile->profile_body = kaa_string_copy_create("test"); kaa_error_t error = kaa_profile_manager_update_profile(profile_manager, profile); profile->destroy(profile); ASSERT_EQUAL(error, KAA_ERR_NONE); ASSERT_TRUE(kaa_profile_manager_is_profile_set(profile_manager)); #else ASSERT_TRUE(kaa_profile_manager_is_profile_set(profile_manager)); #endif } void test_profile_update(void **state) { (void)state; kaa_profile_t *profile1 = kaa_profile_basic_endpoint_profile_test_create(); profile1->profile_body = kaa_string_copy_create("dummy"); kaa_error_t error = kaa_profile_manager_update_profile(profile_manager, profile1); ASSERT_EQUAL(error, KAA_ERR_NONE); bool need_resync = false; error = kaa_profile_need_profile_resync(profile_manager, &need_resync); ASSERT_EQUAL(error, KAA_ERR_NONE); ASSERT_TRUE(need_resync); error = kaa_profile_manager_update_profile(profile_manager, profile1); ASSERT_EQUAL(error, KAA_ERR_NONE); error = kaa_profile_need_profile_resync(profile_manager, &need_resync); ASSERT_EQUAL(error, KAA_ERR_NONE); ASSERT_FALSE(need_resync); profile1->destroy(profile1); kaa_profile_t *profile2 = kaa_profile_basic_endpoint_profile_test_create(); profile2->profile_body = kaa_string_copy_create("new_dummy"); error = kaa_profile_manager_update_profile(profile_manager, profile2); ASSERT_EQUAL(error, KAA_ERR_NONE); error = kaa_profile_need_profile_resync(profile_manager, &need_resync); ASSERT_EQUAL(error, KAA_ERR_NONE); ASSERT_TRUE(need_resync); profile2->destroy(profile2); } void test_profile_sync_get_size(void **state) { (void)state; kaa_profile_t *profile = kaa_profile_basic_endpoint_profile_test_create(); profile->profile_body = kaa_string_copy_create("dummy"); size_t serialized_profile_size = profile->get_size(profile); char *serialized_profile = (char *) KAA_MALLOC(serialized_profile_size * sizeof(char)); avro_writer_t writer = avro_writer_memory(serialized_profile, serialized_profile_size); profile->serialize(writer, profile); size_t expected_size = KAA_EXTENSION_HEADER_SIZE + sizeof(uint32_t) // profile size + kaa_aligned_size_get(serialized_profile_size); size_t profile_sync_size = 0; kaa_error_t error_code = kaa_profile_manager_update_profile(profile_manager, profile); ASSERT_EQUAL(error_code, KAA_ERR_NONE); status->is_registered = true; error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); ASSERT_EQUAL(expected_size, profile_sync_size); status->is_registered = false; expected_size += sizeof(uint32_t) + TEST_PUB_KEY_SIZE; error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); ASSERT_EQUAL(expected_size, profile_sync_size); const char *access_token = "access token"; error_code = kaa_profile_manager_set_endpoint_access_token(profile_manager, access_token); assert_int_equal(KAA_ERR_NONE, error_code); expected_size += sizeof(uint32_t) + strlen(access_token); error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); ASSERT_EQUAL(expected_size, profile_sync_size); avro_writer_free(writer); KAA_FREE(serialized_profile); profile->destroy(profile); } void test_profile_sync_serialize(void **state) { (void)state; kaa_error_t error_code; kaa_platform_message_writer_t *manual_writer; kaa_platform_message_writer_t *auto_writer; const char *access_token = "access token"; const size_t access_token_size = strlen(access_token); kaa_profile_t *profile = kaa_profile_basic_endpoint_profile_test_create(); profile->profile_body = kaa_string_copy_create("dummy"); size_t serialized_profile_size = profile->get_size(profile); char *serialized_profile = (char *) KAA_MALLOC(serialized_profile_size * sizeof(char)); avro_writer_t avro_writer = avro_writer_memory(serialized_profile, serialized_profile_size); profile->serialize(avro_writer, profile); error_code = kaa_profile_manager_update_profile(profile_manager, profile); ASSERT_EQUAL(error_code, KAA_ERR_NONE); status->is_registered = false; error_code = kaa_profile_manager_set_endpoint_access_token(profile_manager, access_token); ASSERT_EQUAL(error_code, KAA_ERR_NONE); size_t profile_sync_size; error_code = kaa_profile_request_get_size(profile_manager, &profile_sync_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); uint8_t buffer[profile_sync_size]; error_code = kaa_platform_message_writer_create(&manual_writer, buffer, profile_sync_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); uint32_t network_order_32; error_code = kaa_platform_message_write_extension_header(manual_writer , KAA_EXTENSION_PROFILE , 0 , profile_sync_size - KAA_EXTENSION_HEADER_SIZE); ASSERT_EQUAL(error_code, KAA_ERR_NONE); bool need_resync = true; ASSERT_EQUAL(kaa_profile_need_profile_resync(profile_manager, &need_resync), KAA_ERR_NONE); network_order_32 = KAA_HTONL(0); if (need_resync) network_order_32 = KAA_HTONL(serialized_profile_size); error_code = kaa_platform_message_write(manual_writer, &network_order_32, sizeof(uint32_t)); ASSERT_EQUAL(error_code, KAA_ERR_NONE); if (need_resync) { error_code = kaa_platform_message_write_aligned(manual_writer, serialized_profile, serialized_profile_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); } network_order_32 = KAA_HTONS(TEST_PUB_KEY_SIZE) << 16 | PUB_KEY_VALUE; error_code = kaa_platform_message_write(manual_writer, &network_order_32, sizeof(uint32_t)); ASSERT_EQUAL(error_code, KAA_ERR_NONE); error_code = kaa_platform_message_write_aligned(manual_writer, test_ep_key, TEST_PUB_KEY_SIZE); ASSERT_EQUAL(error_code, KAA_ERR_NONE); network_order_32 = KAA_HTONS(access_token_size) << 16 | ACCESS_TOKEN_VALUE; error_code = kaa_platform_message_write(manual_writer, &network_order_32, sizeof(uint32_t)); ASSERT_EQUAL(error_code, KAA_ERR_NONE); error_code = kaa_platform_message_write_aligned(manual_writer, access_token, access_token_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); uint8_t buffer2[profile_sync_size]; error_code = kaa_platform_message_writer_create(&auto_writer, buffer2, profile_sync_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); error_code = kaa_profile_request_serialize(profile_manager, auto_writer); ASSERT_EQUAL(error_code, KAA_ERR_NONE); error_code = (memcmp(buffer, buffer2, profile_sync_size) == 0 ? KAA_ERR_NONE : KAA_ERR_BADDATA); ASSERT_EQUAL(error_code, KAA_ERR_NONE); KAA_FREE(serialized_profile); avro_writer_free(avro_writer); profile->destroy(profile); kaa_platform_message_writer_destroy(auto_writer); kaa_platform_message_writer_destroy(manual_writer); } void test_profile_handle_sync(void **state) { (void)state; bool need_resync = false; uint16_t extension_options = 0x1; /* Need resync */ const size_t buffer_size = 6; uint8_t buffer[buffer_size]; kaa_platform_message_reader_t *reader; kaa_error_t error_code = kaa_platform_message_reader_create(&reader, buffer, buffer_size); ASSERT_EQUAL(error_code, KAA_ERR_NONE); error_code = kaa_profile_handle_server_sync(profile_manager, reader, extension_options, 0); ASSERT_EQUAL(error_code, KAA_ERR_NONE); error_code = kaa_profile_need_profile_resync(profile_manager, &need_resync); ASSERT_EQUAL(error_code, KAA_ERR_NONE); ASSERT_TRUE(need_resync); extension_options = 0x0; /* Need resync */ error_code = kaa_profile_handle_server_sync(profile_manager, reader, extension_options, 0); ASSERT_EQUAL(error_code, KAA_ERR_NONE); error_code = kaa_profile_need_profile_resync(profile_manager, &need_resync); ASSERT_EQUAL(error_code, KAA_ERR_NONE); ASSERT_FALSE(need_resync); kaa_platform_message_reader_destroy(reader); } static void test_profile_force_sync(void **state) { (void)state; kaa_error_t rc = kaa_profile_force_sync(profile_manager); ASSERT_EQUAL(KAA_ERR_NONE, rc); ASSERT_TRUE(mock_sync_handler_called); } int test_init(void **state) { (void)state; kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL); if (error || !logger) { return error; } kaa_context.logger = logger; error = kaa_status_create(&status); if (error || !status) { return error; } error = kaa_channel_manager_create(&channel_manager, &kaa_context); if (error || !channel_manager) { return error; } /* Add channel will fail due to absent access point, but it is expected */ kaa_channel_manager_add_transport_channel(channel_manager, &channel, NULL); error = kaa_profile_manager_create(&profile_manager, status, channel_manager, logger); if (error || !profile_manager) { return error; } return 0; } int test_deinit(void **state) { (void)state; kaa_profile_manager_destroy(profile_manager); kaa_channel_manager_destroy(channel_manager); kaa_status_destroy(status); kaa_log_destroy(logger); return 0; } int main(void) { const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown(test_profile_is_set, test_init, test_deinit), cmocka_unit_test_setup_teardown(test_profile_update, test_init, test_deinit), cmocka_unit_test_setup_teardown(test_profile_sync_get_size, test_init, test_deinit), cmocka_unit_test_setup_teardown(test_profile_sync_serialize, test_init, test_deinit), cmocka_unit_test_setup_teardown(test_profile_handle_sync, test_init, test_deinit), cmocka_unit_test_setup_teardown(test_profile_force_sync, test_init, test_deinit), }; return cmocka_run_group_tests(tests, NULL, NULL); }
forGGe/kaa
client/client-multi/client-c/test/test_kaa_profile.c
C
apache-2.0
14,769
[ 30522, 1013, 1008, 1008, 9385, 2297, 1011, 2355, 16941, 17084, 1010, 4297, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2025, 2224, 2023, 5371, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class PassengerStatus < Scout::Plugin def build_report cmd = option(:passenger_status_command) || "passenger-status" data = `#{cmd} 2>&1` if $?.success? stats = parse_data(data) report(stats) else error "Could not get data from command", "Error: #{data}" end end private def parse_data(data) stats = {} data.each_line do |line| #line = line.gsub(/\e\[\d+m/,'') if line =~ /^max\s+=\s(\d+)/ stats["max"] = $1 elsif line =~ /^count\s+=\s(\d+)/ stats["current"] = $1 elsif line =~ /^active\s+=\s(\d+)/ stats["active"] = $1 elsif line =~ /^inactive\s+=\s(\d+)/ stats["inactive"] = $1 elsif line =~ /^Waiting on global queue: (\d+)/ stats["gq_wait"] = $1 end end stats end end
pingdomserver/scout-plugins
passenger_status/passenger_status.rb
Ruby
mit
830
[ 30522, 2465, 5467, 29336, 2271, 1026, 7464, 1024, 1024, 13354, 2378, 13366, 3857, 1035, 3189, 4642, 2094, 1027, 5724, 1006, 1024, 4628, 1035, 3570, 1035, 3094, 1007, 1064, 1064, 1000, 4628, 1011, 3570, 1000, 2951, 1027, 1036, 1001, 1063, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
showWord(["n. "," aktivite pou al chase bèt sovaj pou vyann nan osnon pou po. Mwen pa janm al lachas, paske mwen pa gen kè pou mwen touye okenn bèt." ])
georgejhunt/HaitiDictionary.activity
data/words/lachas.js
JavaScript
gpl-2.0
155
[ 30522, 2265, 18351, 1006, 1031, 1000, 1050, 1012, 1000, 1010, 1000, 17712, 29068, 4221, 13433, 2226, 2632, 5252, 6655, 2061, 3567, 3501, 13433, 2226, 1058, 7054, 2078, 16660, 9808, 8540, 13433, 2226, 13433, 1012, 12464, 2368, 6643, 5553, 22...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// From https://hapijs.com/api/16.1.1#route-prerequisites import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); const pre1: Hapi.RoutePrerequisiteRequestHandler = function (request, reply) { return reply('Hello'); }; const pre2: Hapi.RoutePrerequisiteRequestHandler = function (request, reply) { return reply('World'); }; const pre3: Hapi.RoutePrerequisiteRequestHandler = function (request, reply) { const pre = request.pre as Pre1; return reply(pre.m1 + ' ' + pre.m2); }; server.route({ method: 'GET', path: '/', config: { pre: [ [ // m1 and m2 executed in parallel { method: pre1, assign: 'm1' }, { method: pre2, assign: 'm2' } ], { method: pre3, assign: 'm3' }, ], handler: function (request, reply) { const pre = request.pre as Pre2; return reply(pre.m3 + '\n'); } } }); interface Pre1 { m1: string; m2: string; } interface Pre2 extends Pre1 { m3: string; }
markogresak/DefinitelyTyped
types/hapi/v16/test/route/prerequisites.ts
TypeScript
mit
1,098
[ 30522, 1013, 1013, 2013, 16770, 1024, 1013, 1013, 5292, 8197, 22578, 1012, 4012, 1013, 17928, 1013, 2385, 1012, 1015, 1012, 1015, 1001, 2799, 1011, 3653, 2890, 24871, 2015, 12324, 1008, 2004, 5292, 8197, 2013, 1005, 5292, 8197, 1005, 1025, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package lab; public class IntArrayWorker { /** two dimensional matrix */ private int[][] matrix = null; /** set the matrix to the passed one * @param theMatrix the one to use */ public void setMatrix(int[][] theMatrix) { matrix = theMatrix; } /** * Method to return the total * @return the total of the values in the array */ public int getTotal() { int total = 0; for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < matrix[0].length; col++) { total = total + matrix[row][col]; } } return total; } /** * Method to return the total using a nested for-each loop * @return the total of the values in the array */ public int getTotalNested() { int total = 0; for (int[] rowArray : matrix) { for (int item : rowArray) { total = total + item; } } return total; } /** * Method to fill with an increasing count */ public void fillCount() { int numCols = matrix[0].length; int count = 1; for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < numCols; col++) { matrix[row][col] = count; count++; } } } /** * print the values in the array in rows and columns */ public void print() { for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < matrix[0].length; col++) { System.out.print( matrix[row][col] + " " ); } System.out.println(); } System.out.println(); } public int getCount(int num){ int count = 0; for(int row = 0; row < matrix.length; row++) for(int col = 0; col < matrix[0].length; col++) if(matrix[row][col] == num) count++; return count; } public int getColTotal(int col){ int total = 0; for(int row = 0; row < matrix.length; row++) total += matrix[row][col]; return total; } public int getLargest(){ int largest = matrix[0][0]; for(int row = 0; row < matrix.length; row++) for(int col = 0; col < matrix[0].length; col++) if(matrix[row][col] > largest) largest = matrix[row][col]; return largest; } /** * fill the array with a pattern */ public void fillPattern1() { for (int row = 0; row < matrix.length; row++) { for (int col = 0; col < matrix[0].length; col++) { if (row < col) matrix[row][col] = 1; else if (row == col) matrix[row][col] = 2; else matrix[row][col] = 3; } } } }
Zedai/APCOMSCI
ApComSci/pictures_lab/lab/IntArrayWorker.java
Java
mit
2,755
[ 30522, 7427, 6845, 1025, 2270, 2465, 20014, 2906, 9447, 6198, 2121, 1063, 1013, 1008, 1008, 2048, 8789, 8185, 1008, 1013, 2797, 20014, 1031, 1033, 1031, 1033, 8185, 1027, 19701, 1025, 1013, 1008, 1008, 2275, 1996, 8185, 2000, 1996, 2979, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#ifndef GRAPH_INTERFACE_HPP #define GRAPH_INTERFACE_HPP #include "graphdsl.hpp" #include <vector> #include <utility> #include <type_traits> namespace netalgo { template<typename NodeType, typename EdgeType> class GraphInterface { private: static_assert(std::is_class<NodeType>::value, "NodeType must be a class type"); static_assert(std::is_class<EdgeType>::value, "EdgeType must be a class type"); template<typename U> static std::false_type sfinae_checkid(bool, U NodeType::* = &NodeType::id()) {} static std::true_type sfinae_checkid(int) {} static_assert(decltype(sfinae_checkid(0))::value, "NodeType must contain member function id"); template<typename U> static std::false_type sfinae_checkedge(bool, U EdgeType::* = &EdgeType::id()) {} static std::true_type sfinae_checkedge(int) {} static_assert(decltype(sfinae_checkedge(0))::value, "EdgeType must contain member function id"); template<typename U> static std::false_type sfinae_checkedgefrom(bool, U EdgeType::* = &EdgeType::from()) {} static std::true_type sfinae_checkedgefrom(int) {} static_assert(decltype(sfinae_checkedgefrom(0))::value, "EdgeType must contain member function from"); template<typename U> static std::false_type sfinae_checkedgeto(bool, U EdgeType::* = &EdgeType::to) {} static std::true_type sfinae_checkedgeto(int) {} static_assert(decltype(sfinae_checkedgeto(0))::value, "EdgeType must contain member function to"); static_assert(std::is_convertible< decltype(std::declval<EdgeType>().from()), decltype(std::declval<NodeType>().id()) >::value, "EdgeType.from() must be convertible to NodeType.id()"); static_assert(std::is_convertible< decltype(std::declval<EdgeType>().to()), decltype(std::declval<NodeType>().id()) >::value, "EdgeType.to() must be convertible to NodeType.id()"); public: GraphInterface() = default; GraphInterface(const GraphInterface&) = delete; GraphInterface& operator=(const GraphInterface&) = delete; GraphInterface(GraphInterface&&) = default; virtual ~GraphInterface() {} typedef std::vector<NodeType> NodesBundle; typedef std::vector<EdgeType> EdgesBundle; typedef std::pair<NodesBundle, EdgesBundle> ResultType; typedef typename std::remove_const< typename std::remove_reference<decltype(std::declval<NodeType>().id())>::type >::type NodeIdType; typedef typename std::remove_const< typename std::remove_reference<decltype(std::declval<EdgeType>().id())>::type >::type EdgeIdType; virtual void setNode(const NodeType&) = 0; virtual void setEdge(const EdgeType&) = 0; virtual void setNodesBundle(const NodesBundle&) = 0; virtual void setEdgesBundle(const EdgesBundle&) = 0; virtual void removeNode(const NodeIdType&) = 0; virtual void removeEdge(const EdgeIdType&) = 0; virtual void destroy() = 0; }; } #endif
htfy96/network_algo
include/graph_interface.hpp
C++
gpl-3.0
3,289
[ 30522, 1001, 2065, 13629, 2546, 10629, 1035, 8278, 1035, 6522, 2361, 1001, 9375, 10629, 1035, 8278, 1035, 6522, 2361, 1001, 2421, 1000, 10629, 5104, 2140, 1012, 6522, 2361, 1000, 1001, 2421, 1026, 9207, 1028, 1001, 2421, 1026, 9710, 1028, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package client import ( "bufio" "bytes" "encoding/base64" "encoding/json" "errors" "fmt" "io" "io/ioutil" "net/http" "net/url" "os" "os/exec" "path" "path/filepath" "runtime" "sort" "strconv" "strings" "sync" "text/tabwriter" "text/template" "time" log "github.com/Sirupsen/logrus" "github.com/docker/docker/api" "github.com/docker/docker/api/types" "github.com/docker/docker/autogen/dockerversion" "github.com/docker/docker/engine" "github.com/docker/docker/graph" "github.com/docker/docker/nat" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/common" "github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/homedir" flag "github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/parsers/filters" "github.com/docker/docker/pkg/progressreader" "github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/resolvconf" "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/timeutils" "github.com/docker/docker/pkg/units" "github.com/docker/docker/pkg/urlutil" "github.com/docker/docker/registry" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" ) const ( tarHeaderSize = 512 ) func (cli *DockerCli) CmdHelp(args ...string) error { if len(args) > 1 { method, exists := cli.getMethod(args[:2]...) if exists { method("--help") return nil } } if len(args) > 0 { method, exists := cli.getMethod(args[0]) if !exists { fmt.Fprintf(cli.err, "docker: '%s' is not a docker command. See 'docker --help'.\n", args[0]) os.Exit(1) } else { method("--help") return nil } } flag.Usage() return nil } func (cli *DockerCli) CmdBuild(args ...string) error { cmd := cli.Subcmd("build", "PATH | URL | -", "Build a new image from the source code at PATH", true) tag := cmd.String([]string{"t", "-tag"}, "", "Repository name (and optionally a tag) for the image") suppressOutput := cmd.Bool([]string{"q", "-quiet"}, false, "Suppress the verbose output generated by the containers") noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image") rm := cmd.Bool([]string{"#rm", "-rm"}, true, "Remove intermediate containers after a successful build") forceRm := cmd.Bool([]string{"-force-rm"}, false, "Always remove intermediate containers") pull := cmd.Bool([]string{"-pull"}, false, "Always attempt to pull a newer version of the image") dockerfileName := cmd.String([]string{"f", "-file"}, "", "Name of the Dockerfile (Default is 'PATH/Dockerfile')") flMemoryString := cmd.String([]string{"m", "-memory"}, "", "Memory limit") flMemorySwap := cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap") flCpuShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)") flCpuSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)") cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) var ( context archive.Archive isRemote bool err error ) _, err = exec.LookPath("git") hasGit := err == nil if cmd.Arg(0) == "-" { // As a special case, 'docker build -' will build from either an empty context with the // contents of stdin as a Dockerfile, or a tar-ed context from stdin. buf := bufio.NewReader(cli.in) magic, err := buf.Peek(tarHeaderSize) if err != nil && err != io.EOF { return fmt.Errorf("failed to peek context header from STDIN: %v", err) } if !archive.IsArchive(magic) { dockerfile, err := ioutil.ReadAll(buf) if err != nil { return fmt.Errorf("failed to read Dockerfile from STDIN: %v", err) } // -f option has no meaning when we're reading it from stdin, // so just use our default Dockerfile name *dockerfileName = api.DefaultDockerfileName context, err = archive.Generate(*dockerfileName, string(dockerfile)) } else { context = ioutil.NopCloser(buf) } } else if urlutil.IsURL(cmd.Arg(0)) && (!urlutil.IsGitURL(cmd.Arg(0)) || !hasGit) { isRemote = true } else { root := cmd.Arg(0) if urlutil.IsGitURL(root) { remoteURL := cmd.Arg(0) if !urlutil.IsGitTransport(remoteURL) { remoteURL = "https://" + remoteURL } root, err = ioutil.TempDir("", "docker-build-git") if err != nil { return err } defer os.RemoveAll(root) if output, err := exec.Command("git", "clone", "--recursive", remoteURL, root).CombinedOutput(); err != nil { return fmt.Errorf("Error trying to use git: %s (%s)", err, output) } } if _, err := os.Stat(root); err != nil { return err } absRoot, err := filepath.Abs(root) if err != nil { return err } filename := *dockerfileName // path to Dockerfile if *dockerfileName == "" { // No -f/--file was specified so use the default *dockerfileName = api.DefaultDockerfileName filename = filepath.Join(absRoot, *dockerfileName) // Just to be nice ;-) look for 'dockerfile' too but only // use it if we found it, otherwise ignore this check if _, err = os.Lstat(filename); os.IsNotExist(err) { tmpFN := path.Join(absRoot, strings.ToLower(*dockerfileName)) if _, err = os.Lstat(tmpFN); err == nil { *dockerfileName = strings.ToLower(*dockerfileName) filename = tmpFN } } } origDockerfile := *dockerfileName // used for error msg if filename, err = filepath.Abs(filename); err != nil { return err } // Verify that 'filename' is within the build context filename, err = symlink.FollowSymlinkInScope(filename, absRoot) if err != nil { return fmt.Errorf("The Dockerfile (%s) must be within the build context (%s)", origDockerfile, root) } // Now reset the dockerfileName to be relative to the build context *dockerfileName, err = filepath.Rel(absRoot, filename) if err != nil { return err } // And canonicalize dockerfile name to a platform-independent one *dockerfileName, err = archive.CanonicalTarNameForPath(*dockerfileName) if err != nil { return fmt.Errorf("Cannot canonicalize dockerfile path %s: %v", dockerfileName, err) } if _, err = os.Lstat(filename); os.IsNotExist(err) { return fmt.Errorf("Cannot locate Dockerfile: %s", origDockerfile) } var includes = []string{"."} excludes, err := utils.ReadDockerIgnore(path.Join(root, ".dockerignore")) if err != nil { return err } // If .dockerignore mentions .dockerignore or the Dockerfile // then make sure we send both files over to the daemon // because Dockerfile is, obviously, needed no matter what, and // .dockerignore is needed to know if either one needs to be // removed. The deamon will remove them for us, if needed, after it // parses the Dockerfile. keepThem1, _ := fileutils.Matches(".dockerignore", excludes) keepThem2, _ := fileutils.Matches(*dockerfileName, excludes) if keepThem1 || keepThem2 { includes = append(includes, ".dockerignore", *dockerfileName) } if err = utils.ValidateContextDirectory(root, excludes); err != nil { return fmt.Errorf("Error checking context is accessible: '%s'. Please check permissions and try again.", err) } options := &archive.TarOptions{ Compression: archive.Uncompressed, ExcludePatterns: excludes, IncludeFiles: includes, } context, err = archive.TarWithOptions(root, options) if err != nil { return err } } // windows: show error message about modified file permissions // FIXME: this is not a valid warning when the daemon is running windows. should be removed once docker engine for windows can build. if runtime.GOOS == "windows" { log.Warn(`SECURITY WARNING: You are building a Docker image from Windows against a Linux Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`) } var body io.Reader // Setup an upload progress bar // FIXME: ProgressReader shouldn't be this annoying to use if context != nil { sf := utils.NewStreamFormatter(false) body = progressreader.New(progressreader.Config{ In: context, Out: cli.out, Formatter: sf, NewLines: true, ID: "", Action: "Sending build context to Docker daemon", }) } var memory int64 if *flMemoryString != "" { parsedMemory, err := units.RAMInBytes(*flMemoryString) if err != nil { return err } memory = parsedMemory } var memorySwap int64 if *flMemorySwap != "" { if *flMemorySwap == "-1" { memorySwap = -1 } else { parsedMemorySwap, err := units.RAMInBytes(*flMemorySwap) if err != nil { return err } memorySwap = parsedMemorySwap } } // Send the build context v := &url.Values{} //Check if the given image name can be resolved if *tag != "" { repository, tag := parsers.ParseRepositoryTag(*tag) if err := registry.ValidateRepositoryName(repository); err != nil { return err } if len(tag) > 0 { if err := graph.ValidateTagName(tag); err != nil { return err } } } v.Set("t", *tag) if *suppressOutput { v.Set("q", "1") } if isRemote { v.Set("remote", cmd.Arg(0)) } if *noCache { v.Set("nocache", "1") } if *rm { v.Set("rm", "1") } else { v.Set("rm", "0") } if *forceRm { v.Set("forcerm", "1") } if *pull { v.Set("pull", "1") } v.Set("cpusetcpus", *flCpuSetCpus) v.Set("cpushares", strconv.FormatInt(*flCpuShares, 10)) v.Set("memory", strconv.FormatInt(memory, 10)) v.Set("memswap", strconv.FormatInt(memorySwap, 10)) v.Set("dockerfile", *dockerfileName) cli.LoadConfigFile() headers := http.Header(make(map[string][]string)) buf, err := json.Marshal(cli.configFile) if err != nil { return err } headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf)) if context != nil { headers.Set("Content-Type", "application/tar") } err = cli.stream("POST", fmt.Sprintf("/build?%s", v.Encode()), body, cli.out, headers) if jerr, ok := err.(*utils.JSONError); ok { // If no error code is set, default to 1 if jerr.Code == 0 { jerr.Code = 1 } return &utils.StatusError{Status: jerr.Message, StatusCode: jerr.Code} } return err } // 'docker login': login / register a user to registry service. func (cli *DockerCli) CmdLogin(args ...string) error { cmd := cli.Subcmd("login", "[SERVER]", "Register or log in to a Docker registry server, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true) cmd.Require(flag.Max, 1) var username, password, email string cmd.StringVar(&username, []string{"u", "-username"}, "", "Username") cmd.StringVar(&password, []string{"p", "-password"}, "", "Password") cmd.StringVar(&email, []string{"e", "-email"}, "", "Email") utils.ParseFlags(cmd, args, true) serverAddress := registry.IndexServerAddress() if len(cmd.Args()) > 0 { serverAddress = cmd.Arg(0) } promptDefault := func(prompt string, configDefault string) { if configDefault == "" { fmt.Fprintf(cli.out, "%s: ", prompt) } else { fmt.Fprintf(cli.out, "%s (%s): ", prompt, configDefault) } } readInput := func(in io.Reader, out io.Writer) string { reader := bufio.NewReader(in) line, _, err := reader.ReadLine() if err != nil { fmt.Fprintln(out, err.Error()) os.Exit(1) } return string(line) } cli.LoadConfigFile() authconfig, ok := cli.configFile.Configs[serverAddress] if !ok { authconfig = registry.AuthConfig{} } if username == "" { promptDefault("Username", authconfig.Username) username = readInput(cli.in, cli.out) username = strings.Trim(username, " ") if username == "" { username = authconfig.Username } } // Assume that a different username means they may not want to use // the password or email from the config file, so prompt them if username != authconfig.Username { if password == "" { oldState, err := term.SaveState(cli.inFd) if err != nil { return err } fmt.Fprintf(cli.out, "Password: ") term.DisableEcho(cli.inFd, oldState) password = readInput(cli.in, cli.out) fmt.Fprint(cli.out, "\n") term.RestoreTerminal(cli.inFd, oldState) if password == "" { return fmt.Errorf("Error : Password Required") } } if email == "" { promptDefault("Email", authconfig.Email) email = readInput(cli.in, cli.out) if email == "" { email = authconfig.Email } } } else { // However, if they don't override the username use the // password or email from the cmd line if specified. IOW, allow // then to change/override them. And if not specified, just // use what's in the config file if password == "" { password = authconfig.Password } if email == "" { email = authconfig.Email } } authconfig.Username = username authconfig.Password = password authconfig.Email = email authconfig.ServerAddress = serverAddress cli.configFile.Configs[serverAddress] = authconfig stream, statusCode, err := cli.call("POST", "/auth", cli.configFile.Configs[serverAddress], false) if statusCode == 401 { delete(cli.configFile.Configs, serverAddress) registry.SaveConfig(cli.configFile) return err } if err != nil { return err } var out2 engine.Env err = out2.Decode(stream) if err != nil { cli.configFile, _ = registry.LoadConfig(homedir.Get()) return err } registry.SaveConfig(cli.configFile) fmt.Fprintf(cli.out, "WARNING: login credentials saved in %s.\n", path.Join(homedir.Get(), registry.CONFIGFILE)) if out2.Get("Status") != "" { fmt.Fprintf(cli.out, "%s\n", out2.Get("Status")) } return nil } // log out from a Docker registry func (cli *DockerCli) CmdLogout(args ...string) error { cmd := cli.Subcmd("logout", "[SERVER]", "Log out from a Docker registry, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true) cmd.Require(flag.Max, 1) utils.ParseFlags(cmd, args, false) serverAddress := registry.IndexServerAddress() if len(cmd.Args()) > 0 { serverAddress = cmd.Arg(0) } cli.LoadConfigFile() if _, ok := cli.configFile.Configs[serverAddress]; !ok { fmt.Fprintf(cli.out, "Not logged in to %s\n", serverAddress) } else { fmt.Fprintf(cli.out, "Remove login credentials for %s\n", serverAddress) delete(cli.configFile.Configs, serverAddress) if err := registry.SaveConfig(cli.configFile); err != nil { return fmt.Errorf("Failed to save docker config: %v", err) } } return nil } // 'docker wait': block until a container stops func (cli *DockerCli) CmdWait(args ...string) error { cmd := cli.Subcmd("wait", "CONTAINER [CONTAINER...]", "Block until a container stops, then print its exit code.", true) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) var encounteredError error for _, name := range cmd.Args() { status, err := waitForExit(cli, name) if err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to wait one or more containers") } else { fmt.Fprintf(cli.out, "%d\n", status) } } return encounteredError } // 'docker version': show version information func (cli *DockerCli) CmdVersion(args ...string) error { cmd := cli.Subcmd("version", "", "Show the Docker version information.", true) cmd.Require(flag.Exact, 0) utils.ParseFlags(cmd, args, false) if dockerversion.VERSION != "" { fmt.Fprintf(cli.out, "Client version: %s\n", dockerversion.VERSION) } fmt.Fprintf(cli.out, "Client API version: %s\n", api.APIVERSION) fmt.Fprintf(cli.out, "Go version (client): %s\n", runtime.Version()) if dockerversion.GITCOMMIT != "" { fmt.Fprintf(cli.out, "Git commit (client): %s\n", dockerversion.GITCOMMIT) } fmt.Fprintf(cli.out, "OS/Arch (client): %s/%s\n", runtime.GOOS, runtime.GOARCH) body, _, err := readBody(cli.call("GET", "/version", nil, false)) if err != nil { return err } out := engine.NewOutput() remoteVersion, err := out.AddEnv() if err != nil { log.Errorf("Error reading remote version: %s", err) return err } if _, err := out.Write(body); err != nil { log.Errorf("Error reading remote version: %s", err) return err } out.Close() fmt.Fprintf(cli.out, "Server version: %s\n", remoteVersion.Get("Version")) if apiVersion := remoteVersion.Get("ApiVersion"); apiVersion != "" { fmt.Fprintf(cli.out, "Server API version: %s\n", apiVersion) } fmt.Fprintf(cli.out, "Go version (server): %s\n", remoteVersion.Get("GoVersion")) fmt.Fprintf(cli.out, "Git commit (server): %s\n", remoteVersion.Get("GitCommit")) fmt.Fprintf(cli.out, "OS/Arch (server): %s/%s\n", remoteVersion.Get("Os"), remoteVersion.Get("Arch")) return nil } // 'docker info': display system-wide information. func (cli *DockerCli) CmdInfo(args ...string) error { cmd := cli.Subcmd("info", "", "Display system-wide information", true) cmd.Require(flag.Exact, 0) utils.ParseFlags(cmd, args, false) body, _, err := readBody(cli.call("GET", "/info", nil, false)) if err != nil { return err } out := engine.NewOutput() remoteInfo, err := out.AddEnv() if err != nil { return err } if _, err := out.Write(body); err != nil { log.Errorf("Error reading remote info: %s", err) return err } out.Close() if remoteInfo.Exists("Containers") { fmt.Fprintf(cli.out, "Containers: %d\n", remoteInfo.GetInt("Containers")) } if remoteInfo.Exists("Images") { fmt.Fprintf(cli.out, "Images: %d\n", remoteInfo.GetInt("Images")) } if remoteInfo.Exists("Driver") { fmt.Fprintf(cli.out, "Storage Driver: %s\n", remoteInfo.Get("Driver")) } if remoteInfo.Exists("DriverStatus") { var driverStatus [][2]string if err := remoteInfo.GetJson("DriverStatus", &driverStatus); err != nil { return err } for _, pair := range driverStatus { fmt.Fprintf(cli.out, " %s: %s\n", pair[0], pair[1]) } } if remoteInfo.Exists("ExecutionDriver") { fmt.Fprintf(cli.out, "Execution Driver: %s\n", remoteInfo.Get("ExecutionDriver")) } if remoteInfo.Exists("KernelVersion") { fmt.Fprintf(cli.out, "Kernel Version: %s\n", remoteInfo.Get("KernelVersion")) } if remoteInfo.Exists("OperatingSystem") { fmt.Fprintf(cli.out, "Operating System: %s\n", remoteInfo.Get("OperatingSystem")) } if remoteInfo.Exists("NCPU") { fmt.Fprintf(cli.out, "CPUs: %d\n", remoteInfo.GetInt("NCPU")) } if remoteInfo.Exists("MemTotal") { fmt.Fprintf(cli.out, "Total Memory: %s\n", units.BytesSize(float64(remoteInfo.GetInt64("MemTotal")))) } if remoteInfo.Exists("Name") { fmt.Fprintf(cli.out, "Name: %s\n", remoteInfo.Get("Name")) } if remoteInfo.Exists("ID") { fmt.Fprintf(cli.out, "ID: %s\n", remoteInfo.Get("ID")) } if remoteInfo.GetBool("Debug") || os.Getenv("DEBUG") != "" { if remoteInfo.Exists("Debug") { fmt.Fprintf(cli.out, "Debug mode (server): %v\n", remoteInfo.GetBool("Debug")) } fmt.Fprintf(cli.out, "Debug mode (client): %v\n", os.Getenv("DEBUG") != "") if remoteInfo.Exists("NFd") { fmt.Fprintf(cli.out, "Fds: %d\n", remoteInfo.GetInt("NFd")) } if remoteInfo.Exists("NGoroutines") { fmt.Fprintf(cli.out, "Goroutines: %d\n", remoteInfo.GetInt("NGoroutines")) } if remoteInfo.Exists("SystemTime") { t, err := remoteInfo.GetTime("SystemTime") if err != nil { log.Errorf("Error reading system time: %v", err) } else { fmt.Fprintf(cli.out, "System Time: %s\n", t.Format(time.UnixDate)) } } if remoteInfo.Exists("NEventsListener") { fmt.Fprintf(cli.out, "EventsListeners: %d\n", remoteInfo.GetInt("NEventsListener")) } if initSha1 := remoteInfo.Get("InitSha1"); initSha1 != "" { fmt.Fprintf(cli.out, "Init SHA1: %s\n", initSha1) } if initPath := remoteInfo.Get("InitPath"); initPath != "" { fmt.Fprintf(cli.out, "Init Path: %s\n", initPath) } if root := remoteInfo.Get("DockerRootDir"); root != "" { fmt.Fprintf(cli.out, "Docker Root Dir: %s\n", root) } } if remoteInfo.Exists("HttpProxy") { fmt.Fprintf(cli.out, "Http Proxy: %s\n", remoteInfo.Get("HttpProxy")) } if remoteInfo.Exists("HttpsProxy") { fmt.Fprintf(cli.out, "Https Proxy: %s\n", remoteInfo.Get("HttpsProxy")) } if remoteInfo.Exists("NoProxy") { fmt.Fprintf(cli.out, "No Proxy: %s\n", remoteInfo.Get("NoProxy")) } if len(remoteInfo.GetList("IndexServerAddress")) != 0 { cli.LoadConfigFile() u := cli.configFile.Configs[remoteInfo.Get("IndexServerAddress")].Username if len(u) > 0 { fmt.Fprintf(cli.out, "Username: %v\n", u) fmt.Fprintf(cli.out, "Registry: %v\n", remoteInfo.GetList("IndexServerAddress")) } } if remoteInfo.Exists("MemoryLimit") && !remoteInfo.GetBool("MemoryLimit") { fmt.Fprintf(cli.err, "WARNING: No memory limit support\n") } if remoteInfo.Exists("SwapLimit") && !remoteInfo.GetBool("SwapLimit") { fmt.Fprintf(cli.err, "WARNING: No swap limit support\n") } if remoteInfo.Exists("IPv4Forwarding") && !remoteInfo.GetBool("IPv4Forwarding") { fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n") } if remoteInfo.Exists("Labels") { fmt.Fprintln(cli.out, "Labels:") for _, attribute := range remoteInfo.GetList("Labels") { fmt.Fprintf(cli.out, " %s\n", attribute) } } return nil } func (cli *DockerCli) CmdStop(args ...string) error { cmd := cli.Subcmd("stop", "CONTAINER [CONTAINER...]", "Stop a running container by sending SIGTERM and then SIGKILL after a\ngrace period", true) nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing it") cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) v := url.Values{} v.Set("t", strconv.Itoa(*nSeconds)) var encounteredError error for _, name := range cmd.Args() { _, _, err := readBody(cli.call("POST", "/containers/"+name+"/stop?"+v.Encode(), nil, false)) if err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to stop one or more containers") } else { fmt.Fprintf(cli.out, "%s\n", name) } } return encounteredError } func (cli *DockerCli) CmdRestart(args ...string) error { cmd := cli.Subcmd("restart", "CONTAINER [CONTAINER...]", "Restart a running container", true) nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing the container") cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) v := url.Values{} v.Set("t", strconv.Itoa(*nSeconds)) var encounteredError error for _, name := range cmd.Args() { _, _, err := readBody(cli.call("POST", "/containers/"+name+"/restart?"+v.Encode(), nil, false)) if err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to restart one or more containers") } else { fmt.Fprintf(cli.out, "%s\n", name) } } return encounteredError } func (cli *DockerCli) forwardAllSignals(cid string) chan os.Signal { sigc := make(chan os.Signal, 128) signal.CatchAll(sigc) go func() { for s := range sigc { if s == signal.SIGCHLD { continue } var sig string for sigStr, sigN := range signal.SignalMap { if sigN == s { sig = sigStr break } } if sig == "" { log.Errorf("Unsupported signal: %v. Discarding.", s) } if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/kill?signal=%s", cid, sig), nil, false)); err != nil { log.Debugf("Error sending signal: %s", err) } } }() return sigc } func (cli *DockerCli) CmdStart(args ...string) error { var ( cErr chan error tty bool cmd = cli.Subcmd("start", "CONTAINER [CONTAINER...]", "Start one or more stopped containers", true) attach = cmd.Bool([]string{"a", "-attach"}, false, "Attach STDOUT/STDERR and forward signals") openStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Attach container's STDIN") ) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) if *attach || *openStdin { if cmd.NArg() > 1 { return fmt.Errorf("You cannot start and attach multiple containers at once.") } stream, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/json", nil, false) if err != nil { return err } env := engine.Env{} if err := env.Decode(stream); err != nil { return err } config := env.GetSubEnv("Config") tty = config.GetBool("Tty") if !tty { sigc := cli.forwardAllSignals(cmd.Arg(0)) defer signal.StopCatch(sigc) } var in io.ReadCloser v := url.Values{} v.Set("stream", "1") if *openStdin && config.GetBool("OpenStdin") { v.Set("stdin", "1") in = cli.in } v.Set("stdout", "1") v.Set("stderr", "1") hijacked := make(chan io.Closer) // Block the return until the chan gets closed defer func() { log.Debugf("CmdStart() returned, defer waiting for hijack to finish.") if _, ok := <-hijacked; ok { log.Errorf("Hijack did not finish (chan still open)") } cli.in.Close() }() cErr = promise.Go(func() error { return cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), tty, in, cli.out, cli.err, hijacked, nil) }) // Acknowledge the hijack before starting select { case closer := <-hijacked: // Make sure that the hijack gets closed when returning (results // in closing the hijack chan and freeing server's goroutines) if closer != nil { defer closer.Close() } case err := <-cErr: if err != nil { return err } } } var encounteredError error for _, name := range cmd.Args() { _, _, err := readBody(cli.call("POST", "/containers/"+name+"/start", nil, false)) if err != nil { if !*attach && !*openStdin { // attach and openStdin is false means it could be starting multiple containers // when a container start failed, show the error message and start next fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to start one or more containers") } else { encounteredError = err } } else { if !*attach && !*openStdin { fmt.Fprintf(cli.out, "%s\n", name) } } } if encounteredError != nil { return encounteredError } if *openStdin || *attach { if tty && cli.isTerminalOut { if err := cli.monitorTtySize(cmd.Arg(0), false); err != nil { log.Errorf("Error monitoring TTY size: %s", err) } } if attchErr := <-cErr; attchErr != nil { return attchErr } _, status, err := getExitCode(cli, cmd.Arg(0)) if err != nil { return err } if status != 0 { return &utils.StatusError{StatusCode: status} } } return nil } func (cli *DockerCli) CmdUnpause(args ...string) error { cmd := cli.Subcmd("unpause", "CONTAINER [CONTAINER...]", "Unpause all processes within a container", true) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, false) var encounteredError error for _, name := range cmd.Args() { if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/unpause", name), nil, false)); err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to unpause container named %s", name) } else { fmt.Fprintf(cli.out, "%s\n", name) } } return encounteredError } func (cli *DockerCli) CmdPause(args ...string) error { cmd := cli.Subcmd("pause", "CONTAINER [CONTAINER...]", "Pause all processes within a container", true) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, false) var encounteredError error for _, name := range cmd.Args() { if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/pause", name), nil, false)); err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to pause container named %s", name) } else { fmt.Fprintf(cli.out, "%s\n", name) } } return encounteredError } func (cli *DockerCli) CmdRename(args ...string) error { cmd := cli.Subcmd("rename", "OLD_NAME NEW_NAME", "Rename a container", true) if err := cmd.Parse(args); err != nil { return nil } if cmd.NArg() != 2 { cmd.Usage() return nil } old_name := cmd.Arg(0) new_name := cmd.Arg(1) if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/rename?name=%s", old_name, new_name), nil, false)); err != nil { fmt.Fprintf(cli.err, "%s\n", err) return fmt.Errorf("Error: failed to rename container named %s", old_name) } return nil } func (cli *DockerCli) CmdInspect(args ...string) error { cmd := cli.Subcmd("inspect", "CONTAINER|IMAGE [CONTAINER|IMAGE...]", "Return low-level information on a container or image", true) tmplStr := cmd.String([]string{"f", "#format", "-format"}, "", "Format the output using the given go template") cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) var tmpl *template.Template if *tmplStr != "" { var err error if tmpl, err = template.New("").Funcs(funcMap).Parse(*tmplStr); err != nil { fmt.Fprintf(cli.err, "Template parsing error: %v\n", err) return &utils.StatusError{StatusCode: 64, Status: "Template parsing error: " + err.Error()} } } indented := new(bytes.Buffer) indented.WriteByte('[') status := 0 for _, name := range cmd.Args() { obj, _, err := readBody(cli.call("GET", "/containers/"+name+"/json", nil, false)) if err != nil { if strings.Contains(err.Error(), "Too many") { fmt.Fprintf(cli.err, "Error: %v", err) status = 1 continue } obj, _, err = readBody(cli.call("GET", "/images/"+name+"/json", nil, false)) if err != nil { if strings.Contains(err.Error(), "No such") { fmt.Fprintf(cli.err, "Error: No such image or container: %s\n", name) } else { fmt.Fprintf(cli.err, "%s", err) } status = 1 continue } } if tmpl == nil { if err = json.Indent(indented, obj, "", " "); err != nil { fmt.Fprintf(cli.err, "%s\n", err) status = 1 continue } } else { // Has template, will render var value interface{} if err := json.Unmarshal(obj, &value); err != nil { fmt.Fprintf(cli.err, "%s\n", err) status = 1 continue } if err := tmpl.Execute(cli.out, value); err != nil { return err } cli.out.Write([]byte{'\n'}) } indented.WriteString(",") } if indented.Len() > 1 { // Remove trailing ',' indented.Truncate(indented.Len() - 1) } indented.WriteString("]\n") if tmpl == nil { if _, err := io.Copy(cli.out, indented); err != nil { return err } } if status != 0 { return &utils.StatusError{StatusCode: status} } return nil } func (cli *DockerCli) CmdTop(args ...string) error { cmd := cli.Subcmd("top", "CONTAINER [ps OPTIONS]", "Display the running processes of a container", true) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) val := url.Values{} if cmd.NArg() > 1 { val.Set("ps_args", strings.Join(cmd.Args()[1:], " ")) } stream, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/top?"+val.Encode(), nil, false) if err != nil { return err } var procs engine.Env if err := procs.Decode(stream); err != nil { return err } w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0) fmt.Fprintln(w, strings.Join(procs.GetList("Titles"), "\t")) processes := [][]string{} if err := procs.GetJson("Processes", &processes); err != nil { return err } for _, proc := range processes { fmt.Fprintln(w, strings.Join(proc, "\t")) } w.Flush() return nil } func (cli *DockerCli) CmdPort(args ...string) error { cmd := cli.Subcmd("port", "CONTAINER [PRIVATE_PORT[/PROTO]]", "List port mappings for the CONTAINER, or lookup the public-facing port that\nis NAT-ed to the PRIVATE_PORT", true) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) stream, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/json", nil, false) if err != nil { return err } env := engine.Env{} if err := env.Decode(stream); err != nil { return err } ports := nat.PortMap{} if err := env.GetSubEnv("NetworkSettings").GetJson("Ports", &ports); err != nil { return err } if cmd.NArg() == 2 { var ( port = cmd.Arg(1) proto = "tcp" parts = strings.SplitN(port, "/", 2) ) if len(parts) == 2 && len(parts[1]) != 0 { port = parts[0] proto = parts[1] } natPort := port + "/" + proto if frontends, exists := ports[nat.Port(port+"/"+proto)]; exists && frontends != nil { for _, frontend := range frontends { fmt.Fprintf(cli.out, "%s:%s\n", frontend.HostIp, frontend.HostPort) } return nil } return fmt.Errorf("Error: No public port '%s' published for %s", natPort, cmd.Arg(0)) } for from, frontends := range ports { for _, frontend := range frontends { fmt.Fprintf(cli.out, "%s -> %s:%s\n", from, frontend.HostIp, frontend.HostPort) } } return nil } // 'docker rmi IMAGE' removes all images with the name IMAGE func (cli *DockerCli) CmdRmi(args ...string) error { var ( cmd = cli.Subcmd("rmi", "IMAGE [IMAGE...]", "Remove one or more images", true) force = cmd.Bool([]string{"f", "-force"}, false, "Force removal of the image") noprune = cmd.Bool([]string{"-no-prune"}, false, "Do not delete untagged parents") ) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) v := url.Values{} if *force { v.Set("force", "1") } if *noprune { v.Set("noprune", "1") } var encounteredError error for _, name := range cmd.Args() { body, _, err := readBody(cli.call("DELETE", "/images/"+name+"?"+v.Encode(), nil, false)) if err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to remove one or more images") } else { outs := engine.NewTable("Created", 0) if _, err := outs.ReadListFrom(body); err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to remove one or more images") continue } for _, out := range outs.Data { if out.Get("Deleted") != "" { fmt.Fprintf(cli.out, "Deleted: %s\n", out.Get("Deleted")) } else { fmt.Fprintf(cli.out, "Untagged: %s\n", out.Get("Untagged")) } } } } return encounteredError } func (cli *DockerCli) CmdHistory(args ...string) error { cmd := cli.Subcmd("history", "IMAGE", "Show the history of an image", true) quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) body, _, err := readBody(cli.call("GET", "/images/"+cmd.Arg(0)+"/history", nil, false)) if err != nil { return err } outs := engine.NewTable("Created", 0) if _, err := outs.ReadListFrom(body); err != nil { return err } w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0) if !*quiet { fmt.Fprintln(w, "IMAGE\tCREATED\tCREATED BY\tSIZE") } for _, out := range outs.Data { outID := out.Get("Id") if !*quiet { if *noTrunc { fmt.Fprintf(w, "%s\t", outID) } else { fmt.Fprintf(w, "%s\t", common.TruncateID(outID)) } fmt.Fprintf(w, "%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0)))) if *noTrunc { fmt.Fprintf(w, "%s\t", out.Get("CreatedBy")) } else { fmt.Fprintf(w, "%s\t", utils.Trunc(out.Get("CreatedBy"), 45)) } fmt.Fprintf(w, "%s\n", units.HumanSize(float64(out.GetInt64("Size")))) } else { if *noTrunc { fmt.Fprintln(w, outID) } else { fmt.Fprintln(w, common.TruncateID(outID)) } } } w.Flush() return nil } func (cli *DockerCli) CmdRm(args ...string) error { cmd := cli.Subcmd("rm", "CONTAINER [CONTAINER...]", "Remove one or more containers", true) v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container") link := cmd.Bool([]string{"l", "#link", "-link"}, false, "Remove the specified link") force := cmd.Bool([]string{"f", "-force"}, false, "Force the removal of a running container (uses SIGKILL)") cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) val := url.Values{} if *v { val.Set("v", "1") } if *link { val.Set("link", "1") } if *force { val.Set("force", "1") } var encounteredError error for _, name := range cmd.Args() { _, _, err := readBody(cli.call("DELETE", "/containers/"+name+"?"+val.Encode(), nil, false)) if err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to remove one or more containers") } else { fmt.Fprintf(cli.out, "%s\n", name) } } return encounteredError } // 'docker kill NAME' kills a running container func (cli *DockerCli) CmdKill(args ...string) error { cmd := cli.Subcmd("kill", "CONTAINER [CONTAINER...]", "Kill a running container using SIGKILL or a specified signal", true) signal := cmd.String([]string{"s", "-signal"}, "KILL", "Signal to send to the container") cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) var encounteredError error for _, name := range cmd.Args() { if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/kill?signal=%s", name, *signal), nil, false)); err != nil { fmt.Fprintf(cli.err, "%s\n", err) encounteredError = fmt.Errorf("Error: failed to kill one or more containers") } else { fmt.Fprintf(cli.out, "%s\n", name) } } return encounteredError } func (cli *DockerCli) CmdImport(args ...string) error { cmd := cli.Subcmd("import", "URL|- [REPOSITORY[:TAG]]", "Create an empty filesystem image and import the contents of the\ntarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then\noptionally tag it.", true) flChanges := opts.NewListOpts(nil) cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image") cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) var ( v = url.Values{} src = cmd.Arg(0) repository = cmd.Arg(1) ) v.Set("fromSrc", src) v.Set("repo", repository) for _, change := range flChanges.GetAll() { v.Add("changes", change) } if cmd.NArg() == 3 { fmt.Fprintf(cli.err, "[DEPRECATED] The format 'URL|- [REPOSITORY [TAG]]' has been deprecated. Please use URL|- [REPOSITORY[:TAG]]\n") v.Set("tag", cmd.Arg(2)) } if repository != "" { //Check if the given image name can be resolved repo, _ := parsers.ParseRepositoryTag(repository) if err := registry.ValidateRepositoryName(repo); err != nil { return err } } var in io.Reader if src == "-" { in = cli.in } return cli.stream("POST", "/images/create?"+v.Encode(), in, cli.out, nil) } func (cli *DockerCli) CmdPush(args ...string) error { cmd := cli.Subcmd("push", "NAME[:TAG]", "Push an image or a repository to the registry", true) cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) name := cmd.Arg(0) cli.LoadConfigFile() remote, tag := parsers.ParseRepositoryTag(name) // Resolve the Repository name from fqn to RepositoryInfo repoInfo, err := registry.ParseRepositoryInfo(remote) if err != nil { return err } // Resolve the Auth config relevant for this server authConfig := cli.configFile.ResolveAuthConfig(repoInfo.Index) // If we're not using a custom registry, we know the restrictions // applied to repository names and can warn the user in advance. // Custom repositories can have different rules, and we must also // allow pushing by image ID. if repoInfo.Official { username := authConfig.Username if username == "" { username = "<user>" } return fmt.Errorf("You cannot push a \"root\" repository. Please rename your repository to <user>/<repo> (ex: %s/%s)", username, repoInfo.LocalName) } v := url.Values{} v.Set("tag", tag) push := func(authConfig registry.AuthConfig) error { buf, err := json.Marshal(authConfig) if err != nil { return err } registryAuthHeader := []string{ base64.URLEncoding.EncodeToString(buf), } return cli.stream("POST", "/images/"+remote+"/push?"+v.Encode(), nil, cli.out, map[string][]string{ "X-Registry-Auth": registryAuthHeader, }) } if err := push(authConfig); err != nil { if strings.Contains(err.Error(), "Status 401") { fmt.Fprintln(cli.out, "\nPlease login prior to push:") if err := cli.CmdLogin(repoInfo.Index.GetAuthConfigKey()); err != nil { return err } authConfig := cli.configFile.ResolveAuthConfig(repoInfo.Index) return push(authConfig) } return err } return nil } func (cli *DockerCli) CmdPull(args ...string) error { cmd := cli.Subcmd("pull", "NAME[:TAG|@DIGEST]", "Pull an image or a repository from the registry", true) allTags := cmd.Bool([]string{"a", "-all-tags"}, false, "Download all tagged images in the repository") cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) var ( v = url.Values{} remote = cmd.Arg(0) newRemote = remote ) taglessRemote, tag := parsers.ParseRepositoryTag(remote) if tag == "" && !*allTags { newRemote = utils.ImageReference(taglessRemote, graph.DEFAULTTAG) } if tag != "" && *allTags { return fmt.Errorf("tag can't be used with --all-tags/-a") } v.Set("fromImage", newRemote) // Resolve the Repository name from fqn to RepositoryInfo repoInfo, err := registry.ParseRepositoryInfo(taglessRemote) if err != nil { return err } cli.LoadConfigFile() // Resolve the Auth config relevant for this server authConfig := cli.configFile.ResolveAuthConfig(repoInfo.Index) pull := func(authConfig registry.AuthConfig) error { buf, err := json.Marshal(authConfig) if err != nil { return err } registryAuthHeader := []string{ base64.URLEncoding.EncodeToString(buf), } return cli.stream("POST", "/images/create?"+v.Encode(), nil, cli.out, map[string][]string{ "X-Registry-Auth": registryAuthHeader, }) } if err := pull(authConfig); err != nil { if strings.Contains(err.Error(), "Status 401") { fmt.Fprintln(cli.out, "\nPlease login prior to pull:") if err := cli.CmdLogin(repoInfo.Index.GetAuthConfigKey()); err != nil { return err } authConfig := cli.configFile.ResolveAuthConfig(repoInfo.Index) return pull(authConfig) } return err } return nil } func (cli *DockerCli) CmdImages(args ...string) error { cmd := cli.Subcmd("images", "[REPOSITORY]", "List images", true) quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs") all := cmd.Bool([]string{"a", "-all"}, false, "Show all images (default hides intermediate images)") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") showDigests := cmd.Bool([]string{"-digests"}, false, "Show digests") // FIXME: --viz and --tree are deprecated. Remove them in a future version. flViz := cmd.Bool([]string{"#v", "#viz", "#-viz"}, false, "Output graph in graphviz format") flTree := cmd.Bool([]string{"#t", "#tree", "#-tree"}, false, "Output graph in tree format") flFilter := opts.NewListOpts(nil) cmd.Var(&flFilter, []string{"f", "-filter"}, "Filter output based on conditions provided") cmd.Require(flag.Max, 1) utils.ParseFlags(cmd, args, true) // Consolidate all filter flags, and sanity check them early. // They'll get process in the daemon/server. imageFilterArgs := filters.Args{} for _, f := range flFilter.GetAll() { var err error imageFilterArgs, err = filters.ParseFlag(f, imageFilterArgs) if err != nil { return err } } matchName := cmd.Arg(0) // FIXME: --viz and --tree are deprecated. Remove them in a future version. if *flViz || *flTree { v := url.Values{ "all": []string{"1"}, } if len(imageFilterArgs) > 0 { filterJson, err := filters.ToParam(imageFilterArgs) if err != nil { return err } v.Set("filters", filterJson) } body, _, err := readBody(cli.call("GET", "/images/json?"+v.Encode(), nil, false)) if err != nil { return err } outs := engine.NewTable("Created", 0) if _, err := outs.ReadListFrom(body); err != nil { return err } var ( printNode func(cli *DockerCli, noTrunc bool, image *engine.Env, prefix string) startImage *engine.Env roots = engine.NewTable("Created", outs.Len()) byParent = make(map[string]*engine.Table) ) for _, image := range outs.Data { if image.Get("ParentId") == "" { roots.Add(image) } else { if children, exists := byParent[image.Get("ParentId")]; exists { children.Add(image) } else { byParent[image.Get("ParentId")] = engine.NewTable("Created", 1) byParent[image.Get("ParentId")].Add(image) } } if matchName != "" { if matchName == image.Get("Id") || matchName == common.TruncateID(image.Get("Id")) { startImage = image } for _, repotag := range image.GetList("RepoTags") { if repotag == matchName { startImage = image } } } } if *flViz { fmt.Fprintf(cli.out, "digraph docker {\n") printNode = (*DockerCli).printVizNode } else { printNode = (*DockerCli).printTreeNode } if startImage != nil { root := engine.NewTable("Created", 1) root.Add(startImage) cli.WalkTree(*noTrunc, root, byParent, "", printNode) } else if matchName == "" { cli.WalkTree(*noTrunc, roots, byParent, "", printNode) } if *flViz { fmt.Fprintf(cli.out, " base [style=invisible]\n}\n") } } else { v := url.Values{} if len(imageFilterArgs) > 0 { filterJson, err := filters.ToParam(imageFilterArgs) if err != nil { return err } v.Set("filters", filterJson) } if cmd.NArg() == 1 { // FIXME rename this parameter, to not be confused with the filters flag v.Set("filter", matchName) } if *all { v.Set("all", "1") } body, _, err := readBody(cli.call("GET", "/images/json?"+v.Encode(), nil, false)) if err != nil { return err } outs := engine.NewTable("Created", 0) if _, err := outs.ReadListFrom(body); err != nil { return err } w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0) if !*quiet { if *showDigests { fmt.Fprintln(w, "REPOSITORY\tTAG\tDIGEST\tIMAGE ID\tCREATED\tVIRTUAL SIZE") } else { fmt.Fprintln(w, "REPOSITORY\tTAG\tIMAGE ID\tCREATED\tVIRTUAL SIZE") } } for _, out := range outs.Data { outID := out.Get("Id") if !*noTrunc { outID = common.TruncateID(outID) } repoTags := out.GetList("RepoTags") repoDigests := out.GetList("RepoDigests") if len(repoTags) == 1 && repoTags[0] == "<none>:<none>" && len(repoDigests) == 1 && repoDigests[0] == "<none>@<none>" { // dangling image - clear out either repoTags or repoDigsts so we only show it once below repoDigests = []string{} } // combine the tags and digests lists tagsAndDigests := append(repoTags, repoDigests...) for _, repoAndRef := range tagsAndDigests { repo, ref := parsers.ParseRepositoryTag(repoAndRef) // default tag and digest to none - if there's a value, it'll be set below tag := "<none>" digest := "<none>" if utils.DigestReference(ref) { digest = ref } else { tag = ref } if !*quiet { if *showDigests { fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", repo, tag, digest, outID, units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0))), units.HumanSize(float64(out.GetInt64("VirtualSize")))) } else { fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\n", repo, tag, outID, units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0))), units.HumanSize(float64(out.GetInt64("VirtualSize")))) } } else { fmt.Fprintln(w, outID) } } } if !*quiet { w.Flush() } } return nil } // FIXME: --viz and --tree are deprecated. Remove them in a future version. func (cli *DockerCli) WalkTree(noTrunc bool, images *engine.Table, byParent map[string]*engine.Table, prefix string, printNode func(cli *DockerCli, noTrunc bool, image *engine.Env, prefix string)) { length := images.Len() if length > 1 { for index, image := range images.Data { if index+1 == length { printNode(cli, noTrunc, image, prefix+"└─") if subimages, exists := byParent[image.Get("Id")]; exists { cli.WalkTree(noTrunc, subimages, byParent, prefix+" ", printNode) } } else { printNode(cli, noTrunc, image, prefix+"\u251C─") if subimages, exists := byParent[image.Get("Id")]; exists { cli.WalkTree(noTrunc, subimages, byParent, prefix+"\u2502 ", printNode) } } } } else { for _, image := range images.Data { printNode(cli, noTrunc, image, prefix+"└─") if subimages, exists := byParent[image.Get("Id")]; exists { cli.WalkTree(noTrunc, subimages, byParent, prefix+" ", printNode) } } } } // FIXME: --viz and --tree are deprecated. Remove them in a future version. func (cli *DockerCli) printVizNode(noTrunc bool, image *engine.Env, prefix string) { var ( imageID string parentID string ) if noTrunc { imageID = image.Get("Id") parentID = image.Get("ParentId") } else { imageID = common.TruncateID(image.Get("Id")) parentID = common.TruncateID(image.Get("ParentId")) } if parentID == "" { fmt.Fprintf(cli.out, " base -> \"%s\" [style=invis]\n", imageID) } else { fmt.Fprintf(cli.out, " \"%s\" -> \"%s\"\n", parentID, imageID) } if image.GetList("RepoTags")[0] != "<none>:<none>" { fmt.Fprintf(cli.out, " \"%s\" [label=\"%s\\n%s\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n", imageID, imageID, strings.Join(image.GetList("RepoTags"), "\\n")) } } // FIXME: --viz and --tree are deprecated. Remove them in a future version. func (cli *DockerCli) printTreeNode(noTrunc bool, image *engine.Env, prefix string) { var imageID string if noTrunc { imageID = image.Get("Id") } else { imageID = common.TruncateID(image.Get("Id")) } fmt.Fprintf(cli.out, "%s%s Virtual Size: %s", prefix, imageID, units.HumanSize(float64(image.GetInt64("VirtualSize")))) if image.GetList("RepoTags")[0] != "<none>:<none>" { fmt.Fprintf(cli.out, " Tags: %s\n", strings.Join(image.GetList("RepoTags"), ", ")) } else { fmt.Fprint(cli.out, "\n") } } func (cli *DockerCli) CmdPs(args ...string) error { var ( err error psFilterArgs = filters.Args{} v = url.Values{} cmd = cli.Subcmd("ps", "", "List containers", true) quiet = cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs") size = cmd.Bool([]string{"s", "-size"}, false, "Display total file sizes") all = cmd.Bool([]string{"a", "-all"}, false, "Show all containers (default shows just running)") noTrunc = cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") nLatest = cmd.Bool([]string{"l", "-latest"}, false, "Show the latest created container, include non-running") since = cmd.String([]string{"#sinceId", "#-since-id", "-since"}, "", "Show created since Id or Name, include non-running") before = cmd.String([]string{"#beforeId", "#-before-id", "-before"}, "", "Show only container created before Id or Name") last = cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running") flFilter = opts.NewListOpts(nil) ) cmd.Require(flag.Exact, 0) cmd.Var(&flFilter, []string{"f", "-filter"}, "Filter output based on conditions provided") utils.ParseFlags(cmd, args, true) if *last == -1 && *nLatest { *last = 1 } if *all { v.Set("all", "1") } if *last != -1 { v.Set("limit", strconv.Itoa(*last)) } if *since != "" { v.Set("since", *since) } if *before != "" { v.Set("before", *before) } if *size { v.Set("size", "1") } // Consolidate all filter flags, and sanity check them. // They'll get processed in the daemon/server. for _, f := range flFilter.GetAll() { if psFilterArgs, err = filters.ParseFlag(f, psFilterArgs); err != nil { return err } } if len(psFilterArgs) > 0 { filterJson, err := filters.ToParam(psFilterArgs) if err != nil { return err } v.Set("filters", filterJson) } body, _, err := readBody(cli.call("GET", "/containers/json?"+v.Encode(), nil, false)) if err != nil { return err } outs := engine.NewTable("Created", 0) if _, err := outs.ReadListFrom(body); err != nil { return err } w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0) if !*quiet { fmt.Fprint(w, "CONTAINER ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tPORTS\tNAMES") if *size { fmt.Fprintln(w, "\tSIZE") } else { fmt.Fprint(w, "\n") } } stripNamePrefix := func(ss []string) []string { for i, s := range ss { ss[i] = s[1:] } return ss } for _, out := range outs.Data { outID := out.Get("Id") if !*noTrunc { outID = common.TruncateID(outID) } if *quiet { fmt.Fprintln(w, outID) continue } var ( outNames = stripNamePrefix(out.GetList("Names")) outCommand = strconv.Quote(out.Get("Command")) ports = engine.NewTable("", 0) ) if !*noTrunc { outCommand = utils.Trunc(outCommand, 20) // only display the default name for the container with notrunc is passed for _, name := range outNames { if len(strings.Split(name, "/")) == 1 { outNames = []string{name} break } } } ports.ReadListFrom([]byte(out.Get("Ports"))) image := out.Get("Image") if image == "" { image = "<no image>" } fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t%s\t", outID, image, outCommand, units.HumanDuration(time.Now().UTC().Sub(time.Unix(out.GetInt64("Created"), 0))), out.Get("Status"), api.DisplayablePorts(ports), strings.Join(outNames, ",")) if *size { if out.GetInt("SizeRootFs") > 0 { fmt.Fprintf(w, "%s (virtual %s)\n", units.HumanSize(float64(out.GetInt64("SizeRw"))), units.HumanSize(float64(out.GetInt64("SizeRootFs")))) } else { fmt.Fprintf(w, "%s\n", units.HumanSize(float64(out.GetInt64("SizeRw")))) } continue } fmt.Fprint(w, "\n") } if !*quiet { w.Flush() } return nil } func (cli *DockerCli) CmdCommit(args ...string) error { cmd := cli.Subcmd("commit", "CONTAINER [REPOSITORY[:TAG]]", "Create a new image from a container's changes", true) flPause := cmd.Bool([]string{"p", "-pause"}, true, "Pause container during commit") flComment := cmd.String([]string{"m", "-message"}, "", "Commit message") flAuthor := cmd.String([]string{"a", "#author", "-author"}, "", "Author (e.g., \"John Hannibal Smith <hannibal@a-team.com>\")") flChanges := opts.NewListOpts(nil) cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image") // FIXME: --run is deprecated, it will be replaced with inline Dockerfile commands. flConfig := cmd.String([]string{"#run", "#-run"}, "", "This option is deprecated and will be removed in a future version in favor of inline Dockerfile-compatible commands") cmd.Require(flag.Max, 2) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) var ( name = cmd.Arg(0) repository, tag = parsers.ParseRepositoryTag(cmd.Arg(1)) ) //Check if the given image name can be resolved if repository != "" { if err := registry.ValidateRepositoryName(repository); err != nil { return err } } v := url.Values{} v.Set("container", name) v.Set("repo", repository) v.Set("tag", tag) v.Set("comment", *flComment) v.Set("author", *flAuthor) for _, change := range flChanges.GetAll() { v.Add("changes", change) } if *flPause != true { v.Set("pause", "0") } var ( config *runconfig.Config env engine.Env ) if *flConfig != "" { config = &runconfig.Config{} if err := json.Unmarshal([]byte(*flConfig), config); err != nil { return err } } stream, _, err := cli.call("POST", "/commit?"+v.Encode(), config, false) if err != nil { return err } if err := env.Decode(stream); err != nil { return err } fmt.Fprintf(cli.out, "%s\n", env.Get("Id")) return nil } func (cli *DockerCli) CmdEvents(args ...string) error { cmd := cli.Subcmd("events", "", "Get real time events from the server", true) since := cmd.String([]string{"#since", "-since"}, "", "Show all events created since timestamp") until := cmd.String([]string{"-until"}, "", "Stream events until this timestamp") flFilter := opts.NewListOpts(nil) cmd.Var(&flFilter, []string{"f", "-filter"}, "Filter output based on conditions provided") cmd.Require(flag.Exact, 0) utils.ParseFlags(cmd, args, true) var ( v = url.Values{} loc = time.FixedZone(time.Now().Zone()) eventFilterArgs = filters.Args{} ) // Consolidate all filter flags, and sanity check them early. // They'll get process in the daemon/server. for _, f := range flFilter.GetAll() { var err error eventFilterArgs, err = filters.ParseFlag(f, eventFilterArgs) if err != nil { return err } } var setTime = func(key, value string) { format := timeutils.RFC3339NanoFixed if len(value) < len(format) { format = format[:len(value)] } if t, err := time.ParseInLocation(format, value, loc); err == nil { v.Set(key, strconv.FormatInt(t.Unix(), 10)) } else { v.Set(key, value) } } if *since != "" { setTime("since", *since) } if *until != "" { setTime("until", *until) } if len(eventFilterArgs) > 0 { filterJson, err := filters.ToParam(eventFilterArgs) if err != nil { return err } v.Set("filters", filterJson) } if err := cli.stream("GET", "/events?"+v.Encode(), nil, cli.out, nil); err != nil { return err } return nil } func (cli *DockerCli) CmdExport(args ...string) error { cmd := cli.Subcmd("export", "CONTAINER", "Export a filesystem as a tar archive (streamed to STDOUT by default)", true) outfile := cmd.String([]string{"o", "-output"}, "", "Write to a file, instead of STDOUT") cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) var ( output io.Writer = cli.out err error ) if *outfile != "" { output, err = os.Create(*outfile) if err != nil { return err } } else if cli.isTerminalOut { return errors.New("Cowardly refusing to save to a terminal. Use the -o flag or redirect.") } if len(cmd.Args()) == 1 { image := cmd.Arg(0) if err := cli.stream("GET", "/containers/"+image+"/export", nil, output, nil); err != nil { return err } } else { v := url.Values{} for _, arg := range cmd.Args() { v.Add("names", arg) } if err := cli.stream("GET", "/containers/get?"+v.Encode(), nil, output, nil); err != nil { return err } } return nil } func (cli *DockerCli) CmdDiff(args ...string) error { cmd := cli.Subcmd("diff", "CONTAINER", "Inspect changes on a container's filesystem", true) cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) body, _, err := readBody(cli.call("GET", "/containers/"+cmd.Arg(0)+"/changes", nil, false)) if err != nil { return err } outs := engine.NewTable("", 0) if _, err := outs.ReadListFrom(body); err != nil { return err } for _, change := range outs.Data { var kind string switch change.GetInt("Kind") { case archive.ChangeModify: kind = "C" case archive.ChangeAdd: kind = "A" case archive.ChangeDelete: kind = "D" } fmt.Fprintf(cli.out, "%s %s\n", kind, change.Get("Path")) } return nil } func (cli *DockerCli) CmdLogs(args ...string) error { var ( cmd = cli.Subcmd("logs", "CONTAINER", "Fetch the logs of a container", true) follow = cmd.Bool([]string{"f", "-follow"}, false, "Follow log output") times = cmd.Bool([]string{"t", "-timestamps"}, false, "Show timestamps") tail = cmd.String([]string{"-tail"}, "all", "Number of lines to show from the end of the logs") ) cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) name := cmd.Arg(0) stream, _, err := cli.call("GET", "/containers/"+name+"/json", nil, false) if err != nil { return err } env := engine.Env{} if err := env.Decode(stream); err != nil { return err } if env.GetSubEnv("HostConfig").GetSubEnv("LogConfig").Get("Type") != "json-file" { return fmt.Errorf("\"logs\" command is supported only for \"json-file\" logging driver") } v := url.Values{} v.Set("stdout", "1") v.Set("stderr", "1") if *times { v.Set("timestamps", "1") } if *follow { v.Set("follow", "1") } v.Set("tail", *tail) return cli.streamHelper("GET", "/containers/"+name+"/logs?"+v.Encode(), env.GetSubEnv("Config").GetBool("Tty"), nil, cli.out, cli.err, nil) } func (cli *DockerCli) CmdAttach(args ...string) error { var ( cmd = cli.Subcmd("attach", "CONTAINER", "Attach to a running container", true) noStdin = cmd.Bool([]string{"#nostdin", "-no-stdin"}, false, "Do not attach STDIN") proxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy all received signals to the process") ) cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) name := cmd.Arg(0) stream, _, err := cli.call("GET", "/containers/"+name+"/json", nil, false) if err != nil { return err } env := engine.Env{} if err := env.Decode(stream); err != nil { return err } if !env.GetSubEnv("State").GetBool("Running") { return fmt.Errorf("You cannot attach to a stopped container, start it first") } var ( config = env.GetSubEnv("Config") tty = config.GetBool("Tty") ) if err := cli.CheckTtyInput(!*noStdin, tty); err != nil { return err } if tty && cli.isTerminalOut { if err := cli.monitorTtySize(cmd.Arg(0), false); err != nil { log.Debugf("Error monitoring TTY size: %s", err) } } var in io.ReadCloser v := url.Values{} v.Set("stream", "1") if !*noStdin && config.GetBool("OpenStdin") { v.Set("stdin", "1") in = cli.in } v.Set("stdout", "1") v.Set("stderr", "1") if *proxy && !tty { sigc := cli.forwardAllSignals(cmd.Arg(0)) defer signal.StopCatch(sigc) } if err := cli.hijack("POST", "/containers/"+cmd.Arg(0)+"/attach?"+v.Encode(), tty, in, cli.out, cli.err, nil, nil); err != nil { return err } _, status, err := getExitCode(cli, cmd.Arg(0)) if err != nil { return err } if status != 0 { return &utils.StatusError{StatusCode: status} } return nil } func (cli *DockerCli) CmdSearch(args ...string) error { cmd := cli.Subcmd("search", "TERM", "Search the Docker Hub for images", true) noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") trusted := cmd.Bool([]string{"#t", "#trusted", "#-trusted"}, false, "Only show trusted builds") automated := cmd.Bool([]string{"-automated"}, false, "Only show automated builds") stars := cmd.Int([]string{"s", "#stars", "-stars"}, 0, "Only displays with at least x stars") cmd.Require(flag.Exact, 1) utils.ParseFlags(cmd, args, true) v := url.Values{} v.Set("term", cmd.Arg(0)) body, _, err := readBody(cli.call("GET", "/images/search?"+v.Encode(), nil, true)) if err != nil { return err } outs := engine.NewTable("star_count", 0) if _, err := outs.ReadListFrom(body); err != nil { return err } w := tabwriter.NewWriter(cli.out, 10, 1, 3, ' ', 0) fmt.Fprintf(w, "NAME\tDESCRIPTION\tSTARS\tOFFICIAL\tAUTOMATED\n") for _, out := range outs.Data { if ((*automated || *trusted) && (!out.GetBool("is_trusted") && !out.GetBool("is_automated"))) || (*stars > out.GetInt("star_count")) { continue } desc := strings.Replace(out.Get("description"), "\n", " ", -1) desc = strings.Replace(desc, "\r", " ", -1) if !*noTrunc && len(desc) > 45 { desc = utils.Trunc(desc, 42) + "..." } fmt.Fprintf(w, "%s\t%s\t%d\t", out.Get("name"), desc, out.GetInt("star_count")) if out.GetBool("is_official") { fmt.Fprint(w, "[OK]") } fmt.Fprint(w, "\t") if out.GetBool("is_automated") || out.GetBool("is_trusted") { fmt.Fprint(w, "[OK]") } fmt.Fprint(w, "\n") } w.Flush() return nil } // Ports type - Used to parse multiple -p flags type ports []int func (cli *DockerCli) CmdTag(args ...string) error { cmd := cli.Subcmd("tag", "IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]", "Tag an image into a repository", true) force := cmd.Bool([]string{"f", "#force", "-force"}, false, "Force") cmd.Require(flag.Exact, 2) utils.ParseFlags(cmd, args, true) var ( repository, tag = parsers.ParseRepositoryTag(cmd.Arg(1)) v = url.Values{} ) //Check if the given image name can be resolved if err := registry.ValidateRepositoryName(repository); err != nil { return err } v.Set("repo", repository) v.Set("tag", tag) if *force { v.Set("force", "1") } if _, _, err := readBody(cli.call("POST", "/images/"+cmd.Arg(0)+"/tag?"+v.Encode(), nil, false)); err != nil { return err } return nil } func (cli *DockerCli) pullImage(image string) error { return cli.pullImageCustomOut(image, cli.out) } func (cli *DockerCli) pullImageCustomOut(image string, out io.Writer) error { v := url.Values{} repos, tag := parsers.ParseRepositoryTag(image) // pull only the image tagged 'latest' if no tag was specified if tag == "" { tag = graph.DEFAULTTAG } v.Set("fromImage", repos) v.Set("tag", tag) // Resolve the Repository name from fqn to RepositoryInfo repoInfo, err := registry.ParseRepositoryInfo(repos) if err != nil { return err } // Load the auth config file, to be able to pull the image cli.LoadConfigFile() // Resolve the Auth config relevant for this server authConfig := cli.configFile.ResolveAuthConfig(repoInfo.Index) buf, err := json.Marshal(authConfig) if err != nil { return err } registryAuthHeader := []string{ base64.URLEncoding.EncodeToString(buf), } if err = cli.stream("POST", "/images/create?"+v.Encode(), nil, out, map[string][]string{"X-Registry-Auth": registryAuthHeader}); err != nil { return err } return nil } type cidFile struct { path string file *os.File written bool } func newCIDFile(path string) (*cidFile, error) { if _, err := os.Stat(path); err == nil { return nil, fmt.Errorf("Container ID file found, make sure the other container isn't running or delete %s", path) } f, err := os.Create(path) if err != nil { return nil, fmt.Errorf("Failed to create the container ID file: %s", err) } return &cidFile{path: path, file: f}, nil } func (cid *cidFile) Close() error { cid.file.Close() if !cid.written { if err := os.Remove(cid.path); err != nil { return fmt.Errorf("failed to remove the CID file '%s': %s \n", cid.path, err) } } return nil } func (cid *cidFile) Write(id string) error { if _, err := cid.file.Write([]byte(id)); err != nil { return fmt.Errorf("Failed to write the container ID to the file: %s", err) } cid.written = true return nil } func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runconfig.HostConfig, cidfile, name string) (*types.ContainerCreateResponse, error) { containerValues := url.Values{} if name != "" { containerValues.Set("name", name) } mergedConfig := runconfig.MergeConfigs(config, hostConfig) var containerIDFile *cidFile if cidfile != "" { var err error if containerIDFile, err = newCIDFile(cidfile); err != nil { return nil, err } defer containerIDFile.Close() } //create the container stream, statusCode, err := cli.call("POST", "/containers/create?"+containerValues.Encode(), mergedConfig, false) //if image not found try to pull it if statusCode == 404 { repo, tag := parsers.ParseRepositoryTag(config.Image) if tag == "" { tag = graph.DEFAULTTAG } fmt.Fprintf(cli.err, "Unable to find image '%s' locally\n", utils.ImageReference(repo, tag)) // we don't want to write to stdout anything apart from container.ID if err = cli.pullImageCustomOut(config.Image, cli.err); err != nil { return nil, err } // Retry if stream, _, err = cli.call("POST", "/containers/create?"+containerValues.Encode(), mergedConfig, false); err != nil { return nil, err } } else if err != nil { return nil, err } var response types.ContainerCreateResponse if err := json.NewDecoder(stream).Decode(&response); err != nil { return nil, err } for _, warning := range response.Warnings { fmt.Fprintf(cli.err, "WARNING: %s\n", warning) } if containerIDFile != nil { if err = containerIDFile.Write(response.ID); err != nil { return nil, err } } return &response, nil } func (cli *DockerCli) CmdCreate(args ...string) error { cmd := cli.Subcmd("create", "IMAGE [COMMAND] [ARG...]", "Create a new container", true) // These are flags not stored in Config/HostConfig var ( flName = cmd.String([]string{"-name"}, "", "Assign a name to the container") ) config, hostConfig, cmd, err := runconfig.Parse(cmd, args) if err != nil { utils.ReportError(cmd, err.Error(), true) } if config.Image == "" { cmd.Usage() return nil } response, err := cli.createContainer(config, hostConfig, hostConfig.ContainerIDFile, *flName) if err != nil { return err } fmt.Fprintf(cli.out, "%s\n", response.ID) return nil } func (cli *DockerCli) CmdRun(args ...string) error { // FIXME: just use runconfig.Parse already cmd := cli.Subcmd("run", "IMAGE [COMMAND] [ARG...]", "Run a command in a new container", true) // These are flags not stored in Config/HostConfig var ( flAutoRemove = cmd.Bool([]string{"#rm", "-rm"}, false, "Automatically remove the container when it exits") flDetach = cmd.Bool([]string{"d", "-detach"}, false, "Run container in background and print container ID") flSigProxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy received signals to the process") flName = cmd.String([]string{"#name", "-name"}, "", "Assign a name to the container") flAttach *opts.ListOpts ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d") ErrConflictRestartPolicyAndAutoRemove = fmt.Errorf("Conflicting options: --restart and --rm") ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d") ) config, hostConfig, cmd, err := runconfig.Parse(cmd, args) // just in case the Parse does not exit if err != nil { utils.ReportError(cmd, err.Error(), true) } if len(hostConfig.Dns) > 0 { // check the DNS settings passed via --dns against // localhost regexp to warn if they are trying to // set a DNS to a localhost address for _, dnsIP := range hostConfig.Dns { if resolvconf.IsLocalhost(dnsIP) { fmt.Fprintf(cli.err, "WARNING: Localhost DNS setting (--dns=%s) may fail in containers.\n", dnsIP) break } } } if config.Image == "" { cmd.Usage() return nil } if !*flDetach { if err := cli.CheckTtyInput(config.AttachStdin, config.Tty); err != nil { return err } } else { if fl := cmd.Lookup("-attach"); fl != nil { flAttach = fl.Value.(*opts.ListOpts) if flAttach.Len() != 0 { return ErrConflictAttachDetach } } if *flAutoRemove { return ErrConflictDetachAutoRemove } config.AttachStdin = false config.AttachStdout = false config.AttachStderr = false config.StdinOnce = false } // Disable flSigProxy when in TTY mode sigProxy := *flSigProxy if config.Tty { sigProxy = false } createResponse, err := cli.createContainer(config, hostConfig, hostConfig.ContainerIDFile, *flName) if err != nil { return err } if sigProxy { sigc := cli.forwardAllSignals(createResponse.ID) defer signal.StopCatch(sigc) } var ( waitDisplayId chan struct{} errCh chan error ) if !config.AttachStdout && !config.AttachStderr { // Make this asynchronous to allow the client to write to stdin before having to read the ID waitDisplayId = make(chan struct{}) go func() { defer close(waitDisplayId) fmt.Fprintf(cli.out, "%s\n", createResponse.ID) }() } if *flAutoRemove && (hostConfig.RestartPolicy.Name == "always" || hostConfig.RestartPolicy.Name == "on-failure") { return ErrConflictRestartPolicyAndAutoRemove } // We need to instantiate the chan because the select needs it. It can // be closed but can't be uninitialized. hijacked := make(chan io.Closer) // Block the return until the chan gets closed defer func() { log.Debugf("End of CmdRun(), Waiting for hijack to finish.") if _, ok := <-hijacked; ok { log.Errorf("Hijack did not finish (chan still open)") } }() if config.AttachStdin || config.AttachStdout || config.AttachStderr { var ( out, stderr io.Writer in io.ReadCloser v = url.Values{} ) v.Set("stream", "1") if config.AttachStdin { v.Set("stdin", "1") in = cli.in } if config.AttachStdout { v.Set("stdout", "1") out = cli.out } if config.AttachStderr { v.Set("stderr", "1") if config.Tty { stderr = cli.out } else { stderr = cli.err } } errCh = promise.Go(func() error { return cli.hijack("POST", "/containers/"+createResponse.ID+"/attach?"+v.Encode(), config.Tty, in, out, stderr, hijacked, nil) }) } else { close(hijacked) } // Acknowledge the hijack before starting select { case closer := <-hijacked: // Make sure that the hijack gets closed when returning (results // in closing the hijack chan and freeing server's goroutines) if closer != nil { defer closer.Close() } case err := <-errCh: if err != nil { log.Debugf("Error hijack: %s", err) return err } } defer func() { if *flAutoRemove { if _, _, err = readBody(cli.call("DELETE", "/containers/"+createResponse.ID+"?v=1", nil, false)); err != nil { log.Errorf("Error deleting container: %s", err) } } }() //start the container if _, _, err = readBody(cli.call("POST", "/containers/"+createResponse.ID+"/start", nil, false)); err != nil { return err } if (config.AttachStdin || config.AttachStdout || config.AttachStderr) && config.Tty && cli.isTerminalOut { if err := cli.monitorTtySize(createResponse.ID, false); err != nil { log.Errorf("Error monitoring TTY size: %s", err) } } if errCh != nil { if err := <-errCh; err != nil { log.Debugf("Error hijack: %s", err) return err } } // Detached mode: wait for the id to be displayed and return. if !config.AttachStdout && !config.AttachStderr { // Detached mode <-waitDisplayId return nil } var status int // Attached mode if *flAutoRemove { // Autoremove: wait for the container to finish, retrieve // the exit code and remove the container if _, _, err := readBody(cli.call("POST", "/containers/"+createResponse.ID+"/wait", nil, false)); err != nil { return err } if _, status, err = getExitCode(cli, createResponse.ID); err != nil { return err } } else { // No Autoremove: Simply retrieve the exit code if !config.Tty { // In non-TTY mode, we can't detach, so we must wait for container exit if status, err = waitForExit(cli, createResponse.ID); err != nil { return err } } else { // In TTY mode, there is a race: if the process dies too slowly, the state could // be updated after the getExitCode call and result in the wrong exit code being reported if _, status, err = getExitCode(cli, createResponse.ID); err != nil { return err } } } if status != 0 { return &utils.StatusError{StatusCode: status} } return nil } func (cli *DockerCli) CmdCp(args ...string) error { cmd := cli.Subcmd("cp", "CONTAINER:PATH HOSTDIR|-", "Copy files/folders from a PATH on the container to a HOSTDIR on the host\nrunning the command. Use '-' to write the data\nas a tar file to STDOUT.", true) cmd.Require(flag.Exact, 2) utils.ParseFlags(cmd, args, true) var copyData engine.Env info := strings.Split(cmd.Arg(0), ":") if len(info) != 2 { return fmt.Errorf("Error: Path not specified") } copyData.Set("Resource", info[1]) copyData.Set("HostPath", cmd.Arg(1)) stream, statusCode, err := cli.call("POST", "/containers/"+info[0]+"/copy", copyData, false) if stream != nil { defer stream.Close() } if statusCode == 404 { return fmt.Errorf("No such container: %v", info[0]) } if err != nil { return err } if statusCode == 200 { dest := copyData.Get("HostPath") if dest == "-" { _, err = io.Copy(cli.out, stream) } else { err = archive.Untar(stream, dest, &archive.TarOptions{NoLchown: true}) } if err != nil { return err } } return nil } func (cli *DockerCli) CmdSave(args ...string) error { cmd := cli.Subcmd("save", "IMAGE [IMAGE...]", "Save an image(s) to a tar archive (streamed to STDOUT by default)", true) outfile := cmd.String([]string{"o", "-output"}, "", "Write to an file, instead of STDOUT") cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) var ( output io.Writer = cli.out err error ) if *outfile != "" { output, err = os.Create(*outfile) if err != nil { return err } } else if cli.isTerminalOut { return errors.New("Cowardly refusing to save to a terminal. Use the -o flag or redirect.") } if len(cmd.Args()) == 1 { image := cmd.Arg(0) if err := cli.stream("GET", "/images/"+image+"/get", nil, output, nil); err != nil { return err } } else { v := url.Values{} for _, arg := range cmd.Args() { v.Add("names", arg) } if err := cli.stream("GET", "/images/get?"+v.Encode(), nil, output, nil); err != nil { return err } } return nil } func (cli *DockerCli) CmdLoad(args ...string) error { cmd := cli.Subcmd("load", "", "Load an image from a tar archive on STDIN", true) infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN") cmd.Require(flag.Exact, 0) utils.ParseFlags(cmd, args, true) var ( input io.Reader = cli.in err error ) if *infile != "" { input, err = os.Open(*infile) if err != nil { return err } } if err := cli.stream("POST", "/images/load", input, cli.out, nil); err != nil { return err } return nil } func (cli *DockerCli) CmdExec(args ...string) error { cmd := cli.Subcmd("exec", "CONTAINER COMMAND [ARG...]", "Run a command in a running container", true) execConfig, err := runconfig.ParseExec(cmd, args) // just in case the ParseExec does not exit if execConfig.Container == "" || err != nil { return &utils.StatusError{StatusCode: 1} } stream, _, err := cli.call("POST", "/containers/"+execConfig.Container+"/exec", execConfig, false) if err != nil { return err } var response types.ContainerExecCreateResponse if err := json.NewDecoder(stream).Decode(&response); err != nil { return err } for _, warning := range response.Warnings { fmt.Fprintf(cli.err, "WARNING: %s\n", warning) } execID := response.ID if execID == "" { fmt.Fprintf(cli.out, "exec ID empty") return nil } if !execConfig.Detach { if err := cli.CheckTtyInput(execConfig.AttachStdin, execConfig.Tty); err != nil { return err } } else { if _, _, err := readBody(cli.call("POST", "/exec/"+execID+"/start", execConfig, false)); err != nil { return err } // For now don't print this - wait for when we support exec wait() // fmt.Fprintf(cli.out, "%s\n", execID) return nil } // Interactive exec requested. var ( out, stderr io.Writer in io.ReadCloser hijacked = make(chan io.Closer) errCh chan error ) // Block the return until the chan gets closed defer func() { log.Debugf("End of CmdExec(), Waiting for hijack to finish.") if _, ok := <-hijacked; ok { log.Errorf("Hijack did not finish (chan still open)") } }() if execConfig.AttachStdin { in = cli.in } if execConfig.AttachStdout { out = cli.out } if execConfig.AttachStderr { if execConfig.Tty { stderr = cli.out } else { stderr = cli.err } } errCh = promise.Go(func() error { return cli.hijack("POST", "/exec/"+execID+"/start", execConfig.Tty, in, out, stderr, hijacked, execConfig) }) // Acknowledge the hijack before starting select { case closer := <-hijacked: // Make sure that hijack gets closed when returning. (result // in closing hijack chan and freeing server's goroutines. if closer != nil { defer closer.Close() } case err := <-errCh: if err != nil { log.Debugf("Error hijack: %s", err) return err } } if execConfig.Tty && cli.isTerminalIn { if err := cli.monitorTtySize(execID, true); err != nil { log.Errorf("Error monitoring TTY size: %s", err) } } if err := <-errCh; err != nil { log.Debugf("Error hijack: %s", err) return err } var status int if _, status, err = getExecExitCode(cli, execID); err != nil { return err } if status != 0 { return &utils.StatusError{StatusCode: status} } return nil } type containerStats struct { Name string CpuPercentage float64 Memory float64 MemoryLimit float64 MemoryPercentage float64 NetworkRx float64 NetworkTx float64 mu sync.RWMutex err error } func (s *containerStats) Collect(cli *DockerCli) { stream, _, err := cli.call("GET", "/containers/"+s.Name+"/stats", nil, false) if err != nil { s.err = err return } defer stream.Close() var ( previousCpu uint64 previousSystem uint64 start = true dec = json.NewDecoder(stream) u = make(chan error, 1) ) go func() { for { var v *types.Stats if err := dec.Decode(&v); err != nil { u <- err return } var ( memPercent = float64(v.MemoryStats.Usage) / float64(v.MemoryStats.Limit) * 100.0 cpuPercent = 0.0 ) if !start { cpuPercent = calculateCpuPercent(previousCpu, previousSystem, v) } start = false s.mu.Lock() s.CpuPercentage = cpuPercent s.Memory = float64(v.MemoryStats.Usage) s.MemoryLimit = float64(v.MemoryStats.Limit) s.MemoryPercentage = memPercent s.NetworkRx = float64(v.Network.RxBytes) s.NetworkTx = float64(v.Network.TxBytes) s.mu.Unlock() previousCpu = v.CpuStats.CpuUsage.TotalUsage previousSystem = v.CpuStats.SystemUsage u <- nil } }() for { select { case <-time.After(2 * time.Second): // zero out the values if we have not received an update within // the specified duration. s.mu.Lock() s.CpuPercentage = 0 s.Memory = 0 s.MemoryPercentage = 0 s.mu.Unlock() case err := <-u: if err != nil { s.mu.Lock() s.err = err s.mu.Unlock() return } } } } func (s *containerStats) Display(w io.Writer) error { s.mu.RLock() defer s.mu.RUnlock() if s.err != nil { return s.err } fmt.Fprintf(w, "%s\t%.2f%%\t%s/%s\t%.2f%%\t%s/%s\n", s.Name, s.CpuPercentage, units.BytesSize(s.Memory), units.BytesSize(s.MemoryLimit), s.MemoryPercentage, units.BytesSize(s.NetworkRx), units.BytesSize(s.NetworkTx)) return nil } func (cli *DockerCli) CmdStats(args ...string) error { cmd := cli.Subcmd("stats", "CONTAINER [CONTAINER...]", "Display a live stream of one or more containers' resource usage statistics", true) cmd.Require(flag.Min, 1) utils.ParseFlags(cmd, args, true) names := cmd.Args() sort.Strings(names) var ( cStats []*containerStats w = tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0) ) printHeader := func() { fmt.Fprint(cli.out, "\033[2J") fmt.Fprint(cli.out, "\033[H") fmt.Fprintln(w, "CONTAINER\tCPU %\tMEM USAGE/LIMIT\tMEM %\tNET I/O") } for _, n := range names { s := &containerStats{Name: n} cStats = append(cStats, s) go s.Collect(cli) } // do a quick pause so that any failed connections for containers that do not exist are able to be // evicted before we display the initial or default values. time.Sleep(500 * time.Millisecond) var errs []string for _, c := range cStats { c.mu.Lock() if c.err != nil { errs = append(errs, fmt.Sprintf("%s: %v", c.Name, c.err)) } c.mu.Unlock() } if len(errs) > 0 { return fmt.Errorf("%s", strings.Join(errs, ", ")) } for _ = range time.Tick(500 * time.Millisecond) { printHeader() toRemove := []int{} for i, s := range cStats { if err := s.Display(w); err != nil { toRemove = append(toRemove, i) } } for j := len(toRemove) - 1; j >= 0; j-- { i := toRemove[j] cStats = append(cStats[:i], cStats[i+1:]...) } if len(cStats) == 0 { return nil } w.Flush() } return nil } func calculateCpuPercent(previousCpu, previousSystem uint64, v *types.Stats) float64 { var ( cpuPercent = 0.0 // calculate the change for the cpu usage of the container in between readings cpuDelta = float64(v.CpuStats.CpuUsage.TotalUsage - previousCpu) // calculate the change for the entire system between readings systemDelta = float64(v.CpuStats.SystemUsage - previousSystem) ) if systemDelta > 0.0 && cpuDelta > 0.0 { cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CpuStats.CpuUsage.PercpuUsage)) * 100.0 } return cpuPercent }
elipiwas/DockerBirthday
api/client/commands.go
GO
apache-2.0
83,968
[ 30522, 7427, 7396, 12324, 1006, 1000, 20934, 8873, 2080, 1000, 1000, 27507, 1000, 1000, 17181, 1013, 2918, 21084, 1000, 1000, 17181, 1013, 1046, 3385, 1000, 1000, 10697, 1000, 1000, 4718, 2102, 1000, 1000, 22834, 1000, 1000, 22834, 1013, 22...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#if !defined(AFX_VIDEOSETDLG_H__664275CD_D25D_4617_BDF9_55BBFFF58C78__INCLUDED_) #define AFX_VIDEOSETDLG_H__664275CD_D25D_4617_BDF9_55BBFFF58C78__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // VideoSetDlg.h : header file // ///////////////////////////////////////////////////////////////////////////// // VideoSetDlg dialog class VideoSetDlg : public CDialog { // Construction public: void initDlg(); void refreshDevice(); VideoSetDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(VideoSetDlg) enum { IDD = IDD_DIALOG_VIDEOSET }; CComboBox m_playDevice; CComboBox m_videoDevice; CComboBox m_resolution; CComboBox m_quality; CComboBox m_preparam; CComboBox m_frameRate; CComboBox m_bitRate; CComboBox m_audioMode; CComboBox m_audioDevice; BOOL m_enableAGC; BOOL m_enableEcho; BOOL m_enableNS; BOOL m_enableVAD; BOOL m_serverPriority; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(VideoSetDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(VideoSetDlg) afx_msg void OnCheckAGC(); afx_msg void OnCheckEcho(); afx_msg void OnCheckNS(); afx_msg void OnCheckVAD(); afx_msg void OnCheckServerPriority(); afx_msg void OnSelAudioDevice(); afx_msg void OnSelAudioMode(); afx_msg void OnSelBitRate(); afx_msg void OnSelFrameRate(); afx_msg void OnSelPreParam(); afx_msg void OnSelVideoQuality(); afx_msg void OnSelResolution(); afx_msg void OnSelVideodevice(); virtual BOOL OnInitDialog(); afx_msg void OnSelPlayDevice(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_VIDEOSETDLG_H__664275CD_D25D_4617_BDF9_55BBFFF58C78__INCLUDED_)
alucard263096/AMKRemoteClass
Documents/AnyChat/AnyChatCoreSDK_Win32_r4840/src/client/c++/Hello AnyChat/VideoSetDlg.h
C
apache-2.0
1,945
[ 30522, 1001, 2065, 999, 4225, 1006, 21358, 2595, 1035, 6876, 3388, 19422, 2290, 1035, 1044, 1035, 1035, 5764, 20958, 23352, 19797, 1035, 1040, 17788, 2094, 1035, 4805, 16576, 1035, 1038, 20952, 2683, 1035, 4583, 10322, 4246, 2546, 27814, 22...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // Use this file to import your target's public headers that you would like to expose to Swift. // #import "example.h"
dolphilia/swift-lua-example
09_lua_in_swift_multithreading/swiftobjctest/swiftobjctest-Bridging-Header.h
C
mit
123
[ 30522, 1013, 1013, 1013, 1013, 2224, 2023, 5371, 2000, 12324, 2115, 4539, 1005, 1055, 2270, 20346, 2015, 2008, 2017, 2052, 2066, 2000, 14451, 2000, 9170, 1012, 1013, 1013, 1001, 12324, 1000, 2742, 1012, 1044, 1000, 102, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
const chai = require('chai'); const expect = chai.expect; const ComplexArray = require('../complex-array/complex-array'); function assertArrayEquals(first, second) { const message = `${first} != ${second}`; first.forEach((item, i) => { expect(item).to.equal(second[i], message); }); } describe('Complex Array', () => { describe('Consructor', () => { it('should construct from a number', () => { const a = new ComplexArray(10); expect(a).to.exist; expect(a.real.length).to.equal(10); expect(a.imag.length).to.equal(10); expect(a.real[0]).to.equal(0); expect(a.imag[0]).to.equal(0); }); it('should construct from a number with a type', () => { const a = new ComplexArray(10, Int32Array); expect(a.ArrayType).to.equal(Int32Array); expect(a.real.length).to.equal(10); expect(a.imag.length).to.equal(10); expect(a.real[0]).to.equal(0); expect(a.imag[0]).to.equal(0); }); it('should contruct from a real array', () => { const a = new ComplexArray([1, 2]); assertArrayEquals([1, 2], a.real); assertArrayEquals([0, 0], a.imag); }); it('should contruct from a real array with a type', () => { const a = new ComplexArray([1, 2], Int32Array); expect(a.ArrayType).to.equal(Int32Array) assertArrayEquals([1, 2], a.real); assertArrayEquals([0, 0], a.imag); }); it('should contruct from another complex array', () => { const a = new ComplexArray(new ComplexArray([1, 2])); assertArrayEquals([1, 2], a.real); assertArrayEquals([0, 0], a.imag); }); }); describe('`map` method', () => { it('should alter all values', () => { const a = new ComplexArray([1, 2]).map((value, i) => { value.real *= 10; value.imag = i; }); assertArrayEquals([10, 20], a.real); assertArrayEquals([0, 1], a.imag); }); }); describe('`forEach` method', () => { it('should touch every value', () => { const a = new ComplexArray([1, 2]); a.imag[0] = 4; a.imag[1] = 8; let sum = 0; a.forEach((value, i) => { sum += value.real; sum += value.imag; }); expect(sum).to.equal(15); }); }); describe('`conjugate` method', () => { it('should multiply a number', () => { const a = new ComplexArray([1, 2]); a.imag[0] = 1; a.imag[1] = -2; const b = a.conjugate(); assertArrayEquals([1, 2], b.real); assertArrayEquals([-1, 2], b.imag); }); }); describe('`magnitude` method', () => { it('should give the an array of magnitudes', () => { const a = new ComplexArray([1, 3]); a.imag[0] = 0; a.imag[1] = 4; assertArrayEquals([1, 5], a.magnitude()); }); it('should return an iterable ArrayType object', () => { const a = new ComplexArray([1, 2]); let sum = 0; a.magnitude().forEach((value, i) => { sum += value; }); expect(sum).to.equal(3); }); }); });
JoeKarlsson/data-structures
test/complex-array.spec.js
JavaScript
mit
3,055
[ 30522, 9530, 3367, 15775, 2072, 1027, 5478, 1006, 1005, 15775, 2072, 1005, 1007, 1025, 9530, 3367, 5987, 1027, 15775, 2072, 1012, 5987, 1025, 9530, 3367, 3375, 2906, 9447, 1027, 5478, 1006, 1005, 1012, 1012, 1013, 3375, 1011, 9140, 1013, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * Copyright (C) 2012 - 2014 Xeiam LLC http://xeiam.com * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.xeiam.xchange.justcoin.service.trade; import static org.fest.assertions.api.Assertions.assertThat; import java.io.IOException; import java.io.InputStream; import org.junit.Test; import com.fasterxml.jackson.databind.ObjectMapper; import com.xeiam.xchange.justcoin.dto.PostCreateResponse; import com.xeiam.xchange.justcoin.service.marketdata.JustcoinDepthTest; /** * @author jamespedwards42 */ public class JustcoinPostCreateResponseJsonTest { @Test public void testUnmarshal() throws IOException { // Read in the JSON from the example resources final InputStream is = JustcoinDepthTest.class.getResourceAsStream("/trade/example-post-create-response-data.json"); // Use Jackson to parse it final ObjectMapper mapper = new ObjectMapper(); final PostCreateResponse response = mapper.readValue(is, PostCreateResponse.class); assertThat(response.getId()).isEqualTo("1895549"); } }
habibmasuro/XChange
xchange-justcoin/src/test/java/com/xeiam/xchange/justcoin/service/trade/JustcoinPostCreateResponseJsonTest.java
Java
mit
2,068
[ 30522, 1013, 1008, 1008, 1008, 9385, 1006, 1039, 1007, 2262, 1011, 2297, 1060, 27958, 2213, 11775, 8299, 1024, 1013, 1013, 1060, 27958, 2213, 1012, 4012, 1008, 1008, 6656, 2003, 2182, 3762, 4379, 1010, 2489, 1997, 3715, 1010, 2000, 2151, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var direccion = '/api/Usuarios/' + sessionStorage.userId + '?access_token=' + sessionStorage.userToken; var nombre; /* Eliminar los valores de sesión */ function eliminarStorage(){ sessionStorage.removeItem("userToken"); sessionStorage.removeItem("userId"); sessionStorage.removeItem("userTtl"); sessionStorage.removeItem("userCreated"); sessionStorage.removeItem("userNombre"); sessionStorage.removeItem("userApellidos"); sessionStorage.removeItem("userDni"); sessionStorage.removeItem("userTelefono"); sessionStorage.removeItem("userCurso"); sessionStorage.removeItem("userUsername"); sessionStorage.removeItem("userEmail"); sessionStorage.removeItem("userObjetivoId"); sessionStorage.removeItem("userCentroId"); sessionStorage.removeItem("NombreCentro"); sessionStorage.removeItem("CodigoCentro"); sessionStorage.removeItem("LocalidadCentro"); sessionStorage.removeItem("userIdAlumnado"); sessionStorage.removeItem("NombreObjetivo"); } conexion('GET','',direccion); function conexion(metodo,datos,url){ $.ajax({ async: true, dataType: 'json', data: datos, method: metodo, url: url, }).done(function (respuesta){ if(typeof(respuesta.id) !== undefined){ sessionStorage.userNombre = respuesta.Nombre; sessionStorage.userApellidos = respuesta.Apellidos; sessionStorage.userDni = respuesta.DNI; sessionStorage.userTelefono = respuesta.Telefono; sessionStorage.userCurso = respuesta.Curso; sessionStorage.userUsername = respuesta.username; sessionStorage.userEmail = respuesta.email; sessionStorage.userCentroId = respuesta.centroId; sessionStorage.userObjetivoId = respuesta.objetivo; nombre = "<i class='fa fa-user-circle' aria-hidden='true'></i> " + sessionStorage.userNombre; $("#botonPerfil").html(nombre); $("#botonPerfilAdmin").html(nombre); $('#mensajeInicio').html("BIENVENIDO " + sessionStorage.userNombre + " A LA APLICACIÓN DE GESTIÓN DEL VIAJE DE ESTUDIOS"); }else{ console.log("Error Inicio"); eliminarStorage(); window.location.href = "../index.html"; } }).fail(function (xhr){ console.log("Error Inicio"); eliminarStorage(); window.location.href = "../index.html"; }); } $(document).ready(function() { $("#botonSalir").click(function(){ eliminarStorage(); window.location.href = "../index.html"; }); $("#botonPerfil").click(function(){ window.location.href = "perfil.html"; }); })
Salva79/ProyectoViaje
client/js/usuario.js
JavaScript
gpl-3.0
2,438
[ 30522, 13075, 18704, 14693, 2239, 1027, 1005, 1013, 17928, 1013, 2149, 6692, 9488, 2015, 1013, 1005, 1009, 6521, 4263, 4270, 1012, 5310, 3593, 1009, 1005, 1029, 3229, 1035, 19204, 1027, 1005, 1009, 6521, 4263, 4270, 1012, 5310, 18715, 2368,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * File: * Author: ezio * * Created on 2016年2月25日, 下午9:14 */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <ctype.h> #include <sys/un.h> #include <sys/socket.h> #define SV_SOCK_PATH "/tmp/us_xfr" #define BUF_SIZE 10 #define BACKLOG 5 int main(void) { struct sockaddr_un svaddr,claddr; int sfd,j; ssize_t numRead; socklen_t len; char buf[BUF_SIZE]; sfd = socket(AF_UNIX , SOCK_DGRAM, 0); if (sfd == -1) exit(-1); if(unlink(SV_SOCK_PATH) == -1 && errno != ENOENT) exit(-2); memset(&svaddr, 0, sizeof(struct sockaddr_un)); svaddr.sun_family = AF_UNIX; strncpy(svaddr.sun_path, SV_SOCK_PATH, sizeof(svaddr.sun_path) -1 ); if(bind(sfd, (struct sockaddr *)&svaddr, sizeof(struct sockaddr_un))== -1) exit(-3); for(;;) { len = sizeof(struct sockaddr_un); numRead = recvfrom(sfd, buf, BUF_SIZE, 0, (struct sockaddr *)&claddr, &len); if(numRead == -1) exit(-4); printf("server recved %ld bytes from %s\n",(long) numRead, claddr.sun_path); for(j = 0; j<numRead; j++) buf[j] = toupper((unsigned char )buf[j]); if (sendto(sfd, buf, numRead, 0, (struct sockaddr *)&claddr, len) != numRead) perror("sendto "); } return 0; }
oska874/cCode
socket/ud_ser.c
C
apache-2.0
1,436
[ 30522, 1013, 1008, 1008, 5371, 1024, 1008, 3166, 1024, 23043, 1008, 1008, 2580, 2006, 2355, 1840, 1016, 1872, 2423, 1864, 1010, 1743, 100, 1023, 1024, 2403, 1008, 1013, 1001, 2421, 1026, 2358, 20617, 1012, 1044, 1028, 1001, 2421, 1026, 23...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
jsonp({"cep":"13256566","logradouro":"Rua Angelo Capeletto","bairro":"Loteamento Residencial Terra Nova","cidade":"Itatiba","uf":"SP","estado":"S\u00e3o Paulo"});
lfreneda/cepdb
api/v1/13256566.jsonp.js
JavaScript
cc0-1.0
163
[ 30522, 1046, 3385, 2361, 1006, 1063, 1000, 8292, 2361, 1000, 1024, 1000, 14078, 26976, 26976, 2575, 1000, 1010, 1000, 8833, 12173, 8162, 2080, 1000, 1024, 1000, 21766, 2050, 12262, 4880, 20897, 2080, 1000, 1010, 1000, 21790, 18933, 1000, 10...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
__author__ = "Jon Dawson" __copyright__ = "Copyright (C) 2012, Jonathan P Dawson" __version__ = "0.1" class Allocator: """Maintain a pool of registers, variables and arrays. Keep track of what they are used for.""" def __init__(self, reuse): self.registers = [] self.all_registers = {} self.memory_size_2 = 0 self.memory_size_4 = 0 self.reuse = reuse self.memory_content_2 = {} self.memory_content_4 = {} def new_array(self, size, contents, element_size): if element_size == 2: reg = self.memory_size_2 self.memory_size_2 += int(size) if contents is not None: for location, value in enumerate(contents, reg): self.memory_content_2[location] = value return reg elif element_size == 4: reg = self.memory_size_4 self.memory_size_4 += int(size) if contents is not None: for location, value in enumerate(contents, reg): self.memory_content_4[location] = value return reg def regsize(self, reg): return self.all_registers[reg][1] def new(self, size, name="temporary_register"): assert type(size) == int reg = 0 while reg in self.registers or (reg in self.all_registers and self.regsize(reg) != size): reg += 1 self.registers.append(reg) self.all_registers[reg] = (name, size) return reg def free(self, register): if register in self.registers and self.reuse: self.registers.remove(register)
amerc/phimii
chips2/chips/compiler/allocator.py
Python
mit
1,644
[ 30522, 1035, 1035, 3166, 1035, 1035, 1027, 1000, 6285, 11026, 1000, 1035, 1035, 9385, 1035, 1035, 1027, 1000, 9385, 1006, 1039, 1007, 2262, 1010, 5655, 1052, 11026, 1000, 1035, 1035, 2544, 1035, 1035, 1027, 1000, 1014, 1012, 1015, 1000, 2...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Data-Structure-Tutorial Simple concepts of basic data structures.
cathayandy/Data-Structure-Tutorial
README.md
Markdown
mit
68
[ 30522, 1001, 2951, 1011, 3252, 1011, 14924, 4818, 3722, 8474, 1997, 3937, 2951, 5090, 1012, 102, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
obj-$(CONFIG_BLUETOOTH) += bluetooth/ obj-$(CONFIG_NETWORKING) += ip/ obj-$(CONFIG_NET_BUF) += buf.o
coldnew/zephyr-project-fork
net/Makefile
Makefile
apache-2.0
101
[ 30522, 27885, 3501, 1011, 1002, 1006, 9530, 8873, 2290, 1035, 2630, 19392, 1007, 1009, 1027, 2630, 19392, 1013, 27885, 3501, 1011, 1002, 1006, 9530, 8873, 2290, 1035, 14048, 1007, 1009, 1027, 12997, 1013, 27885, 3501, 1011, 1002, 1006, 9530...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#region License // Copyright (c) 2007 James Newton-King // // 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. #endregion using System; using System.Reflection; using HazTech.Json.Utilities; using System.Globalization; namespace HazTech.Json.Serialization { /// <summary> /// Get and set values for a <see cref="MemberInfo"/> using reflection. /// </summary> public class ReflectionValueProvider : IValueProvider { private readonly MemberInfo _memberInfo; /// <summary> /// Initializes a new instance of the <see cref="ReflectionValueProvider"/> class. /// </summary> /// <param name="memberInfo">The member info.</param> public ReflectionValueProvider(MemberInfo memberInfo) { ValidationUtils.ArgumentNotNull(memberInfo, "memberInfo"); _memberInfo = memberInfo; } /// <summary> /// Sets the value. /// </summary> /// <param name="target">The target to set the value on.</param> /// <param name="value">The value to set on the target.</param> public void SetValue(object target, object value) { try { ReflectionUtils.SetMemberValue(_memberInfo, target, value); } catch (Exception ex) { throw new JsonSerializationException("Error setting value to '{0}' on '{1}'.".FormatWith(CultureInfo.InvariantCulture, _memberInfo.Name, target.GetType()), ex); } } /// <summary> /// Gets the value. /// </summary> /// <param name="target">The target to get the value from.</param> /// <returns>The value.</returns> public object GetValue(object target) { try { return ReflectionUtils.GetMemberValue(_memberInfo, target); } catch (Exception ex) { throw new JsonSerializationException("Error getting value from '{0}' on '{1}'.".FormatWith(CultureInfo.InvariantCulture, _memberInfo.Name, target.GetType()), ex); } } } }
marhazk/HazTechClass
AeraClass/Newtonsoft.Json/Serialization/ReflectionValueProvider.cs
C#
gpl-2.0
3,187
[ 30522, 1001, 2555, 6105, 1013, 1013, 9385, 1006, 1039, 1007, 2289, 2508, 8446, 1011, 2332, 1013, 1013, 1013, 1013, 6656, 2003, 2182, 3762, 4379, 1010, 2489, 1997, 3715, 1010, 2000, 30524, 2023, 4007, 1998, 3378, 12653, 1013, 1013, 6764, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# javatra Simple Java Web Framework inspired by SparkJava
toanvando/YuckJava
README.md
Markdown
mit
58
[ 30522, 1001, 9262, 6494, 3722, 9262, 4773, 7705, 4427, 2011, 12125, 3900, 3567, 102, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
class HomeController < ApplicationController def index end def playgame @orientation = "" @waiting_players = [] if params[:nick_name] # This user gave us a nickname and is looking for other players @looking = true #register user nick_name = params[:nick_name] @u = User.find_or_initialize_by(nick_name: nick_name) @u.save! # get list of available players players = User.where('connection_id is not null') @waiting_players = players - [@u] elsif params[:game_id] # This user came from a link and doesn't have a nickname @looking = false @game = Game.find(params[:game_id]) @u = User.find_or_initialize_by(nick_name: User.make_random_name) @u.save! if !@game.white #first player gets white @game.white = @u.id @orientation = "white" elsif !@game.black #second player gets black @game.black = @u.id @orientation = "black" else #already 2 players? render "gamefull" return end @game.save! end end def replay @game = Game.find(params[:game_id]) moves = Move.where("game_id = ?", @game.id) @fens = moves.map{ |move| move.fen} end def creategame @game = Game.create @link = @game.generate_play_link request.host_with_port end end
sdb1228/chess
app/controllers/home_controller.rb
Ruby
mit
1,377
[ 30522, 2465, 2188, 8663, 13181, 10820, 1026, 4646, 8663, 13181, 10820, 13366, 5950, 2203, 13366, 2377, 16650, 1030, 10296, 1027, 1000, 1000, 1030, 3403, 1035, 2867, 1027, 1031, 1033, 2065, 11498, 5244, 1031, 1024, 4172, 1035, 2171, 1033, 10...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; namespace MySql.Data.Serialization { internal class PingPayload { public static PayloadData Create() { return new PayloadData(new ArraySegment<byte>(new[] { (byte) CommandKind.Ping })); } } }
gitsno/MySqlConnector
src/MySqlConnector/Serialization/PingPayload.cs
C#
mit
222
[ 30522, 2478, 2291, 1025, 3415, 15327, 2026, 2015, 4160, 2140, 1012, 2951, 1012, 7642, 3989, 1063, 4722, 2465, 17852, 4502, 8516, 10441, 2094, 1063, 2270, 10763, 18093, 2850, 2696, 3443, 1006, 1007, 1063, 2709, 2047, 18093, 2850, 2696, 1006,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * hostapd / Initialization and configuration * Copyright (c) 2002-2014, Jouni Malinen <j@w1.fi> * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #include "utils/includes.h" #include "utils/common.h" #include "utils/eloop.h" #include "common/ieee802_11_defs.h" #include "common/wpa_ctrl.h" #include "common/hw_features_common.h" #include "radius/radius_client.h" #include "radius/radius_das.h" #include "eap_server/tncs.h" #include "eapol_auth/eapol_auth_sm.h" #include "eapol_auth/eapol_auth_sm_i.h" #include "fst/fst.h" #include "hostapd.h" #include "authsrv.h" #include "sta_info.h" #include "accounting.h" #include "ap_list.h" #include "beacon.h" #include "iapp.h" #include "ieee802_1x.h" #include "ieee802_11_auth.h" #include "vlan_init.h" #include "wpa_auth.h" #include "wps_hostapd.h" #include "hw_features.h" #include "wpa_auth_glue.h" #include "ap_drv_ops.h" #include "ap_config.h" #include "p2p_hostapd.h" #include "gas_serv.h" #include "dfs.h" #include "ieee802_11.h" #include "bss_load.h" #include "x_snoop.h" #include "dhcp_snoop.h" #include "ndisc_snoop.h" #include "neighbor_db.h" #include "rrm.h" #ifdef CONFIG_KARMA_ATTACK #include "karma_handlers.h" #endif static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason); static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd); static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd); static int setup_interface2(struct hostapd_iface *iface); static void channel_list_update_timeout(void *eloop_ctx, void *timeout_ctx); #ifdef CONFIG_KARMA_ATTACK struct hostapd_data *g_hapd_data; #endif int hostapd_for_each_interface(struct hapd_interfaces *interfaces, int (*cb)(struct hostapd_iface *iface, void *ctx), void *ctx) { size_t i; int ret; for (i = 0; i < interfaces->count; i++) { ret = cb(interfaces->iface[i], ctx); if (ret) return ret; } return 0; } static void hostapd_reload_bss(struct hostapd_data *hapd) { struct hostapd_ssid *ssid; #ifndef CONFIG_NO_RADIUS radius_client_reconfig(hapd->radius, hapd->conf->radius); #endif /* CONFIG_NO_RADIUS */ ssid = &hapd->conf->ssid; if (!ssid->wpa_psk_set && ssid->wpa_psk && !ssid->wpa_psk->next && ssid->wpa_passphrase_set && ssid->wpa_passphrase) { /* * Force PSK to be derived again since SSID or passphrase may * have changed. */ hostapd_config_clear_wpa_psk(&hapd->conf->ssid.wpa_psk); } if (hostapd_setup_wpa_psk(hapd->conf)) { wpa_printf(MSG_ERROR, "Failed to re-configure WPA PSK " "after reloading configuration"); } if (hapd->conf->ieee802_1x || hapd->conf->wpa) hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 1); else hostapd_set_drv_ieee8021x(hapd, hapd->conf->iface, 0); if ((hapd->conf->wpa || hapd->conf->osen) && hapd->wpa_auth == NULL) { hostapd_setup_wpa(hapd); if (hapd->wpa_auth) wpa_init_keys(hapd->wpa_auth); } else if (hapd->conf->wpa) { const u8 *wpa_ie; size_t wpa_ie_len; hostapd_reconfig_wpa(hapd); wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len); if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len)) wpa_printf(MSG_ERROR, "Failed to configure WPA IE for " "the kernel driver."); } else if (hapd->wpa_auth) { wpa_deinit(hapd->wpa_auth); hapd->wpa_auth = NULL; hostapd_set_privacy(hapd, 0); hostapd_setup_encryption(hapd->conf->iface, hapd); hostapd_set_generic_elem(hapd, (u8 *) "", 0); } ieee802_11_set_beacon(hapd); hostapd_update_wps(hapd); if (hapd->conf->ssid.ssid_set && hostapd_set_ssid(hapd, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len)) { wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver"); /* try to continue */ } wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd->conf->iface); } static void hostapd_clear_old(struct hostapd_iface *iface) { size_t j; /* * Deauthenticate all stations since the new configuration may not * allow them to use the BSS anymore. */ for (j = 0; j < iface->num_bss; j++) { hostapd_flush_old_stations(iface->bss[j], WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_broadcast_wep_clear(iface->bss[j]); #ifndef CONFIG_NO_RADIUS /* TODO: update dynamic data based on changed configuration * items (e.g., open/close sockets, etc.) */ radius_client_flush(iface->bss[j]->radius, 0); #endif /* CONFIG_NO_RADIUS */ } } int hostapd_reload_config(struct hostapd_iface *iface) { struct hostapd_data *hapd = iface->bss[0]; struct hostapd_config *newconf, *oldconf; size_t j; if (iface->config_fname == NULL) { /* Only in-memory config in use - assume it has been updated */ hostapd_clear_old(iface); for (j = 0; j < iface->num_bss; j++) hostapd_reload_bss(iface->bss[j]); return 0; } if (iface->interfaces == NULL || iface->interfaces->config_read_cb == NULL) return -1; newconf = iface->interfaces->config_read_cb(iface->config_fname); if (newconf == NULL) return -1; hostapd_clear_old(iface); oldconf = hapd->iconf; iface->conf = newconf; for (j = 0; j < iface->num_bss; j++) { hapd = iface->bss[j]; hapd->iconf = newconf; hapd->iconf->channel = oldconf->channel; hapd->iconf->acs = oldconf->acs; hapd->iconf->secondary_channel = oldconf->secondary_channel; hapd->iconf->ieee80211n = oldconf->ieee80211n; hapd->iconf->ieee80211ac = oldconf->ieee80211ac; hapd->iconf->ht_capab = oldconf->ht_capab; hapd->iconf->vht_capab = oldconf->vht_capab; hapd->iconf->vht_oper_chwidth = oldconf->vht_oper_chwidth; hapd->iconf->vht_oper_centr_freq_seg0_idx = oldconf->vht_oper_centr_freq_seg0_idx; hapd->iconf->vht_oper_centr_freq_seg1_idx = oldconf->vht_oper_centr_freq_seg1_idx; hapd->conf = newconf->bss[j]; hostapd_reload_bss(hapd); } hostapd_config_free(oldconf); return 0; } static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd, const char *ifname) { int i; if (!ifname) return; for (i = 0; i < NUM_WEP_KEYS; i++) { if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i, 0, NULL, 0, NULL, 0)) { wpa_printf(MSG_DEBUG, "Failed to clear default " "encryption keys (ifname=%s keyidx=%d)", ifname, i); } } #ifdef CONFIG_IEEE80211W if (hapd->conf->ieee80211w) { for (i = NUM_WEP_KEYS; i < NUM_WEP_KEYS + 2; i++) { if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i, 0, NULL, 0, NULL, 0)) { wpa_printf(MSG_DEBUG, "Failed to clear " "default mgmt encryption keys " "(ifname=%s keyidx=%d)", ifname, i); } } } #endif /* CONFIG_IEEE80211W */ } static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd) { hostapd_broadcast_key_clear_iface(hapd, hapd->conf->iface); return 0; } static int hostapd_broadcast_wep_set(struct hostapd_data *hapd) { int errors = 0, idx; struct hostapd_ssid *ssid = &hapd->conf->ssid; idx = ssid->wep.idx; if (ssid->wep.default_len && hostapd_drv_set_key(hapd->conf->iface, hapd, WPA_ALG_WEP, broadcast_ether_addr, idx, 1, NULL, 0, ssid->wep.key[idx], ssid->wep.len[idx])) { wpa_printf(MSG_WARNING, "Could not set WEP encryption."); errors++; } return errors; } static void hostapd_free_hapd_data(struct hostapd_data *hapd) { os_free(hapd->probereq_cb); hapd->probereq_cb = NULL; hapd->num_probereq_cb = 0; #ifdef CONFIG_P2P wpabuf_free(hapd->p2p_beacon_ie); hapd->p2p_beacon_ie = NULL; wpabuf_free(hapd->p2p_probe_resp_ie); hapd->p2p_probe_resp_ie = NULL; #endif /* CONFIG_P2P */ if (!hapd->started) { wpa_printf(MSG_ERROR, "%s: Interface %s wasn't started", __func__, hapd->conf->iface); return; } hapd->started = 0; wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface); iapp_deinit(hapd->iapp); hapd->iapp = NULL; accounting_deinit(hapd); hostapd_deinit_wpa(hapd); vlan_deinit(hapd); hostapd_acl_deinit(hapd); #ifndef CONFIG_NO_RADIUS radius_client_deinit(hapd->radius); hapd->radius = NULL; radius_das_deinit(hapd->radius_das); hapd->radius_das = NULL; #endif /* CONFIG_NO_RADIUS */ hostapd_deinit_wps(hapd); authsrv_deinit(hapd); if (hapd->interface_added) { hapd->interface_added = 0; if (hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd->conf->iface)) { wpa_printf(MSG_WARNING, "Failed to remove BSS interface %s", hapd->conf->iface); hapd->interface_added = 1; } else { /* * Since this was a dynamically added interface, the * driver wrapper may have removed its internal instance * and hapd->drv_priv is not valid anymore. */ hapd->drv_priv = NULL; } } wpabuf_free(hapd->time_adv); #ifdef CONFIG_INTERWORKING gas_serv_deinit(hapd); #endif /* CONFIG_INTERWORKING */ bss_load_update_deinit(hapd); ndisc_snoop_deinit(hapd); dhcp_snoop_deinit(hapd); x_snoop_deinit(hapd); #ifdef CONFIG_SQLITE bin_clear_free(hapd->tmp_eap_user.identity, hapd->tmp_eap_user.identity_len); bin_clear_free(hapd->tmp_eap_user.password, hapd->tmp_eap_user.password_len); #endif /* CONFIG_SQLITE */ #ifdef CONFIG_MESH wpabuf_free(hapd->mesh_pending_auth); hapd->mesh_pending_auth = NULL; #endif /* CONFIG_MESH */ hostapd_clean_rrm(hapd); } /** * hostapd_cleanup - Per-BSS cleanup (deinitialization) * @hapd: Pointer to BSS data * * This function is used to free all per-BSS data structures and resources. * Most of the modules that are initialized in hostapd_setup_bss() are * deinitialized here. */ static void hostapd_cleanup(struct hostapd_data *hapd) { wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s))", __func__, hapd, hapd->conf->iface); if (hapd->iface->interfaces && hapd->iface->interfaces->ctrl_iface_deinit) hapd->iface->interfaces->ctrl_iface_deinit(hapd); hostapd_free_hapd_data(hapd); } static void sta_track_deinit(struct hostapd_iface *iface) { struct hostapd_sta_info *info; if (!iface->num_sta_seen) return; while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info, list))) { dl_list_del(&info->list); iface->num_sta_seen--; sta_track_del(info); } } static void hostapd_cleanup_iface_partial(struct hostapd_iface *iface) { wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface); #ifdef CONFIG_IEEE80211N #ifdef NEED_AP_MLME hostapd_stop_setup_timers(iface); #endif /* NEED_AP_MLME */ #endif /* CONFIG_IEEE80211N */ hostapd_free_hw_features(iface->hw_features, iface->num_hw_features); iface->hw_features = NULL; os_free(iface->current_rates); iface->current_rates = NULL; os_free(iface->basic_rates); iface->basic_rates = NULL; ap_list_deinit(iface); sta_track_deinit(iface); } /** * hostapd_cleanup_iface - Complete per-interface cleanup * @iface: Pointer to interface data * * This function is called after per-BSS data structures are deinitialized * with hostapd_cleanup(). */ static void hostapd_cleanup_iface(struct hostapd_iface *iface) { wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface); eloop_cancel_timeout(channel_list_update_timeout, iface, NULL); hostapd_cleanup_iface_partial(iface); hostapd_config_free(iface->conf); iface->conf = NULL; os_free(iface->config_fname); os_free(iface->bss); wpa_printf(MSG_DEBUG, "%s: free iface=%p", __func__, iface); os_free(iface); } static void hostapd_clear_wep(struct hostapd_data *hapd) { if (hapd->drv_priv && !hapd->iface->driver_ap_teardown) { hostapd_set_privacy(hapd, 0); hostapd_broadcast_wep_clear(hapd); } } static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd) { int i; hostapd_broadcast_wep_set(hapd); if (hapd->conf->ssid.wep.default_len) { hostapd_set_privacy(hapd, 1); return 0; } /* * When IEEE 802.1X is not enabled, the driver may need to know how to * set authentication algorithms for static WEP. */ hostapd_drv_set_authmode(hapd, hapd->conf->auth_algs); for (i = 0; i < 4; i++) { if (hapd->conf->ssid.wep.key[i] && hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i, i == hapd->conf->ssid.wep.idx, NULL, 0, hapd->conf->ssid.wep.key[i], hapd->conf->ssid.wep.len[i])) { wpa_printf(MSG_WARNING, "Could not set WEP " "encryption."); return -1; } if (hapd->conf->ssid.wep.key[i] && i == hapd->conf->ssid.wep.idx) hostapd_set_privacy(hapd, 1); } return 0; } static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason) { int ret = 0; u8 addr[ETH_ALEN]; if (hostapd_drv_none(hapd) || hapd->drv_priv == NULL) return 0; if (!hapd->iface->driver_ap_teardown) { wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "Flushing old station entries"); if (hostapd_flush(hapd)) { wpa_msg(hapd->msg_ctx, MSG_WARNING, "Could not connect to kernel driver"); ret = -1; } } wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "Deauthenticate all stations"); os_memset(addr, 0xff, ETH_ALEN); hostapd_drv_sta_deauth(hapd, addr, reason); hostapd_free_stas(hapd); return ret; } static void hostapd_bss_deinit_no_free(struct hostapd_data *hapd) { #ifdef CONFIG_KARMA_ATTACK free_all_karma_data(hapd); #endif hostapd_free_stas(hapd); hostapd_flush_old_stations(hapd, WLAN_REASON_DEAUTH_LEAVING); hostapd_clear_wep(hapd); } /** * hostapd_validate_bssid_configuration - Validate BSSID configuration * @iface: Pointer to interface data * Returns: 0 on success, -1 on failure * * This function is used to validate that the configured BSSIDs are valid. */ static int hostapd_validate_bssid_configuration(struct hostapd_iface *iface) { u8 mask[ETH_ALEN] = { 0 }; struct hostapd_data *hapd = iface->bss[0]; unsigned int i = iface->conf->num_bss, bits = 0, j; int auto_addr = 0; if (hostapd_drv_none(hapd)) return 0; if (iface->conf->use_driver_iface_addr) return 0; /* Generate BSSID mask that is large enough to cover the BSSIDs. */ /* Determine the bits necessary to cover the number of BSSIDs. */ for (i--; i; i >>= 1) bits++; /* Determine the bits necessary to any configured BSSIDs, if they are higher than the number of BSSIDs. */ for (j = 0; j < iface->conf->num_bss; j++) { if (is_zero_ether_addr(iface->conf->bss[j]->bssid)) { if (j) auto_addr++; continue; } for (i = 0; i < ETH_ALEN; i++) { mask[i] |= iface->conf->bss[j]->bssid[i] ^ hapd->own_addr[i]; } } if (!auto_addr) goto skip_mask_ext; for (i = 0; i < ETH_ALEN && mask[i] == 0; i++) ; j = 0; if (i < ETH_ALEN) { j = (5 - i) * 8; while (mask[i] != 0) { mask[i] >>= 1; j++; } } if (bits < j) bits = j; if (bits > 40) { wpa_printf(MSG_ERROR, "Too many bits in the BSSID mask (%u)", bits); return -1; } os_memset(mask, 0xff, ETH_ALEN); j = bits / 8; for (i = 5; i > 5 - j; i--) mask[i] = 0; j = bits % 8; while (j--) mask[i] <<= 1; skip_mask_ext: wpa_printf(MSG_DEBUG, "BSS count %lu, BSSID mask " MACSTR " (%d bits)", (unsigned long) iface->conf->num_bss, MAC2STR(mask), bits); if (!auto_addr) return 0; for (i = 0; i < ETH_ALEN; i++) { if ((hapd->own_addr[i] & mask[i]) != hapd->own_addr[i]) { wpa_printf(MSG_ERROR, "Invalid BSSID mask " MACSTR " for start address " MACSTR ".", MAC2STR(mask), MAC2STR(hapd->own_addr)); wpa_printf(MSG_ERROR, "Start address must be the " "first address in the block (i.e., addr " "AND mask == addr)."); return -1; } } return 0; } static int mac_in_conf(struct hostapd_config *conf, const void *a) { size_t i; for (i = 0; i < conf->num_bss; i++) { if (hostapd_mac_comp(conf->bss[i]->bssid, a) == 0) { return 1; } } return 0; } #ifndef CONFIG_NO_RADIUS static int hostapd_das_nas_mismatch(struct hostapd_data *hapd, struct radius_das_attrs *attr) { if (attr->nas_identifier && (!hapd->conf->nas_identifier || os_strlen(hapd->conf->nas_identifier) != attr->nas_identifier_len || os_memcmp(hapd->conf->nas_identifier, attr->nas_identifier, attr->nas_identifier_len) != 0)) { wpa_printf(MSG_DEBUG, "RADIUS DAS: NAS-Identifier mismatch"); return 1; } if (attr->nas_ip_addr && (hapd->conf->own_ip_addr.af != AF_INET || os_memcmp(&hapd->conf->own_ip_addr.u.v4, attr->nas_ip_addr, 4) != 0)) { wpa_printf(MSG_DEBUG, "RADIUS DAS: NAS-IP-Address mismatch"); return 1; } #ifdef CONFIG_IPV6 if (attr->nas_ipv6_addr && (hapd->conf->own_ip_addr.af != AF_INET6 || os_memcmp(&hapd->conf->own_ip_addr.u.v6, attr->nas_ipv6_addr, 16) != 0)) { wpa_printf(MSG_DEBUG, "RADIUS DAS: NAS-IPv6-Address mismatch"); return 1; } #endif /* CONFIG_IPV6 */ return 0; } static struct sta_info * hostapd_das_find_sta(struct hostapd_data *hapd, struct radius_das_attrs *attr, int *multi) { struct sta_info *selected, *sta; char buf[128]; int num_attr = 0; int count; *multi = 0; for (sta = hapd->sta_list; sta; sta = sta->next) sta->radius_das_match = 1; if (attr->sta_addr) { num_attr++; sta = ap_get_sta(hapd, attr->sta_addr); if (!sta) { wpa_printf(MSG_DEBUG, "RADIUS DAS: No Calling-Station-Id match"); return NULL; } selected = sta; for (sta = hapd->sta_list; sta; sta = sta->next) { if (sta != selected) sta->radius_das_match = 0; } wpa_printf(MSG_DEBUG, "RADIUS DAS: Calling-Station-Id match"); } if (attr->acct_session_id) { num_attr++; if (attr->acct_session_id_len != 16) { wpa_printf(MSG_DEBUG, "RADIUS DAS: Acct-Session-Id cannot match"); return NULL; } count = 0; for (sta = hapd->sta_list; sta; sta = sta->next) { if (!sta->radius_das_match) continue; os_snprintf(buf, sizeof(buf), "%016llX", (unsigned long long) sta->acct_session_id); if (os_memcmp(attr->acct_session_id, buf, 16) != 0) sta->radius_das_match = 0; else count++; } if (count == 0) { wpa_printf(MSG_DEBUG, "RADIUS DAS: No matches remaining after Acct-Session-Id check"); return NULL; } wpa_printf(MSG_DEBUG, "RADIUS DAS: Acct-Session-Id match"); } if (attr->acct_multi_session_id) { num_attr++; if (attr->acct_multi_session_id_len != 16) { wpa_printf(MSG_DEBUG, "RADIUS DAS: Acct-Multi-Session-Id cannot match"); return NULL; } count = 0; for (sta = hapd->sta_list; sta; sta = sta->next) { if (!sta->radius_das_match) continue; if (!sta->eapol_sm || !sta->eapol_sm->acct_multi_session_id) { sta->radius_das_match = 0; continue; } os_snprintf(buf, sizeof(buf), "%016llX", (unsigned long long) sta->eapol_sm->acct_multi_session_id); if (os_memcmp(attr->acct_multi_session_id, buf, 16) != 0) sta->radius_das_match = 0; else count++; } if (count == 0) { wpa_printf(MSG_DEBUG, "RADIUS DAS: No matches remaining after Acct-Multi-Session-Id check"); return NULL; } wpa_printf(MSG_DEBUG, "RADIUS DAS: Acct-Multi-Session-Id match"); } if (attr->cui) { num_attr++; count = 0; for (sta = hapd->sta_list; sta; sta = sta->next) { struct wpabuf *cui; if (!sta->radius_das_match) continue; cui = ieee802_1x_get_radius_cui(sta->eapol_sm); if (!cui || wpabuf_len(cui) != attr->cui_len || os_memcmp(wpabuf_head(cui), attr->cui, attr->cui_len) != 0) sta->radius_das_match = 0; else count++; } if (count == 0) { wpa_printf(MSG_DEBUG, "RADIUS DAS: No matches remaining after Chargeable-User-Identity check"); return NULL; } wpa_printf(MSG_DEBUG, "RADIUS DAS: Chargeable-User-Identity match"); } if (attr->user_name) { num_attr++; count = 0; for (sta = hapd->sta_list; sta; sta = sta->next) { u8 *identity; size_t identity_len; if (!sta->radius_das_match) continue; identity = ieee802_1x_get_identity(sta->eapol_sm, &identity_len); if (!identity || identity_len != attr->user_name_len || os_memcmp(identity, attr->user_name, identity_len) != 0) sta->radius_das_match = 0; else count++; } if (count == 0) { wpa_printf(MSG_DEBUG, "RADIUS DAS: No matches remaining after User-Name check"); return NULL; } wpa_printf(MSG_DEBUG, "RADIUS DAS: User-Name match"); } if (num_attr == 0) { /* * In theory, we could match all current associations, but it * seems safer to just reject requests that do not include any * session identification attributes. */ wpa_printf(MSG_DEBUG, "RADIUS DAS: No session identification attributes included"); return NULL; } selected = NULL; for (sta = hapd->sta_list; sta; sta = sta->next) { if (sta->radius_das_match) { if (selected) { *multi = 1; return NULL; } selected = sta; } } return selected; } static int hostapd_das_disconnect_pmksa(struct hostapd_data *hapd, struct radius_das_attrs *attr) { if (!hapd->wpa_auth) return -1; return wpa_auth_radius_das_disconnect_pmksa(hapd->wpa_auth, attr); } static enum radius_das_res hostapd_das_disconnect(void *ctx, struct radius_das_attrs *attr) { struct hostapd_data *hapd = ctx; struct sta_info *sta; int multi; if (hostapd_das_nas_mismatch(hapd, attr)) return RADIUS_DAS_NAS_MISMATCH; sta = hostapd_das_find_sta(hapd, attr, &multi); if (sta == NULL) { if (multi) { wpa_printf(MSG_DEBUG, "RADIUS DAS: Multiple sessions match - not supported"); return RADIUS_DAS_MULTI_SESSION_MATCH; } if (hostapd_das_disconnect_pmksa(hapd, attr) == 0) { wpa_printf(MSG_DEBUG, "RADIUS DAS: PMKSA cache entry matched"); return RADIUS_DAS_SUCCESS; } wpa_printf(MSG_DEBUG, "RADIUS DAS: No matching session found"); return RADIUS_DAS_SESSION_NOT_FOUND; } wpa_printf(MSG_DEBUG, "RADIUS DAS: Found a matching session " MACSTR " - disconnecting", MAC2STR(sta->addr)); wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr); hostapd_drv_sta_deauth(hapd, sta->addr, WLAN_REASON_PREV_AUTH_NOT_VALID); ap_sta_deauthenticate(hapd, sta, WLAN_REASON_PREV_AUTH_NOT_VALID); return RADIUS_DAS_SUCCESS; } #endif /* CONFIG_NO_RADIUS */ /** * hostapd_setup_bss - Per-BSS setup (initialization) * @hapd: Pointer to BSS data * @first: Whether this BSS is the first BSS of an interface; -1 = not first, * but interface may exist * * This function is used to initialize all per-BSS data structures and * resources. This gets called in a loop for each BSS when an interface is * initialized. Most of the modules that are initialized here will be * deinitialized in hostapd_cleanup(). */ static int hostapd_setup_bss(struct hostapd_data *hapd, int first) { struct hostapd_bss_config *conf = hapd->conf; u8 ssid[SSID_MAX_LEN + 1]; int ssid_len, set_ssid; char force_ifname[IFNAMSIZ]; u8 if_addr[ETH_ALEN]; int flush_old_stations = 1; wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)", __func__, hapd, conf->iface, first); #ifdef EAP_SERVER_TNC if (conf->tnc && tncs_global_init() < 0) { wpa_printf(MSG_ERROR, "Failed to initialize TNCS"); return -1; } #endif /* EAP_SERVER_TNC */ if (hapd->started) { wpa_printf(MSG_ERROR, "%s: Interface %s was already started", __func__, conf->iface); return -1; } hapd->started = 1; if (!first || first == -1) { u8 *addr = hapd->own_addr; if (!is_zero_ether_addr(conf->bssid)) { /* Allocate the configured BSSID. */ os_memcpy(hapd->own_addr, conf->bssid, ETH_ALEN); if (hostapd_mac_comp(hapd->own_addr, hapd->iface->bss[0]->own_addr) == 0) { wpa_printf(MSG_ERROR, "BSS '%s' may not have " "BSSID set to the MAC address of " "the radio", conf->iface); return -1; } } else if (hapd->iconf->use_driver_iface_addr) { addr = NULL; } else { /* Allocate the next available BSSID. */ do { inc_byte_array(hapd->own_addr, ETH_ALEN); } while (mac_in_conf(hapd->iconf, hapd->own_addr)); } hapd->interface_added = 1; if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS, conf->iface, addr, hapd, &hapd->drv_priv, force_ifname, if_addr, conf->bridge[0] ? conf->bridge : NULL, first == -1)) { wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID=" MACSTR ")", MAC2STR(hapd->own_addr)); hapd->interface_added = 0; return -1; } if (!addr) os_memcpy(hapd->own_addr, if_addr, ETH_ALEN); } if (conf->wmm_enabled < 0) conf->wmm_enabled = hapd->iconf->ieee80211n; #ifdef CONFIG_IEEE80211R if (is_zero_ether_addr(conf->r1_key_holder)) os_memcpy(conf->r1_key_holder, hapd->own_addr, ETH_ALEN); #endif /* CONFIG_IEEE80211R */ #ifdef CONFIG_MESH if (hapd->iface->mconf == NULL) flush_old_stations = 0; #endif /* CONFIG_MESH */ if (flush_old_stations) hostapd_flush_old_stations(hapd, WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_set_privacy(hapd, 0); hostapd_broadcast_wep_clear(hapd); if (hostapd_setup_encryption(conf->iface, hapd)) return -1; /* * Fetch the SSID from the system and use it or, * if one was specified in the config file, verify they * match. */ ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid)); if (ssid_len < 0) { wpa_printf(MSG_ERROR, "Could not read SSID from system"); return -1; } if (conf->ssid.ssid_set) { /* * If SSID is specified in the config file and it differs * from what is being used then force installation of the * new SSID. */ set_ssid = (conf->ssid.ssid_len != (size_t) ssid_len || os_memcmp(conf->ssid.ssid, ssid, ssid_len) != 0); } else { /* * No SSID in the config file; just use the one we got * from the system. */ set_ssid = 0; conf->ssid.ssid_len = ssid_len; os_memcpy(conf->ssid.ssid, ssid, conf->ssid.ssid_len); } if (!hostapd_drv_none(hapd)) { wpa_printf(MSG_ERROR, "Using interface %s with hwaddr " MACSTR " and ssid \"%s\"", conf->iface, MAC2STR(hapd->own_addr), wpa_ssid_txt(conf->ssid.ssid, conf->ssid.ssid_len)); } if (hostapd_setup_wpa_psk(conf)) { wpa_printf(MSG_ERROR, "WPA-PSK setup failed."); return -1; } /* Set SSID for the kernel driver (to be used in beacon and probe * response frames) */ if (set_ssid && hostapd_set_ssid(hapd, conf->ssid.ssid, conf->ssid.ssid_len)) { wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver"); return -1; } if (wpa_debug_level <= MSG_MSGDUMP) conf->radius->msg_dumps = 1; #ifndef CONFIG_NO_RADIUS hapd->radius = radius_client_init(hapd, conf->radius); if (hapd->radius == NULL) { wpa_printf(MSG_ERROR, "RADIUS client initialization failed."); return -1; } if (conf->radius_das_port) { struct radius_das_conf das_conf; os_memset(&das_conf, 0, sizeof(das_conf)); das_conf.port = conf->radius_das_port; das_conf.shared_secret = conf->radius_das_shared_secret; das_conf.shared_secret_len = conf->radius_das_shared_secret_len; das_conf.client_addr = &conf->radius_das_client_addr; das_conf.time_window = conf->radius_das_time_window; das_conf.require_event_timestamp = conf->radius_das_require_event_timestamp; das_conf.require_message_authenticator = conf->radius_das_require_message_authenticator; das_conf.ctx = hapd; das_conf.disconnect = hostapd_das_disconnect; hapd->radius_das = radius_das_init(&das_conf); if (hapd->radius_das == NULL) { wpa_printf(MSG_ERROR, "RADIUS DAS initialization " "failed."); return -1; } } #endif /* CONFIG_NO_RADIUS */ if (hostapd_acl_init(hapd)) { wpa_printf(MSG_ERROR, "ACL initialization failed."); return -1; } if (hostapd_init_wps(hapd, conf)) return -1; if (authsrv_init(hapd) < 0) return -1; if (ieee802_1x_init(hapd)) { wpa_printf(MSG_ERROR, "IEEE 802.1X initialization failed."); return -1; } if ((conf->wpa || conf->osen) && hostapd_setup_wpa(hapd)) return -1; if (accounting_init(hapd)) { wpa_printf(MSG_ERROR, "Accounting initialization failed."); return -1; } if (conf->ieee802_11f && (hapd->iapp = iapp_init(hapd, conf->iapp_iface)) == NULL) { wpa_printf(MSG_ERROR, "IEEE 802.11F (IAPP) initialization " "failed."); return -1; } #ifdef CONFIG_INTERWORKING if (gas_serv_init(hapd)) { wpa_printf(MSG_ERROR, "GAS server initialization failed"); return -1; } if (conf->qos_map_set_len && hostapd_drv_set_qos_map(hapd, conf->qos_map_set, conf->qos_map_set_len)) { wpa_printf(MSG_ERROR, "Failed to initialize QoS Map"); return -1; } #endif /* CONFIG_INTERWORKING */ if (conf->bss_load_update_period && bss_load_update_init(hapd)) { wpa_printf(MSG_ERROR, "BSS Load initialization failed"); return -1; } if (conf->proxy_arp) { if (x_snoop_init(hapd)) { wpa_printf(MSG_ERROR, "Generic snooping infrastructure initialization failed"); return -1; } if (dhcp_snoop_init(hapd)) { wpa_printf(MSG_ERROR, "DHCP snooping initialization failed"); return -1; } if (ndisc_snoop_init(hapd)) { wpa_printf(MSG_ERROR, "Neighbor Discovery snooping initialization failed"); return -1; } } if (!hostapd_drv_none(hapd) && vlan_init(hapd)) { wpa_printf(MSG_ERROR, "VLAN initialization failed."); return -1; } if (!conf->start_disabled && ieee802_11_set_beacon(hapd) < 0) return -1; if (hapd->wpa_auth && wpa_init_keys(hapd->wpa_auth) < 0) return -1; if (hapd->driver && hapd->driver->set_operstate) hapd->driver->set_operstate(hapd->drv_priv, 1); return 0; } static void hostapd_tx_queue_params(struct hostapd_iface *iface) { struct hostapd_data *hapd = iface->bss[0]; int i; struct hostapd_tx_queue_params *p; #ifdef CONFIG_MESH if (iface->mconf == NULL) return; #endif /* CONFIG_MESH */ for (i = 0; i < NUM_TX_QUEUES; i++) { p = &iface->conf->tx_queue[i]; if (hostapd_set_tx_queue_params(hapd, i, p->aifs, p->cwmin, p->cwmax, p->burst)) { wpa_printf(MSG_DEBUG, "Failed to set TX queue " "parameters for queue %d.", i); /* Continue anyway */ } } } static int hostapd_set_acl_list(struct hostapd_data *hapd, struct mac_acl_entry *mac_acl, int n_entries, u8 accept_acl) { struct hostapd_acl_params *acl_params; int i, err; acl_params = os_zalloc(sizeof(*acl_params) + (n_entries * sizeof(acl_params->mac_acl[0]))); if (!acl_params) return -ENOMEM; for (i = 0; i < n_entries; i++) os_memcpy(acl_params->mac_acl[i].addr, mac_acl[i].addr, ETH_ALEN); acl_params->acl_policy = accept_acl; acl_params->num_mac_acl = n_entries; err = hostapd_drv_set_acl(hapd, acl_params); os_free(acl_params); return err; } static void hostapd_set_acl(struct hostapd_data *hapd) { struct hostapd_config *conf = hapd->iconf; int err; u8 accept_acl; if (hapd->iface->drv_max_acl_mac_addrs == 0) return; if (conf->bss[0]->macaddr_acl == DENY_UNLESS_ACCEPTED) { accept_acl = 1; err = hostapd_set_acl_list(hapd, conf->bss[0]->accept_mac, conf->bss[0]->num_accept_mac, accept_acl); if (err) { wpa_printf(MSG_DEBUG, "Failed to set accept acl"); return; } } else if (conf->bss[0]->macaddr_acl == ACCEPT_UNLESS_DENIED) { accept_acl = 0; err = hostapd_set_acl_list(hapd, conf->bss[0]->deny_mac, conf->bss[0]->num_deny_mac, accept_acl); if (err) { wpa_printf(MSG_DEBUG, "Failed to set deny acl"); return; } } } static int start_ctrl_iface_bss(struct hostapd_data *hapd) { if (!hapd->iface->interfaces || !hapd->iface->interfaces->ctrl_iface_init) return 0; if (hapd->iface->interfaces->ctrl_iface_init(hapd)) { wpa_printf(MSG_ERROR, "Failed to setup control interface for %s", hapd->conf->iface); return -1; } return 0; } static int start_ctrl_iface(struct hostapd_iface *iface) { size_t i; if (!iface->interfaces || !iface->interfaces->ctrl_iface_init) return 0; for (i = 0; i < iface->num_bss; i++) { struct hostapd_data *hapd = iface->bss[i]; if (iface->interfaces->ctrl_iface_init(hapd)) { wpa_printf(MSG_ERROR, "Failed to setup control interface for %s", hapd->conf->iface); return -1; } } return 0; } static void channel_list_update_timeout(void *eloop_ctx, void *timeout_ctx) { struct hostapd_iface *iface = eloop_ctx; if (!iface->wait_channel_update) { wpa_printf(MSG_INFO, "Channel list update timeout, but interface was not waiting for it"); return; } /* * It is possible that the existing channel list is acceptable, so try * to proceed. */ wpa_printf(MSG_DEBUG, "Channel list update timeout - try to continue anyway"); setup_interface2(iface); } void hostapd_channel_list_updated(struct hostapd_iface *iface, int initiator) { if (!iface->wait_channel_update || initiator != REGDOM_SET_BY_USER) return; wpa_printf(MSG_DEBUG, "Channel list updated - continue setup"); eloop_cancel_timeout(channel_list_update_timeout, iface, NULL); setup_interface2(iface); } static int setup_interface(struct hostapd_iface *iface) { struct hostapd_data *hapd = iface->bss[0]; size_t i; /* * It is possible that setup_interface() is called after the interface * was disabled etc., in which case driver_ap_teardown is possibly set * to 1. Clear it here so any other key/station deletion, which is not * part of a teardown flow, would also call the relevant driver * callbacks. */ iface->driver_ap_teardown = 0; if (!iface->phy[0]) { const char *phy = hostapd_drv_get_radio_name(hapd); if (phy) { wpa_printf(MSG_DEBUG, "phy: %s", phy); os_strlcpy(iface->phy, phy, sizeof(iface->phy)); } } /* * Make sure that all BSSes get configured with a pointer to the same * driver interface. */ for (i = 1; i < iface->num_bss; i++) { iface->bss[i]->driver = hapd->driver; iface->bss[i]->drv_priv = hapd->drv_priv; } if (hostapd_validate_bssid_configuration(iface)) return -1; /* * Initialize control interfaces early to allow external monitoring of * channel setup operations that may take considerable amount of time * especially for DFS cases. */ if (start_ctrl_iface(iface)) return -1; if (hapd->iconf->country[0] && hapd->iconf->country[1]) { char country[4], previous_country[4]; hostapd_set_state(iface, HAPD_IFACE_COUNTRY_UPDATE); if (hostapd_get_country(hapd, previous_country) < 0) previous_country[0] = '\0'; os_memcpy(country, hapd->iconf->country, 3); country[3] = '\0'; if (hostapd_set_country(hapd, country) < 0) { wpa_printf(MSG_ERROR, "Failed to set country code"); return -1; } wpa_printf(MSG_DEBUG, "Previous country code %s, new country code %s", previous_country, country); if (os_strncmp(previous_country, country, 2) != 0) { wpa_printf(MSG_DEBUG, "Continue interface setup after channel list update"); iface->wait_channel_update = 1; eloop_register_timeout(5, 0, channel_list_update_timeout, iface, NULL); return 0; } } return setup_interface2(iface); } static int setup_interface2(struct hostapd_iface *iface) { iface->wait_channel_update = 0; if (hostapd_get_hw_features(iface)) { /* Not all drivers support this yet, so continue without hw * feature data. */ } else { int ret = hostapd_select_hw_mode(iface); if (ret < 0) { wpa_printf(MSG_ERROR, "Could not select hw_mode and " "channel. (%d)", ret); goto fail; } if (ret == 1) { wpa_printf(MSG_DEBUG, "Interface initialization will be completed in a callback (ACS)"); return 0; } ret = hostapd_check_ht_capab(iface); if (ret < 0) goto fail; if (ret == 1) { wpa_printf(MSG_DEBUG, "Interface initialization will " "be completed in a callback"); return 0; } if (iface->conf->ieee80211h) wpa_printf(MSG_DEBUG, "DFS support is enabled"); } return hostapd_setup_interface_complete(iface, 0); fail: hostapd_set_state(iface, HAPD_IFACE_DISABLED); wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); if (iface->interfaces && iface->interfaces->terminate_on_error) eloop_terminate(); return -1; } #ifdef CONFIG_FST static const u8 * fst_hostapd_get_bssid_cb(void *ctx) { struct hostapd_data *hapd = ctx; return hapd->own_addr; } static void fst_hostapd_get_channel_info_cb(void *ctx, enum hostapd_hw_mode *hw_mode, u8 *channel) { struct hostapd_data *hapd = ctx; *hw_mode = ieee80211_freq_to_chan(hapd->iface->freq, channel); } static void fst_hostapd_set_ies_cb(void *ctx, const struct wpabuf *fst_ies) { struct hostapd_data *hapd = ctx; if (hapd->iface->fst_ies != fst_ies) { hapd->iface->fst_ies = fst_ies; if (ieee802_11_set_beacon(hapd)) wpa_printf(MSG_WARNING, "FST: Cannot set beacon"); } } static int fst_hostapd_send_action_cb(void *ctx, const u8 *da, struct wpabuf *buf) { struct hostapd_data *hapd = ctx; return hostapd_drv_send_action(hapd, hapd->iface->freq, 0, da, wpabuf_head(buf), wpabuf_len(buf)); } static const struct wpabuf * fst_hostapd_get_mb_ie_cb(void *ctx, const u8 *addr) { struct hostapd_data *hapd = ctx; struct sta_info *sta = ap_get_sta(hapd, addr); return sta ? sta->mb_ies : NULL; } static void fst_hostapd_update_mb_ie_cb(void *ctx, const u8 *addr, const u8 *buf, size_t size) { struct hostapd_data *hapd = ctx; struct sta_info *sta = ap_get_sta(hapd, addr); if (sta) { struct mb_ies_info info; if (!mb_ies_info_by_ies(&info, buf, size)) { wpabuf_free(sta->mb_ies); sta->mb_ies = mb_ies_by_info(&info); } } } static const u8 * fst_hostapd_get_sta(struct fst_get_peer_ctx **get_ctx, Boolean mb_only) { struct sta_info *s = (struct sta_info *) *get_ctx; if (mb_only) { for (; s && !s->mb_ies; s = s->next) ; } if (s) { *get_ctx = (struct fst_get_peer_ctx *) s->next; return s->addr; } *get_ctx = NULL; return NULL; } static const u8 * fst_hostapd_get_peer_first(void *ctx, struct fst_get_peer_ctx **get_ctx, Boolean mb_only) { struct hostapd_data *hapd = ctx; *get_ctx = (struct fst_get_peer_ctx *) hapd->sta_list; return fst_hostapd_get_sta(get_ctx, mb_only); } static const u8 * fst_hostapd_get_peer_next(void *ctx, struct fst_get_peer_ctx **get_ctx, Boolean mb_only) { return fst_hostapd_get_sta(get_ctx, mb_only); } void fst_hostapd_fill_iface_obj(struct hostapd_data *hapd, struct fst_wpa_obj *iface_obj) { iface_obj->ctx = hapd; iface_obj->get_bssid = fst_hostapd_get_bssid_cb; iface_obj->get_channel_info = fst_hostapd_get_channel_info_cb; iface_obj->set_ies = fst_hostapd_set_ies_cb; iface_obj->send_action = fst_hostapd_send_action_cb; iface_obj->get_mb_ie = fst_hostapd_get_mb_ie_cb; iface_obj->update_mb_ie = fst_hostapd_update_mb_ie_cb; iface_obj->get_peer_first = fst_hostapd_get_peer_first; iface_obj->get_peer_next = fst_hostapd_get_peer_next; } #endif /* CONFIG_FST */ #ifdef NEED_AP_MLME static enum nr_chan_width hostapd_get_nr_chan_width(struct hostapd_data *hapd, int ht, int vht) { if (!ht && !vht) return NR_CHAN_WIDTH_20; if (!hapd->iconf->secondary_channel) return NR_CHAN_WIDTH_20; if (!vht || hapd->iconf->vht_oper_chwidth == VHT_CHANWIDTH_USE_HT) return NR_CHAN_WIDTH_40; if (hapd->iconf->vht_oper_chwidth == VHT_CHANWIDTH_80MHZ) return NR_CHAN_WIDTH_80; if (hapd->iconf->vht_oper_chwidth == VHT_CHANWIDTH_160MHZ) return NR_CHAN_WIDTH_160; if (hapd->iconf->vht_oper_chwidth == VHT_CHANWIDTH_80P80MHZ) return NR_CHAN_WIDTH_80P80; return NR_CHAN_WIDTH_20; } #endif /* NEED_AP_MLME */ static void hostapd_set_own_neighbor_report(struct hostapd_data *hapd) { #ifdef NEED_AP_MLME u16 capab = hostapd_own_capab_info(hapd); int ht = hapd->iconf->ieee80211n && !hapd->conf->disable_11n; int vht = hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac; struct wpa_ssid_value ssid; u8 channel, op_class; int center_freq1 = 0, center_freq2 = 0; enum nr_chan_width width; u32 bssid_info; struct wpabuf *nr; if (!(hapd->conf->radio_measurements[0] & WLAN_RRM_CAPS_NEIGHBOR_REPORT)) return; bssid_info = 3; /* AP is reachable */ bssid_info |= NEI_REP_BSSID_INFO_SECURITY; /* "same as the AP" */ bssid_info |= NEI_REP_BSSID_INFO_KEY_SCOPE; /* "same as the AP" */ if (capab & WLAN_CAPABILITY_SPECTRUM_MGMT) bssid_info |= NEI_REP_BSSID_INFO_SPECTRUM_MGMT; bssid_info |= NEI_REP_BSSID_INFO_RM; /* RRM is supported */ if (hapd->conf->wmm_enabled) { bssid_info |= NEI_REP_BSSID_INFO_QOS; if (hapd->conf->wmm_uapsd && (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_UAPSD)) bssid_info |= NEI_REP_BSSID_INFO_APSD; } if (ht) { bssid_info |= NEI_REP_BSSID_INFO_HT | NEI_REP_BSSID_INFO_DELAYED_BA; /* VHT bit added in IEEE P802.11-REVmc/D4.3 */ if (vht) bssid_info |= NEI_REP_BSSID_INFO_VHT; } /* TODO: Set NEI_REP_BSSID_INFO_MOBILITY_DOMAIN if MDE is set */ ieee80211_freq_to_channel_ext(hapd->iface->freq, hapd->iconf->secondary_channel, hapd->iconf->vht_oper_chwidth, &op_class, &channel); width = hostapd_get_nr_chan_width(hapd, ht, vht); if (vht) { center_freq1 = ieee80211_chan_to_freq( NULL, op_class, hapd->iconf->vht_oper_centr_freq_seg0_idx); if (width == NR_CHAN_WIDTH_80P80) center_freq2 = ieee80211_chan_to_freq( NULL, op_class, hapd->iconf->vht_oper_centr_freq_seg1_idx); } else if (ht) { center_freq1 = hapd->iface->freq + 10 * hapd->iconf->secondary_channel; } ssid.ssid_len = hapd->conf->ssid.ssid_len; os_memcpy(ssid.ssid, hapd->conf->ssid.ssid, ssid.ssid_len); /* * Neighbor Report element size = BSSID + BSSID info + op_class + chan + * phy type + wide bandwidth channel subelement. */ nr = wpabuf_alloc(ETH_ALEN + 4 + 1 + 1 + 1 + 5); if (!nr) return; wpabuf_put_data(nr, hapd->own_addr, ETH_ALEN); wpabuf_put_le32(nr, bssid_info); wpabuf_put_u8(nr, op_class); wpabuf_put_u8(nr, channel); wpabuf_put_u8(nr, ieee80211_get_phy_type(hapd->iface->freq, ht, vht)); /* * Wide Bandwidth Channel subelement may be needed to allow the * receiving STA to send packets to the AP. See IEEE P802.11-REVmc/D5.0 * Figure 9-301. */ wpabuf_put_u8(nr, WNM_NEIGHBOR_WIDE_BW_CHAN); wpabuf_put_u8(nr, 3); wpabuf_put_u8(nr, width); wpabuf_put_u8(nr, center_freq1); wpabuf_put_u8(nr, center_freq2); hostapd_neighbor_set(hapd, hapd->own_addr, &ssid, nr, hapd->iconf->lci, hapd->iconf->civic); wpabuf_free(nr); #endif /* NEED_AP_MLME */ } static int hostapd_setup_interface_complete_sync(struct hostapd_iface *iface, int err) { struct hostapd_data *hapd = iface->bss[0]; size_t j; u8 *prev_addr; int delay_apply_cfg = 0; int res_dfs_offload = 0; if (err) goto fail; wpa_printf(MSG_DEBUG, "Completing interface initialization"); if (iface->conf->channel) { #ifdef NEED_AP_MLME int res; #endif /* NEED_AP_MLME */ iface->freq = hostapd_hw_get_freq(hapd, iface->conf->channel); wpa_printf(MSG_DEBUG, "Mode: %s Channel: %d " "Frequency: %d MHz", hostapd_hw_mode_txt(iface->conf->hw_mode), iface->conf->channel, iface->freq); #ifdef NEED_AP_MLME /* Handle DFS only if it is not offloaded to the driver */ if (!(iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)) { /* Check DFS */ res = hostapd_handle_dfs(iface); if (res <= 0) { if (res < 0) goto fail; return res; } } else { /* If DFS is offloaded to the driver */ res_dfs_offload = hostapd_handle_dfs_offload(iface); if (res_dfs_offload <= 0) { if (res_dfs_offload < 0) goto fail; } else { wpa_printf(MSG_DEBUG, "Proceed with AP/channel setup"); /* * If this is a DFS channel, move to completing * AP setup. */ if (res_dfs_offload == 1) goto dfs_offload; /* Otherwise fall through. */ } } #endif /* NEED_AP_MLME */ #ifdef CONFIG_MESH if (iface->mconf != NULL) { wpa_printf(MSG_DEBUG, "%s: Mesh configuration will be applied while joining the mesh network", iface->bss[0]->conf->iface); delay_apply_cfg = 1; } #endif /* CONFIG_MESH */ if (!delay_apply_cfg && hostapd_set_freq(hapd, hapd->iconf->hw_mode, iface->freq, hapd->iconf->channel, hapd->iconf->ieee80211n, hapd->iconf->ieee80211ac, hapd->iconf->secondary_channel, hapd->iconf->vht_oper_chwidth, hapd->iconf->vht_oper_centr_freq_seg0_idx, hapd->iconf->vht_oper_centr_freq_seg1_idx)) { wpa_printf(MSG_ERROR, "Could not set channel for " "kernel driver"); goto fail; } } if (iface->current_mode) { if (hostapd_prepare_rates(iface, iface->current_mode)) { wpa_printf(MSG_ERROR, "Failed to prepare rates " "table."); hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Failed to prepare rates table."); goto fail; } } if (hapd->iconf->rts_threshold > -1 && hostapd_set_rts(hapd, hapd->iconf->rts_threshold)) { wpa_printf(MSG_ERROR, "Could not set RTS threshold for " "kernel driver"); goto fail; } if (hapd->iconf->fragm_threshold > -1 && hostapd_set_frag(hapd, hapd->iconf->fragm_threshold)) { wpa_printf(MSG_ERROR, "Could not set fragmentation threshold " "for kernel driver"); goto fail; } prev_addr = hapd->own_addr; for (j = 0; j < iface->num_bss; j++) { hapd = iface->bss[j]; if (j) os_memcpy(hapd->own_addr, prev_addr, ETH_ALEN); if (hostapd_setup_bss(hapd, j == 0)) { do { hapd = iface->bss[j]; hostapd_bss_deinit_no_free(hapd); hostapd_free_hapd_data(hapd); } while (j-- > 0); goto fail; } if (is_zero_ether_addr(hapd->conf->bssid)) prev_addr = hapd->own_addr; } hapd = iface->bss[0]; hostapd_tx_queue_params(iface); ap_list_init(iface); hostapd_set_acl(hapd); if (hostapd_driver_commit(hapd) < 0) { wpa_printf(MSG_ERROR, "%s: Failed to commit driver " "configuration", __func__); goto fail; } /* * WPS UPnP module can be initialized only when the "upnp_iface" is up. * If "interface" and "upnp_iface" are the same (e.g., non-bridge * mode), the interface is up only after driver_commit, so initialize * WPS after driver_commit. */ for (j = 0; j < iface->num_bss; j++) { if (hostapd_init_wps_complete(iface->bss[j])) goto fail; } if ((iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) && !res_dfs_offload) { /* * If freq is DFS, and DFS is offloaded to the driver, then wait * for CAC to complete. */ wpa_printf(MSG_DEBUG, "%s: Wait for CAC to complete", __func__); return res_dfs_offload; } #ifdef NEED_AP_MLME dfs_offload: #endif /* NEED_AP_MLME */ #ifdef CONFIG_FST if (hapd->iconf->fst_cfg.group_id[0]) { struct fst_wpa_obj iface_obj; fst_hostapd_fill_iface_obj(hapd, &iface_obj); iface->fst = fst_attach(hapd->conf->iface, hapd->own_addr, &iface_obj, &hapd->iconf->fst_cfg); if (!iface->fst) { wpa_printf(MSG_ERROR, "Could not attach to FST %s", hapd->iconf->fst_cfg.group_id); goto fail; } } #endif /* CONFIG_FST */ hostapd_set_state(iface, HAPD_IFACE_ENABLED); wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_ENABLED); if (hapd->setup_complete_cb) hapd->setup_complete_cb(hapd->setup_complete_cb_ctx); wpa_printf(MSG_DEBUG, "%s: Setup of interface done.", iface->bss[0]->conf->iface); if (iface->interfaces && iface->interfaces->terminate_on_error > 0) iface->interfaces->terminate_on_error--; for (j = 0; j < iface->num_bss; j++) hostapd_set_own_neighbor_report(iface->bss[j]); return 0; fail: wpa_printf(MSG_ERROR, "Interface initialization failed"); hostapd_set_state(iface, HAPD_IFACE_DISABLED); wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); #ifdef CONFIG_FST if (iface->fst) { fst_detach(iface->fst); iface->fst = NULL; } #endif /* CONFIG_FST */ if (iface->interfaces && iface->interfaces->terminate_on_error) eloop_terminate(); return -1; } /** * hostapd_setup_interface_complete - Complete interface setup * * This function is called when previous steps in the interface setup has been * completed. This can also start operations, e.g., DFS, that will require * additional processing before interface is ready to be enabled. Such * operations will call this function from eloop callbacks when finished. */ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err) { struct hapd_interfaces *interfaces = iface->interfaces; struct hostapd_data *hapd = iface->bss[0]; unsigned int i; int not_ready_in_sync_ifaces = 0; if (!iface->need_to_start_in_sync) return hostapd_setup_interface_complete_sync(iface, err); if (err) { wpa_printf(MSG_ERROR, "Interface initialization failed"); hostapd_set_state(iface, HAPD_IFACE_DISABLED); iface->need_to_start_in_sync = 0; wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); if (interfaces && interfaces->terminate_on_error) eloop_terminate(); return -1; } if (iface->ready_to_start_in_sync) { /* Already in ready and waiting. should never happpen */ return 0; } for (i = 0; i < interfaces->count; i++) { if (interfaces->iface[i]->need_to_start_in_sync && !interfaces->iface[i]->ready_to_start_in_sync) not_ready_in_sync_ifaces++; } /* * Check if this is the last interface, if yes then start all the other * waiting interfaces. If not, add this interface to the waiting list. */ if (not_ready_in_sync_ifaces > 1 && iface->state == HAPD_IFACE_DFS) { /* * If this interface went through CAC, do not synchronize, just * start immediately. */ iface->need_to_start_in_sync = 0; wpa_printf(MSG_INFO, "%s: Finished CAC - bypass sync and start interface", iface->bss[0]->conf->iface); return hostapd_setup_interface_complete_sync(iface, err); } if (not_ready_in_sync_ifaces > 1) { /* need to wait as there are other interfaces still coming up */ iface->ready_to_start_in_sync = 1; wpa_printf(MSG_INFO, "%s: Interface waiting to sync with other interfaces", iface->bss[0]->conf->iface); return 0; } wpa_printf(MSG_INFO, "%s: Last interface to sync - starting all interfaces", iface->bss[0]->conf->iface); iface->need_to_start_in_sync = 0; hostapd_setup_interface_complete_sync(iface, err); for (i = 0; i < interfaces->count; i++) { if (interfaces->iface[i]->need_to_start_in_sync && interfaces->iface[i]->ready_to_start_in_sync) { hostapd_setup_interface_complete_sync( interfaces->iface[i], 0); /* Only once the interfaces are sync started */ interfaces->iface[i]->need_to_start_in_sync = 0; } } return 0; } /** * hostapd_setup_interface - Setup of an interface * @iface: Pointer to interface data. * Returns: 0 on success, -1 on failure * * Initializes the driver interface, validates the configuration, * and sets driver parameters based on the configuration. * Flushes old stations, sets the channel, encryption, * beacons, and WDS links based on the configuration. * * If interface setup requires more time, e.g., to perform HT co-ex scans, ACS, * or DFS operations, this function returns 0 before such operations have been * completed. The pending operations are registered into eloop and will be * completed from eloop callbacks. Those callbacks end up calling * hostapd_setup_interface_complete() once setup has been completed. */ int hostapd_setup_interface(struct hostapd_iface *iface) { int ret; ret = setup_interface(iface); if (ret) { wpa_printf(MSG_ERROR, "%s: Unable to setup interface.", iface->bss[0]->conf->iface); return -1; } return 0; } /** * hostapd_alloc_bss_data - Allocate and initialize per-BSS data * @hapd_iface: Pointer to interface data * @conf: Pointer to per-interface configuration * @bss: Pointer to per-BSS configuration for this BSS * Returns: Pointer to allocated BSS data * * This function is used to allocate per-BSS data structure. This data will be * freed after hostapd_cleanup() is called for it during interface * deinitialization. */ struct hostapd_data * hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, struct hostapd_config *conf, struct hostapd_bss_config *bss) { struct hostapd_data *hapd; hapd = os_zalloc(sizeof(*hapd)); if (hapd == NULL) return NULL; hapd->new_assoc_sta_cb = hostapd_new_assoc_sta; hapd->iconf = conf; hapd->conf = bss; hapd->iface = hapd_iface; hapd->driver = hapd->iconf->driver; hapd->ctrl_sock = -1; dl_list_init(&hapd->ctrl_dst); dl_list_init(&hapd->nr_db); return hapd; } static void hostapd_bss_deinit(struct hostapd_data *hapd) { if (!hapd) return; wpa_printf(MSG_DEBUG, "%s: deinit bss %s", __func__, hapd->conf->iface); hostapd_bss_deinit_no_free(hapd); wpa_msg(hapd->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); hostapd_cleanup(hapd); } void hostapd_interface_deinit(struct hostapd_iface *iface) { int j; wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface); if (iface == NULL) return; hostapd_set_state(iface, HAPD_IFACE_DISABLED); #ifdef CONFIG_IEEE80211N #ifdef NEED_AP_MLME hostapd_stop_setup_timers(iface); eloop_cancel_timeout(ap_ht2040_timeout, iface, NULL); #endif /* NEED_AP_MLME */ #endif /* CONFIG_IEEE80211N */ eloop_cancel_timeout(channel_list_update_timeout, iface, NULL); iface->wait_channel_update = 0; #ifdef CONFIG_FST if (iface->fst) { fst_detach(iface->fst); iface->fst = NULL; } #endif /* CONFIG_FST */ for (j = iface->num_bss - 1; j >= 0; j--) { if (!iface->bss) break; hostapd_bss_deinit(iface->bss[j]); } } void hostapd_interface_free(struct hostapd_iface *iface) { size_t j; wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface); for (j = 0; j < iface->num_bss; j++) { if (!iface->bss) break; wpa_printf(MSG_DEBUG, "%s: free hapd %p", __func__, iface->bss[j]); os_free(iface->bss[j]); } hostapd_cleanup_iface(iface); } struct hostapd_iface * hostapd_alloc_iface(void) { struct hostapd_iface *hapd_iface; hapd_iface = os_zalloc(sizeof(*hapd_iface)); if (!hapd_iface) return NULL; dl_list_init(&hapd_iface->sta_seen); return hapd_iface; } /** * hostapd_init - Allocate and initialize per-interface data * @config_file: Path to the configuration file * Returns: Pointer to the allocated interface data or %NULL on failure * * This function is used to allocate main data structures for per-interface * data. The allocated data buffer will be freed by calling * hostapd_cleanup_iface(). */ struct hostapd_iface * hostapd_init(struct hapd_interfaces *interfaces, const char *config_file) { struct hostapd_iface *hapd_iface = NULL; struct hostapd_config *conf = NULL; struct hostapd_data *hapd; size_t i; hapd_iface = hostapd_alloc_iface(); if (hapd_iface == NULL) goto fail; hapd_iface->config_fname = os_strdup(config_file); if (hapd_iface->config_fname == NULL) goto fail; conf = interfaces->config_read_cb(hapd_iface->config_fname); if (conf == NULL) goto fail; hapd_iface->conf = conf; hapd_iface->num_bss = conf->num_bss; hapd_iface->bss = os_calloc(conf->num_bss, sizeof(struct hostapd_data *)); if (hapd_iface->bss == NULL) goto fail; for (i = 0; i < conf->num_bss; i++) { hapd = hapd_iface->bss[i] = hostapd_alloc_bss_data(hapd_iface, conf, conf->bss[i]); if (hapd == NULL) goto fail; hapd->msg_ctx = hapd; } #ifdef CONFIG_KARMA_ATTACK g_hapd_data = hapd_iface->bss[0]; #endif return hapd_iface; fail: wpa_printf(MSG_ERROR, "Failed to set up interface with %s", config_file); if (conf) hostapd_config_free(conf); if (hapd_iface) { os_free(hapd_iface->config_fname); os_free(hapd_iface->bss); wpa_printf(MSG_DEBUG, "%s: free iface %p", __func__, hapd_iface); os_free(hapd_iface); } return NULL; } static int ifname_in_use(struct hapd_interfaces *interfaces, const char *ifname) { size_t i, j; for (i = 0; i < interfaces->count; i++) { struct hostapd_iface *iface = interfaces->iface[i]; for (j = 0; j < iface->num_bss; j++) { struct hostapd_data *hapd = iface->bss[j]; if (os_strcmp(ifname, hapd->conf->iface) == 0) return 1; } } return 0; } /** * hostapd_interface_init_bss - Read configuration file and init BSS data * * This function is used to parse configuration file for a BSS. This BSS is * added to an existing interface sharing the same radio (if any) or a new * interface is created if this is the first interface on a radio. This * allocate memory for the BSS. No actual driver operations are started. * * This is similar to hostapd_interface_init(), but for a case where the * configuration is used to add a single BSS instead of all BSSes for a radio. */ struct hostapd_iface * hostapd_interface_init_bss(struct hapd_interfaces *interfaces, const char *phy, const char *config_fname, int debug) { struct hostapd_iface *new_iface = NULL, *iface = NULL; struct hostapd_data *hapd; int k; size_t i, bss_idx; if (!phy || !*phy) return NULL; for (i = 0; i < interfaces->count; i++) { if (os_strcmp(interfaces->iface[i]->phy, phy) == 0) { iface = interfaces->iface[i]; break; } } wpa_printf(MSG_INFO, "Configuration file: %s (phy %s)%s", config_fname, phy, iface ? "" : " --> new PHY"); if (iface) { struct hostapd_config *conf; struct hostapd_bss_config **tmp_conf; struct hostapd_data **tmp_bss; struct hostapd_bss_config *bss; const char *ifname; /* Add new BSS to existing iface */ conf = interfaces->config_read_cb(config_fname); if (conf == NULL) return NULL; if (conf->num_bss > 1) { wpa_printf(MSG_ERROR, "Multiple BSSes specified in BSS-config"); hostapd_config_free(conf); return NULL; } ifname = conf->bss[0]->iface; if (ifname[0] != '\0' && ifname_in_use(interfaces, ifname)) { wpa_printf(MSG_ERROR, "Interface name %s already in use", ifname); hostapd_config_free(conf); return NULL; } tmp_conf = os_realloc_array( iface->conf->bss, iface->conf->num_bss + 1, sizeof(struct hostapd_bss_config *)); tmp_bss = os_realloc_array(iface->bss, iface->num_bss + 1, sizeof(struct hostapd_data *)); if (tmp_bss) iface->bss = tmp_bss; if (tmp_conf) { iface->conf->bss = tmp_conf; iface->conf->last_bss = tmp_conf[0]; } if (tmp_bss == NULL || tmp_conf == NULL) { hostapd_config_free(conf); return NULL; } bss = iface->conf->bss[iface->conf->num_bss] = conf->bss[0]; iface->conf->num_bss++; hapd = hostapd_alloc_bss_data(iface, iface->conf, bss); if (hapd == NULL) { iface->conf->num_bss--; hostapd_config_free(conf); return NULL; } iface->conf->last_bss = bss; iface->bss[iface->num_bss] = hapd; hapd->msg_ctx = hapd; bss_idx = iface->num_bss++; conf->num_bss--; conf->bss[0] = NULL; hostapd_config_free(conf); } else { /* Add a new iface with the first BSS */ new_iface = iface = hostapd_init(interfaces, config_fname); if (!iface) return NULL; os_strlcpy(iface->phy, phy, sizeof(iface->phy)); iface->interfaces = interfaces; bss_idx = 0; } for (k = 0; k < debug; k++) { if (iface->bss[bss_idx]->conf->logger_stdout_level > 0) iface->bss[bss_idx]->conf->logger_stdout_level--; } if (iface->conf->bss[bss_idx]->iface[0] == '\0' && !hostapd_drv_none(iface->bss[bss_idx])) { wpa_printf(MSG_ERROR, "Interface name not specified in %s", config_fname); if (new_iface) hostapd_interface_deinit_free(new_iface); return NULL; } return iface; } void hostapd_interface_deinit_free(struct hostapd_iface *iface) { const struct wpa_driver_ops *driver; void *drv_priv; wpa_printf(MSG_DEBUG, "%s(%p)", __func__, iface); if (iface == NULL) return; wpa_printf(MSG_DEBUG, "%s: num_bss=%u conf->num_bss=%u", __func__, (unsigned int) iface->num_bss, (unsigned int) iface->conf->num_bss); driver = iface->bss[0]->driver; drv_priv = iface->bss[0]->drv_priv; hostapd_interface_deinit(iface); wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", __func__, driver, drv_priv); if (driver && driver->hapd_deinit && drv_priv) { driver->hapd_deinit(drv_priv); iface->bss[0]->drv_priv = NULL; } hostapd_interface_free(iface); } static void hostapd_deinit_driver(const struct wpa_driver_ops *driver, void *drv_priv, struct hostapd_iface *hapd_iface) { size_t j; wpa_printf(MSG_DEBUG, "%s: driver=%p drv_priv=%p -> hapd_deinit", __func__, driver, drv_priv); if (driver && driver->hapd_deinit && drv_priv) { driver->hapd_deinit(drv_priv); for (j = 0; j < hapd_iface->num_bss; j++) { wpa_printf(MSG_DEBUG, "%s:bss[%d]->drv_priv=%p", __func__, (int) j, hapd_iface->bss[j]->drv_priv); if (hapd_iface->bss[j]->drv_priv == drv_priv) hapd_iface->bss[j]->drv_priv = NULL; } } } int hostapd_enable_iface(struct hostapd_iface *hapd_iface) { size_t j; if (hapd_iface->bss[0]->drv_priv != NULL) { wpa_printf(MSG_ERROR, "Interface %s already enabled", hapd_iface->conf->bss[0]->iface); return -1; } wpa_printf(MSG_DEBUG, "Enable interface %s", hapd_iface->conf->bss[0]->iface); for (j = 0; j < hapd_iface->num_bss; j++) hostapd_set_security_params(hapd_iface->conf->bss[j], 1); if (hostapd_config_check(hapd_iface->conf, 1) < 0) { wpa_printf(MSG_INFO, "Invalid configuration - cannot enable"); return -1; } if (hapd_iface->interfaces == NULL || hapd_iface->interfaces->driver_init == NULL || hapd_iface->interfaces->driver_init(hapd_iface)) return -1; if (hostapd_setup_interface(hapd_iface)) { hostapd_deinit_driver(hapd_iface->bss[0]->driver, hapd_iface->bss[0]->drv_priv, hapd_iface); return -1; } return 0; } int hostapd_reload_iface(struct hostapd_iface *hapd_iface) { size_t j; wpa_printf(MSG_DEBUG, "Reload interface %s", hapd_iface->conf->bss[0]->iface); for (j = 0; j < hapd_iface->num_bss; j++) hostapd_set_security_params(hapd_iface->conf->bss[j], 1); if (hostapd_config_check(hapd_iface->conf, 1) < 0) { wpa_printf(MSG_ERROR, "Updated configuration is invalid"); return -1; } hostapd_clear_old(hapd_iface); for (j = 0; j < hapd_iface->num_bss; j++) hostapd_reload_bss(hapd_iface->bss[j]); return 0; } int hostapd_disable_iface(struct hostapd_iface *hapd_iface) { size_t j; const struct wpa_driver_ops *driver; void *drv_priv; if (hapd_iface == NULL) return -1; if (hapd_iface->bss[0]->drv_priv == NULL) { wpa_printf(MSG_INFO, "Interface %s already disabled", hapd_iface->conf->bss[0]->iface); return -1; } wpa_msg(hapd_iface->bss[0]->msg_ctx, MSG_INFO, AP_EVENT_DISABLED); driver = hapd_iface->bss[0]->driver; drv_priv = hapd_iface->bss[0]->drv_priv; hapd_iface->driver_ap_teardown = !!(hapd_iface->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT); /* same as hostapd_interface_deinit without deinitializing ctrl-iface */ for (j = 0; j < hapd_iface->num_bss; j++) { struct hostapd_data *hapd = hapd_iface->bss[j]; hostapd_bss_deinit_no_free(hapd); hostapd_free_hapd_data(hapd); } hostapd_deinit_driver(driver, drv_priv, hapd_iface); /* From hostapd_cleanup_iface: These were initialized in * hostapd_setup_interface and hostapd_setup_interface_complete */ hostapd_cleanup_iface_partial(hapd_iface); wpa_printf(MSG_DEBUG, "Interface %s disabled", hapd_iface->bss[0]->conf->iface); hostapd_set_state(hapd_iface, HAPD_IFACE_DISABLED); return 0; } static struct hostapd_iface * hostapd_iface_alloc(struct hapd_interfaces *interfaces) { struct hostapd_iface **iface, *hapd_iface; iface = os_realloc_array(interfaces->iface, interfaces->count + 1, sizeof(struct hostapd_iface *)); if (iface == NULL) return NULL; interfaces->iface = iface; hapd_iface = interfaces->iface[interfaces->count] = hostapd_alloc_iface(); if (hapd_iface == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory for " "the interface", __func__); return NULL; } interfaces->count++; hapd_iface->interfaces = interfaces; return hapd_iface; } static struct hostapd_config * hostapd_config_alloc(struct hapd_interfaces *interfaces, const char *ifname, const char *ctrl_iface, const char *driver) { struct hostapd_bss_config *bss; struct hostapd_config *conf; /* Allocates memory for bss and conf */ conf = hostapd_config_defaults(); if (conf == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory for " "configuration", __func__); return NULL; } if (driver) { int j; for (j = 0; wpa_drivers[j]; j++) { if (os_strcmp(driver, wpa_drivers[j]->name) == 0) { conf->driver = wpa_drivers[j]; goto skip; } } wpa_printf(MSG_ERROR, "Invalid/unknown driver '%s' - registering the default driver", driver); } conf->driver = wpa_drivers[0]; if (conf->driver == NULL) { wpa_printf(MSG_ERROR, "No driver wrappers registered!"); hostapd_config_free(conf); return NULL; } skip: bss = conf->last_bss = conf->bss[0]; os_strlcpy(bss->iface, ifname, sizeof(bss->iface)); bss->ctrl_interface = os_strdup(ctrl_iface); if (bss->ctrl_interface == NULL) { hostapd_config_free(conf); return NULL; } /* Reading configuration file skipped, will be done in SET! * From reading the configuration till the end has to be done in * SET */ return conf; } static int hostapd_data_alloc(struct hostapd_iface *hapd_iface, struct hostapd_config *conf) { size_t i; struct hostapd_data *hapd; hapd_iface->bss = os_calloc(conf->num_bss, sizeof(struct hostapd_data *)); if (hapd_iface->bss == NULL) return -1; for (i = 0; i < conf->num_bss; i++) { hapd = hapd_iface->bss[i] = hostapd_alloc_bss_data(hapd_iface, conf, conf->bss[i]); if (hapd == NULL) { while (i > 0) { i--; os_free(hapd_iface->bss[i]); hapd_iface->bss[i] = NULL; } os_free(hapd_iface->bss); hapd_iface->bss = NULL; return -1; } hapd->msg_ctx = hapd; } hapd_iface->conf = conf; hapd_iface->num_bss = conf->num_bss; return 0; } int hostapd_add_iface(struct hapd_interfaces *interfaces, char *buf) { struct hostapd_config *conf = NULL; struct hostapd_iface *hapd_iface = NULL, *new_iface = NULL; struct hostapd_data *hapd; char *ptr; size_t i, j; const char *conf_file = NULL, *phy_name = NULL; if (os_strncmp(buf, "bss_config=", 11) == 0) { char *pos; phy_name = buf + 11; pos = os_strchr(phy_name, ':'); if (!pos) return -1; *pos++ = '\0'; conf_file = pos; if (!os_strlen(conf_file)) return -1; hapd_iface = hostapd_interface_init_bss(interfaces, phy_name, conf_file, 0); if (!hapd_iface) return -1; for (j = 0; j < interfaces->count; j++) { if (interfaces->iface[j] == hapd_iface) break; } if (j == interfaces->count) { struct hostapd_iface **tmp; tmp = os_realloc_array(interfaces->iface, interfaces->count + 1, sizeof(struct hostapd_iface *)); if (!tmp) { hostapd_interface_deinit_free(hapd_iface); return -1; } interfaces->iface = tmp; interfaces->iface[interfaces->count++] = hapd_iface; new_iface = hapd_iface; } if (new_iface) { if (interfaces->driver_init(hapd_iface)) goto fail; if (hostapd_setup_interface(hapd_iface)) { hostapd_deinit_driver( hapd_iface->bss[0]->driver, hapd_iface->bss[0]->drv_priv, hapd_iface); goto fail; } } else { /* Assign new BSS with bss[0]'s driver info */ hapd = hapd_iface->bss[hapd_iface->num_bss - 1]; hapd->driver = hapd_iface->bss[0]->driver; hapd->drv_priv = hapd_iface->bss[0]->drv_priv; os_memcpy(hapd->own_addr, hapd_iface->bss[0]->own_addr, ETH_ALEN); if (start_ctrl_iface_bss(hapd) < 0 || (hapd_iface->state == HAPD_IFACE_ENABLED && hostapd_setup_bss(hapd, -1))) { hostapd_cleanup(hapd); hapd_iface->bss[hapd_iface->num_bss - 1] = NULL; hapd_iface->conf->num_bss--; hapd_iface->num_bss--; wpa_printf(MSG_DEBUG, "%s: free hapd %p %s", __func__, hapd, hapd->conf->iface); hostapd_config_free_bss(hapd->conf); hapd->conf = NULL; os_free(hapd); return -1; } } return 0; } ptr = os_strchr(buf, ' '); if (ptr == NULL) return -1; *ptr++ = '\0'; if (os_strncmp(ptr, "config=", 7) == 0) conf_file = ptr + 7; for (i = 0; i < interfaces->count; i++) { if (!os_strcmp(interfaces->iface[i]->conf->bss[0]->iface, buf)) { wpa_printf(MSG_INFO, "Cannot add interface - it " "already exists"); return -1; } } hapd_iface = hostapd_iface_alloc(interfaces); if (hapd_iface == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory " "for interface", __func__); goto fail; } new_iface = hapd_iface; if (conf_file && interfaces->config_read_cb) { conf = interfaces->config_read_cb(conf_file); if (conf && conf->bss) os_strlcpy(conf->bss[0]->iface, buf, sizeof(conf->bss[0]->iface)); } else { char *driver = os_strchr(ptr, ' '); if (driver) *driver++ = '\0'; conf = hostapd_config_alloc(interfaces, buf, ptr, driver); } if (conf == NULL || conf->bss == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory " "for configuration", __func__); goto fail; } if (hostapd_data_alloc(hapd_iface, conf) < 0) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory " "for hostapd", __func__); goto fail; } conf = NULL; if (start_ctrl_iface(hapd_iface) < 0) goto fail; wpa_printf(MSG_INFO, "Add interface '%s'", hapd_iface->conf->bss[0]->iface); return 0; fail: if (conf) hostapd_config_free(conf); if (hapd_iface) { if (hapd_iface->bss) { for (i = 0; i < hapd_iface->num_bss; i++) { hapd = hapd_iface->bss[i]; if (!hapd) continue; if (hapd_iface->interfaces && hapd_iface->interfaces->ctrl_iface_deinit) hapd_iface->interfaces-> ctrl_iface_deinit(hapd); wpa_printf(MSG_DEBUG, "%s: free hapd %p (%s)", __func__, hapd_iface->bss[i], hapd->conf->iface); hostapd_cleanup(hapd); os_free(hapd); hapd_iface->bss[i] = NULL; } os_free(hapd_iface->bss); hapd_iface->bss = NULL; } if (new_iface) { interfaces->count--; interfaces->iface[interfaces->count] = NULL; } hostapd_cleanup_iface(hapd_iface); } return -1; } static int hostapd_remove_bss(struct hostapd_iface *iface, unsigned int idx) { size_t i; wpa_printf(MSG_INFO, "Remove BSS '%s'", iface->conf->bss[idx]->iface); /* Remove hostapd_data only if it has already been initialized */ if (idx < iface->num_bss) { struct hostapd_data *hapd = iface->bss[idx]; hostapd_bss_deinit(hapd); wpa_printf(MSG_DEBUG, "%s: free hapd %p (%s)", __func__, hapd, hapd->conf->iface); hostapd_config_free_bss(hapd->conf); hapd->conf = NULL; os_free(hapd); iface->num_bss--; for (i = idx; i < iface->num_bss; i++) iface->bss[i] = iface->bss[i + 1]; } else { hostapd_config_free_bss(iface->conf->bss[idx]); iface->conf->bss[idx] = NULL; } iface->conf->num_bss--; for (i = idx; i < iface->conf->num_bss; i++) iface->conf->bss[i] = iface->conf->bss[i + 1]; return 0; } int hostapd_remove_iface(struct hapd_interfaces *interfaces, char *buf) { struct hostapd_iface *hapd_iface; size_t i, j, k = 0; for (i = 0; i < interfaces->count; i++) { hapd_iface = interfaces->iface[i]; if (hapd_iface == NULL) return -1; if (!os_strcmp(hapd_iface->conf->bss[0]->iface, buf)) { wpa_printf(MSG_INFO, "Remove interface '%s'", buf); hapd_iface->driver_ap_teardown = !!(hapd_iface->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT); hostapd_interface_deinit_free(hapd_iface); k = i; while (k < (interfaces->count - 1)) { interfaces->iface[k] = interfaces->iface[k + 1]; k++; } interfaces->count--; return 0; } for (j = 0; j < hapd_iface->conf->num_bss; j++) { if (!os_strcmp(hapd_iface->conf->bss[j]->iface, buf)) { hapd_iface->driver_ap_teardown = !(hapd_iface->drv_flags & WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT); return hostapd_remove_bss(hapd_iface, j); } } } return -1; } /** * hostapd_new_assoc_sta - Notify that a new station associated with the AP * @hapd: Pointer to BSS data * @sta: Pointer to the associated STA data * @reassoc: 1 to indicate this was a re-association; 0 = first association * * This function will be called whenever a station associates with the AP. It * can be called from ieee802_11.c for drivers that export MLME to hostapd and * from drv_callbacks.c based on driver events for drivers that take care of * management frames (IEEE 802.11 authentication and association) internally. */ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta, int reassoc) { if (hapd->tkip_countermeasures) { hostapd_drv_sta_deauth(hapd, sta->addr, WLAN_REASON_MICHAEL_MIC_FAILURE); return; } hostapd_prune_associations(hapd, sta->addr); ap_sta_clear_disconnect_timeouts(hapd, sta); /* IEEE 802.11F (IAPP) */ if (hapd->conf->ieee802_11f) iapp_new_station(hapd->iapp, sta); #ifdef CONFIG_P2P if (sta->p2p_ie == NULL && !sta->no_p2p_set) { sta->no_p2p_set = 1; hapd->num_sta_no_p2p++; if (hapd->num_sta_no_p2p == 1) hostapd_p2p_non_p2p_sta_connected(hapd); } #endif /* CONFIG_P2P */ /* Start accounting here, if IEEE 802.1X and WPA are not used. * IEEE 802.1X/WPA code will start accounting after the station has * been authorized. */ if (!hapd->conf->ieee802_1x && !hapd->conf->wpa && !hapd->conf->osen) { ap_sta_set_authorized(hapd, sta, 1); os_get_reltime(&sta->connected_time); accounting_sta_start(hapd, sta); } /* Start IEEE 802.1X authentication process for new stations */ ieee802_1x_new_station(hapd, sta); if (reassoc) { if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) wpa_auth_sm_event(sta->wpa_sm, WPA_REAUTH); } else wpa_auth_sta_associated(hapd->wpa_auth, sta->wpa_sm); if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_INACTIVITY_TIMER)) { wpa_printf(MSG_DEBUG, "%s: %s: reschedule ap_handle_timer timeout for " MACSTR " (%d seconds - ap_max_inactivity)", hapd->conf->iface, __func__, MAC2STR(sta->addr), hapd->conf->ap_max_inactivity); eloop_cancel_timeout(ap_handle_timer, hapd, sta); eloop_register_timeout(hapd->conf->ap_max_inactivity, 0, ap_handle_timer, hapd, sta); } } const char * hostapd_state_text(enum hostapd_iface_state s) { switch (s) { case HAPD_IFACE_UNINITIALIZED: return "UNINITIALIZED"; case HAPD_IFACE_DISABLED: return "DISABLED"; case HAPD_IFACE_COUNTRY_UPDATE: return "COUNTRY_UPDATE"; case HAPD_IFACE_ACS: return "ACS"; case HAPD_IFACE_HT_SCAN: return "HT_SCAN"; case HAPD_IFACE_DFS: return "DFS"; case HAPD_IFACE_ENABLED: return "ENABLED"; } return "UNKNOWN"; } void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s) { wpa_printf(MSG_INFO, "%s: interface state %s->%s", iface->conf ? iface->conf->bss[0]->iface : "N/A", hostapd_state_text(iface->state), hostapd_state_text(s)); iface->state = s; } int hostapd_csa_in_progress(struct hostapd_iface *iface) { unsigned int i; for (i = 0; i < iface->num_bss; i++) if (iface->bss[i]->csa_in_progress) return 1; return 0; } #ifdef NEED_AP_MLME static void free_beacon_data(struct beacon_data *beacon) { os_free(beacon->head); beacon->head = NULL; os_free(beacon->tail); beacon->tail = NULL; os_free(beacon->probe_resp); beacon->probe_resp = NULL; os_free(beacon->beacon_ies); beacon->beacon_ies = NULL; os_free(beacon->proberesp_ies); beacon->proberesp_ies = NULL; os_free(beacon->assocresp_ies); beacon->assocresp_ies = NULL; } static int hostapd_build_beacon_data(struct hostapd_data *hapd, struct beacon_data *beacon) { struct wpabuf *beacon_extra, *proberesp_extra, *assocresp_extra; struct wpa_driver_ap_params params; int ret; os_memset(beacon, 0, sizeof(*beacon)); ret = ieee802_11_build_ap_params(hapd, &params); if (ret < 0) return ret; ret = hostapd_build_ap_extra_ies(hapd, &beacon_extra, &proberesp_extra, &assocresp_extra); if (ret) goto free_ap_params; ret = -1; beacon->head = os_malloc(params.head_len); if (!beacon->head) goto free_ap_extra_ies; os_memcpy(beacon->head, params.head, params.head_len); beacon->head_len = params.head_len; beacon->tail = os_malloc(params.tail_len); if (!beacon->tail) goto free_beacon; os_memcpy(beacon->tail, params.tail, params.tail_len); beacon->tail_len = params.tail_len; if (params.proberesp != NULL) { beacon->probe_resp = os_malloc(params.proberesp_len); if (!beacon->probe_resp) goto free_beacon; os_memcpy(beacon->probe_resp, params.proberesp, params.proberesp_len); beacon->probe_resp_len = params.proberesp_len; } /* copy the extra ies */ if (beacon_extra) { beacon->beacon_ies = os_malloc(wpabuf_len(beacon_extra)); if (!beacon->beacon_ies) goto free_beacon; os_memcpy(beacon->beacon_ies, beacon_extra->buf, wpabuf_len(beacon_extra)); beacon->beacon_ies_len = wpabuf_len(beacon_extra); } if (proberesp_extra) { beacon->proberesp_ies = os_malloc(wpabuf_len(proberesp_extra)); if (!beacon->proberesp_ies) goto free_beacon; os_memcpy(beacon->proberesp_ies, proberesp_extra->buf, wpabuf_len(proberesp_extra)); beacon->proberesp_ies_len = wpabuf_len(proberesp_extra); } if (assocresp_extra) { beacon->assocresp_ies = os_malloc(wpabuf_len(assocresp_extra)); if (!beacon->assocresp_ies) goto free_beacon; os_memcpy(beacon->assocresp_ies, assocresp_extra->buf, wpabuf_len(assocresp_extra)); beacon->assocresp_ies_len = wpabuf_len(assocresp_extra); } ret = 0; free_beacon: /* if the function fails, the caller should not free beacon data */ if (ret) free_beacon_data(beacon); free_ap_extra_ies: hostapd_free_ap_extra_ies(hapd, beacon_extra, proberesp_extra, assocresp_extra); free_ap_params: ieee802_11_free_ap_params(&params); return ret; } /* * TODO: This flow currently supports only changing channel and width within * the same hw_mode. Any other changes to MAC parameters or provided settings * are not supported. */ static int hostapd_change_config_freq(struct hostapd_data *hapd, struct hostapd_config *conf, struct hostapd_freq_params *params, struct hostapd_freq_params *old_params) { int channel; if (!params->channel) { /* check if the new channel is supported by hw */ params->channel = hostapd_hw_get_channel(hapd, params->freq); } channel = params->channel; if (!channel) return -1; /* if a pointer to old_params is provided we save previous state */ if (old_params && hostapd_set_freq_params(old_params, conf->hw_mode, hostapd_hw_get_freq(hapd, conf->channel), conf->channel, conf->ieee80211n, conf->ieee80211ac, conf->secondary_channel, conf->vht_oper_chwidth, conf->vht_oper_centr_freq_seg0_idx, conf->vht_oper_centr_freq_seg1_idx, conf->vht_capab)) return -1; switch (params->bandwidth) { case 0: case 20: case 40: conf->vht_oper_chwidth = VHT_CHANWIDTH_USE_HT; break; case 80: if (params->center_freq2) conf->vht_oper_chwidth = VHT_CHANWIDTH_80P80MHZ; else conf->vht_oper_chwidth = VHT_CHANWIDTH_80MHZ; break; case 160: conf->vht_oper_chwidth = VHT_CHANWIDTH_160MHZ; break; default: return -1; } conf->channel = channel; conf->ieee80211n = params->ht_enabled; conf->secondary_channel = params->sec_channel_offset; ieee80211_freq_to_chan(params->center_freq1, &conf->vht_oper_centr_freq_seg0_idx); ieee80211_freq_to_chan(params->center_freq2, &conf->vht_oper_centr_freq_seg1_idx); /* TODO: maybe call here hostapd_config_check here? */ return 0; } static int hostapd_fill_csa_settings(struct hostapd_data *hapd, struct csa_settings *settings) { struct hostapd_iface *iface = hapd->iface; struct hostapd_freq_params old_freq; int ret; u8 chan, vht_bandwidth; os_memset(&old_freq, 0, sizeof(old_freq)); if (!iface || !iface->freq || hapd->csa_in_progress) return -1; switch (settings->freq_params.bandwidth) { case 80: if (settings->freq_params.center_freq2) vht_bandwidth = VHT_CHANWIDTH_80P80MHZ; else vht_bandwidth = VHT_CHANWIDTH_80MHZ; break; case 160: vht_bandwidth = VHT_CHANWIDTH_160MHZ; break; default: vht_bandwidth = VHT_CHANWIDTH_USE_HT; break; } if (ieee80211_freq_to_channel_ext( settings->freq_params.freq, settings->freq_params.sec_channel_offset, vht_bandwidth, &hapd->iface->cs_oper_class, &chan) == NUM_HOSTAPD_MODES) { wpa_printf(MSG_DEBUG, "invalid frequency for channel switch (freq=%d, sec_channel_offset=%d, vht_enabled=%d)", settings->freq_params.freq, settings->freq_params.sec_channel_offset, settings->freq_params.vht_enabled); return -1; } settings->freq_params.channel = chan; ret = hostapd_change_config_freq(iface->bss[0], iface->conf, &settings->freq_params, &old_freq); if (ret) return ret; ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); /* change back the configuration */ hostapd_change_config_freq(iface->bss[0], iface->conf, &old_freq, NULL); if (ret) return ret; /* set channel switch parameters for csa ie */ hapd->cs_freq_params = settings->freq_params; hapd->cs_count = settings->cs_count; hapd->cs_block_tx = settings->block_tx; ret = hostapd_build_beacon_data(hapd, &settings->beacon_csa); if (ret) { free_beacon_data(&settings->beacon_after); return ret; } settings->counter_offset_beacon[0] = hapd->cs_c_off_beacon; settings->counter_offset_presp[0] = hapd->cs_c_off_proberesp; settings->counter_offset_beacon[1] = hapd->cs_c_off_ecsa_beacon; settings->counter_offset_presp[1] = hapd->cs_c_off_ecsa_proberesp; return 0; } void hostapd_cleanup_cs_params(struct hostapd_data *hapd) { os_memset(&hapd->cs_freq_params, 0, sizeof(hapd->cs_freq_params)); hapd->cs_count = 0; hapd->cs_block_tx = 0; hapd->cs_c_off_beacon = 0; hapd->cs_c_off_proberesp = 0; hapd->csa_in_progress = 0; hapd->cs_c_off_ecsa_beacon = 0; hapd->cs_c_off_ecsa_proberesp = 0; } int hostapd_switch_channel(struct hostapd_data *hapd, struct csa_settings *settings) { int ret; if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) { wpa_printf(MSG_INFO, "CSA is not supported"); return -1; } ret = hostapd_fill_csa_settings(hapd, settings); if (ret) return ret; ret = hostapd_drv_switch_channel(hapd, settings); free_beacon_data(&settings->beacon_csa); free_beacon_data(&settings->beacon_after); if (ret) { /* if we failed, clean cs parameters */ hostapd_cleanup_cs_params(hapd); return ret; } hapd->csa_in_progress = 1; return 0; } void hostapd_switch_channel_fallback(struct hostapd_iface *iface, const struct hostapd_freq_params *freq_params) { int vht_seg0_idx = 0, vht_seg1_idx = 0, vht_bw = VHT_CHANWIDTH_USE_HT; unsigned int i; wpa_printf(MSG_DEBUG, "Restarting all CSA-related BSSes"); if (freq_params->center_freq1) vht_seg0_idx = 36 + (freq_params->center_freq1 - 5180) / 5; if (freq_params->center_freq2) vht_seg1_idx = 36 + (freq_params->center_freq2 - 5180) / 5; switch (freq_params->bandwidth) { case 0: case 20: case 40: vht_bw = VHT_CHANWIDTH_USE_HT; break; case 80: if (freq_params->center_freq2) vht_bw = VHT_CHANWIDTH_80P80MHZ; else vht_bw = VHT_CHANWIDTH_80MHZ; break; case 160: vht_bw = VHT_CHANWIDTH_160MHZ; break; default: wpa_printf(MSG_WARNING, "Unknown CSA bandwidth: %d", freq_params->bandwidth); break; } iface->freq = freq_params->freq; iface->conf->channel = freq_params->channel; iface->conf->secondary_channel = freq_params->sec_channel_offset; iface->conf->vht_oper_centr_freq_seg0_idx = vht_seg0_idx; iface->conf->vht_oper_centr_freq_seg1_idx = vht_seg1_idx; iface->conf->vht_oper_chwidth = vht_bw; iface->conf->ieee80211n = freq_params->ht_enabled; iface->conf->ieee80211ac = freq_params->vht_enabled; /* * cs_params must not be cleared earlier because the freq_params * argument may actually point to one of these. */ for (i = 0; i < iface->num_bss; i++) hostapd_cleanup_cs_params(iface->bss[i]); hostapd_disable_iface(iface); hostapd_enable_iface(iface); } #endif /* NEED_AP_MLME */ struct hostapd_data * hostapd_get_iface(struct hapd_interfaces *interfaces, const char *ifname) { size_t i, j; for (i = 0; i < interfaces->count; i++) { struct hostapd_iface *iface = interfaces->iface[i]; for (j = 0; j < iface->num_bss; j++) { struct hostapd_data *hapd = iface->bss[j]; if (os_strcmp(ifname, hapd->conf->iface) == 0) return hapd; } } return NULL; } void hostapd_periodic_iface(struct hostapd_iface *iface) { size_t i; ap_list_timer(iface); for (i = 0; i < iface->num_bss; i++) { struct hostapd_data *hapd = iface->bss[i]; if (!hapd->started) continue; #ifndef CONFIG_NO_RADIUS hostapd_acl_expire(hapd); #endif /* CONFIG_NO_RADIUS */ } }
wifiphisher/roguehostapd
roguehostapd/hostapd-2_6/src/ap/hostapd.c
C
bsd-3-clause
84,878
[ 30522, 1013, 1008, 1008, 3677, 9331, 2094, 1013, 3988, 3989, 1998, 9563, 1008, 9385, 1006, 1039, 1007, 2526, 1011, 2297, 1010, 8183, 19496, 16007, 10224, 1026, 1046, 1030, 1059, 2487, 1012, 10882, 1028, 1008, 1008, 2023, 4007, 2089, 2022, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /* * This file is part of the LightSAML-Core package. * * (c) Milos Tomic <tmilos@lightsaml.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace LightSaml\Action\Profile\Entity; use LightSaml\Action\Profile\AbstractProfileAction; use LightSaml\Context\Profile\ProfileContext; use LightSaml\Context\Profile\ProfileContexts; use LightSaml\Model\Context\SerializationContext; use Symfony\Component\HttpFoundation\Response; class SerializeOwnEntityAction extends AbstractProfileAction { /** @var string[] */ protected $supportedContextTypes = ['application/samlmetadata+xml', 'application/xml', 'text/xml']; protected function doExecute(ProfileContext $context) { $ownEntityDescriptor = $context->getOwnEntityDescriptor(); /** @var SerializationContext $serializationContext */ $serializationContext = $context->getSubContext(ProfileContexts::SERIALIZATION, SerializationContext::class); $serializationContext->getDocument()->formatOutput = true; $ownEntityDescriptor->serialize($serializationContext->getDocument(), $serializationContext); $xml = $serializationContext->getDocument()->saveXML(); $response = new Response($xml); $contentType = 'text/xml'; $acceptableContentTypes = array_flip($context->getHttpRequest()->getAcceptableContentTypes()); foreach ($this->supportedContextTypes as $supportedContentType) { if (isset($acceptableContentTypes[$supportedContentType])) { $contentType = $supportedContentType; break; } } $response->headers->replace(['Content-Type' => $contentType]); $context->getHttpResponseContext()->setResponse($response); } }
lightSAML/lightSAML
src/LightSaml/Action/Profile/Entity/SerializeOwnEntityAction.php
PHP
mit
1,832
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 1996, 4597, 3286, 2140, 1011, 4563, 7427, 1012, 1008, 1008, 1006, 1039, 1007, 26038, 3419, 2594, 1026, 1056, 4328, 10483, 1030, 4597, 3286, 2140, 1012, 4012, 1028, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// File: finetune_classifier.cc // Author: Karl Moritz Hermann (mail@karlmoritz.com) // Created: 29-01-2013 // Last Update: Thu 03 Oct 2013 11:26:25 AM BST // STL #include <iostream> #include <algorithm> #include <random> #include <chrono> // Boost #include <boost/program_options/variables_map.hpp> #include <boost/program_options/parsers.hpp> // L-BFGS #include <lbfgs.h> // Local #include "finetune_classifier.h" #include "models.h" #include "fast_math.h" using namespace std; namespace bpo = boost::program_options; FinetuneClassifier::FinetuneClassifier(RecursiveAutoencoderBase& rae, TrainingCorpus& trainC, float lambdaF, float alpha, int dynamic_mode, int iterations) : lambda(lambdaF), alpha_rae(alpha), mode(dynamic_mode), iterations(iterations), it_count(0), num_batches(100), eta(0.1) { /*************************************************************************** * Define a couple of frequently needed variables * ***************************************************************************/ train_length = min(rae.config.num_sentences,int(trainC.size())); bool use_full_corpus = false; if (train_length == 0) { train_length = trainC.size(); use_full_corpus = true; } label_width = rae.config.label_class_size; num_label_types = rae.config.num_label_types; // 1 int multiplier = 1; if (mode == 0) multiplier = 2; if (mode == 3) multiplier = 3; // only works for compound test if (mode == 4) multiplier = 4; // Embedding: s1 + s2 + cos_sim(s1,s2) + len(s1) + len(s2) + // unigram_overlap(s1,s2) following Blacoe/Lapata 2012 dynamic_embedding_size = multiplier * rae.config.word_representation_size; theta_size_ = dynamic_embedding_size * label_width * num_label_types + label_width * num_label_types; trainI_ = new Real[train_length * dynamic_embedding_size](); theta_ = new Real[theta_size_]; WeightVectorType theta(theta_,theta_size_); theta.setZero(); if (true) { std::random_device rd; std::mt19937 gen(rd()); //std::mt19937 gen(0); float r = sqrt( 6.0 / dynamic_embedding_size); std::uniform_real_distribution<> dis(-r,r); for (int i=0; i<theta_size_; i++) theta(i) = dis(gen); } Real* ptr = trainI_; for (auto i=0; i<train_length; ++i) { int j = i; if ((not use_full_corpus) and (i%2 == 1)) j = trainC.size() - i; trainData.push_back(VectorLabelPair(WeightVectorType(ptr, dynamic_embedding_size),trainC[j].value)); mix.push_back(i); ptr += dynamic_embedding_size; } ptr = theta_; for (auto i=0; i<num_label_types; ++i) { Wcat.push_back(WeightMatrixType(ptr, label_width, dynamic_embedding_size)); ptr += label_width * dynamic_embedding_size; } for (auto i=0; i<num_label_types; ++i) { Bcat.push_back(WeightVectorType(ptr, label_width)); Bcat.back().setZero(); // discuss .. ptr += label_width; } /*************************************************************************** * Populate train input with forward Propagation and tricks * ***************************************************************************/ #pragma omp parallel for schedule(dynamic) for (auto i = 0; i<train_length; ++i) { int j = i; if ((not use_full_corpus) and (i%2 == 1)) j = trainC.size() - i; SinglePropBase* propagator = nullptr; Bools bools; if(rae.config.tree == TREE_CCG or rae.config.tree == TREE_STANFORD) propagator = rae.getSingleProp(trainC[j],0.5,bools); assert (propagator != nullptr); propagator->forwardPropagate(true); propagator->setDynamic(trainData[i].vector,mode); //cout << "C: " << trainData[i].vector[0] << endl; delete propagator; } } void FinetuneClassifier::evaluate() { vector<VectorLabelPair>& data = trainData; int length = train_length; int right = 0; int wrong = 0; int tp = 0; int fp = 0; int tn = 0; int fn = 0; #pragma omp parallel for schedule(dynamic) for (auto i = 0; i<length; ++i) { // Encode input ArrayReal label_vec = ( Wcat[0] * data[i].vector + Bcat[0] ).unaryExpr(std::ptr_fun(getSigmoid)).array(); ArrayReal lbl_sm = data[i].label - label_vec; #pragma omp critical { if(abs(lbl_sm.sum()) > 0.5) { wrong += 1; if(data[i].label == 0) ++fp; else ++fn; } else { right += 1; if(data[i].label == 0) ++tn; else ++tp; } } } cout << right << "/" << right + wrong << " "; Real precision = 1.0 * tp / (tp + fp); Real recall = 1.0 * tp / (tp + fn); Real accuracy = 1.0 * (tp + tn) / (tp + tn + fp + fn); Real f1score = 2.0 * (precision * recall) / (precision + recall); cout << "Acc/F1: " << accuracy << " " << f1score << endl; } void FinetuneClassifier::trainLbfgs(LineSearchType linesearch) { batch_from = 0; batch_to = train_length; lbfgs_parameter_t param; lbfgs_parameter_init(&param); param.linesearch = linesearch; param.max_iterations = iterations; //param.epsilon = 0.00000001; param.m = 25; const int n = theta_size_; auto vars = theta_; Real error = 0.0; int tries = 0; while (tries < 3 and it_count < 250) { int ret = lbfgs(n, vars, &error, lbfgs_evaluate_, lbfgs_progress_, this, &param); cout << "L-BFGS optimization terminated with status code = " << ret << endl; cout << "fx=" << error << endl; ++tries; } } void FinetuneClassifier::trainAdaGrad() { auto vars = theta_; int number_vars = theta_size_; WeightArrayType theta(vars,number_vars); Real* Gt_d = new Real[number_vars]; Real* Ginv_d = new Real[number_vars]; WeightArrayType Gt(Gt_d,number_vars); WeightArrayType Ginv(Ginv_d,number_vars); Gt.setZero(); Real* data1 = new Real[number_vars]; int batchsize = (train_length / num_batches) + 1; cout << "Batch size: " << batchsize << endl; for (auto iteration = 0; iteration < iterations; ++iteration) { //unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); random_shuffle (mix.begin(), mix.end()); //, std::default_random_engine(seed)); for (auto batch = 0; batch < num_batches; ++batch) { batch_from = batch*batchsize; batch_to = min((batch+1)*batchsize,train_length); if (batch_to - batch_from > 0) { WeightArrayType grad(data1,number_vars); //float err = finetuneCostAndGrad_(theta_,data1,number_vars); //grad /= (batch_to - batch_from); Gt += grad*grad; for (int i=0;i<number_vars;i++) { if (Gt_d[i] == 0) Ginv_d[i] = 0; else Ginv_d[i] = sqrt(1/Gt_d[i]); } grad *= Ginv; grad *= eta; //cout << theta.abs().sum() << " vs " << grad.abs().sum() << endl; theta -= grad; } } evaluate(); } delete [] data1; delete [] Gt_d; delete [] Ginv_d; } lbfgsfloatval_t FinetuneClassifier::lbfgs_evaluate_( void *instance, const lbfgsfloatval_t *x, lbfgsfloatval_t *g, const int n, const lbfgsfloatval_t step ) { return reinterpret_cast<FinetuneClassifier*>(instance)->finetuneCostAndGrad_(x, g, n); } int FinetuneClassifier::lbfgs_progress_( void *instance, const lbfgsfloatval_t *x, const lbfgsfloatval_t *g, const lbfgsfloatval_t fx, const lbfgsfloatval_t xnorm, const lbfgsfloatval_t gnorm, const lbfgsfloatval_t step, int n, int k, int ls ) { cout << "N: " << n << endl; printf("Iteration %d:\n", k); printf(" fx = %f, x[0] = %f, x[1] = %f %f\n", fx, x[0], x[1], x[2]); printf(" fx = %f, g[0] = %f, g[1] = %f %f\n", fx, g[0], g[1], g[2]); printf(" xnorm = %f, gnorm = %f, step = %f\n", xnorm, gnorm, step); printf("\n"); reinterpret_cast<FinetuneClassifier*>(instance)->it_count++; reinterpret_cast<FinetuneClassifier*>(instance)->evaluate(); return 0; } // ForwardPropagates and returns error and gradient on self lbfgsfloatval_t FinetuneClassifier::finetuneCostAndGrad_( const lbfgsfloatval_t *x, lbfgsfloatval_t *gradient_location, const int n) { WeightVectorType grad(gradient_location,theta_size_); grad.setZero(); WeightMatricesType Wcatgrad; WeightVectorsType Bcatgrad; Real* ptr = gradient_location; for (auto i=0; i<num_label_types; ++i) { Wcatgrad.push_back(WeightMatrixType(ptr, label_width, dynamic_embedding_size)); ptr += label_width * dynamic_embedding_size; } for (auto i=0; i<num_label_types; ++i) { Bcatgrad.push_back(WeightVectorType(ptr, label_width)); ptr += label_width; } assert(ptr == theta_size_ + gradient_location); /*************************************************************************** * Populate train input with forward Propagation and tricks * ***************************************************************************/ Real cost = 0.0; int right = 0; int wrong = 0; int tp = 0; int fp = 0; int tn = 0; int fn = 0; #pragma omp parallel for schedule(dynamic) for (auto k = batch_from; k<batch_to; ++k) { auto i = mix[k]; // Encode input ArrayReal label_vec = ( Wcat[0] * trainData[i].vector + Bcat[0] ).unaryExpr(std::ptr_fun(getSigmoid)).array(); ArrayReal lbl_sm = label_vec - trainData[i].label; ArrayReal delta = lbl_sm * (label_vec) * (1 - label_vec); #pragma omp critical { //cout << "D/D2" << delta << " " << delta2 << endl; cost += 0.5 * (lbl_sm * lbl_sm).sum(); Wcatgrad[0] += delta.matrix() * trainData[i].vector.transpose(); Bcatgrad[0] += delta.matrix(); if(abs(lbl_sm.sum()) > 0.5) { wrong += 1; if(trainData[i].label == 0) ++fp; else ++fn; } else { right += 1; if(trainData[i].label == 0) ++tn; else ++tp; } } } /* *cout << "Correct: " << right << "/" << right + wrong << " "; *cout << "Zero: " << tp << "/" << tp+fn << " "; *cout << "One: " << tn << "/" << tn+fp << endl; */ float lambda_partial = lambda * (batch_to - batch_from) / train_length; Wcatgrad[0] += lambda_partial*Wcat[0]; cost += 0.5*lambda_partial*(Wcat[0].cwiseProduct(Wcat[0])).sum(); Wcatgrad[0] /= (batch_to - batch_from); cost /= (batch_to - batch_from); return cost; } FinetuneClassifier::~FinetuneClassifier() { delete [] trainI_; delete [] theta_; }
karlmoritz/oxcvsm
src/common/finetune_classifier.cc
C++
apache-2.0
10,574
[ 30522, 1013, 1013, 5371, 1024, 2986, 8525, 2638, 1035, 2465, 18095, 1012, 10507, 1013, 1013, 3166, 1024, 6382, 28461, 12224, 1006, 5653, 1030, 6382, 24610, 5753, 1012, 4012, 1007, 1013, 1013, 2580, 1024, 2756, 1011, 5890, 1011, 2286, 1013, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // UIDevice+YYAdd.h // YYCategories <https://github.com/ibireme/YYCategories> // // Created by ibireme on 13/4/3. // Copyright (c) 2015 ibireme. // // This source code is licensed under the MIT-style license found in the // LICENSE file in the root directory of this source tree. // #import <UIKit/UIKit.h> /** Provides extensions for `UIDevice`. */ @interface UIDevice (YYAdd) #pragma mark - Device Information ///============================================================================= /// @name Device Information ///============================================================================= /// Device system version (e.g. 8.1) + (float)systemVersion; /// Whether the device is iPad/iPad mini. @property (nonatomic, readonly) BOOL isPad; /// Whether the device is a simulator. @property (nonatomic, readonly) BOOL isSimulator; /// Whether the device is jailbroken. @property (nonatomic, readonly) BOOL isJailbroken; /// Wherher the device can make phone calls. @property (nonatomic, readonly) BOOL canMakePhoneCalls NS_EXTENSION_UNAVAILABLE_IOS(""); /// The device's machine model. e.g. "iPhone6,1" "iPad4,6" /// @see http://theiphonewiki.com/wiki/Models @property (nonatomic, readonly) NSString *machineModel; /// The device's machine model name. e.g. "iPhone 5s" "iPad mini 2" /// @see http://theiphonewiki.com/wiki/Models @property (nonatomic, readonly) NSString *machineModelName; /// The System's startup time. @property (nonatomic, readonly) NSDate *systemUptime; #pragma mark - Network Information ///============================================================================= /// @name Network Information ///============================================================================= /// WIFI IP address of this device (can be nil). e.g. @"192.168.1.111" @property (nonatomic, readonly) NSString *ipAddressWIFI; /// Cell IP address of this device (can be nil). e.g. @"10.2.2.222" @property (nonatomic, readonly) NSString *ipAddressCell; #pragma mark - Disk Space ///============================================================================= /// @name Disk Space ///============================================================================= /// Total disk space in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t diskSpace; /// Free disk space in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t diskSpaceFree; /// Used disk space in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t diskSpaceUsed; #pragma mark - Memory Information ///============================================================================= /// @name Memory Information ///============================================================================= /// Total physical memory in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t memoryTotal; /// Used (active + inactive + wired) memory in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t memoryUsed; /// Free memory in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t memoryFree; /// Acvite memory in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t memoryActive; /// Inactive memory in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t memoryInactive; /// Wired memory in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t memoryWired; /// Purgable memory in byte. (-1 when error occurs) @property (nonatomic, readonly) int64_t memoryPurgable; #pragma mark - CPU Information ///============================================================================= /// @name CPU Information ///============================================================================= /// Avaliable CPU processor count. @property (nonatomic, readonly) NSUInteger cpuCount; /// Current CPU usage, 1.0 means 100%. (-1 when error occurs) @property (nonatomic, readonly) float cpuUsage; /// Current CPU usage per processor (array of NSNumber), 1.0 means 100%. (nil when error occurs) @property (nonatomic, readonly) NSArray *cpuUsagePerProcessor; @end #ifndef kSystemVersion #define kSystemVersion [UIDevice systemVersion] #endif #ifndef kiOS6Later #define kiOS6Later (kSystemVersion >= 6) #endif #ifndef kiOS7Later #define kiOS7Later (kSystemVersion >= 7) #endif #ifndef kiOS8Later #define kiOS8Later (kSystemVersion >= 8) #endif #ifndef kiOS9Later #define kiOS9Later (kSystemVersion >= 9) #endif
MichaelHuyp/YPCommon
对YYCategories的学习/对YYCategories的学习/YYCategories/UIKit/UIDevice+YYAdd.h
C
mit
4,457
[ 30522, 1013, 1013, 1013, 1013, 21318, 24844, 6610, 1009, 1061, 25152, 2094, 1012, 1044, 1013, 1013, 1061, 2100, 16280, 20255, 3111, 1026, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 21307, 7442, 4168, 1013, 1061, 2100, 16...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Ionic makes it incredibly easy to build beautiful and interactive mobile apps using HTML5 and AngularJS."> <meta name="keywords" content="html5,javascript,mobile,drifty,ionic,hybrid,phonegap,cordova,native,ios,android,angularjs"> <meta name="author" content="Drifty"> <meta property="og:image" content="http://ionicframework.com/img/ionic-logo-blog.png"/> <!-- version /docs/1.0.0-beta.13 should not be indexed --> <meta name="robots" content="noindex"> <title>$ionicTemplateCache - Service in module ionic - Ionic Framework</title> <link href="/css/site.css?12" rel="stylesheet"> <!--<script src="//cdn.optimizely.com/js/595530035.js"></script>--> <script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-44023830-1', 'ionicframework.com'); ga('send', 'pageview'); </script> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body class="docs docs-page docs-api"> <nav class="navbar navbar-default horizontal-gradient" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle button ionic" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <i class="icon ion-navicon"></i> </button> <a class="navbar-brand" href="/"> <img src="/img/ionic-logo-white.svg" width="123" height="43" alt="Ionic Framework"> </a> <a href="http://blog.ionic.io/announcing-ionic-1-0/" target="_blank"> <img src="/img/ionic1-tag.png" alt="Ionic 1.0 is out!" width="28" height="32" style="margin-left: 140px; margin-top:22px; display:block"> </a> </div> <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul class="nav navbar-nav navbar-right"> <li><a class="getting-started-nav nav-link" href="/getting-started/">Getting Started</a></li> <li><a class="docs-nav nav-link" href="/docs/">Docs</a></li> <li><a class="nav-link" href="http://ionic.io/support">Support</a></li> <li><a class="blog-nav nav-link" href="http://blog.ionic.io/">Blog <span id="blog-badge">1</span></a></li> <li><a class="nav-link" href="http://forum.ionicframework.com/">Forum</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle nav-link " data-toggle="dropdown" role="button" aria-expanded="false">More <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <div class="arrow-up"></div> <li><a class="products-nav nav-link" href="http://ionic.io/">Ionic Platform</a></li> <li><a class="examples-nav nav-link" href="http://showcase.ionicframework.com/">Showcase</a></li> <li><a class="nav-link" href="http://jobs.ionic.io/">Job Board</a></li> <li><a class="nav-link" href="http://market.ionic.io/">Market</a></li> <li><a class="nav-link" href="http://ionicworldwide.herokuapp.com/">Ionic Worldwide</a></li> <li><a class="nav-link" href="http://play.ionic.io/">Playground</a></li> <li><a class="nav-link" href="http://creator.ionic.io/">Creator</a></li> <li><a class="nav-link" href="http://shop.ionic.io/">Shop</a></li> <!--<li><a class="nav-link" href="http://ngcordova.com/">ngCordova</a></li>--> </ul> </li> </ul> </div> </div> </nav> <div class="header horizontal-gradient"> <div class="container"> <h3>$ionicTemplateCache</h3> <h4>Service in module ionic</h4> </div> <div class="news"> <div class="container"> <div class="row"> <div class="col-sm-8 news-col"> <div class="picker"> <select onchange="window.location.href=this.options[this.selectedIndex].value"> <option value="/docs/nightly/api/service/$ionicTemplateCache/" > nightly </option> <option value="/docs/api/service/$ionicTemplateCache/" > 1.1.0 (latest) </option> <option value="/docs/1.0.1/api/service/$ionicTemplateCache/" > 1.0.1 </option> <option value="/docs/1.0.0/api/service/$ionicTemplateCache/" > 1.0.0 </option> <option value="/docs/1.0.0-rc.5/api/service/$ionicTemplateCache/" > 1.0.0-rc.5 </option> <option value="/docs/1.0.0-rc.4/api/service/$ionicTemplateCache/" > 1.0.0-rc.4 </option> <option value="/docs/1.0.0-rc.3/api/service/$ionicTemplateCache/" > 1.0.0-rc.3 </option> <option value="/docs/1.0.0-rc.2/api/service/$ionicTemplateCache/" > 1.0.0-rc.2 </option> <option value="/docs/1.0.0-rc.1/api/service/$ionicTemplateCache/" > 1.0.0-rc.1 </option> <option value="/docs/1.0.0-rc.0/api/service/$ionicTemplateCache/" > 1.0.0-rc.0 </option> <option value="/docs/1.0.0-beta.14/api/service/$ionicTemplateCache/" > 1.0.0-beta.14 </option> <option value="/docs/1.0.0-beta.13/api/service/$ionicTemplateCache/" selected> 1.0.0-beta.13 </option> <option value="/docs/1.0.0-beta.12/api/service/$ionicTemplateCache/" > 1.0.0-beta.12 </option> <option value="/docs/1.0.0-beta.11/api/service/$ionicTemplateCache/" > 1.0.0-beta.11 </option> <option value="/docs/1.0.0-beta.10/api/service/$ionicTemplateCache/" > 1.0.0-beta.10 </option> </select> </div> </div> <div class="col-sm-4 search-col"> <div class="search-bar"> <span class="search-icon ionic"><i class="ion-ios7-search-strong"></i></span> <input type="search" id="search-input" value="Search"> </div> </div> </div> </div> </div> </div> <div id="search-results" class="search-results" style="display:none"> <div class="container"> <div class="search-section search-api"> <h4>JavaScript</h4> <ul id="results-api"></ul> </div> <div class="search-section search-css"> <h4>CSS</h4> <ul id="results-css"></ul> </div> <div class="search-section search-content"> <h4>Resources</h4> <ul id="results-content"></ul> </div> </div> </div> <div class="container content-container"> <div class="row"> <div class="col-md-2 col-sm-3 aside-menu"> <div> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/overview/">Overview</a> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/components/">CSS</a> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/platform-customization/">Platform Customization</a> </li> </ul> <!-- Docs: JavaScript --> <ul class="nav left-menu active-menu"> <li class="menu-title"> <a href="/docs/1.0.0-beta.13/api/"> JavaScript </a> </li> <!-- Action Sheet --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicActionSheet/" class="api-section"> Action Sheet </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicActionSheet/"> $ionicActionSheet </a> </li> </ul> </li> <!-- Backdrop --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicBackdrop/" class="api-section"> Backdrop </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicBackdrop/"> $ionicBackdrop </a> </li> </ul> </li> <!-- Content --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionContent/" class="api-section"> Content </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionContent/"> ion-content </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionRefresher/"> ion-refresher </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionPane/"> ion-pane </a> </li> </ul> </li> <!-- Events --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/onHold/" class="api-section"> Events </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/onHold/"> on-hold </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onTap/"> on-tap </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onTouch/"> on-touch </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onRelease/"> on-release </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onDrag/"> on-drag </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onDragUp/"> on-drag-up </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onDragRight/"> on-drag-right </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onDragDown/"> on-drag-down </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onDragLeft/"> on-drag-left </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onSwipe/"> on-swipe </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onSwipeUp/"> on-swipe-up </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onSwipeRight/"> on-swipe-right </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onSwipeDown/"> on-swipe-down </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/onSwipeLeft/"> on-swipe-left </a> </li> </ul> </li> <!-- Form Inputs --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionCheckbox/" class="api-section"> Form Inputs </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionCheckbox/"> ion-checkbox </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionRadio/"> ion-radio </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionToggle/"> ion-toggle </a> </li> </ul> </li> <!-- Gesture --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicGesture/" class="api-section"> Gesture </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicGesture/"> $ionicGesture </a> </li> </ul> </li> <!-- Headers/Footers --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionHeaderBar/" class="api-section"> Headers/Footers </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionHeaderBar/"> ion-header-bar </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionFooterBar/"> ion-footer-bar </a> </li> </ul> </li> <!-- Keyboard --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/page/keyboard/" class="api-section"> Keyboard </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/page/keyboard/"> Keyboard </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/keyboardAttach/"> keyboard-attach </a> </li> </ul> </li> <!-- Lists --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionList/" class="api-section"> Lists </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionList/"> ion-list </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionItem/"> ion-item </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionDeleteButton/"> ion-delete-button </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionReorderButton/"> ion-reorder-button </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionOptionButton/"> ion-option-button </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/collectionRepeat/"> collection-repeat </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicListDelegate/"> $ionicListDelegate </a> </li> </ul> </li> <!-- Loading --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicLoading/" class="api-section"> Loading </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicLoading/"> $ionicLoading </a> </li> </ul> <ul> <li> <a href="/docs/1.0.0-beta.13/api/object/$ionicLoadingConfig/"> $ionicLoadingConfig </a> </li> </ul> </li> <!-- Modal --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicModal/" class="api-section"> Modal </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicModal/"> $ionicModal </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/controller/ionicModal/"> ionicModal </a> </li> </ul> </li> <!-- Navigation --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionNavView/" class="api-section"> Navigation </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionNavView/"> ion-nav-view </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionView/"> ion-view </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionNavBar/"> ion-nav-bar </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionNavButtons/"> ion-nav-buttons </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionNavBackButton/"> ion-nav-back-button </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/navClear/"> nav-clear </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicNavBarDelegate/"> $ionicNavBarDelegate </a> </li> </ul> </li> <!-- Platform --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicPlatform/" class="api-section"> Platform </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicPlatform/"> $ionicPlatform </a> </li> </ul> </li> <!-- Popover --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicPopover/" class="api-section"> Popover </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicPopover/"> $ionicPopover </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/controller/ionicPopover/"> ionicPopover </a> </li> </ul> </li> <!-- Popup --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/service/$ionicPopup/" class="api-section"> Popup </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicPopup/"> $ionicPopup </a> </li> </ul> </li> <!-- Scroll --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionScroll/" class="api-section"> Scroll </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionScroll/"> ion-scroll </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionInfiniteScroll/"> ion-infinite-scroll </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicScrollDelegate/"> $ionicScrollDelegate </a> </li> </ul> </li> <!-- Side Menus --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionSideMenus/" class="api-section"> Side Menus </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionSideMenus/"> ion-side-menus </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionSideMenuContent/"> ion-side-menu-content </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionSideMenu/"> ion-side-menu </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/exposeAsideWhen/"> expose-aside-when </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/menuToggle/"> menu-toggle </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/menuClose/"> menu-close </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicSideMenuDelegate/"> $ionicSideMenuDelegate </a> </li> </ul> </li> <!-- Slide Box --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionSlideBox/" class="api-section"> Slide Box </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionSlideBox/"> ion-slide-box </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicSlideBoxDelegate/"> $ionicSlideBoxDelegate </a> </li> </ul> </li> <!-- Tabs --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/directive/ionTabs/" class="api-section"> Tabs </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionTabs/"> ion-tabs </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/directive/ionTab/"> ion-tab </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicTabsDelegate/"> $ionicTabsDelegate </a> </li> </ul> </li> <!-- Tap --> <li class="menu-section"> <a href="/docs/1.0.0-beta.13/api/page/tap/" class="api-section"> Tap &amp; Click </a> </li> <!-- Utility --> <li class="menu-section"> <a href="#" class="api-section"> Utility </a> <ul> <li> <a href="/docs/1.0.0-beta.13/api/provider/$ionicConfigProvider/"> $ionicConfigProvider </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/utility/ionic.Platform/"> ionic.Platform </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/utility/ionic.DomUtil/"> ionic.DomUtil </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/utility/ionic.EventController/"> ionic.EventController </a> </li> <li> <a href="/docs/1.0.0-beta.13/api/service/$ionicPosition/"> $ionicPosition </a> </li> </ul> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/cli/">CLI</a> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="http://learn.ionicframework.com/">Learn Ionic</a> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/guide/">Guide</a> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/ionic-cli-faq/">FAQ</a> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/getting-help/">Getting Help</a> </li> </ul> <ul class="nav left-menu"> <li class="menu-title"> <a href="/docs/concepts/">Ionic Concepts</a> </li> </ul> </div> </div> <div class="col-md-10 col-sm-9 main-content"> <div class="improve-docs"> <a href='http://github.com/driftyco/ionic/tree/master/js/angular/service/templateCache.js#L5'> View Source </a> &nbsp; <a href='http://github.com/driftyco/ionic/edit/master/js/angular/service/templateCache.js#L5'> Improve this doc </a> </div> <h1 class="api-title"> $ionicTemplateCache </h1> <p>A service that preemptively caches template files to eliminate transition flicker and boost performance.</p> <h2>Usage</h2> <p>State templates are cached automatically, but you can optionally cache other templates.</p> <div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nx">$ionicTemplateCache</span><span class="p">(</span><span class="s1">&#39;myNgIncludeTemplate.html&#39;</span><span class="p">);</span> </code></pre></div> <p>Optionally disable all preemptive caching with the <code>$ionicConfigProvider</code> or individual states by setting <code>prefetchTemplate</code> in the <code>$state</code> definition</p> <div class="highlight"><pre><code class="language-js" data-lang="js"> <span class="nx">angular</span><span class="p">.</span><span class="nx">module</span><span class="p">(</span><span class="s1">&#39;myApp&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;ionic&#39;</span><span class="p">])</span> <span class="p">.</span><span class="nx">config</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">$stateProvider</span><span class="p">,</span> <span class="nx">$ionicConfigProvider</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// disable preemptive template caching globally</span> <span class="nx">$ionicConfigProvider</span><span class="p">.</span><span class="nx">prefetchTemplates</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span> <span class="c1">// disable individual states</span> <span class="nx">$stateProvider</span> <span class="p">.</span><span class="nx">state</span><span class="p">(</span><span class="s1">&#39;tabs&#39;</span><span class="p">,</span> <span class="p">{</span> <span class="nx">url</span><span class="o">:</span> <span class="s2">&quot;/tab&quot;</span><span class="p">,</span> <span class="kr">abstract</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span> <span class="nx">prefetchTemplate</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">templateUrl</span><span class="o">:</span> <span class="s2">&quot;tabs-templates/tabs.html&quot;</span> <span class="p">})</span> <span class="p">.</span><span class="nx">state</span><span class="p">(</span><span class="s1">&#39;tabs.home&#39;</span><span class="p">,</span> <span class="p">{</span> <span class="nx">url</span><span class="o">:</span> <span class="s2">&quot;/home&quot;</span><span class="p">,</span> <span class="nx">views</span><span class="o">:</span> <span class="p">{</span> <span class="s1">&#39;home-tab&#39;</span><span class="o">:</span> <span class="p">{</span> <span class="nx">prefetchTemplate</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span> <span class="nx">templateUrl</span><span class="o">:</span> <span class="s2">&quot;tabs-templates/home.html&quot;</span><span class="p">,</span> <span class="nx">controller</span><span class="o">:</span> <span class="s1">&#39;HomeTabCtrl&#39;</span> <span class="p">}</span> <span class="p">}</span> <span class="p">});</span> <span class="p">});</span> </code></pre></div> </div> </div> </div> <div class="pre-footer"> <div class="row ionic"> <div class="col-sm-6 col-a"> <h4> <a href="/getting-started/">Getting started <span class="icon ion-arrow-right-c"></span></a> </h4> <p> Learn more about how Ionic was built, why you should use it, and what's included. We'll cover the basics and help you get started from the ground up. </p> </div> <div class="col-sm-6 col-b"> <h4> <a href="/docs/">Documentation <span class="icon ion-arrow-right-c"></span></a> </h4> <p> What are you waiting for? Take a look and get coding! Our documentation covers all you need to know to get an app up and running in minutes. </p> </div> </div> </div> <footer class="footer"> <nav class="base-links"> <dl> <dt>Docs</dt> <dd><a href="http://ionicframework.com/docs/">Documentation</a></dd> <dd><a href="http://ionicframework.com/getting-started/">Getting Started</a></dd> <dd><a href="http://ionicframework.com/docs/overview/">Overview</a></dd> <dd><a href="http://ionicframework.com/docs/components/">Components</a></dd> <dd><a href="http://ionicframework.com/docs/api/">JavaScript</a></dd> <dd><a href="http://ionicframework.com/submit-issue/">Submit Issue</a></dd> </dl> <dl> <dt>Resources</dt> <dd><a href="http://learn.ionicframework.com/">Learn Ionic</a></dd> <dd><a href="http://ngcordova.com/">ngCordova</a></dd> <dd><a href="http://ionicons.com/">Ionicons</a></dd> <dd><a href="http://creator.ionic.io/">Creator</a></dd> <dd><a href="http://showcase.ionicframework.com/">Showcase</a></dd> <dd><a href="http://manning.com/wilken/?a_aid=ionicinactionben&a_bid=1f0a0e1d">The Ionic Book</a></dd> </dl> <dl> <dt>Contribute</dt> <dd><a href="http://forum.ionicframework.com/">Community Forum</a></dd> <dd><a href="http://webchat.freenode.net/?randomnick=1&amp;channels=%23ionic&amp;uio=d4">Ionic IRC</a></dd> <dd><a href="http://ionicframework.com/present-ionic/">Present Ionic</a></dd> <dd><a href="http://ionicframework.com/contribute/">Contribute</a></dd> <dd><a href="https://github.com/driftyco/ionic-learn/issues/new">Write for us</a></dd> <dd><a href="http://shop.ionic.io/">Ionic Shop</a></dd> </dl> <dl class="small-break"> <dt>About</dt> <dd><a href="http://blog.ionic.io/">Blog</a></dd> <dd><a href="http://ionic.io">Services</a></dd> <dd><a href="http://drifty.com">Company</a></dd> <dd><a href="https://s3.amazonaws.com/ionicframework.com/logo-pack.zip">Logo Pack</a></dd> <dd><a href="mailto:hi@ionicframework.com">Contact</a></dd> <dd><a href="http://ionicframework.com/jobs/">Jobs</a></dd> </dl> <dl> <dt>Connect</dt> <dd><a href="https://twitter.com/IonicFramework">Twitter</a></dd> <dd><a href="https://github.com/driftyco/ionic">GitHub</a></dd> <dd><a href="https://www.facebook.com/ionicframework">Facebook</a></dd> <dd><a href="https://plus.google.com/b/112280728135675018538/+Ionicframework/posts">Google+</a></dd> <dd><a href="https://www.youtube.com/channel/UChYheBnVeCfhCmqZfCUdJQw">YouTube</a></dd> <dd><a href="https://twitter.com/ionitron">Ionitron</a></dd> </dl> </nav> <div class="newsletter row"> <div class="newsletter-container"> <div class="col-sm-7"> <div class="newsletter-text">Stay in the loop</div> <div class="sign-up">Sign up to receive emails for the latest updates, features, and news on the framework.</div> </div> <form action="http://codiqa.createsend.com/t/t/s/jytylh/" method="post" class="input-group col-sm-5"> <input id="fieldEmail" name="cm-jytylh-jytylh" class="form-control" type="email" placeholder="Email" required /> <span class="input-group-btn"> <button class="btn btn-default" type="submit">Subscribe</button> </span> </form> </div> </div> <div class="copy"> <div class="copy-container"> <p class="authors"> Code licensed under <a href="/docs/#license">MIT</a>. Docs under <a href="https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)">Apache 2</a> <span>|</span> &copy; 2013-2015 <a href="http://drifty.com/">Drifty Co</a> </p> </div> </div> </footer> <script type="text/javascript"> var _sf_async_config = { uid: 54141, domain: 'ionicframework.com', useCanonical: true }; (function() { function loadChartbeat() { window._sf_endpt = (new Date()).getTime(); var e = document.createElement('script'); e.setAttribute('language', 'javascript'); e.setAttribute('type', 'text/javascript'); e.setAttribute('src','//static.chartbeat.com/js/chartbeat.js'); document.body.appendChild(e); }; var oldonload = window.onload; window.onload = (typeof window.onload != 'function') ? loadChartbeat : function() { oldonload(); loadChartbeat(); }; })(); </script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script> <script src="/js/site.js?1"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/Cookies.js/0.4.0/cookies.min.js"></script> <script> $('.navbar .dropdown').on('show.bs.dropdown', function(e){ //$(this).find('.dropdown-menu').addClass('animated fadeInDown'); }); // ADD SLIDEUP ANIMATION TO DROPDOWN // $('.navbar .dropdown').on('hide.bs.dropdown', function(e){ //$(this).find('.dropdown-menu').first().stop(true, true).slideUp(200); //$(this).find('.dropdown-menu').removeClass('animated fadeInDown'); }); try { var d = new Date('2015-03-20 05:00:00 -0400'); var ts = d.getTime(); var cd = Cookies.get('_iondj'); if(cd) { cd = JSON.parse(atob(cd)); if(parseInt(cd.lp) < ts) { var bt = document.getElementById('blog-badge'); bt.style.display = 'block'; } cd.lp = ts; } else { var bt = document.getElementById('blog-badge'); bt.style.display = 'block'; cd = { lp: ts } } Cookies.set('_iondj', btoa(JSON.stringify(cd))); } catch(e) { } </script> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> </body> </html>
sachinvettithanam/ionic-site
_site/docs/1.0.0-beta.13/api/service/$ionicTemplateCache/index.html
HTML
apache-2.0
32,239
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 30524, 6412, 1000, 4180, 1027, 1000, 24774, 3084, 2009, 11...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
:- module(db_client_types, [ socketname/1, dbname/1, user/1, passwd/1, answertableterm/1, tuple/1, answertupleterm/1, sqlstring/1 ],[assertions,regtypes,basicmodes]). % ---------------------------------------------------------------------------- :- comment(title,"Types for the Low-level interface to SQL databases"). :- comment(author,"D. Cabeza, M. Carro, I. Caballero, and M. Hermenegildo."). :- comment(module,"This module implement the types for the low level interface to SQL databases"). % ---------------------------------------------------------------------------- :- regtype socketname(IPP) # "@var{IPP} is a structure describing a complete TCP/IP port address.". socketname( IPAddress : PortNumber ) :- atm(IPAddress), int(PortNumber). :- comment(socketname/1,"@includedef{socketname/1}"). % ---------------------------------------------------------------------------- :- regtype dbname(DBId) # "@var{DBId} is the identifier of an database.". dbname(DBId) :- atm(DBId). :- comment(dbname/1,"@includedef{dbname/1}"). :- regtype user(User) # "@var{User} is a user name in the database.". user(User) :- atm(User). :- comment(user/1,"@includedef{user/1}"). :- regtype passwd(Passwd) # "@var{Passwd} is the password for the user name in the database.". passwd(Passwd) :- atm(Passwd). :- comment(passwd/1,"@includedef{passwd/1}"). % ---------------------------------------------------------------------------- :- regtype answertupleterm(X) # "@var{X} is a predicate containing a tuple.". answertupleterm([]). answertupleterm(tup(T)) :- tuple(T). :- comment(answertupleterm/1,"@includedef{answertupleterm/1}"). % ---------------------------------------------------------------------------- :- regtype sqlstring(S) # "@var{S} is a string of SQL code.". sqlstring( S ) :- string(S). :- comment(sqlstring/1,"@includedef{sqlstring/1}"). :- comment(answertableterm/1,"Represents the types of responses that will be returned from the database interface. These can be a set of answer tuples, or the atom @tt{ok} in case of a successful addition or deletion."). :- regtype answertableterm(AT) # "@var{AT} is a response from the database interface.". answertableterm(ok). answertableterm(t(Answers)) :- list(Answers,tuple). answertableterm(err(Answer)) :- term(Answer). :- comment(answertableterm/1,"@includedef{answertableterm/1}"). :- regtype tuple(T) # "@var{T} is a tuple of values from the database interface.". tuple(T) :- list(T,atm). :- comment(tuple/1,"@includedef{tuple/1}").
leuschel/ecce
www/CiaoDE/ciao/library/persdb_mysql/db_client_types.pl
Perl
apache-2.0
2,597
[ 30522, 1024, 1011, 11336, 1006, 16962, 1035, 7396, 1035, 4127, 1010, 1031, 22278, 18442, 1013, 1015, 1010, 16962, 18442, 1013, 1015, 1010, 5310, 1013, 1015, 1010, 3413, 21724, 1013, 1015, 1010, 3437, 10880, 3334, 2213, 1013, 1015, 1010, 107...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magento.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magento.com for more information. * * @category Mage * @package Mage_CatalogIndex * @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Catalog indexer price processor * * @method Mage_CatalogIndex_Model_Resource_Indexer_Price _getResource() * @method Mage_CatalogIndex_Model_Resource_Indexer_Price getResource() * @method Mage_CatalogIndex_Model_Indexer_Price setEntityId(int $value) * @method int getCustomerGroupId() * @method Mage_CatalogIndex_Model_Indexer_Price setCustomerGroupId(int $value) * @method int getWebsiteId() * @method Mage_CatalogIndex_Model_Indexer_Price setWebsiteId(int $value) * @method int getTaxClassId() * @method Mage_CatalogIndex_Model_Indexer_Price setTaxClassId(int $value) * @method float getPrice() * @method Mage_CatalogIndex_Model_Indexer_Price setPrice(float $value) * @method float getFinalPrice() * @method Mage_CatalogIndex_Model_Indexer_Price setFinalPrice(float $value) * @method float getMinPrice() * @method Mage_CatalogIndex_Model_Indexer_Price setMinPrice(float $value) * @method float getMaxPrice() * @method Mage_CatalogIndex_Model_Indexer_Price setMaxPrice(float $value) * @method float getTierPrice() * @method Mage_CatalogIndex_Model_Indexer_Price setTierPrice(float $value) * * @category Mage * @package Mage_CatalogIndex * @author Magento Core Team <core@magentocommerce.com> */ class Mage_CatalogIndex_Model_Indexer_Price extends Mage_CatalogIndex_Model_Indexer_Abstract { protected $_customerGroups = array(); protected $_processChildrenForConfigurable = false; protected function _construct() { $this->_init('catalogindex/indexer_price'); $this->_customerGroups = Mage::getModel('customer/group')->getCollection(); } public function createIndexData(Mage_Catalog_Model_Product $object, Mage_Eav_Model_Entity_Attribute_Abstract $attribute = null) { $data = array(); $data['store_id'] = $attribute->getStoreId(); $data['entity_id'] = $object->getId(); $data['attribute_id'] = $attribute->getId(); $data['value'] = $object->getData($attribute->getAttributeCode()); if ($attribute->getAttributeCode() == 'price') { $result = array(); foreach ($this->_customerGroups as $group) { $object->setCustomerGroupId($group->getId()); $finalPrice = $object->getFinalPrice(); $row = $data; $row['customer_group_id'] = $group->getId(); $row['value'] = $finalPrice; $result[] = $row; } return $result; } return $data; } protected function _isAttributeIndexable(Mage_Eav_Model_Entity_Attribute_Abstract $attribute) { if ($attribute->getFrontendInput() != 'price') { return false; } if ($attribute->getAttributeCode() == 'tier_price') { return false; } if ($attribute->getAttributeCode() == 'minimal_price') { return false; } return true; } protected function _getIndexableAttributeConditions() { $conditions = "frontend_input = 'price' AND attribute_code <> 'price'"; return $conditions; } }
fabiensebban/magento
app/code/core/Mage/CatalogIndex/Model/Indexer/Price.php
PHP
mit
4,100
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 17454, 13663, 1008, 1008, 5060, 1997, 6105, 1008, 1008, 2023, 3120, 5371, 2003, 3395, 2000, 1996, 2330, 4007, 6105, 1006, 9808, 2140, 1017, 1012, 1014, 1007, 1008, 2008, 2003, 24378, 2007, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.ee.imperator.template.thymeleaf; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import org.thymeleaf.TemplateEngine; import org.thymeleaf.context.AbstractContext; import com.ee.imperator.template.Template; public class ThymeleafTemplate implements Template { private final String template; private final TemplateEngine engine; private final AbstractContext context; public ThymeleafTemplate(String template, TemplateEngine engine, AbstractContext context) { this.template = template; this.engine = engine; this.context = context; } @Override public Template setVariable(String key, Object value) { context.setVariable(key, value); return this; } @Override public String process() { return engine.process(template, context); } @Override public void process(OutputStream output) throws IOException { final Writer writer = new OutputStreamWriter(output); engine.process(template, context, writer); writer.flush(); } }
Assumeru/Imperator4J
src/main/java/com/ee/imperator/template/thymeleaf/ThymeleafTemplate.java
Java
apache-2.0
1,076
[ 30522, 7427, 4012, 1012, 25212, 1012, 17727, 6906, 4263, 1012, 23561, 1012, 15177, 10199, 5243, 2546, 1025, 12324, 9262, 1012, 22834, 1012, 22834, 10288, 24422, 1025, 12324, 9262, 1012, 22834, 1012, 27852, 25379, 1025, 12324, 9262, 1012, 2283...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# user.py is the autostart code for a ulnoiot node. # Configure your devices, sensors and local interaction here. # Always start with this to make everything from ulnoiot available. # Therefore, do not delete the following line. from ulnoiot import * # The following is just example code, adjust to your needs accordingly. # wifi and mqtt connect are done automatically, we assume for this example # the following configuration. # mqtt("ulnoiotgw", "myroom/test1") ## Use some shields # The onboard-led is always available. # With this configuration it will report under myroom/test1/blue # and can be set via sending off or on to myroom/test1/blue/test. from ulnoiot.shield.onboardled import blue blue.high() # make sure it's off (it's reversed) ## Add some other devices # Add a button with a slightly higher debounce rate, which will report # in the topic myroom/test1/button1. button("b1", d6, pullup=False, threshold=2) # Count rising signals on d2=Pin(4) and # report number counted at myroom/test1/shock1. # trigger("shock1",Pin(4)) ## Start to transmit every 10 seconds (or when status changed). # Don't forget the run-comamnd at the end. run(5)
ulno/micropython-extra-ulno
examples/integriot_test/testnode1/files/autostart.py
Python
mit
1,163
[ 30522, 1001, 5310, 1012, 1052, 2100, 2003, 1996, 8285, 14117, 2102, 3642, 2005, 1037, 17359, 3630, 25185, 13045, 1012, 1001, 9530, 8873, 27390, 2063, 2115, 5733, 1010, 13907, 1998, 2334, 8290, 2182, 1012, 1001, 2467, 2707, 2007, 2023, 2000,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php $this->load->Model('exam/Exam_manager_model'); $this->load->model('Branch/Course_model'); $exams = $this->Exam_manager_model->exam_details(); $exam_type = $this->Exam_manager_model->get_all_exam_type(); $branch = $this->Course_model->order_by_column('c_name'); ?> <div class="row"> <div class=col-lg-12> <!-- col-lg-12 start here --> <div class="panel-default toggle panelMove panelClose panelRefresh"></div> <div class=panel-body> <?php echo form_open(base_url() . 'exam/internal_create', array('class' => 'form-horizontal form-groups-bordered validate', 'role' => 'form', 'id' => 'examform', 'target' => '_top')); ?> <div class="padded"> <div class="form-group"> <label class="col-sm-4 control-label"><?php echo ucwords("Branch"); ?><span style="color:red">*</span></label> <div class="col-sm-8"> <select class="form-control" name="course" id="course"> <?php foreach ($branch as $course): ?> <option value="<?php echo $course->course_id; ?>"><?php echo $course->c_name; ?></option> <?php endforeach; ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label"><?php echo ucwords("Semester"); ?><span style="color:red">*</span></label> <div class="col-sm-8"> <select class="form-control" name="semester" id="semester"> </select> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label"><?php echo ucwords("Subejct"); ?><span style="color:red">*</span></label> <div class="col-sm-8"> <select class="form-control" name="subject" id="subject"> </select> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label"><?php echo ucwords("Title"); ?><span style="color:red">*</span></label> <div class="col-sm-8"> <input type="text" class="form-control" name="exam_name" id="exam_name" value="<?php echo set_value('exam_name'); ?>"/> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label"><?php echo ucwords("Total Marks"); ?><span style="color:red">*</span></label> <div class="col-sm-8"> <input type="number" class="form-control" name="total_marks" id="total_marks" min="0" value="<?php echo set_value('total_marks'); ?>"/> </div> </div> <div class="form-group"> <div class="col-sm-offset-4 col-sm-8"> <button type="submit" class="btn btn-info vd_bg-green"><?php echo ucwords("Add"); ?></button> </div> </div> <?php echo form_close(); ?> </div> </div> <!-- End .panel --> </div> <!-- col-lg-12 end here --> </div> <script> $(document).ready(function () { var js_date_format = '<?php echo js_dateformat(); ?>'; var date = ''; var start_date = ''; $('#edit_start_date').datepicker({ format: js_date_format, startDate: new Date(), autoclose: true, todayHighlight: true, }); $('#edit_start_date').on('change', function () { date = new Date($(this).val()); start_date = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear(); console.log(start_date); setTimeout(function () { $("#edit_end_date_time").datepicker({ format: js_date_format, autoclose: true, startDate: start_date }); }, 700); }); }) </script> <script type="text/javascript"> $.validator.setDefaults({ submitHandler: function (form) { form.submit(); } }); $().ready(function () { $("#examform").validate({ rules: { course: "required", semester: "required", subject:"required", exam_name:"required", total_marks: "required" }, messages: { course: "Select branch", semester: "Select semester", subject:"Select subject", exam_name:"Enter title", total_marks: "Enter total marks", } }); }); </script> <script> $(document).ready(function () { //course by degree $('#degree').on('change', function () { var course_id = $('#course').val(); var degree_id = $(this).val(); //remove all present element $('#course').find('option').remove().end(); $('#course').append('<option value="">Select</option>'); var degree_id = $(this).val(); $.ajax({ url: '<?php echo base_url(); ?>branch/department_branch/' + degree_id, type: 'get', success: function (content) { var course = jQuery.parseJSON(content); $.each(course, function (key, value) { $('#course').append('<option value=' + value.course_id + '>' + value.c_name + '</option>'); }) } }) batch_from_degree_and_course(degree_id, course_id); }); //batch from course and degree $('#course').on('change', function () { var course_id = $(this).val(); get_semester_from_branch(course_id); }) //find batch from degree and course function batch_from_degree_and_course(degree_id, course_id) { //remove all element from batch $('#batch').find('option').remove().end(); $.ajax({ url: '<?php echo base_url(); ?>batch/department_branch_batch/' + degree_id + '/' + course_id, type: 'get', success: function (content) { $('#batch').append('<option value="">Select</option>'); var batch = jQuery.parseJSON(content); console.log(batch); $.each(batch, function (key, value) { $('#batch').append('<option value=' + value.b_id + '>' + value.b_name + '</option>'); }) } }) } function get_subject_from_branch_semester(course_id,semester_id) { $('#subject').find('option').remove().end(); $.ajax({ url: '<?php echo base_url(); ?>subject/subejct_list_branch_sem/' + course_id +'/'+semester_id, type: 'get', success: function (content) { $('#subject').append('<option value="">Select</option>'); var subject = jQuery.parseJSON(content); $.each(subject, function (key, value) { $('#subject').append('<option value=' + value.sm_id + '>' + value.subject_name + '</option>'); }) } }) } //get semester from brach function get_semester_from_branch(branch_id) { $('#semester').find('option').remove().end(); $.ajax({ url: '<?php echo base_url(); ?>semester/semester_branch/' + branch_id, type: 'get', success: function (content) { $('#semester').append('<option value="">Select</option>'); var semester = jQuery.parseJSON(content); $.each(semester, function (key, value) { $('#semester').append('<option value=' + value.s_id + '>' + value.s_name + '</option>'); }) } }) } $("#semester").change(function(){ var course_id = $("#course").val(); var semester_id = $(this).val(); get_subject_from_branch_semester(course_id,semester_id); }); }) </script> <script> $(document).ready(function () { $('#total_marks').on('blur', function () { var total_marks = $(this).val(); $('#passing_marks').attr('max', total_marks); $('#passing_marks').attr('required', ''); }); $('#passing_marks').on('focus', function () { var total_marks = $('#total_marks').val(); $(this).attr('max', total_marks); }) }) </script> <script> $(document).ready(function () { var date = ''; var start_date = ''; $("#date").datepicker({ format: ' MM dd, yyyy', startDate: new Date(), todayHighlight: true, autoclose: true }); $('#date').on('change', function () { date = new Date($(this).val()); start_date = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear(); console.log(start_date); setTimeout(function () { $("#end_date_time").datepicker({ format: ' MM dd, yyyy', todayHighlight: true, startDate: start_date, autoclose: true, }); }, 700); }); }) </script>
mayursn/lms_hmvc_live
application/modules/exam/views/addinternal.php
PHP
mit
10,084
[ 30522, 1026, 1029, 25718, 1002, 2023, 1011, 1028, 7170, 1011, 1028, 2944, 1006, 1005, 11360, 1013, 11360, 1035, 3208, 1035, 2944, 1005, 1007, 1025, 1002, 2023, 1011, 1028, 7170, 1011, 1028, 2944, 1006, 1005, 3589, 1013, 2607, 1035, 30524, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * fs/f2fs/segment.c * * Copyright (c) 2012 Samsung Electronics Co., Ltd. * http://www.samsung.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/fs.h> #include <linux/f2fs_fs.h> #include <linux/bio.h> #include <linux/blkdev.h> #include <linux/prefetch.h> #include <linux/kthread.h> #include <linux/vmalloc.h> #include <linux/swap.h> #include "f2fs.h" #include "segment.h" #include "node.h" #include <trace/events/f2fs.h> #define __reverse_ffz(x) __reverse_ffs(~(x)) static struct kmem_cache *discard_entry_slab; static struct kmem_cache *sit_entry_set_slab; static struct kmem_cache *inmem_entry_slab; /** * Copied from latest lib/llist.c * llist_for_each_entry_safe - iterate over some deleted entries of * lock-less list of given type * safe against removal of list entry * @pos: the type * to use as a loop cursor. * @n: another type * to use as temporary storage * @node: the first entry of deleted list entries. * @member: the name of the llist_node with the struct. * * In general, some entries of the lock-less list can be traversed * safely only after being removed from list, so start with an entry * instead of list head. * * If being used on entries deleted from lock-less list directly, the * traverse order is from the newest to the oldest added entry. If * you want to traverse from the oldest to the newest, you must * reverse the order by yourself before traversing. */ #define llist_for_each_entry_safe(pos, n, node, member) \ for (pos = llist_entry((node), typeof(*pos), member); \ &pos->member != NULL && \ (n = llist_entry(pos->member.next, typeof(*n), member), true); \ pos = n) /** * Copied from latest lib/llist.c * llist_reverse_order - reverse order of a llist chain * @head: first item of the list to be reversed * * Reverse the order of a chain of llist entries and return the * new first entry. */ struct llist_node *llist_reverse_order(struct llist_node *head) { struct llist_node *new_head = NULL; while (head) { struct llist_node *tmp = head; head = head->next; tmp->next = new_head; new_head = tmp; } return new_head; } /** * Copied from latest linux/list.h * list_last_entry - get the last element from a list * @ptr: the list head to take the element from. * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. * * Note, that list is expected to be not empty. */ #define list_last_entry(ptr, type, member) \ list_entry((ptr)->prev, type, member) /* * __reverse_ffs is copied from include/asm-generic/bitops/__ffs.h since * MSB and LSB are reversed in a byte by f2fs_set_bit. */ static inline unsigned long __reverse_ffs(unsigned long word) { int num = 0; #if BITS_PER_LONG == 64 if ((word & 0xffffffff) == 0) { num += 32; word >>= 32; } #endif if ((word & 0xffff) == 0) { num += 16; word >>= 16; } if ((word & 0xff) == 0) { num += 8; word >>= 8; } if ((word & 0xf0) == 0) num += 4; else word >>= 4; if ((word & 0xc) == 0) num += 2; else word >>= 2; if ((word & 0x2) == 0) num += 1; return num; } /* * __find_rev_next(_zero)_bit is copied from lib/find_next_bit.c because * f2fs_set_bit makes MSB and LSB reversed in a byte. * Example: * LSB <--> MSB * f2fs_set_bit(0, bitmap) => 0000 0001 * f2fs_set_bit(7, bitmap) => 1000 0000 */ static unsigned long __find_rev_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { const unsigned long *p = addr + BIT_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG - 1); unsigned long tmp; unsigned long mask, submask; unsigned long quot, rest; if (offset >= size) return size; size -= result; offset %= BITS_PER_LONG; if (!offset) goto aligned; tmp = *(p++); quot = (offset >> 3) << 3; rest = offset & 0x7; mask = ~0UL << quot; submask = (unsigned char)(0xff << rest) >> rest; submask <<= quot; mask &= submask; tmp &= mask; if (size < BITS_PER_LONG) goto found_first; if (tmp) goto found_middle; size -= BITS_PER_LONG; result += BITS_PER_LONG; aligned: while (size & ~(BITS_PER_LONG-1)) { tmp = *(p++); if (tmp) goto found_middle; result += BITS_PER_LONG; size -= BITS_PER_LONG; } if (!size) return result; tmp = *p; found_first: tmp &= (~0UL >> (BITS_PER_LONG - size)); if (tmp == 0UL) /* Are any bits set? */ return result + size; /* Nope. */ found_middle: return result + __reverse_ffs(tmp); } static unsigned long __find_rev_next_zero_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { const unsigned long *p = addr + BIT_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG - 1); unsigned long tmp; unsigned long mask, submask; unsigned long quot, rest; if (offset >= size) return size; size -= result; offset %= BITS_PER_LONG; if (!offset) goto aligned; tmp = *(p++); quot = (offset >> 3) << 3; rest = offset & 0x7; mask = ~(~0UL << quot); submask = (unsigned char)~((unsigned char)(0xff << rest) >> rest); submask <<= quot; mask += submask; tmp |= mask; if (size < BITS_PER_LONG) goto found_first; if (~tmp) goto found_middle; size -= BITS_PER_LONG; result += BITS_PER_LONG; aligned: while (size & ~(BITS_PER_LONG - 1)) { tmp = *(p++); if (~tmp) goto found_middle; result += BITS_PER_LONG; size -= BITS_PER_LONG; } if (!size) return result; tmp = *p; found_first: tmp |= ~0UL << size; if (tmp == ~0UL) /* Are any bits zero? */ return result + size; /* Nope. */ found_middle: return result + __reverse_ffz(tmp); } void register_inmem_page(struct inode *inode, struct page *page) { struct f2fs_inode_info *fi = F2FS_I(inode); struct inmem_pages *new; int err; SetPagePrivate(page); new = f2fs_kmem_cache_alloc(inmem_entry_slab, GFP_NOFS); /* add atomic page indices to the list */ new->page = page; INIT_LIST_HEAD(&new->list); retry: /* increase reference count with clean state */ mutex_lock(&fi->inmem_lock); err = radix_tree_insert(&fi->inmem_root, page->index, new); if (err == -EEXIST) { mutex_unlock(&fi->inmem_lock); kmem_cache_free(inmem_entry_slab, new); return; } else if (err) { mutex_unlock(&fi->inmem_lock); goto retry; } get_page(page); list_add_tail(&new->list, &fi->inmem_pages); inc_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES); mutex_unlock(&fi->inmem_lock); } void invalidate_inmem_page(struct inode *inode, struct page *page) { struct f2fs_inode_info *fi = F2FS_I(inode); struct inmem_pages *cur; mutex_lock(&fi->inmem_lock); cur = radix_tree_lookup(&fi->inmem_root, page->index); if (cur) { radix_tree_delete(&fi->inmem_root, cur->page->index); f2fs_put_page(cur->page, 0); list_del(&cur->list); kmem_cache_free(inmem_entry_slab, cur); dec_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES); } mutex_unlock(&fi->inmem_lock); } void commit_inmem_pages(struct inode *inode, bool abort) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_inode_info *fi = F2FS_I(inode); struct inmem_pages *cur, *tmp; bool submit_bio = false; struct f2fs_io_info fio = { .type = DATA, .rw = WRITE_SYNC, }; /* * The abort is true only when f2fs_evict_inode is called. * Basically, the f2fs_evict_inode doesn't produce any data writes, so * that we don't need to call f2fs_balance_fs. * Otherwise, f2fs_gc in f2fs_balance_fs can wait forever until this * inode becomes free by iget_locked in f2fs_iget. */ if (!abort) f2fs_balance_fs(sbi); f2fs_lock_op(sbi); mutex_lock(&fi->inmem_lock); list_for_each_entry_safe(cur, tmp, &fi->inmem_pages, list) { lock_page(cur->page); if (!abort && cur->page->mapping == inode->i_mapping) { f2fs_wait_on_page_writeback(cur->page, DATA); if (clear_page_dirty_for_io(cur->page)) inode_dec_dirty_pages(inode); do_write_data_page(cur->page, &fio); submit_bio = true; } radix_tree_delete(&fi->inmem_root, cur->page->index); f2fs_put_page(cur->page, 1); list_del(&cur->list); kmem_cache_free(inmem_entry_slab, cur); dec_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES); } if (submit_bio) f2fs_submit_merged_bio(sbi, DATA, WRITE); mutex_unlock(&fi->inmem_lock); filemap_fdatawait_range(inode->i_mapping, 0, LLONG_MAX); f2fs_unlock_op(sbi); } /* * This function balances dirty node and dentry pages. * In addition, it controls garbage collection. */ void f2fs_balance_fs(struct f2fs_sb_info *sbi) { /* * We should do GC or end up with checkpoint, if there are so many dirty * dir/node pages without enough free segments. */ if (has_not_enough_free_secs(sbi, 0)) { mutex_lock(&sbi->gc_mutex); f2fs_gc(sbi); } } void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) { /* check the # of cached NAT entries and prefree segments */ if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || excess_prefree_segs(sbi) || available_free_memory(sbi, INO_ENTRIES)) f2fs_sync_fs(sbi->sb, true); } struct __submit_bio_ret { struct completion event; int error; }; static void __submit_bio_wait_endio(struct bio *bio, int error) { struct __submit_bio_ret *ret = bio->bi_private; ret->error = error; complete(&ret->event); } static int __submit_bio_wait(int rw, struct bio *bio) { struct __submit_bio_ret ret; rw |= REQ_SYNC; init_completion(&ret.event); bio->bi_private = &ret; bio->bi_end_io = __submit_bio_wait_endio; submit_bio(rw, bio); wait_for_completion(&ret.event); return ret.error; } static int issue_flush_thread(void *data) { struct f2fs_sb_info *sbi = data; struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; wait_queue_head_t *q = &fcc->flush_wait_queue; repeat: if (kthread_should_stop()) return 0; if (!llist_empty(&fcc->issue_list)) { struct bio *bio = bio_alloc(GFP_NOIO, 0); struct flush_cmd *cmd, *next; int ret; fcc->dispatch_list = llist_del_all(&fcc->issue_list); fcc->dispatch_list = llist_reverse_order(fcc->dispatch_list); bio->bi_bdev = sbi->sb->s_bdev; ret = __submit_bio_wait(WRITE_FLUSH, bio); llist_for_each_entry_safe(cmd, next, fcc->dispatch_list, llnode) { cmd->ret = ret; complete(&cmd->wait); } bio_put(bio); fcc->dispatch_list = NULL; } wait_event_interruptible(*q, kthread_should_stop() || !llist_empty(&fcc->issue_list)); goto repeat; } int f2fs_issue_flush(struct f2fs_sb_info *sbi) { struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; struct flush_cmd cmd; trace_f2fs_issue_flush(sbi->sb, test_opt(sbi, NOBARRIER), test_opt(sbi, FLUSH_MERGE)); if (test_opt(sbi, NOBARRIER)) return 0; if (!test_opt(sbi, FLUSH_MERGE)) return blkdev_issue_flush(sbi->sb->s_bdev, GFP_KERNEL, NULL); init_completion(&cmd.wait); llist_add(&cmd.llnode, &fcc->issue_list); if (!fcc->dispatch_list) wake_up(&fcc->flush_wait_queue); wait_for_completion(&cmd.wait); return cmd.ret; } int create_flush_cmd_control(struct f2fs_sb_info *sbi) { dev_t dev = sbi->sb->s_bdev->bd_dev; struct flush_cmd_control *fcc; int err = 0; fcc = kzalloc(sizeof(struct flush_cmd_control), GFP_KERNEL); if (!fcc) return -ENOMEM; init_waitqueue_head(&fcc->flush_wait_queue); init_llist_head(&fcc->issue_list); SM_I(sbi)->cmd_control_info = fcc; fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); if (IS_ERR(fcc->f2fs_issue_flush)) { err = PTR_ERR(fcc->f2fs_issue_flush); kfree(fcc); SM_I(sbi)->cmd_control_info = NULL; return err; } return err; } void destroy_flush_cmd_control(struct f2fs_sb_info *sbi) { struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; if (fcc && fcc->f2fs_issue_flush) kthread_stop(fcc->f2fs_issue_flush); kfree(fcc); SM_I(sbi)->cmd_control_info = NULL; } static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, enum dirty_type dirty_type) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); /* need not be added */ if (IS_CURSEG(sbi, segno)) return; if (!test_and_set_bit(segno, dirty_i->dirty_segmap[dirty_type])) dirty_i->nr_dirty[dirty_type]++; if (dirty_type == DIRTY) { struct seg_entry *sentry = get_seg_entry(sbi, segno); enum dirty_type t = sentry->type; if (unlikely(t >= DIRTY)) { f2fs_bug_on(sbi, 1); return; } if (!test_and_set_bit(segno, dirty_i->dirty_segmap[t])) dirty_i->nr_dirty[t]++; } } static void __remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, enum dirty_type dirty_type) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); if (test_and_clear_bit(segno, dirty_i->dirty_segmap[dirty_type])) dirty_i->nr_dirty[dirty_type]--; if (dirty_type == DIRTY) { struct seg_entry *sentry = get_seg_entry(sbi, segno); enum dirty_type t = sentry->type; if (test_and_clear_bit(segno, dirty_i->dirty_segmap[t])) dirty_i->nr_dirty[t]--; if (get_valid_blocks(sbi, segno, sbi->segs_per_sec) == 0) clear_bit(GET_SECNO(sbi, segno), dirty_i->victim_secmap); } } /* * Should not occur error such as -ENOMEM. * Adding dirty entry into seglist is not critical operation. * If a given segment is one of current working segments, it won't be added. */ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); unsigned short valid_blocks; if (segno == NULL_SEGNO || IS_CURSEG(sbi, segno)) return; mutex_lock(&dirty_i->seglist_lock); valid_blocks = get_valid_blocks(sbi, segno, 0); if (valid_blocks == 0) { __locate_dirty_segment(sbi, segno, PRE); __remove_dirty_segment(sbi, segno, DIRTY); } else if (valid_blocks < sbi->blocks_per_seg) { __locate_dirty_segment(sbi, segno, DIRTY); } else { /* Recovery routine with SSR needs this */ __remove_dirty_segment(sbi, segno, DIRTY); } mutex_unlock(&dirty_i->seglist_lock); } static int f2fs_issue_discard(struct f2fs_sb_info *sbi, block_t blkstart, block_t blklen) { sector_t start = SECTOR_FROM_BLOCK(blkstart); sector_t len = SECTOR_FROM_BLOCK(blklen); trace_f2fs_issue_discard(sbi->sb, blkstart, blklen); return blkdev_issue_discard(sbi->sb->s_bdev, start, len, GFP_NOFS, 0); } void discard_next_dnode(struct f2fs_sb_info *sbi, block_t blkaddr) { if (f2fs_issue_discard(sbi, blkaddr, 1)) { struct page *page = grab_meta_page(sbi, blkaddr); /* zero-filled page */ set_page_dirty(page); f2fs_put_page(page, 1); } } static void __add_discard_entry(struct f2fs_sb_info *sbi, struct cp_control *cpc, unsigned int start, unsigned int end) { struct list_head *head = &SM_I(sbi)->discard_list; struct discard_entry *new, *last; if (!list_empty(head)) { last = list_last_entry(head, struct discard_entry, list); if (START_BLOCK(sbi, cpc->trim_start) + start == last->blkaddr + last->len) { last->len += end - start; goto done; } } new = f2fs_kmem_cache_alloc(discard_entry_slab, GFP_NOFS); INIT_LIST_HEAD(&new->list); new->blkaddr = START_BLOCK(sbi, cpc->trim_start) + start; new->len = end - start; list_add_tail(&new->list, head); done: SM_I(sbi)->nr_discards += end - start; cpc->trimmed += end - start; } static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) { int entries = SIT_VBLOCK_MAP_SIZE / sizeof(unsigned long); int max_blocks = sbi->blocks_per_seg; struct seg_entry *se = get_seg_entry(sbi, cpc->trim_start); unsigned long *cur_map = (unsigned long *)se->cur_valid_map; unsigned long *ckpt_map = (unsigned long *)se->ckpt_valid_map; unsigned long dmap[entries]; unsigned int start = 0, end = -1; bool force = (cpc->reason == CP_DISCARD); int i; if (!force && !test_opt(sbi, DISCARD)) return; if (force && !se->valid_blocks) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); /* * if this segment is registered in the prefree list, then * we should skip adding a discard candidate, and let the * checkpoint do that later. */ mutex_lock(&dirty_i->seglist_lock); if (test_bit(cpc->trim_start, dirty_i->dirty_segmap[PRE])) { mutex_unlock(&dirty_i->seglist_lock); cpc->trimmed += sbi->blocks_per_seg; return; } mutex_unlock(&dirty_i->seglist_lock); __add_discard_entry(sbi, cpc, 0, sbi->blocks_per_seg); return; } /* zero block will be discarded through the prefree list */ if (!se->valid_blocks || se->valid_blocks == max_blocks) return; /* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */ for (i = 0; i < entries; i++) dmap[i] = ~(cur_map[i] | ckpt_map[i]); while (force || SM_I(sbi)->nr_discards <= SM_I(sbi)->max_discards) { start = __find_rev_next_bit(dmap, max_blocks, end + 1); if (start >= max_blocks) break; end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1); if (end - start < cpc->trim_minlen) continue; __add_discard_entry(sbi, cpc, start, end); } } void release_discard_addrs(struct f2fs_sb_info *sbi) { struct list_head *head = &(SM_I(sbi)->discard_list); struct discard_entry *entry, *this; /* drop caches */ list_for_each_entry_safe(entry, this, head, list) { list_del(&entry->list); kmem_cache_free(discard_entry_slab, entry); } } /* * Should call clear_prefree_segments after checkpoint is done. */ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); unsigned int segno; mutex_lock(&dirty_i->seglist_lock); for_each_set_bit(segno, dirty_i->dirty_segmap[PRE], MAIN_SEGS(sbi)) __set_test_and_free(sbi, segno); mutex_unlock(&dirty_i->seglist_lock); } void clear_prefree_segments(struct f2fs_sb_info *sbi) { struct list_head *head = &(SM_I(sbi)->discard_list); struct discard_entry *entry, *this; struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); unsigned long *prefree_map = dirty_i->dirty_segmap[PRE]; unsigned int start = 0, end = -1; mutex_lock(&dirty_i->seglist_lock); while (1) { int i; start = find_next_bit(prefree_map, MAIN_SEGS(sbi), end + 1); if (start >= MAIN_SEGS(sbi)) break; end = find_next_zero_bit(prefree_map, MAIN_SEGS(sbi), start + 1); for (i = start; i < end; i++) clear_bit(i, prefree_map); dirty_i->nr_dirty[PRE] -= end - start; if (!test_opt(sbi, DISCARD)) continue; f2fs_issue_discard(sbi, START_BLOCK(sbi, start), (end - start) << sbi->log_blocks_per_seg); } mutex_unlock(&dirty_i->seglist_lock); /* send small discards */ list_for_each_entry_safe(entry, this, head, list) { f2fs_issue_discard(sbi, entry->blkaddr, entry->len); list_del(&entry->list); SM_I(sbi)->nr_discards -= entry->len; kmem_cache_free(discard_entry_slab, entry); } } static bool __mark_sit_entry_dirty(struct f2fs_sb_info *sbi, unsigned int segno) { struct sit_info *sit_i = SIT_I(sbi); if (!__test_and_set_bit(segno, sit_i->dirty_sentries_bitmap)) { sit_i->dirty_sentries++; return false; } return true; } static void __set_sit_entry_type(struct f2fs_sb_info *sbi, int type, unsigned int segno, int modified) { struct seg_entry *se = get_seg_entry(sbi, segno); se->type = type; if (modified) __mark_sit_entry_dirty(sbi, segno); } static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) { struct seg_entry *se; unsigned int segno, offset; long int new_vblocks; segno = GET_SEGNO(sbi, blkaddr); se = get_seg_entry(sbi, segno); new_vblocks = se->valid_blocks + del; offset = GET_BLKOFF_FROM_SEG0(sbi, blkaddr); f2fs_bug_on(sbi, (new_vblocks >> (sizeof(unsigned short) << 3) || (new_vblocks > sbi->blocks_per_seg))); se->valid_blocks = new_vblocks; se->mtime = get_mtime(sbi); SIT_I(sbi)->max_mtime = se->mtime; /* Update valid block bitmap */ if (del > 0) { if (f2fs_test_and_set_bit(offset, se->cur_valid_map)) f2fs_bug_on(sbi, 1); } else { if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map)) f2fs_bug_on(sbi, 1); } if (!f2fs_test_bit(offset, se->ckpt_valid_map)) se->ckpt_valid_blocks += del; __mark_sit_entry_dirty(sbi, segno); /* update total number of valid blocks to be written in ckpt area */ SIT_I(sbi)->written_valid_blocks += del; if (sbi->segs_per_sec > 1) get_sec_entry(sbi, segno)->valid_blocks += del; } void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new) { update_sit_entry(sbi, new, 1); if (GET_SEGNO(sbi, old) != NULL_SEGNO) update_sit_entry(sbi, old, -1); locate_dirty_segment(sbi, GET_SEGNO(sbi, old)); locate_dirty_segment(sbi, GET_SEGNO(sbi, new)); } void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr) { unsigned int segno = GET_SEGNO(sbi, addr); struct sit_info *sit_i = SIT_I(sbi); f2fs_bug_on(sbi, addr == NULL_ADDR); if (addr == NEW_ADDR) return; /* add it into sit main buffer */ mutex_lock(&sit_i->sentry_lock); update_sit_entry(sbi, addr, -1); /* add it into dirty seglist */ locate_dirty_segment(sbi, segno); mutex_unlock(&sit_i->sentry_lock); } /* * This function should be resided under the curseg_mutex lock */ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type, struct f2fs_summary *sum) { struct curseg_info *curseg = CURSEG_I(sbi, type); void *addr = curseg->sum_blk; addr += curseg->next_blkoff * sizeof(struct f2fs_summary); memcpy(addr, sum, sizeof(struct f2fs_summary)); } /* * Calculate the number of current summary pages for writing */ int npages_for_summary_flush(struct f2fs_sb_info *sbi) { int valid_sum_count = 0; int i, sum_in_page; for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { if (sbi->ckpt->alloc_type[i] == SSR) valid_sum_count += sbi->blocks_per_seg; else valid_sum_count += curseg_blkoff(sbi, i); } sum_in_page = (PAGE_CACHE_SIZE - 2 * SUM_JOURNAL_SIZE - SUM_FOOTER_SIZE) / SUMMARY_SIZE; if (valid_sum_count <= sum_in_page) return 1; else if ((valid_sum_count - sum_in_page) <= (PAGE_CACHE_SIZE - SUM_FOOTER_SIZE) / SUMMARY_SIZE) return 2; return 3; } /* * Caller should put this summary page */ struct page *get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno) { return get_meta_page(sbi, GET_SUM_BLOCK(sbi, segno)); } static void write_sum_page(struct f2fs_sb_info *sbi, struct f2fs_summary_block *sum_blk, block_t blk_addr) { struct page *page = grab_meta_page(sbi, blk_addr); void *kaddr = page_address(page); memcpy(kaddr, sum_blk, PAGE_CACHE_SIZE); set_page_dirty(page); f2fs_put_page(page, 1); } static int is_next_segment_free(struct f2fs_sb_info *sbi, int type) { struct curseg_info *curseg = CURSEG_I(sbi, type); unsigned int segno = curseg->segno + 1; struct free_segmap_info *free_i = FREE_I(sbi); if (segno < MAIN_SEGS(sbi) && segno % sbi->segs_per_sec) return !test_bit(segno, free_i->free_segmap); return 0; } /* * Find a new segment from the free segments bitmap to right order * This function should be returned with success, otherwise BUG */ static void get_new_segment(struct f2fs_sb_info *sbi, unsigned int *newseg, bool new_sec, int dir) { struct free_segmap_info *free_i = FREE_I(sbi); unsigned int segno, secno, zoneno; unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone; unsigned int hint = *newseg / sbi->segs_per_sec; unsigned int old_zoneno = GET_ZONENO_FROM_SEGNO(sbi, *newseg); unsigned int left_start = hint; bool init = true; int go_left = 0; int i; write_lock(&free_i->segmap_lock); if (!new_sec && ((*newseg + 1) % sbi->segs_per_sec)) { segno = find_next_zero_bit(free_i->free_segmap, MAIN_SEGS(sbi), *newseg + 1); if (segno - *newseg < sbi->segs_per_sec - (*newseg % sbi->segs_per_sec)) goto got_it; } find_other_zone: secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); if (secno >= MAIN_SECS(sbi)) { if (dir == ALLOC_RIGHT) { secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), 0); f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); } else { go_left = 1; left_start = hint - 1; } } if (go_left == 0) goto skip_left; while (test_bit(left_start, free_i->free_secmap)) { if (left_start > 0) { left_start--; continue; } left_start = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), 0); f2fs_bug_on(sbi, left_start >= MAIN_SECS(sbi)); break; } secno = left_start; skip_left: hint = secno; segno = secno * sbi->segs_per_sec; zoneno = secno / sbi->secs_per_zone; /* give up on finding another zone */ if (!init) goto got_it; if (sbi->secs_per_zone == 1) goto got_it; if (zoneno == old_zoneno) goto got_it; if (dir == ALLOC_LEFT) { if (!go_left && zoneno + 1 >= total_zones) goto got_it; if (go_left && zoneno == 0) goto got_it; } for (i = 0; i < NR_CURSEG_TYPE; i++) if (CURSEG_I(sbi, i)->zone == zoneno) break; if (i < NR_CURSEG_TYPE) { /* zone is in user, try another */ if (go_left) hint = zoneno * sbi->secs_per_zone - 1; else if (zoneno + 1 >= total_zones) hint = 0; else hint = (zoneno + 1) * sbi->secs_per_zone; init = false; goto find_other_zone; } got_it: /* set it as dirty segment in free segmap */ f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); __set_inuse(sbi, segno); *newseg = segno; write_unlock(&free_i->segmap_lock); } static void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified) { struct curseg_info *curseg = CURSEG_I(sbi, type); struct summary_footer *sum_footer; curseg->segno = curseg->next_segno; curseg->zone = GET_ZONENO_FROM_SEGNO(sbi, curseg->segno); curseg->next_blkoff = 0; curseg->next_segno = NULL_SEGNO; sum_footer = &(curseg->sum_blk->footer); memset(sum_footer, 0, sizeof(struct summary_footer)); if (IS_DATASEG(type)) SET_SUM_TYPE(sum_footer, SUM_TYPE_DATA); if (IS_NODESEG(type)) SET_SUM_TYPE(sum_footer, SUM_TYPE_NODE); __set_sit_entry_type(sbi, type, curseg->segno, modified); } /* * Allocate a current working segment. * This function always allocates a free segment in LFS manner. */ static void new_curseg(struct f2fs_sb_info *sbi, int type, bool new_sec) { struct curseg_info *curseg = CURSEG_I(sbi, type); unsigned int segno = curseg->segno; int dir = ALLOC_LEFT; write_sum_page(sbi, curseg->sum_blk, GET_SUM_BLOCK(sbi, segno)); if (type == CURSEG_WARM_DATA || type == CURSEG_COLD_DATA) dir = ALLOC_RIGHT; if (test_opt(sbi, NOHEAP)) dir = ALLOC_RIGHT; get_new_segment(sbi, &segno, new_sec, dir); curseg->next_segno = segno; reset_curseg(sbi, type, 1); curseg->alloc_type = LFS; } static void __next_free_blkoff(struct f2fs_sb_info *sbi, struct curseg_info *seg, block_t start) { struct seg_entry *se = get_seg_entry(sbi, seg->segno); int entries = SIT_VBLOCK_MAP_SIZE / sizeof(unsigned long); unsigned long target_map[entries]; unsigned long *ckpt_map = (unsigned long *)se->ckpt_valid_map; unsigned long *cur_map = (unsigned long *)se->cur_valid_map; int i, pos; for (i = 0; i < entries; i++) target_map[i] = ckpt_map[i] | cur_map[i]; pos = __find_rev_next_zero_bit(target_map, sbi->blocks_per_seg, start); seg->next_blkoff = pos; } /* * If a segment is written by LFS manner, next block offset is just obtained * by increasing the current block offset. However, if a segment is written by * SSR manner, next block offset obtained by calling __next_free_blkoff */ static void __refresh_next_blkoff(struct f2fs_sb_info *sbi, struct curseg_info *seg) { if (seg->alloc_type == SSR) __next_free_blkoff(sbi, seg, seg->next_blkoff + 1); else seg->next_blkoff++; } /* * This function always allocates a used segment(from dirty seglist) by SSR * manner, so it should recover the existing segment information of valid blocks */ static void change_curseg(struct f2fs_sb_info *sbi, int type, bool reuse) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); struct curseg_info *curseg = CURSEG_I(sbi, type); unsigned int new_segno = curseg->next_segno; struct f2fs_summary_block *sum_node; struct page *sum_page; write_sum_page(sbi, curseg->sum_blk, GET_SUM_BLOCK(sbi, curseg->segno)); __set_test_and_inuse(sbi, new_segno); mutex_lock(&dirty_i->seglist_lock); __remove_dirty_segment(sbi, new_segno, PRE); __remove_dirty_segment(sbi, new_segno, DIRTY); mutex_unlock(&dirty_i->seglist_lock); reset_curseg(sbi, type, 1); curseg->alloc_type = SSR; __next_free_blkoff(sbi, curseg, 0); if (reuse) { sum_page = get_sum_page(sbi, new_segno); sum_node = (struct f2fs_summary_block *)page_address(sum_page); memcpy(curseg->sum_blk, sum_node, SUM_ENTRY_SIZE); f2fs_put_page(sum_page, 1); } } static int get_ssr_segment(struct f2fs_sb_info *sbi, int type) { struct curseg_info *curseg = CURSEG_I(sbi, type); const struct victim_selection *v_ops = DIRTY_I(sbi)->v_ops; if (IS_NODESEG(type) || !has_not_enough_free_secs(sbi, 0)) return v_ops->get_victim(sbi, &(curseg)->next_segno, BG_GC, type, SSR); /* For data segments, let's do SSR more intensively */ for (; type >= CURSEG_HOT_DATA; type--) if (v_ops->get_victim(sbi, &(curseg)->next_segno, BG_GC, type, SSR)) return 1; return 0; } /* * flush out current segment and replace it with new segment * This function should be returned with success, otherwise BUG */ static void allocate_segment_by_default(struct f2fs_sb_info *sbi, int type, bool force) { struct curseg_info *curseg = CURSEG_I(sbi, type); if (force) new_curseg(sbi, type, true); else if (type == CURSEG_WARM_NODE) new_curseg(sbi, type, false); else if (curseg->alloc_type == LFS && is_next_segment_free(sbi, type)) new_curseg(sbi, type, false); else if (need_SSR(sbi) && get_ssr_segment(sbi, type)) change_curseg(sbi, type, true); else new_curseg(sbi, type, false); stat_inc_seg_type(sbi, curseg); } void allocate_new_segments(struct f2fs_sb_info *sbi) { struct curseg_info *curseg; unsigned int old_curseg; int i; for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { curseg = CURSEG_I(sbi, i); old_curseg = curseg->segno; SIT_I(sbi)->s_ops->allocate_segment(sbi, i, true); locate_dirty_segment(sbi, old_curseg); } } static const struct segment_allocation default_salloc_ops = { .allocate_segment = allocate_segment_by_default, }; int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) { __u64 start = range->start >> sbi->log_blocksize; __u64 end = start + (range->len >> sbi->log_blocksize) - 1; unsigned int start_segno, end_segno; struct cp_control cpc; if (range->minlen > SEGMENT_SIZE(sbi) || start >= MAX_BLKADDR(sbi) || range->len < sbi->blocksize) return -EINVAL; cpc.trimmed = 0; if (end <= MAIN_BLKADDR(sbi)) goto out; /* start/end segment number in main_area */ start_segno = (start <= MAIN_BLKADDR(sbi)) ? 0 : GET_SEGNO(sbi, start); end_segno = (end >= MAX_BLKADDR(sbi)) ? MAIN_SEGS(sbi) - 1 : GET_SEGNO(sbi, end); cpc.reason = CP_DISCARD; cpc.trim_start = start_segno; cpc.trim_end = end_segno; cpc.trim_minlen = range->minlen >> sbi->log_blocksize; /* do checkpoint to issue discard commands safely */ mutex_lock(&sbi->gc_mutex); write_checkpoint(sbi, &cpc); mutex_unlock(&sbi->gc_mutex); out: range->len = cpc.trimmed << sbi->log_blocksize; return 0; } static bool __has_curseg_space(struct f2fs_sb_info *sbi, int type) { struct curseg_info *curseg = CURSEG_I(sbi, type); if (curseg->next_blkoff < sbi->blocks_per_seg) return true; return false; } static int __get_segment_type_2(struct page *page, enum page_type p_type) { if (p_type == DATA) return CURSEG_HOT_DATA; else return CURSEG_HOT_NODE; } static int __get_segment_type_4(struct page *page, enum page_type p_type) { if (p_type == DATA) { struct inode *inode = page->mapping->host; if (S_ISDIR(inode->i_mode)) return CURSEG_HOT_DATA; else return CURSEG_COLD_DATA; } else { if (IS_DNODE(page) && is_cold_node(page)) return CURSEG_WARM_NODE; else return CURSEG_COLD_NODE; } } static int __get_segment_type_6(struct page *page, enum page_type p_type) { if (p_type == DATA) { struct inode *inode = page->mapping->host; if (S_ISDIR(inode->i_mode)) return CURSEG_HOT_DATA; else if (is_cold_data(page) || file_is_cold(inode)) return CURSEG_COLD_DATA; else return CURSEG_WARM_DATA; } else { if (IS_DNODE(page)) return is_cold_node(page) ? CURSEG_WARM_NODE : CURSEG_HOT_NODE; else return CURSEG_COLD_NODE; } } static int __get_segment_type(struct page *page, enum page_type p_type) { switch (F2FS_P_SB(page)->active_logs) { case 2: return __get_segment_type_2(page, p_type); case 4: return __get_segment_type_4(page, p_type); } /* NR_CURSEG_TYPE(6) logs by default */ f2fs_bug_on(F2FS_P_SB(page), F2FS_P_SB(page)->active_logs != NR_CURSEG_TYPE); return __get_segment_type_6(page, p_type); } void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, block_t old_blkaddr, block_t *new_blkaddr, struct f2fs_summary *sum, int type) { struct sit_info *sit_i = SIT_I(sbi); struct curseg_info *curseg; curseg = CURSEG_I(sbi, type); mutex_lock(&curseg->curseg_mutex); *new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg); /* * __add_sum_entry should be resided under the curseg_mutex * because, this function updates a summary entry in the * current summary block. */ __add_sum_entry(sbi, type, sum); mutex_lock(&sit_i->sentry_lock); __refresh_next_blkoff(sbi, curseg); stat_inc_block_count(sbi, curseg); if (!__has_curseg_space(sbi, type)) sit_i->s_ops->allocate_segment(sbi, type, false); /* * SIT information should be updated before segment allocation, * since SSR needs latest valid block information. */ refresh_sit_entry(sbi, old_blkaddr, *new_blkaddr); mutex_unlock(&sit_i->sentry_lock); if (page && IS_NODESEG(type)) fill_node_footer_blkaddr(page, NEXT_FREE_BLKADDR(sbi, curseg)); mutex_unlock(&curseg->curseg_mutex); } static void do_write_page(struct f2fs_sb_info *sbi, struct page *page, block_t old_blkaddr, block_t *new_blkaddr, struct f2fs_summary *sum, struct f2fs_io_info *fio) { int type = __get_segment_type(page, fio->type); allocate_data_block(sbi, page, old_blkaddr, new_blkaddr, sum, type); /* writeout dirty page into bdev */ f2fs_submit_page_mbio(sbi, page, *new_blkaddr, fio); } void write_meta_page(struct f2fs_sb_info *sbi, struct page *page) { struct f2fs_io_info fio = { .type = META, .rw = WRITE_SYNC | REQ_META | REQ_PRIO }; set_page_writeback(page); f2fs_submit_page_mbio(sbi, page, page->index, &fio); } void write_node_page(struct f2fs_sb_info *sbi, struct page *page, struct f2fs_io_info *fio, unsigned int nid, block_t old_blkaddr, block_t *new_blkaddr) { struct f2fs_summary sum; set_summary(&sum, nid, 0, 0); do_write_page(sbi, page, old_blkaddr, new_blkaddr, &sum, fio); } void write_data_page(struct page *page, struct dnode_of_data *dn, block_t *new_blkaddr, struct f2fs_io_info *fio) { struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); struct f2fs_summary sum; struct node_info ni; f2fs_bug_on(sbi, dn->data_blkaddr == NULL_ADDR); get_node_info(sbi, dn->nid, &ni); set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version); do_write_page(sbi, page, dn->data_blkaddr, new_blkaddr, &sum, fio); } void rewrite_data_page(struct page *page, block_t old_blkaddr, struct f2fs_io_info *fio) { f2fs_submit_page_mbio(F2FS_P_SB(page), page, old_blkaddr, fio); } void recover_data_page(struct f2fs_sb_info *sbi, struct page *page, struct f2fs_summary *sum, block_t old_blkaddr, block_t new_blkaddr) { struct sit_info *sit_i = SIT_I(sbi); struct curseg_info *curseg; unsigned int segno, old_cursegno; struct seg_entry *se; int type; segno = GET_SEGNO(sbi, new_blkaddr); se = get_seg_entry(sbi, segno); type = se->type; if (se->valid_blocks == 0 && !IS_CURSEG(sbi, segno)) { if (old_blkaddr == NULL_ADDR) type = CURSEG_COLD_DATA; else type = CURSEG_WARM_DATA; } curseg = CURSEG_I(sbi, type); mutex_lock(&curseg->curseg_mutex); mutex_lock(&sit_i->sentry_lock); old_cursegno = curseg->segno; /* change the current segment */ if (segno != curseg->segno) { curseg->next_segno = segno; change_curseg(sbi, type, true); } curseg->next_blkoff = GET_BLKOFF_FROM_SEG0(sbi, new_blkaddr); __add_sum_entry(sbi, type, sum); refresh_sit_entry(sbi, old_blkaddr, new_blkaddr); locate_dirty_segment(sbi, old_cursegno); mutex_unlock(&sit_i->sentry_lock); mutex_unlock(&curseg->curseg_mutex); } static inline bool is_merged_page(struct f2fs_sb_info *sbi, struct page *page, enum page_type type) { enum page_type btype = PAGE_TYPE_OF_BIO(type); struct f2fs_bio_info *io = &sbi->write_io[btype]; struct bio_vec *bvec; int i; down_read(&io->io_rwsem); if (!io->bio) goto out; __bio_for_each_segment(bvec, io->bio, i, 0) { if (page == bvec->bv_page) { up_read(&io->io_rwsem); return true; } } out: up_read(&io->io_rwsem); return false; } void f2fs_wait_on_page_writeback(struct page *page, enum page_type type) { if (PageWriteback(page)) { struct f2fs_sb_info *sbi = F2FS_P_SB(page); if (is_merged_page(sbi, page, type)) f2fs_submit_merged_bio(sbi, type, WRITE); wait_on_page_writeback(page); } } static int read_compacted_summaries(struct f2fs_sb_info *sbi) { struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); struct curseg_info *seg_i; unsigned char *kaddr; struct page *page; block_t start; int i, j, offset; start = start_sum_block(sbi); page = get_meta_page(sbi, start++); kaddr = (unsigned char *)page_address(page); /* Step 1: restore nat cache */ seg_i = CURSEG_I(sbi, CURSEG_HOT_DATA); memcpy(&seg_i->sum_blk->n_nats, kaddr, SUM_JOURNAL_SIZE); /* Step 2: restore sit cache */ seg_i = CURSEG_I(sbi, CURSEG_COLD_DATA); memcpy(&seg_i->sum_blk->n_sits, kaddr + SUM_JOURNAL_SIZE, SUM_JOURNAL_SIZE); offset = 2 * SUM_JOURNAL_SIZE; /* Step 3: restore summary entries */ for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { unsigned short blk_off; unsigned int segno; seg_i = CURSEG_I(sbi, i); segno = le32_to_cpu(ckpt->cur_data_segno[i]); blk_off = le16_to_cpu(ckpt->cur_data_blkoff[i]); seg_i->next_segno = segno; reset_curseg(sbi, i, 0); seg_i->alloc_type = ckpt->alloc_type[i]; seg_i->next_blkoff = blk_off; if (seg_i->alloc_type == SSR) blk_off = sbi->blocks_per_seg; for (j = 0; j < blk_off; j++) { struct f2fs_summary *s; s = (struct f2fs_summary *)(kaddr + offset); seg_i->sum_blk->entries[j] = *s; offset += SUMMARY_SIZE; if (offset + SUMMARY_SIZE <= PAGE_CACHE_SIZE - SUM_FOOTER_SIZE) continue; f2fs_put_page(page, 1); page = NULL; page = get_meta_page(sbi, start++); kaddr = (unsigned char *)page_address(page); offset = 0; } } f2fs_put_page(page, 1); return 0; } static int read_normal_summaries(struct f2fs_sb_info *sbi, int type) { struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); struct f2fs_summary_block *sum; struct curseg_info *curseg; struct page *new; unsigned short blk_off; unsigned int segno = 0; block_t blk_addr = 0; /* get segment number and block addr */ if (IS_DATASEG(type)) { segno = le32_to_cpu(ckpt->cur_data_segno[type]); blk_off = le16_to_cpu(ckpt->cur_data_blkoff[type - CURSEG_HOT_DATA]); if (is_set_ckpt_flags(ckpt, CP_UMOUNT_FLAG)) blk_addr = sum_blk_addr(sbi, NR_CURSEG_TYPE, type); else blk_addr = sum_blk_addr(sbi, NR_CURSEG_DATA_TYPE, type); } else { segno = le32_to_cpu(ckpt->cur_node_segno[type - CURSEG_HOT_NODE]); blk_off = le16_to_cpu(ckpt->cur_node_blkoff[type - CURSEG_HOT_NODE]); if (is_set_ckpt_flags(ckpt, CP_UMOUNT_FLAG)) blk_addr = sum_blk_addr(sbi, NR_CURSEG_NODE_TYPE, type - CURSEG_HOT_NODE); else blk_addr = GET_SUM_BLOCK(sbi, segno); } new = get_meta_page(sbi, blk_addr); sum = (struct f2fs_summary_block *)page_address(new); if (IS_NODESEG(type)) { if (is_set_ckpt_flags(ckpt, CP_UMOUNT_FLAG)) { struct f2fs_summary *ns = &sum->entries[0]; int i; for (i = 0; i < sbi->blocks_per_seg; i++, ns++) { ns->version = 0; ns->ofs_in_node = 0; } } else { int err; err = restore_node_summary(sbi, segno, sum); if (err) { f2fs_put_page(new, 1); return err; } } } /* set uncompleted segment to curseg */ curseg = CURSEG_I(sbi, type); mutex_lock(&curseg->curseg_mutex); memcpy(curseg->sum_blk, sum, PAGE_CACHE_SIZE); curseg->next_segno = segno; reset_curseg(sbi, type, 0); curseg->alloc_type = ckpt->alloc_type[type]; curseg->next_blkoff = blk_off; mutex_unlock(&curseg->curseg_mutex); f2fs_put_page(new, 1); return 0; } static int restore_curseg_summaries(struct f2fs_sb_info *sbi) { int type = CURSEG_HOT_DATA; int err; if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_COMPACT_SUM_FLAG)) { /* restore for compacted data summary */ if (read_compacted_summaries(sbi)) return -EINVAL; type = CURSEG_HOT_NODE; } for (; type <= CURSEG_COLD_NODE; type++) { err = read_normal_summaries(sbi, type); if (err) return err; } return 0; } static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr) { struct page *page; unsigned char *kaddr; struct f2fs_summary *summary; struct curseg_info *seg_i; int written_size = 0; int i, j; page = grab_meta_page(sbi, blkaddr++); kaddr = (unsigned char *)page_address(page); /* Step 1: write nat cache */ seg_i = CURSEG_I(sbi, CURSEG_HOT_DATA); memcpy(kaddr, &seg_i->sum_blk->n_nats, SUM_JOURNAL_SIZE); written_size += SUM_JOURNAL_SIZE; /* Step 2: write sit cache */ seg_i = CURSEG_I(sbi, CURSEG_COLD_DATA); memcpy(kaddr + written_size, &seg_i->sum_blk->n_sits, SUM_JOURNAL_SIZE); written_size += SUM_JOURNAL_SIZE; /* Step 3: write summary entries */ for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { unsigned short blkoff; seg_i = CURSEG_I(sbi, i); if (sbi->ckpt->alloc_type[i] == SSR) blkoff = sbi->blocks_per_seg; else blkoff = curseg_blkoff(sbi, i); for (j = 0; j < blkoff; j++) { if (!page) { page = grab_meta_page(sbi, blkaddr++); kaddr = (unsigned char *)page_address(page); written_size = 0; } summary = (struct f2fs_summary *)(kaddr + written_size); *summary = seg_i->sum_blk->entries[j]; written_size += SUMMARY_SIZE; if (written_size + SUMMARY_SIZE <= PAGE_CACHE_SIZE - SUM_FOOTER_SIZE) continue; set_page_dirty(page); f2fs_put_page(page, 1); page = NULL; } } if (page) { set_page_dirty(page); f2fs_put_page(page, 1); } } static void write_normal_summaries(struct f2fs_sb_info *sbi, block_t blkaddr, int type) { int i, end; if (IS_DATASEG(type)) end = type + NR_CURSEG_DATA_TYPE; else end = type + NR_CURSEG_NODE_TYPE; for (i = type; i < end; i++) { struct curseg_info *sum = CURSEG_I(sbi, i); mutex_lock(&sum->curseg_mutex); write_sum_page(sbi, sum->sum_blk, blkaddr + (i - type)); mutex_unlock(&sum->curseg_mutex); } } void write_data_summaries(struct f2fs_sb_info *sbi, block_t start_blk) { if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_COMPACT_SUM_FLAG)) write_compacted_summaries(sbi, start_blk); else write_normal_summaries(sbi, start_blk, CURSEG_HOT_DATA); } void write_node_summaries(struct f2fs_sb_info *sbi, block_t start_blk) { if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_UMOUNT_FLAG)) write_normal_summaries(sbi, start_blk, CURSEG_HOT_NODE); } int lookup_journal_in_cursum(struct f2fs_summary_block *sum, int type, unsigned int val, int alloc) { int i; if (type == NAT_JOURNAL) { for (i = 0; i < nats_in_cursum(sum); i++) { if (le32_to_cpu(nid_in_journal(sum, i)) == val) return i; } if (alloc && nats_in_cursum(sum) < NAT_JOURNAL_ENTRIES) return update_nats_in_cursum(sum, 1); } else if (type == SIT_JOURNAL) { for (i = 0; i < sits_in_cursum(sum); i++) if (le32_to_cpu(segno_in_journal(sum, i)) == val) return i; if (alloc && sits_in_cursum(sum) < SIT_JOURNAL_ENTRIES) return update_sits_in_cursum(sum, 1); } return -1; } static struct page *get_current_sit_page(struct f2fs_sb_info *sbi, unsigned int segno) { return get_meta_page(sbi, current_sit_addr(sbi, segno)); } static struct page *get_next_sit_page(struct f2fs_sb_info *sbi, unsigned int start) { struct sit_info *sit_i = SIT_I(sbi); struct page *src_page, *dst_page; pgoff_t src_off, dst_off; void *src_addr, *dst_addr; src_off = current_sit_addr(sbi, start); dst_off = next_sit_addr(sbi, src_off); /* get current sit block page without lock */ src_page = get_meta_page(sbi, src_off); dst_page = grab_meta_page(sbi, dst_off); f2fs_bug_on(sbi, PageDirty(src_page)); src_addr = page_address(src_page); dst_addr = page_address(dst_page); memcpy(dst_addr, src_addr, PAGE_CACHE_SIZE); set_page_dirty(dst_page); f2fs_put_page(src_page, 1); set_to_next_sit(sit_i, start); return dst_page; } static struct sit_entry_set *grab_sit_entry_set(void) { struct sit_entry_set *ses = f2fs_kmem_cache_alloc(sit_entry_set_slab, GFP_ATOMIC); ses->entry_cnt = 0; INIT_LIST_HEAD(&ses->set_list); return ses; } static void release_sit_entry_set(struct sit_entry_set *ses) { list_del(&ses->set_list); kmem_cache_free(sit_entry_set_slab, ses); } static void adjust_sit_entry_set(struct sit_entry_set *ses, struct list_head *head) { struct sit_entry_set *next = ses; if (list_is_last(&ses->set_list, head)) return; list_for_each_entry_continue(next, head, set_list) if (ses->entry_cnt <= next->entry_cnt) break; list_move_tail(&ses->set_list, &next->set_list); } static void add_sit_entry(unsigned int segno, struct list_head *head) { struct sit_entry_set *ses; unsigned int start_segno = START_SEGNO(segno); list_for_each_entry(ses, head, set_list) { if (ses->start_segno == start_segno) { ses->entry_cnt++; adjust_sit_entry_set(ses, head); return; } } ses = grab_sit_entry_set(); ses->start_segno = start_segno; ses->entry_cnt++; list_add(&ses->set_list, head); } static void add_sits_in_set(struct f2fs_sb_info *sbi) { struct f2fs_sm_info *sm_info = SM_I(sbi); struct list_head *set_list = &sm_info->sit_entry_set; unsigned long *bitmap = SIT_I(sbi)->dirty_sentries_bitmap; unsigned int segno; for_each_set_bit(segno, bitmap, MAIN_SEGS(sbi)) add_sit_entry(segno, set_list); } static void remove_sits_in_journal(struct f2fs_sb_info *sbi) { struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); struct f2fs_summary_block *sum = curseg->sum_blk; int i; for (i = sits_in_cursum(sum) - 1; i >= 0; i--) { unsigned int segno; bool dirtied; segno = le32_to_cpu(segno_in_journal(sum, i)); dirtied = __mark_sit_entry_dirty(sbi, segno); if (!dirtied) add_sit_entry(segno, &SM_I(sbi)->sit_entry_set); } update_sits_in_cursum(sum, -sits_in_cursum(sum)); } /* * CP calls this function, which flushes SIT entries including sit_journal, * and moves prefree segs to free segs. */ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) { struct sit_info *sit_i = SIT_I(sbi); unsigned long *bitmap = sit_i->dirty_sentries_bitmap; struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); struct f2fs_summary_block *sum = curseg->sum_blk; struct sit_entry_set *ses, *tmp; struct list_head *head = &SM_I(sbi)->sit_entry_set; bool to_journal = true; struct seg_entry *se; mutex_lock(&curseg->curseg_mutex); mutex_lock(&sit_i->sentry_lock); /* * add and account sit entries of dirty bitmap in sit entry * set temporarily */ add_sits_in_set(sbi); /* * if there are no enough space in journal to store dirty sit * entries, remove all entries from journal and add and account * them in sit entry set. */ if (!__has_cursum_space(sum, sit_i->dirty_sentries, SIT_JOURNAL)) remove_sits_in_journal(sbi); if (!sit_i->dirty_sentries) goto out; /* * there are two steps to flush sit entries: * #1, flush sit entries to journal in current cold data summary block. * #2, flush sit entries to sit page. */ list_for_each_entry_safe(ses, tmp, head, set_list) { struct page *page = NULL; struct f2fs_sit_block *raw_sit = NULL; unsigned int start_segno = ses->start_segno; unsigned int end = min(start_segno + SIT_ENTRY_PER_BLOCK, (unsigned long)MAIN_SEGS(sbi)); unsigned int segno = start_segno; if (to_journal && !__has_cursum_space(sum, ses->entry_cnt, SIT_JOURNAL)) to_journal = false; if (!to_journal) { page = get_next_sit_page(sbi, start_segno); raw_sit = page_address(page); } /* flush dirty sit entries in region of current sit set */ for_each_set_bit_from(segno, bitmap, end) { int offset, sit_offset; se = get_seg_entry(sbi, segno); /* add discard candidates */ if (SM_I(sbi)->nr_discards < SM_I(sbi)->max_discards) { cpc->trim_start = segno; add_discard_addrs(sbi, cpc); } if (to_journal) { offset = lookup_journal_in_cursum(sum, SIT_JOURNAL, segno, 1); f2fs_bug_on(sbi, offset < 0); segno_in_journal(sum, offset) = cpu_to_le32(segno); seg_info_to_raw_sit(se, &sit_in_journal(sum, offset)); } else { sit_offset = SIT_ENTRY_OFFSET(sit_i, segno); seg_info_to_raw_sit(se, &raw_sit->entries[sit_offset]); } __clear_bit(segno, bitmap); sit_i->dirty_sentries--; ses->entry_cnt--; } if (!to_journal) f2fs_put_page(page, 1); f2fs_bug_on(sbi, ses->entry_cnt); release_sit_entry_set(ses); } f2fs_bug_on(sbi, !list_empty(head)); f2fs_bug_on(sbi, sit_i->dirty_sentries); out: if (cpc->reason == CP_DISCARD) { for (; cpc->trim_start <= cpc->trim_end; cpc->trim_start++) add_discard_addrs(sbi, cpc); } mutex_unlock(&sit_i->sentry_lock); mutex_unlock(&curseg->curseg_mutex); set_prefree_as_free_segments(sbi); } static int build_sit_info(struct f2fs_sb_info *sbi) { struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); struct sit_info *sit_i; unsigned int sit_segs, start; char *src_bitmap, *dst_bitmap; unsigned int bitmap_size; /* allocate memory for SIT information */ sit_i = kzalloc(sizeof(struct sit_info), GFP_KERNEL); if (!sit_i) return -ENOMEM; SM_I(sbi)->sit_info = sit_i; sit_i->sentries = vzalloc(MAIN_SEGS(sbi) * sizeof(struct seg_entry)); if (!sit_i->sentries) return -ENOMEM; bitmap_size = f2fs_bitmap_size(MAIN_SEGS(sbi)); sit_i->dirty_sentries_bitmap = kzalloc(bitmap_size, GFP_KERNEL); if (!sit_i->dirty_sentries_bitmap) return -ENOMEM; for (start = 0; start < MAIN_SEGS(sbi); start++) { sit_i->sentries[start].cur_valid_map = kzalloc(SIT_VBLOCK_MAP_SIZE, GFP_KERNEL); sit_i->sentries[start].ckpt_valid_map = kzalloc(SIT_VBLOCK_MAP_SIZE, GFP_KERNEL); if (!sit_i->sentries[start].cur_valid_map || !sit_i->sentries[start].ckpt_valid_map) return -ENOMEM; } if (sbi->segs_per_sec > 1) { sit_i->sec_entries = vzalloc(MAIN_SECS(sbi) * sizeof(struct sec_entry)); if (!sit_i->sec_entries) return -ENOMEM; } /* get information related with SIT */ sit_segs = le32_to_cpu(raw_super->segment_count_sit) >> 1; /* setup SIT bitmap from ckeckpoint pack */ bitmap_size = __bitmap_size(sbi, SIT_BITMAP); src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP); dst_bitmap = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL); if (!dst_bitmap) return -ENOMEM; /* init SIT information */ sit_i->s_ops = &default_salloc_ops; sit_i->sit_base_addr = le32_to_cpu(raw_super->sit_blkaddr); sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg; sit_i->written_valid_blocks = le64_to_cpu(ckpt->valid_block_count); sit_i->sit_bitmap = dst_bitmap; sit_i->bitmap_size = bitmap_size; sit_i->dirty_sentries = 0; sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK; sit_i->elapsed_time = le64_to_cpu(sbi->ckpt->elapsed_time); sit_i->mounted_time = CURRENT_TIME_SEC.tv_sec; mutex_init(&sit_i->sentry_lock); return 0; } static int build_free_segmap(struct f2fs_sb_info *sbi) { struct free_segmap_info *free_i; unsigned int bitmap_size, sec_bitmap_size; /* allocate memory for free segmap information */ free_i = kzalloc(sizeof(struct free_segmap_info), GFP_KERNEL); if (!free_i) return -ENOMEM; SM_I(sbi)->free_info = free_i; bitmap_size = f2fs_bitmap_size(MAIN_SEGS(sbi)); free_i->free_segmap = kmalloc(bitmap_size, GFP_KERNEL); if (!free_i->free_segmap) return -ENOMEM; sec_bitmap_size = f2fs_bitmap_size(MAIN_SECS(sbi)); free_i->free_secmap = kmalloc(sec_bitmap_size, GFP_KERNEL); if (!free_i->free_secmap) return -ENOMEM; /* set all segments as dirty temporarily */ memset(free_i->free_segmap, 0xff, bitmap_size); memset(free_i->free_secmap, 0xff, sec_bitmap_size); /* init free segmap information */ free_i->start_segno = GET_SEGNO_FROM_SEG0(sbi, MAIN_BLKADDR(sbi)); free_i->free_segments = 0; free_i->free_sections = 0; rwlock_init(&free_i->segmap_lock); return 0; } static int build_curseg(struct f2fs_sb_info *sbi) { struct curseg_info *array; int i; array = kcalloc(NR_CURSEG_TYPE, sizeof(*array), GFP_KERNEL); if (!array) return -ENOMEM; SM_I(sbi)->curseg_array = array; for (i = 0; i < NR_CURSEG_TYPE; i++) { mutex_init(&array[i].curseg_mutex); array[i].sum_blk = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL); if (!array[i].sum_blk) return -ENOMEM; array[i].segno = NULL_SEGNO; array[i].next_blkoff = 0; } return restore_curseg_summaries(sbi); } static void build_sit_entries(struct f2fs_sb_info *sbi) { struct sit_info *sit_i = SIT_I(sbi); struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); struct f2fs_summary_block *sum = curseg->sum_blk; int sit_blk_cnt = SIT_BLK_CNT(sbi); unsigned int i, start, end; unsigned int readed, start_blk = 0; int nrpages = MAX_BIO_BLOCKS(sbi); do { readed = ra_meta_pages(sbi, start_blk, nrpages, META_SIT); start = start_blk * sit_i->sents_per_block; end = (start_blk + readed) * sit_i->sents_per_block; for (; start < end && start < MAIN_SEGS(sbi); start++) { struct seg_entry *se = &sit_i->sentries[start]; struct f2fs_sit_block *sit_blk; struct f2fs_sit_entry sit; struct page *page; mutex_lock(&curseg->curseg_mutex); for (i = 0; i < sits_in_cursum(sum); i++) { if (le32_to_cpu(segno_in_journal(sum, i)) == start) { sit = sit_in_journal(sum, i); mutex_unlock(&curseg->curseg_mutex); goto got_it; } } mutex_unlock(&curseg->curseg_mutex); page = get_current_sit_page(sbi, start); sit_blk = (struct f2fs_sit_block *)page_address(page); sit = sit_blk->entries[SIT_ENTRY_OFFSET(sit_i, start)]; f2fs_put_page(page, 1); got_it: check_block_count(sbi, start, &sit); seg_info_from_raw_sit(se, &sit); if (sbi->segs_per_sec > 1) { struct sec_entry *e = get_sec_entry(sbi, start); e->valid_blocks += se->valid_blocks; } } start_blk += readed; } while (start_blk < sit_blk_cnt); } static void init_free_segmap(struct f2fs_sb_info *sbi) { unsigned int start; int type; for (start = 0; start < MAIN_SEGS(sbi); start++) { struct seg_entry *sentry = get_seg_entry(sbi, start); if (!sentry->valid_blocks) __set_free(sbi, start); } /* set use the current segments */ for (type = CURSEG_HOT_DATA; type <= CURSEG_COLD_NODE; type++) { struct curseg_info *curseg_t = CURSEG_I(sbi, type); __set_test_and_inuse(sbi, curseg_t->segno); } } static void init_dirty_segmap(struct f2fs_sb_info *sbi) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); struct free_segmap_info *free_i = FREE_I(sbi); unsigned int segno = 0, offset = 0; unsigned short valid_blocks; while (1) { /* find dirty segment based on free segmap */ segno = find_next_inuse(free_i, MAIN_SEGS(sbi), offset); if (segno >= MAIN_SEGS(sbi)) break; offset = segno + 1; valid_blocks = get_valid_blocks(sbi, segno, 0); if (valid_blocks == sbi->blocks_per_seg || !valid_blocks) continue; if (valid_blocks > sbi->blocks_per_seg) { f2fs_bug_on(sbi, 1); continue; } mutex_lock(&dirty_i->seglist_lock); __locate_dirty_segment(sbi, segno, DIRTY); mutex_unlock(&dirty_i->seglist_lock); } } static int init_victim_secmap(struct f2fs_sb_info *sbi) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); unsigned int bitmap_size = f2fs_bitmap_size(MAIN_SECS(sbi)); dirty_i->victim_secmap = kzalloc(bitmap_size, GFP_KERNEL); if (!dirty_i->victim_secmap) return -ENOMEM; return 0; } static int build_dirty_segmap(struct f2fs_sb_info *sbi) { struct dirty_seglist_info *dirty_i; unsigned int bitmap_size, i; /* allocate memory for dirty segments list information */ dirty_i = kzalloc(sizeof(struct dirty_seglist_info), GFP_KERNEL); if (!dirty_i) return -ENOMEM; SM_I(sbi)->dirty_info = dirty_i; mutex_init(&dirty_i->seglist_lock); bitmap_size = f2fs_bitmap_size(MAIN_SEGS(sbi)); for (i = 0; i < NR_DIRTY_TYPE; i++) { dirty_i->dirty_segmap[i] = kzalloc(bitmap_size, GFP_KERNEL); if (!dirty_i->dirty_segmap[i]) return -ENOMEM; } init_dirty_segmap(sbi); return init_victim_secmap(sbi); } /* * Update min, max modified time for cost-benefit GC algorithm */ static void init_min_max_mtime(struct f2fs_sb_info *sbi) { struct sit_info *sit_i = SIT_I(sbi); unsigned int segno; mutex_lock(&sit_i->sentry_lock); sit_i->min_mtime = LLONG_MAX; for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) { unsigned int i; unsigned long long mtime = 0; for (i = 0; i < sbi->segs_per_sec; i++) mtime += get_seg_entry(sbi, segno + i)->mtime; mtime = div_u64(mtime, sbi->segs_per_sec); if (sit_i->min_mtime > mtime) sit_i->min_mtime = mtime; } sit_i->max_mtime = get_mtime(sbi); mutex_unlock(&sit_i->sentry_lock); } int build_segment_manager(struct f2fs_sb_info *sbi) { struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); struct f2fs_sm_info *sm_info; int err; sm_info = kzalloc(sizeof(struct f2fs_sm_info), GFP_KERNEL); if (!sm_info) return -ENOMEM; /* init sm info */ sbi->sm_info = sm_info; sm_info->seg0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr); sm_info->main_blkaddr = le32_to_cpu(raw_super->main_blkaddr); sm_info->segment_count = le32_to_cpu(raw_super->segment_count); sm_info->reserved_segments = le32_to_cpu(ckpt->rsvd_segment_count); sm_info->ovp_segments = le32_to_cpu(ckpt->overprov_segment_count); sm_info->main_segments = le32_to_cpu(raw_super->segment_count_main); sm_info->ssa_blkaddr = le32_to_cpu(raw_super->ssa_blkaddr); sm_info->rec_prefree_segments = sm_info->main_segments * DEF_RECLAIM_PREFREE_SEGMENTS / 100; sm_info->ipu_policy = 1 << F2FS_IPU_FSYNC; sm_info->min_ipu_util = DEF_MIN_IPU_UTIL; sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS; INIT_LIST_HEAD(&sm_info->discard_list); sm_info->nr_discards = 0; sm_info->max_discards = 0; INIT_LIST_HEAD(&sm_info->sit_entry_set); if (test_opt(sbi, FLUSH_MERGE) && !f2fs_readonly(sbi->sb)) { err = create_flush_cmd_control(sbi); if (err) return err; } err = build_sit_info(sbi); if (err) return err; err = build_free_segmap(sbi); if (err) return err; err = build_curseg(sbi); if (err) return err; /* reinit free segmap based on SIT */ build_sit_entries(sbi); init_free_segmap(sbi); err = build_dirty_segmap(sbi); if (err) return err; init_min_max_mtime(sbi); return 0; } static void discard_dirty_segmap(struct f2fs_sb_info *sbi, enum dirty_type dirty_type) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); mutex_lock(&dirty_i->seglist_lock); kfree(dirty_i->dirty_segmap[dirty_type]); dirty_i->nr_dirty[dirty_type] = 0; mutex_unlock(&dirty_i->seglist_lock); } static void destroy_victim_secmap(struct f2fs_sb_info *sbi) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); kfree(dirty_i->victim_secmap); } static void destroy_dirty_segmap(struct f2fs_sb_info *sbi) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); int i; if (!dirty_i) return; /* discard pre-free/dirty segments list */ for (i = 0; i < NR_DIRTY_TYPE; i++) discard_dirty_segmap(sbi, i); destroy_victim_secmap(sbi); SM_I(sbi)->dirty_info = NULL; kfree(dirty_i); } static void destroy_curseg(struct f2fs_sb_info *sbi) { struct curseg_info *array = SM_I(sbi)->curseg_array; int i; if (!array) return; SM_I(sbi)->curseg_array = NULL; for (i = 0; i < NR_CURSEG_TYPE; i++) kfree(array[i].sum_blk); kfree(array); } static void destroy_free_segmap(struct f2fs_sb_info *sbi) { struct free_segmap_info *free_i = SM_I(sbi)->free_info; if (!free_i) return; SM_I(sbi)->free_info = NULL; kfree(free_i->free_segmap); kfree(free_i->free_secmap); kfree(free_i); } static void destroy_sit_info(struct f2fs_sb_info *sbi) { struct sit_info *sit_i = SIT_I(sbi); unsigned int start; if (!sit_i) return; if (sit_i->sentries) { for (start = 0; start < MAIN_SEGS(sbi); start++) { kfree(sit_i->sentries[start].cur_valid_map); kfree(sit_i->sentries[start].ckpt_valid_map); } } vfree(sit_i->sentries); vfree(sit_i->sec_entries); kfree(sit_i->dirty_sentries_bitmap); SM_I(sbi)->sit_info = NULL; kfree(sit_i->sit_bitmap); kfree(sit_i); } void destroy_segment_manager(struct f2fs_sb_info *sbi) { struct f2fs_sm_info *sm_info = SM_I(sbi); if (!sm_info) return; destroy_flush_cmd_control(sbi); destroy_dirty_segmap(sbi); destroy_curseg(sbi); destroy_free_segmap(sbi); destroy_sit_info(sbi); sbi->sm_info = NULL; kfree(sm_info); } int __init create_segment_manager_caches(void) { discard_entry_slab = f2fs_kmem_cache_create("discard_entry", sizeof(struct discard_entry)); if (!discard_entry_slab) goto fail; sit_entry_set_slab = f2fs_kmem_cache_create("sit_entry_set", sizeof(struct sit_entry_set)); if (!sit_entry_set_slab) goto destory_discard_entry; inmem_entry_slab = f2fs_kmem_cache_create("inmem_page_entry", sizeof(struct inmem_pages)); if (!inmem_entry_slab) goto destroy_sit_entry_set; return 0; destroy_sit_entry_set: kmem_cache_destroy(sit_entry_set_slab); destory_discard_entry: kmem_cache_destroy(discard_entry_slab); fail: return -ENOMEM; } void destroy_segment_manager_caches(void) { kmem_cache_destroy(sit_entry_set_slab); kmem_cache_destroy(discard_entry_slab); kmem_cache_destroy(inmem_entry_slab); }
forumi0721/bananapi_linux-sunxi
fs/f2fs/segment.c
C
gpl-2.0
62,223
[ 30522, 1013, 1008, 1008, 1042, 2015, 1013, 1042, 2475, 10343, 1013, 6903, 1012, 1039, 1008, 1008, 9385, 1006, 1039, 1007, 2262, 19102, 8139, 2522, 1012, 1010, 5183, 1012, 1008, 8299, 1024, 1013, 1013, 7479, 1012, 19102, 1012, 4012, 1013, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
module Cryptoexchange::Exchanges module Unnamed class Market < Cryptoexchange::Models::Market NAME = 'unnamed' API_URL = 'https://api.unnamed.exchange/v1/Public' def self.trade_page_url(args={}) "https://www.unnamed.exchange/Exchange/Basic?market=#{args[:base]}_#{args[:target]}" end end end end
coingecko/cryptoexchange
lib/cryptoexchange/exchanges/unnamed/market.rb
Ruby
mit
341
[ 30522, 11336, 19888, 8913, 2595, 22305, 2063, 1024, 1024, 15800, 11336, 13294, 2465, 3006, 1026, 19888, 8913, 2595, 22305, 2063, 1024, 1024, 4275, 1024, 1024, 3006, 2171, 1027, 1005, 13294, 1005, 17928, 1035, 24471, 2140, 1027, 1005, 16770, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Dns-Monitoring-Scripts A collection of Simple shell scripts for DNS and DNSSEC monitoring. The script have been explained in the November 3rd Webinar 'DNS and DNSSEC Monitoring – Strategy and Tools' from Men & Mice. You can still watch the recording at https://www.menandmice.com/resources/educational-resources/webinars/dns-and-dnssec-monitoring-strategy-and-tools/ and on YouTube. These tests can be build upon, please send a pull request if you have additions/fixes. These scripts are simple for a reason, please keep them simple.
cstrotm/dns-monitoring-scripts
README.md
Markdown
bsd-2-clause
543
[ 30522, 1001, 1040, 3619, 1011, 8822, 1011, 14546, 1037, 3074, 1997, 3722, 5806, 14546, 2005, 1040, 3619, 1998, 1040, 3619, 3366, 2278, 8822, 1012, 1996, 5896, 2031, 2042, 4541, 1999, 1996, 2281, 3822, 4773, 3981, 2099, 1005, 1040, 3619, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> {% load staticfiles %} <link rel="stylesheet" href="{% static 'css/foundation.css' %}" /> </head> <body> <div class="row"> <div class="panel"> <h2> You have successfully logged out </h2> <p> You can <a href="/pta/">login</a> again and access the PTA application</p> </div> </div> </body> </html>
cptdanko/ptaApp
pta/templates/pta/logout.html
HTML
bsd-3-clause
420
[ 30522, 1026, 30524, 1014, 1000, 1028, 1063, 1003, 7170, 10763, 8873, 4244, 1003, 1065, 1026, 4957, 2128, 2140, 1027, 1000, 6782, 21030, 2102, 1000, 17850, 12879, 1027, 1000, 1063, 1003, 10763, 1005, 20116, 2015, 1013, 3192, 1012, 20116, 201...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: "使用Java结合PhantomJS去加载需要滑动到底部的网站" date: 2017-07-20 category: Java tag: PhantomJS --- ## 背景 有一些网站,滑动条往下滑动的时候页面才加载或者再次获取数据 ## 使用PhantomJS来实现自动加载,以www.toutiao.com为例 ### 安装phantomjs 把phantomjs放在工程phantomjs文件夹下 ### maven需要依赖的包 ```xml <dependency> <groupId>com.github.detro</groupId> <artifactId>phantomjsdriver</artifactId> <version>1.2.0</version> </dependency> ``` ### Java代码 ```java import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.phantomjs.PhantomJSDriver; import org.openqa.selenium.phantomjs.PhantomJSDriverService; import org.openqa.selenium.remote.DesiredCapabilities; import java.io.File; import java.util.concurrent.TimeUnit; /** * 测试PhantomJS框架函数 */ public class PhantomJST { public static void main(String[] args) throws Exception{ String currDir = System.getProperty("user.dir"); String driverPath = currDir + File.separator + "phantomjs/phantomjs"; DesiredCapabilities capabilities = DesiredCapabilities.phantomjs(); capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, driverPath); PhantomJSDriverService service = PhantomJSDriverService.createDefaultService(capabilities); WebDriver webDriver = new PhantomJSDriver(service, capabilities); webDriver.manage().deleteAllCookies(); webDriver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS); webDriver.manage().timeouts().setScriptTimeout(5, TimeUnit.SECONDS); webDriver.get("http://www.toutiao.com"); JavascriptExecutor jse = (JavascriptExecutor) webDriver; Long position = (Long)jse.executeScript("return window.scrollY;"); System.out.println(webDriver.getPageSource()); System.out.println("***" + position + "***"); System.out.println("------------------------------------------"); jse.executeScript("window.scrollTo(0, document.body.scrollHeight);"); position = (Long)jse.executeScript("return window.scrollY;"); Thread.sleep(3000); System.out.println(webDriver.getPageSource()); System.out.println("***" + position + "***"); System.out.println("------------------------------------------"); jse.executeScript("window.scrollTo(0, document.body.scrollHeight);"); position = (Long)jse.executeScript("return window.scrollY;"); Thread.sleep(3000); System.out.println(webDriver.getPageSource()); System.out.println("***" + position + "***"); System.out.println("------------------------------------------"); webDriver.quit(); } } ```
zhaomengit/zhaomengit.github.io
_posts/2017-07-20-使用Java结合PhantomJS去加载需要滑动到底部的网站.md
Markdown
mit
2,895
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1000, 100, 100, 9262, 100, 1792, 11588, 22578, 100, 1779, 100, 100, 100, 100, 100, 100, 100, 1960, 1916, 100, 100, 1000, 3058, 1024, 2418, 1011, 5718, 1011, 2322, 4696, 1024, 9262, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#################################################################################### #.Synopsis # Creates and deletes sinkhole domains in Windows DNS servers. # #.Description # Script takes fully-qualified domain names (FQDNs) and/or simple domain # names, then uses them to create primary zones (not Active Directory # integrated) in a Windows DNS server, setting all zones to resolve to a # single chosen IP address. The IP address might be "0.0.0.0" or the IP # of an internal server configured for logging. The intention is to # prevent clients from resolving the correct IP address of unwanted FQDNs # and domain names, such as for malware and phishing sites. Such names # are said to be "sinkholed" or "blackholed" since they often resolve # to 0.0.0.0, which is an inaccessible IP address. # #.Parameter InputFile # Path to a file which contains the FQDNs and domain names to sinkhole. # File can have blank lines, comment lines (# or ;), multiple FQDNs or # domains per line (space- or comma-delimited), and can be a hosts file # with IP addresses too (addresses and localhost entires will be ignored). # You can also include wildcards to input multiple files, e.g., # "*bad*.txt", or pass in an array of file objects instead of a string. # #.Parameter Domain # One or more FQDNs or domains to sinkhole, separated by spaces or commas. # #.Parameter SinkHoleIP # The IP address to which all sinkholed names will resolve. The # default is "0.0.0.0", but perhaps is better set to an internal server. # Remember, there is only one IP for ALL the sinkholed domains. # #.Parameter DnsServerName # FQDN of the Windows DNS server. Defaults to localhost. If specified, # please always use a fully-qualified domain name (FQDN), especially if # the DNS server is a stand-alone or in a different domain. # #.Parameter IncludeWildCard # Will add a wildcard host record (*) to every sinkhole domain, which # will match all possible hostnames within that domain. Keep in mind # that sinkholing "www.sans.org" will treat the "www" as a domain # name, so a wildcard is not needed to match it; but sinkholing just # "sans.org" will not match "www.sans.org" or "ftp.sans.org" without # the wildcard. If you only want to sinkhole the exact FQDN or domain # name supplied to the script, then don't include a wildcard record. # If you are certain that you do not want to resolve anything whatsoever # under the sinkholed domains, then include the wildcard DNS record. # #.Parameter ReloadSinkHoleDomains # Will cause every sinkholed domain in your DNS server to re-read the # one shared zone file they all use. This is the zone file for the # 000-sinkholed-domain.local domain. Keep in mind that the DNS # graphical management tool shows you what is cached in memory, not # what is in the zone file. Reload the sinkhole domains if you, # for example, change the sinkhole IP address. Using this switch # causes any other parameters to be ignored. # #.Parameter DeleteSinkHoleDomains # Will delete all sinkhole domains, but will not delete any regular # non-sinkhole domains. Strictly speaking, this deletes any domain # which uses a zone file named "000-sinkholed-domain.local.dns". # The zone file itself is not deleted, but it only 1KB in size. # Using this switch causes any other parameters to be ignored. # #.Parameter RemoveLeadingWWW # Some lists of sinkhole names are simple domain names, while other # lists might prepend "www." to the beginning of many of the names. # Use this switch to remove the "www." from the beginning of any # name to be sinkholed, then consider using -IncludeWildCard too. # Note that "www.", "www1.", "www2." ... "www9." will be cut too, # but only for a single digit after the "www" part (1-9 only). # #.Parameter Credential # An "authority\username" string to explicitly authenticate to the # DNS server instead of using single sign-on with the current # identity. The authority is either a server name or a domain name. # You will be prompted for the passphrase. You can also pass in # a variable with a credential object from Get-Credential. # #.Example # .\Sinkhole-DNS.ps1 -Domain "www.sans.org" # # This will create a primary DNS domain named "www.sans.org" # which will resolve to "0.0.0.0". DNS server is local. # #.Example # .\Sinkhole-DNS.ps1 -Domain "www.sans.org" -SinkHoleIP "10.1.1.1" # # This will create a primary DNS domain named "www.sans.org" # which will resolve to "10.1.1.1". DNS server is local. # #.Example # .\Sinkhole-DNS.ps1 -InputFile file.txt -IncludeWildCard # # This will create DNS domains out of all the FQDNs and domain # names listed in file.txt, plus add a wildcard (*) record. # #.Example # .\Sinkhole-DNS.ps1 -ReloadSinkHoleDomains # # Perhaps after changing the sinkhole IP address, this will cause # all sinkholed domains to re-read their shared zone file. # #.Example # .\Sinkhole-DNS.ps1 -DeleteSinkHoleDomains # # This will delete all sinkholed domains, but will not delete # any other domains. This does not delete the sinkhole zone file. # #.Example # .\Sinkhole-DNS.ps1 -InputFile file.txt -DnsServerName ` # "server7.sans.org" -Credential "server7\administrator" # # This will create sinkholed domains from file.txt on a remote # DNS server named "server7.sans.org" with explicit credentials. # You will be prompted for the passphrase. # #.Example # $Cred = Get-Credential -Credential "server7\administrator" # # .\Sinkhole-DNS.ps1 -InputFile *evil*.txt ` # -DnsServerName "server7.sans.org" -Credential $Cred # # This will create sinkholed domains from *evil*.txt on a remote # DNS server named "server7.sans.org" with explicit credentials # supplied in a credential object ($Cred) which can be reused again. # Multiple input files may match "*evil*.txt". # # #################################################################################### Param ($InputFile, [String] $Domain, [String] $SinkHoleIP = "0.0.0.0", [String] $DnsServerName = ".", [Switch] $IncludeWildCard, [Switch] $ReloadSinkHoleDomains, [Switch] $DeleteSinkHoleDomains, [Switch] $RemoveLeadingWWW, $Credential) # Check for common help switches. if (($InputFile -ne $Null) -and ($InputFile.GetType().Name -eq "String") -and ($InputFile -match "/\?|-help|--h|--help")) { If ($Host.Version.Major -ge 2) { get-help -full .\sinkhole-dns.ps1 } Else {"`nPlease read this script's header in Notepad for the help information."} Exit } # Confirm PowerShell 2.0 or later. If ($Host.Version.Major -lt 2) { "This script requires PowerShell 2.0 or later.`nDownload the latest version from http://www.microsoft.com/powershell`n" ; Exit } # If necessary, prompt user for domain\username and a passphrase. If ($Credential) { $Cred = Get-Credential -Credential $Credential } Function Main { # Test access to WMI at target server ($ZoneClass is used later too). $ZoneClass = GetWMI -Query "SELECT * FROM META_CLASS WHERE __CLASS = 'MicrosoftDNS_Zone'" If (-not $? -or $ZoneClass.Name -ne "MicrosoftDNS_Zone") { Throw("Failed to connect to WMI service or the WMI DNS_Zone namespace!") ; Exit } ##### Parse input domains, but exclude the following: localhost, any IP addresses, blank lines. #Process any -Domain args. [Object[]] $Domains = @($Domain -Split "[\s\;\,]") #Process any -InputFile arguments and expand any wildcards. If (($InputFile -ne $Null) -and ($InputFile.GetType().Name -eq "String")) { $InputFile = dir $InputFile } If ($InputFile -ne $Null) { $InputFile | ForEach { $Domains += Get-Content $_ | Where { $_ -notmatch "^[\#\;\<]" } | ForEach { $_ -Split "[\s\;\,]" } } } #If -RemoveLeadingWWW was used, edit out those "www." strings. If ($RemoveLeadingWWW) { 0..$([Int] $Domains.Count - 1) | ForEach { $Domains[$_] = $Domains[$_] -Replace "^www[1-9]{0,1}\.","" } } #Convert to lowercase, remove redundants, exclude blank lines, exclude IPs, exclude anything with a colon in it, e.g., IPv6. $Domains = $Domains | ForEach { $_.Trim().ToLower() } | Sort -Unique | Where { $_.Length -ne 0 -and $_ -notmatch "^localhost$|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\:" } If ($Domains.Count -le 0) { "No domains specified!" ; exit } Else { "`n" + [String] $Domains.Count + " domain(s) to sinkhole to $SinkHoleIP." } ##### ##### Get or create the master sinkhole zone: 000-sinkholed-domain.local. $WmiPath = "Root\MicrosoftDNS:MicrosoftDNS_Zone.ContainerName='000-sinkholed-domain.local',DnsServerName='" + $DnsServerName + "',Name='000-sinkholed-domain.local'" If (InvokeWmiMethod -ObjectPath $WmiPath -MethodName GetDistinguishedName) #Zone exists. { "`nThe 000-sinkholed-domain.local zone already exists, deleting its existing DNS records." $ExistingRecords = @(GetWMI -Query "SELECT * FROM MicrosoftDNS_AType WHERE ContainerName = '000-sinkholed-domain.local'") If (-not $?) { Throw("Failed to query the A records of the 000-sinkholed-domain.local domain!") ; exit } If ($ExistingRecords.Count -gt 0) { $ExistingRecords | ForEach { $_.Delete() } } } Else #Zone does not exist. { "`nCreating the 000-sinkholed-domain.local zone and its zone file." $RR = $ZoneClass.CreateZone("000-sinkholed-domain.local",0,$false,$null,$null,"only-edit.000-sinkholed-domain.local.") If (-not $? -or $RR.__CLASS -ne "__PARAMETERS") { If ($Credential -And ($DnsServerName.Length -ne 0) -And ($DnsServerName -NotLike "*.*")) { "Did you forget to use a FQDN for the DNS server name?" } Throw("Failed to create the 000-sinkholed-domain.local domain!") Exit } } ##### ##### Create DNS records in master sinkhole zone. # Create the default A record with the sinkhole IP address. $RecordClass = $Null # Defaults to "IN" class of record. $TTL = 120 # Seconds. Defaults to zone default if you set this to $null. $ATypeRecords = GetWMI -Query "SELECT * FROM META_CLASS WHERE __CLASS = 'MicrosoftDNS_AType'" If (-not $? -or $ATypeRecords.Name -ne "MicrosoftDNS_AType") { "`nFailed to query A type records, but continuing..." } $ARecord = $ATypeRecords.CreateInstanceFromPropertyData($DnsServerName,"000-sinkholed-domain.local","000-sinkholed-domain.local",$RecordClass,$TTL,$SinkHoleIP) If ($?) { "Created default DNS record for the 000-sinkholed-domain.local zone ($SinkHoleIP)." } Else { "Failed to create default A record for the 000-sinkholed-domain.local zone, but continuing..." } # Create the wildcard A record if the -IncludeWildCard switch was used. If ($IncludeWildCard) { $ARecord = $ATypeRecords.CreateInstanceFromPropertyData($DnsServerName,"000-sinkholed-domain.local","*.000-sinkholed-domain.local",$RecordClass,$TTL,$SinkHoleIP) If ($?) { "Created the wildcard (*) record for the 000-sinkholed-domain.local zone ($SinkHoleIP)." } Else { "Failed to create the wildcard (*) record for the 000-sinkholed-domain.local zone, but continuing..." } } # Update zone data file on disk after adding the A record(s). If (InvokeWmiMethod -ObjectPath $WmiPath -MethodName WriteBackZone) { "Updated the zone file for 000-sinkholed-domain.local." } Else { Start-Sleep -Seconds 2 #Just seems to help... $ItWorked = InvokeWmiMethod -ObjectPath $WmiPath -MethodName WriteBackZone If ($ItWorked) { "Updated the zone file for 000-sinkholed-domain.local." } Else {"`nFailed to update the server data file for the 000-sinkholed-domain.local zone, but continuing..." } } ##### ##### Create the sinkholed domains using the 000-sinkholed-domain.local.dns zone file. $Created = $NotCreated = 0 $CurrentErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = "SilentlyContinue" $Domains | ForEach ` { $ZoneClass.CreateZone($_,0,$false,"000-sinkholed-domain.local.dns",$null,"only-edit.000-sinkholed-domain.local.") | Out-Null If ($?) { $Created++ } Else { $NotCreated++ } } $ErrorActionPreference = $CurrentErrorActionPreference "`nSinkhole domains created at the DNS server: $Created" "`nDomains NOT created (maybe already existed): $NotCreated`n" } #End of Main Function GetWMI ([String] $Query) { # This is a helper function for the sake of -Credential. If ($Credential) { Get-WmiObject -Query $Query -Namespace "Root/MicrosoftDNS" -ComputerName $DnsServerName -Credential $Cred } Else { Get-WmiObject -Query $Query -Namespace "Root/MicrosoftDNS" -ComputerName $DnsServerName } } Function InvokeWmiMethod ([String] $ObjectPath, [String] $MethodName) { # This is a helper function for the sake of -Credential. $ErrorActionPreference = "SilentlyContinue" If ($Credential) { Invoke-WmiMethod -Path $ObjectPath -Name $MethodName -ComputerName $DnsServerName -Credential $Cred } Else { Invoke-WmiMethod -Path $ObjectPath -Name $MethodName -ComputerName $DnsServerName } $? #Returns } Function Reload-SinkHoledDomains { # Function causes sinkholed domains to be reloaded from the shared master zone file, perhaps after a -SinkHoleIP change. # You may get errors if zone is temporarily locked for updates, but the DNS server's default lock is only two minutes. "`nReloading sinkholed domains from the 000-sinkholed-domain.local.dns zone file, `nwhich may take a few minutes if you have 10K+ domains..." $BHDomains = @(GetWMI -Query "SELECT * FROM MicrosoftDNS_Zone WHERE DataFile = '000-sinkholed-domain.local.dns'") If (-not $?) { Throw("Failed to connect to WMI service!") ; exit } "`nSinkholed domains to be reloaded from the zone file: " + [String] $BHDomains.Count $Locked = @() #Index numbers of zones which are temporarily locked and cannot be reloaded yet. $i = 0 $ErrorActionPreference = "SilentlyContinue" If ($BHDomains.Count -gt 0) { $BHDomains | ForEach { $_.ReloadZone() ; If (-not $?) { $Locked += $i } ; $i++ } } If ($Locked.Count -gt 0) { "`n" + [String] $Locked.Count + " zone(s) are still temporarily locked, will try those again in two minutes.`nPlease wait two minutes or hit Ctrl-C to cancel..." Start-Sleep -Seconds 60 "Just one more minute... Thank you for holding, your function call is appreciated." Start-Sleep -Seconds 30 "Just 30 more seconds... Your patience is admirable, and you're good looking too!" Start-Sleep -Seconds 35 $Locked | ForEach { $BHDomains[$_].ReloadZone() ; if (-not $?) { "`n" + [String] $BHDomains[$_].ContainerName + " is still locked and has not reloaded yet." } } } "`nThe other sinkholed domains were successfully reloaded.`n" } #End Function Delete-SinkHoledDomains { # Delete all sinkholed zones, including 000-sinkholed-domain.local, but # note that this does not delete the (tiny) zone file on the drive. "`nDeleting all sinkholed domains, which may take a few minutes if you have 10K+ domains..." $BHDomains = @(GetWMI -Query "SELECT * FROM MicrosoftDNS_Zone WHERE DataFile = '000-sinkholed-domain.local.dns'") If (-not $?) { Throw("Failed to connect to WMI service!") ; exit } "`nSinkhole domains to be deleted: " + [String] $BHDomains.Count $i = 0 If ($BHDomains.Count -gt 0) { $BHDomains | ForEach { $_.Delete() ; If ($?){$i++} } } "Sinkhole domains deleted count: $i`n" } #End ######################## # MAIN # ######################## If ($ReloadSinkHoleDomains) { Reload-SinkHoledDomains ; Exit } If ($DeleteSinkHoleDomains) { Delete-SinkHoledDomains ; Exit } Main
allenj0321/Powershell
Sinkhole-DNS.ps1
PowerShell
bsd-2-clause
15,857
[ 30522, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 100...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
datab = [{},{"Document Version":{"colspan":"1","rowspan":"1","text":"1.1"},"Date":{"colspan":"1","rowspan":"1","text":"October 30,2003"},"Author":{"colspan":"1","rowspan":"1","text":"WG 6"},"Description":{"colspan":"1","rowspan":"1","text":"For Final Text"}},{"Document Version":{"colspan":"1","rowspan":"1","text":"1.2"},"Date":{"colspan":"1","rowspan":"1","text":"August 30, 2007"},"Author":{"colspan":"1","rowspan":"1","text":"WG 6"},"Description":{"colspan":"1","rowspan":"1","text":"Revised Introduction"}}];
vupeter/posdaJS
lib/json/book/part02/table_E.3.1-1.js
JavaScript
mit
513
[ 30522, 2951, 2497, 1027, 1031, 1063, 1065, 1010, 1063, 1000, 6254, 2544, 1000, 1024, 1063, 1000, 8902, 13102, 2319, 1000, 1024, 1000, 1015, 1000, 1010, 1000, 10281, 9739, 1000, 1024, 1000, 1015, 1000, 1010, 1000, 3793, 1000, 1024, 1000, 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.cqs.socket.example; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLServerSocketFactory; import java.io.BufferedInputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.ServerSocket; import java.net.Socket; import java.util.logging.Level; import java.util.logging.Logger; /** * Created by cqs on 10/29/16. */ public class SocketServerEncrypt { private final static Logger logger = Logger.getLogger(SocketServerEncrypt.class.getName()); public static void main(String[] args) { try { ServerSocketFactory factory = SSLServerSocketFactory.getDefault(); ServerSocket server = factory.createServerSocket(10000); while (true) { Socket socket = server.accept(); invoke(socket); } } catch (Exception ex) { ex.printStackTrace(); } } private static void invoke(final Socket socket) throws IOException { new Thread(new Runnable() { public void run() { ObjectInputStream is = null; ObjectOutputStream os = null; try { is = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); os = new ObjectOutputStream(socket.getOutputStream()); Object obj = is.readObject(); User user = (User) obj; System.out.println("user: " + user.getName() + "/" + user.getPassword()); user.setName(user.getName() + "_new"); user.setPassword(user.getPassword() + "_new"); os.writeObject(user); os.flush(); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { logger.log(Level.SEVERE, null, ex); } finally { try { is.close(); } catch (Exception ex) { } try { os.close(); } catch (Exception ex) { } try { socket.close(); } catch (Exception ex) { } } } }).start(); } }
lixwcqs/funny
src/main/java/com.cqs/socket/example/SocketServerEncrypt.java
Java
apache-2.0
2,461
[ 30522, 7427, 4012, 1012, 1039, 4160, 2015, 1012, 22278, 1012, 2742, 1025, 12324, 9262, 2595, 1012, 5658, 1012, 14903, 7432, 3388, 21450, 1025, 12324, 9262, 2595, 1012, 5658, 1012, 7020, 2140, 1012, 7020, 4877, 2121, 14028, 7432, 3388, 21450...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
+++ date = "2015-08-22" title = "Teaching" menu = "main" url = "teaching/" hide = "true" +++ Links to teaching materials: ## - [BBSRC](http://www.bbsrc.ac.uk/) **/** [**Natural History Museum**](http://www.nhm.ac.uk/our-science/courses-and-students.html) [**Training in computational and data literacy skills for research course**](http://www.nhm.ac.uk/our-science/courses-and-students/advancing-computational-and-data-literacy-for-life-scientists.html) Advancing computational and data literacy skills schools for life scientists. - github [repo](https://github.com/NHM-STARS/materials) ## - [**ACCE DTP Research Data Management workshop Feb 17th 2017**](https://annakrystalli.github.io/ACCE_RDM/Rmd/index.html) ## - [**Mozfest Rstudio ♥ GitHub**](https://github.com/annakrystalli/Mozfest_github-rstudio) ## - [**UNAM, #rstats & #openscience workshop**](https://annakrystalli.github.io/UNAM-site/) ## - [**ISBE 2016 Reproducible Science Workshop Materials**](http://annakrystalli.github.io/ISBE2016/index.html)
annakrystalli/annakrystalli.github.io
content/teaching.md
Markdown
mit
1,037
[ 30522, 1009, 1009, 1009, 3058, 1027, 1000, 2325, 1011, 5511, 1011, 2570, 1000, 2516, 1027, 1000, 4252, 1000, 12183, 1027, 1000, 2364, 1000, 24471, 2140, 1027, 1000, 4252, 1013, 1000, 5342, 1027, 1000, 2995, 1000, 1009, 1009, 1009, 6971, 2...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
Bitcoin version 0.6.0 is now available for download at: http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.6.0/test/ This release includes more than 20 language localizations. More translations are welcome; join the project at Transifex to help: https://www.transifex.net/projects/p/bitcoin/ Please report bugs using the issue tracker at github: https://github.com/bitcoin/bitcoin/issues Project source code is hosted at github; we are no longer distributing .tar.gz files here, you can get them directly from github: https://github.com/bitcoin/bitcoin/tarball/v0.6.0 # .tar.gz https://github.com/bitcoin/bitcoin/zipball/v0.6.0 # .zip For Ubuntu users, there is a ppa maintained by Matt Corallo which you can add to your system so that it will automatically keep bitcoin up-to-date. Just type sudo apt-add-repository ppa:bitcoin/bitcoin in your terminal, then install the bitcoin-qt package. KNOWN ISSUES Shutting down while synchronizing with the network (downloading the blockchain) can take more than a minute, because database writes are queued to speed up download time. NEW FEATURES SINCE BITCOIN VERSION 0.5 Initial network synchronization should be much faster (one or two hours on a typical machine instead of ten or more hours). Backup Wallet menu option. Bitcoin-Qt can display and save QR codes for sending and receiving addresses. New context menu on addresses to copy/edit/delete them. New Sign Message dialog that allows you to prove that you own a bitcoin address by creating a digital signature. New wallets created with this version will use 33-byte 'compressed' public keys instead of 65-byte public keys, resulting in smaller transactions and less traffic on the bitcoin network. The shorter keys are already supported by the network but wallet.dat files containing short keys are not compatible with earlier versions of Bitcoin-Qt/krugercoind. New command-line argument -blocknotify=<command> that will spawn a shell process to run <command> when a new block is accepted. New command-line argument -splash=0 to disable Bitcoin-Qt's initial splash screen validateaddress JSON-RPC api command output includes two new fields for addresses in the wallet: pubkey : hexadecimal public key iscompressed : true if pubkey is a short 33-byte key New JSON-RPC api commands for dumping/importing private keys from the wallet (dumprivkey, importprivkey). New JSON-RPC api command for getting information about blocks (getblock, getblockhash). New JSON-RPC api command (getmininginfo) for getting extra information related to mining. The getinfo JSON-RPC command no longer includes mining-related information (generate/genproclimit/hashespersec). NOTABLE CHANGES BIP30 implemented (security fix for an attack involving duplicate "coinbase transactions"). The -nolisten, -noupnp and -nodnsseed command-line options were renamed to -listen, -upnp and -dnsseed, with a default value of 1. The old names are still supported for compatibility (so specifying -nolisten is automatically interpreted as -listen=0; every boolean argument can now be specified as either -foo or -nofoo). The -noirc command-line options was renamed to -irc, with a default value of 0. Run -irc=1 to get the old behavior. Three fill-up-available-memory denial-of-service attacks were fixed. NOT YET IMPLEMENTED FEATURES Support for clicking on bitcoin: URIs and opening/launching Bitcoin-Qt is available only on Linux, and only if you configure your desktop to launch Bitcoin-Qt. All platforms support dragging and dropping bitcoin: URIs onto the Bitcoin-Qt window to start payment. PRELIMINARY SUPPORT FOR MULTISIGNATURE TRANSACTIONS This release has preliminary support for multisignature transactions-- transactions that require authorization from more than one person or device before they will be accepted by the bitcoin network. Prior to this release, multisignature transactions were considered 'non-standard' and were ignored; with this release multisignature transactions are considered standard and will start to be relayed and accepted into blocks. It is expected that future releases of Bitcoin-Qt will support the creation of multisignature transactions, once enough of the network has upgraded so relaying and validating them is robust. For this release, creation and testing of multisignature transactions is limited to the bitcoin test network using the "addmultisigaddress" JSON-RPC api call. Short multisignature address support is included in this release, as specified in BIP 13 and BIP 16.
coinerd/krugercoin
doc/release-notes/release-notes-0.6.0.md
Markdown
mit
4,544
[ 30522, 2978, 3597, 2378, 2544, 1014, 1012, 1020, 1012, 1014, 2003, 2085, 2800, 2005, 8816, 2012, 1024, 8299, 1024, 1013, 1013, 3120, 29278, 3351, 1012, 5658, 1013, 3934, 1013, 2978, 3597, 2378, 1013, 6764, 1013, 2978, 3597, 2378, 1013, 29...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "agencyinclude.h" SNIPERESULT snipe(PPLAYER ps, PWEAPON weapon, bool training) { SNIPERESULT sr; int hitcode; bool shotfired = false; bool critical = false; if(!weapon){ shotfired = false; } else{ //PLAY RELOAD SOUND SnipeShowOptics(ps, training); //NOW DO THE TEST hitcode = snipetest(ps, training); } //PLAY THE SOUND FOR THE WEAPON AND FLASH if(hitcode != SNIPECODE_OVEROCULAR){ playWeaponSound(weapon, WEAPONSOUND_SHOOT, SOUND_MODE_MIX); flashscope(); Sleep(500); if (hitcode != SNIPECODE_MISS && hitcode != SNIPECODE_CHEST_SCRAPE ){ //CRITICAL POSSIBLITY = SNIPING SKILL FOR A MAX CHANCE OF 40%. } sr.shotfired = true; } else{ if(!training){ //ADD IN A SCRIPTED EVENT THAT RESTORES OCULAR FOCUS. ps->currentmissioninfo.cansnipe = false; SCRIPTEDEVENT Event; Event.Type = SCRIPTEDEVENT_TYPE_OCULARFOCUS; Event.TriggerTime = GetTimeToNewOcularFocus(ps, &globals.globalmapstruct.totaltime); AddScriptedEvent(&Event); } } reportsnipehit(hitcode, critical); sr.hitcode = hitcode; sr.critical = critical; return sr; } void SnipeShowOptics(PPLAYER ps, bool training) { char* Normal = "DSA STANDARD OPTICS ONLINE"; char* NV = "DSA X-RIFLE INTERFACE - LIGHT AMPLIFICATION"; char* Therm = "DSA X-RIFLE INTERFACE - THERMAL AMPLIFICATION"; char* Switch = "X-RIFLE - NO CONNECTION - DEFAULTING TO NORMAL OPTICS"; POINT Point; Point.y = retrieveTextCenterV(); if(training || !FindActiveGizmoOfType(GIZMO_TYPE_XRIFLE, ps->p_gizmos)){ WHITE; Point.x = retrieveTextCenterH(Normal); setcursor(Point.x, Point.y); bufferprints(30, Normal, BEEPC); Sleep(500); DGRAY; showscope(); Sleep(100); GRAY; showscope(); Sleep(100); WHITE; showscope(); } else if(FindActiveGizmoOfType(GIZMO_TYPE_TAS, ps->p_gizmos)){ LRED; Point.x = retrieveTextCenterH(Therm); setcursor(Point.x, Point.y); bufferprints(30, Therm, BEEPC); Sleep(500); RED; showscope(); Sleep(100); LRED; showscope(); } else if(FindActiveGizmoOfType(GIZMO_TYPE_NVG, ps->p_gizmos)){ LGREEN; Point.x = retrieveTextCenterH(NV); setcursor(Point.x, Point.y); bufferprints(30, NV, BEEPC); Sleep(500); GREEN; showscope(); Sleep(100); LGREEN; showscope(); } else { WHITE; Point.x = retrieveTextCenterH(Switch); bufferprints(30, Switch, BEEPC); Sleep(500); DGRAY; showscope(); Sleep(100); GRAY; showscope(); Sleep(100); WHITE; showscope(); } } WORD SnipeGetOpticColor(PPLAYER ps, bool training) { if(training) { return FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; } if(!FindActiveGizmoOfType(GIZMO_TYPE_XRIFLE, ps->p_gizmos)){ return FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; } else if(FindActiveGizmoOfType(GIZMO_TYPE_TAS, ps->p_gizmos)){ return FOREGROUND_RED | FOREGROUND_INTENSITY; } else if(FindActiveGizmoOfType(GIZMO_TYPE_NVG, ps->p_gizmos)){ return FOREGROUND_GREEN | FOREGROUND_INTENSITY; } else{ return FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; } } void RestoreOcularFocus(PPLAYER player) { player->currentmissioninfo.cansnipe = TRUE; SetGlobalDBoxParam(DB_SCHEME_BLUEANDYELLOW, DB_MEDIUM, 1, FALSE); StaticDialogBox("Ocular Focus Restored", "Your eyes calm down from their painful over-correction and return to normal. You feel ready to snipe again should the need arise.", "Press ENTER", &globals.dboxparams); } MISSIONCHRONO GetTimeToNewOcularFocus(PPLAYER player, PMISSIONCHRONO totaltime) { MISSIONCHRONO OurChron = *totaltime; int minutes = 0; int seconds = 0; int split = 0; //WE'LL JUST GO AHEAD AND GET THE NUMBER OF SPLIT SECONDS TO RECOVERY. //WE WANT A NUMBER WITHIN MAX_SNIPE_OCULAR_STATES. double MinTime = (double)MAX_OCULAR_RECOVERY_SECONDS; double MaxSubtractive = (double)MAX_OCULAR_RECOVERY_SECONDS - MIN_OCULAR_RECOVERY_SECONDS; double CurrentPercentage = (double)(player->psychskill.skills.snipingcombat * 100 / MAX_SKILL); MinTime -= MaxSubtractive * CurrentPercentage / 100.0; MinTime *= 100; //FOR SPLIT SECONDS. split = (int)MinTime; if(split >= 100){ seconds = split/100; split = split%100; } if(seconds >= 60){ minutes = seconds /60; seconds = seconds % 60; } OurChron.minutes += minutes; OurChron.seconds += seconds; OurChron.split += split; calibratemissionchrono(&OurChron); return OurChron; } void SnipeDrawOcularState(int status) { RECT ClearingRect; ClearingRect.top = 0; ClearingRect.left = 0; ClearingRect.right = getconsize().X/2 - 3; ClearingRect.bottom = 0; ClearRect(ClearingRect); setcursor(0,0); WHITE; writestring("Ocular Status: "); switch(status) { case SNIPEOCULAR_RELAXED: LGREEN; writestring("Relaxed"); break; case SNIPEOCULAR_TENSING: LBLUE; writestring("Tensing"); break; case SNIPEOCULAR_TENSE: GRAY; writestring("Tensed"); break; case SNIPEOCULAR_TREMBLING: YELLOW; writestring("Trembling"); break; case SNIPEOCULAR_BLURRING: LYELLOW; writestring("Blurring"); break; case SNIPEOCULAR_LOSINGFOCUS: LRED; writestring("LOSING FOCUS"); break; default: RED; writestring("UNKNOWN"); break; } } int GetNewOcularState(PPLAYER player, int totalsplitelapsed) { //WE WANT A NUMBER WITHIN MAX_SNIPE_OCULAR_STATES. double MaxTime = (double)MIN_OCULAR_HOLD_SECONDS; double MaxAdditive = (double)MAX_OCULAR_HOLD_SECONDS - MIN_OCULAR_HOLD_SECONDS; double CurrentPercentage = (double)(player->psychskill.skills.snipingcombat * 100 / MAX_SKILL); MaxTime += MaxAdditive * CurrentPercentage / 100.0; MaxTime *= 100; //FOR SPLIT SECONDS. //WE NOW HAVE THE MAXIMUM AMOUNT OF TIME BEFORE WE GO BLURRY. if(totalsplitelapsed > MaxTime){ return SNIPEOCULAR_LOST; } double CurrentDState = (double)totalsplitelapsed * (double)MAX_SNIPE_OCULAR_STATES / MaxTime; int CurrentIState = (int)CurrentDState; return CurrentIState; } int snipetest(PPLAYER ps, bool training) { // int choice; int vcenter; int hcenter; int numevents; int i; unsigned int splittime = 0; int OcularState = SNIPEOCULAR_RELAXED; int NextState = SNIPEOCULAR_RELAXED; USHORT key; WORD opticcolor = SnipeGetOpticColor(ps, training); TIMER Timer; INPUT_RECORD InputRec; RECT scopebound; //ULONG events; // ULONG written; COORD consize; COORD targetxarrow; COORD targetyarrow; COORD yourxarrow; COORD scoperedrawpt1; COORD scoperedrawpt2; BOOL yourxarrowdir = 0; COORD youryarrow; BOOL youryarrowdir = 0; consize = getconsize(); hcenter = consize.X / 2; vcenter = consize.Y / 2; FLUSH; clearinputrecords(); //GET THE SCOPE BOUNDARIES scopebound.left = 12; scopebound.right = consize.X - 16; scopebound.top = 1; scopebound.bottom = consize.Y - 2; scoperedrawpt1.X = hcenter - 2; scoperedrawpt1.Y = vcenter - 1; scoperedrawpt2.X = hcenter -3; scoperedrawpt2.Y = vcenter; targetxarrow.X = random(scopebound.left + 2, scopebound.right - 2); targetxarrow.Y = vcenter + 1; if(targetxarrow.X == hcenter){ targetxarrow.X ++; } targetyarrow.X = hcenter - 1; targetyarrow.Y = random(scopebound.top + 2, scopebound.bottom - 2); if(targetyarrow.Y == vcenter){ targetyarrow.Y ++; } yourxarrow.X = random(scopebound.left, scopebound.right); yourxarrow.Y = vcenter - 1; youryarrow.X = hcenter - 3; youryarrow.Y = random(scopebound.top, scopebound.bottom); youryarrowdir = rand()%2; yourxarrowdir = rand()%2; setcursor(targetxarrow.X, targetxarrow.Y); LRED; printf("%c",SNIPECHAR_UPARROW); setcursor(targetyarrow.X, targetyarrow.Y); LRED; printf("%c",SNIPECHAR_RTARROW); SnipeDrawOcularState(OcularState); memset(&InputRec, 0, sizeof(INPUT_RECORD)); FLUSH; // memset(&yourxarrowoverwrite, 0, sizeof(CHAR_INFO)); //memset(&youryarrowoverwrite, 0, sizeof(CHAR_INFO)); for(;;) { StartTimer(&Timer); //SET THE CURSOR TO REWRITE THE CHARACTER UNDERNEATH THE ARROW setcursor(yourxarrow.X, yourxarrow.Y); // printf("%c", yourxarrowoverwrite.Char.AsciiChar); printf(" "); setcursor(youryarrow.X, youryarrow.Y); // printf("%c", youryarrowoverwrite.Char.AsciiChar); printf(" "); //SET NEW COORDINATES if (yourxarrowdir) // IF GOING RIGHT { if (yourxarrow.X < scopebound.right) { //yourxarrow.X = random(scopebound.left, scopebound.right); yourxarrow.X += 1; } } else if (!yourxarrowdir) //IF GOING LEFT { if (yourxarrow.X > scopebound.left) { yourxarrow.X -= 1; } } // yourxarrow.X += 1; if (youryarrowdir) // IF GOING DOWN { if (youryarrow.Y < scopebound.bottom) { //yourxarrow.X = random(scopebound.left, scopebound.right); youryarrow.Y += 1; } } else if (!youryarrowdir) //IF GOING UP { if (youryarrow.Y > scopebound.top) { youryarrow.Y -= 1; } } //GET THE NEW CHAR_INFOS AT THOSE COORDS // ReadConsoleOutputCharacter(getconsoleoutputh(), &yourxarrowoverwrite.Char.AsciiChar, 1, yourxarrow, &written); // ReadConsoleOutputAttribute(getconsoleoutputh(), &yourxarrowoverwrite.Attributes, 1, yourxarrow, &written); //REDRAW THE SCOPE OVERDRAW POINTS setcursor(scoperedrawpt1.X, scoperedrawpt1.Y); setcolor(opticcolor); printf("%c", SNIPECHAR_CROSS); setcursor(scoperedrawpt2.X, scoperedrawpt2.Y); printf("%c", SNIPECHAR_HLINE); //DRAW THE NEW ARROWS setcursor(yourxarrow.X, yourxarrow.Y); LGREEN; printf("%c", SNIPECHAR_DNARROW); setcursor(youryarrow.X, youryarrow.Y); LGREEN; printf("%c", SNIPECHAR_LTARROW); setcursor(targetxarrow.X, targetxarrow.Y); LRED; printf("%c", SNIPECHAR_UPARROW); setcursor(targetyarrow.X, targetyarrow.Y); LRED; printf("%c", SNIPECHAR_RTARROW); numevents = checkforinput(); if (numevents > 1) { for (i = 1; i <= numevents; i++) { key = getinput(i); if (key == ' ') { return CheckSnipeHit(yourxarrow.X - targetxarrow.X, youryarrow.Y - targetyarrow.Y); } else if (key == VK_LEFT) { yourxarrowdir = 0; } else if (key == VK_RIGHT) { yourxarrowdir = 1; } else if (key == VK_UP) { youryarrowdir = 0; } else if (key == VK_DOWN) { youryarrowdir = 1; } FLUSH; } clearinputrecords(); } Sleep(SNIPE_MAX_SLEEP - SNIPE_DROP_PER_OCULAR * OcularState + SNIPE_SLEEP_CALMNESS_BONUS * ps->psychskill.psych.calmness); EndTimer(&Timer); splittime += SplitElapsed(&Timer); NextState = GetNewOcularState(ps, splittime); if(NextState == SNIPEOCULAR_LOST){ GRAY; showscope(); Sleep(100); DGRAY; showscope(); Sleep(100); cls(0); return SNIPECODE_OVEROCULAR; } else if(NextState != OcularState){ OcularState = NextState; SnipeDrawOcularState(OcularState); } } } void showscope() { COORD scopecoord; COORD consize; COORD scopesize; cls(0); consize = getconsize(); scopesize = getgraphicdimensions(globals.graphicslist, SNIPE_GRAPHIC_ID); scopecoord.X = (consize.X / 2) - (scopesize.X / 2) - 2; scopecoord.Y = 1; printgraphic(globals.graphicslist, scopecoord, SNIPE_GRAPHIC_ID); zerocursor(); } void flashscope() { fillwithcolor(FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE); Sleep(100); fillwithcolor(FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY); Sleep(500); cls(0); } int CheckSnipeHit(int xoff, int yoff) { if (!xoff)//DEAD ON HORIZ { if(!yoff){ return SNIPECODE_HEART; } else if (yoff == -2 || yoff == -1){ return SNIPECODE_BRAINSTEM; } else if (yoff == 2 || yoff == 1){ return SNIPECODE_ABDOMEN; } else{ return SNIPECODE_MISS; } } else if (xoff >= -2 && xoff <= 2)//OFF BY SMALL AMOUNT HORIZ LEFT { if(!yoff){ return SNIPECODE_CHEST; } if (yoff == -2 || yoff == -1){ return SNIPECODE_SHOULDER; } else if (yoff == 2 || yoff == 1){ return SNIPECODE_LEG; } else{ return SNIPECODE_MISS; } } else if (xoff >= -4 && xoff <= 4) //OFF BY A CONSIDERABLE MARGIN { if(!yoff){ return SNIPECODE_CHEST_SCRAPE; } else if (yoff == -2 || yoff == -1){ return SNIPECODE_ARM; } else if (yoff == 2 || yoff == 1){ return SNIPECODE_LEG; } else{ return SNIPECODE_MISS; } } else{ return SNIPECODE_MISS; } } int reportsnipehit(int hitcode,bool critical) { int vcenter; int hcenter; int t_hcenter; COORD consize; char hittext[9][30] = {"MISSED TARGET", "BRAINSTEM SEVERED", "HEART PUNCTURED", "CHEST PIERCED", "ABDOMEN PUNCTURED", "SHOULDER PIERCED", "ARM PIERCED", "LEG PIERCED", "CHEST LACERATED"}; char* scritical = "C R I T I C A L"; char* focusloss = "F O C U S L O S T"; //GET SOME POSITION DATA consize = getconsize(); vcenter = consize.Y / 2; hcenter = consize.X / 2; //PRINT THE RESULT if (hitcode >= 0 && hitcode <= 9) { t_hcenter = (hcenter - (strlen(hittext[hitcode]) / 2)); setcursor(t_hcenter, vcenter); RED; bufferprints(50, hittext[hitcode], BEEPA); } else if(hitcode == -1){ t_hcenter = (hcenter - (strlen(focusloss) / 2)); setcursor(t_hcenter, vcenter); LRED; bufferprints(50, focusloss, BEEPC); } else { t_hcenter = (hcenter - (strlen("ERROR!!!") / 2)); setcursor(t_hcenter, vcenter); RED; bufferprint(50, "ERROR!!!"); } Sleep(1500); cls(0); Sleep(500); if (critical) { t_hcenter = (hcenter - (strlen(scritical) / 2)); setcursor(t_hcenter, vcenter); RED; writestring(scritical); Sleep(100); LRED; setcursor(t_hcenter, vcenter); writestring(scritical); } Sleep(1500); if (critical) { t_hcenter = (hcenter - (strlen(scritical) / 2)); setcursor(t_hcenter, vcenter); RED; writestring(scritical); Sleep(100); cls(0); Sleep(500); } return 1; }
agentcox/TheAgencyRazorOne
sniping.cpp
C++
mit
14,457
[ 30522, 1001, 2421, 1000, 4034, 2378, 20464, 12672, 1012, 1044, 1000, 17515, 2229, 11314, 1055, 3490, 5051, 1006, 4903, 24314, 8827, 1010, 1052, 8545, 9331, 2239, 5195, 1010, 22017, 2140, 2731, 1007, 1063, 17515, 2229, 11314, 5034, 1025, 200...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html> <html> <head> <meta charset='utf-8' /> <link href='../dist/fullcalendar.css' rel='stylesheet' /> <link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' /> <script src='../lib/moment/moment.js'></script> <script src='../lib/jquery/dist/jquery.js'></script> <script src='../dist/fullcalendar.js'></script> <script> $(document).ready(function() { var currentTimezone = false; // load the list of available timezones $.getJSON('php/get-timezones.php', function(timezones) { $.each(timezones, function(i, timezone) { if (timezone != 'UTC') { // UTC is already in the list $('#timezone-selector').append( $("<option/>").text(timezone).attr('value', timezone) ); } }); }); // when the timezone selector changes, rerender the calendar $('#timezone-selector').on('change', function() { currentTimezone = this.value || false; $('#calendar').fullCalendar('destroy'); renderCalendar(); }); function renderCalendar() { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, defaultDate: '2014-11-12', timezone: currentTimezone, editable: true, eventLimit: true, // allow "more" link when too many events events: { url: 'php/get-events.php', error: function() { $('#script-warning').show(); } }, loading: function(bool) { $('#loading').toggle(bool); }, eventRender: function(event, el) { // render the timezone offset below the event title if (event.start.hasZone()) { el.find('.fc-title').after( $('<div class="tzo"/>').text(event.start.format('Z')) ); } } }); } renderCalendar(); }); </script> <style> body { margin: 0; padding: 0; font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif; font-size: 14px; } #top { background: #eee; border-bottom: 1px solid #ddd; padding: 0 10px; line-height: 40px; font-size: 12px; } .left { float: left } .right { float: right } .clear { clear: both } #script-warning, #loading { display: none } #script-warning { font-weight: bold; color: red } #calendar { max-width: 900px; margin: 40px auto; padding: 0 10px; } .tzo { color: #000; } </style> </head> <body> <div id='top'> <div class='left'> Timezone: <select id='timezone-selector'> <option value='' selected>none</option> <option value='local'>local</option> <option value='UTC'>UTC</option> </select> </div> <div class='right'> <span id='loading'>loading...</span> <span id='script-warning'><code>php/get-events.php</code> must be running.</span> </div> <div class='clear'></div> </div> <div id='calendar'></div> </body> </html>
microuser/HTML4PHP
webroot/resources/fullcalendar/demos/timezones.html
HTML
mit
2,806
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1005, 21183, 2546, 1011, 1022, 1005, 1013, 1028, 1026, 4957, 17850, 12879, 1027, 1005, 1012, 1012, 1013, 4487, 3367, 1013, 244...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.zuoqing.demo.entity; /** * http 请求返回的最外层对象 */ public class Result<T> { private Integer code; private String msg; private T data; public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public T getData() { return data; } public void setData(T data) { this.data = data; } }
zuoqing135du/SpringBoot
src/main/java/com/zuoqing/demo/entity/Result.java
Java
apache-2.0
569
[ 30522, 7427, 4012, 1012, 16950, 2080, 19784, 1012, 9703, 1012, 9178, 1025, 1013, 1008, 1008, 1008, 8299, 100, 100, 100, 100, 1916, 100, 1809, 100, 100, 100, 1008, 1013, 2270, 2465, 2765, 1026, 1056, 1028, 1063, 2797, 16109, 3642, 1025, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "../lib/includes.h" #include "../lib/utils.h" #include "../lib/methnum.h" #include "../Enum_type.h" #include "../Var/var.h" #include "../T0/t0.h" #include "upot.h" void test_der ( Upot * U , U_type upot_t , T0_type t0_t, bool phi_eq_phibar ); #define TD_T(f,df,nf,str) do{ testderiv(f,df,Tmin ,Tmax ,N,0.001,nf,str); } while(0) #define TD_phi(f,df,nf,str) do{ testderiv(f,df,phimin,phimax,N,0.001,nf,str); } while(0) #define TD_mu(f,df,nf,str) do{ testderiv(f,df,mumin ,mumax ,N,0.001,nf,str); } while(0) #define TOTO(i) do{ printf("toto %d\n", i); } while(0) int main ( void ) { bool all_test = false ; printf ("testing Gluonic potential derivatives \n" ); bool phi_eq_phibar = true ; Upot * U = Upot_alloc_32 ( U_POW, T0_CST, C_ANA, 0.650, phi_eq_phibar ); test_der ( U , U_POW , T0_T2, true ); if ( false ){ test_der ( U , U_POW , T0_CST, phi_eq_phibar ); test_der ( U , U_POW , T0_T1, phi_eq_phibar ); test_der ( U , U_POW , T0_T2, phi_eq_phibar ); } if ( false ) { test_der ( U , U_POW , T0_T2, phi_eq_phibar ); test_der ( U , U_LOG , T0_T2, phi_eq_phibar ); test_der ( U , U_FUK , T0_T2, phi_eq_phibar ); test_der ( U , U_DEX , T0_T2, phi_eq_phibar ); } if ( all_test ) { test_der ( U , U_POW , T0_CST, phi_eq_phibar ); test_der ( U , U_POW , T0_T1, phi_eq_phibar ); test_der ( U , U_POW , T0_T2, phi_eq_phibar ); test_der ( U , U_LOG , T0_CST, phi_eq_phibar ); test_der ( U , U_LOG , T0_T1, phi_eq_phibar ); test_der ( U , U_LOG , T0_T2, phi_eq_phibar ); test_der ( U , U_FUK , T0_CST, phi_eq_phibar ); test_der ( U , U_DEX , T0_CST, phi_eq_phibar ); test_der ( U , U_DEX , T0_T1, phi_eq_phibar ); test_der ( U , U_DEX , T0_T2, phi_eq_phibar ); } Upot_free ( U ); return 0 ; } void test_der ( Upot * U , U_type upot_t , T0_type t0_t, bool phi_eq_phibar ) { // Upot_set_type ( U , upot_t, t0_t, ANA ); double T_ = 0.1 , phi_ = 0.5 , phibar_= 0.7, mu_= 0.1 ; double Tmin= 0.1, Tmax=0.5, mumin=0., mumax=0.2, phimin=0.01,phimax=0.1 ; int N = 40 ; char pref[128], nf[256] ; Var * V = Var_alloc ( ); if ( upot_t == U_POW ) { Upot_set_pow_std ( U , t0_t, phi_eq_phibar); if ( phi_eq_phibar ) { if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Upow_T0_cst_phi_eq_phibar" ); else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Upow_T0_t1_phi_eq_phibar" ); else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Upow_T0_t2_phi_eq_phibar" ); else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error"); } } else { if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Upow_T0_cst" ); else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Upow_T0_t1" ); else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Upow_T0_t2" ); else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error"); } } } else if ( upot_t == U_LOG ) { Upot_set_log_std ( U , t0_t, phi_eq_phibar); if ( phi_eq_phibar ) { if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Ulog_T0_cst_phi_eq_phibar" ); else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Ulog_T0_t1_phi_eq_phibar" ); else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Ulog_T0_t2_phi_eq_phibar" ); else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error");} } else { if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Ulog_T0_cst" ); else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Ulog_T0_t1" ); else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Ulog_T0_t2" ); else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error");} } } else if ( upot_t == U_FUK ) { Upot_set_fuk_std ( U , t0_t, 0.650, phi_eq_phibar); if ( phi_eq_phibar ) sprintf (pref ,"%s" ,"Ufuk_phi_eq_phibar" ); else sprintf (pref ,"%s" ,"Ufuk" ); } else if ( upot_t == U_DEX ) { Upot_set_dex_std ( U , t0_t, phi_eq_phibar); if ( phi_eq_phibar ) { if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Udex_T0_cst_phi_eq_phibar" ); else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Udex_T0_t1_phi_eq_phibar" ); else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Udex_T0_t2_phi_eq_phibar" ); else { Var_free ( V ); Upot_free ( U );ERROR ( stdout , "T0 type error"); } } else { if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Udex_T0_cst" ); else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Udex_T0_t1" ); else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Udex_T0_t2" ); else { Var_free ( V ); Upot_free ( U );ERROR ( stdout , "T0 type error"); } } } else { Var_free ( V ); Upot_free ( U );ERROR ( stdout , "U type error"); } if ( !phi_eq_phibar ) { //////////// GRAND POTENTIAL //// double u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->Ug( U->P , U->T0, V ); } double u_phibar ( double phibar ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi_, phibar ); return U->Ug( U->P , U->T0, V ); } double u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->Ug( U->P , U->T0, V ); } double u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->Ug( U->P , U->T0, V ); } sprintf ( nf , "%s_phi" , pref ); plot_2D ( u_phi , phimin,phimax,N,nf,"set xla \"phi\"; set xzeroaxis" , false ); sprintf ( nf , "%s_phibar", pref ); plot_2D ( u_phibar, phimin,phimax,N,nf,"set xla \"phibar\"; set xzeroaxis", false ); sprintf ( nf , "%s_T" , pref ); plot_2D ( u_T , Tmin ,Tmax ,N,nf,"set xla \"T\"; set xzeroaxis" , false ); sprintf ( nf , "%s_mu" , pref ); plot_2D ( u_mu , mumin ,mumax ,N,nf,"set xla \"mu\"; set xzeroaxis" , false ); //////////// 1ST DERIVATIVES //// double dphi_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi_Ug ( U->P , U->T0, V ); } double dphibar_u_phibar ( double phibar ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi_, phibar ); return U->dphibar_Ug( U->P , U->T0, V ); } double dT_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT_Ug ( U->P , U->T0, V ); } double dmu_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu_Ug ( U->P , U->T0, V ); } sprintf ( nf , "dphi_%s_phi" , pref ); TD_phi(u_phi ,dphi_u_phi ,nf,"set xla\"phi\""); sprintf ( nf , "dphibar_%s_phibar", pref ); TD_phi(u_phibar,dphibar_u_phibar,nf,"set xla\"phibar\""); sprintf ( nf , "dT_%s_T" , pref ); TD_T (u_T ,dT_u_T ,nf,"set xla\"T\""); sprintf ( nf , "dmu_%s_mu" , pref ); TD_mu (u_mu ,dmu_u_mu ,nf,"set xla\"mu\""); //////////// 2ND DERIVATIVES //// double dT2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2_Ug ( U->P , U->T0, V ); } double dTmu_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmu_Ug ( U->P , U->T0, V ); } double dmu_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmu_Ug ( U->P , U->T0, V ); } double dTphi_u_T( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphi_Ug ( U->P , U->T0, V ); } double dphi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphi_Ug ( U->P , U->T0, V ); } double dTphibar_u_T( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphibar_Ug ( U->P , U->T0, V ); } double dphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphibar_Ug ( U->P , U->T0, V ); } double dmu2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu2_Ug ( U->P , U->T0, V ); } double dmuphi_u_mu ( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphi_Ug ( U->P , U->T0, V ); } double dphi_u_mu( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphi_Ug ( U->P , U->T0, V ); } double dmuphibar_u_mu ( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphibar_Ug ( U->P , U->T0, V ); } double dphibar_u_mu( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphibar_Ug ( U->P , U->T0, V ); } double dphi2_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi2_Ug ( U->P , U->T0, V ); } double dphiphibar_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphiphibar_Ug ( U->P , U->T0, V ); } double dphibar_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphibar_Ug ( U->P , U->T0, V ); } double dphibar2_u_phibar ( double phibar ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi_, phibar ); return U->dphibar2_Ug( U->P , U->T0, V ); } sprintf ( nf , "dT2_%s_T", pref ); TD_T(dT_u_T, dT2_u_T,nf , "set xla\"T\""); sprintf ( nf , "dTmu_%s_T", pref ); TD_T(dmu_u_T, dTmu_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTphi_%s_T", pref ); TD_T(dphi_u_T, dTphi_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTphibar_%s_T", pref ); TD_T(dphibar_u_T, dTphibar_u_T,nf,"set xla\"T\""); sprintf ( nf , "dmu2_%s_mu", pref ); TD_mu (dmu_u_mu,dmu2_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmuphi_%s_mu", pref ); TD_mu (dphi_u_mu,dmuphi_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmuphibar_%s_mu", pref ); TD_mu (dphibar_u_mu,dmuphibar_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dphi2_%s_phi" , pref ); TD_phi(dphi_u_phi,dphi2_u_phi,nf,"set xla\"phi\""); sprintf ( nf , "dphiphibar_%s_phi" , pref ); TD_phi(dphibar_u_phi,dphiphibar_u_phi,nf,"set xla\"phi\""); sprintf ( nf , "dphibar2_%s_phibar", pref ); TD_phi(dphibar_u_phibar,dphibar2_u_phibar,nf,"set xla\"phibar\""); //////////// 3RD DERIVATIVES //// double dT3_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT3_Ug ( U->P , U->T0, V ); } double dT2mu_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2mu_Ug ( U->P , U->T0, V ); } double dT2phi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2phi_Ug ( U->P , U->T0, V ); } double dT2phibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2phibar_Ug ( U->P , U->T0, V ); } double dTmu2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmu2_Ug ( U->P , U->T0, V ); } double dmu2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmu2_Ug ( U->P , U->T0, V ); } double dTmuphi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmuphi_Ug ( U->P , U->T0, V ); } double dmuphi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmuphi_Ug ( U->P , U->T0, V ); } double dTmuphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmuphibar_Ug ( U->P , U->T0, V ); } double dmuphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmuphibar_Ug ( U->P , U->T0, V ); } double dTphi2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphi2_Ug ( U->P , U->T0, V ); } double dphi2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphi2_Ug ( U->P , U->T0, V ); } double dTphiphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphiphibar_Ug ( U->P , U->T0, V ); } double dphiphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphiphibar_Ug ( U->P , U->T0, V ); } double dTphibar2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphibar2_Ug ( U->P , U->T0, V ); } double dphibar2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphibar2_Ug ( U->P , U->T0, V ); } double dmu3_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu3_Ug ( U->P , U->T0, V ); } double dmu2phi_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu2phi_Ug ( U->P , U->T0, V ); } double dmu2phibar_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu2phibar_Ug ( U->P , U->T0, V ); } double dmuphi2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphi2_Ug ( U->P , U->T0, V ); } double dphi2_u_mu ( double mu ) {Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphi2_Ug ( U->P , U->T0, V ); } double dmuphiphibar_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphiphibar_Ug ( U->P , U->T0, V ); } double dphiphibar_u_mu ( double mu ) {Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphiphibar_Ug ( U->P , U->T0, V ); } double dmuphibar2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphibar2_Ug ( U->P , U->T0, V ); } double dphibar2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphibar2_Ug ( U->P , U->T0, V ); } double dphi3_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi3_Ug ( U->P , U->T0, V ); } double dphi2phibar_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi2phibar_Ug ( U->P , U->T0, V ); } double dphiphibar2_u_phi ( double phi ) {Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphiphibar2_Ug ( U->P , U->T0, V ); } double dphibar2_u_phi ( double phi ){Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphibar2_Ug ( U->P , U->T0, V ); } double dphibar3_u_phibar ( double phibar ) { Var_set_Tmuphiphibar( V, T_, mu_, phi_, phibar ); return U->dphibar3_Ug( U->P , U->T0, V ); } sprintf ( nf , "dT3_%s_T", pref ); TD_T(dT2_u_T, dT3_u_T,nf,"set xla\"T\""); sprintf ( nf , "dT2mu_%s_T", pref ); TD_T(dTmu_u_T, dT2mu_u_T,nf,"set xla\"T\""); sprintf ( nf , "dT2phi_%s_T", pref ); TD_T(dTphi_u_T, dT2phi_u_T,nf,"set xla\"T\""); sprintf ( nf , "dT2phibar_%s_T", pref ); TD_T(dTphibar_u_T, dT2phibar_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTmu2_%s_T", pref ); TD_T(dmu2_u_T, dTmu2_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTmuphi_%s_T", pref ); TD_T(dmuphi_u_T, dTmuphi_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTmuphibar_%s_T", pref ); TD_T(dmuphibar_u_T, dTmuphibar_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTphi2_%s_T", pref ); TD_T(dphi2_u_T, dTphi2_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTphiphibar_%s_T", pref ); TD_T(dphiphibar_u_T, dTphiphibar_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTphibar2_%s_T", pref ); TD_T(dphibar2_u_T, dTphibar2_u_T,nf,"set xla\"T\""); sprintf ( nf , "dmu3_%s_mu", pref ); TD_mu (dmu2_u_mu,dmu3_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmu2phi_%s_mu", pref ); TD_mu (dmuphi_u_mu,dmu2phi_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmu2phibar_%s_mu", pref ); TD_mu (dmuphibar_u_mu,dmu2phibar_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmuphi2_%s_mu", pref ); TD_mu (dphi2_u_mu,dmuphi2_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmuphiphibar_%s_mu", pref ); TD_mu (dphiphibar_u_mu,dmuphiphibar_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmuphibar2_%s_mu", pref ); TD_mu (dphibar2_u_mu,dmuphibar2_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dphi3_%s_phi", pref ); TD_phi(dphi2_u_phi,dphi3_u_phi,nf,"set xla\"phi\""); sprintf ( nf , "dphiphibar_%s_phi", pref ); TD_phi(dphiphibar_u_phi,dphi2phibar_u_phi,nf,"set xla\"phi\""); sprintf ( nf , "dphiphibar2_%s_phi", pref ); TD_phi(dphibar2_u_phi,dphiphibar2_u_phi,nf,"set xla\"phi\""); sprintf ( nf , "dphibar3_%s_phibar", pref ); TD_phi(dphibar2_u_phibar,dphibar3_u_phibar,nf,"set xla\"phibar\""); } else // phi = phibar { //////////// GRAND POTENTIAL //// double u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->Ug( U->P , U->T0, V ); } double u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->Ug( U->P , U->T0, V ); } double u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->Ug( U->P , U->T0, V ); } sprintf ( nf , "%s_phi" , pref ); plot_2D ( u_phi , phimin,phimax,N,nf,"set xla \"phi\"; set xzeroaxis" , false ); sprintf ( nf , "%s_T" , pref ); plot_2D ( u_T , Tmin ,Tmax ,N,nf,"set xla \"T\"; set xzeroaxis" , false ); sprintf ( nf , "%s_mu" , pref ); plot_2D ( u_mu , mumin ,mumax ,N,nf,"set xla \"mu\"; set xzeroaxis" , false ); //////////// 1ST DERIVATIVES //// double dphi_u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->dphi_Ug ( U->P , U->T0, V ); } double dT_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT_Ug ( U->P , U->T0, V ); } double dmu_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu_Ug ( U->P , U->T0, V ); } sprintf ( nf , "dphi_%s_phi" , pref ); TD_phi(u_phi ,dphi_u_phi ,nf,"set xla\"phi\""); sprintf ( nf , "dT_%s_T" , pref ); TD_T (u_T ,dT_u_T ,nf,"set xla\"T\""); sprintf ( nf , "dmu_%s_mu" , pref ); TD_mu (u_mu ,dmu_u_mu ,nf,"set xla\"mu\""); //////////// 2ND DERIVATIVES //// double dT2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT2_Ug ( U->P , U->T0, V ); } double dTmu_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTmu_Ug ( U->P , U->T0, V ); } double dmu_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dmu_Ug ( U->P , U->T0, V ); } double dTphi_u_T( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTphi_Ug ( U->P , U->T0, V ); } double dphi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dphi_Ug ( U->P , U->T0, V ); } double dmu2_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu2_Ug ( U->P , U->T0, V ); } double dmuphi_u_mu ( double mu ){ Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmuphi_Ug ( U->P , U->T0, V ); } double dphi_u_mu( double mu ){ Var_set_Tmuphi ( V, T_, mu , phi_); return U->dphi_Ug ( U->P , U->T0, V ); } double dphi2_u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->dphi2_Ug ( U->P , U->T0, V ); } //if ( false ) { sprintf ( nf , "dT2_%s_T", pref ); TD_T(dT_u_T, dT2_u_T,nf , "set xla\"T\""); sprintf ( nf , "dTmu_%s_T", pref ); TD_T(dmu_u_T, dTmu_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTphi_%s_T", pref ); TD_T(dphi_u_T, dTphi_u_T,nf,"set xla\"T\""); sprintf ( nf , "dmu2_%s_mu", pref ); TD_mu (dmu_u_mu,dmu2_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmuphi_%s_mu", pref ); TD_mu (dphi_u_mu,dmuphi_u_mu ,nf,"set xla\"mu\""); //} sprintf ( nf , "dphi2_%s_phi" , pref ); TD_phi(dphi_u_phi,dphi2_u_phi,nf,"set xla\"phi\""); //} //////////// 3RD DERIVATIVES //// double dT3_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT3_Ug ( U->P , U->T0, V ); } double dT2mu_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT2mu_Ug ( U->P , U->T0, V ); } double dT2phi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT2phi_Ug ( U->P , U->T0, V ); } double dTmu2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTmu2_Ug ( U->P , U->T0, V ); } double dmu2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dmu2_Ug ( U->P , U->T0, V ); } double dTmuphi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTmuphi_Ug ( U->P , U->T0, V ); } double dmuphi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dmuphi_Ug ( U->P , U->T0, V ); } double dTphi2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTphi2_Ug ( U->P , U->T0, V ); } double dphi2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dphi2_Ug ( U->P , U->T0, V ); } double dmu3_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu3_Ug ( U->P , U->T0, V ); } double dmu2phi_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu2phi_Ug ( U->P , U->T0, V ); } double dmuphi2_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmuphi2_Ug ( U->P , U->T0, V ); } double dphi2_u_mu ( double mu ) {Var_set_Tmuphi ( V, T_, mu , phi_); return U->dphi2_Ug ( U->P , U->T0, V ); } double dphi3_u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->dphi3_Ug ( U->P , U->T0, V ); } //if ( false ){ sprintf ( nf , "dT3_%s_T", pref ); TD_T(dT2_u_T, dT3_u_T,nf,"set xla\"T\""); sprintf ( nf , "dT2mu_%s_T", pref ); TD_T(dTmu_u_T, dT2mu_u_T,nf,"set xla\"T\""); sprintf ( nf , "dT2phi_%s_T", pref ); TD_T(dTphi_u_T, dT2phi_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTmu2_%s_T", pref ); TD_T(dmu2_u_T, dTmu2_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTmuphi_%s_T", pref ); TD_T(dmuphi_u_T, dTmuphi_u_T,nf,"set xla\"T\""); sprintf ( nf , "dTphi2_%s_T", pref ); TD_T(dphi2_u_T, dTphi2_u_T,nf,"set xla\"T\""); sprintf ( nf , "dmu3_%s_mu", pref ); TD_mu (dmu2_u_mu,dmu3_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmu2phi_%s_mu", pref ); TD_mu (dmuphi_u_mu,dmu2phi_u_mu ,nf,"set xla\"mu\""); sprintf ( nf , "dmuphi2_%s_mu", pref ); TD_mu (dphi2_u_mu,dmuphi2_u_mu ,nf,"set xla\"mu\""); // } sprintf ( nf , "dphi3_%s_phi", pref ); TD_phi(dphi2_u_phi,dphi3_u_phi,nf,"set xla\"phi\""); /* double dphi2_u ( double phi ) */ /* { */ /* Var_set_Tmuphi( V, T_, mu_, phi ); */ /* double dphi_u( double phi ) */ /* { */ /* Var_set_Tmuphi( V, T_, mu_, phi); */ /* double u ( double phi ) */ /* { */ /* Var_set_Tmuphi( V, T_, mu_, phi); */ /* return upot_pow_phi_eq_phibar( U->P, U->T0, V ); */ /* } */ /* return deriv ( u, phi, 0.001 ) ; */ /* } */ /* return deriv( dphi_u, phi, 0.001 ) ; */ /* } */ /* sprintf( nf, "all-num__dphi3_%s_phi", pref ) ; TD_phi( dphi2_u, dphi3_u_phi,nf, "set xla\"phi\"" ); */ } Var_free ( V ); }
AlexandreBiguet/NJLlikeModels
legacy/programs/njl-1/Upot/test_der.c
C
gpl-3.0
22,920
[ 30522, 1001, 2421, 1000, 1012, 1012, 1013, 5622, 2497, 1013, 2950, 1012, 1044, 1000, 1001, 2421, 1000, 1012, 1012, 1013, 5622, 2497, 1013, 21183, 12146, 1012, 1044, 1000, 1001, 2421, 1000, 1012, 1012, 1013, 5622, 2497, 1013, 2777, 7295, 2...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System.Threading.Tasks; namespace JumbleRef.Core.Services { public interface IUserInteractionService { Task<string> PromptForText(string title, string message, string initialValue, string acceptText, string cancelText = null); Task<bool> PromptYesNo(string title, string message, string acceptText, string cancelText); } }
garrettpauls/JumbleRef
Source/JumbleRef.Core/Services/IUserInteractionService.cs
C#
gpl-3.0
358
[ 30522, 2478, 2291, 1012, 11689, 2075, 1012, 8518, 1025, 3415, 15327, 18414, 19661, 2890, 2546, 1012, 4563, 1012, 2578, 1063, 2270, 8278, 1045, 20330, 18447, 6906, 22014, 2121, 7903, 2063, 1063, 4708, 1026, 5164, 1028, 25732, 13028, 10288, 2...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.faro.papaya; import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; import org.junit.Assert; import org.junit.Test; import com.faro.papaya.util.LzyMap; import com.faro.papaya.util.ValueFactory; public class LzyMapTest { @Test public void testLoad() { LzyMap<String, AtomicInteger> map = new LzyMap<>(new HashMap<String, AtomicInteger>()); ValueFactory<String, AtomicInteger> aIntFactory = new ValueFactory<String, AtomicInteger>() { @Override public AtomicInteger build(String key) { return new AtomicInteger(0); } }; Assert.assertNull(map.get("abc")); Assert.assertEquals(0, map.get("abc", aIntFactory).intValue()); Assert.assertNotNull(map.get("abc")); } @Test public void testNullNotLoad() { LzyMap<String, AtomicInteger> map = new LzyMap<>(new HashMap<String, AtomicInteger>()); ValueFactory<String, AtomicInteger> aIntFactory = new ValueFactory<String, AtomicInteger>() { @Override public AtomicInteger build(String key) { return new AtomicInteger(0); } }; map.put("abc", null); Assert.assertNull(map.get("abc", aIntFactory)); } }
kevin-faro/papaya
src/test/java/com/faro/papaya/LzyMapTest.java
Java
apache-2.0
1,136
[ 30522, 7427, 4012, 1012, 2521, 2080, 1012, 13008, 3148, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 23325, 2863, 2361, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 16483, 1012, 9593, 1012, 9593, 18447, 26320, 1025, 12324, 8917, 1012, 12022, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var breadcrumbs=[['-1',"",""],['2',"SOLUTION-WIDE PROPERTIES Reference","topic_0000000000000C16.html"],['1984',"Tlece.Recruitment.Models.Company Namespace","topic_0000000000000699.html"],['1998',"CompanyDto Class","topic_00000000000006A8.html"],['2000',"Properties","topic_00000000000006A8_props--.html"],['2002',"AccessibilityString Property","topic_00000000000006D4.html"]];
asiboro/asiboro.github.io
vsdoc/toc--/topic_00000000000006D4.html.js
JavaScript
mit
376
[ 30522, 13075, 7852, 26775, 25438, 2015, 1027, 1031, 1031, 1005, 1011, 1015, 1005, 1010, 1000, 1000, 1010, 1000, 1000, 1033, 1010, 1031, 1005, 1016, 1005, 1010, 1000, 5576, 1011, 2898, 5144, 4431, 1000, 1010, 1000, 8476, 1035, 2199, 8889, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_65) on Mon Feb 03 22:27:04 EST 2014 --> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE> Uses of Class com.puppycrawl.tools.checkstyle.checks.indentation.SlistHandler (checkstyle 5.7 API) </TITLE> <META NAME="date" CONTENT="2014-02-03"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class com.puppycrawl.tools.checkstyle.checks.indentation.SlistHandler (checkstyle 5.7 API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../com/puppycrawl/tools/checkstyle/checks/indentation/SlistHandler.html" title="class in com.puppycrawl.tools.checkstyle.checks.indentation"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../../index.html?com/puppycrawl/tools/checkstyle/checks/indentation//class-useSlistHandler.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="SlistHandler.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <CENTER> <H2> <B>Uses of Class<br>com.puppycrawl.tools.checkstyle.checks.indentation.SlistHandler</B></H2> </CENTER> No usage of com.puppycrawl.tools.checkstyle.checks.indentation.SlistHandler <P> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../com/puppycrawl/tools/checkstyle/checks/indentation/SlistHandler.html" title="class in com.puppycrawl.tools.checkstyle.checks.indentation"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../../index.html?com/puppycrawl/tools/checkstyle/checks/indentation//class-useSlistHandler.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="SlistHandler.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> Copyright &#169; 2001-2014. All Rights Reserved. </BODY> </HTML>
guharoytamajit/checkstyle
site/apidocs/com/puppycrawl/tools/checkstyle/checks/indentation/class-use/SlistHandler.html
HTML
lgpl-2.1
6,414
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_80) on Thu Oct 15 19:28:09 UTC 2015 --> <title>com.amazonaws.services.elasticmapreduce (AWS SDK for Java - 1.10.27)</title> <meta name="date" content="2015-10-15"> <link rel="stylesheet" type="text/css" href="../../../../JavaDoc.css" title="Style"> </head> <body> <h1 class="bar"><a href="../../../../com/amazonaws/services/elasticmapreduce/package-summary.html" target="classFrame">com.amazonaws.services.elasticmapreduce</a></h1> <div class="indexContainer"> <h2 title="Interfaces">Interfaces</h2> <ul title="Interfaces"> <li><a href="AmazonElasticMapReduce.html" title="interface in com.amazonaws.services.elasticmapreduce" target="classFrame"><i>AmazonElasticMapReduce</i></a></li> <li><a href="AmazonElasticMapReduceAsync.html" title="interface in com.amazonaws.services.elasticmapreduce" target="classFrame"><i>AmazonElasticMapReduceAsync</i></a></li> </ul> <h2 title="Classes">Classes</h2> <ul title="Classes"> <li><a href="AbstractAmazonElasticMapReduce.html" title="class in com.amazonaws.services.elasticmapreduce" target="classFrame">AbstractAmazonElasticMapReduce</a></li> <li><a href="AbstractAmazonElasticMapReduceAsync.html" title="class in com.amazonaws.services.elasticmapreduce" target="classFrame">AbstractAmazonElasticMapReduceAsync</a></li> <li><a href="AmazonElasticMapReduceAsyncClient.html" title="class in com.amazonaws.services.elasticmapreduce" target="classFrame">AmazonElasticMapReduceAsyncClient</a></li> <li><a href="AmazonElasticMapReduceClient.html" title="class in com.amazonaws.services.elasticmapreduce" target="classFrame">AmazonElasticMapReduceClient</a></li> </ul> </div> </body> </html>
TomNong/Project2-Intel-Edison
documentation/javadoc/com/amazonaws/services/elasticmapreduce/package-frame.html
HTML
apache-2.0
1,812
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using CsvHelper; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RowScatter.Common { [InputHandler("csv")] public class CsvInputHandler : InputHandler { [Parameter('f', "filename")] public string Filename { get; set; } private Row _current; public override Row Current { get { return _current; } } private TextReader textReader; private CsvReader csvReader; private CsvReader CsvFile { get { if (textReader == null) textReader = File.OpenText(Filename); if (csvReader == null) csvReader = new CsvReader(textReader); csvReader.Configuration.HasHeaderRecord = true; return csvReader; } } public override IEnumerable<string> Headers { get { return CsvFile.FieldHeaders.ToList(); } } public override string Title { get { return "CSV Input Handler"; } } public override void Dispose() { } public override bool MoveNext() { var res = CsvFile.Read(); if (res) { if (CsvFile.IsRecordEmpty()) return false; _current = new Row(); _current.Index = CsvFile.Row - 1; foreach (var header in CsvFile.FieldHeaders) { var value = CsvFile.GetField(header); if (value != null) { _current.Values.Add(header, value); } } } return res; } public override void Reset() { } } }
Trogsoft/rowscatter
RowScatter.Common/CsvInputHandler.cs
C#
mit
2,002
[ 30522, 2478, 20116, 2615, 16001, 4842, 1025, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 2291, 1012, 22834, 1025, 2478, 2291, 1012, 11409, 4160, 1025, 2478, 2291, 1012, 3793, 1025, 2478, 2291, 1012, 11689, 2075, 1012,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_H_ #define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_SERVICE_H_ #include "chrome/common/thumbnail_score.h" #include "components/browser_context_keyed_service/refcounted_browser_context_keyed_service.h" #include "ui/gfx/image/image.h" class GURL; namespace base { class RefCountedMemory; } namespace thumbnails { class ThumbnailingAlgorithm; struct ThumbnailingContext; class ThumbnailService : public RefcountedBrowserContextKeyedService { public: virtual bool SetPageThumbnail(const ThumbnailingContext& context, const gfx::Image& thumbnail) = 0; virtual ThumbnailingAlgorithm* GetThumbnailingAlgorithm() const = 0; virtual bool GetPageThumbnail( const GURL& url, bool prefix_match, scoped_refptr<base::RefCountedMemory>* bytes) = 0; virtual void AddForcedURL(const GURL& url) = 0; virtual bool ShouldAcquirePageThumbnail(const GURL& url) = 0; protected: virtual ~ThumbnailService() {} }; } #endif
qtekfun/htcDesire820Kernel
external/chromium_org/chrome/browser/thumbnails/thumbnail_service.h
C
gpl-2.0
1,250
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2262, 1996, 10381, 21716, 5007, 6048, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 18667, 2094, 1011, 2806, 6105, 2008, 2064, 2022, 1013, 1013, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<iframe src="/files/extensions/api_test/app_process/path1/iframe.html"></iframe>
plxaye/chromium
src/chrome/test/data/extensions/api_test/app_process/path3/container.html
HTML
apache-2.0
81
[ 30522, 1026, 2065, 6444, 2063, 5034, 2278, 1027, 1000, 1013, 6764, 1013, 14305, 1013, 17928, 1035, 3231, 1013, 10439, 1035, 2832, 1013, 4130, 2487, 1013, 2065, 6444, 2063, 1012, 16129, 1000, 1028, 1026, 1013, 2065, 6444, 2063, 1028, 102, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var path = require('path') ScrewTurnPageFile.LATEST = -1 ScrewTurnPageFile.compare = compare ScrewTurnPageFile.prototype.isLatest = isLatest ScrewTurnPageFile.prototype.compareTo = compareTo function ScrewTurnPageFile(filename) { var revision = getRevision(filename) , title = getTitle(filename) this.__defineGetter__('filename', function() { return filename }) this.__defineGetter__('title', function() { return title }) this.__defineGetter__('revision', function() { return revision }) } function getRevision(filename) { var basename = path.basename(filename, '.cs') , offset = basename.indexOf('.') , revision = offset >= 0 ? parseInt(basename.substr(offset + 1), 10) : ScrewTurnPageFile.LATEST return revision } function getTitle(filename) { var basename = path.basename(filename, 'cs') , offset = basename.indexOf('.') , title = offset >= 0 ? basename.substr(0, offset) : basename return title } function isLatest() { return this.revision === ScrewTurnPageFile.LATEST } function compareTo(item) { return compare(this, item) } function compare(a, b) { if(a.title < b.title) return -1 else if(a.title > b.title) return 1 else if(a.revision === ScrewTurnPageFile.LATEST) return 1 else if(b.revision === ScrewTurnPageFile.LATEST) return -1 return a.revision - b.revision } module.exports = ScrewTurnPageFile
Cyberitas/ScrewturnToMediawiki
lib/model/ScrewTurnPageFile.js
JavaScript
mit
1,480
[ 30522, 13075, 4130, 1027, 5478, 1006, 1005, 4130, 1005, 1007, 11224, 22299, 13704, 8873, 2571, 1012, 6745, 1027, 1011, 1015, 11224, 22299, 13704, 8873, 2571, 1012, 12826, 1027, 12826, 11224, 22299, 13704, 8873, 2571, 1012, 8773, 1012, 25340, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php ob_start(); // here we test argument passed if (function_exists("say_hello")) { say_hello(); say_hello("unicornteam"); say_hello("zzu_softboy"); say_hello(3.14); // here will convert into string } $ret = trim(ob_get_clean()); $expect = <<<'EOF' hello, zapi hello, unicornteam hello, zzu_softboy hello, 3.14 EOF; if ($ret != $expect) { echo "got: ".$ret; exit(1); }
qcoreteam/zendapi
tests/lang/func/FunctionDefaultArgTest.phpt
PHP
apache-2.0
396
[ 30522, 1026, 1029, 25718, 27885, 1035, 2707, 1006, 1007, 1025, 1013, 1013, 2182, 2057, 3231, 6685, 2979, 2065, 1006, 3853, 1035, 6526, 1006, 1000, 2360, 1035, 7592, 1000, 1007, 1007, 1063, 2360, 1035, 7592, 1006, 1007, 1025, 2360, 1035, 7...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!-- @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt --> <link rel="import" href="../../bower_components/polymer/polymer.html"> <dom-module id="a-listitem"> <style> :host { display: block; } </style> <template> <div>Hello from <span>{{foo}}</span></div> </template> </dom-module> <script> (function() { Polymer({ is: 'a-listitem', properties: { foo: { type: String, value: 'bar', notify: true } } }); })(); </script>
A-StadLabs/spreadit
app/elements/a-listitem/a-listitem.html
HTML
bsd-3-clause
954
[ 30522, 1026, 999, 1011, 1011, 1030, 6105, 9385, 1006, 1039, 1007, 2325, 1996, 17782, 2622, 6048, 1012, 2035, 2916, 9235, 1012, 2023, 3642, 2089, 2069, 2022, 2109, 2104, 1996, 18667, 2094, 2806, 6105, 2179, 2012, 8299, 1024, 1013, 1013, 17...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * LICENSE: * 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/>. * * * @categories Games/Entertainment, Systems Administration * @package Bright Game Panel * @author warhawk3407 <warhawk3407@gmail.com> @NOSPAM * @copyleft 2013 * @license GNU General Public License version 3.0 (GPLv3) * @version (Release 0) DEVELOPER BETA 8 * @link http://www.bgpanel.net/ */ $page = 'boxgamefile'; $tab = 3; $isSummary = TRUE; ### if (isset($_GET['id']) && is_numeric($_GET['id'])) { $boxid = $_GET['id']; } else { exit('Error: BoxID error.'); } ### $return = 'boxgamefile.php?id='.urlencode($boxid); require("../configuration.php"); require("./include.php"); require_once("../includes/func.ssh2.inc.php"); require_once("../libs/phpseclib/Crypt/AES.php"); require_once("../libs/gameinstaller/gameinstaller.php"); $title = T_('Box Game File Repositories'); if (query_numrows( "SELECT `name` FROM `".DBPREFIX."box` WHERE `boxid` = '".$boxid."'" ) == 0) { exit('Error: BoxID is invalid.'); } $rows = query_fetch_assoc( "SELECT * FROM `".DBPREFIX."box` WHERE `boxid` = '".$boxid."' LIMIT 1" ); $games = mysql_query( "SELECT * FROM `".DBPREFIX."game` ORDER BY `game`" ); $aes = new Crypt_AES(); $aes->setKeyLength(256); $aes->setKey(CRYPT_KEY); // Get SSH2 Object OR ERROR String $ssh = newNetSSH2($rows['ip'], $rows['sshport'], $rows['login'], $aes->decrypt($rows['password'])); if (!is_object($ssh)) { $_SESSION['msg1'] = T_('Connection Error!'); $_SESSION['msg2'] = $ssh; $_SESSION['msg-type'] = 'error'; } $gameInstaller = new GameInstaller( $ssh ); include("./bootstrap/header.php"); /** * Notifications */ include("./bootstrap/notifications.php"); ?> <ul class="nav nav-tabs"> <li><a href="boxsummary.php?id=<?php echo $boxid; ?>"><?php echo T_('Summary'); ?></a></li> <li><a href="boxprofile.php?id=<?php echo $boxid; ?>"><?php echo T_('Profile'); ?></a></li> <li><a href="boxip.php?id=<?php echo $boxid; ?>"><?php echo T_('IP Addresses'); ?></a></li> <li><a href="boxserver.php?id=<?php echo $boxid; ?>"><?php echo T_('Servers'); ?></a></li> <li><a href="boxchart.php?id=<?php echo $boxid; ?>"><?php echo T_('Charts'); ?></a></li> <li class="active"><a href="boxgamefile.php?id=<?php echo $boxid; ?>"><?php echo T_('Game File Repositories'); ?></a></li> <li><a href="boxlog.php?id=<?php echo $boxid; ?>"><?php echo T_('Activity Logs'); ?></a></li> </ul> <div class="well"> <table id="gamefiles" class="zebra-striped"> <thead> <tr> <th><?php echo T_('Game'); ?></th> <th><?php echo T_('Cache Directory'); ?></th> <th><?php echo T_('Disk Usage'); ?></th> <th><?php echo T_('Last Modification'); ?></th> <th><?php echo T_('Status'); ?></th> <th></th> <th></th> </tr> </thead> <tbody> <?php while ($rowsGames = mysql_fetch_assoc($games)) { $repoCacheInfo = $gameInstaller->getCacheInfo( $rowsGames['cachedir'] ); $gameExists = $gameInstaller->gameExists( $rowsGames['game'] ); ?> <tr> <td><?php echo htmlspecialchars($rowsGames['game'], ENT_QUOTES); ?></td> <td><?php echo htmlspecialchars($rowsGames['cachedir'], ENT_QUOTES); ?></td> <td><?php if ($repoCacheInfo != FALSE) { echo htmlspecialchars($repoCacheInfo['size'], ENT_QUOTES); } else { echo T_('None'); } ?></td> <td><?php if ($repoCacheInfo != FALSE) { echo @date('l | F j, Y | H:i', $repoCacheInfo['mtime']); } else { echo T_('Never'); } ?></td> <td><?php if ($gameExists == FALSE) { echo "<span class=\"label\">".T_('Game Not Supported')."</span>"; } else if ($repoCacheInfo == FALSE) { echo "<span class=\"label label-warning\">".T_('No Cache')."</span>"; } else if ($repoCacheInfo['status'] == 'Ready') { echo "<span class=\"label label-success\">Ready</span>"; } else if ($repoCacheInfo['status'] == 'Aborted') { echo "<span class=\"label label-important\">Aborted</span>"; } else { echo "<span class=\"label label-info\">".htmlspecialchars($repoCacheInfo['status'], ENT_QUOTES)."</span>"; } ?></td> <td> <!-- Actions --> <div style="text-align: center;"> <?php if ($gameExists) { if ( ($repoCacheInfo == FALSE) || ($repoCacheInfo['status'] == 'Aborted') ) { // No repo OR repo not ready ?> <a class="btn btn-small" href="#" onclick="doRepoAction('<?php echo $boxid; ?>', '<?php echo $rowsGames['gameid']; ?>', 'makeRepo', '<?php echo T_('create a new cache repository for'); ?>', '<?php echo htmlspecialchars($rowsGames['game'], ENT_QUOTES); ?>')"> <i class="icon-download-alt <?php echo formatIcon(); ?>"></i> </a> <?php } if ( ($repoCacheInfo != FALSE) && ($repoCacheInfo['status'] != 'Aborted') && ($repoCacheInfo['status'] != 'Ready') ) { // Operation in progress ?> <a class="btn btn-small" href="#" onclick="doRepoAction('<?php echo $boxid; ?>', '<?php echo $rowsGames['gameid']; ?>', 'abortOperation', '<?php echo T_('abort current operation for repository'); ?>', '<?php echo htmlspecialchars($rowsGames['game'], ENT_QUOTES); ?>')"> <i class="icon-stop <?php echo formatIcon(); ?>"></i> </a> <?php } if ( $repoCacheInfo['status'] == 'Ready') { // Cache Ready ?> <a class="btn btn-small" href="#" onclick="doRepoAction('<?php echo $boxid; ?>', '<?php echo $rowsGames['gameid']; ?>', 'makeRepo', '<?php echo T_('refresh repository contents for'); ?>', '<?php echo htmlspecialchars($rowsGames['game'], ENT_QUOTES); ?>')"> <i class="icon-repeat <?php echo formatIcon(); ?>"></i> </a> <?php } } ?> </div> </td> <td> <!-- Drop Action --> <div style="text-align: center;"> <?php if ($gameExists) { if ( ($repoCacheInfo != FALSE) && ( ($repoCacheInfo['status'] == 'Aborted') || ($repoCacheInfo['status'] == 'Ready') ) ) { // Repo exists AND no operation in progress ?> <a class="btn btn-small" href="#" onclick="doRepoAction('<?php echo $boxid; ?>', '<?php echo $rowsGames['gameid']; ?>', 'deleteRepo', '<?php echo T_('remove cache repository for'); ?>', '<?php echo htmlspecialchars($rowsGames['game'], ENT_QUOTES); ?>')"> <i class="icon-trash <?php echo formatIcon(); ?>"></i> </a> <?php } } ?> </div> </td> </tr> <?php } ?> </tbody> </table> <?php if (mysql_num_rows($games) != 0) { ?> <script type="text/javascript"> $(document).ready(function() { $("#gamefiles").tablesorter({ headers: { 5: { sorter: false }, 6: { sorter: false } }, sortList: [[0,0]] }); }); <!-- --> function doRepoAction(boxid, gameid, task, action, game) { if (confirm('<?php echo T_('Are you sure you want to'); ?> '+action+' '+game+' ?')) { window.location='boxprocess.php?boxid='+boxid+'&gameid='+gameid+'&task='+task; } } </script> <?php } unset($games); ?> </div> <?php include("./bootstrap/footer.php"); ?>
kinnngg/knightofsorrow.tk
bgp/admin/boxgamefile.php
PHP
mit
7,705
[ 30522, 1026, 1029, 25718, 1013, 1008, 6819, 2213, 1024, 2275, 7818, 2696, 2497, 21628, 16033, 2361, 1027, 1018, 5670, 9148, 11927, 2232, 1027, 1018, 3730, 2696, 5910, 14399, 1027, 1018, 1024, 1008, 1013, 1013, 1008, 1008, 1008, 6105, 1024, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Salix mucronata Thunb. SPECIES #### Status ACCEPTED #### According to International Plant Names Index #### Published in null #### Original name null ### Remarks null
mdoering/backbone
life/Plantae/Magnoliophyta/Magnoliopsida/Malpighiales/Salicaceae/Salix/Salix mucronata/README.md
Markdown
apache-2.0
172
[ 30522, 1001, 16183, 7646, 14163, 26775, 7856, 30524, 2427, 1001, 1001, 1001, 1001, 3570, 3970, 1001, 1001, 1001, 1001, 2429, 2000, 2248, 3269, 3415, 5950, 1001, 1001, 1001, 1001, 2405, 1999, 19701, 1001, 1001, 1001, 1001, 2434, 2171, 19701,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.tkmdpa.taf.definitions.pantheon; import com.tkmdpa.taf.steps.pantheon.UserAccountSteps; import net.thucydides.core.annotations.Steps; import org.jbehave.core.annotations.Given; import org.jbehave.core.annotations.Then; import org.jbehave.core.annotations.When; public class UserAccountDefinition { @Steps UserAccountSteps userAccountPage; @When("navigate to Pantheon Edit Profile page from User Account page") public void navigateToEditProfile(){ userAccountPage.navigateToEditProfilePage(); } @Given("navigate to Pantheon Add New App page from User Account page") @When("navigate to Pantheon Add New App page from User Account page") public void navigateToAddNewApp(){ userAccountPage.navigateToAddNewAppPage(); } @Given("all the applications were deleted") public void allAppsWereDeleted(){ userAccountPage.deleteAllApps(); } @Then("check general page elements for Pantheon User Account page") public void checkGeneralPageElements(){ userAccountPage.checkIfTitleIsCorrect(); userAccountPage.checkGeneralPageElements(); } }
ticketmaster-api/ticketmaster-api.github.io
tests/serenity/src/test/java/com/tkmdpa/taf/definitions/pantheon/UserAccountDefinition.java
Java
mit
1,145
[ 30522, 7427, 4012, 1012, 1056, 22287, 18927, 2050, 1012, 11937, 2546, 1012, 15182, 1012, 24152, 1025, 12324, 4012, 1012, 1056, 22287, 18927, 2050, 1012, 11937, 2546, 1012, 4084, 1012, 24152, 1012, 5310, 6305, 3597, 16671, 13473, 4523, 1025, ...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package gazette import java.sql.Date import gazette.Client.GazetteAction import gazette.IO._ import gazette.Util._ import net.bmjames.opts._ import org.http4s.Uri import monocle.std.list.listIndex import scalaz.{Applicative, Bind} import scalaz.concurrent.Task import scalaz.std.string.parseInt import scalaz.syntax.apply._ object Cli extends TaskApp { val serverInfoParser: Parser[Uri] = { val host = strOption(short('n'), long("host"), metavar("HOST"), help("Host of server - e.g. 127.0.0.1")).map(Uri.IPv4.apply) val port = intOption(short('p'), long("port"), metavar("PORT"), help("Port of server - e.g. 8080")) (host |@| port)(Client.uriWith) } val maxWidth = 15 def menu(date: Date): String = s""" Gazette CLI - ${date} -------------------------- 1. Create new 2. Fetch all 3. Fetch category 4. Due today 5. Due on .. 6. Fetch tag 7. Finish to-do 0. Exit """ val todaysMenu: Task[String] = currentDate.map(menu) val createTodo: GazetteAction[Option[Todo]] = (gprompt("Event name") |@| gprompt("Category") |@| gprompt("Due date (yyyy-MM-dd) (optional)") |@| gprompt("Tags, comma separated")) { case (e, c, d, t) => val ts = Util.parseCsv(t) if (d.isEmpty) Some(Todo(e, c, None, ts)) else parseDate(d).map(date => Todo(e, c, Some(date), ts)) } def mangle(s: String): String = if (s.size > maxWidth) s.take(maxWidth - 2) + ".." else s ++ (" " * (maxWidth - s.size)) def prettyTodo(todo: Todo): String = s"Event: ${todo.event}\n" ++ s"Category: ${todo.category}\n" ++ todo.due.fold("")(d => s"Due: ${todo.due}\n") ++ s"Tags: ${todo.tags.mkString(", ")}" def prettyList(tds: List[Todo]): String = { val bar = " | " val size = tds.size.toString.size + 1 val sizePad = (" " * size) ++ bar def index(i: Int): String = i.toString ++ (" " * (size - i.toString.size)) ++ bar val header = List("Event", "Category", "Due", "Tags").map(s => s ++ (" " * (maxWidth - s.size))).mkString(bar) val sep = "-" * header.size sizePad ++ header ++ "\n" ++ sep ++ "\n" ++ tds.zipWithIndex.map { case (t, i) => (t, i + 1) }.map { case (todo, i) => val dueDate = todo.due.fold(" " * maxWidth)(date => mangle(date.toString)) val tagsString = todo.tags.mkString(",") index(i) ++ List(mangle(todo.event), mangle(todo.category), dueDate, mangle(tagsString)).mkString(bar) }.mkString("\n") } def runAndPrint(action: GazetteAction[List[Todo]]): GazetteAction[Unit] = for { a <- action _ <- gputStrLn(prettyList(a)) } yield () def handleInput(n: Int): GazetteAction[Unit] = n match { case 1 => for { ot <- createTodo _ <- ot.fold(gputStrLn("Unable to create Todo."))(td => Client.insert(td) *> gputStrLn(prettyTodo(td))) } yield () case 2 => runAndPrint(Client.todo) case 3 => for { c <- gprompt("Category") _ <- runAndPrint(Client.category(c)) } yield () case 4 => runAndPrint(Client.today) case 5 => for { d <- gprompt("Date (yyyy-MM-dd)") _ <- parseDate(d).fold(gputStrLn("Invalid date."))(date => runAndPrint(Client.due(date))) } yield () case 6 => for { t <- gprompt("Tag") _ <- runAndPrint(Client.tag(t)) } yield () case 7 => for { tds <- Client.todo _ <- gputStrLn(prettyList(tds)) rn <- gprompt("Number") _ <- parseInt(rn).toOption.fold(gputStrLn("Invalid number.")) { i => val actualIndex = i - 1 listIndex.index(actualIndex).getOption(tds).fold(gputStrLn("Number out of range.")) { todo => Client.finish(todo) } } } yield () case 0 => gputStrLn("Goodbye..") *> Applicative[GazetteAction].point(sys.exit(0)) case _ => gputStrLn("Bad input, try again.") } override def runl(args: List[String]): Task[Unit] = { val opts = info(serverInfoParser <*> helper, progDesc("Connect to Gazette server w/ a CLI."), header("Gazette CLI")) val loop = for { u <- Task.delay(execParser(args.toArray, "gazette.Cli", opts)) s <- todaysMenu _ <- putStrLn(s) i <- prompt("Enter an option") _ <- putStrLn("") _ <- parseInt(i).toOption.fold(putStrLn("Please enter a number."))(i => handleInput(i).run(u)) _ <- putStrLn("") } yield () Bind[Task].forever(loop) } }
adelbertc/gazette
core/src/main/scala/gazette/Cli.scala
Scala
apache-2.0
4,678
[ 30522, 7427, 11391, 12324, 9262, 1012, 29296, 1012, 3058, 12324, 11391, 1012, 7396, 1012, 11391, 18908, 3258, 12324, 11391, 1012, 22834, 1012, 1035, 12324, 11391, 1012, 21183, 4014, 1012, 1035, 12324, 5658, 1012, 1038, 2213, 3900, 7834, 1012,...
[ 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...
[ 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...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...