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
""" ``editquality generate_make -h`` :: Code-generate Makefile from template and configuration :Usage: generate_make -h | --help generate_make [--config=<path>] [--main=<filename>] [--output=<path>] [--templates=<path>] [--debug] :Options: --config=<path> Directory to search for configuration files [default: config/] --main=<filename> Override to use a main template other than the default [default: Makefile.j2] --output=<path> Where to write the Makefile output. [default: <stdout>] --templates=<path> Directory to search for input templates. [default: templates/] --debug Print debug logging """ # TODO: # * make API calls to learn things # * ores/config has dict merge # * survey dependency solvers # https://github.com/ninja-build/ninja/wiki/List-of-generators-producing-ninja-build-files # ** Still considering: scons, doit, drake, ninja, meson # ** Don't like so far: waf # * Where can we store information about samples? # Original population rates; how we've distorted them. import logging import os.path import sys import docopt from .. import config from ..codegen import generate logger = logging.getLogger(__name__) def main(argv=None): args = docopt.docopt(__doc__, argv=argv) logging.basicConfig( level=logging.DEBUG if args['--debug'] else logging.WARNING, format='%(asctime)s %(levelname)s:%(name)s -- %(message)s' ) config_path = args["--config"] output_f = sys.stdout \ if args["--output"] == "<stdout>" \ else open(args["--output"], "w") templates_path = args["--templates"] main_template_path = args["--main"] if not os.path.isabs(main_template_path): # Join a filename to the default templates dir. main_template_path = os.path.join(templates_path, main_template_path) with open(main_template_path, "r") as f: main_template = f.read() variables = config.load_config(config_path) output = generate.generate(variables, templates_path, main_template) output_f.write(output)
wiki-ai/editquality
editquality/utilities/generate_make.py
Python
mit
2,362
[ 30522, 1000, 1000, 1000, 1036, 1036, 10086, 26426, 3012, 9699, 1035, 2191, 1011, 1044, 1036, 1036, 1024, 1024, 3642, 1011, 9699, 2191, 8873, 2571, 2013, 23561, 1998, 9563, 1024, 8192, 1024, 9699, 1035, 2191, 1011, 1044, 1064, 1011, 1011, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 django.template import Library, Node, resolve_variable, TemplateSyntaxError from django.core.urlresolvers import reverse register = Library() @register.simple_tag def active(request, pattern): import re if re.search(pattern, request.get_full_path()): return 'active' return ''
Kami/munin_exchange
munin_exchange/apps/core/templatetags/navclass.py
Python
bsd-3-clause
307
[ 30522, 2013, 6520, 23422, 1012, 23561, 12324, 3075, 1010, 13045, 1010, 10663, 1035, 8023, 1010, 23561, 6508, 12380, 2595, 2121, 29165, 2013, 6520, 23422, 1012, 4563, 1012, 24471, 20974, 2229, 4747, 14028, 12324, 7901, 4236, 1027, 3075, 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...
<!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_71) on Sun Jan 11 17:03:54 EET 2015 --> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <title>com.github.tilastokeskus.matertis.core.command (Matertis 1.0-SNAPSHOT Test API)</title> <meta name="date" content="2015-01-11"> <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> </head> <body> <h1 class="bar"><a href="../../../../../../com/github/tilastokeskus/matertis/core/command/package-summary.html" target="classFrame">com.github.tilastokeskus.matertis.core.command</a></h1> <div class="indexContainer"> <h2 title="Classes">Classes</h2> <ul title="Classes"> <li><a href="DropCommandTest.html" title="class in com.github.tilastokeskus.matertis.core.command" target="classFrame">DropCommandTest</a></li> <li><a href="MoveCommandTest.html" title="class in com.github.tilastokeskus.matertis.core.command" target="classFrame">MoveCommandTest</a></li> <li><a href="PauseCommandTest.html" title="class in com.github.tilastokeskus.matertis.core.command" target="classFrame">PauseCommandTest</a></li> </ul> </div> </body> </html>
tilastokeskus/Matertis
dist/site/testapidocs/com/github/tilastokeskus/matertis/core/command/package-frame.html
HTML
mit
1,272
[ 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...
<h3 align="center"> <a href="https://github.com/umpirsky"> <img src="https://farm2.staticflickr.com/1709/25098526884_ae4d50465f_o_d.png" /> </a> </h3> <p align="center"> <a href="https://github.com/umpirsky/Symfony-Upgrade-Fixer">symfony upgrade fixer</a> &bull; <a href="https://github.com/umpirsky/Twig-Gettext-Extractor">twig gettext extractor</a> &bull; <a href="https://github.com/umpirsky/wisdom">wisdom</a> &bull; <a href="https://github.com/umpirsky/centipede">centipede</a> &bull; <a href="https://github.com/umpirsky/PermissionsHandler">permissions handler</a> &bull; <a href="https://github.com/umpirsky/Extraload">extraload</a> &bull; <b>gravatar</b> &bull; <a href="https://github.com/umpirsky/locurro">locurro</a> &bull; <a href="https://github.com/umpirsky/country-list">country list</a> &bull; <a href="https://github.com/umpirsky/Transliterator">transliterator</a> </p> # Gravatar [![Build Status](https://travis-ci.org/umpirsky/Gravatar.svg)](https://travis-ci.org/umpirsky/Gravatar) Lightweight Gravatar library. ## Examples ### Basic ```php <?php print((new Gravatar\Gravatar())->getUrl('umpirsky@gmail.com')); // Outputs: // http://www.gravatar.com/avatar/71a0abb69d81544d7cb390e186d5d123 ``` ![gravatar](http://www.gravatar.com/avatar/71a0abb69d81544d7cb390e186d5d123) ### Custom options ```php <?php $gravatar = new Gravatar\Gravatar(array( 'size' => 120, 'rating' => 'x', )); print($gravatar)->getUrl('umpirsky@gmail.com')); // Outputs: // http://www.gravatar.com/avatar/71a0abb69d81544d7cb390e186d5d123?size=120&rating=x ``` ![gravatar](http://www.gravatar.com/avatar/71a0abb69d81544d7cb390e186d5d123?size=120&rating=x) See more [examples](https://github.com/umpirsky/Gravatar/tree/master/examples).
umpirsky/Gravatar
README.md
Markdown
mit
1,784
[ 30522, 1026, 1044, 2509, 25705, 1027, 1000, 2415, 1000, 1028, 1026, 1037, 17850, 12879, 1027, 1000, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 8529, 8197, 27472, 2100, 1000, 1028, 1026, 10047, 2290, 5034, 2278, 1027, 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...
using System; using System.IO; using System.Net; namespace FluentMnistDemo { internal class DataSets { private const string urlMnist = @"http://yann.lecun.com/exdb/mnist/"; private const string mnistFolder = @"..\Mnist\"; private const string trainingLabelFile = "train-labels-idx1-ubyte.gz"; private const string trainingImageFile = "train-images-idx3-ubyte.gz"; private const string testingLabelFile = "t10k-labels-idx1-ubyte.gz"; private const string testingImageFile = "t10k-images-idx3-ubyte.gz"; public DataSet Train { get; set; } public DataSet Validation { get; set; } public DataSet Test { get; set; } private void DownloadFile(string urlFile, string destFilepath) { if (!File.Exists(destFilepath)) { try { using (var client = new WebClient()) { client.DownloadFile(urlFile, destFilepath); } } catch (Exception e) { Console.WriteLine("Failed downloading " + urlFile); Console.WriteLine(e.Message); } } } public bool Load(int validationSize = 1000) { Directory.CreateDirectory(mnistFolder); var trainingLabelFilePath = Path.Combine(mnistFolder, trainingLabelFile); var trainingImageFilePath = Path.Combine(mnistFolder, trainingImageFile); var testingLabelFilePath = Path.Combine(mnistFolder, testingLabelFile); var testingImageFilePath = Path.Combine(mnistFolder, testingImageFile); // Download Mnist files if needed Console.WriteLine("Downloading Mnist training files..."); DownloadFile(urlMnist + trainingLabelFile, trainingLabelFilePath); DownloadFile(urlMnist + trainingImageFile, trainingImageFilePath); Console.WriteLine("Downloading Mnist testing files..."); DownloadFile(urlMnist + testingLabelFile, testingLabelFilePath); DownloadFile(urlMnist + testingImageFile, testingImageFilePath); // Load data Console.WriteLine("Loading the datasets..."); var train_images = MnistReader.Load(trainingLabelFilePath, trainingImageFilePath); var testing_images = MnistReader.Load(testingLabelFilePath, testingImageFilePath); var valiation_images = train_images.GetRange(train_images.Count - validationSize, validationSize); train_images = train_images.GetRange(0, train_images.Count - validationSize); if (train_images.Count == 0 || valiation_images.Count == 0 || testing_images.Count == 0) { Console.WriteLine("Missing Mnist training/testing files."); Console.ReadKey(); return false; } this.Train = new DataSet(train_images); this.Validation = new DataSet(valiation_images); this.Test = new DataSet(testing_images); return true; } } }
cbovar/ConvNetSharp
Examples/FluentMnistDemo/DataSets.cs
C#
mit
3,189
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 22834, 1025, 2478, 2291, 1012, 5658, 1025, 3415, 15327, 19376, 2213, 26942, 3207, 5302, 1063, 4722, 2465, 2951, 13462, 2015, 1063, 2797, 9530, 3367, 5164, 24471, 13728, 26942, 1027, 1030, 1000, 829...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 collections import defaultdict import re import sys from stop_words import STOP_WORD_SET from collections import Counter PUNCTUATION_RE = re.compile("[%s]" % re.escape( """!"&()*+,-\.\/:;<=>?\[\\\]^`\{|\}~]+""")) DISCARD_RE = re.compile("^('{|`|git@|@|https?:)") def remove_stop_words(word_seq, stop_words): """Sanitize using intersection and list.remove()""" return [w for w in word_seq if w and w not in stop_words] def remove_punctuation(word_seq): def remove_punc_inner(word): return PUNCTUATION_RE.sub("", word) removed = map(remove_punc_inner, word_seq) # Remove emptry strings return [w for w in removed if w] def filter_discards(word_seq): def discard(word): return not DISCARD_RE.match(word) return filter(discard, word_seq) def count_words_from_seq(word_seq): word_count = defaultdict(int) for word in word_seq: word_count[word] += 1 return word_count def keep_top_n_words(word_counts, n): return dict(Counter(word_counts).most_common(n)) def count_words(text_blob): word_seq = re.split('[=|\s]+', text_blob.lower()) print ' Splitting blob' word_seq = filter_discards(word_seq) print ' Filtering discards' word_seq = remove_punctuation(word_seq) print ' Removing punctuation' word_seq = remove_stop_words(word_seq, STOP_WORD_SET) print ' Removing stop words' word_counts = count_words_from_seq(word_seq) print ' Counting words' top_n = keep_top_n_words(word_counts, 100) print ' Filtering to top 100 words' return top_n if __name__ == '__main__': print count_words(sys.stdin.read())
sprin/heroku-tut
worker/word_count.py
Python
mit
1,663
[ 30522, 2013, 6407, 12324, 12398, 29201, 12324, 2128, 12324, 25353, 2015, 2013, 2644, 1035, 2616, 12324, 2644, 1035, 2773, 1035, 2275, 2013, 6407, 12324, 4675, 26136, 6593, 14505, 1035, 2128, 1027, 2128, 1012, 4012, 22090, 1006, 1000, 1031, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 "rar.hpp" EncodeFileName::EncodeFileName() { Flags=0; FlagBits=0; FlagsPos=0; DestSize=0; } void EncodeFileName::Decode(char *Name,byte *EncName,size_t EncSize,wchar *NameW, size_t MaxDecSize) { size_t EncPos=0,DecPos=0; byte HighByte=EncName[EncPos++]; while (EncPos<EncSize && DecPos<MaxDecSize) { if (FlagBits==0) { Flags=EncName[EncPos++]; FlagBits=8; } switch(Flags>>6) { case 0: NameW[DecPos++]=EncName[EncPos++]; break; case 1: NameW[DecPos++]=EncName[EncPos++]+(HighByte<<8); break; case 2: NameW[DecPos++]=EncName[EncPos]+(EncName[EncPos+1]<<8); EncPos+=2; break; case 3: { int Length=EncName[EncPos++]; if (Length & 0x80) { byte Correction=EncName[EncPos++]; for (Length=(Length&0x7f)+2;Length>0 && DecPos<MaxDecSize;Length--,DecPos++) NameW[DecPos]=((Name[DecPos]+Correction)&0xff)+(HighByte<<8); } else for (Length+=2;Length>0 && DecPos<MaxDecSize;Length--,DecPos++) NameW[DecPos]=Name[DecPos]; } break; } Flags<<=2; FlagBits-=2; } NameW[DecPos<MaxDecSize ? DecPos:MaxDecSize-1]=0; }
Dr-Shadow/desmume
src/windows/File_Extractor/unrar/encname.cpp
C++
gpl-2.0
1,377
[ 30522, 1001, 2421, 1000, 10958, 2099, 1012, 6522, 2361, 1000, 4372, 16044, 8873, 20844, 4168, 1024, 1024, 4372, 16044, 8873, 20844, 4168, 1006, 1007, 1063, 9245, 1027, 1014, 1025, 5210, 16313, 2015, 1027, 1014, 1025, 9245, 6873, 2015, 1027,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
#============================================================= -*-Perl-*- # # Pod::POM::Constants # # DESCRIPTION # Constants used by Pod::POM. # # AUTHOR # Andy Wardley <abw@kfs.org> # Andrew Ford <a.ford@ford-mason.co.uk> # # COPYRIGHT # Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved. # Copyright (C) 2009 Andrew Ford. All Rights Reserved. # # This module is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # REVISION # $Id: Constants.pm 89 2013-05-30 07:41:52Z ford $ # #======================================================================== package Pod::POM::Constants; $Pod::POM::Constants::VERSION = '2.00'; require 5.006; use strict; use warnings; use parent qw( Exporter ); our @SEQUENCE = qw( CMD LPAREN RPAREN FILE LINE CONTENT ); our @STATUS = qw( IGNORE REDUCE REJECT ); our @EXPORT_OK = ( @SEQUENCE, @STATUS ); our %EXPORT_TAGS = ( status => [ @STATUS ], seq => [ @SEQUENCE ], all => [ @STATUS, @SEQUENCE ], ); # sequence items use constant CMD => 0; use constant LPAREN => 1; use constant RPAREN => 2; use constant FILE => 3; use constant LINE => 4; use constant CONTENT => 5; # node add return values use constant IGNORE => 0; use constant REDUCE => 1; use constant REJECT => 2; 1; =head1 NAME Pod::POM::Constants =head1 DESCRIPTION Constants used by Pod::POM. =head1 AUTHOR Andy Wardley E<lt>abw@kfs.orgE<gt> Andrew Ford E<lt>a.ford@ford-mason.co.ukE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved. Copyright (C) 2009 Andrew Ford. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut
mishin/dwimperl-windows
strawberry-perl-5.20.0.1-32bit-portable/perl/site/lib/Pod/POM/Constants.pm
Perl
gpl-2.0
1,772
[ 30522, 1001, 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, 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...
package th.ac.kmitl.ce.ooad.cest.repository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import th.ac.kmitl.ce.ooad.cest.domain.Course; import th.ac.kmitl.ce.ooad.cest.domain.Faculty; import java.util.List; public interface CourseRepository extends CrudRepository<Course, Long>{ Course findFirstByCourseId(String courseId); Course findFirstByCourseName(String courseName); List<Course> findByCourseNameContainingOrCourseIdContainingOrderByCourseNameAsc(String courseName, String courseId); List<Course> findByFacultyOrderByCourseNameAsc(Faculty faculty); List<Course> findByDepartmentOrderByCourseNameAsc(String department); @Query("select c from Course c where c.department = ?2 or c.department = '' and c.faculty = ?1 order by c.courseName") List<Course> findByFacultyAndDepartmentOrNone(Faculty faculty, String department); }
CE-KMITL-OOAD-2015/CE-SMART-TRACKER-DEV
CE Smart Tracker Server/src/main/java/th/ac/kmitl/ce/ooad/cest/repository/CourseRepository.java
Java
apache-2.0
930
[ 30522, 7427, 16215, 1012, 9353, 1012, 2463, 4183, 2140, 1012, 8292, 1012, 1051, 10441, 2094, 1012, 8292, 3367, 1012, 22409, 1025, 12324, 8917, 1012, 3500, 15643, 6198, 1012, 2951, 1012, 16545, 2050, 1012, 22409, 1012, 23032, 1025, 12324, 89...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 https = require('https'); var xml2js = require('xml2js'); var groups = {}; var host, port , auth, origin; groups.getUserGroups = function(req, res) { var options = { rejectUnauthorized: false, hostname: host, port: port, path: "/sap/opu/odata/UI2/PAGE_BUILDER_PERS/PageSets('%2FUI2%2FFiori2LaunchpadHome')/Pages?$expand=PageChipInstances/Chip/ChipBags/ChipProperties", method: 'GET', auth: auth, agent: false }; var parser = new xml2js.Parser(); https.get(options, function(response) { var bodyChunks = []; response.on('data', function(chunk) { bodyChunks.push(chunk); }).on('end', function() { var body = Buffer.concat(bodyChunks); var jsonResult = []; console.log(body.toString()); //convert the XML response to JSON using the xml2js parser.parseString(body, function (err, result) { var groups = result.feed.entry; var currentGroupProperties, currentGroupTiles; if(groups){ for(var i=0; i<groups.length; i++){ currentGroupProperties = groups[i].content[0]['m:properties'][0]; currentGroupTiles = groups[i].link[3]['m:inline'][0].feed[0].entry; var groupJson = { id : currentGroupProperties['d:id'][0], title : currentGroupProperties['d:id'][0]==='/UI2/Fiori2LaunchpadHome'? 'My Home' : currentGroupProperties['d:title'][0], tiles: [] }; //iterate on current group tiles and add them the json var tileProps, chip, curTile; if(currentGroupTiles){ for(var k=0; k<currentGroupTiles.length; k++){ chip = currentGroupTiles[k].link[1]['m:inline'][0]; if(chip !== ""){ //Need to remove tiles that were built from a catalog chip which is no longer exists, they should be removed...(not appear in FLP) tileProps = chip.entry[0].content[0]['m:properties'][0]; //currentGroupTiles[k].content[0]['m:properties'][0]; curTile = { title: tileProps['d:title'][0], configuration: parseConfiguration(tileProps['d:configuration'][0]), url: tileProps['d:url'][0], baseChipId: tileProps['d:baseChipId'][0],//identify the type of tile (e.g."X-SAP-UI2-CHIP:/UI2/DYNAMIC_APPLAUNCHER") id: tileProps['d:id'][0] }; curTile.isDoubleWidth = curTile.configuration.col > 1; curTile.isDoubleHeight = curTile.configuration.row > 1; curTile.icon = '/images/index/main/apps/NewsImage11.png'; curTile.refreshInterval = curTile.configuration['service_refresh_interval']; curTile.realIcon = matchTileIcon(curTile.configuration['display_icon_url']); curTile.navigationTargetUrl = curTile.configuration['navigation_target_url']; curTile.serviceURL = curTile.configuration['service_url']; //Try to build working app url curTile.navUrl = undefined; if(curTile.navigationTargetUrl){ if(curTile.navigationTargetUrl.indexOf('#')===-1){ //it doesn't contain semantic object + action curTile.navUrl = origin + curTile.navigationTargetUrl; }else{ curTile.navUrl = origin + '/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html?' + curTile.navigationTargetUrl; } } curTile.dynamicData = 0; getDynamicData(curTile); curTile.description = curTile.configuration['display_subtitle_text']; curTile.displayInfoText = curTile.configuration['display_info_text']; curTile.displayNumberUnit = curTile.configuration['display_number_unit']; switch(curTile.baseChipId){ case "X-SAP-UI2-CHIP:/UI2/AR_SRVC_NEWS": curTile.type = 0; break; case "X-SAP-UI2-CHIP:/UI2/DYNAMIC_APPLAUNCHER": curTile.type = 1; break; default: //"X-SAP-UI2-CHIP:/UI2/STATIC_APPLAUNCHER": curTile.type = 2; } groupJson.tiles.push(curTile); } } } if(groupJson.tiles.length === 0){ groupJson.tiles.push(getEmptyTile()); } jsonResult.push(groupJson); } } //Needs to be after the parsing completes res.json({ //Set the response back status: 'OK', results:jsonResult }); }) }) }).on('error', function(e) { console.error(e); var jsonResult = jsonResult || []; //work-around for non working ABAP if(jsonResult.length === 0){ for(var i=0; i<6; i++){ var tile, tiles = []; for(var k=0 ; k<i; k++){ tile = { title: "TileTitle_" + k, description: "TileDescription_" + k, configuration: JSON.parse('{"row":"1","col":"1"}'), //Default value for regular tiles url: "TODO tileURL", baseChipId: "TODO", id: "Tile_" + k, isNews: (k%2)?true:false }; tile.isDoubleWidth = tile.configuration.row > 1, tile.isDoubleHeight = tile.configuration.col > 1, tiles.push(tile); } jsonResult.push({ id : "Group_" + i, title : "GroupTitle_" + i, tiles: tiles }); } } res.json({ //Set the response back status: 'OK', results:jsonResult }); }); var parseConfiguration = function(confString){ var res; if(!confString){ res = {"row":"1","col":"1"}; }else{ res = JSON.parse(confString); if(res.tileConfiguration){ res = JSON.parse(res.tileConfiguration); } } return res; }; var getEmptyTile = function(){ return { title: '', configuration: {"row":"1","col":"1"}, url: '', icon: '/images/index/main/apps/plusSign.png', type: -1 }; }; var getDynamicData = function(curTile){ if(curTile.serviceURL){ options.path = curTile.serviceURL; https.get(options, function(response) { var bodyChunks = []; response.on('data', function(chunk) { bodyChunks.push(chunk); }); response.on('end', function() { var body = Buffer.concat(bodyChunks); this.dynamicData = body.toString(); }); }.bind(curTile)) } }; var matchTileIcon = function(fontName){ switch(fontName){ case 'sap-icon://multi-select': return 'glyphicon glyphicon-list'; break; case 'sap-icon://action-settings': return 'glyphicon glyphicon-cog'; break; case 'sap-icon://appointment': return 'glyphicon glyphicon-calendar'; break; case 'sap-icon://travel-itinerary': return 'glyphicon glyphicon-plane'; break; case 'sap-icon://table-chart': return 'glyphicon glyphicon-th'; break; default: return 'glyphicon glyphicon-eye-close'; } } }; module.exports = function(opts) { if(opts) { if(opts.fiori) { var url = opts.fiori.split('//')[1].split(':'); host = url[0]; port = url[1]; origin = opts.fiori; } if(opts.fioriAuth) { auth = opts.fioriAuth; } } return groups; };
micellius/sap-one-experience
services/group.js
JavaScript
mit
9,934
[ 30522, 13075, 16770, 1027, 5478, 1006, 1005, 16770, 1005, 1007, 1025, 13075, 20950, 2475, 22578, 1027, 5478, 1006, 1005, 20950, 2475, 22578, 1005, 1007, 1025, 13075, 2967, 1027, 1063, 1065, 1025, 13075, 3677, 1010, 3417, 1010, 8740, 2705, 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...
# frozen_string_literal: true # Copyright 2015-2017, the Linux Foundation, IDA, and the # CII Best Practices badge contributors # SPDX-License-Identifier: MIT require 'test_helper' class BlankDetectiveTest < ActiveSupport::TestCase setup do # @user = User.new(name: 'Example User', email: 'user@example.com', # password: 'p@$$w0rd', password_confirmation: 'p@$$w0rd') end test 'Blank' do results = BlankDetective.new.analyze( nil, license: '(GPL-2.0 WITH CLASSPATH' ) assert results == {} end end
yannickmoy/cii-best-practices-badge
test/unit/lib/blank_detective_test.rb
Ruby
mit
551
[ 30522, 1001, 7708, 1035, 5164, 1035, 18204, 1024, 2995, 1001, 9385, 2325, 1011, 2418, 1010, 1996, 11603, 3192, 1010, 16096, 1010, 1998, 1996, 1001, 25022, 2072, 2190, 6078, 10780, 16884, 1001, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 1809...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 HelperFunctions def log_in email = 'test@sumofus.org' password = 'password' User.create! email: email, password: password visit '/users/sign_in' fill_in 'user_email', with: email fill_in 'user_password', with: password click_button 'Log in' end def create_tags Tag.create!([ { tag_name: '*Welcome_Sequence', actionkit_uri: '/rest/v1/tag/1000/' }, { tag_name: '#Animal_Rights', actionkit_uri: '/rest/v1/tag/944/' }, { tag_name: '#Net_Neutrality', actionkit_uri: '/rest/v1/tag/1078/' }, { tag_name: '*FYI_and_VIP', actionkit_uri: '/rest/v1/tag/980/' }, { tag_name: '@Germany', actionkit_uri: '/rest/v1/tag/1036/' }, { tag_name: '@NewZealand', actionkit_uri: '/rest/v1/tag/1140/' }, { tag_name: '@France', actionkit_uri: '/rest/v1/tag/1128/' }, { tag_name: '#Sexism', actionkit_uri: '/rest/v1/tag/1208/' }, { tag_name: '#Disability_Rights', actionkit_uri: '/rest/v1/tag/1040/' }, { tag_name: '@Austria', actionkit_uri: '/rest/v1/tag/1042/' } ]) end def error_messages_from_response(response) JSON.parse(response.body)['errors'].inject([]) { |memo, error| memo << error['message'] }.uniq end end
SumOfUs/Champaign
spec/support/helper_functions.rb
Ruby
mit
1,244
[ 30522, 1001, 7708, 1035, 5164, 1035, 18204, 1024, 2995, 11336, 2393, 2121, 11263, 27989, 2015, 13366, 8833, 1035, 1999, 10373, 1027, 1005, 3231, 1030, 28193, 25608, 1012, 8917, 1005, 20786, 1027, 1005, 20786, 1005, 5310, 1012, 3443, 999, 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...
/* flexNES - Flexible NAT Emulation Software Copyright (C) 2008, Jeremy Beker <gothmog@confusticate.com> 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FN_STRUCTURES_H // one-time include #define FN_STRUCTURES_H #include <string> typedef struct _udp_packet_tuple { uint32_t src_ip; uint16_t src_port; uint32_t dest_ip; uint16_t dest_port; } udp_packet_tuple; typedef struct _tcp_packet_tuple { uint32_t src_ip; uint16_t src_port; uint32_t dest_ip; uint16_t dest_port; } tcp_packet_tuple; typedef struct _icmp_packet_tuple { uint32_t src_ip; uint32_t dest_ip; } icmp_packet_tuple; typedef struct _nat_map_entry { // char entry_id[64]; std::string in_interface; std::string out_interface; uint16_t protocol; time_t activity; union { udp_packet_tuple inside_udp; tcp_packet_tuple inside_tcp; icmp_packet_tuple inside_icmp; }; union { udp_packet_tuple outside_udp; tcp_packet_tuple outside_tcp; icmp_packet_tuple outside_icmp; }; // expiration timestamp } nat_map_entry; #endif
tst2005googlecode/flexnes
src/structures.h
C
gpl-2.0
1,677
[ 30522, 1013, 1008, 23951, 5267, 1011, 12379, 14085, 7861, 9513, 4007, 9385, 1006, 1039, 1007, 2263, 1010, 7441, 2022, 5484, 1026, 25976, 5302, 2290, 1030, 9530, 25608, 22723, 2618, 1012, 4012, 1028, 2023, 2565, 2003, 2489, 4007, 1025, 2017,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 contents of this file are subject to the GNU General Public License * * (GPL) Version 2 or later (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.gnu.org/copyleft/gpl.html * * * * Software distributed under the License is distributed on an "AS IS" basis, * * without warranty of any kind, either expressed or implied. See the License * * for the specific language governing rights and limitations under the * * License. * * * * This file was originally developed as part of the software suite that * * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * * MIT Press 2005. If you modify the contents of this file, please document and * * mark your changes clearly, for the benefit of others. * ********************************************************************************/ package SimulatorsGUI; import javax.swing.*; import java.awt.*; import HackGUI.*; /** * This Panel contains six MemorySegmentComponents: static, local, arg, * this, that, and temp - and provides the split pane feature between * them. */ public class MemorySegmentsComponent extends JPanel { // The spllit pane containing static and local. private JSplitPane segmentsSplitPane1; // The split pane between arg and the previous split pane. private JSplitPane segmentsSplitPane2; // The split pane between this and the previous split pane. private JSplitPane segmentsSplitPane3; // The split pane between that and the previous split pane. private JSplitPane segmentsSplitPane4; // The split pane between temp and the previous split pane. private JSplitPane segmentsSplitPane5; // 'Static' memory segment private MemorySegmentComponent staticSegment; // 'Local' memory segment private MemorySegmentComponent localSegment; // 'Arg' memory segment private MemorySegmentComponent argSegment; // 'This' memory segment private MemorySegmentComponent thisSegment; // 'That' memory segment private MemorySegmentComponent thatSegment; // 'Temp' memory segment private MemorySegmentComponent tempSegment; /** * Constructs a new MemorySegmentsComponent. */ public MemorySegmentsComponent() { // creating the segments and giving them names. staticSegment = new MemorySegmentComponent(); staticSegment.setSegmentName("Static"); localSegment = new MemorySegmentComponent(); localSegment.setSegmentName("Local"); argSegment = new MemorySegmentComponent(); argSegment.setSegmentName("Argument"); thisSegment = new MemorySegmentComponent(); thisSegment.setSegmentName("This"); thatSegment = new MemorySegmentComponent(); thatSegment.setSegmentName("That"); tempSegment = new MemorySegmentComponent(); tempSegment.setSegmentName("Temp"); // creating the split panes. segmentsSplitPane5 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, thatSegment, tempSegment); segmentsSplitPane4 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, thisSegment, segmentsSplitPane5); segmentsSplitPane3 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, argSegment, segmentsSplitPane4); segmentsSplitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, localSegment, segmentsSplitPane3); segmentsSplitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, staticSegment, segmentsSplitPane2); // providing a one touch expandable feature to the split panes. segmentsSplitPane1.setOneTouchExpandable(true); segmentsSplitPane2.setOneTouchExpandable(true); segmentsSplitPane3.setOneTouchExpandable(true); segmentsSplitPane4.setOneTouchExpandable(true); segmentsSplitPane5.setOneTouchExpandable(true); // disabling the automatic border of each one of the first four // split panes. enabling the border of the fifth one. segmentsSplitPane5.setBorder(null); segmentsSplitPane4.setBorder(null); segmentsSplitPane3.setBorder(null); segmentsSplitPane2.setBorder(null); segmentsSplitPane1.setDividerLocation(30 + staticSegment.getTable().getRowHeight() * 5); segmentsSplitPane2.setDividerLocation(30 + localSegment.getTable().getRowHeight() * 5); segmentsSplitPane3.setDividerLocation(30 + argSegment.getTable().getRowHeight() * 5); segmentsSplitPane4.setDividerLocation(30 + thisSegment.getTable().getRowHeight() * 5); segmentsSplitPane5.setDividerLocation(30 + thatSegment.getTable().getRowHeight() * 2); segmentsSplitPane1.setSize(new Dimension(195, 587)); segmentsSplitPane1.setPreferredSize(new Dimension(195, 587)); } /** * Returns the split pane which contains all of the other split peanes. */ public JSplitPane getSplitPane() { return segmentsSplitPane1; } /** * Returns static memory segment. */ public MemorySegmentComponent getStaticSegment() { return staticSegment; } /** * Returns local memory segment. */ public MemorySegmentComponent getLocalSegment() { return localSegment; } /** * Returns arg memory segment. */ public MemorySegmentComponent getArgSegment() { return argSegment; } /** * Returns this memory segment. */ public MemorySegmentComponent getThisSegment() { return thisSegment; } /** * Returns that memory segment. */ public MemorySegmentComponent getThatSegment() { return thatSegment; } /** * Returns temp memory segment. */ public MemorySegmentComponent getTempSegment() { return tempSegment; } }
andyandy1992/MyMOOCs
courses/Other/Nand2Tetris(Partial)/Code/SimulatorsGUIPackageSource/SimulatorsGUI/MemorySegmentsComponent.java
Java
cc0-1.0
6,216
[ 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...
// Type definitions for auth0-lock 10.9 // Project: http://auth0.com // Definitions by: Brian Caruso <https://github.com/carusology> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// <reference types="auth0-js/v7" /> interface Auth0LockAdditionalSignUpFieldOption { value: string; label: string; } type Auth0LockAdditionalSignUpFieldOptionsCallback = (error: Auth0Error, options: Auth0LockAdditionalSignUpFieldOption[]) => void; type Auth0LockAdditionalSignUpFieldOptionsFunction = (callback: Auth0LockAdditionalSignUpFieldOptionsCallback) => void; type Auth0LockAdditionalSignUpFieldPrefillCallback = (error: Auth0Error, prefill: string) => void; type Auth0LockAdditionalSignUpFieldPrefillFunction = (callback: Auth0LockAdditionalSignUpFieldPrefillCallback) => void; interface Auth0LockAdditionalSignUpField { icon?: string; name: string; options?: Auth0LockAdditionalSignUpFieldOption[] | Auth0LockAdditionalSignUpFieldOptionsFunction; placeholder: string; prefill?: string | Auth0LockAdditionalSignUpFieldPrefillFunction; type?: "select" | "text"; validator?: (input: string) => { valid: boolean; hint?: string }; } type Auth0LockAvatarUrlCallback = (error: Auth0Error, url: string) => void; type Auth0LockAvatarDisplayNameCallback = (error: Auth0Error, displayName: string) => void; interface Auth0LockAvatarOptions { url: (email: string, callback: Auth0LockAvatarUrlCallback) => void; displayName: (email: string, callback: Auth0LockAvatarDisplayNameCallback) => void; } interface Auth0LockThemeOptions { logo?: string; primaryColor?: string; } // https://auth0.com/docs/libraries/lock/v10/sending-authentication-parameters interface Auth0LockAuthParamsOptions { access_token?: any; connection_scopes?: any; device?: any; nonce?: any; protocol?: any; request_id?: any; scope?: string; state?: string; } interface Auth0LockAuthOptions { params?: Auth0LockAuthParamsOptions; redirect?: boolean; redirectUrl?: string; responseType?: string; sso?: boolean; } interface Auth0LockPopupOptions { width: number; height: number; left: number; top: number; } interface Auth0LockConstructorOptions { additionalSignUpFields?: Auth0LockAdditionalSignUpField[]; allowedConnections?: string[]; allowForgotPassword?: boolean; allowLogin?: boolean; allowSignUp?: boolean; assetsUrl?: string; auth?: Auth0LockAuthOptions; autoclose?: boolean; autofocus?: boolean; avatar?: Auth0LockAvatarOptions; closable?: boolean; container?: string; defaultADUsernameFromEmailPrefix?: string; defaultDatabaseConnection?: string; defaultEnterpriseConnection?: string; forgotPasswordLink?: string; initialScreen?: "login" | "signUp" | "forgotPassword"; language?: string; languageDictionary?: any; loginAfterSignUp?: boolean; mustAcceptTerms?: boolean; popupOptions?: Auth0LockPopupOptions; prefill?: { email?: string, username?: string}; rememberLastLogin?: boolean; signupLink?: string; socialButtonStyle?: "big" | "small"; theme?: Auth0LockThemeOptions; usernameStyle?: string; } interface Auth0LockFlashMessageOptions { type: "success" | "error"; text: string; } interface Auth0LockShowOptions { allowedConnections?: string[]; allowForgotPassword?: boolean; allowLogin?: boolean; allowSignUp?: boolean; auth?: Auth0LockAuthOptions; initialScreen?: "login" | "signUp" | "forgotPassword"; flashMessage?: Auth0LockFlashMessageOptions; rememberLastLogin?: boolean; } interface Auth0LockStatic { new (clientId: string, domain: string, options?: Auth0LockConstructorOptions): Auth0LockStatic; // deprecated getProfile(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void; getUserInfo(token: string, callback: (error: Auth0Error, profile: Auth0UserProfile) => void): void; show(options?: Auth0LockShowOptions): void; hide(): void; logout(query: any): void; on(event: "show" | "hide", callback: () => void): void; on(event: "unrecoverable_error" | "authorization_error", callback: (error: Auth0Error) => void): void; on(event: "authenticated", callback: (authResult: any) => void): void; on(event: string, callback: (...args: any[]) => void): void; } declare var Auth0Lock: Auth0LockStatic; declare module "auth0-lock" { export default Auth0Lock; }
progre/DefinitelyTyped
auth0-lock/index.d.ts
TypeScript
mit
4,526
[ 30522, 1013, 1013, 2828, 15182, 2005, 8740, 2705, 2692, 1011, 5843, 2184, 1012, 30524, 1013, 2482, 26658, 6483, 1028, 1013, 1013, 15182, 1024, 16770, 1024, 1013, 1013, 21025, 2705, 12083, 1012, 4012, 1013, 5791, 13874, 2094, 1013, 5791, 138...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 {bootstrap, Component, View, NgIf, bind, Inject, Observable, FormBuilder} from 'angular2/angular2'; import {People} from '../people/people'; @Component({ selector: 'main' }) @View({ templateUrl: './components/main/main.html', directives: [People] }) export class Main { constructor() { } }
sofyk/starter-kit-angular2
app/components/main/main.ts
TypeScript
mit
307
[ 30522, 12324, 1063, 6879, 6494, 2361, 1010, 6922, 1010, 3193, 1010, 12835, 10128, 1010, 14187, 1010, 1999, 20614, 1010, 27885, 8043, 12423, 1010, 2433, 8569, 23891, 2099, 1065, 2013, 1005, 16108, 2475, 1013, 16108, 2475, 1005, 1025, 12324, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/waf-regional/WAFRegional_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace WAFRegional { namespace Model { class AWS_WAFREGIONAL_API GetChangeTokenResult { public: GetChangeTokenResult(); GetChangeTokenResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); GetChangeTokenResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * <p>The <code>ChangeToken</code> that you used in the request. Use this value in * a <code>GetChangeTokenStatus</code> request to get the current status of the * request. </p> */ inline const Aws::String& GetChangeToken() const{ return m_changeToken; } /** * <p>The <code>ChangeToken</code> that you used in the request. Use this value in * a <code>GetChangeTokenStatus</code> request to get the current status of the * request. </p> */ inline void SetChangeToken(const Aws::String& value) { m_changeToken = value; } /** * <p>The <code>ChangeToken</code> that you used in the request. Use this value in * a <code>GetChangeTokenStatus</code> request to get the current status of the * request. </p> */ inline void SetChangeToken(Aws::String&& value) { m_changeToken = std::move(value); } /** * <p>The <code>ChangeToken</code> that you used in the request. Use this value in * a <code>GetChangeTokenStatus</code> request to get the current status of the * request. </p> */ inline void SetChangeToken(const char* value) { m_changeToken.assign(value); } /** * <p>The <code>ChangeToken</code> that you used in the request. Use this value in * a <code>GetChangeTokenStatus</code> request to get the current status of the * request. </p> */ inline GetChangeTokenResult& WithChangeToken(const Aws::String& value) { SetChangeToken(value); return *this;} /** * <p>The <code>ChangeToken</code> that you used in the request. Use this value in * a <code>GetChangeTokenStatus</code> request to get the current status of the * request. </p> */ inline GetChangeTokenResult& WithChangeToken(Aws::String&& value) { SetChangeToken(std::move(value)); return *this;} /** * <p>The <code>ChangeToken</code> that you used in the request. Use this value in * a <code>GetChangeTokenStatus</code> request to get the current status of the * request. </p> */ inline GetChangeTokenResult& WithChangeToken(const char* value) { SetChangeToken(value); return *this;} private: Aws::String m_changeToken; }; } // namespace Model } // namespace WAFRegional } // namespace Aws
awslabs/aws-sdk-cpp
aws-cpp-sdk-waf-regional/include/aws/waf-regional/model/GetChangeTokenResult.h
C
apache-2.0
3,027
[ 30522, 1013, 1008, 1008, 1008, 9385, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 30524, 19699, 13910, 19301, 1035, 14338, 1012, 1044, 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...
# Selenium WebDriverを動かすシェルスクリプトの動かし方 <div style="text-align: right;"> 東平洋史 </div> 1. はじめに この資料は Selenium WebDriver を動かすシェルスクリプト koedo.bash の動かし方を記述したものです。このシェルスクリプトは次の手順で、今は亡き高橋信頼さんが日経Linuxで書かれた、小江戸らぐに関する記事を表示させます。 1. Mozilla Firefoxを起動します。 2. Googleのページを表示します。 3. 「小江戸らぐ」をキーに検索します。 4. 日経Linuxの記事へのリンクをクリックします。 5. 広告のページが表示されるので広告をスキップさせます。 6. 表示された小江戸らぐメンバーの集合写真をクリックします。 7. 10秒待ちます。 8. 起動したMozilla Firefoxを終了させます。 2. 準備 1. Selenium Standalone Serverのダウンロード 次のURLからSelenium Standalone Serverを取得します。 <http://www.seleniumhq.org/download/> 3. Selenium Standalone Serverの起動 次のコマンド(1行で記述)を叩いてSelenium Standalone Serverを起動します。 なお、環境変数DISPLAYは表示先の端末に応じて適宜変えてください。 `$ DISPLAY=:0.0 java -jar /home/hirofumi/Selenium/bin/selenium-server-standalone-2.53.0.jar` 次のメッセージが出力されたら起動完了です。 `INFO - Selenium Server is up and running` なお上記は Mozilla Firefox のみしか起動できません。他のブラウザも起動する場合はドライバを指定するため、次のようなオプションをつけます。 1. Google Chrome および Google Chrome on Android `-Dwebdriver.chrome.driver=C:/Selenium/bin/chromedriver_win32/chromedriver.exe`' 2. Internet Explorer `-Dwebdriver.ie.driver=C:/Selenium/bin/IEDriverServer_x64/IEDriverServer.exe` 3. Microsoft Edge `-Dwebdriver.edge.driver=C:/Program\ Files\ \(x86\)/Microsoft\ Web\ Driver/MicrosoftWebDriver.exe` 4. シェルスクリプトの起動 以上で準備完了です。シェルスクリプトを起動しましょう。 1. Mozilla Firefoxを起動する場合 `$ ./koedoUsingPageObject.bash` または `$ ./koedoUsingPageObject.bash firefox` 2. Google Chromeを起動する場合 `$ ./koedoUsingPageObject.bash chrome` 3. Internet Explorerを起動する場合 `$ ./koedoUsingPageObject.bash ie` 4. Microsoft Edgeを起動する場合 `$ ./koedoUsingPageObject.bash edge` 5. Google Chrome on Androidを起動する場合 `$ ./koedoUsingPageObject.bash Android` 5. 参考文献 1. WebDriver Living Document W3C Editor's Draft 28 April 2016 <https://w3c.github.io/webdriver/webdriver-spec.html> 2. Seleniumの薄っすい話4:俺と非公式バインディング <http://qiita.com/hiroshitoda/items/5fa5292ceb1e3e8a9610> 3. OSS支える!コミュニティー訪問 小江戸らぐ - 川越を中心にゆるく活動するLinuxユーザー会 <http://itpro.nikkeibp.co.jp/article/COLUMN/20131003/508665/>
hirokundayon/koedo
Bash/ReadMe.md
Markdown
apache-2.0
3,325
[ 30522, 1001, 7367, 7770, 5007, 4773, 23663, 2099, 30216, 100, 1651, 30184, 30232, 30223, 30259, 30233, 30228, 30258, 30246, 30240, 30197, 100, 1651, 30183, 1863, 1026, 4487, 2615, 2806, 1027, 1000, 3793, 1011, 25705, 1024, 2157, 1025, 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...
using System; using System.Runtime.InteropServices; namespace VulkanCore.Android { /// <summary> /// Provides Android specific extension methods for the <see cref="Device"/> class. /// </summary> public static unsafe class DeviceExtensions { /// <exception cref="VulkanException">Vulkan returns an error code.</exception> public static int GetSwapchainGrallocUsageAndroid(this Device device, Format format, int imageUsage) { int usage; Result result = vkGetSwapchainGrallocUsageANDROID(device)(device, format, imageUsage, &usage); VulkanException.ThrowForInvalidResult(result); return usage; } private delegate Result vkGetSwapchainGrallocUsageANDROIDDelegate(IntPtr device, Format format, int imageUsage, int* grallocUsage); private static vkGetSwapchainGrallocUsageANDROIDDelegate vkGetSwapchainGrallocUsageANDROID(Device device) => device.GetProc<vkGetSwapchainGrallocUsageANDROIDDelegate>(nameof(vkGetSwapchainGrallocUsageANDROID)); } [StructLayout(LayoutKind.Sequential)] public struct NativeBufferAndroid { public StructureType Type; public IntPtr Next; public IntPtr Handle; public int Stride; public int Format; public int Usage; } }
discosultan/VulkanCore
Src/Android/DeviceExtensions.cs
C#
mit
1,329
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 2448, 7292, 1012, 6970, 11923, 2121, 7903, 2229, 1025, 3415, 15327, 24728, 26518, 15305, 2890, 1012, 11924, 1063, 1013, 1013, 1013, 1026, 12654, 1028, 1013, 1013, 1013, 3640, 11924, 3563, 5331, 472...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/** * linux terminal progress bar (no thread safe). * @package progress.h */ #ifndef progress_h #define progress_h #include <stdio.h> typedef struct { char chr; /*tip char*/ char *title; /*tip string*/ int style; /*progress style*/ int max; /*maximum value*/ float offset; char *pro; } progress_t; #define PROGRESS_NUM_STYLE 0 #define PROGRESS_CHR_STYLE 1 #define PROGRESS_BGC_STYLE 2 extern void progress_init(progress_t *, char *, int, int); extern void progress_show(progress_t *, float); extern void progress_destroy(progress_t *); #endif /*ifndef*/
Chaunecy/bigdata-installer
libs/ltpro.h
C
mit
619
[ 30522, 1013, 1008, 1008, 1008, 11603, 5536, 5082, 3347, 1006, 2053, 11689, 3647, 1007, 1012, 1008, 1030, 7427, 5082, 1012, 1044, 1008, 1013, 1001, 2065, 13629, 2546, 5082, 1035, 1044, 1001, 9375, 5082, 1035, 1044, 1001, 2421, 1026, 2358, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 python # Copyright (c) 2017 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. """Valid certificate chain where the target certificate contains a public key with a 512-bit modulus (weak).""" import sys sys.path += ['../..'] import gencerts # Self-signed root certificate. root = gencerts.create_self_signed_root_certificate('Root') # Intermediate intermediate = gencerts.create_intermediate_certificate('Intermediate', root) # Target certificate. target = gencerts.create_end_entity_certificate('Target', intermediate) target.set_key(gencerts.get_or_generate_rsa_key( 512, gencerts.create_key_path(target.name))) chain = [target, intermediate, root] gencerts.write_chain(__doc__, chain, 'chain.pem')
nwjs/chromium.src
net/data/verify_certificate_chain_unittest/target-has-512bit-rsa-key/generate-chains.py
Python
bsd-3-clause
820
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 18750, 1001, 9385, 1006, 1039, 1007, 2418, 1996, 10381, 21716, 5007, 6048, 1012, 2035, 2916, 9235, 1012, 1001, 2224, 1997, 30524, 2011, 1037, 18667, 2094, 1011, 2806, 6105, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
# 从SparkPi图解Spark core ---------------- @玄畅 2015.1.30 spark core是spark的核心库,执行最基础的RDD操作。通过本文,从万年pi入手,逐层分解spark core整个运行过程,一窥其貌。 文字是辅助阅读的面包屑。 先不管那么多名词,一路看下去,理脉络。 ## 万年Pi 这个代码做了以下几件事: 1. 初始化配置`SparkConf` 2. 初始化上下文`SparkContext` 3. 准备数据,从1~N, 分slices段,用ParallelCollectionRDD表示 4. map变换,使用大括号里的函数计算ParallelCollectionRDD中的每一个数据项,用MappedRDD表示 5. reduce,合并数据,计算函数为: `_ + _` ``` object SparkPi { def main(args: Array[String]) { val conf = new SparkConf().setMaster("local").setAppName("Spark Pi") val spark = new SparkContext(conf) val slices = if (args.length > 0) args(0).toInt else 2 val n = math.min(100000L * slices, Int.MaxValue).toInt // avoid overflow val count = spark.parallelize(1 until n, slices).map { i => val x = random * 2 - 1 val y = random * 2 - 1 if (x*x + y*y < 1) 1 else 0 }.reduce(_ + _) println("Pi is roughly " + 4.0 * count / n) spark.stop() } } ``` ## 启动 & 初始化配置和上下文 1. 入口spark-submit, SparkSubmit会调用`SparkPi`的入口函数`main`() Driver, client, master, worker的启动和交互关系另表, todo) 2. 初始化SparkConf 执行spark-submit时传入的vm参数,spark参数统统由这个对象表示 3. 初始化SparkContext 初始化:UI,statusTracker, progressBar, jars, files, env, heartbeatReceiver, masterUrl, applicationId。。。 关键的是:dagScheduler, taskScheduler, schedulerBackend, blockManager taskScheduler用于提交`TaskSet`即提交RDD schedulerBackend用于接受任务,分配任务给worker去执行 从createTaskScheduler函数下去,取得`spark-submit`的master url,根据master的scheme协议类型生成不同的`SchedulerBackend`、`TaskScheduler`, master的类型有:local、local-cluster、simr、spark、mesos、zk、yarn-standalone、yarn-cluster。 相应的种类:LocalBackend, SparkDeploySchedulerBackend, SimrSchedulerBackend, CoarseGrainedSchedulerBackend, CoarseMesosSchedulerBackend, MesosSchedulerBackend ![init](img/spark_core_init.jpg) ## 提交job 上文,初始化完了sparkContext, 执行到下面的代码: ``` val count = spark.parallelize(1 until n, slices).map { i => val x = random * 2 - 1 val y = random * 2 - 1 if (x*x + y*y < 1) 1 else 0 }.reduce(_ + _) ``` 1. 步骤分解。这行代码,分为三步: 1. `spark.parallelize`生成`ParallelCollectionRDD` 2. 然后, `ParallelCollectionRDD`执行`map()`函数,生成`MapPartitionsRDD` 3. `MapPartitionsRDD`执行`reduce`函数,生成最终结果 上面可以看出RDD之间是有依赖关系的,这个依赖关系怎么形成的? 2. 依赖关系 `new MapPartitionsRDD[U, T](this, (context, pid, iter) => iter.map(cleanF))`,这个`this`指向`ParallelCollectionRDD`, 这俩RDD都继承自`RDD`, `RDD`的一个构造函数`def this(@transient oneParent: RDD[_]) = this(oneParent.context , List(new OneToOneDependency(oneParent)))`会定义当前RDD的上一个RDD是谁,并用一个`deps: Seq[Dependency[_]]`对象表示所有的依赖对象。 如此,每个RDD都会记录与上一个RDD的关系,是一对一,还是一对多. 3. 计算函数 计算函数是用户定义的`map()`中的代码块。 一个RDD包含多个分区partition,这个计算函数会应用到所有的partition中的所有数据。这就隐含着两个遍历操作:遍历RDD的partition;遍历partiton中的数据 如此,整个RDD经过算子的运算,原始数据变成了想要的数据,即map过程,就像数学中的函数概念, `f(x) = 3x + 100`。但是,这里仅仅是表示这种计算关系,并没有马上计算出来结果。真正执行计算的时机由action函数触发,如下面的`reduce` 4. 合并 上面这些准备数据,演算过程,都是虚的,真正触发计算过程的时机在此。 既然是分布式计算,就需要把数据和算子分布到多台服务器上。 这里首先把map、reduce的用户定义的函数序列化,传输到不同的机器上。而partition实际的分片数据是可以根据`Partition`的信息定位到数据的位置的。 `reduce(_ + _)`函数会把整个计算过程封装成一个`Job` ![init](img/spark_core_submitjob.jpg) ## DAGScheduler构建final stage `DAGScheduler`对象在`SparkContext`初始化的时候会实例化,这里开用了。 这里会对job做一些整理变换,以便符合适合下一阶段要求。在job中rdd的partition并不包含实际数据,只是partition的序号。 1. 提交Job `eventProcessActor ! JobSubmitted` 发射消息 这里开始使用akka, `eventProcessActor`使用`DAGSchedulerEventProcessActor` 来处理收到的消息。 actor`DAGSchedulerActorSupervisor`收到提交的`JobSubmitted`。dag会执行`handleJobSubmitted`来处理提交的job。 2. 处理提交的job,生成finalStage 这里可以看到提交的是finalRDD,表示这是老末了,通过这位老末可以向上遍历找到所有的父RDD及其包含的相应的父partition。 `handleJobSubmitted`就是根据RDD的依赖关系向上遍历父RDD,关系树中的RDD都封装成stage,结果就是finalRDD变成finalStage。 这里遍历依赖关系使用先进后出的栈。先把自己finalRDD送进去,pop出来,找到所有的`dependencies`, 遍历依赖, 把`ShuffleDependency`类型的依赖封装成一个`Stage`对象添加到返回的列表中,非`ShuffleDependency`继续取出`dependencies`入栈。 每个`Stage`对象中都包含当前job的jobId。 这样,父依赖RDD和当前的finalRDD都转换成了`Stage`对象,即:finalStage包含了父stages ![](img/spark_core_dag_finalstage.jpg) ## DAGScheduler提交stage(submitStage) 上一步对finalRDD进行了大清洗,把RDD及其父RDD洗白成`Stage`. 1. 检查block miss的stage 检查每个stage对应的存储块是否存在, 即:每个rdd的partition id封装成一个`BlockId`, 向master的`BlockManagerMasterActor`发消息(`GetLocationsMultipleBlockIds`),收到消息后,根据本地的`blockLocations`取出`BlockManagerId`, 如果没有则返回空。 这样确保所有的stage对应的block都是存在的,然后把stage存入`waitingStages` 不得不说说`BlockManagerId`,这货有`executorId, host, port`,即它已经许身给了某个worker,有身份和地址的对象。 2. 正式提交stage 遍历`waitingStages`的拷贝,`submitStage`提交每一个stage, 这样没有miss的stage,直接进入下一步:`submitMissingTasks` 提交时,把`Stage`对象中每个分区和rdd序列化,把stage.rdd封装成`Broadcast`对象,默认为`TorrentBroadcast`。stage(RDD)的partition封装成task, 有两种类型的task:ResultTask、ShuffleMapTask。而`TaskSet`是tasks的持有者,`taskScheduler.submitTasks(...)`实际执行提交任务。 `taskScheduler`是在sparkContext初始化时生成的任务调度器。 ## 任务调度器提交任务 入口:`TaskSchedulerImpl#submitTasks` 书接上文,DAG把finalRDD最后封装成`Task`对象,调用sparkContext里的`taskScheduler`。 `taskScheduler`中,加一个`maxTaskFailures`最大任务失败数,把TaskSet封装成`TaskSetManager`对象。提交到`Pool`中。这里的`Pool`即是`SparkContext`初始化时构建TaskSchedulerImpl时初始化的池化对象,把任务提交到`ConcurrentLinkedQueue`。 spark任务躺在linkedqueue中,`backend.reviveOffers()`触发下一步任务的执行。backend就是在初始化时根据不同的master类型确定的不同backend类型。 *模块之间通过队列解耦,数据在不同的模块中由不同的对象来封装和表达。* 在backend(CoarseGrainedSchedulerBackend)的reviveOffers中,`Driver`发送消息`ReviveOffers`。通过发消息的方式,任务的执行就不是顺序执行了,而是乱序并行执行。driverActor收到消息,从TaskSchedulerImpl中取出随机shuffle的task,发射task,把任务发送到各个`Executor(worker)`上执行,对象在网络上传播就需要序列化对象。发送消息对象`LaunchTask`到具体的任务执行者`executorActor`。 ![](img/spark_core_taskscheduler.jpg) ## Executor任务执行1 `CoarseGrainedExecutorBackend`收到`LaunchTask`消息,首先要做的就是反序列化task描述对象`TaskDescription`。下面的事情就是放到线程池中执行任务。 实例`TaskRunner`对象,放到队列中,线程池执行。 `TaskRunner`运行时,反序列化task为三个对象:taskFiles,taskJars, taskBytes。`taskFiles`,`taskJars`会加载到时机的文件,jar引入到当前类加载器中。 回顾前面application,`spark-submit`提交时会添加jar,各种参数。application执行时需要用户提交的外部依赖jar, 在每个线程中执行任务时就要把这些外部以来文件和依赖jar加载进来。 `taskBytes`反序列化为`Task`对象,运行的时候,首先实例化任务的上下文`context = new TaskContextImpl(stageId, partitionId, attemptId, runningLocally = false)`, context存入`ThreadLocal`。 现在万事具备,只需要执行Task了(application的代码), Task有两种:`ShuffleMapTask`、`ResultTask`,默认为`ResultTask` ![](img/spark_core_executor_before_run.jpg) ## 执行ResultTask(默认) 反序列化`taskBinary: Broadcast[Array[Byte]]`, 还原出rdd和计算函数。`Broadcast`是DAG中封装的对象。 计算需要两部分内容:计算函数,数据。 计算函数就是application中map函数体的内容。数据就需要从存储系统中获取。 执行函数和取数据的函数: `func(context, rdd.iterator(partition, context))` 而在提交job的代码如下: ``` def runJob[T, U: ClassTag]( rdd: RDD[T], processPartition: Iterator[T] => U, resultHandler: (Int, U) => Unit) { val processFunc = (context: TaskContext, iter: Iterator[T]) => processPartition(iter) runJob[T, U](rdd, processFunc, 0 until rdd.partitions.size, false, resultHandler) } ``` processFunc的签名为:`func: (TaskContext, Iterator[T]) => U,` 跟ResutTask中调用时的一样, 这样前后就对上号了。 1. 取数据 取数据从rdd的`iterator`函数进去,传入当前task所对应的partition和`TaskContext`。 数据的标示:不论数据存储在哪个level上,都需要有个唯一的标示来表示实际存储的数据:`RDDBlockId`, blockId是用rdd id和partiton index组合成的字符串。 数据序列化:不论保存在何种level上,都可以指定序列化,序列化以及压缩能够大幅节省内存,但是消耗CPU,空间与时间的平衡。 数据位置氛围本地和远程,本地存储类别为:memoryStore, tachyonStore, diskStore。远程存储类型为:todo **本地存储:** memoryStore保存在heap中,`LinkedHashMap`持有。根据blockId取出数据,如果没有反序列化则反序列化成`Iterator[Any]`对象。 tachyonStore保存在tackyon分布式内存存储中,根据blockId取出ByteBuffer数据,反序列化成`Iterator[Any]`对象。 diskStore保存在本地磁盘中,根据blockId,从`DiskBlockManager`中拼装文件名、文件路径,返回File对象,通过`RandomAccessFile`随机访问文件对象读取文件的具体内容,返回`ByteBuffer`, 反序列化成`Iterator[Any]`对象。 通过上述三种本地存储,取出`Iterator[Any]`数据对象,强制类型转换成`BlockResult`。如果取出的数据为空,则表示当前这个partition的数据没有分布在当前的`Executor`上,需要从远程读取数据。 **远程存储:** 本地没有当前task对应的partition数据,需要先问下`Master`这个数据分布在哪里`master.getLocations(blockId)`。master收到消息`GetLocations(blockId)`, `BlockManagerMasterActor`根据blockId在`blockLocations:JHashMap[BlockId, mutable.HashSet[BlockManagerId]]`中get出数据块表示对象`Seq[BlockManagerId]` 从master咨询得到partiton的数据块表示`Seq[BlockManagerId]`, 随机混排一下,再把数据块远程下载下来`blockTransferService.fetchBlockSync( loc.host, loc.port, loc.executorId, blockId.toString).nioByteBuffer()` 在fetchBlocks抓取数据块时有两种方式:`NettyBlockTransferService`和`NioBlockTransferService`。netty和spark写的nio。在`SparkEnv#create`中,用户传入的spark参数`spark.shuffle.blockTransferService`(默认**netty**)实例化数据块传输对象`NettyBlockTransferService`或`NioBlockTransferService`。 以`NioBlockTransferService#fetchBlocks`为例,`SparkEnv`在初始化的时候确定了使用哪个传输服务(默认`NettyBlockTransferService`), `NettyBlockTransferService`对象在初始化的时候会启动Netty Server来监听网络端口,发送和接收数据。SparkEnv封装`NettyBlockTransferService`到对象`BlockManager`在sparkContext初始化的时候调用blockManager初始化方法`env.blockManager.initialize(applicationId)`。如此:数据块传输的netty server就启动了。 数据块的传输处理handler为`TransportChannelHandler`, 处理过程为netty的pipeline。handler包含三个成员,responseHandler处理响应,requestHandler和client发送请求。 responseHandler通过pipeline的解码,得到ResponseMessage,message有四种类型:ChunkFetchSuccess、ChunkFetchFailure、RpcResponse、RpcFailure,收到数据后,会直接从channel中取到byteBuffer,从`outstandingFetches`取出`ChunkReceivedCallback`,调用onSuccess回调函数,回调函数再调用`BlockFetchingListener`监听器,最终返回partition的完整数据块。 小结:取partition数据,如果数据保存在本地,就从cache, tachyon, disk中读取;如果保存在远程,则通过netty或者NIO读取。最终返回的都是ByteBuffer, 反序列化成响应的对象。 **重新计算** 如果storageLevel不为空,但是存储系统中都没有数据,那么就需要计算出所需的数据。 这时分三种情况:1. cache正在被加载,等待加载后直接返回;2. 从checkpoint读;2. 重新计算。 不同的RDD类型有不同的compute实现。ParallelCollectionPartition是直接返回起iterator数据。这个就是最原始的数据了。 2. 应用计算函数 现在数据有了,计算函数也有了,直接调用计算函数,传入数据,遍历partition,应用函数计算每一项数据。返回计算后的数据 ![](img/spark_core_executor_resulttask.jpg) ## 执行ShuffleMapTask todo ...
junwucs/spark_study
spark_core_getstart_from_pi.markdown
Markdown
apache-2.0
14,942
[ 30522, 1001, 100, 12125, 8197, 100, 100, 12125, 4563, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1030, 100, 100, 2325, 1012, 1015, 1012, 2382, 12125, 4563, 100, 12125, 1916, 100, 1849, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 http-equiv="content-type" content="text/html; charset=windows-1252"> <meta charset="US-ASCII"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>ASN.1 JavaScript decoder</title> <link rel="stylesheet" href="ASN.1%20JavaScript%20decoder_files/index.css" type="text/css"> <script type="text/javascript" src="ASN.1%20JavaScript%20decoder_files/hex.js"></script> <script type="text/javascript" src="ASN.1%20JavaScript%20decoder_files/base64.js"></script> <script type="text/javascript" src="ASN.1%20JavaScript%20decoder_files/oids.js"></script> <script type="text/javascript" src="ASN.1%20JavaScript%20decoder_files/int10.js"></script> <script type="text/javascript" src="ASN.1%20JavaScript%20decoder_files/asn1.js"></script> <script type="text/javascript" src="ASN.1%20JavaScript%20decoder_files/dom.js"></script> <script type="text/javascript" src="ASN.1%20JavaScript%20decoder_files/index.js"></script> </head> <body> <h1>ASN.1 JavaScript decoder</h1> <div style="position: relative; padding-bottom: 1em;"> <div id="dump" style="position: absolute; right: 0px;"></div> <div id="tree"></div> </div> <form> <textarea id="pem" style="width: 100%;" rows="8">MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIAwggHvMIIB WKADAgECAhAvoXazbunwSfREtACZZhlFMA0GCSqGSIb3DQEBBQUAMAwxCjAIBgNVBAMMAWEwHhcN MDgxMDE1MTUwMzQxWhcNMDkxMDE1MTUwMzQxWjAMMQowCAYDVQQDDAFhMIGfMA0GCSqGSIb3DQEB AQUAA4GNADCBiQKBgQCJUwlwhu5hR8X01f+vG0mKPRHsVRjpZNxSEmsmFPdDiD9kylE3ertTDf0g RkpIvWfNJ+eymuxoXF0Qgl5gXAVuSrjupGD6J+VapixJiwLXJHokmDihLs3zfGARz08O3qnO5ofB y0pRxq5isu/bAAcjoByZ1sI/g0iAuotC1UFObwIDAQABo1IwUDAOBgNVHQ8BAf8EBAMCBPAwHQYD VR0OBBYEFEIGXQB4h+04Z3y/n7Nv94+CqPitMB8GA1UdIwQYMBaAFEIGXQB4h+04Z3y/n7Nv94+C qPitMA0GCSqGSIb3DQEBBQUAA4GBAE0G7tAiaacJxvP3fhEj+yP9VDxL0omrRRAEaMXwWaBf/Ggk 1T/u+8/CDAdjuGNCiF6ctooKc8u8KpnZJsGqnpGQ4n6L2KjTtRUDh+hija0eJRBFdirPQe2HAebQ GFnmOk6Mn7KiQfBIsOzXim/bFqaBSbf06bLTQNwFouSO+jwOAAAxggElMIIBIQIBATAgMAwxCjAI BgNVBAMMAWECEC+hdrNu6fBJ9ES0AJlmGUUwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkq hkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA4MTAxNTE1MDM0M1owIwYJKoZIhvcNAQkEMRYEFAAA AAAAAAAAAAAAAAAAAAAAAAAAMA0GCSqGSIb3DQEBAQUABIGAdB7ShyMGf5lVdZtvwKlnYLHMUqJW uBnFk7aQwHAmg3JnH6OcgId2F+xfg6twXm8hhUBkhHPlHGoWa5kQtN9n8rz3NorzvcM/1Xv9+0Ea l7NYSn2Hb0C0DMj2XNIYH2C6CLIHkmy1egzUvzsomZPTkx5nGDWm+8WHCjWb9A6lyrMAAAAAAAA= </textarea> <br> <label title="can be slow with big files"><input id="wantHex" checked="checked" type="checkbox"> with hex dump</label> <input value="decode" onclick="decodeArea();" type="button"> <input value="clear" onclick="clearAll();" type="button"> <input style="display: block;" id="file" type="file"> </form> <div id="help"> <h2>Instructions</h2> <p>This page contains a JavaScript generic ASN.1 parser that can decode any valid ASN.1 DER or BER structure whether Base64-encoded (raw base64, PEM armoring and <span class="tt">begin-base64</span> are recognized) or Hex-encoded. </p> <p>This tool can be used online at the address <a href="http://lapo.it/asn1js/"><span class="tt">http://lapo.it/asn1js/</span></a> or offline, unpacking <a href="http://lapo.it/asn1js/asn1js.zip">the ZIP file</a> in a directory and opening <span class="tt">index.html</span> in a browser</p> <p>On the left of the page will be printed a tree representing the hierarchical structure, on the right side an hex dump will be shown. <br> Hovering on the tree highlights ancestry (the hovered node and all its ancestors get colored) and the position of the hovered node gets highlighted in the hex dump (with header and content in a different colors). <br> Clicking a node in the tree will hide its sub-nodes (collapsed nodes can be noticed because they will become <i>italic</i>).</p> <div class="license"> <h3>Copyright</h3> <div class="ref"><p class="hidden"> ASN.1 JavaScript decoder<br> Copyright © 2008-2014 Lapo Luchini &lt;lapo@lapo.it&gt;<br> <br> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.<br> <br> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. </p></div> <p>ASN.1 JavaScript decoder Copyright © 2008-2014 <a href="http://lapo.it/">Lapo Luchini</a>; released as <a href="http://opensource.org/licenses/isc-license.txt">opensource</a> under the <a href="http://en.wikipedia.org/wiki/ISC_licence">ISC license</a>.</p> </div> <p><span class="tt">OBJECT&nbsp;IDENTIFIER</span> values are recognized using data taken from Peter Gutmann's <a href="http://www.cs.auckland.ac.nz/%7Epgut001/#standards">dumpasn1</a> program.</p> <h3>Links</h3> <ul> <li><a href="http://lapo.it/asn1js/">official website</a></li> <li><a href="http://idf.lapo.it/p/asn1js/">InDefero tracker</a></li> <li><a href="https://github.com/lapo-luchini/asn1js">github mirror</a></li> <li><a href="https://www.ohloh.net/p/asn1js">Ohloh code stats</a></li> </ul> </div> </body></html>
vjeantet/goldap
doc/asn1js/ASN.1 JavaScript decoder.html
HTML
gpl-2.0
5,603
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 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, 3645, 1011, 8732...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 // // ZoneMinder web action file // Copyright (C) 2019 ZoneMinder LLC // // 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // Event scope actions, view permissions only required if ( !canView('Events') ) { ZM\Warning('You do not have permission to view Events.'); return; } if ( isset($_REQUEST['object']) and ( $_REQUEST['object'] == 'filter' ) ) { if ( $action == 'addterm' ) { $_REQUEST['filter'] = addFilterTerm($_REQUEST['filter'], $_REQUEST['line']); } elseif ( $action == 'delterm' ) { $_REQUEST['filter'] = delFilterTerm($_REQUEST['filter'], $_REQUEST['line']); } else if ( canEdit('Events') ) { require_once('includes/Filter.php'); $filter = new ZM\Filter($_REQUEST['Id']); if ( $action == 'delete' ) { if ( !empty($_REQUEST['Id']) ) { if ( $filter->Background() ) { $filter->control('stop'); } $filter->delete(); } else { ZM\Error('No filter id passed when deleting'); } } else if ( ( $action == 'Save' ) or ( $action == 'SaveAs' ) or ( $action == 'execute' ) ) { $sql = ''; $_REQUEST['filter']['Query']['sort_field'] = validStr($_REQUEST['filter']['Query']['sort_field']); $_REQUEST['filter']['Query']['sort_asc'] = validStr($_REQUEST['filter']['Query']['sort_asc']); $_REQUEST['filter']['Query']['limit'] = validInt($_REQUEST['filter']['Query']['limit']); $_REQUEST['filter']['AutoCopy'] = empty($_REQUEST['filter']['AutoCopy']) ? 0 : 1; $_REQUEST['filter']['AutoMove'] = empty($_REQUEST['filter']['AutoMove']) ? 0 : 1; $_REQUEST['filter']['AutoArchive'] = empty($_REQUEST['filter']['AutoArchive']) ? 0 : 1; $_REQUEST['filter']['AutoVideo'] = empty($_REQUEST['filter']['AutoVideo']) ? 0 : 1; $_REQUEST['filter']['AutoUpload'] = empty($_REQUEST['filter']['AutoUpload']) ? 0 : 1; $_REQUEST['filter']['AutoEmail'] = empty($_REQUEST['filter']['AutoEmail']) ? 0 : 1; $_REQUEST['filter']['AutoMessage'] = empty($_REQUEST['filter']['AutoMessage']) ? 0 : 1; $_REQUEST['filter']['AutoExecute'] = empty($_REQUEST['filter']['AutoExecute']) ? 0 : 1; $_REQUEST['filter']['AutoDelete'] = empty($_REQUEST['filter']['AutoDelete']) ? 0 : 1; $_REQUEST['filter']['UpdateDiskSpace'] = empty($_REQUEST['filter']['UpdateDiskSpace']) ? 0 : 1; $_REQUEST['filter']['Background'] = empty($_REQUEST['filter']['Background']) ? 0 : 1; $_REQUEST['filter']['Concurrent'] = empty($_REQUEST['filter']['Concurrent']) ? 0 : 1; $changes = $filter->changes($_REQUEST['filter']); ZM\Logger::Debug('Changes: ' . print_r($changes,true)); if ( $_REQUEST['Id'] and ( $action == 'Save' ) ) { if ( $filter->Background() ) $filter->control('stop'); $filter->save($changes); } else { if ( $action == 'execute' ) { if ( count($changes) ) { $filter->Name('_TempFilter'.time()); $filter->Id(null); } } else if ( $action == 'SaveAs' ) { $filter->Id(null); } $filter->save($changes); // We update the request id so that the newly saved filter is auto-selected $_REQUEST['Id'] = $filter->Id(); } if ( $action == 'execute' ) { $filter->execute(); if ( count($changes) ) $filter->delete(); $view = 'events'; } else if ( $filter->Background() ) { $filter->control('start'); } $redirect = '?view=filter&Id='.$filter->Id(); } else if ( $action == 'control' ) { if ( $_REQUEST['command'] == 'start' or $_REQUEST['command'] == 'stop' or $_REQUEST['command'] == 'restart' ) { $filter->control($_REQUEST['command'], $_REQUEST['ServerId']); } else { ZM\Error('Invalid command for filter ('.$_REQUEST['command'].')'); } } // end if save or execute } // end if canEdit(Events) } // end if object == filter ?>
ZoneMinder/ZoneMinder
web/includes/actions/filter.php
PHP
gpl-2.0
4,624
[ 30522, 1026, 1029, 25718, 1013, 1013, 1013, 1013, 4224, 23356, 2121, 4773, 2895, 5371, 1013, 1013, 9385, 1006, 1039, 1007, 10476, 4224, 23356, 2121, 11775, 1013, 1013, 1013, 1013, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 namespace Elementor\Core\Common\Modules\Connect\Apps; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } abstract class Base_User_App extends Base_App { /** * @since 2.3.0 * @access protected */ protected function update_settings() { update_user_option( get_current_user_id(), $this->get_option_name(), $this->data ); } /** * @since 2.3.0 * @access protected */ protected function init_data() { $this->data = get_user_option( $this->get_option_name() ); if ( ! $this->data ) { $this->data = []; } } }
pojome/elementor
core/common/modules/connect/apps/base-user-app.php
PHP
gpl-3.0
560
[ 30522, 1026, 1029, 25718, 3415, 15327, 5783, 2953, 1032, 4563, 1032, 2691, 1032, 14184, 1032, 7532, 1032, 18726, 1025, 2065, 1006, 999, 4225, 1006, 1005, 14689, 15069, 1005, 1007, 1007, 1063, 6164, 1025, 1013, 1013, 6164, 2065, 11570, 3495,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* * This file is part of AtlasMapper server and clients. * * Copyright (C) 2012 Australian Institute of Marine Science * * Contact: Gael Lafond <g.lafond@aims.org.au> * * 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/>. */ package au.gov.aims.atlasmapperserver.jsonWrappers.server; import au.gov.aims.atlasmapperserver.jsonWrappers.AbstractWrapper; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class UsersConfigWrapper extends AbstractWrapper { public UsersConfigWrapper() { super(); } public UsersConfigWrapper(JSONObject json) { super(json); } public Double getVersion() { return this.getVersion(null); } public Double getVersion(Double defaultValue) { if (this.json.isNull("version")) { return defaultValue; } return this.json.optDouble("version"); } public void setVersion(Double version) throws JSONException { if (version == null && !this.json.isNull("version")) { this.json.remove("version"); } else { this.json.put("version", version); } } public JSONArray getUsers() { return this.json.optJSONArray("users"); } public void setUsers(JSONArray users) throws JSONException { this.json.put("users", users); } }
windrobin/atlasmapper
src/main/java/au/gov/aims/atlasmapperserver/jsonWrappers/server/UsersConfigWrapper.java
Java
gpl-3.0
1,823
[ 30522, 1013, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 11568, 2863, 18620, 8241, 1998, 7846, 1012, 1008, 1008, 9385, 1006, 1039, 1007, 2262, 2827, 2820, 1997, 3884, 2671, 1008, 1008, 3967, 1024, 28151, 2474, 14876, 4859, 1026, 1043, 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) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <errno.h> #include <malloc.h> #include <string.h> #define __USE_GNU #ifndef __set_errno #define __set_errno(e) errno = (e) #endif #include <search.h> /* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986 [Knuth] The Art of Computer Programming, part 3 (6.4) */ /* The reentrant version has no static variables to maintain the state. Instead the interface of all functions is extended to take an argument which describes the current status. */ typedef struct _ENTRY { unsigned int used; ENTRY entry; } _ENTRY; /* For the used double hash method the table size has to be a prime. To correct the user given table size we need a prime test. This trivial algorithm is adequate because a) the code is (most probably) called a few times per program run and b) the number is small because the table must fit in the core */ static int isprime (unsigned int number) { /* no even number will be passed */ unsigned int div = 3; while (div * div < number && number % div != 0) div += 2; return number % div != 0; } /* Before using the hash table we must allocate memory for it. Test for an existing table are done. We allocate one element more as the found prime number says. This is done for more effective indexing as explained in the comment for the hsearch function. The contents of the table is zeroed, especially the field used becomes zero. */ int hcreate_r (nel, htab) size_t nel; struct hsearch_data *htab; { /* Test for correct arguments. */ if (htab == NULL) { __set_errno (EINVAL); return 0; } /* There is still another table active. Return with error. */ if (htab->table != NULL) return 0; /* Change nel to the first prime number not smaller as nel. */ nel |= 1; /* make odd */ while (!isprime (nel)) nel += 2; htab->size = nel; htab->filled = 0; /* allocate memory and zero out */ htab->table = (_ENTRY *) calloc (htab->size + 1, sizeof (_ENTRY)); if (htab->table == NULL) return 0; /* everything went alright */ return 1; } /* After using the hash table it has to be destroyed. The used memory can be freed and the local static variable can be marked as not used. */ void hdestroy_r (htab) struct hsearch_data *htab; { /* Test for correct arguments. */ if (htab == NULL) { __set_errno (EINVAL); return; } if (htab->table != NULL) /* free used memory */ free (htab->table); /* the sign for an existing table is an value != NULL in htable */ htab->table = NULL; } /* This is the search function. It uses double hashing with open addressing. The argument item.key has to be a pointer to an zero terminated, most probably strings of chars. The function for generating a number of the strings is simple but fast. It can be replaced by a more complex function like ajw (see [Aho,Sethi,Ullman]) if the needs are shown. We use an trick to speed up the lookup. The table is created by hcreate with one more element available. This enables us to use the index zero special. This index will never be used because we store the first hash index in the field used where zero means not used. Every other value means used. The used field can be used as a first fast comparison for equality of the stored and the parameter value. This helps to prevent unnecessary expensive calls of strcmp. */ int hsearch_r (item, action, retval, htab) ENTRY item; ACTION action; ENTRY **retval; struct hsearch_data *htab; { unsigned int hval; unsigned int count; unsigned int len = strlen (item.key); unsigned int idx; /* Compute an value for the given string. Perhaps use a better method. */ hval = len; count = len; while (count-- > 0) { hval <<= 4; hval += item.key[count]; } /* First hash function: simply take the modulo but prevent zero. */ hval %= htab->size; if (hval == 0) ++hval; /* The first index tried. */ idx = hval; if (htab->table[idx].used) { /* Further action might be required according to the action value. */ unsigned hval2; if (htab->table[idx].used == hval && strcmp (item.key, htab->table[idx].entry.key) == 0) { if (action == ENTER) htab->table[idx].entry.data = item.data; *retval = &htab->table[idx].entry; return 1; } /* Second hash function, as suggested in [Knuth] */ hval2 = 1 + hval % (htab->size - 2); do { /* Because SIZE is prime this guarantees to step through all available indexes. */ if (idx <= hval2) idx = htab->size + idx - hval2; else idx -= hval2; /* If we visited all entries leave the loop unsuccessfully. */ if (idx == hval) break; /* If entry is found use it. */ if (htab->table[idx].used == hval && strcmp (item.key, htab->table[idx].entry.key) == 0) { if (action == ENTER) htab->table[idx].entry.data = item.data; *retval = &htab->table[idx].entry; return 1; } } while (htab->table[idx].used); } /* An empty bucket has been found. */ if (action == ENTER) { /* If table is full and another entry should be entered return with error. */ if (action == ENTER && htab->filled == htab->size) { __set_errno (ENOMEM); *retval = NULL; return 0; } htab->table[idx].used = hval; htab->table[idx].entry = item; ++htab->filled; *retval = &htab->table[idx].entry; return 1; } __set_errno (ESRCH); *retval = NULL; return 0; }
voku/external-alsa-lib
src/compat/hsearch_r.c
C
lgpl-2.1
6,640
[ 30522, 1013, 1008, 9385, 1006, 1039, 1007, 2857, 1010, 2786, 1010, 2727, 1010, 2722, 2489, 4007, 3192, 1010, 4297, 1012, 2023, 5371, 2003, 2112, 1997, 1996, 27004, 1039, 3075, 1012, 5201, 2011, 19619, 2852, 13699, 4842, 1026, 2852, 13699, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import { selectUser } from '../../../store/actions' import { PagingState, SortingState, } from '@devexpress/dx-react-grid' import { Grid, TableView, TableHeaderRow, PagingPanel, } from '@devexpress/dx-react-grid-bootstrap3' const URL = 'https://js.devexpress.com/Demos/WidgetsGallery/data/orderItems' class UserList extends React.Component { constructor (props) { super(props) this.state = { columns: [ { name: 'OrderNumber', title: 'Order #', align: 'right' }, { name: 'OrderDate', title: 'Order Date' }, { name: 'StoreCity', title: 'Store City' }, { name: 'StoreState', title: 'Store State' }, { name: 'Employee', title: 'Employee' }, { name: 'SaleAmount', title: 'Sale Amount', align: 'right' }, ], rows: [], sorting: [{ columnName: 'StoreCity', direction: 'asc' }], totalCount: 0, pageSize: 10, allowedPageSizes: [5, 10, 15], currentPage: 0, // loading: true, } this.changeSorting = this.changeSorting.bind(this) this.changeCurrentPage = this.changeCurrentPage.bind(this) this.changePageSize = this.changePageSize.bind(this) } componentDidMount () { this.loadData() } componentDidUpdate () { this.loadData() } changeSorting (sorting) { this.setState({ // loading: true, sorting, }) } changeCurrentPage (currentPage) { this.setState({ // loading: true, currentPage, }) } changePageSize (pageSize) { const totalPages = Math.ceil(this.state.totalCount / pageSize) const currentPage = Math.min(this.state.currentPage, totalPages - 1) this.setState({ // loading: true, pageSize, currentPage, }) } queryString () { const { sorting, pageSize, currentPage } = this.state let queryString = `${URL}?take=${pageSize}&skip=${pageSize * currentPage}` const columnSorting = sorting[0] if (columnSorting) { const sortingDirectionString = columnSorting.direction === 'desc' ? ' desc' : '' queryString = `${queryString}&orderby=${columnSorting.columnName}${sortingDirectionString}` } return queryString } loadData () { const queryString = this.queryString() if (queryString === this.lastQuery) { // this.setState({ loading: false }) return } fetch(queryString) .then(response => response.json()) .then(data => { console.log(data.items.length) this.setState({ rows: data.items, totalCount: data.totalCount, // loading: false, }) }) .catch(() => this.setState({ // loading: false })) this.lastQuery = queryString } createTableItems () { return this.props.users.map((user, i) => { return ( <tr onClick={() => this.props.selectUser(user)} key={i}> <th>{user.id}</th> <th>{user.name}</th> <th>{user.born}</th> <th>{user.description}</th> <th><img src={user.image} alt='' /></th> </tr> ) }) } render () { const { rows, columns, sorting, pageSize, allowedPageSizes, currentPage, totalCount, loading, } = this.state return ( <div style={{ position: 'relative' }}> <Grid rows={rows} columns={columns} > <SortingState sorting={sorting} onSortingChange={this.changeSorting} /> <PagingState currentPage={currentPage} onCurrentPageChange={this.changeCurrentPage} pageSize={pageSize} onPageSizeChange={this.changePageSize} totalCount={totalCount} /> <TableView tableCellTemplate={({ row, column }) => { if (column.name === 'SaleAmount') { return ( <td style={{ textAlign: 'right' }}>${row.SaleAmount}</td> ) } return undefined }} tableNoDataCellTemplate={({ colspan }) => ( <td style={{ textAlign: 'center', padding: '40px 0', }} colSpan={colspan} > <big className='text-muted'>{loading ? '' : 'No data'}</big> </td> )} /> <TableHeaderRow allowSorting /> <PagingPanel allowedPageSizes={allowedPageSizes} /> </Grid> </div> ) } } UserList.propTypes = { users: PropTypes.array, selectUser: PropTypes.func } const mapStateToProps = (state) => ({ users: state.users }) const matchDispatchToProps = (dispatch) => { return bindActionCreators({ selectUser: selectUser }, dispatch) } export default connect(mapStateToProps, matchDispatchToProps)(UserList)
roslaneshellanoo/react-redux-tutorial
src/routes/Users/containers/userListContainer.js
JavaScript
mit
5,095
[ 30522, 12324, 10509, 2013, 1005, 10509, 1005, 12324, 17678, 13874, 2015, 2013, 1005, 17678, 1011, 4127, 1005, 12324, 1063, 7532, 1065, 2013, 1005, 10509, 1011, 2417, 5602, 1005, 12324, 1063, 14187, 18908, 3258, 16748, 18926, 1065, 2013, 1005,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 2015 JBoss Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * * 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.kie.server.client; import org.kie.api.command.Command; import org.kie.server.api.model.ServiceResponse; public interface RuleServicesClient { ServiceResponse<String> executeCommands(String id, String payload); ServiceResponse<String> executeCommands(String id, Command<?> cmd); }
BeatCoding/droolsjbpm-integration
kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/client/RuleServicesClient.java
Java
apache-2.0
856
[ 30522, 1013, 1008, 1008, 9385, 2325, 1046, 15853, 2015, 4297, 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, 3272, 1999, 12646, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* * This file is part of pcb2gcode. * * Copyright (C) 2009, 2010 Patrick Birnzain <pbirnzain@users.sourceforge.net> * * pcb2gcode 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. * * pcb2gcode 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 pcb2gcode. If not, see <http://www.gnu.org/licenses/>. */ #ifndef DRILL_H #define DRILL_H #include <map> using std::map; #include <string> using std::string; #include <vector> using std::vector; #include <map> using std::map; #include <boost/shared_ptr.hpp> using boost::shared_ptr; extern "C" { #include <gerbv.h> } #include "coord.hpp" #include <boost/exception/all.hpp> class drill_exception : virtual std::exception, virtual boost::exception {}; #include "mill.hpp" #include "svg_exporter.hpp" #include "geometry.h" class drillbit { public: double diameter; string unit; int drill_count; }; //! Reads Excellon drill files and directly creates RS274-NGC gcode output. /*! While we could easily add different input and output formats for the layerfiles * to pcb2gcode, i've decided to ditch the importer/exporter scheme here. * We'll very likely not encounter any drill files that gerbv can't read, and * still rather likely never export to anything other than a ngc g-code file. * Also, i'm lazy, and if I turn out to be wrong splitting the code won't be much effort anyway. */ class ExcellonProcessor { public: ExcellonProcessor( const string drillfile, const ivalue_t board_width ); ~ExcellonProcessor(); void add_header( string ); void set_preamble(string); void set_postamble(string); //SVG EXPORTER void set_svg_exporter( shared_ptr<SVG_Exporter> svgexpo ); void export_ngc( const string of_name, shared_ptr<Driller> target, bool mirrored, bool mirror_absolute ); void export_ngc( const string of_name, shared_ptr<Cutter> target, bool mirrored, bool mirror_absolute ); shared_ptr<const map<int,drillbit> > get_bits(); shared_ptr<const map<int,icoords> > get_holes(); private: void parse_holes(); void parse_bits(); const ivalue_t board_width; bool bDoSVG; shared_ptr<SVG_Exporter> svgexpo; shared_ptr< map<int,drillbit> > bits; shared_ptr< map<int,icoords> > holes; gerbv_project_t* project; vector<string> header; string preamble,postamble; private: //methods void millhole(DxfNgc_Layer &l,float x, float y, shared_ptr<Cutter> cutter,float holediameter); }; #endif // DRILL_H
bkubicek/pcb2gcode
drill.hpp
C++
gpl-3.0
2,860
[ 30522, 1013, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 7473, 2497, 2475, 18195, 10244, 1012, 1008, 1008, 9385, 1006, 1039, 1007, 2268, 1010, 2230, 4754, 12170, 6826, 25290, 2078, 1026, 1052, 17706, 16786, 2378, 1030, 5198, 1012, 3120, 29278...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_HASH_H #define BITCOIN_HASH_H #include "crypto/ripemd160.h" #include "crypto/sha256.h" #include "serialize.h" #include "uint256.h" #include "version.h" #include "crypto/sph_blake.h" #include "crypto/sph_bmw.h" #include "crypto/sph_groestl.h" #include "crypto/sph_jh.h" #include "crypto/sph_keccak.h" #include "crypto/sph_skein.h" #include <iomanip> #include <openssl/sha.h> #include <sstream> #include <vector> using namespace std; /** A hasher class for Bitcoin's 256-bit hash (double SHA-256). */ class CHash256 { private: CSHA256 sha; public: static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE; void Finalize(unsigned char hash[OUTPUT_SIZE]) { unsigned char buf[sha.OUTPUT_SIZE]; sha.Finalize(buf); sha.Reset().Write(buf, sha.OUTPUT_SIZE).Finalize(hash); } CHash256& Write(const unsigned char* data, size_t len) { sha.Write(data, len); return *this; } CHash256& Reset() { sha.Reset(); return *this; } }; #ifdef GLOBALDEFINED #define GLOBAL #else #define GLOBAL extern #endif GLOBAL sph_blake512_context z_blake; GLOBAL sph_bmw512_context z_bmw; GLOBAL sph_groestl512_context z_groestl; GLOBAL sph_jh512_context z_jh; GLOBAL sph_keccak512_context z_keccak; GLOBAL sph_skein512_context z_skein; #define fillz() \ do { \ sph_blake512_init(&z_blake); \ sph_bmw512_init(&z_bmw); \ sph_groestl512_init(&z_groestl); \ sph_jh512_init(&z_jh); \ sph_keccak512_init(&z_keccak); \ sph_skein512_init(&z_skein); \ } while (0) #define ZBLAKE (memcpy(&ctx_blake, &z_blake, sizeof(z_blake))) #define ZBMW (memcpy(&ctx_bmw, &z_bmw, sizeof(z_bmw))) #define ZGROESTL (memcpy(&ctx_groestl, &z_groestl, sizeof(z_groestl))) #define ZJH (memcpy(&ctx_jh, &z_jh, sizeof(z_jh))) #define ZKECCAK (memcpy(&ctx_keccak, &z_keccak, sizeof(z_keccak))) #define ZSKEIN (memcpy(&ctx_skein, &z_skein, sizeof(z_skein))) /* ----------- Bitcoin Hash ------------------------------------------------- */ /** A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160). */ class CHash160 { private: CSHA256 sha; public: static const size_t OUTPUT_SIZE = CRIPEMD160::OUTPUT_SIZE; void Finalize(unsigned char hash[OUTPUT_SIZE]) { unsigned char buf[sha.OUTPUT_SIZE]; sha.Finalize(buf); CRIPEMD160().Write(buf, sha.OUTPUT_SIZE).Finalize(hash); } CHash160& Write(const unsigned char* data, size_t len) { sha.Write(data, len); return *this; } CHash160& Reset() { sha.Reset(); return *this; } }; /** Compute the 256-bit hash of a std::string */ inline std::string Hash(std::string input) { unsigned char hash[SHA256_DIGEST_LENGTH]; SHA256_CTX sha256; SHA256_Init(&sha256); SHA256_Update(&sha256, input.c_str(), input.size()); SHA256_Final(hash, &sha256); stringstream ss; for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) { ss << hex << setw(2) << setfill('0') << (int)hash[i]; } return ss.str(); } /** Compute the 256-bit hash of a void pointer */ inline void Hash(void* in, unsigned int len, unsigned char* out) { SHA256_CTX sha256; SHA256_Init(&sha256); SHA256_Update(&sha256, in, len); SHA256_Final(out, &sha256); } /** Compute the 256-bit hash of an object. */ template <typename T1> inline uint256 Hash(const T1 pbegin, const T1 pend) { static const unsigned char pblank[1] = {}; uint256 result; CHash256().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0])).Finalize((unsigned char*)&result); return result; } /** Compute the 256-bit hash of the concatenation of two objects. */ template <typename T1, typename T2> inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end) { static const unsigned char pblank[1] = {}; uint256 result; CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Finalize((unsigned char*)&result); return result; } /** Compute the 256-bit hash of the concatenation of three objects. */ template <typename T1, typename T2, typename T3> inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end) { static const unsigned char pblank[1] = {}; uint256 result; CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Finalize((unsigned char*)&result); return result; } /** Compute the 256-bit hash of the concatenation of three objects. */ template <typename T1, typename T2, typename T3, typename T4> inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end) { static const unsigned char pblank[1] = {}; uint256 result; CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Finalize((unsigned char*)&result); return result; } /** Compute the 256-bit hash of the concatenation of three objects. */ template <typename T1, typename T2, typename T3, typename T4, typename T5> inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end, const T5 p5begin, const T5 p5end) { static const unsigned char pblank[1] = {}; uint256 result; CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0])).Finalize((unsigned char*)&result); return result; } /** Compute the 256-bit hash of the concatenation of three objects. */ template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end, const T5 p5begin, const T5 p5end, const T6 p6begin, const T6 p6end) { static const unsigned char pblank[1] = {}; uint256 result; CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0])).Write(p6begin == p6end ? pblank : (const unsigned char*)&p6begin[0], (p6end - p6begin) * sizeof(p6begin[0])).Finalize((unsigned char*)&result); return result; } /** Compute the 160-bit hash an object. */ template <typename T1> inline uint160 Hash160(const T1 pbegin, const T1 pend) { static unsigned char pblank[1] = {}; uint160 result; CHash160().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0])).Finalize((unsigned char*)&result); return result; } /** Compute the 160-bit hash of a vector. */ inline uint160 Hash160(const std::vector<unsigned char>& vch) { return Hash160(vch.begin(), vch.end()); } /** A writer stream (for serialization) that computes a 256-bit hash. */ class CHashWriter { private: CHash256 ctx; public: int nType; int nVersion; CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {} CHashWriter& write(const char* pch, size_t size) { ctx.Write((const unsigned char*)pch, size); return (*this); } // invalidates the object uint256 GetHash() { uint256 result; ctx.Finalize((unsigned char*)&result); return result; } template <typename T> CHashWriter& operator<<(const T& obj) { // Serialize to this stream ::Serialize(*this, obj, nType, nVersion); return (*this); } }; /** Compute the 256-bit hash of an object's serialization. */ template <typename T> uint256 SerializeHash(const T& obj, int nType = SER_GETHASH, int nVersion = PROTOCOL_VERSION) { CHashWriter ss(nType, nVersion); ss << obj; return ss.GetHash(); } unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char>& vDataToHash); void BIP32Hash(const unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]); //int HMAC_SHA512_Init(HMAC_SHA512_CTX *pctx, const void *pkey, size_t len); //int HMAC_SHA512_Update(HMAC_SHA512_CTX *pctx, const void *pdata, size_t len); //int HMAC_SHA512_Final(unsigned char *pmd, HMAC_SHA512_CTX *pctx); /* ----------- Quark Hash ------------------------------------------------ */ template <typename T1> inline uint256 HashQuark(const T1 pbegin, const T1 pend) { sph_blake512_context ctx_blake; sph_bmw512_context ctx_bmw; sph_groestl512_context ctx_groestl; sph_jh512_context ctx_jh; sph_keccak512_context ctx_keccak; sph_skein512_context ctx_skein; static unsigned char pblank[1]; uint512 mask = 8; uint512 zero = 0; uint512 hash[9]; sph_blake512_init(&ctx_blake); // ZBLAKE; sph_blake512(&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0])); sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[0])); sph_bmw512_init(&ctx_bmw); // ZBMW; sph_bmw512(&ctx_bmw, static_cast<const void*>(&hash[0]), 64); sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[1])); if ((hash[1] & mask) != zero) { sph_groestl512_init(&ctx_groestl); // ZGROESTL; sph_groestl512(&ctx_groestl, static_cast<const void*>(&hash[1]), 64); sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[2])); } else { sph_skein512_init(&ctx_skein); // ZSKEIN; sph_skein512(&ctx_skein, static_cast<const void*>(&hash[1]), 64); sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[2])); } sph_groestl512_init(&ctx_groestl); // ZGROESTL; sph_groestl512(&ctx_groestl, static_cast<const void*>(&hash[2]), 64); sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[3])); sph_jh512_init(&ctx_jh); // ZJH; sph_jh512(&ctx_jh, static_cast<const void*>(&hash[3]), 64); sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[4])); if ((hash[4] & mask) != zero) { sph_blake512_init(&ctx_blake); // ZBLAKE; sph_blake512(&ctx_blake, static_cast<const void*>(&hash[4]), 64); sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[5])); } else { sph_bmw512_init(&ctx_bmw); // ZBMW; sph_bmw512(&ctx_bmw, static_cast<const void*>(&hash[4]), 64); sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[5])); } sph_keccak512_init(&ctx_keccak); // ZKECCAK; sph_keccak512(&ctx_keccak, static_cast<const void*>(&hash[5]), 64); sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[6])); sph_skein512_init(&ctx_skein); // SKEIN; sph_skein512(&ctx_skein, static_cast<const void*>(&hash[6]), 64); sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[7])); if ((hash[7] & mask) != zero) { sph_keccak512_init(&ctx_keccak); // ZKECCAK; sph_keccak512(&ctx_keccak, static_cast<const void*>(&hash[7]), 64); sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[8])); } else { sph_jh512_init(&ctx_jh); // ZJH; sph_jh512(&ctx_jh, static_cast<const void*>(&hash[7]), 64); sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[8])); } return hash[8].trim256(); } void scrypt_hash(const char* pass, unsigned int pLen, const char* salt, unsigned int sLen, char* output, unsigned int N, unsigned int r, unsigned int p, unsigned int dkLen); #endif // BITCOIN_HASH_H
presstab/PIVX
src/hash.h
C
mit
13,680
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2268, 1011, 2230, 20251, 6182, 17823, 22591, 3406, 1013, 1013, 9385, 1006, 1039, 1007, 2268, 1011, 2297, 1996, 2978, 3597, 2378, 9797, 1013, 1013, 9385, 1006, 1039, 1007, 2297, 1011, 2325, 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...
<!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_25) on Wed Jul 23 10:47:42 EDT 2014 --> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <title>Deprecated List</title> <meta name="date" content="2014-07-23"> <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Deprecated List"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="overview-summary.html">Overview</a></li> <li>Package</li> <li>Class</li> <li><a href="overview-tree.html">Tree</a></li> <li class="navBarCell1Rev">Deprecated</li> <li><a href="index-files/index-1.html">Index</a></li> <li><a href="help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="index.html?deprecated-list.html" target="_top">Frames</a></li> <li><a href="deprecated-list.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h1 title="Deprecated API" class="title">Deprecated API</h1> <h2 title="Contents">Contents</h2> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="overview-summary.html">Overview</a></li> <li>Package</li> <li>Class</li> <li><a href="overview-tree.html">Tree</a></li> <li class="navBarCell1Rev">Deprecated</li> <li><a href="index-files/index-1.html">Index</a></li> <li><a href="help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="index.html?deprecated-list.html" target="_top">Frames</a></li> <li><a href="deprecated-list.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
cosimoiaia/pyAiml-2.0
doc/program-ab-reference-doc/deprecated-list.html
HTML
gpl-2.0
3,477
[ 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...
.tabDIV{background: url(tabmenubg2.gif);height:38px; padding-top:13px; margin-bottom:3px; padding-left:5px;} .tabtitle{float: left; text-indent:18px; font-size:14px; /*background:url(arrow7.gif) no-repeat left center;*/padding-right:8px;} .tabselect{background: url(bgx5.gif) no-repeat center bottom;text-align: center;float: left;height: 25px;width: 74px;margin:0 1px;padding:6px 0 0 0;cursor:hand} .tabnoselect{background: url(bgx3.gif) no-repeat center bottom;text-align: center;float: left;height: 25px;width: 74px;margin:0 1px;padding:6px 0 0 0;text-decoration: none;cursor:hand} .tabselect8{background: url(bgx7.gif) no-repeat center bottom;text-align: center;float: left;height: 25px;width: 108px;margin:0 1px;padding:6px 0 0 0;cursor:hand} .div_title{ float:left;text-indent:18px;font-size:14px; /*background:url(../../images/arrow7.gif) no-repeat left top;*/ padding-right:8px;margin-top:15px;}
javakaka/hslg
hslg/WebContent/res/js/tab/Style.css
CSS
mit
904
[ 30522, 1012, 21628, 4305, 2615, 1063, 4281, 1024, 24471, 2140, 1006, 21628, 3549, 12083, 2290, 2475, 1012, 21025, 2546, 1007, 1025, 4578, 1024, 4229, 2361, 2595, 1025, 11687, 4667, 1011, 2327, 1024, 2410, 2361, 2595, 1025, 7785, 1011, 3953,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* * This file is part of the MicroPython project, http://micropython.org/ * * Development of the code in this file was sponsored by Microbric Pty Ltd * and Mnemote Pty Ltd * * The MIT License (MIT) * * Copyright (c) 2016, 2017 Nick Moore @mnemote * * Based on esp8266/modnetwork.c which is Copyright (c) 2015 Paul Sokolovsky * And the ESP IDF example code which is Public Domain / CC0 * * 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. */ #include <stdio.h> #include <stdint.h> #include <string.h> #include "py/nlr.h" #include "py/objlist.h" #include "py/runtime.h" #include "py/mphal.h" #include "py/mperrno.h" #include "netutils.h" #include "esp_wifi.h" #include "esp_wifi_types.h" #include "esp_log.h" #include "esp_event_loop.h" #include "esp_log.h" #include "lwip/dns.h" #include "tcpip_adapter.h" #define MODNETWORK_INCLUDE_CONSTANTS (1) NORETURN void _esp_exceptions(esp_err_t e) { switch (e) { case ESP_ERR_WIFI_NOT_INIT: mp_raise_msg(&mp_type_OSError, "Wifi Not Initialized"); case ESP_ERR_WIFI_NOT_STARTED: mp_raise_msg(&mp_type_OSError, "Wifi Not Started"); case ESP_ERR_WIFI_CONN: mp_raise_msg(&mp_type_OSError, "Wifi Internal Error"); case ESP_ERR_WIFI_SSID: mp_raise_msg(&mp_type_OSError, "Wifi SSID Invalid"); case ESP_FAIL: mp_raise_msg(&mp_type_OSError, "Wifi Internal Failure"); case ESP_ERR_WIFI_IF: mp_raise_msg(&mp_type_OSError, "Wifi Invalid Interface"); case ESP_ERR_WIFI_MAC: mp_raise_msg(&mp_type_OSError, "Wifi Invalid MAC Address"); case ESP_ERR_INVALID_ARG: mp_raise_msg(&mp_type_OSError, "Wifi Invalid Argument"); case ESP_ERR_WIFI_MODE: mp_raise_msg(&mp_type_OSError, "Wifi Invalid Mode"); case ESP_ERR_WIFI_PASSWORD: mp_raise_msg(&mp_type_OSError, "Wifi Invalid Password"); case ESP_ERR_WIFI_NVS: mp_raise_msg(&mp_type_OSError, "Wifi Internal NVS Error"); case ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS: mp_raise_msg(&mp_type_OSError, "TCP/IP Invalid Parameters"); case ESP_ERR_TCPIP_ADAPTER_IF_NOT_READY: mp_raise_msg(&mp_type_OSError, "TCP/IP IF Not Ready"); case ESP_ERR_TCPIP_ADAPTER_DHCPC_START_FAILED: mp_raise_msg(&mp_type_OSError, "TCP/IP DHCP Client Start Failed"); case ESP_ERR_WIFI_TIMEOUT: mp_raise_OSError(MP_ETIMEDOUT); case ESP_ERR_TCPIP_ADAPTER_NO_MEM: case ESP_ERR_NO_MEM: mp_raise_OSError(MP_ENOMEM); default: nlr_raise(mp_obj_new_exception_msg_varg( &mp_type_RuntimeError, "Wifi Unknown Error 0x%04x", e )); } } static inline void esp_exceptions(esp_err_t e) { if (e != ESP_OK) _esp_exceptions(e); } #define ESP_EXCEPTIONS(x) do { esp_exceptions(x); } while (0); typedef struct _wlan_if_obj_t { mp_obj_base_t base; int if_id; } wlan_if_obj_t; const mp_obj_type_t wlan_if_type; STATIC const wlan_if_obj_t wlan_sta_obj = {{&wlan_if_type}, WIFI_IF_STA}; STATIC const wlan_if_obj_t wlan_ap_obj = {{&wlan_if_type}, WIFI_IF_AP}; //static wifi_config_t wifi_ap_config = {{{0}}}; static wifi_config_t wifi_sta_config = {{{0}}}; // Set to "true" if the STA interface is requested to be connected by the // user, used for automatic reassociation. static bool wifi_sta_connected = false; // This function is called by the system-event task and so runs in a different // thread to the main MicroPython task. It must not raise any Python exceptions. static esp_err_t event_handler(void *ctx, system_event_t *event) { switch(event->event_id) { case SYSTEM_EVENT_STA_START: ESP_LOGI("wifi", "STA_START"); break; case SYSTEM_EVENT_STA_GOT_IP: ESP_LOGI("wifi", "GOT_IP"); break; case SYSTEM_EVENT_STA_DISCONNECTED: { // This is a workaround as ESP32 WiFi libs don't currently // auto-reassociate. system_event_sta_disconnected_t *disconn = &event->event_info.disconnected; ESP_LOGI("wifi", "STA_DISCONNECTED, reason:%d", disconn->reason); switch (disconn->reason) { case WIFI_REASON_AUTH_FAIL: mp_printf(MP_PYTHON_PRINTER, "authentication failed"); wifi_sta_connected = false; break; default: // Let other errors through and try to reconnect. break; } if (wifi_sta_connected) { wifi_mode_t mode; if (esp_wifi_get_mode(&mode) == ESP_OK) { if (mode & WIFI_MODE_STA) { // STA is active so attempt to reconnect. esp_err_t e = esp_wifi_connect(); if (e != ESP_OK) { mp_printf(MP_PYTHON_PRINTER, "error attempting to reconnect: 0x%04x", e); } } } } break; } default: ESP_LOGI("wifi", "event %d", event->event_id); break; } return ESP_OK; } /*void error_check(bool status, const char *msg) { if (!status) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, msg)); } } */ STATIC void require_if(mp_obj_t wlan_if, int if_no) { wlan_if_obj_t *self = MP_OBJ_TO_PTR(wlan_if); if (self->if_id != if_no) { mp_raise_msg(&mp_type_OSError, if_no == WIFI_IF_STA ? "STA required" : "AP required"); } } STATIC mp_obj_t get_wlan(size_t n_args, const mp_obj_t *args) { int idx = (n_args > 0) ? mp_obj_get_int(args[0]) : WIFI_IF_STA; if (idx == WIFI_IF_STA) { return MP_OBJ_FROM_PTR(&wlan_sta_obj); } else if (idx == WIFI_IF_AP) { return MP_OBJ_FROM_PTR(&wlan_ap_obj); } else { mp_raise_msg(&mp_type_ValueError, "invalid WLAN interface identifier"); } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(get_wlan_obj, 0, 1, get_wlan); STATIC mp_obj_t esp_initialize() { static int initialized = 0; if (!initialized) { // wifi binary does not listens to compuiler log level, and must be set at runtime esp_log_level_set("wifi", ESP_LOG_WARN); ESP_LOGD("modnetwork", "Initializing TCP/IP"); tcpip_adapter_init(); ESP_LOGD("modnetwork", "Initializing Event Loop"); ESP_EXCEPTIONS( esp_event_loop_init(event_handler, NULL) ); ESP_LOGD("modnetwork", "esp_event_loop_init done"); wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_LOGD("modnetwork", "Initializing WiFi"); ESP_EXCEPTIONS( esp_wifi_init(&cfg) ); ESP_EXCEPTIONS( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); ESP_LOGD("modnetwork", "Initialized"); ESP_EXCEPTIONS( esp_wifi_set_mode(0) ); ESP_EXCEPTIONS( esp_wifi_start() ); ESP_LOGD("modnetwork", "Started"); initialized = 1; } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_initialize_obj, esp_initialize); #if (WIFI_MODE_STA & WIFI_MODE_AP != WIFI_MODE_NULL || WIFI_MODE_STA | WIFI_MODE_AP != WIFI_MODE_APSTA) #error WIFI_MODE_STA and WIFI_MODE_AP are supposed to be bitfields! #endif STATIC mp_obj_t esp_active(size_t n_args, const mp_obj_t *args) { wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]); wifi_mode_t mode; ESP_EXCEPTIONS( esp_wifi_get_mode(&mode) ); int bit = (self->if_id == WIFI_IF_STA) ? WIFI_MODE_STA : WIFI_MODE_AP; if (n_args > 1) { bool active = mp_obj_is_true(args[1]); mode = active ? (mode | bit) : (mode & ~bit); ESP_EXCEPTIONS( esp_wifi_set_mode(mode) ); } return (mode & bit) ? mp_const_true : mp_const_false; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_active_obj, 1, 2, esp_active); STATIC mp_obj_t esp_connect(size_t n_args, const mp_obj_t *args) { mp_uint_t len; const char *p; if (n_args > 1) { memset(&wifi_sta_config, 0, sizeof(wifi_sta_config)); p = mp_obj_str_get_data(args[1], &len); memcpy(wifi_sta_config.sta.ssid, p, MIN(len, sizeof(wifi_sta_config.sta.ssid))); p = (n_args > 2) ? mp_obj_str_get_data(args[2], &len) : ""; memcpy(wifi_sta_config.sta.password, p, MIN(len, sizeof(wifi_sta_config.sta.password))); ESP_EXCEPTIONS( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_sta_config) ); } MP_THREAD_GIL_EXIT(); ESP_EXCEPTIONS( esp_wifi_connect() ); MP_THREAD_GIL_ENTER(); wifi_sta_connected = true; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_connect_obj, 1, 7, esp_connect); STATIC mp_obj_t esp_disconnect(mp_obj_t self_in) { wifi_sta_connected = false; ESP_EXCEPTIONS( esp_wifi_disconnect() ); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_disconnect_obj, esp_disconnect); STATIC mp_obj_t esp_status(mp_obj_t self_in) { return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_status_obj, esp_status); STATIC mp_obj_t esp_scan(mp_obj_t self_in) { // check that STA mode is active wifi_mode_t mode; ESP_EXCEPTIONS(esp_wifi_get_mode(&mode)); if ((mode & WIFI_MODE_STA) == 0) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "STA must be active")); } mp_obj_t list = mp_obj_new_list(0, NULL); wifi_scan_config_t config = { 0 }; // XXX how do we scan hidden APs (and if we can scan them, are they really hidden?) MP_THREAD_GIL_EXIT(); esp_err_t status = esp_wifi_scan_start(&config, 1); MP_THREAD_GIL_ENTER(); if (status == 0) { uint16_t count = 0; ESP_EXCEPTIONS( esp_wifi_scan_get_ap_num(&count) ); wifi_ap_record_t *wifi_ap_records = calloc(count, sizeof(wifi_ap_record_t)); ESP_EXCEPTIONS( esp_wifi_scan_get_ap_records(&count, wifi_ap_records) ); for (uint16_t i = 0; i < count; i++) { mp_obj_tuple_t *t = mp_obj_new_tuple(6, NULL); uint8_t *x = memchr(wifi_ap_records[i].ssid, 0, sizeof(wifi_ap_records[i].ssid)); int ssid_len = x ? x - wifi_ap_records[i].ssid : sizeof(wifi_ap_records[i].ssid); t->items[0] = mp_obj_new_bytes(wifi_ap_records[i].ssid, ssid_len); t->items[1] = mp_obj_new_bytes(wifi_ap_records[i].bssid, sizeof(wifi_ap_records[i].bssid)); t->items[2] = MP_OBJ_NEW_SMALL_INT(wifi_ap_records[i].primary); t->items[3] = MP_OBJ_NEW_SMALL_INT(wifi_ap_records[i].rssi); t->items[4] = MP_OBJ_NEW_SMALL_INT(wifi_ap_records[i].authmode); t->items[5] = mp_const_false; // XXX hidden? mp_obj_list_append(list, MP_OBJ_FROM_PTR(t)); } free(wifi_ap_records); } return list; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_scan_obj, esp_scan); STATIC mp_obj_t esp_isconnected(mp_obj_t self_in) { wlan_if_obj_t *self = MP_OBJ_TO_PTR(self_in); require_if(self_in, WIFI_IF_STA); tcpip_adapter_ip_info_t info; tcpip_adapter_get_ip_info(self->if_id, &info); return mp_obj_new_bool(info.ip.addr != 0); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_isconnected_obj, esp_isconnected); STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) { wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]); tcpip_adapter_ip_info_t info; ip_addr_t dns_addr; tcpip_adapter_get_ip_info(self->if_id, &info); if (n_args == 1) { // get dns_addr = dns_getserver(0); mp_obj_t tuple[4] = { netutils_format_ipv4_addr((uint8_t*)&info.ip, NETUTILS_BIG), netutils_format_ipv4_addr((uint8_t*)&info.netmask, NETUTILS_BIG), netutils_format_ipv4_addr((uint8_t*)&info.gw, NETUTILS_BIG), netutils_format_ipv4_addr((uint8_t*)&dns_addr, NETUTILS_BIG), }; return mp_obj_new_tuple(4, tuple); } else { // set mp_obj_t *items; mp_obj_get_array_fixed_n(args[1], 4, &items); netutils_parse_ipv4_addr(items[0], (void*)&info.ip, NETUTILS_BIG); if (mp_obj_is_integer(items[1])) { // allow numeric netmask, i.e.: // 24 -> 255.255.255.0 // 16 -> 255.255.0.0 // etc... uint32_t* m = (uint32_t*)&info.netmask; *m = htonl(0xffffffff << (32 - mp_obj_get_int(items[1]))); } else { netutils_parse_ipv4_addr(items[1], (void*)&info.netmask, NETUTILS_BIG); } netutils_parse_ipv4_addr(items[2], (void*)&info.gw, NETUTILS_BIG); netutils_parse_ipv4_addr(items[3], (void*)&dns_addr, NETUTILS_BIG); // To set a static IP we have to disable DHCP first if (self->if_id == WIFI_IF_STA) { esp_err_t e = tcpip_adapter_dhcpc_stop(WIFI_IF_STA); if (e != ESP_OK && e != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED) _esp_exceptions(e); ESP_EXCEPTIONS(tcpip_adapter_set_ip_info(WIFI_IF_STA, &info)); } else if (self->if_id == WIFI_IF_AP) { esp_err_t e = tcpip_adapter_dhcps_stop(WIFI_IF_AP); if (e != ESP_OK && e != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED) _esp_exceptions(e); ESP_EXCEPTIONS(tcpip_adapter_set_ip_info(WIFI_IF_AP, &info)); ESP_EXCEPTIONS(tcpip_adapter_dhcps_start(WIFI_IF_AP)); } return mp_const_none; } } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_ifconfig_obj, 1, 2, esp_ifconfig); STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { if (n_args != 1 && kwargs->used != 0) { nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "either pos or kw args are allowed")); } wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]); // get the config for the interface wifi_config_t cfg; ESP_EXCEPTIONS(esp_wifi_get_config(self->if_id, &cfg)); if (kwargs->used != 0) { for (size_t i = 0; i < kwargs->alloc; i++) { if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) { int req_if = -1; #define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x) switch ((uintptr_t)kwargs->table[i].key) { case QS(MP_QSTR_mac): { mp_buffer_info_t bufinfo; mp_get_buffer_raise(kwargs->table[i].value, &bufinfo, MP_BUFFER_READ); if (bufinfo.len != 6) { nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "invalid buffer length")); } ESP_EXCEPTIONS(esp_wifi_set_mac(self->if_id, bufinfo.buf)); break; } case QS(MP_QSTR_essid): { req_if = WIFI_IF_AP; mp_uint_t len; const char *s = mp_obj_str_get_data(kwargs->table[i].value, &len); len = MIN(len, sizeof(cfg.ap.ssid)); memcpy(cfg.ap.ssid, s, len); cfg.ap.ssid_len = len; break; } case QS(MP_QSTR_hidden): { req_if = WIFI_IF_AP; cfg.ap.ssid_hidden = mp_obj_is_true(kwargs->table[i].value); break; } case QS(MP_QSTR_authmode): { req_if = WIFI_IF_AP; cfg.ap.authmode = mp_obj_get_int(kwargs->table[i].value); break; } case QS(MP_QSTR_password): { req_if = WIFI_IF_AP; mp_uint_t len; const char *s = mp_obj_str_get_data(kwargs->table[i].value, &len); len = MIN(len, sizeof(cfg.ap.password) - 1); memcpy(cfg.ap.password, s, len); cfg.ap.password[len] = 0; break; } case QS(MP_QSTR_channel): { req_if = WIFI_IF_AP; cfg.ap.channel = mp_obj_get_int(kwargs->table[i].value); break; } default: goto unknown; } #undef QS // We post-check interface requirements to save on code size if (req_if >= 0) { require_if(args[0], req_if); } } } ESP_EXCEPTIONS(esp_wifi_set_config(self->if_id, &cfg)); return mp_const_none; } // Get config if (n_args != 2) { nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "can query only one param")); } int req_if = -1; mp_obj_t val; #define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x) switch ((uintptr_t)args[1]) { case QS(MP_QSTR_mac): { uint8_t mac[6]; ESP_EXCEPTIONS(esp_wifi_get_mac(self->if_id, mac)); return mp_obj_new_bytes(mac, sizeof(mac)); } case QS(MP_QSTR_essid): req_if = WIFI_IF_AP; val = mp_obj_new_str((char*)cfg.ap.ssid, cfg.ap.ssid_len, false); break; case QS(MP_QSTR_hidden): req_if = WIFI_IF_AP; val = mp_obj_new_bool(cfg.ap.ssid_hidden); break; case QS(MP_QSTR_authmode): req_if = WIFI_IF_AP; val = MP_OBJ_NEW_SMALL_INT(cfg.ap.authmode); break; case QS(MP_QSTR_channel): req_if = WIFI_IF_AP; val = MP_OBJ_NEW_SMALL_INT(cfg.ap.channel); break; default: goto unknown; } #undef QS // We post-check interface requirements to save on code size if (req_if >= 0) { require_if(args[0], req_if); } return val; unknown: nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "unknown config param")); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(esp_config_obj, 1, esp_config); STATIC const mp_map_elem_t wlan_if_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_active), (mp_obj_t)&esp_active_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_connect), (mp_obj_t)&esp_connect_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_disconnect), (mp_obj_t)&esp_disconnect_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_status), (mp_obj_t)&esp_status_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_scan), (mp_obj_t)&esp_scan_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_isconnected), (mp_obj_t)&esp_isconnected_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_config), (mp_obj_t)&esp_config_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_ifconfig), (mp_obj_t)&esp_ifconfig_obj }, }; STATIC MP_DEFINE_CONST_DICT(wlan_if_locals_dict, wlan_if_locals_dict_table); const mp_obj_type_t wlan_if_type = { { &mp_type_type }, .name = MP_QSTR_WLAN, .locals_dict = (mp_obj_t)&wlan_if_locals_dict, }; STATIC mp_obj_t esp_phy_mode(size_t n_args, const mp_obj_t *args) { return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_phy_mode_obj, 0, 1, esp_phy_mode); STATIC const mp_map_elem_t mp_module_network_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_network) }, { MP_OBJ_NEW_QSTR(MP_QSTR___init__), (mp_obj_t)&esp_initialize_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_WLAN), (mp_obj_t)&get_wlan_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj }, #if MODNETWORK_INCLUDE_CONSTANTS { MP_OBJ_NEW_QSTR(MP_QSTR_STA_IF), MP_OBJ_NEW_SMALL_INT(WIFI_IF_STA)}, { MP_OBJ_NEW_QSTR(MP_QSTR_AP_IF), MP_OBJ_NEW_SMALL_INT(WIFI_IF_AP)}, { MP_OBJ_NEW_QSTR(MP_QSTR_MODE_11B), MP_OBJ_NEW_SMALL_INT(WIFI_PROTOCOL_11B) }, { MP_OBJ_NEW_QSTR(MP_QSTR_MODE_11G), MP_OBJ_NEW_SMALL_INT(WIFI_PROTOCOL_11G) }, { MP_OBJ_NEW_QSTR(MP_QSTR_MODE_11N), MP_OBJ_NEW_SMALL_INT(WIFI_PROTOCOL_11N) }, { MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_OPEN), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_OPEN) }, { MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_WEP), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_WEP) }, { MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_WPA_PSK), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_WPA_PSK) }, { MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_WPA2_PSK), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_WPA2_PSK) }, { MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_WPA_WPA2_PSK), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_WPA_WPA2_PSK) }, { MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_MAX), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_MAX) }, #endif }; STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals_table); const mp_obj_module_t mp_module_network = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&mp_module_network_globals, };
SHA2017-badge/micropython-esp32
esp32/modnetwork.c
C
mit
21,601
[ 30522, 1013, 1008, 1008, 2023, 30524, 2278, 13866, 2100, 5183, 1008, 1998, 24098, 6633, 12184, 13866, 2100, 5183, 1008, 1008, 1996, 10210, 6105, 1006, 10210, 1007, 1008, 1008, 9385, 1006, 1039, 1007, 2355, 1010, 2418, 4172, 5405, 1030, 2409...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 "hex.ih" int hex_smear(su3_tuple *m_field_out, hex_parameters const *params, su3_tuple *m_field_in) { static int initialized = 0; static su3_tuple *gamma_buffer[3]; static su3_tuple *v_buffer[3]; if (!initialized) { /* Allocate consecutive memory for both of the buffers upon first instantiation */ /* Three times 4 buffers needed for compatibility purposes (similar signature to gauge_field...) */ for (int idx = 0; idx < 3; ++idx) { gamma_buffer[idx] = (su3_tuple*)malloc(sizeof(su3_tuple) * VOLUMEPLUSRAND + 1); v_buffer[idx] = (su3_tuple*)malloc(sizeof(su3_tuple) * VOLUMEPLUSRAND + 1); if ((gamma_buffer[idx] == (su3_tuple*)NULL) || (v_buffer[idx] == (su3_tuple*)NULL)) return -1; #if (defined SSE || defined SSE2 || defined SSE3) gamma_buffer[idx] = (su3_tuple*)(((unsigned long int)(gamma_buffer[idx]) + ALIGN_BASE) & ~ALIGN_BASE); v_buffer[idx] = (su3_tuple*)(((unsigned long int)(v_buffer[idx]) + ALIGN_BASE) & ~ALIGN_BASE); #endif } initialized = 1; } for (int iter = 0; iter < params->iterations; ++iter) { /* First level of contractions */ hyp_staples_exclude_two(gamma_buffer, m_field_in); stout_exclude_two(v_buffer, params->alpha[2], gamma_buffer, m_field_in); for (int idx = 0; idx < 3; ++idx) generic_exchange(v_buffer[idx], sizeof(su3_tuple)); /* Second level of contractions */ hyp_staples_exclude_one(gamma_buffer, v_buffer); stout_exclude_one(v_buffer, params->alpha[1], gamma_buffer, m_field_in); for (int idx = 0; idx < 3; ++idx) generic_exchange(v_buffer[idx], sizeof(su3_tuple)); /* Final level of contractions */ hyp_staples_exclude_none(gamma_buffer, v_buffer); stout_exclude_none(m_field_out, params->alpha[0], gamma_buffer, m_field_in); generic_exchange(m_field_out, sizeof(su3_tuple)); m_field_in = m_field_out; /* Prepare for next iteration */ } return 0; }
amabdelrehim/tmLQCD
smearing/hex_hex_smear.c
C
gpl-3.0
1,957
[ 30522, 1001, 2421, 1000, 2002, 2595, 1012, 1045, 2232, 1000, 20014, 2002, 2595, 1035, 15488, 14644, 1006, 10514, 2509, 1035, 10722, 10814, 1008, 1049, 1035, 2492, 1035, 2041, 1010, 2002, 2595, 1035, 11709, 9530, 3367, 1008, 11498, 5244, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
function Locations(){var a=this;a.id="locations",a.map=jQuery("#"+a.id),a.markers=[],a.initAddresAndMap=function(b){a.map.length&&jQuery.ajax({type:"GET",dataType:"json",url:"http://maps.googleapis.com/maps/api/geocode/json?address="+b,success:function(b){"OK"==b.status?a.initMap(b.results[0].geometry.location.lat,b.results[0].geometry.location.lng):a.initMap(40.4778838,-74.290702)}})},a.initMap=function(b,c){var d={zoom:15,center:new google.maps.LatLng(b,c),scrollwheel:!1,draggable:!1},e=new google.maps.Map(document.getElementById(a.id),d),f=new google.maps.Marker({position:new google.maps.LatLng(b,c),map:e,title:"Click to zoom"});google.maps.event.addListener(f,"click",function(){e.setZoom(8),e.setCenter(f.getPosition())})}}jQuery(document).ready(function(){var a=new Locations;a.map.length&&a.initAddresAndMap(a.map.data("address"))});
RDSergij/tm-real-estate
assets/js/locations.min.js
JavaScript
gpl-3.0
848
[ 30522, 3853, 5269, 1006, 1007, 1063, 13075, 1037, 1027, 2023, 1025, 1037, 1012, 8909, 1027, 1000, 5269, 1000, 1010, 1037, 1012, 4949, 1027, 1046, 4226, 2854, 1006, 1000, 1001, 1000, 1009, 1037, 1012, 8909, 1007, 1010, 1037, 1012, 16387, 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...
#include "NoteState.h" #include "EffectParam.h" #include "ITrackState.h" #include "PlayerState.h" #include "SDL.h" #include <math.h> NoteState::NoteState() : frequency(0), slideTarget(0), volume(0) { SDL_memset(effectMemory, 0, sizeof(effectMemory)); } void NoteState::setFrequencyFromNote(int note) { static const float ratio = powf(2.0f, 1.0f/12.0f); frequency = powf(ratio, note - (12 * 3 + 9)); } void NoteState::setSlideTargetFromNote(int note) { static const float ratio = powf(2.0f, 1.0f/12.0f); slideTarget = powf(ratio, note - (12 * 3 + 9)); } bool NoteState::handleEffectZeroTick(const EffectParam& effect, ITrackState& trackState, PlayerState& playerState) { int asByte = effect.getParamsAsByte(); switch (effect.effect) { case 'c': volume = asByte; if (volume > ITrackState::maxVolume) volume = ITrackState::maxVolume; break; case 'f': if (asByte < 0x20) playerState.songSpeed = asByte; else playerState.songRate = asByte; break; default: return trackState.handleEffectZeroTick(effect, playerState); } return false; } void NoteState::handleEffectAnyTick(const EffectParam& effect, ITrackState& trackState, PlayerState& playerState) { int param1 = effect.param1; int param2 = effect.param2; int asByte = effect.getParamsAsByte(); if (asByte != 0) effectMemory[effect.effect] = asByte; else { asByte = effectMemory[effect.effect]; param1 = (asByte >> 4) & 0xf; param2 = asByte & 0xf; } switch (effect.effect) { case 'a': volume -= param2; if (volume < 0) volume = 0; volume += param1; if (volume > ITrackState::maxVolume) volume = ITrackState::maxVolume; break; case 'k': if (asByte == playerState.tick) volume = 0; break; case '1': { frequency += (float)asByte / slideDivider; } break; case '2': { frequency -= (float)asByte / slideDivider; if (frequency < 0) frequency = 0; } break; case '3': { if (slideTarget < frequency) { frequency -= (float)asByte / slideDivider; if (frequency < slideTarget) frequency = slideTarget; } else { frequency += (float)asByte / slideDivider; if (frequency > slideTarget) frequency = slideTarget; } } break; default: trackState.handleEffectAnyTick(EffectParam(effect.effect, param1, param2), playerState); break; } }
kometbomb/prototracker
src/NoteState.cpp
C++
mit
2,449
[ 30522, 1001, 2421, 1000, 3964, 12259, 1012, 1044, 1000, 1001, 2421, 1000, 3466, 28689, 2213, 1012, 1044, 1000, 1001, 2421, 1000, 2009, 22648, 5705, 12259, 1012, 1044, 1000, 1001, 2421, 1000, 2867, 12259, 1012, 1044, 1000, 1001, 2421, 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...
var Observer = require('../../../../src/observer') var config = require('../../../../src/config') var _ = require('../../../../src/util') describe('Observer', function () { it('create on non-observables', function () { // skip primitive value var ob = Observer.create(1) expect(ob).toBeUndefined() // avoid vue instance ob = Observer.create(new _.Vue()) expect(ob).toBeUndefined() // avoid frozen objects ob = Observer.create(Object.freeze({})) expect(ob).toBeUndefined() }) it('create on object', function () { // on object var obj = { a: {}, b: {} } var ob = Observer.create(obj) expect(ob instanceof Observer).toBe(true) expect(ob.value).toBe(obj) expect(obj.__ob__).toBe(ob) // should've walked children expect(obj.a.__ob__ instanceof Observer).toBe(true) expect(obj.b.__ob__ instanceof Observer).toBe(true) // should return existing ob on already observed objects var ob2 = Observer.create(obj) expect(ob2).toBe(ob) }) it('create on array', function () { // on object var arr = [{}, {}] var ob = Observer.create(arr) expect(ob instanceof Observer).toBe(true) expect(ob.value).toBe(arr) expect(arr.__ob__).toBe(ob) // should've walked children expect(arr[0].__ob__ instanceof Observer).toBe(true) expect(arr[1].__ob__ instanceof Observer).toBe(true) }) it('observing object prop change', function () { var obj = { a: { b: 2 } } Observer.create(obj) // mock a watcher! var watcher = { deps: [], addDep: function (dep) { this.deps.push(dep) dep.addSub(this) }, update: jasmine.createSpy() } // collect dep Observer.setTarget(watcher) obj.a.b Observer.setTarget(null) expect(watcher.deps.length).toBe(3) // obj.a + a.b + b obj.a.b = 3 expect(watcher.update.calls.count()).toBe(1) // swap object obj.a = { b: 4 } expect(watcher.update.calls.count()).toBe(2) watcher.deps = [] Observer.setTarget(watcher) obj.a.b Observer.setTarget(null) expect(watcher.deps.length).toBe(3) // set on the swapped object obj.a.b = 5 expect(watcher.update.calls.count()).toBe(3) }) it('observing $add/$set/$delete', function () { var obj = { a: 1 } var ob = Observer.create(obj) var dep = ob.dep spyOn(dep, 'notify') obj.$add('b', 2) expect(obj.b).toBe(2) expect(dep.notify.calls.count()).toBe(1) obj.$delete('a') expect(obj.hasOwnProperty('a')).toBe(false) expect(dep.notify.calls.count()).toBe(2) // should ignore adding an existing key obj.$add('b', 3) expect(obj.b).toBe(2) expect(dep.notify.calls.count()).toBe(2) // set existing key, should be a plain set and not // trigger own ob's notify obj.$set('b', 3) expect(obj.b).toBe(3) expect(dep.notify.calls.count()).toBe(2) // set non-existing key obj.$set('c', 1) expect(obj.c).toBe(1) expect(dep.notify.calls.count()).toBe(3) // should ignore deleting non-existing key obj.$delete('a') expect(dep.notify.calls.count()).toBe(3) // should work on non-observed objects var obj2 = { a: 1 } obj2.$delete('a') expect(obj2.hasOwnProperty('a')).toBe(false) }) it('observing array mutation', function () { var arr = [] var ob = Observer.create(arr) var dep = ob.dep spyOn(dep, 'notify') var objs = [{}, {}, {}] arr.push(objs[0]) arr.pop() arr.unshift(objs[1]) arr.shift() arr.splice(0, 0, objs[2]) arr.sort() arr.reverse() expect(dep.notify.calls.count()).toBe(7) // inserted elements should be observed objs.forEach(function (obj) { expect(obj.__ob__ instanceof Observer).toBe(true) }) }) it('array $set', function () { var arr = [1] var ob = Observer.create(arr) var dep = ob.dep spyOn(dep, 'notify') arr.$set(0, 2) expect(arr[0]).toBe(2) expect(dep.notify.calls.count()).toBe(1) // setting out of bound index arr.$set(2, 3) expect(arr[2]).toBe(3) expect(dep.notify.calls.count()).toBe(2) }) it('array $remove', function () { var arr = [{}, {}] var obj1 = arr[0] var obj2 = arr[1] var ob = Observer.create(arr) var dep = ob.dep spyOn(dep, 'notify') // remove by index arr.$remove(0) expect(arr.length).toBe(1) expect(arr[0]).toBe(obj2) expect(dep.notify.calls.count()).toBe(1) // remove by identity, not in array arr.$remove(obj1) expect(arr.length).toBe(1) expect(arr[0]).toBe(obj2) expect(dep.notify.calls.count()).toBe(1) // remove by identity, in array arr.$remove(obj2) expect(arr.length).toBe(0) expect(dep.notify.calls.count()).toBe(2) }) it('no proto', function () { config.proto = false // object var obj = {a: 1} var ob = Observer.create(obj) expect(obj.$add).toBeTruthy() expect(obj.$delete).toBeTruthy() var dep = ob.dep spyOn(dep, 'notify') obj.$add('b', 2) expect(dep.notify).toHaveBeenCalled() // array var arr = [1, 2, 3] var ob2 = Observer.create(arr) expect(arr.$set).toBeTruthy() expect(arr.$remove).toBeTruthy() expect(arr.push).not.toBe([].push) var dep2 = ob2.dep spyOn(dep2, 'notify') arr.push(1) expect(dep2.notify).toHaveBeenCalled() config.proto = true }) })
coopsource/vue
test/unit/specs/observer/observer_spec.js
JavaScript
mit
5,426
[ 30522, 13075, 9718, 1027, 5478, 1006, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 1012, 1012, 1013, 5034, 2278, 1013, 9718, 1005, 1007, 13075, 9530, 8873, 2290, 1027, 5478, 1006, 1005, 1012, 1012, 1013, 1012, 1012, 1013, 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...
import tkinter FRAME_BORDER = 5 class PageView(object): __root = None bd = None def __init__(self, root=None, main_frame=None): param = self.params() if root is None: # standalone self.__root = tkinter.Tk() self.__root.title(param['title']) self.__root.geometry('%sx%s+%s+%s' % (param['w'], param['h'], param['x'], param['y'] )) else: # inside self.__root = root self.bd = param['bd'] if main_frame is None: # standalone main_f = tkinter.Frame(master=self.__root, bg='black', bd=self.bd) main_f.pack(fill='both', expand=True) else: # inside main_f = main_frame self.make_widgets(main_f) @property def root(self): return self.__root def close(self): self.__root.destroy() self.__root.quit() # Override def make_widgets(self, main_frame): pass # Override def params(self): param = { 'x': 0, 'y': 0, 'w': 500, 'h': 500, 'title': '% Type Prog Title Here %', } return param def mk_scrollable_area(obj, obj_frame, sbars): obj.grid(row=0, column=0, sticky='NSWE') if 'y' in sbars: y_scrollbar = tkinter.ttk.Scrollbar(obj_frame) y_scrollbar.grid(row=0, column=1, sticky='NS') y_scrollbar['command'] = obj.yview obj['yscrollcommand'] = y_scrollbar.set if 'x' in sbars: x_scrollbar = tkinter.ttk.Scrollbar(obj_frame, orient='horizontal') x_scrollbar.grid(row=1, column=0, sticky='WE') x_scrollbar['command'] = obj.xview obj['xscrollcommand'] = x_scrollbar.set obj_frame.columnconfigure(1, 'minsize') obj_frame.columnconfigure(0, weight=1) obj_frame.rowconfigure(1, 'minsize') obj_frame.rowconfigure(0, weight=1) def mk_listbox(frame, side='top', sbars='y', sel_mode=tkinter.EXTENDED): BORDER = 0 COLOR = 'grey' listbox_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) listbox_frame.pack(side=side, fill='both', expand=True) listbox = tkinter.Listbox(listbox_frame, selectmode=sel_mode) mk_scrollable_area(listbox, listbox_frame, sbars) return listbox def mk_treeview(frame, side='top', sbars='y'): BORDER = 0 COLOR = 'grey' treeview_frame = tkinter.Frame(frame, bg=COLOR, bd=BORDER) treeview_frame.pack(side=side, fill='both', expand=True) treeview = tkinter.ttk.Treeview(treeview_frame) mk_scrollable_area(treeview, treeview_frame, sbars) return treeview
sora7/listparse
src/listparse/ui/common.py
Python
gpl-2.0
2,865
[ 30522, 12324, 1056, 4939, 3334, 4853, 1035, 3675, 1027, 1019, 2465, 3931, 8584, 1006, 4874, 1007, 1024, 1035, 1035, 7117, 1027, 3904, 1038, 2094, 1027, 3904, 13366, 1035, 1035, 1999, 4183, 1035, 1035, 1006, 2969, 1010, 7117, 1027, 3904, 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...
/*------------------------------------------------------------------- Copyright 2012 Ravishankar Sundararaman This file is part of JDFTx. JDFTx 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. JDFTx 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 JDFTx. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------*/ #ifndef JDFTX_ELECTRONIC_SPECIESINFO_INTERNAL_H #define JDFTX_ELECTRONIC_SPECIESINFO_INTERNAL_H //!@file SpeciesInfo_internal.h Shared GPU/CPU code for ion/pseudopotential related calculations #include <core/matrix3.h> #include <electronic/RadialFunction.h> #include <electronic/SphericalHarmonics.h> #include <stdint.h> //! Compute Vnl and optionally its gradients for a subset of the basis space, and for multiple atomic positions template<int l, int m> __hostanddev__ void Vnl_calc(int n, int atomStride, int nAtoms, const vector3<>& k, const vector3<int>* iGarr, const matrix3<>& G, const vector3<>* pos, const RadialFunctionG& VnlRadial, complex* Vnl) { vector3<> kpG = k + iGarr[n]; //k+G in reciprocal lattice coordinates: vector3<> qvec = kpG * G; //k+G in cartesian coordinates double q = qvec.length(); vector3<> qhat = qvec * (q ? 1.0/q : 0.0); //the unit vector along qvec (set qhat to 0 for q=0 (doesn't matter)) double prefac = Ylm<l,m>(qhat) * VnlRadial(q); //prefactor to structure factor //Loop over columns (multiple atoms at same l,m): for(int atom=0; atom<nAtoms; atom++) Vnl[atom*atomStride+n] = prefac * cis((-2*M_PI)*dot(pos[atom],kpG)); } void Vnl(int nbasis, int atomStride, int nAtoms, int l, int m, const vector3<> k, const vector3<int>* iGarr, const matrix3<> G, const vector3<>* pos, const RadialFunctionG& VnlRadial, complex* Vnl); #ifdef GPU_ENABLED void Vnl_gpu(int nbasis, int atomStride, int nAtoms, int l, int m, const vector3<> k, const vector3<int>* iGarr, const matrix3<> G, const vector3<>* pos, const RadialFunctionG& VnlRadial, complex* Vnl); #endif //! Perform the loop: //! for(lm=0; lm < Nlm; lm++) (*f)(tag< lm >); //! at compile time using templates. Note with lm := l*(l+1)+m to loop over spherical harmonics, Nlm = (lMax+1)^2. //! The functor f is templated over lm by using the tag class StaticLoopYlmTag< lm >. template<int lm> struct StaticLoopYlmTag{}; template<int Nlm, typename Functor, int lmInv> struct StaticLoopYlm { __hostanddev__ static void exec(Functor* f) { (*f)(StaticLoopYlmTag<Nlm-lmInv>()); StaticLoopYlm< Nlm, Functor, lmInv-1 >::exec(f); } }; template<int Nlm, typename Functor> struct StaticLoopYlm< Nlm, Functor, 0> { __hostanddev__ static void exec(Functor* f) { return; } }; template<int Nlm, typename Functor> __hostanddev__ void staticLoopYlm(Functor* f) { StaticLoopYlm< Nlm, Functor, Nlm >::exec(f); } #define SwitchTemplate_Nlm(Nlm, func, args) \ switch(Nlm) \ { case 1: func<1> args; break; \ case 4: func<4> args; break; \ case 9: func<9> args; break; \ case 16: func<16> args; break; \ case 25: func<25> args; break; \ case 49: func<49> args; break; \ default: fprintf(stderr, "Invalid Nlm in SwitchTemplate_Nlm"); exit(1); \ } //! Augment electron density by spherical functions (radial functions multiplied by spherical harmonics) //! and propagate gradient w.r.t to it to that w.r.t the atom position (accumulate) //! (In MPI mode, each process only collects contributions for a subset of G-vectors) struct nAugmentFunctor { vector3<> qhat; double q; int nCoeff; double dGinv; const double* nRadial; complex n; __hostanddev__ nAugmentFunctor(const vector3<>& qvec, int nCoeff, double dGinv, const double* nRadial) : nCoeff(nCoeff), dGinv(dGinv), nRadial(nRadial) { q = qvec.length(); qhat = qvec * (q ? 1.0/q : 0.0); //the unit vector along qvec (set qhat to 0 for q=0 (doesn't matter)) } template<int lm> __hostanddev__ void operator()(const StaticLoopYlmTag<lm>&) { //Compute phase (-i)^l: complex mIota(0,-1), phase(1,0); for(int l=0; l*(l+2) < lm; l++) phase *= mIota; //Accumulate result: double Gindex = q * dGinv; if(Gindex < nCoeff-5) n += phase * Ylm<lm>(qhat) * QuinticSpline::value(nRadial+lm*nCoeff, Gindex); } }; template<int Nlm> __hostanddev__ void nAugment_calc(int i, const vector3<int>& iG, const matrix3<>& G, int nCoeff, double dGinv, const double* nRadial, const vector3<>& atpos, complex* n) { nAugmentFunctor functor(iG*G, nCoeff, dGinv, nRadial); staticLoopYlm<Nlm>(&functor); n[i] += functor.n * cis((-2*M_PI)*dot(atpos,iG)); } void nAugment(int Nlm, const vector3<int> S, const matrix3<>& G, int iGstart, int iGstop, int nCoeff, double dGinv, const double* nRadial, const vector3<>& atpos, complex* n); #ifdef GPU_ENABLED void nAugment_gpu(int Nlm, const vector3<int> S, const matrix3<>& G, int iGstart, int iGstop, int nCoeff, double dGinv, const double* nRadial, const vector3<>& atpos, complex* n); #endif //Function for initializing the index arrays used by nAugmentGrad //! (In MPI mode, only a subset of G-vectors are indexed on each process (to correspond to nAUgment)) __hostanddev__ uint64_t setNagIndex_calc(const vector3<int>& iG, const vector3<int>& S, const matrix3<>& G, double dGinv) { uint64_t Gindex = uint64_t((iG*G).length() * dGinv); vector3<int> iv = iG; for(int k=0; k<3; k++) if(iv[k]<0) iv[k] += S[k]; return (Gindex << 48) //Putting Gindex in the higher word allows sorting by it first, and then by grid point index + (uint64_t(iv[0]) << 32) + (uint64_t(iv[1]) << 16) + uint64_t(iv[2]); } __hostanddev__ void setNagIndexPtr_calc(int i, int iMax, int nCoeff, const uint64_t* nagIndex, size_t* nagIndexPtr) { int Gindex = int(nagIndex[i] >> 48); int GindexNext = (i+1<iMax) ? int(nagIndex[i+1] >> 48) : nCoeff; if(i==0) for(int j=0; j<=Gindex; j++) nagIndexPtr[j] = 0; for(int j=Gindex; j<GindexNext; j++) nagIndexPtr[j+1] = i+1; } void setNagIndex(const vector3<int>& S, const matrix3<>& G, int iGstart, int iGstop, int nCoeff, double dGinv, uint64_t*& nagIndex, size_t*& nagIndexPtr); #ifdef GPU_ENABLED void setNagIndex_gpu(const vector3<int>& S, const matrix3<>& G, int iGstart, int iGstop, int nCoeff, double dGinv, uint64_t*& nagIndex, size_t*& nagIndexPtr); #endif //Gradient propragation corresponding to nAugment: //(The MPI division happens implicitly here, because nagIndex is limited to each process's share (see above)) struct nAugmentGradFunctor { vector3<> qhat; double q; int nCoeff; double dGinv; const double* nRadial; complex E_n, nE_n; double* E_nRadial; int dotPrefac; //prefactor in dot-product (1 or 2 for each reciprocal space point, because of real symmetry) __hostanddev__ nAugmentGradFunctor(const vector3<>& qvec, int nCoeff, double dGinv, const double* nRadial, const complex& E_n, double* E_nRadial, int dotPrefac) : nCoeff(nCoeff), dGinv(dGinv), nRadial(nRadial), E_n(E_n), E_nRadial(E_nRadial), dotPrefac(dotPrefac) { q = qvec.length(); qhat = qvec * (q ? 1.0/q : 0.0); //the unit vector along qvec (set qhat to 0 for q=0 (doesn't matter)) } template<int lm> __hostanddev__ void operator()(const StaticLoopYlmTag<lm>&) { //Compute phase (-i)^l: complex mIota(0,-1), phase(1,0); for(int l=0; l*(l+2) < lm; l++) phase *= mIota; //Accumulate result: double Gindex = q * dGinv; if(Gindex < nCoeff-5) { complex term = phase * Ylm<lm>(qhat) * E_n; QuinticSpline::valueGrad(dotPrefac * term.real(), E_nRadial+lm*nCoeff, Gindex); if(nRadial) nE_n += term * QuinticSpline::value(nRadial+lm*nCoeff, Gindex); //needed again only when computing forces } } }; template<int Nlm> __hostanddev__ void nAugmentGrad_calc(uint64_t key, const vector3<int>& S, const matrix3<>& G, int nCoeff, double dGinv, const double* nRadial, const vector3<>& atpos, const complex* ccE_n, double* E_nRadial, vector3<complex*> E_atpos, bool dummyGpuThread=false) { //Obtain 3D index iG and array offset i for this point (similar to COMPUTE_halfGindices) vector3<int> iG; iG[2] = int(0xFFFF & key); key >>= 16; iG[1] = int(0xFFFF & key); key >>= 16; iG[0] = int(0xFFFF & key); size_t i = iG[2] + (S[2]/2+1)*size_t(iG[1] + S[1]*iG[0]); for(int j=0; j<3; j++) if(2*iG[j]>S[j]) iG[j]-=S[j]; int dotPrefac = (iG[2]==0||2*iG[2]==S[2]) ? 1 : 2; nAugmentGradFunctor functor(iG*G, nCoeff, dGinv, nRadial, dummyGpuThread ? complex() : ccE_n[i].conj() * cis((-2*M_PI)*dot(atpos,iG)), E_nRadial, dotPrefac); staticLoopYlm<Nlm>(&functor); if(nRadial && !dummyGpuThread) accumVector((functor.nE_n * complex(0,-2*M_PI)) * iG, E_atpos, i); } void nAugmentGrad(int Nlm, const vector3<int> S, const matrix3<>& G, int nCoeff, double dGinv, const double* nRadial, const vector3<>& atpos, const complex* ccE_n, double* E_nRadial, vector3<complex*> E_atpos, const uint64_t* nagIndex, const size_t* nagIndexPtr); #ifdef GPU_ENABLED void nAugmentGrad_gpu(int Nlm, const vector3<int> S, const matrix3<>& G, int nCoeff, double dGinv, const double* nRadial, const vector3<>& atpos, const complex* ccE_n, double* E_nRadial, vector3<complex*> E_atpos, const uint64_t* nagIndex, const size_t* nagIndexPtr); #endif //!Get structure factor for a specific iG, given a list of atoms __hostanddev__ complex getSG_calc(const vector3<int>& iG, const int& nAtoms, const vector3<>* atpos) { complex SG = complex(0,0); for(int atom=0; atom<nAtoms; atom++) SG += cis(-2*M_PI*dot(iG,atpos[atom])); return SG; } //!Get structure factor in a ScalarFieldTilde's data/dataGpu (with 1/vol normalization factor) void getSG(const vector3<int> S, int nAtoms, const vector3<>* atpos, double invVol, complex* SG); #ifdef GPU_ENABLED void getSG_gpu(const vector3<int> S, int nAtoms, const vector3<>* atpos, double invVol, complex* SG); #endif //! Calculate local pseudopotential, ionic density and chargeball due to one species at a given G-vector __hostanddev__ void updateLocal_calc(int i, const vector3<int>& iG, const matrix3<>& GGT, complex *Vlocps, complex *rhoIon, complex *nChargeball, complex* nCore, complex* tauCore, int nAtoms, const vector3<>* atpos, double invVol, const RadialFunctionG& VlocRadial, double Z, const RadialFunctionG& nCoreRadial, const RadialFunctionG& tauCoreRadial, double Zchargeball, double wChargeball) { double Gsq = GGT.metric_length_squared(iG); //Compute structure factor (scaled by 1/detR): complex SGinvVol = getSG_calc(iG, nAtoms, atpos) * invVol; //Short-ranged part of Local potential (long-ranged part added on later in IonInfo.cpp): Vlocps[i] += SGinvVol * VlocRadial(sqrt(Gsq)); //Nuclear charge (optionally widened to a gaussian later in IonInfo.cpp): rhoIon[i] += SGinvVol * (-Z); //Chargeball: if(nChargeball) nChargeball[i] += SGinvVol * Zchargeball * exp(-0.5*Gsq*pow(wChargeball,2)); //Partial core: if(nCore) nCore[i] += SGinvVol * nCoreRadial(sqrt(Gsq)); if(tauCore) tauCore[i] += SGinvVol * tauCoreRadial(sqrt(Gsq)); } void updateLocal(const vector3<int> S, const matrix3<> GGT, complex *Vlocps, complex *rhoIon, complex *n_chargeball, complex* n_core, complex* tauCore, int nAtoms, const vector3<>* atpos, double invVol, const RadialFunctionG& VlocRadial, double Z, const RadialFunctionG& nCoreRadial, const RadialFunctionG& tauCoreRadial, double Zchargeball, double wChargeball); #ifdef GPU_ENABLED void updateLocal_gpu(const vector3<int> S, const matrix3<> GGT, complex *Vlocps, complex *rhoIon, complex *n_chargeball, complex* n_core, complex* tauCore, int nAtoms, const vector3<>* atpos, double invVol, const RadialFunctionG& VlocRadial, double Z, const RadialFunctionG& nCoreRadial, const RadialFunctionG& tauCoreRadial, double Zchargeball, double wChargeball); #endif //! Propagate (complex conjugates of) gradients w.r.t Vlocps, rhoIon etc to complex conjugate gradient w.r.t SG (the strutcure factor) __hostanddev__ void gradLocalToSG_calc(int i, const vector3<int> iG, const matrix3<> GGT, const complex* ccgrad_Vlocps, const complex* ccgrad_rhoIon, const complex* ccgrad_nChargeball, const complex* ccgrad_nCore, const complex* ccgrad_tauCore, complex* ccgrad_SG, const RadialFunctionG& VlocRadial, double Z, const RadialFunctionG& nCoreRadial, const RadialFunctionG& tauCoreRadial, double Zchargeball, double wChargeball) { double Gsq = GGT.metric_length_squared(iG); complex ccgrad_SGinvVol(0,0); //result for this G value (gradient w.r.t structure factor/volume) //Local potential (short ranged part in the radial function - Z/r): ccgrad_SGinvVol += ccgrad_Vlocps[i] * VlocRadial(sqrt(Gsq)); //Nuclear charge if(ccgrad_rhoIon) ccgrad_SGinvVol += ccgrad_rhoIon[i] * (-Z); //Chargeball: if(ccgrad_nChargeball) ccgrad_SGinvVol += ccgrad_nChargeball[i] * Zchargeball * exp(-0.5*Gsq*pow(wChargeball,2)); //Partial core: if(ccgrad_nCore) ccgrad_SGinvVol += ccgrad_nCore[i] * nCoreRadial(sqrt(Gsq)); if(ccgrad_tauCore) ccgrad_SGinvVol += ccgrad_tauCore[i] * tauCoreRadial(sqrt(Gsq)); //Store result: ccgrad_SG[i] = ccgrad_SGinvVol; } void gradLocalToSG(const vector3<int> S, const matrix3<> GGT, const complex* ccgrad_Vlocps, const complex* ccgrad_rhoIon, const complex* ccgrad_nChargeball, const complex* ccgrad_nCore, const complex* ccgrad_tauCore, complex* ccgrad_SG, const RadialFunctionG& VlocRadial, double Z, const RadialFunctionG& nCoreRadial, const RadialFunctionG& tauCoreRadial, double Zchargeball, double wChargeball); #ifdef GPU_ENABLED void gradLocalToSG_gpu(const vector3<int> S, const matrix3<> GGT, const complex* ccgrad_Vlocps, const complex* ccgrad_rhoIon, const complex* ccgrad_nChargeball, const complex* ccgrad_nCore, const complex* ccgrad_tauCore, complex* ccgrad_SG, const RadialFunctionG& VlocRadial, double Z, const RadialFunctionG& nCoreRadial, const RadialFunctionG& tauCoreRadial, double Zchargeball, double wChargeball); #endif //! Propagate the complex conjugate gradient w.r.t the structure factor to the given atomic position //! this is still per G-vector, need to sum grad_atpos over G to get the force on that atom __hostanddev__ void gradSGtoAtpos_calc(int i, const vector3<int> iG, const vector3<> atpos, const complex* ccgrad_SG, vector3<complex*> grad_atpos) { complex term = complex(0,-2*M_PI) * cis(-2*M_PI*dot(iG,atpos)) * ccgrad_SG[i].conj(); storeVector(iG * term, grad_atpos, i); } void gradSGtoAtpos(const vector3<int> S, const vector3<> atpos, const complex* ccgrad_SG, vector3<complex*> grad_atpos); #ifdef GPU_ENABLED void gradSGtoAtpos_gpu(const vector3<int> S, const vector3<> atpos, const complex* ccgrad_SG, vector3<complex*> grad_atpos); #endif #endif // JDFTX_ELECTRONIC_SPECIESINFO_INTERNAL_H
yalcinozhabes/pythonJDFTx
jdftx/electronic/SpeciesInfo_internal.h
C
gpl-2.0
14,933
[ 30522, 1013, 1008, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 origin import ( "crypto/md5" "crypto/x509" "fmt" "net/url" "code.google.com/p/go-uuid/uuid" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" "github.com/projectatomic/atomic-enterprise/pkg/auth/server/session" configapi "github.com/projectatomic/atomic-enterprise/pkg/cmd/server/api" "github.com/projectatomic/atomic-enterprise/pkg/cmd/server/api/latest" "github.com/projectatomic/atomic-enterprise/pkg/cmd/server/etcd" identityregistry "github.com/projectatomic/atomic-enterprise/pkg/user/registry/identity" identityetcd "github.com/projectatomic/atomic-enterprise/pkg/user/registry/identity/etcd" userregistry "github.com/projectatomic/atomic-enterprise/pkg/user/registry/user" useretcd "github.com/projectatomic/atomic-enterprise/pkg/user/registry/user/etcd" ) type AuthConfig struct { Options configapi.OAuthConfig // TODO: possibly change to point to MasterConfig's version OpenshiftEnabled bool // AssetPublicAddresses contains valid redirectURI prefixes to direct browsers to the web console AssetPublicAddresses []string MasterRoots *x509.CertPool EtcdHelper tools.EtcdHelper UserRegistry userregistry.Registry IdentityRegistry identityregistry.Registry SessionAuth *session.Authenticator } func BuildAuthConfig(options configapi.MasterConfig) (*AuthConfig, error) { client, err := etcd.GetAndTestEtcdClient(options.EtcdClientInfo) if err != nil { return nil, err } etcdHelper, err := NewEtcdHelper(client, options.EtcdStorageConfig.OpenShiftStorageVersion, options.EtcdStorageConfig.OpenShiftStoragePrefix) if err != nil { return nil, fmt.Errorf("Error setting up server storage: %v", err) } apiServerCAs, err := configapi.GetAPIServerCertCAPool(options) if err != nil { return nil, err } var sessionAuth *session.Authenticator if options.OAuthConfig.SessionConfig != nil { secure := isHTTPS(options.OAuthConfig.MasterPublicURL) auth, err := BuildSessionAuth(secure, options.OAuthConfig.SessionConfig) if err != nil { return nil, err } sessionAuth = auth } // Build the list of valid redirect_uri prefixes for a login using the openshift-web-console client to redirect to // TODO: allow configuring this // TODO: remove hard-coding of development UI server assetPublicURLs := []string{options.OAuthConfig.AssetPublicURL, "http://localhost:9000", "https://localhost:9000"} userStorage := useretcd.NewREST(etcdHelper) userRegistry := userregistry.NewRegistry(userStorage) identityStorage := identityetcd.NewREST(etcdHelper) identityRegistry := identityregistry.NewRegistry(identityStorage) ret := &AuthConfig{ Options: *options.OAuthConfig, OpenshiftEnabled: options.OpenshiftEnabled, AssetPublicAddresses: assetPublicURLs, MasterRoots: apiServerCAs, EtcdHelper: etcdHelper, IdentityRegistry: identityRegistry, UserRegistry: userRegistry, SessionAuth: sessionAuth, } return ret, nil } func BuildSessionAuth(secure bool, config *configapi.SessionConfig) (*session.Authenticator, error) { secrets, err := getSessionSecrets(config.SessionSecretsFile) if err != nil { return nil, err } sessionStore := session.NewStore(secure, int(config.SessionMaxAgeSeconds), secrets...) return session.NewAuthenticator(sessionStore, config.SessionName), nil } func getSessionSecrets(filename string) ([]string, error) { // Build secrets list secrets := []string{} if len(filename) != 0 { sessionSecrets, err := latest.ReadSessionSecrets(filename) if err != nil { return nil, fmt.Errorf("error reading sessionSecretsFile %s: %v", filename, err) } if len(sessionSecrets.Secrets) == 0 { return nil, fmt.Errorf("sessionSecretsFile %s contained no secrets", filename) } for _, s := range sessionSecrets.Secrets { secrets = append(secrets, s.Authentication) secrets = append(secrets, s.Encryption) } } else { // Generate random signing and encryption secrets if none are specified in config secrets = append(secrets, fmt.Sprintf("%x", md5.Sum([]byte(uuid.NewRandom().String())))) secrets = append(secrets, fmt.Sprintf("%x", md5.Sum([]byte(uuid.NewRandom().String())))) } return secrets, nil } // isHTTPS returns true if the given URL is a valid https URL func isHTTPS(u string) bool { parsedURL, err := url.Parse(u) return err == nil && parsedURL.Scheme == "https" }
marsmensch/atomic-enterprise
pkg/cmd/server/origin/auth_config.go
GO
apache-2.0
4,367
[ 30522, 7427, 4761, 12324, 1006, 1000, 19888, 2080, 1013, 9108, 2629, 1000, 1000, 19888, 2080, 1013, 1060, 12376, 2683, 1000, 1000, 4718, 2102, 1000, 1000, 5658, 1013, 24471, 2140, 1000, 1000, 3642, 1012, 8224, 1012, 4012, 1013, 1052, 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...
package test; import static org.junit.Assert.*; import java.text.DateFormat; import java.util.Date; import org.junit.Test; public class A{ void say(){ System.out.println("A"); } }
spartan2015/kata
test/src/main/java/test/A.java
Java
gpl-3.0
196
[ 30522, 7427, 3231, 1025, 12324, 10763, 8917, 1012, 12022, 4183, 1012, 20865, 1012, 1008, 1025, 12324, 9262, 1012, 3793, 1012, 3058, 14192, 4017, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 3058, 1025, 12324, 8917, 1012, 12022, 4183, 1012, 3...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
// mgo - MongoDB driver for Go // // Copyright (c) 2014 - Gustavo Niemeyer <gustavo@niemeyer.net> // // 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. // Pacakage scram implements a SCRAM-{SHA-1,etc} client per RFC5802. // // http://tools.ietf.org/html/rfc5802 // package scram import ( "bytes" "crypto/hmac" "crypto/rand" "encoding/base64" "fmt" "hash" "strconv" "strings" ) // Client implements a SCRAM-* client (SCRAM-SHA-1, SCRAM-SHA-256, etc). // // A Client may be used within a SASL conversation with logic resembling: // // var in []byte // var client = scram.NewClient(sha1.New, user, pass) // for client.Step(in) { // out := client.Out() // // send out to server // in := serverOut // } // if client.Err() != nil { // // auth failed // } // type Client struct { newHash func() hash.Hash user string pass string step int out bytes.Buffer err error clientNonce []byte serverNonce []byte saltedPass []byte authMsg bytes.Buffer } // NewClient returns a new SCRAM-* client with the provided hash algorithm. // // For SCRAM-SHA-1, for example, use: // // client := scram.NewClient(sha1.New, user, pass) // func NewClient(newHash func() hash.Hash, user, pass string) *Client { c := &Client{ newHash: newHash, user: user, pass: pass, } c.out.Grow(256) c.authMsg.Grow(256) return c } // Out returns the data to be sent to the server in the current step. func (c *Client) Out() []byte { if c.out.Len() == 0 { return nil } return c.out.Bytes() } // Err returns the error that ocurred, or nil if there were no errors. func (c *Client) Err() error { return c.err } // SetNonce sets the client nonce to the provided value. // If not set, the nonce is generated automatically out of crypto/rand on the first step. func (c *Client) SetNonce(nonce []byte) { c.clientNonce = nonce } var escaper = strings.NewReplacer("=", "=3D", ",", "=2C") // Step processes the incoming data from the server and makes the // next round of data for the server available via Client.Out. // Step returns false if there are no errors and more data is // still expected. func (c *Client) Step(in []byte) bool { c.out.Reset() if c.step > 2 || c.err != nil { return false } c.step++ switch c.step { case 1: c.err = c.step1(in) case 2: c.err = c.step2(in) case 3: c.err = c.step3(in) } return c.step > 2 || c.err != nil } func (c *Client) step1(in []byte) error { if len(c.clientNonce) == 0 { const nonceLen = 6 buf := make([]byte, nonceLen+b64.EncodedLen(nonceLen)) if _, err := rand.Read(buf[:nonceLen]); err != nil { return fmt.Errorf("cannot read random SCRAM-SHA-1 nonce from operating system: %v", err) } c.clientNonce = buf[nonceLen:] b64.Encode(c.clientNonce, buf[:nonceLen]) } c.authMsg.WriteString("n=") escaper.WriteString(&c.authMsg, c.user) c.authMsg.WriteString(",r=") c.authMsg.Write(c.clientNonce) c.out.WriteString("n,,") c.out.Write(c.authMsg.Bytes()) return nil } var b64 = base64.StdEncoding func (c *Client) step2(in []byte) error { c.authMsg.WriteByte(',') c.authMsg.Write(in) fields := bytes.Split(in, []byte(",")) if len(fields) != 3 { return fmt.Errorf("expected 3 fields in first SCRAM-SHA-1 server message, got %d: %q", len(fields), in) } if !bytes.HasPrefix(fields[0], []byte("r=")) || len(fields[0]) < 2 { return fmt.Errorf("server sent an invalid SCRAM-SHA-1 nonce: %q", fields[0]) } if !bytes.HasPrefix(fields[1], []byte("s=")) || len(fields[1]) < 6 { return fmt.Errorf("server sent an invalid SCRAM-SHA-1 salt: %q", fields[1]) } if !bytes.HasPrefix(fields[2], []byte("i=")) || len(fields[2]) < 6 { return fmt.Errorf("server sent an invalid SCRAM-SHA-1 iteration count: %q", fields[2]) } c.serverNonce = fields[0][2:] if !bytes.HasPrefix(c.serverNonce, c.clientNonce) { return fmt.Errorf("server SCRAM-SHA-1 nonce is not prefixed by client nonce: got %q, want %q+\"...\"", c.serverNonce, c.clientNonce) } salt := make([]byte, b64.DecodedLen(len(fields[1][2:]))) n, err := b64.Decode(salt, fields[1][2:]) if err != nil { return fmt.Errorf("cannot decode SCRAM-SHA-1 salt sent by server: %q", fields[1]) } salt = salt[:n] iterCount, err := strconv.Atoi(string(fields[2][2:])) if err != nil { return fmt.Errorf("server sent an invalid SCRAM-SHA-1 iteration count: %q", fields[2]) } c.saltPassword(salt, iterCount) c.authMsg.WriteString(",c=biws,r=") c.authMsg.Write(c.serverNonce) c.out.WriteString("c=biws,r=") c.out.Write(c.serverNonce) c.out.WriteString(",p=") c.out.Write(c.clientProof()) return nil } func (c *Client) step3(in []byte) error { var isv, ise bool var fields = bytes.Split(in, []byte(",")) if len(fields) == 1 { isv = bytes.HasPrefix(fields[0], []byte("v=")) ise = bytes.HasPrefix(fields[0], []byte("e=")) } if ise { return fmt.Errorf("SCRAM-SHA-1 authentication error: %s", fields[0][2:]) } else if !isv { return fmt.Errorf("unsupported SCRAM-SHA-1 final message from server: %q", in) } if !bytes.Equal(c.serverSignature(), fields[0][2:]) { return fmt.Errorf("cannot authenticate SCRAM-SHA-1 server signature: %q", fields[0][2:]) } return nil } func (c *Client) saltPassword(salt []byte, iterCount int) { mac := hmac.New(c.newHash, []byte(c.pass)) mac.Write(salt) mac.Write([]byte{0, 0, 0, 1}) ui := mac.Sum(nil) hi := make([]byte, len(ui)) copy(hi, ui) for i := 1; i < iterCount; i++ { mac.Reset() mac.Write(ui) mac.Sum(ui[:0]) for j, b := range ui { hi[j] ^= b } } c.saltedPass = hi } func (c *Client) clientProof() []byte { mac := hmac.New(c.newHash, c.saltedPass) mac.Write([]byte("Client Key")) clientKey := mac.Sum(nil) hash := c.newHash() hash.Write(clientKey) storedKey := hash.Sum(nil) mac = hmac.New(c.newHash, storedKey) mac.Write(c.authMsg.Bytes()) clientProof := mac.Sum(nil) for i, b := range clientKey { clientProof[i] ^= b } clientProof64 := make([]byte, b64.EncodedLen(len(clientProof))) b64.Encode(clientProof64, clientProof) return clientProof64 } func (c *Client) serverSignature() []byte { mac := hmac.New(c.newHash, c.saltedPass) mac.Write([]byte("Server Key")) serverKey := mac.Sum(nil) mac = hmac.New(c.newHash, serverKey) mac.Write(c.authMsg.Bytes()) serverSignature := mac.Sum(nil) encoded := make([]byte, b64.EncodedLen(len(serverSignature))) b64.Encode(encoded, serverSignature) return encoded }
nildev/prj-tpl-basic-api
vendor/gopkg.in/mgo.v2/internal/scram/scram.go
GO
mit
7,708
[ 30522, 1013, 1013, 11460, 2080, 1011, 12256, 3995, 18939, 4062, 2005, 2175, 1013, 1013, 1013, 1013, 9385, 1006, 1039, 1007, 2297, 1011, 24801, 9152, 21382, 10532, 1026, 24801, 1030, 9152, 21382, 10532, 1012, 5658, 1028, 1013, 1013, 1013, 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...
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * Copyright 2004-2008 Analog Devices Inc. * * Licensed under the GPL-2 or later. */ #ifndef _UAPI_BFIN_SIGINFO_H #define _UAPI_BFIN_SIGINFO_H #include <linux/types.h> #include <asm-generic/siginfo.h> #define UID16_SIGINFO_COMPAT_NEEDED #define si_uid16 _sifields._kill._uid #define ILL_ILLPARAOP 2 /* illegal opcode combine ********** */ #define ILL_ILLEXCPT 4 /* unrecoverable exception ********** */ #define ILL_CPLB_VI 9 /* D/I CPLB protect violation ******** */ #define ILL_CPLB_MISS 10 /* D/I CPLB miss ******** */ #define ILL_CPLB_MULHIT 11 /* D/I CPLB multiple hit ******** */ #undef NSIGILL #define NSIGILL 11 /* * SIGBUS si_codes */ #define BUS_OPFETCH 4 /* error from instruction fetch ******** */ #undef NSIGBUS #define NSIGBUS 4 /* * SIGTRAP si_codes */ #define TRAP_STEP 1 /* single-step breakpoint************* */ #define TRAP_TRACEFLOW 2 /* trace buffer overflow ************* */ #define TRAP_WATCHPT 3 /* watchpoint match ************* */ #define TRAP_ILLTRAP 4 /* illegal trap ************* */ #undef NSIGTRAP #define NSIGTRAP 4 /* * SIGSEGV si_codes */ #define SEGV_STACKFLOW 3 /* stack overflow */ #undef NSIGSEGV #define NSIGSEGV 3 #endif /* _UAPI_BFIN_SIGINFO_H */
BPI-SINOVOIP/BPI-Mainline-kernel
linux-4.14/arch/blackfin/include/uapi/asm/siginfo.h
C
gpl-2.0
1,295
[ 30522, 1013, 1008, 30524, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1016, 1012, 1014, 1009, 2007, 11603, 1011, 25353, 15782, 3363, 1011, 3602, 1008, 1013, 1013, 1008, 1008, 9385, 2432, 1011, 2263, 11698, 5733, 4297, 1012, 1008, 1008...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 BookingsController < ApplicationController respond_to :html, :json before_action :find_booking, except: [:create, :index] def index @bookings = Booking.current.order(:starts_at) respond_with @bookings end def new @booking = Booking.new end def create @booking = Booking.new(booking_params) if @booking.save if request.xhr? render json: {status: :success}.to_json else redirect_to bookings_url end else if request.xhr? render json: {errors: @booking.errors.full_messages, status: :error}.to_json else render 'new' end end end def show @booking = Booking.find(params[:id]) respond_with @bookings end def destroy if @booking.destroy flash[:notice] = "Booking: #{@booking} deleted" redirect_to bookings_url else render 'index' end end def edit end def update if @booking.update(booking_params) flash[:notice] = 'Your booking was updated successfully' if request.xhr? render json: {status: :success}.to_json else redirect_to bookings_url end else if request.xhr? render json: {errors: @booking.errors.full_messages, status: :error}.to_json else render 'edit' end end end private def booking_params params[:booking].permit! end def find_booking @booking = Booking.find(params[:id]) end end
codenamev/bookings
lib/bookings/generators/templates/bookings_controller.rb
Ruby
mit
1,474
[ 30522, 2465, 21725, 9363, 3372, 26611, 1026, 4646, 8663, 13181, 10820, 6869, 1035, 2000, 1024, 16129, 1010, 1024, 1046, 3385, 2077, 1035, 2895, 1024, 2424, 1035, 21725, 1010, 3272, 1024, 1031, 1024, 3443, 1010, 1024, 5950, 1033, 13366, 5950...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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) WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wso2.carbon.identity.mgt.policy; import java.util.ArrayList; public class PolicyRegistry { private ArrayList<PolicyEnforcer> policyCollection = new ArrayList<PolicyEnforcer>(); public PolicyRegistry() { } public void enforcePasswordPolicies(Object... args) throws PolicyViolationException { if (args != null) { for (PolicyEnforcer policy : policyCollection) { if (policy instanceof AbstractPasswordPolicyEnforcer) { if (!policy.enforce(args)) { throw new PolicyViolationException(policy.getErrorMessage()); } } } } } public void addPolicy(PolicyEnforcer policy) { policyCollection.add(policy); } }
SupunS/carbon-identity
components/identity/org.wso2.carbon.identity.mgt/src/main/java/org/wso2/carbon/identity/mgt/policy/PolicyRegistry.java
Java
apache-2.0
1,305
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 1059, 6499, 2475, 4297, 1012, 1006, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 6499, 2475, 1012, 8917, 1007, 2035, 2916, 9235, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 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...
require File.dirname(__FILE__) + '/spec_helper' describe 'A new', SprocketExpressOrder, '(in general)' do before(:each) do @order = SprocketExpressOrder.new end it 'should default to having shipping the same as the billing address' do @order.shipping_same_as_billing?.should eql(true) end it 'should default to a non-foreign (domestic) order' do @order.foreign?.should eql(false) end end describe 'A new', SprocketExpressOrder, 'when given acceptable values for the following attributes (and nothing more): ship_via, billing_last_name, billing_first_name, billing_company, billing_address_1, billing_address_2, billing_city, billing_state, billing_zipcode, billing_phone, billing_email, billing_country, date_of_original_purchase_transaction, id_from_original_purchase_transaction and shipping_same_as_billing set to true' do before(:each) do @order = SprocketExpressOrder.new(valid_order_attributes) end it 'should be valid' do @order.should be_valid end it 'before validating, should truncate billing_first_name, shipping_first_name, billing_last_name, shipping_last_name, billing_company, and shipping_company if those attributes are over the allowed lengths' do { :billing_first_name => 15, :shipping_first_name => 15, :billing_last_name => 20, :shipping_last_name => 20, :billing_company => 40, :shipping_company => 40 }.each_pair do |attribute,limit| @order.send("#{attribute.to_s}=", 'x' * (limit+1)) end end { :billing_first_name => 15, :shipping_first_name => 15, :billing_last_name => 20, :shipping_last_name => 20, :billing_company => 40, :shipping_company => 40 }.each_pair do |attribute,limit| it "it should truncate the #{attribute} attribute if that value supplied is over the allowable limit" do @order.send("#{attribute.to_s}=", 'x' * (limit+1)) @order.stubs(:'shipping_same_as_billing?').returns(false) @order.valid? @order.send(attribute).length.should <= limit end end end describe 'A new', SprocketExpressOrder, 'when any one of the following attributes are missing: billing_first_name, billing_last_name, billing_address_1, billing_city, billing_country, billing_state, billing_zipcode, ship_via' do it 'should be invalid' do [:billing_first_name, :billing_last_name, :billing_address_1, :billing_city, :billing_country, :billing_zipcode, :ship_via].each do |attribute| @order = SprocketExpressOrder.new(valid_order_attributes.except(attribute)) @order.should_not be_valid end end end describe 'A', SprocketExpressOrder, 'with shipping_same_as_billing set to true but values specified for shipping' do before(:each) do @order = SprocketExpressOrder.new(valid_order_attributes) end it 'should remove those values before saving' do [ "shipping_last_name", "shipping_first_name", "shipping_company", "shipping_address_1", "shipping_address_2", "shipping_city", "shipping_state", "shipping_zipcode", "shipping_phone", "shipping_email", "shipping_country" ].each do |attribute| @order.send("#{attribute}=",'face') end @order.save! [ "shipping_last_name", "shipping_first_name", "shipping_company", "shipping_address_1", "shipping_address_2", "shipping_city", "shipping_state", "shipping_zipcode", "shipping_phone", "shipping_email", "shipping_country" ].each do |attribute| @order.send("#{attribute}").should eql(nil) end end end
norbauer/sprocket_express
spec/sprocket_fullfillment_order_spec.rb
Ruby
mit
3,538
[ 30522, 5478, 5371, 1012, 16101, 18442, 1006, 1035, 1035, 5371, 1035, 1035, 1007, 1009, 1005, 1013, 28699, 1035, 2393, 2121, 1005, 6235, 1005, 1037, 2047, 1005, 1010, 11867, 16901, 12870, 2595, 20110, 8551, 2121, 1010, 1005, 1006, 1999, 2236...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
# -*- coding: utf-8 -*- # Generated by Django 1.9.7 on 2016-07-10 18:33 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('main', '0006_auto_20160616_1640'), ] operations = [ migrations.AlterField( model_name='episode', name='edit_key', field=models.CharField(blank=True, default='41086227', help_text='key to allow unauthenticated users to edit this item.', max_length=32, null=True), ), ]
xfxf/veyepar
dj/main/migrations/0007_auto_20160710_1833.py
Python
mit
560
[ 30522, 1001, 1011, 1008, 1011, 16861, 1024, 21183, 2546, 1011, 1022, 1011, 1008, 1011, 1001, 7013, 2011, 6520, 23422, 1015, 1012, 1023, 1012, 1021, 2006, 2355, 1011, 5718, 1011, 2184, 2324, 1024, 3943, 2013, 1035, 1035, 2925, 1035, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
USB Armory ========== In this package is support for using the [USB Armory](https://inversepath.com/usbarmory.html) hardware with the firmware transparency demo. Since the SoC on the hardware already has ROM we can't patch that to root our trust there, so for now we'll simply use a first-stage EL3 bootloader to "enforce" the correctness of the proof bundle before chaining to something (e.g. a full linux image based app) that represents the firmware being made transparent. The enforcement code not being in the masked ROM is an obvious shortcoming of this demo, however given the interesting array of security hardware on this board it should be possible to use some of that as an alternative trust base. Storage ------- > :warning: these are scratch notes, not yet reflective of reality, and so may > change drastically! We'll use the µSD card slot of the USB Armory for our purposes. The SD card will contain: - our "enforcing" [bootloader](./bootloader) - the firmware being made discoverable - a [proof bundle](/binary_transparency/firmware/api/update_package.go) for the firmware which convinces the bootloader that it _is_ discoverable and therefore ok to launch. > :info: the USB Armory is built around an NXP i.MX6 SoC. When booting, the ROM > loader on this SoC expects to find the first-stage bootloader at the > 1024th byte of the external storage. > This allows sufficient space beforehand to store a partition table. The on-disk partition layout will be: index | name | size | format | notes ------|------------|---------|--------|----------------------------------------------- 1 | boot | 10M | raw | Must cover disk bytes 1024 onwards as we'll directly write the bootloader here. 2 | proof | 512KB | ext4 | EXT4 filesystem for storing a serialised proof bundle 3 | firmware | 64MB+ | ext4 | EXT4 filesystem containing the bootable firmware image, armory boot config, etc. ### Preparing the SD Card > :warning: When following the instructions below, be *very sure* you know which > device is your SD card - if performed with an incorrect device, the instructions below > can cause data loss! #### Linux ##### Partition & file-systems First use the `parted -l` command to figure out which device corresponds to your SD card. > :tip: you can run the `parted -l` command twice, once with your SD card > reader plugged in, and once without to help identify the device. `/dev/my_sdcard` is used as a placeholder below, you should replace that with the path for your SD card device. ```bash sudo parted /dev/my_sdcard # double (triple!) check we've got the right device: (parted) print ... (parted) mklabel msdos # Create space for the bootloader (parted) mkpart primary 1KB 10240KB # Create a partition for the proofs (parted) mkpart primary ext4 10241KB 10753KB # Create a partition for the firmware (parted) mkpart primary ext4 10754KB 100MB # Check our work: (parted) unit b (parted) print Model: Generic- Micro SD/M2 (scsi) Disk /dev/sdc: 15931539456B Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 512B 10240511B 10240000B primary lba 2 10240512B 10753023B 512512B primary ext4 lba 3 10753536B 100000255B 89246720B primary ext4 lba ``` Finally, create filesystems on the 2nd and 3rd partitions of our SDCard: ```bash $ sudo mkfs.ext4 /dev/my_sdcard2 -L proof $ sudo mkfs.ext4 /dev/my_sdcard3 -L firmware ``` Next you'll build and install the bootloader on the card. Compiling the bootloader ------------------------ Follow the instructions on the [tamago-example](https://github.com/f-secure-foundry/tamago-example#Compiling) site to set up your tool-chain and environment variables. To compile the bootloader itself, run the following command in the `bootloader` directory: ```bash # Note that START_KERNEL corresponds to the offset of the firmware partition, # and START_PROOF is the offset of the proof partition make CROSS_COMPILE=arm-none-eabi- TARGET=usbarmory imx BOOT=uSD START_KERNEL=10753536 START_PROOF=10240512 LEN_KERNEL=89246720 ``` If successful, this will create a few files - the one we're interested in is `armory-boot.imx`, this is the "native format" bootloader code for the NXP SoC. ##### Install bootloader Finally, we'll write the bootloader we just built onto the SD card in the right place: ```bash # Note that we're writing to the raw device here NOT the boot partition. $ sudo dd if=armory-boot.imx of=/dev/myscard bs=512 seek=2 conv=fsync,notrunc ``` Firmware images --------------- Currently, the bootloader can only chain to either a Linux kernel, or a bare-metal ELF unikernel (only tested with tamago-example thus far). There are some invariants which must hold for this chain to work: 1. The `firmware` partition MUST be located at the precise offset mentioned above. 2. The `firmware` partition MUST be formatted with ext4. 3. The `firmware` partition MUST contain a `/boot` directory with at least the following contents: * `armory-boot.conf` - a JSON file which tells the bootloader which files to load * Either: * to boot a Linux Kernel: * a valid ARM linux Kernel image * a valid DTB file * to boot ELF unikernel: * a valid ARM bare-metal ELF binary/unikernel Note that the `armory-boot.conf` file also contains SHA256 hashes of all files referenced, and these MUST be correct. To aid in the creation of valid firmware images, use the `[cmd/usbarmory/image_builder/build.sh](/binary_transparency/firmware/cmd/usbarmory/image_builder/build.sh)` script, e.g.: ```bash $ ./cmd/usbarmory/image_builder/build.sh -u ./testdata/firmware/usbarmory/example/tamago-example -o /tmp/armory.ext4 /tmp/armory.ext4: Writing to the journal is not supported. Created image in /tmp/armory.ext4: -rw-rw-r-- 1 al al 13M Nov 30 10:39 /tmp/armory.ext4 ``` This image can be written to the target partition using the following commands: ```bash # first, log the image $ go run ./cmd/publisher/ --logtostderr --binary_path /tmp/armory.ext4 --output_path /tmp/update.ota --device="armory" # then flash the device firmware $ sudo $(which go) ./cmd/flash_tool \ --logtostderr \ --device=armory \ --update_file /tmp/update.ota \ --armory_proof_mount_point /path/to/mounted/proof/partition --armory_unikernel_dev /dev/mysdcard3 ``` <details> <summary>Alternative approach using regular shell commands</summary> Alternatively, if you prefer to see what's going on, you can currently achieve a similar goal with the following $ sudo dd if=/tmp/armory.ext of=/dev/my_sdcard3 bs=1M conf=fsync # finally, copy over the proof bundle (assumes /dev/my_sdcard2 is mounted on /mnt/proof) $ jq '.ProofBundle|@base64d|fromjson' /tmp/update.ota > /tmp/bundle.proof $ sudo mv /tmp/bundle.proof /mnt/proof/bundle.json ``` </details> ### Linux > :frog: The [Armory Debian Base Image](https://github.com/f-secure-foundry/usbarmory-debian-base_image/releases) > is a good source for the kernel (zImage) and dtb files. > > You can decompress and mount the image to access the files like so: > ```bash > # decompress image > $ xz -d usbarmory-mark-two-usd-debian_buster-base_image-20200714.raw.xz > # mount image with loopback: > # note the offset parameter below - the raw file is a complete disk image, this > # offset is the first byte of the root partition (you can use fdisk or parted > # on the raw file to view this yourself) > $ sudo mount -o loop,ro,offet=5242880 /home/al/Downloads/usbarmory-mark-two-usd-debian_buster-base_image-20201020.raw /mnt > # the files we're interested in are now visible in /mnt/boot: > $ ls -l /mnt/boot > total 8148 > -rw-r--r-- 1 root root 99319 Oct 20 17:13 config-5.4.72-0-usbarmory > lrwxrwxrwx 1 root root 21 Oct 20 17:14 imx6ull-usbarmory.dtb -> imx6ulz-usbarmory.dtb > -rw-r--r-- 1 root root 19938 Oct 20 17:14 imx6ulz-usbarmory-default-5.4.72-0.dtb > lrwxrwxrwx 1 root root 38 Oct 20 17:14 imx6ulz-usbarmory.dtb -> imx6ulz-usbarmory-default-5.4.72-0.dtb > -rw-r--r-- 1 root root 1488951 Oct 20 17:13 System.map-5.4.72-0-usbarmory > lrwxrwxrwx 1 root root 25 Oct 20 17:14 zImage -> zImage-5.4.72-0-usbarmory > -rwxr-xr-x 1 root root 6726952 Oct 20 17:13 zImage-5.4.72-0-usbarmory > ``` An example `armory-boot.conf` file configured to boot a Linux kernel is: ```json { "kernel": [ "/boot/zImage-5.4.51-0-usbarmory", "aceb3514d5ba6ac591a7d5f2cad680e83a9f848d19763563da8024f003e927c7" ], "dtb": [ "/boot/imx6ulz-usbarmory-default-5.4.51-0.dtb", "60d4fe465ef60042293f5723bf4a001d8e75f26e517af2b55e6efaef9c0db1f6" ], "cmdline": "console=ttymxc1,115200 root=/dev/sdc3 rootwait rw" } ``` TODO(al): Consider wrapping this up into a script. ### ELF unikernel > :frog: A good sample unikernel is the > [tamago-example](https://github.com/f-secure-foundry/tamago-example) > application. An example `armory-boot.conf` file configured to boot an ELF unikernel is: ```json { "unikernel": [ "/boot/tamago-example", "aceb3514d5ba6ac591a7d5f2cad680e83a9f848d19763563da8024f003e927c7" ] } ``` Booting ------- If all is well, booting the USB Armory using the debug accessory will show console output like so: ``` Terminal ready �armory-boot: starting kernel image@80800000 params@87000000 Booting Linux on physical CPU 0x0 Linux version 5.4.72-0 (usbarmory@f-secure-foundry) (gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)) #1 PREEMPT Tue Oct 20 16:03:37 UTC 2020 CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d CPU: div instructions available: patching division code CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache OF: fdt: Machine model: F-Secure USB armory Mk II Memory policy: Data cache writeback CPU: All CPU(s) started in SVC mode. Built 1 zonelists, mobility grouping on. Total pages: 130048 Kernel command line: console=ttymxc1,115200 root=/dev/sda3 rootwait rw Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear) ... ``` Firmware Measurement -------------------- The 'firmware measurement' hash for the USB Armory is defined to be the SHA256 hash of the raw bytes of the `ext4` **filesystem image** stored in the 'firmware' partition of the SD Card. Note that this _may well_ be a different size than the partition itself.
google/trillian-examples
binary_transparency/firmware/devices/usbarmory/README.md
Markdown
apache-2.0
10,495
[ 30522, 18833, 24139, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1999, 2023, 7427, 2003, 2490, 2005, 2478, 1996, 1031, 18833, 24139, 1033, 1006, 16770, 1024, 1013, 1013, 19262, 15069, 1012, 4012, 1013, 18833, 27292, 10253, 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...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Coq bench</title> <link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" /> <link href="../../../../../bootstrap.min.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"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <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="../../..">Unstable</a></li> <li><a href=".">8.4.5 / contrib:higman-s dev</a></li> <li class="active"><a href="">2014-11-17 16:11:16</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="../../../../../about.html">About</a></li> </ul> </div> </div> </div> <div class="article"> <div class="row"> <div class="col-md-12"> <a href=".">« Up</a> <h1> contrib:higman-s <small> dev <span class="label label-danger">Lint error</span> </small> </h1> <p><em><script>document.write(moment("2014-11-17 16:11:16 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2014-11-17 16:11:16 UTC)</em><p> <h2>Lint</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>ruby lint.rb unstable ../unstable/packages/coq:contrib:higman-s/coq:contrib:higman-s.dev</code></dd> <dt>Return code</dt> <dd>256</dd> <dt>Duration</dt> <dd>0 s</dd> <dt>Output</dt> <dd><pre>You should add an homepage for your package. For example: homepage: &quot;https://github.com/user/project&quot; </pre></dd> </dl> <h2>Dry install</h2> <p>Dry install with the current Coq version:</p> <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> <p>Dry install without Coq, to test if the problem was incompatibility with the current Coq version:</p> <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 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>Data not available in this bench.</p> <h2>Uninstall</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> <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-old
clean/Linux-x86_64-4.02.1-1.2.0/unstable/8.4.5/contrib:higman-s/dev/2014-11-17_16-11-16.html
HTML
mit
5,340
[ 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...
using System.Collections.Generic; namespace AGS.API { /// <summary> /// Custom properties that you can attach to entities and can be used to get/set values during the game. /// </summary> public interface ICustomPropertiesPerType<TValue> { /// <summary> /// Gets the stored value for the custom property with the specified name. /// If no value is stored for this property, returns the specified default value instead /// (and stored that default value as the property's new value). /// </summary> /// <returns>The value.</returns> /// <param name="name">Name.</param> /// <param name="defaultValue">Default value.</param> TValue GetValue(string name, TValue defaultValue = default); /// <summary> /// Stores a new value for the custom property with the specified name. /// If an old value is stored it will be overridden by the new value. /// </summary> /// <param name="name">Name.</param> /// <param name="value">Value.</param> void SetValue(string name, TValue value); /// <summary> /// Returns a dictionary with all existing custom properties for this type. /// </summary> /// <returns>The properties.</returns> IDictionary<string, TValue> AllProperties(); /// <summary> /// Copies the custom properties from a different object (this will override /// values in the current object, but will not delete properties which don't /// have an equivalent in the given object). /// </summary> /// <param name="properties">Properties.</param> void CopyFrom(ICustomPropertiesPerType<TValue> properties); } }
tzachshabtay/MonoAGS
Source/AGS.API/Misc/CustomProperties/ICustomPropertiesPerType.cs
C#
artistic-2.0
1,758
[ 30522, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 3415, 15327, 12943, 2015, 1012, 17928, 1063, 1013, 1013, 1013, 1026, 12654, 1028, 1013, 1013, 1013, 7661, 5144, 2008, 2017, 2064, 22476, 2000, 11422, 1998, 2064, 2022, 2109, 2000, 2131, 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...
<?php /* +---------------------------------------------------------------------------+ | OpenX v2.8 | | ========== | | | | Copyright (c) 2003-2009 OpenX Limited | | For contact details, see: http://www.openx.org/ | | | | This program is free software; you can redistribute it and/or modify | | it under the terms of the GNU General Public License as published by | | the Free Software Foundation; either version 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 | +---------------------------------------------------------------------------+ $Id: affiliate-edit.php 12839 2007-11-27 16:32:39Z bernard.lange@openads.org $ */ // Require the initialisation file require_once '../../init.php'; // Required files require_once MAX_PATH . '/www/admin/config.php'; // Register input variables // TODO: This variable has been added to demonstrate that clicking on // links from error messages could bring the already entered e-mail address // to the new form. Feel free to keep it or remove, depending on the // implementation strategy. phpAds_registerGlobalUnslashed ('email'); /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ phpAds_PageHeader("4.1.3.4.7.3"); // TODO: The path here should probably start with the advertiser's data // Not sure if we need to include the campaign and banner in the path though. // We'll need to clarify this with the Product team. echo "<img src='" . OX::assetPath() . "/images/icon-affiliate.gif' align='absmiddle'>&nbsp;<b>Edit AdSense Account</b><br /><br /><br />"; phpAds_ShowSections(array("4.1.3.4.7.3")); /*-------------------------------------------------------*/ /* Main code */ /*-------------------------------------------------------*/ require_once MAX_PATH . '/lib/OA/Admin/Template.php'; $oTpl = new OA_Admin_Template('adsense-edit.html'); $oTpl->assign('fields', array( array( 'title' => 'AdSense Account Information', 'fields' => array( array( 'name' => 'name', 'label' => 'Name', 'value' => '' ), array( 'name' => 'email', 'label' => 'Email', 'value' => $email ), array( 'name' => 'phone5digits', 'label' => 'Last 5 digits of phone number', 'value' => '' ), array( 'name' => 'postalcode', 'label' => 'Postal Code', 'value' => '' ) ) ) )); //var_dump($oTpl); //die(); $oTpl->display(); /*-------------------------------------------------------*/ /* HTML framework */ /*-------------------------------------------------------*/ phpAds_PageFooter(); ?>
wassemgtk/OpenX-using-S3-and-CloudFront
www/admin/adsense-edit.php
PHP
gpl-2.0
4,108
[ 30522, 1026, 1029, 25718, 1013, 1008, 1009, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 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...
/* * Copyright (c) 2019 The Hyve B.V. * * This library 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. The software and documentation provided hereunder * is on an "as is" basis, and Memorial Sloan-Kettering Cancer Center has no * obligations to provide maintenance, support, updates, enhancements or * modifications. In no event shall Memorial Sloan-Kettering Cancer Center be * liable to any party for direct, indirect, special, incidental or * consequential damages, including lost profits, arising out of the use of this * software and its documentation, even if Memorial Sloan-Kettering Cancer * Center has been advised of the possibility of such damage. */ /* * This file is part of cBioPortal. * * cBioPortal is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.mskcc.cbio.portal.model; import java.io.Serializable; /** * @author Pim van Nierop, pim@thehyve.nl */ public class Treatment implements Serializable { private int id; private int geneticEntityId; private String stableId; private String name; private String description; private String refLink; /** * Create a Treatment object from fields * * @param treatmentId Treatment table ID key of the treament * @param geneticEntityId Genetic_entity table ID key associated to the treament record * @param stableId Stable identifier of the treatment used in the cBioPortal instance * @param name Name of the treatment * @param description Description of the treatment * @param refLink Url for the treatment */ public Treatment(int id, int geneticEntityId, String stableId, String name, String description, String refLink) { this.geneticEntityId = geneticEntityId; this.geneticEntityId = geneticEntityId; this.stableId = stableId; this.name = name; this.description = description; this.refLink = refLink; } /** * Create a Treatment object from fields * * @param treatmentId Treatment table ID key of the treament * @param geneticEntityId Genetic_entity table ID key associated to the treament record * @param stableId Stable identifier of the treatment used in the cBioPortal instance * @param name Name of the treatment * @param description Description of the treatment * @param refLink Url for the treatment */ public Treatment(String stableId, String name, String description, String refLink) { this.stableId = stableId; this.name = name; this.description = description; this.refLink = refLink; } /** * @return the id */ public int getId() { return id; } /** * @param id the id to set */ public void setId(Integer id) { this.id = id; } /** * @return the geneticEntityId */ public int getGeneticEntityId() { return geneticEntityId; } /** * @param geneticEntityId the geneticEntityId to set */ public void setGeneticEntityId(Integer geneticEntityId) { this.geneticEntityId = geneticEntityId; } /** * @return the stableId */ public String getStableId() { return stableId; } /** * @param stableId the stableId to set */ public void setStableId(String stableId) { this.stableId = stableId; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the description */ public String getDescription() { return description; } /** * @param description the description to set */ public void setDescription(String description) { this.description = description; } /** * @return the refLink */ public String getRefLink() { return refLink; } /** * @param refLink the refLink to set */ public void setRefLink(String refLink) { this.refLink = refLink; } }
pughlab/cbioportal
core/src/main/java/org/mskcc/cbio/portal/model/Treatment.java
Java
agpl-3.0
4,931
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 10476, 1996, 1044, 2100, 3726, 1038, 1012, 1058, 1012, 1008, 1008, 2023, 3075, 2003, 5500, 1999, 1996, 3246, 2008, 2009, 2097, 2022, 6179, 1010, 2021, 2302, 1008, 2151, 10943, 2100, 1010, 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...
<!DOCTYPE html> <html class="ui-mobile-rendering"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery Mobile Docs - Content Themes</title> <link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css" /> <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/> <script data-main="../../js/jquery.mobile.docs" src="../../external/requirejs/require.js"></script> <script src="../../js/jquery.js"></script> </head> <body> <div data-role="page" class="type-interior"> <div data-role="header" data-theme="f"> <h1>Theming content</h1> <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a> </div><!-- /header --> <div data-role="content"> <div class="content-primary"> <h2>Theming the content area</h2> <p>The main content area of a page (container with the <code> data-role="content"</code> attribute) should be themed by adding the <code> data-theme</code> attribute to the <code> data-role="page"</code> container to ensure that the background colors are applied to the full page, regardless of the content length. (If you add the <code> data-theme</code> attribute to the content container, the background color will stop after the content. So there may be a gap in color between the content and fixed footer.)</p> <p>Additionally, the content area of a collapsible can be themed to match the theme of the collapsible header using the <code>data-content-theme</code> attribute.</p> <code> &lt;div data-role=&quot;page&quot; <strong> data-theme=&quot;a&quot;</strong> <strong>data-content-theme=&quot;a&quot;</strong>&gt; </code> <h2>Theming collapsible blocks</h2> <p>To set the color of the collapsible header, add the <code> data-theme</code> attribute to the collapsible container. The icon and body are not currently themable through data attributes, but can be styled directly with custom css.</p> <code> &lt;div data-role=&quot;collapsible&quot; data-collapsed=&quot;true&quot; <strong> data-theme=&quot;a&quot;&gt;</strong> </code> <h2>Themed examples</h2> <p><strong>A</strong> theme swatch on content &amp; collapsible</p> <div class="ui-body ui-body-a"> <h1>H1 Heading</h1> <p>This is a paragraph that contains <strong>strong</strong>, <em>emphasized</em> and <a href="index.html">linked</a> text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.</p> <div data-role="collapsible" data-collapsed="true" data-theme="a"> <h3>I'm a themed collapsible</h3> <p>I have <code> data-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div><!-- /collapsible --> <div data-role="collapsible" data-theme="a" data-content-theme="a"> <h3>I'm a themed collapsible with a themed content</h3> <p>I have <code> data-content-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div> </div><!-- /themed container --> <p><strong>B</strong> theme swatch on content &amp; collapsible</p> <div class="ui-body ui-body-b"> <h1>H1 Heading</h1> <p>This is a paragraph that contains <strong>strong</strong>, <em>emphasized</em> and <a href="index.html">linked</a> text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.</p> <div data-role="collapsible" data-collapsed="true" data-theme="b"> <h3>I'm a themed collapsible</h3> <p>I have <code> data-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div><!-- /collapsible --> <div data-role="collapsible" data-theme="b" data-content-theme="b"> <h3>I'm a themed collapsible with a themed content</h3> <p>I have <code> data-content-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div> </div><!-- /themed container --> <p><strong>C</strong> theme swatch on content &amp; collapsible</p> <div class="ui-body ui-body-c"> <h1>H1 Heading</h1> <p>This is a paragraph that contains <strong>strong</strong>, <em>emphasized</em> and <a href="index.html">linked</a> text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.</p> <div data-role="collapsible" data-collapsed="true" data-theme="c"> <h3>I'm a themed collapsible</h3> <p>I have <code> data-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div><!-- /collapsible --> <div data-role="collapsible" data-theme="c" data-content-theme="c"> <h3>I'm a themed collapsible with a themed content</h3> <p>I have <code> data-content-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div> </div><!-- /themed container --> <p><strong>D</strong> theme swatch on content &amp; collapsible</p> <div class="ui-body ui-body-d"> <h1>H1 Heading</h1> <p>This is a paragraph that contains <strong>strong</strong>, <em>emphasized</em> and <a href="index.html">linked</a> text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.</p> <div data-role="collapsible" data-collapsed="true" data-theme="d"> <h3>I'm a themed collapsible</h3> <p>I have <code> data-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div><!-- /collapsible --> <div data-role="collapsible" data-theme="d" data-content-theme="d"> <h3>I'm a themed collapsible with a themed content</h3> <p>I have <code> data-content-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div> </div><!-- /themed container --> <p><strong>E</strong> theme swatch on content &amp; collapsible</p> <div class="ui-body ui-body-e"> <h1>H1 Heading</h1> <p>This is a paragraph that contains <strong>strong</strong>, <em>emphasized</em> and <a href="index.html">linked</a> text. Here is more text so you can see how HTML markup works in content. Here is more text so you can see how HTML markup works in content.</p> <div data-role="collapsible" data-collapsed="true" data-theme="e"> <h3>I'm a themed collapsible</h3> <p>I have <code> data-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div><!-- /collapsible --> <div data-role="collapsible" data-theme="e" data-content-theme="e"> <h3>I'm a themed collapsible with a themed content</h3> <p>I have <code> data-content-theme</code> attribute set manually on my container to set the color to match the content block I'm in. </p> </div> </div><!-- /themed container --> </div><!--/content-primary --> <div class="content-secondary"> <div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d"> <h3>More in this section</h3> <ul data-role="listview" data-theme="c" data-dividertheme="d"> <li data-role="list-divider">Content Formatting</li> <li><a href="content-html.html">Basic HTML styles</a></li> <li><a href="content-grids.html">Layout grids (columns)</a></li> <li><a href="content-collapsible.html">Collapsible content blocks</a></li> <li><a href="content-collapsible-set.html">Collapsible sets (accordions)</a></li> <li data-theme="a"><a href="content-themes.html">Theming content</a></li> </ul> </div> </div> </div><!-- /content --> <div data-role="footer" class="footer-docs" data-theme="c"> <p>&copy; 2011 The jQuery Project</p> </div> </div><!-- /page --> </body> </html>
madeinnordeste/open-rsvp
static/plugin/jquery-mobile/docs/content/content-themes.html
HTML
bsd-3-clause
8,024
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 2465, 1027, 1000, 21318, 1011, 4684, 1011, 14259, 1000, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1028, 1026, 18804, 2171, 1027, 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...
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/iotwireless/model/MulticastGroup.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace IoTWireless { namespace Model { MulticastGroup::MulticastGroup() : m_idHasBeenSet(false), m_arnHasBeenSet(false), m_nameHasBeenSet(false) { } MulticastGroup::MulticastGroup(JsonView jsonValue) : m_idHasBeenSet(false), m_arnHasBeenSet(false), m_nameHasBeenSet(false) { *this = jsonValue; } MulticastGroup& MulticastGroup::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("Id")) { m_id = jsonValue.GetString("Id"); m_idHasBeenSet = true; } if(jsonValue.ValueExists("Arn")) { m_arn = jsonValue.GetString("Arn"); m_arnHasBeenSet = true; } if(jsonValue.ValueExists("Name")) { m_name = jsonValue.GetString("Name"); m_nameHasBeenSet = true; } return *this; } JsonValue MulticastGroup::Jsonize() const { JsonValue payload; if(m_idHasBeenSet) { payload.WithString("Id", m_id); } if(m_arnHasBeenSet) { payload.WithString("Arn", m_arn); } if(m_nameHasBeenSet) { payload.WithString("Name", m_name); } return payload; } } // namespace Model } // namespace IoTWireless } // namespace Aws
aws/aws-sdk-cpp
aws-cpp-sdk-iotwireless/source/model/MulticastGroup.cpp
C++
apache-2.0
1,434
[ 30522, 1013, 1008, 1008, 1008, 9385, 9733, 1012, 4012, 1010, 4297, 1012, 2030, 2049, 18460, 1012, 2035, 2916, 9235, 1012, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 15895, 1011, 1016, 1012, 1014, 1012, 1008, 1013, 1001, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 React, { Component } from 'react'; import { Link } from 'react-router-dom' import { CSSTransition } from 'react-transition-group'; class Nav extends Component { constructor(props) { super(props); this.state = { menuActive: false } this.handleClick = this.handleClick.bind(this); } handleClick() { var obj = {}; obj['menuActive'] = !this.state.menuActive; this.setState(obj); } render() { return ( <div className={this.state.menuActive? 'nav active': 'nav'} > <div className='nav__button' onClick={this.handleClick}> <div className='nav__buttonPart' /> <div className='nav__buttonPart' /> <div className='nav__buttonPart' /> <div className="nav__buttonTitle"> {this.state.menuActive? <div>Close</div> : <div>Menu</div>} </div> </div> <div className='nav__menuBox'> <ul className='nav__menu'> <li className='nav__menuItem'> <Link to='/'> home </Link> </li> <li className='nav__menuItem'> <Link to='/'> blog </Link> </li> <li className='nav__menuItem'> <Link to='/About'> about </Link> </li> </ul> </div> <CSSTransition in={this.state.menuActive} timeout={300} classNames="nav__background" > <div className="nav__background"/> </CSSTransition> <CSSTransition in={this.state.menuActive} timeout={300} classNames="nav__shadowBackground" > <div className="nav__shadowBackground"/> </CSSTransition> </div> ); } } export default Nav;
7sleepwalker/addicted-to-mnt
src/js/Components/Nav.js
JavaScript
gpl-3.0
1,662
[ 30522, 12324, 10509, 1010, 1063, 6922, 1065, 2013, 1005, 10509, 1005, 1025, 12324, 1063, 4957, 1065, 2013, 1005, 10509, 1011, 2799, 2099, 1011, 14383, 1005, 12324, 1063, 20116, 20528, 3619, 22753, 1065, 2013, 1005, 10509, 1011, 6653, 1011, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 <glib.h> int main (int argc, char **argv) { g_autoptr(GVariant) v = NULL; g_autoptr(GError) error = NULL; gsize size; const gchar *data; if (argc < 2) { g_printerr ("Usage: %s GVARIANT_TEXT\n", argv[0]); return 1; } v = g_variant_parse (NULL, argv[1], NULL, NULL, &error); if (v == NULL) { g_autofree gchar *msg = NULL; msg = g_variant_parse_error_print_context (error, argv[1]); g_printerr ("%s", msg); return 1; } g_print ("%s\n", g_variant_get_type_string (v)); size = g_variant_get_size (v); data = g_variant_get_data (v); if (size > 0) { g_print ("[ 0x%x", data[0] & 0xff); for (gsize i = 1; i < size; i++) g_print (", 0x%x", data[i] & 0xff); g_print (" ]\n"); } else g_print ("[]\n"); return 0; }
larsu/gvariant.js
glib-gvariant/glib-gvariant.c
C
bsd-3-clause
840
[ 30522, 1001, 2421, 1026, 1043, 29521, 1012, 1044, 1028, 20014, 2364, 1006, 20014, 12098, 18195, 1010, 25869, 1008, 1008, 12098, 2290, 2615, 1007, 1063, 1043, 1035, 8285, 13876, 2099, 1006, 1043, 10755, 2937, 2102, 1007, 1058, 1027, 19701, 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...
--- title: 'txt2re: Regular Expression Generator' date: '2011-10-10T03:56:00.000-07:00' tags: - Regex - Utilities modified_time: '2011-10-10T05:14:47.941-07:00' blogger_id: tag:blogger.com,1999:blog-3456458686961244994.post-7064012350422304264 blogger_orig_url: http://blog.kieranties.com/2011/10/txt2re-regular-expression-generator.html redirect_from: "/2011/10/txt2re-regular-expression-generator.html" --- <a href="http://txt2re.com/">[Link]</a><br />A pretty awesome page to help when creating regular expressions. &nbsp;Type in the string you want to match, then use the selectors to create a snippet of code with the regex and validation process pre-populated, allowing you to drop the code straight into your application. (full credit to <a href="https://twitter.com/zoe_nolan">Zoe Nolan</a> for the link!)<br /><br />This is a cracking starting point for some simple regex work (or when your head just isn't wrapping itself around the joys of regex), but for more detailed help, pointers and tips I'd suggest taking a look at the following: <br /><ul><li><a href="http://regexlib.com/">Regex Library</a></li><li><a href="http://www.regular-expressions.info/">Regular Expressions Info</a></li></ul>
Kieranties/Kieranties.github.io
_posts/2011-10-10-txt2re-regular-expression-generator.html
HTML
mit
1,207
[ 30522, 1011, 1011, 1011, 2516, 1024, 1005, 19067, 2102, 2475, 2890, 1024, 3180, 3670, 13103, 1005, 3058, 1024, 1005, 2249, 1011, 2184, 1011, 2184, 2102, 2692, 2509, 1024, 5179, 1024, 4002, 1012, 2199, 1011, 5718, 1024, 4002, 1005, 22073, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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: 쇼룸(공연전) date: 2016-06-10 tags: showroom category: blog --- <iframe title='' width='640px' height='360px' src='http://videofarm.daum.net/controller/video/viewer/Video.html?vid=vcc3buoUVoXoUlMC8Clo8Ry&play_loc=undefined&alert=true' frameborder='0' scrolling='no' ></iframe>
joyplug/hiwatan
_posts/2016-06-10-akb48-showroom.md
Markdown
mit
307
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1461, 30013, 29994, 30014, 30023, 1006, 1455, 30011, 30025, 29999, 30010, 30021, 30000, 30008, 30021, 1007, 3058, 1024, 2355, 1011, 5757, 1011, 2184, 22073, 1024, 2265, 9954, 4696, 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...
// ThresClassEventSender.h // author: Ionut Damianr <damian@hcm-lab.de> // created: 2013/08/21 // Copyright (C) 2007-13 University of Augsburg, Lab for Human Centered Multimedia // // ************************************************************************************************* // // This file is part of Social Signal Interpretation (SSI) developed at the // Lab for Human Centered Multimedia of the University of Augsburg // // This library is free software; you can redistribute itand/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 any laterversion. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FORA PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public // License along withthis library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // //************************************************************************************************* #ifndef SSI_EVENT_THRESCLASSEVENTSENDER_H #define SSI_EVENT_THRESCLASSEVENTSENDER_H #include "base/IConsumer.h" #include "ioput/option/OptionList.h" #include "event/EventAddress.h" namespace ssi { class ThresClassEventSender : public IConsumer { public: class Options : public OptionList { public: Options () : minDiff (0.1f), mean(false) { setSender ("tcsender"); setEvent ("class"); setClasses ("low, medium, high"); setThresholds ("0.1, 0.3, 0.8"); addOption ("sname", sname, SSI_MAX_CHAR, SSI_CHAR, "name of sender (if sent to event board)"); addOption ("ename", ename, SSI_MAX_CHAR, SSI_CHAR, "name of event (if sent to event board)"); addOption ("classes", classes, SSI_MAX_CHAR, SSI_CHAR, "names of the classes event (e.g. low,medium,high)"); addOption ("thres", &thres, SSI_MAX_CHAR, SSI_CHAR, "thresholds (e.g. 0.1,0.3,0.8)"); addOption ("minDiff", &minDiff, 1, SSI_FLOAT, "minimum difference to previous value"); addOption ("mean", &mean, 1, SSI_BOOL, "classify based on mean value of entire frame"); }; void setSender (const ssi_char_t *sname) { if (sname) { ssi_strcpy (this->sname, sname); } } void setEvent (const ssi_char_t *ename) { if (ename) { ssi_strcpy (this->ename, ename); } } void setClasses (const ssi_char_t *classes) { if (classes) { ssi_strcpy (this->classes, classes); } } void setThresholds (const ssi_char_t *thres) { if (thres) { ssi_strcpy (this->thres, thres); } } void setThresholds (ssi_size_t n_thres, ssi_real_t *thres) { thres[0] = '\0'; if (n_thres > 0) { ssi_char_t c[SSI_MAX_CHAR]; ssi_sprint (c, "%f", thres[0]); strcat (classes, c); for (ssi_size_t i = 1; i < n_thres; i++) { ssi_sprint (c, ",%f", thres[i]); strcat (classes, c); } } } bool mean; ssi_real_t minDiff; ssi_char_t sname[SSI_MAX_CHAR]; ssi_char_t ename[SSI_MAX_CHAR]; ssi_char_t classes[SSI_MAX_CHAR]; ssi_char_t thres[SSI_MAX_CHAR]; }; public: static const ssi_char_t *GetCreateName () { return "ssi_consumer_ThresClassEventSender"; }; static IObject *Create (const ssi_char_t *file) { return new ThresClassEventSender (file); }; ~ThresClassEventSender (); static ssi_char_t *ssi_log_name; int ssi_log_level; Options *getOptions () { return &_options; }; const ssi_char_t *getName () { return GetCreateName (); }; const ssi_char_t *getInfo () { return "Classifies stream using thresholds."; }; void consume_enter (ssi_size_t stream_in_num, ssi_stream_t stream_in[]); void consume (IConsumer::info consume_info, ssi_size_t stream_in_num, ssi_stream_t stream_in[]); void consume_flush (ssi_size_t stream_in_num, ssi_stream_t stream_in[]); bool setEventListener (IEventListener *listener); const ssi_char_t *getEventAddress () { return _event_address.getAddress (); } protected: ThresClassEventSender (const ssi_char_t *file = 0); int classify(ssi_real_t value, ssi_real_t* thresholds, ssi_size_t n_thresholds); bool handleEvent(IEventListener *listener, ssi_event_t* ev, const ssi_char_t* class_name, ssi_time_t time); ThresClassEventSender::Options _options; ssi_char_t *_file; IEventListener *_elistener; EventAddress _event_address; ssi_event_t _event; ssi_real_t *_thres; ssi_size_t _num_classes; const ssi_char_t **_classes; int _lastClass; ssi_real_t _lastValue; ssi_real_t *parseFloats (const ssi_char_t *str, ssi_size_t &n_indices, bool sort = false, const ssi_char_t *delims = " ,"); const ssi_char_t **parseStrings (const ssi_char_t *str, ssi_size_t &n_indices, const ssi_char_t *delims = " ,"); }; } #endif
eNTERFACE14Auracle/AuracleSSI
core/include/event/ThresClassEventSender.h
C
gpl-3.0
5,067
[ 30522, 1013, 1013, 16215, 6072, 26266, 18697, 7666, 10497, 2121, 1012, 1044, 1013, 1013, 3166, 1024, 10163, 4904, 19507, 2099, 1026, 19507, 1030, 16731, 2213, 1011, 6845, 1012, 2139, 1028, 1013, 1013, 2580, 1024, 2286, 1013, 5511, 1013, 253...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* Routines for LTE RLC disassembly * * Martin Mathieson * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> * Copyright 1998 Gerald Combs * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" #include <stdio.h> #include <string.h> #include <epan/packet.h> #include <epan/exceptions.h> #include <epan/conversation.h> #include <epan/expert.h> #include <epan/prefs.h> #include <epan/tap.h> #include <epan/wmem/wmem.h> #include "packet-mac-lte.h" #include "packet-rlc-lte.h" #include "packet-pdcp-lte.h" /* Described in: * 3GPP TS 36.322 Evolved Universal Terrestial Radio Access (E-UTRA) * Radio Link Control (RLC) Protocol specification v9.3.0 */ /* TODO: - add intermediate results to segments leading to final reassembly - use multiple active rlc_channel_reassembly_info's per channel - sequence analysis gets confused when we change cells and skip back to SN 0. Maybe add cell-id to context and add to channel/result key? */ void proto_register_rlc_lte(void); void proto_reg_handoff_rlc_lte(void); /********************************/ /* Preference settings */ #define SEQUENCE_ANALYSIS_MAC_ONLY 1 #define SEQUENCE_ANALYSIS_RLC_ONLY 2 /* By default do try to analyse the sequence of messages for AM/UM channels using MAC PDUs */ static gint global_rlc_lte_am_sequence_analysis = SEQUENCE_ANALYSIS_MAC_ONLY; static gint global_rlc_lte_um_sequence_analysis = SEQUENCE_ANALYSIS_MAC_ONLY; /* By default do call PDCP/RRC dissectors for SDU data */ static gboolean global_rlc_lte_call_pdcp_for_srb = TRUE; enum pdcp_for_drb { PDCP_drb_off, PDCP_drb_SN_7, PDCP_drb_SN_12, PDCP_drb_SN_signalled, PDCP_drb_SN_15}; static const enum_val_t pdcp_drb_col_vals[] = { {"pdcp-drb-off", "Off", PDCP_drb_off}, {"pdcp-drb-sn-7", "7-bit SN", PDCP_drb_SN_7}, {"pdcp-drb-sn-12", "12-bit SN", PDCP_drb_SN_12}, {"pdcp-drb-sn-15", "15-bit SN", PDCP_drb_SN_15}, {"pdcp-drb-sn-signalling", "Use signalled value", PDCP_drb_SN_signalled}, {NULL, NULL, -1} }; static gint global_rlc_lte_call_pdcp_for_drb = (gint)PDCP_drb_SN_signalled; static gint signalled_pdcp_sn_bits = 12; static gboolean global_rlc_lte_call_rrc_for_ccch = TRUE; static gboolean global_rlc_lte_call_rrc_for_mcch = FALSE; static gboolean global_rlc_lte_call_ip_for_mtch = FALSE; /* Preference to expect RLC headers without payloads */ static gboolean global_rlc_lte_headers_expected = FALSE; /* Heuristic dissection */ static gboolean global_rlc_lte_heur = FALSE; /* Re-assembly of segments */ static gboolean global_rlc_lte_reassembly = TRUE; /**************************************************/ /* Initialize the protocol and registered fields. */ int proto_rlc_lte = -1; extern int proto_mac_lte; extern int proto_pdcp_lte; static dissector_handle_t pdcp_lte_handle; static dissector_handle_t ip_handle; static int rlc_lte_tap = -1; /* Decoding context */ static int hf_rlc_lte_context = -1; static int hf_rlc_lte_context_mode = -1; static int hf_rlc_lte_context_direction = -1; static int hf_rlc_lte_context_priority = -1; static int hf_rlc_lte_context_ueid = -1; static int hf_rlc_lte_context_channel_type = -1; static int hf_rlc_lte_context_channel_id = -1; static int hf_rlc_lte_context_pdu_length = -1; static int hf_rlc_lte_context_um_sn_length = -1; /* Transparent mode fields */ static int hf_rlc_lte_tm = -1; static int hf_rlc_lte_tm_data = -1; /* Unacknowledged mode fields */ static int hf_rlc_lte_um = -1; static int hf_rlc_lte_um_header = -1; static int hf_rlc_lte_um_fi = -1; static int hf_rlc_lte_um_fixed_e = -1; static int hf_rlc_lte_um_sn = -1; static int hf_rlc_lte_um_fixed_reserved = -1; static int hf_rlc_lte_um_data = -1; static int hf_rlc_lte_extension_part = -1; /* Extended header (common to UM and AM) */ static int hf_rlc_lte_extension_e = -1; static int hf_rlc_lte_extension_li = -1; static int hf_rlc_lte_extension_padding = -1; /* Acknowledged mode fields */ static int hf_rlc_lte_am = -1; static int hf_rlc_lte_am_header = -1; static int hf_rlc_lte_am_data_control = -1; static int hf_rlc_lte_am_rf = -1; static int hf_rlc_lte_am_p = -1; static int hf_rlc_lte_am_fi = -1; static int hf_rlc_lte_am_fixed_e = -1; static int hf_rlc_lte_am_fixed_sn = -1; static int hf_rlc_lte_am_segment_lsf = -1; static int hf_rlc_lte_am_segment_so = -1; static int hf_rlc_lte_am_data = -1; /* Control fields */ static int hf_rlc_lte_am_cpt = -1; static int hf_rlc_lte_am_ack_sn = -1; static int hf_rlc_lte_am_e1 = -1; static int hf_rlc_lte_am_e2 = -1; static int hf_rlc_lte_am_nack_sn = -1; static int hf_rlc_lte_am_nacks = -1; static int hf_rlc_lte_am_so_start = -1; static int hf_rlc_lte_am_so_end = -1; static int hf_rlc_lte_predefined_pdu = -1; static int hf_rlc_lte_header_only = -1; /* Sequence Analysis */ static int hf_rlc_lte_sequence_analysis = -1; static int hf_rlc_lte_sequence_analysis_ok = -1; static int hf_rlc_lte_sequence_analysis_previous_frame = -1; static int hf_rlc_lte_sequence_analysis_next_frame = -1; static int hf_rlc_lte_sequence_analysis_expected_sn = -1; static int hf_rlc_lte_sequence_analysis_framing_info_correct = -1; static int hf_rlc_lte_sequence_analysis_mac_retx = -1; static int hf_rlc_lte_sequence_analysis_retx = -1; static int hf_rlc_lte_sequence_analysis_repeated = -1; static int hf_rlc_lte_sequence_analysis_skipped = -1; static int hf_rlc_lte_sequence_analysis_repeated_nack = -1; static int hf_rlc_lte_sequence_analysis_repeated_nack_original_frame = -1; static int hf_rlc_lte_sequence_analysis_ack_out_of_range = -1; static int hf_rlc_lte_sequence_analysis_ack_out_of_range_opposite_frame = -1; /* Reassembly */ static int hf_rlc_lte_reassembly_source = -1; static int hf_rlc_lte_reassembly_source_number_of_segments = -1; static int hf_rlc_lte_reassembly_source_total_length = -1; static int hf_rlc_lte_reassembly_source_segment = -1; static int hf_rlc_lte_reassembly_source_segment_sn = -1; static int hf_rlc_lte_reassembly_source_segment_framenum = -1; static int hf_rlc_lte_reassembly_source_segment_length = -1; /* Subtrees. */ static int ett_rlc_lte = -1; static int ett_rlc_lte_context = -1; static int ett_rlc_lte_um_header = -1; static int ett_rlc_lte_am_header = -1; static int ett_rlc_lte_extension_part = -1; static int ett_rlc_lte_sequence_analysis = -1; static int ett_rlc_lte_reassembly_source = -1; static int ett_rlc_lte_reassembly_source_segment = -1; static expert_field ei_rlc_lte_context_mode = EI_INIT; static expert_field ei_rlc_lte_am_nack_sn = EI_INIT; static expert_field ei_rlc_lte_am_nack_sn_ahead_ack = EI_INIT; static expert_field ei_rlc_lte_um_sn_repeated = EI_INIT; static expert_field ei_rlc_lte_am_nack_sn_ack_same = EI_INIT; static expert_field ei_rlc_lte_am_cpt = EI_INIT; static expert_field ei_rlc_lte_am_data_no_data = EI_INIT; static expert_field ei_rlc_lte_sequence_analysis_last_segment_complete = EI_INIT; static expert_field ei_rlc_lte_sequence_analysis_mac_retx = EI_INIT; static expert_field ei_rlc_lte_am_nack_sn_partial = EI_INIT; static expert_field ei_rlc_lte_sequence_analysis_repeated_nack = EI_INIT; static expert_field ei_rlc_lte_bytes_after_status_pdu_complete = EI_INIT; static expert_field ei_rlc_lte_sequence_analysis_repeated = EI_INIT; static expert_field ei_rlc_lte_wrong_sequence_number = EI_INIT; static expert_field ei_rlc_lte_sequence_analysis_retx = EI_INIT; static expert_field ei_rlc_lte_am_sn_missing = EI_INIT; static expert_field ei_rlc_lte_um_sn = EI_INIT; static expert_field ei_rlc_lte_header_only = EI_INIT; static expert_field ei_rlc_lte_am_data_no_data_beyond_extensions = EI_INIT; static expert_field ei_rlc_lte_um_sn_missing = EI_INIT; static expert_field ei_rlc_lte_sequence_analysis_ack_out_of_range_opposite_frame = EI_INIT; static expert_field ei_rlc_lte_sequence_analysis_last_segment_not_continued = EI_INIT; static expert_field ei_rlc_lte_reserved_bits_not_zero = EI_INIT; /* Value-strings */ static const value_string direction_vals[] = { { DIRECTION_UPLINK, "Uplink"}, { DIRECTION_DOWNLINK, "Downlink"}, { 0, NULL } }; static const value_string rlc_mode_short_vals[] = { { RLC_TM_MODE, "TM"}, { RLC_UM_MODE, "UM"}, { RLC_AM_MODE, "AM"}, { RLC_PREDEF, "PREDEFINED"}, /* For data testing */ { 0, NULL } }; static const value_string rlc_mode_vals[] = { { RLC_TM_MODE, "Transparent Mode"}, { RLC_UM_MODE, "Unacknowledged Mode"}, { RLC_AM_MODE, "Acknowledged Mode"}, { 0, NULL } }; static const value_string rlc_channel_type_vals[] = { { CHANNEL_TYPE_CCCH, "CCCH"}, { CHANNEL_TYPE_BCCH_BCH, "BCCH_BCH"}, { CHANNEL_TYPE_PCCH, "PCCH"}, { CHANNEL_TYPE_SRB, "SRB"}, { CHANNEL_TYPE_DRB, "DRB"}, { CHANNEL_TYPE_BCCH_DL_SCH, "BCCH_DL_SCH"}, { CHANNEL_TYPE_MCCH, "MCCH"}, { CHANNEL_TYPE_MTCH, "MTCH"}, { 0, NULL } }; static const value_string framing_info_vals[] = { { 0, "First byte begins a RLC SDU and last byte ends a RLC SDU"}, { 1, "First byte begins a RLC SDU and last byte does not end a RLC SDU"}, { 2, "First byte does not begin a RLC SDU and last byte ends a RLC SDU"}, { 3, "First byte does not begin a RLC SDU and last byte does not end a RLC SDU"}, { 0, NULL } }; static const value_string fixed_extension_vals[] = { { 0, "Data field follows from the octet following the fixed part of the header"}, { 1, "A set of E field and LI field follows from the octet following the fixed part of the header"}, { 0, NULL } }; static const value_string extension_extension_vals[] = { { 0, "Data field follows from the octet following the LI field following this E field"}, { 1, "A set of E field and LI field follows from the bit following the LI field following this E field"}, { 0, NULL } }; static const value_string data_or_control_vals[] = { { 0, "Control PDU"}, { 1, "Data PDU"}, { 0, NULL } }; static const value_string resegmentation_flag_vals[] = { { 0, "AMD PDU"}, { 1, "AMD PDU segment"}, { 0, NULL } }; static const value_string polling_bit_vals[] = { { 0, "Status report not requested"}, { 1, "Status report is requested"}, { 0, NULL } }; static const value_string lsf_vals[] = { { 0, "Last byte of the AMD PDU segment does not correspond to the last byte of an AMD PDU"}, { 1, "Last byte of the AMD PDU segment corresponds to the last byte of an AMD PDU"}, { 0, NULL } }; static const value_string control_pdu_type_vals[] = { { 0, "STATUS PDU"}, { 0, NULL } }; static const value_string am_e1_vals[] = { { 0, "A set of NACK_SN, E1 and E2 does not follow"}, { 1, "A set of NACK_SN, E1 and E2 follows"}, { 0, NULL } }; static const value_string am_e2_vals[] = { { 0, "A set of SOstart and SOend does not follow for this NACK_SN"}, { 1, "A set of SOstart and SOend follows for this NACK_SN"}, { 0, NULL } }; static const value_string header_only_vals[] = { { 0, "RLC PDU Headers and body present"}, { 1, "RLC PDU Headers only"}, { 0, NULL } }; /**********************************************************************************/ /* These are for keeping track of UM/AM extension headers, and the lengths found */ /* in them */ static guint8 s_number_of_extensions = 0; #define MAX_RLC_SDUS 64 static guint16 s_lengths[MAX_RLC_SDUS]; /*********************************************************************/ /* UM/AM sequence analysis */ /* Types for RLC channel hash table */ /* This table is maintained during initial dissection of RLC */ /* frames, mapping from channel_hash_key -> sequence_analysis_report */ /* Channel key */ typedef struct { guint ueId : 16; guint channelType : 3; guint channelId : 5; guint direction : 1; } channel_hash_key; /******************************************************************/ /* State maintained for AM/UM reassembly */ typedef struct rlc_segment { guint32 frameNum; guint16 SN; guint8 *data; guint16 length; } rlc_segment; typedef struct rlc_channel_reassembly_info { guint16 number_of_segments; #define RLC_MAX_SEGMENTS 100 rlc_segment segments[RLC_MAX_SEGMENTS]; } rlc_channel_reassembly_info; /*******************************************************************/ /* Conversation-type status for sequence analysis on channel */ typedef struct { guint8 rlcMode; /* For UM, we always expect the SN to keep advancing, and these fields keep track of this. For AM, these correspond to new data */ guint16 previousSequenceNumber; guint32 previousFrameNum; gboolean previousSegmentIncomplete; /* Accumulate info about current segmented SDU */ struct rlc_channel_reassembly_info *reassembly_info; } channel_sequence_analysis_status; /* The sequence analysis channel hash table */ static GHashTable *sequence_analysis_channel_hash = NULL; /* Types for sequence analysis frame report hash table */ /* This is a table from framenum -> state_report_in_frame */ /* This is necessary because the per-packet info is already being used */ /* for context information before the dissector is called */ /* Info to attach to frame when first read, recording what to show about sequence */ typedef enum { SN_OK, SN_Repeated, SN_MAC_Retx, SN_Retx, SN_Missing, ACK_Out_of_Window, SN_Error } sequence_analysis_state; typedef struct { gboolean sequenceExpectedCorrect; guint16 sequenceExpected; guint32 previousFrameNum; gboolean previousSegmentIncomplete; guint32 nextFrameNum; guint16 firstSN; guint16 lastSN; /* AM/UM */ sequence_analysis_state state; } sequence_analysis_report; /* The sequence analysis frame report hash table instance itself */ static GHashTable *sequence_analysis_report_hash = NULL; static gpointer get_report_hash_key(guint16 SN, guint32 frameNumber, rlc_lte_info *p_rlc_lte_info, gboolean do_persist); /* The reassembly result hash table */ static GHashTable *reassembly_report_hash = NULL; /* Create a new struct for reassembly */ static void reassembly_reset(channel_sequence_analysis_status *status) { status->reassembly_info = wmem_new0(wmem_file_scope(), rlc_channel_reassembly_info); } /* Hide previous one */ static void reassembly_destroy(channel_sequence_analysis_status *status) { /* Just "leak" it. There seems to be no way to free this memory... */ status->reassembly_info = NULL; } /* Add a new segment to the accumulating segmented SDU */ static void reassembly_add_segment(channel_sequence_analysis_status *status, guint16 SN, guint32 frame, tvbuff_t *tvb, gint offset, gint length) { int segment_number = status->reassembly_info->number_of_segments; guint8 *segment_data; /* Give up if reach segment limit */ if (segment_number >= (RLC_MAX_SEGMENTS-1)) { reassembly_destroy(status); return; } segment_data = (guint8 *)wmem_alloc(wmem_file_scope(), length); /* TODO: is there a better way to do this? */ memcpy(segment_data, tvb_get_ptr(tvb, offset, length), length); /* Add new segment */ status->reassembly_info->segments[segment_number].frameNum = frame; status->reassembly_info->segments[segment_number].SN = SN; status->reassembly_info->segments[segment_number].data = segment_data; status->reassembly_info->segments[segment_number].length = length; status->reassembly_info->number_of_segments++; } /* Record the current & complete segmented SDU by mapping from this frame number to struct with segment info. */ static void reassembly_record(channel_sequence_analysis_status *status, packet_info *pinfo, guint16 SN, rlc_lte_info *p_rlc_lte_info) { /* Just store existing info in hash table */ g_hash_table_insert(reassembly_report_hash, get_report_hash_key(SN, pinfo->fd->num, p_rlc_lte_info, TRUE), status->reassembly_info); } /* Create and return a tvb based upon contents of reassembly info */ static tvbuff_t* reassembly_get_reassembled_tvb(rlc_channel_reassembly_info *reassembly_info, tvbuff_t *parent_tvb, packet_info *pinfo) { gint n; guint combined_length = 0; guint8 *combined_data; guint combined_offset = 0; tvbuff_t *reassembled_tvb; /* Allocate buffer big enough to hold re-assembled data */ for (n=0; n < reassembly_info->number_of_segments; n++) { combined_length += reassembly_info->segments[n].length; } combined_data = (guint8 *)g_malloc(combined_length); /* Copy data into contiguous buffer */ for (n=0; n < reassembly_info->number_of_segments; n++) { guint8 *data = reassembly_info->segments[n].data; int length = reassembly_info->segments[n].length; memcpy(combined_data+combined_offset, data, length); combined_offset += length; } /* Create and return tvb with this data */ reassembled_tvb = tvb_new_child_real_data(parent_tvb, combined_data, combined_offset, combined_offset); tvb_set_free_cb(reassembled_tvb, g_free); add_new_data_source(pinfo, reassembled_tvb, "Reassembled SDU"); return reassembled_tvb; } /* Show where the segments came from for a reassembled SDU */ static void reassembly_show_source(rlc_channel_reassembly_info *reassembly_info, proto_tree *tree, tvbuff_t *tvb, gint offset) { int n; proto_item *source_ti, *ti; proto_tree *source_tree; proto_item *segment_ti; proto_tree *segment_tree; guint total_length=0; /* Create root of source info */ source_ti = proto_tree_add_item(tree, hf_rlc_lte_reassembly_source, tvb, 0, 0, ENC_ASCII|ENC_NA); source_tree = proto_item_add_subtree(source_ti, ett_rlc_lte_reassembly_source); PROTO_ITEM_SET_GENERATED(source_ti); for (n=0; n < reassembly_info->number_of_segments; n++) { total_length += reassembly_info->segments[n].length; } proto_item_append_text(source_ti, " %u segments, %u bytes", reassembly_info->number_of_segments, total_length); /* Number of segments */ ti = proto_tree_add_uint(source_tree, hf_rlc_lte_reassembly_source_number_of_segments, tvb, 0, 0, reassembly_info->number_of_segments); PROTO_ITEM_SET_GENERATED(ti); /* Total length */ ti = proto_tree_add_uint(source_tree, hf_rlc_lte_reassembly_source_total_length, tvb, 0, 0, total_length); PROTO_ITEM_SET_GENERATED(ti); /* Now add info about each segment in turn */ for (n=0; n < reassembly_info->number_of_segments; n++) { /* Add next segment as a subtree */ rlc_segment *segment = &(reassembly_info->segments[n]); proto_item_append_text(source_ti, " (SN=%u frame=%u len=%u)", segment->SN, segment->frameNum, segment->length); /* N.B. assume last segment from passed-in tvb! */ segment_ti = proto_tree_add_item(source_tree, hf_rlc_lte_reassembly_source_segment, tvb, (n == reassembly_info->number_of_segments-1) ? offset : 0, (n == reassembly_info->number_of_segments-1) ? segment->length : 0, ENC_NA); segment_tree = proto_item_add_subtree(segment_ti, ett_rlc_lte_reassembly_source_segment); proto_item_append_text(segment_ti, " (SN=%u frame=%u length=%u)", segment->SN, segment->frameNum, segment->length); PROTO_ITEM_SET_GENERATED(segment_ti); /* Add details to segment tree */ ti = proto_tree_add_uint(segment_tree, hf_rlc_lte_reassembly_source_segment_sn, tvb, 0, 0, segment->SN); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_uint(segment_tree, hf_rlc_lte_reassembly_source_segment_framenum, tvb, 0, 0, segment->frameNum); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_uint(segment_tree, hf_rlc_lte_reassembly_source_segment_length, tvb, 0, 0, segment->length); PROTO_ITEM_SET_GENERATED(ti); } } /******************************************************************/ /* Conversation-type status for repeated NACK checking on channel */ typedef struct { guint16 noOfNACKs; guint16 NACKs[MAX_NACKs]; guint32 frameNum; } channel_repeated_nack_status; static GHashTable *repeated_nack_channel_hash = NULL; typedef struct { guint16 noOfNACKsRepeated; guint16 repeatedNACKs[MAX_NACKs]; guint32 previousFrameNum; } channel_repeated_nack_report; static GHashTable *repeated_nack_report_hash = NULL; /********************************************************/ /* Forward declarations & functions */ static void dissect_rlc_lte_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_udp_framing); /* Write the given formatted text to: - the info column - the top-level RLC PDU item - another subtree item (if supplied) */ static void write_pdu_label_and_info(proto_item *pdu_ti, proto_item *sub_ti, packet_info *pinfo, const char *format, ...) { #define MAX_INFO_BUFFER 256 static char info_buffer[MAX_INFO_BUFFER]; va_list ap; va_start(ap, format); g_vsnprintf(info_buffer, MAX_INFO_BUFFER, format, ap); va_end(ap); /* Add to indicated places */ col_append_str(pinfo->cinfo, COL_INFO, info_buffer); proto_item_append_text(pdu_ti, "%s", info_buffer); if (sub_ti != NULL) { proto_item_append_text(sub_ti, "%s", info_buffer); } } /* Version of function above, where no g_vsnprintf() call needed - the info column - the top-level RLC PDU item - another subtree item (if supplied) */ static void write_pdu_label_and_info_literal(proto_item *pdu_ti, proto_item *sub_ti, packet_info *pinfo, const char *info_buffer) { /* Add to indicated places */ col_append_str(pinfo->cinfo, COL_INFO, info_buffer); proto_item_append_text(pdu_ti, "%s", info_buffer); if (sub_ti != NULL) { proto_item_append_text(sub_ti, "%s", info_buffer); } } /* Dissect extension headers (common to both UM and AM) */ static int dissect_rlc_lte_extension_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset) { guint8 isOdd; guint64 extension = 1; guint64 length; /* Reset this count */ s_number_of_extensions = 0; while (extension && (s_number_of_extensions < MAX_RLC_SDUS)) { proto_tree *extension_part_tree; proto_item *extension_part_ti; isOdd = (s_number_of_extensions % 2); /* Extension part subtree */ extension_part_ti = proto_tree_add_string_format(tree, hf_rlc_lte_extension_part, tvb, offset, 2, "", "Extension Part"); extension_part_tree = proto_item_add_subtree(extension_part_ti, ett_rlc_lte_extension_part); /* Read next extension */ proto_tree_add_bits_ret_val(extension_part_tree, hf_rlc_lte_extension_e, tvb, (offset*8) + ((isOdd) ? 4 : 0), 1, &extension, ENC_BIG_ENDIAN); /* Read length field */ proto_tree_add_bits_ret_val(extension_part_tree, hf_rlc_lte_extension_li, tvb, (offset*8) + ((isOdd) ? 5 : 1), 11, &length, ENC_BIG_ENDIAN); proto_item_append_text(extension_part_tree, " (length=%u)", (guint16)length); /* Move on to byte of next extension */ if (isOdd) { offset += 2; } else { offset++; } s_lengths[s_number_of_extensions++] = (guint16)length; } /* May need to skip padding after last extension part */ isOdd = (s_number_of_extensions % 2); if (isOdd) { proto_tree_add_item(tree, hf_rlc_lte_extension_padding, tvb, offset++, 1, ENC_BIG_ENDIAN); } return offset; } /* Show in the info column how many bytes are in the UM/AM PDU, and indicate whether or not the beginning and end are included in this packet */ static void show_PDU_in_info(packet_info *pinfo, proto_item *top_ti, gint32 length, gboolean first_includes_start, gboolean last_includes_end) { /* Reflect this PDU in the info column */ if (length > 0) { write_pdu_label_and_info(top_ti, NULL, pinfo, " %s%u-byte%s%s", (first_includes_start) ? "[" : "..", length, (length > 1) ? "s" : "", (last_includes_end) ? "]" : ".."); } else { write_pdu_label_and_info(top_ti, NULL, pinfo, " %sunknown-bytes%s", (first_includes_start) ? "[" : "..", (last_includes_end) ? "]" : ".."); } } /* Show an SDU. If configured, pass to PDCP/RRC/IP dissector */ static void show_PDU_in_tree(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, rlc_lte_info *rlc_info, gboolean whole_pdu, rlc_channel_reassembly_info *reassembly_info, sequence_analysis_state state) { /* Add raw data (according to mode) */ proto_item *data_ti = proto_tree_add_item(tree, (rlc_info->rlcMode == RLC_AM_MODE) ? hf_rlc_lte_am_data : hf_rlc_lte_um_data, tvb, offset, length, ENC_NA); if (whole_pdu || (reassembly_info != NULL)) { if (((global_rlc_lte_call_pdcp_for_srb) && (rlc_info->channelType == CHANNEL_TYPE_SRB)) || ((global_rlc_lte_call_pdcp_for_drb != PDCP_drb_off) && (rlc_info->channelType == CHANNEL_TYPE_DRB))) { /* Send whole PDU to PDCP */ /* TODO: made static to avoid compiler warning... */ static tvbuff_t *pdcp_tvb = NULL; struct pdcp_lte_info *p_pdcp_lte_info; /* Get tvb for passing to LTE PDCP dissector */ if (reassembly_info == NULL) { pdcp_tvb = tvb_new_subset(tvb, offset, length, length); } else { /* Get combined tvb. */ pdcp_tvb = reassembly_get_reassembled_tvb(reassembly_info, tvb, pinfo); reassembly_show_source(reassembly_info, tree, tvb, offset); } /* Reuse or allocate struct */ p_pdcp_lte_info = (pdcp_lte_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_pdcp_lte, 0); if (p_pdcp_lte_info == NULL) { p_pdcp_lte_info = wmem_new0(wmem_file_scope(), pdcp_lte_info); /* Store info in packet */ p_add_proto_data(wmem_file_scope(), pinfo, proto_pdcp_lte, 0, p_pdcp_lte_info); } p_pdcp_lte_info->ueid = rlc_info->ueid; p_pdcp_lte_info->channelType = Channel_DCCH; p_pdcp_lte_info->channelId = rlc_info->channelId; p_pdcp_lte_info->direction = rlc_info->direction; p_pdcp_lte_info->is_retx = (state != SN_OK); /* Set plane and sequence number length */ p_pdcp_lte_info->no_header_pdu = FALSE; if (rlc_info->channelType == CHANNEL_TYPE_SRB) { p_pdcp_lte_info->plane = SIGNALING_PLANE; p_pdcp_lte_info->seqnum_length = 5; } else { p_pdcp_lte_info->plane = USER_PLANE; switch (global_rlc_lte_call_pdcp_for_drb) { case PDCP_drb_SN_7: p_pdcp_lte_info->seqnum_length = 7; break; case PDCP_drb_SN_12: p_pdcp_lte_info->seqnum_length = 12; break; case PDCP_drb_SN_15: p_pdcp_lte_info->seqnum_length = 15; break; case PDCP_drb_SN_signalled: /* Use whatever was signalled (e.g. in RRC) */ p_pdcp_lte_info->seqnum_length = signalled_pdcp_sn_bits; break; default: DISSECTOR_ASSERT(FALSE); break; } } TRY { call_dissector_only(pdcp_lte_handle, pdcp_tvb, pinfo, tree, NULL); } CATCH_ALL { } ENDTRY PROTO_ITEM_SET_HIDDEN(data_ti); } else if (global_rlc_lte_call_rrc_for_mcch && (rlc_info->channelType == CHANNEL_TYPE_MCCH)) { /* Send whole PDU to RRC */ static tvbuff_t *rrc_tvb = NULL; volatile dissector_handle_t protocol_handle; /* Get tvb for passing to LTE RRC dissector */ if (reassembly_info == NULL) { rrc_tvb = tvb_new_subset(tvb, offset, length, length); } else { /* Get combined tvb. */ rrc_tvb = reassembly_get_reassembled_tvb(reassembly_info, tvb, pinfo); reassembly_show_source(reassembly_info, tree, tvb, offset); } /* Get dissector handle */ protocol_handle = find_dissector("lte_rrc.mcch"); TRY { call_dissector_only(protocol_handle, rrc_tvb, pinfo, tree, NULL); } CATCH_ALL { } ENDTRY PROTO_ITEM_SET_HIDDEN(data_ti); } else if (global_rlc_lte_call_ip_for_mtch && (rlc_info->channelType == CHANNEL_TYPE_MTCH)) { /* Send whole PDU to IP */ static tvbuff_t *ip_tvb = NULL; /* Get tvb for passing to IP dissector */ if (reassembly_info == NULL) { ip_tvb = tvb_new_subset(tvb, offset, length, length); } else { /* Get combined tvb. */ ip_tvb = reassembly_get_reassembled_tvb(reassembly_info, tvb, pinfo); reassembly_show_source(reassembly_info, tree, tvb, offset); } TRY { call_dissector_only(ip_handle, ip_tvb, pinfo, tree, NULL); } CATCH_ALL { } ENDTRY PROTO_ITEM_SET_HIDDEN(data_ti); } } } /* Hash table functions for RLC channels */ /* Equal keys */ static gint rlc_channel_equal(gconstpointer v, gconstpointer v2) { const channel_hash_key* val1 = (const channel_hash_key *)v; const channel_hash_key* val2 = (const channel_hash_key *)v2; /* All fields must match */ /* N.B. Currently fits into one word, so could return (*v == *v2) if we're sure they're initialised to 0... */ return ((val1->ueId == val2->ueId) && (val1->channelType == val2->channelType) && (val1->channelId == val2->channelId) && (val1->direction == val2->direction)); } /* Compute a hash value for a given key. */ static guint rlc_channel_hash_func(gconstpointer v) { const channel_hash_key* val1 = (const channel_hash_key *)v; /* TODO: check/reduce multipliers */ return ((val1->ueId * 1024) + (val1->channelType*64) + (val1->channelId*2) + val1->direction); } /*************************************************************************/ /* Result hash */ typedef struct { guint32 frameNumber; guint32 SN : 10; guint32 channelType : 2; guint32 channelId: 5; guint32 direction: 1; } rlc_result_hash_key; /* Compare 2 rlc_result_hash_key structs */ static gint rlc_result_hash_equal(gconstpointer v, gconstpointer v2) { const rlc_result_hash_key *val1 = (const rlc_result_hash_key *)v; const rlc_result_hash_key *val2 = (const rlc_result_hash_key *)v2; /* All fields (and any padding...) must match */ return (memcmp(val1, val2, sizeof(rlc_result_hash_key)) == 0); } /* Compute a hash value for a given key. */ static guint rlc_result_hash_func(gconstpointer v) { const rlc_result_hash_key* val1 = (const rlc_result_hash_key *)v; /* Got rid of multipliers - no evidence that they reduced collisions */ return val1->frameNumber + val1->SN + val1->channelType + val1->channelId + val1->direction; } /* Convenience function to get a pointer for the hash_func to work with */ static gpointer get_report_hash_key(guint16 SN, guint32 frameNumber, rlc_lte_info *p_rlc_lte_info, gboolean do_persist) { static rlc_result_hash_key key; rlc_result_hash_key *p_key; /* Only allocate a struct when will be adding entry */ if (do_persist) { p_key = wmem_new0(wmem_file_scope(), rlc_result_hash_key); } else { memset(&key, 0, sizeof(rlc_result_hash_key)); p_key = &key; } /* Fill in details, and return pointer */ p_key->frameNumber = frameNumber; p_key->SN = SN; p_key->channelType = p_rlc_lte_info->channelType; p_key->channelId = p_rlc_lte_info->channelId; p_key->direction = p_rlc_lte_info->direction; return p_key; } static void checkFIconsistency(sequence_analysis_report *p, rlc_lte_info *p_rlc_lte_info, gboolean newSegmentStarted, proto_tree *seqnum_tree, packet_info *pinfo, tvbuff_t *tvb) { proto_item *ti; if (p->previousSegmentIncomplete) { /* Previous segment was incomplete, so this PDU should continue it */ if (newSegmentStarted) { ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_framing_info_correct, tvb, 0, 0, FALSE); expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_last_segment_not_continued, "Last segment of previous PDU was not continued for UE %u (%s-%u)", p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); } else { ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_framing_info_correct, tvb, 0, 0, TRUE); PROTO_ITEM_SET_HIDDEN(ti); } } else { /* Previous segment was complete, so this PDU should start a new one */ if (!newSegmentStarted) { ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_framing_info_correct, tvb, 0, 0, FALSE); expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_last_segment_complete, "Last segment of previous PDU was complete, but new segment was not started on UE %u (%s-%u)", p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); } else { ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_framing_info_correct, tvb, 0, 0, TRUE); PROTO_ITEM_SET_HIDDEN(ti); } } PROTO_ITEM_SET_GENERATED(ti); } /* Add to the tree values associated with sequence analysis for this frame */ static void addChannelSequenceInfo(sequence_analysis_report *p, gboolean isControlFrame, rlc_lte_info *p_rlc_lte_info, guint16 sequenceNumber, gboolean newSegmentStarted, rlc_lte_tap_info *tap_info, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb) { proto_tree *seqnum_tree; proto_item *seqnum_ti; proto_item *ti; /* Create subtree */ seqnum_ti = proto_tree_add_string_format(tree, hf_rlc_lte_sequence_analysis, tvb, 0, 0, "", "Sequence Analysis"); seqnum_tree = proto_item_add_subtree(seqnum_ti, ett_rlc_lte_sequence_analysis); PROTO_ITEM_SET_GENERATED(seqnum_ti); if (p->previousFrameNum != 0) { ti = proto_tree_add_uint(seqnum_tree, hf_rlc_lte_sequence_analysis_previous_frame, tvb, 0, 0, p->previousFrameNum); PROTO_ITEM_SET_GENERATED(ti); } switch (p_rlc_lte_info->rlcMode) { case RLC_AM_MODE: /********************************************/ /* AM */ /********************************************/ switch (p->state) { case SN_OK: if (isControlFrame) { return; } ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); proto_item_append_text(seqnum_ti, " - OK"); /* Link to next SN in channel (if known) */ if (p->nextFrameNum != 0) { proto_tree_add_uint(seqnum_tree, hf_rlc_lte_sequence_analysis_next_frame, tvb, 0, 0, p->nextFrameNum); } /* Correct sequence number, so check frame indication bits consistent */ /* Deactivated for now as it gets confused by resegmentation */ /* checkFIconsistency(p, p_rlc_lte_info, newSegmentStarted, seqnum_tree, pinfo, tvb); */ break; case SN_MAC_Retx: if (isControlFrame) { return; } ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_mac_retx, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_mac_retx, "AM Frame retransmitted for %s on UE %u - due to MAC retx! (%s-%u)", val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, " - MAC retx of SN %u", p->firstSN); break; case SN_Retx: if (isControlFrame) { return; } ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_retx, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_retx, "AM Frame retransmitted for %s on UE %u - most likely in response to NACK (%s-%u)", val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, " - SN %u retransmitted", p->firstSN); break; case SN_Repeated: if (isControlFrame) { return; } ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_repeated, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_repeated, "AM SN Repeated for %s for UE %u - probably because didn't receive Status PDU? (%s-%u)", val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, "- SN %u Repeated", p->firstSN); break; case SN_Missing: if (isControlFrame) { return; } ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_skipped, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); if (p->lastSN != p->firstSN) { expert_add_info_format(pinfo, ti, &ei_rlc_lte_am_sn_missing, "AM SNs (%u to %u) missing for %s on UE %u (%s-%u)", p->firstSN, p->lastSN, val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, " - SNs missing (%u to %u)", p->firstSN, p->lastSN); tap_info->missingSNs = ((1024 + p->lastSN - p->firstSN) % 1024) + 1; } else { expert_add_info_format(pinfo, ti, &ei_rlc_lte_am_sn_missing, "AM SN (%u) missing for %s on UE %u (%s-%u)", p->firstSN, val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, " - SN missing (%u)", p->firstSN); tap_info->missingSNs = 1; } break; case ACK_Out_of_Window: if (!isControlFrame) { return; } /* Not OK */ ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); /* Out of range */ PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ack_out_of_range, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); /* Link back to last seen SN in other direction */ ti = proto_tree_add_uint(seqnum_tree, hf_rlc_lte_sequence_analysis_ack_out_of_range_opposite_frame, tvb, 0, 0, p->previousFrameNum); PROTO_ITEM_SET_GENERATED(ti); /* Expert error */ expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_ack_out_of_range_opposite_frame, "AM ACK for SN %u - but last received SN in other direction is %u for UE %u (%s-%u)", p->firstSN, p->sequenceExpected, p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, "- ACK SN %u Outside Rx Window - last received SN is %u", p->firstSN, p->sequenceExpected); break; default: return; } break; case RLC_UM_MODE: /********************************************/ /* UM */ /********************************************/ /* Expected sequence number */ ti = proto_tree_add_uint(seqnum_tree, hf_rlc_lte_sequence_analysis_expected_sn, tvb, 0, 0, p->sequenceExpected); PROTO_ITEM_SET_GENERATED(ti); if (p->sequenceExpectedCorrect) { PROTO_ITEM_SET_HIDDEN(ti); } if (!p->sequenceExpectedCorrect) { /* Work out SN wrap (in case needed below) */ guint16 snLimit; if (p_rlc_lte_info->UMSequenceNumberLength == 5) { snLimit = 32; } else { snLimit = 1024; } switch (p->state) { case SN_Missing: ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_skipped, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); if (p->lastSN != p->firstSN) { expert_add_info_format(pinfo, ti, &ei_rlc_lte_um_sn_missing, "UM SNs (%u to %u) missing for %s on UE %u (%s-%u)", p->firstSN, p->lastSN, val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, " - SNs missing (%u to %u)", p->firstSN, p->lastSN); tap_info->missingSNs = ((snLimit + p->lastSN - p->firstSN) % snLimit) + 1; } else { expert_add_info_format(pinfo, ti, &ei_rlc_lte_um_sn_missing, "UM SN (%u) missing for %s on UE %u (%s-%u)", p->firstSN, val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, " - SN missing (%u)", p->firstSN); tap_info->missingSNs = 1; } break; case SN_Repeated: ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_repeated, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); expert_add_info_format(pinfo, ti, &ei_rlc_lte_um_sn_repeated, "UM SN (%u) repeated for %s for UE %u (%s-%u)", p->firstSN, val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); proto_item_append_text(seqnum_ti, "- SN %u Repeated", p->firstSN); break; case SN_MAC_Retx: ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_mac_retx, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_mac_retx, "UM Frame retransmitted for %s on UE %u - due to MAC retx! (%s-%u)", val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); break; default: /* Incorrect sequence number */ expert_add_info_format(pinfo, ti, &ei_rlc_lte_wrong_sequence_number, "Wrong Sequence Number for %s on UE %u - got %u, expected %u (%s-%u)", val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid, sequenceNumber, p->sequenceExpected, val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); break; } } else { /* Correct sequence number, so check frame indication bits consistent */ checkFIconsistency(p, p_rlc_lte_info, newSegmentStarted, seqnum_tree, pinfo, tvb); /* Set OK here! */ ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, TRUE); PROTO_ITEM_SET_GENERATED(ti); proto_item_append_text(seqnum_ti, " - OK"); } /* Next channel frame */ if (p->nextFrameNum != 0) { ti = proto_tree_add_uint(seqnum_tree, hf_rlc_lte_sequence_analysis_next_frame, tvb, 0, 0, p->nextFrameNum); PROTO_ITEM_SET_GENERATED(ti); } } } /* Update the channel status and set report for this frame */ static sequence_analysis_state checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb, rlc_lte_info *p_rlc_lte_info, gboolean isControlFrame, guint8 number_of_segments, guint16 firstSegmentOffset, guint16 firstSegmentLength, guint16 lastSegmentOffset, guint16 sequenceNumber, gboolean first_includes_start, gboolean last_includes_end, gboolean is_resegmented _U_, rlc_lte_tap_info *tap_info, proto_tree *tree) { channel_hash_key channel_key; channel_hash_key *p_channel_key; channel_sequence_analysis_status *p_channel_status; sequence_analysis_report *p_report_in_frame = NULL; gboolean createdChannel = FALSE; guint16 expectedSequenceNumber = 0; guint16 snLimit = 0; /* If find stat_report_in_frame already, use that and get out */ if (pinfo->fd->flags.visited) { p_report_in_frame = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, get_report_hash_key(sequenceNumber, pinfo->fd->num, p_rlc_lte_info, FALSE)); if (p_report_in_frame != NULL) { addChannelSequenceInfo(p_report_in_frame, isControlFrame, p_rlc_lte_info, sequenceNumber, first_includes_start, tap_info, pinfo, tree, tvb); return p_report_in_frame->state; } /* Don't just give up here... */ } /**************************************************/ /* Create or find an entry for this channel state */ channel_key.ueId = p_rlc_lte_info->ueid; channel_key.channelType = p_rlc_lte_info->channelType; channel_key.channelId = p_rlc_lte_info->channelId; channel_key.direction = p_rlc_lte_info->direction; /* Do the table lookup */ p_channel_status = (channel_sequence_analysis_status*)g_hash_table_lookup(sequence_analysis_channel_hash, &channel_key); /* Create table entry if necessary */ if (p_channel_status == NULL) { createdChannel = TRUE; /* Allocate a new value and duplicate key contents */ p_channel_status = wmem_new0(wmem_file_scope(), channel_sequence_analysis_status); p_channel_key = (channel_hash_key *)wmem_memdup(wmem_file_scope(), &channel_key, sizeof(channel_hash_key)); /* Set mode */ p_channel_status->rlcMode = p_rlc_lte_info->rlcMode; /* Add entry */ g_hash_table_insert(sequence_analysis_channel_hash, p_channel_key, p_channel_status); } /* Create space for frame state_report */ p_report_in_frame = wmem_new0(wmem_file_scope(), sequence_analysis_report); /* Deal with according to channel mode */ switch (p_channel_status->rlcMode) { case RLC_UM_MODE: if (p_rlc_lte_info->UMSequenceNumberLength == 5) { snLimit = 32; } else { snLimit = 1024; } /* Work out expected sequence number */ if (!createdChannel) { expectedSequenceNumber = (p_channel_status->previousSequenceNumber + 1) % snLimit; } else { /* Whatever we got is fine.. */ expectedSequenceNumber = sequenceNumber; } if ((sequenceNumber == 0) && ((p_rlc_lte_info->channelType == CHANNEL_TYPE_MCCH) || (p_rlc_lte_info->channelType == CHANNEL_TYPE_MTCH))) { /* With eMBMS, SN restarts to 0 at each MCH Scheduling Period so we cannot deduce easily whether there was a PDU loss or not without analysing the Frame Indicator; assume no loss when seeing 0 */ expectedSequenceNumber = 0; } /* Set report for this frame */ /* For UM, sequence number is always expectedSequence number */ p_report_in_frame->sequenceExpectedCorrect = (sequenceNumber == expectedSequenceNumber); /* For wrong sequence number... */ if (!p_report_in_frame->sequenceExpectedCorrect) { /* Don't get confused by MAC (HARQ) retx */ if (is_mac_lte_frame_retx(pinfo, p_rlc_lte_info->direction)) { p_report_in_frame->state = SN_MAC_Retx; p_report_in_frame->firstSN = sequenceNumber; /* No channel state to update */ break; } /* Frames are not missing if we get an earlier sequence number again */ /* TODO: taking time into account would give better idea of whether missing or repeated... */ else if ((p_rlc_lte_info->channelType == CHANNEL_TYPE_MCCH) || (p_rlc_lte_info->channelType == CHANNEL_TYPE_MTCH) || (((snLimit + sequenceNumber - expectedSequenceNumber) % snLimit) < 10)) { reassembly_destroy(p_channel_status); p_report_in_frame->state = SN_Missing; tap_info->missingSNs = (snLimit + sequenceNumber - expectedSequenceNumber) % snLimit; p_report_in_frame->firstSN = expectedSequenceNumber; p_report_in_frame->lastSN = (snLimit + sequenceNumber - 1) % snLimit; p_report_in_frame->sequenceExpected = expectedSequenceNumber; p_report_in_frame->previousFrameNum = p_channel_status->previousFrameNum; p_report_in_frame->previousSegmentIncomplete = p_channel_status->previousSegmentIncomplete; /* Update channel status to remember *this* frame */ p_channel_status->previousFrameNum = pinfo->fd->num; p_channel_status->previousSequenceNumber = sequenceNumber; p_channel_status->previousSegmentIncomplete = !last_includes_end; } else { /* An SN has been repeated */ p_report_in_frame->state = SN_Repeated; p_report_in_frame->firstSN = sequenceNumber; p_report_in_frame->sequenceExpected = expectedSequenceNumber; p_report_in_frame->previousFrameNum = p_channel_status->previousFrameNum; } } else { /* SN was OK */ p_report_in_frame->sequenceExpected = expectedSequenceNumber; p_report_in_frame->previousFrameNum = p_channel_status->previousFrameNum; p_report_in_frame->previousSegmentIncomplete = p_channel_status->previousSegmentIncomplete; /* Update channel status to remember *this* frame */ p_channel_status->previousFrameNum = pinfo->fd->num; p_channel_status->previousSequenceNumber = sequenceNumber; p_channel_status->previousSegmentIncomplete = !last_includes_end; if (p_channel_status->reassembly_info) { /* Add next segment to reassembly info */ reassembly_add_segment(p_channel_status, sequenceNumber, pinfo->fd->num, tvb, firstSegmentOffset, firstSegmentLength); /* The end of existing reassembly? */ if (!first_includes_start && ((number_of_segments > 1) || last_includes_end)) { reassembly_record(p_channel_status, pinfo, sequenceNumber, p_rlc_lte_info); reassembly_destroy(p_channel_status); } } /* The start of a new reassembly? */ if (!last_includes_end && ((number_of_segments > 1) || first_includes_start)) { guint16 lastSegmentLength = tvb_reported_length(tvb)-lastSegmentOffset; if (global_rlc_lte_reassembly) { reassembly_reset(p_channel_status); reassembly_add_segment(p_channel_status, sequenceNumber, pinfo->fd->num, tvb, lastSegmentOffset, lastSegmentLength); } } if (p_report_in_frame->previousFrameNum != 0) { /* Get report for previous frame */ sequence_analysis_report *p_previous_report; if (p_rlc_lte_info->UMSequenceNumberLength == 5) { snLimit = 32; } else { snLimit = 1024; } /* Look up report for previous SN */ p_previous_report = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, get_report_hash_key((sequenceNumber+snLimit-1) % snLimit, p_report_in_frame->previousFrameNum, p_rlc_lte_info, FALSE)); /* It really shouldn't be NULL... */ if (p_previous_report != NULL) { /* Point it forward to this one */ p_previous_report->nextFrameNum = pinfo->fd->num; } } } break; case RLC_AM_MODE: /* Work out expected sequence number */ if (!createdChannel) { expectedSequenceNumber = (p_channel_status->previousSequenceNumber + 1) % 1024; } else { /* Whatever we got is fine.. */ expectedSequenceNumber = sequenceNumber; } /* For AM, may be: - expected Sequence number OR - previous frame repeated - old SN being sent (in response to NACK) - new SN, but with frames missed out Assume window whose front is at expectedSequenceNumber */ /* First of all, check to see whether frame is judged to be MAC Retx */ if (is_mac_lte_frame_retx(pinfo, p_rlc_lte_info->direction)) { /* Just report that this is a MAC Retx */ p_report_in_frame->state = SN_MAC_Retx; p_report_in_frame->firstSN = sequenceNumber; /* No channel state to update */ break; } if (sequenceNumber != expectedSequenceNumber) { /* Don't trash reassembly info if this looks like a close retx... */ if (((1024 + sequenceNumber - expectedSequenceNumber) % 1024) < 50) { reassembly_destroy(p_channel_status); } } /* Expected? */ if (sequenceNumber == expectedSequenceNumber) { /* Set report for this frame */ p_report_in_frame->sequenceExpectedCorrect = TRUE; p_report_in_frame->sequenceExpected = expectedSequenceNumber; p_report_in_frame->previousFrameNum = p_channel_status->previousFrameNum; p_report_in_frame->previousSegmentIncomplete = p_channel_status->previousSegmentIncomplete; p_report_in_frame->state = SN_OK; /* Update channel status */ p_channel_status->previousSequenceNumber = sequenceNumber; p_channel_status->previousFrameNum = pinfo->fd->num; p_channel_status->previousSegmentIncomplete = !last_includes_end; if (p_channel_status->reassembly_info) { /* Add next segment to reassembly info */ reassembly_add_segment(p_channel_status, sequenceNumber, pinfo->fd->num, tvb, firstSegmentOffset, firstSegmentLength); /* The end of existing reassembly? */ if (!first_includes_start && ((number_of_segments > 1) || last_includes_end)) { reassembly_record(p_channel_status, pinfo, sequenceNumber, p_rlc_lte_info); reassembly_destroy(p_channel_status); } } /* The start of a new reassembly? */ if (!last_includes_end && ((number_of_segments > 1) || first_includes_start)) { guint16 lastSegmentLength = tvb_reported_length(tvb)-lastSegmentOffset; if (global_rlc_lte_reassembly) { reassembly_reset(p_channel_status); reassembly_add_segment(p_channel_status, sequenceNumber, pinfo->fd->num, tvb, lastSegmentOffset, lastSegmentLength); } } if (p_report_in_frame->previousFrameNum != 0) { /* Get report for previous frame */ sequence_analysis_report *p_previous_report; p_previous_report = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, get_report_hash_key((sequenceNumber+1023) % 1024, p_report_in_frame->previousFrameNum, p_rlc_lte_info, FALSE)); /* It really shouldn't be NULL... */ if (p_previous_report != NULL) { /* Point it forward to this one */ p_previous_report->nextFrameNum = pinfo->fd->num; } } } /* Previous subframe repeated? */ else if (((sequenceNumber+1) % 1024) == expectedSequenceNumber) { p_report_in_frame->state = SN_Repeated; /* Set report for this frame */ p_report_in_frame->sequenceExpectedCorrect = FALSE; p_report_in_frame->sequenceExpected = expectedSequenceNumber; p_report_in_frame->firstSN = sequenceNumber; p_report_in_frame->previousFrameNum = p_channel_status->previousFrameNum; p_report_in_frame->previousSegmentIncomplete = p_channel_status->previousSegmentIncomplete; /* Really should be nothing to update... */ p_channel_status->previousSequenceNumber = sequenceNumber; p_channel_status->previousFrameNum = pinfo->fd->num; p_channel_status->previousSegmentIncomplete = !last_includes_end; } else { /* Need to work out if new (with skips, or likely a retx (due to NACK)) */ int delta = (1024 + expectedSequenceNumber - sequenceNumber) % 1024; /* Rx window is 512, so check to see if this is a retx */ if (delta < 512) { /* Probably a retx due to receiving NACK */ p_report_in_frame->state = SN_Retx; p_report_in_frame->firstSN = sequenceNumber; /* Don't update anything in channel state */ } else { /* Ahead of expected SN. Assume frames have been missed */ p_report_in_frame->state = SN_Missing; p_report_in_frame->firstSN = expectedSequenceNumber; p_report_in_frame->lastSN = (1024 + sequenceNumber-1) % 1024; /* Update channel state - forget about missed SNs */ p_report_in_frame->sequenceExpected = expectedSequenceNumber; p_channel_status->previousSequenceNumber = sequenceNumber; p_channel_status->previousFrameNum = pinfo->fd->num; p_channel_status->previousSegmentIncomplete = !last_includes_end; } } break; default: /* Shouldn't get here! */ return SN_Error; } /* Associate with this frame number */ g_hash_table_insert(sequence_analysis_report_hash, get_report_hash_key(sequenceNumber, pinfo->fd->num, p_rlc_lte_info, TRUE), p_report_in_frame); /* Add state report for this frame into tree */ addChannelSequenceInfo(p_report_in_frame, isControlFrame, p_rlc_lte_info, sequenceNumber, first_includes_start, tap_info, pinfo, tree, tvb); return p_report_in_frame->state; } /* Add to the tree values associated with sequence analysis for this frame */ static void addChannelRepeatedNACKInfo(channel_repeated_nack_report *p, rlc_lte_info *p_rlc_lte_info, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb) { proto_tree *seqnum_tree; proto_item *seqnum_ti; proto_item *ti; gint n; /* Create subtree */ seqnum_ti = proto_tree_add_string_format(tree, hf_rlc_lte_sequence_analysis, tvb, 0, 0, "", "Sequence Analysis"); seqnum_tree = proto_item_add_subtree(seqnum_ti, ett_rlc_lte_sequence_analysis); PROTO_ITEM_SET_GENERATED(seqnum_ti); /* OK = FALSE */ ti = proto_tree_add_boolean(seqnum_tree, hf_rlc_lte_sequence_analysis_ok, tvb, 0, 0, FALSE); PROTO_ITEM_SET_GENERATED(ti); /* Add each repeated NACK as item & expert info */ for (n=0; n < p->noOfNACKsRepeated; n++) { ti = proto_tree_add_uint(seqnum_tree, hf_rlc_lte_sequence_analysis_repeated_nack, tvb, 0, 0, p->repeatedNACKs[n]); PROTO_ITEM_SET_GENERATED(ti); expert_add_info_format(pinfo, ti, &ei_rlc_lte_sequence_analysis_repeated_nack, "Same SN (%u) NACKd for %s on UE %u in successive Status PDUs", p->repeatedNACKs[n], val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid); } /* Link back to previous status report */ ti = proto_tree_add_uint(seqnum_tree, hf_rlc_lte_sequence_analysis_repeated_nack_original_frame, tvb, 0, 0, p->previousFrameNum); PROTO_ITEM_SET_GENERATED(ti); /* Append count to sequence analysis root */ proto_item_append_text(seqnum_ti, " - %u SNs repeated from previous Status PDU", p->noOfNACKsRepeated); } /* Update the channel repeated NACK status and set report for this frame */ static void checkChannelRepeatedNACKInfo(packet_info *pinfo, rlc_lte_info *p_rlc_lte_info, rlc_lte_tap_info *tap_info, proto_tree *tree, tvbuff_t *tvb) { channel_hash_key channel_key; channel_hash_key *p_channel_key; channel_repeated_nack_status *p_channel_status; channel_repeated_nack_report *p_report_in_frame = NULL; guint16 noOfNACKsRepeated = 0; guint16 repeatedNACKs[MAX_NACKs]; gint n, i, j; /* If find state_report_in_frame already, use that and get out */ if (pinfo->fd->flags.visited) { p_report_in_frame = (channel_repeated_nack_report*)g_hash_table_lookup(repeated_nack_report_hash, get_report_hash_key(0, pinfo->fd->num, p_rlc_lte_info, FALSE)); if (p_report_in_frame != NULL) { addChannelRepeatedNACKInfo(p_report_in_frame, p_rlc_lte_info, pinfo, tree, tvb); return; } else { /* Give up - we must have tried already... */ return; } } /**************************************************/ /* Create or find an entry for this channel state */ channel_key.ueId = p_rlc_lte_info->ueid; channel_key.channelType = p_rlc_lte_info->channelType; channel_key.channelId = p_rlc_lte_info->channelId; channel_key.direction = p_rlc_lte_info->direction; memset(repeatedNACKs, 0, sizeof(repeatedNACKs)); /* Do the table lookup */ p_channel_status = (channel_repeated_nack_status*)g_hash_table_lookup(repeated_nack_channel_hash, &channel_key); /* Create table entry if necessary */ if (p_channel_status == NULL) { /* Allocate a new key and value */ p_channel_key = wmem_new(wmem_file_scope(), channel_hash_key); p_channel_status = wmem_new0(wmem_file_scope(), channel_repeated_nack_status); /* Copy key contents */ memcpy(p_channel_key, &channel_key, sizeof(channel_hash_key)); /* Add entry to table */ g_hash_table_insert(repeated_nack_channel_hash, p_channel_key, p_channel_status); } /* Compare NACKs in channel status with NACKs in tap_info. Note any that are repeated */ for (i=0; i < p_channel_status->noOfNACKs; i++) { for (j=0; j < MIN(tap_info->noOfNACKs, MAX_NACKs); j++) { if (tap_info->NACKs[j] == p_channel_status->NACKs[i]) { /* Don't add the same repeated NACK twice! */ if ((noOfNACKsRepeated == 0) || (repeatedNACKs[noOfNACKsRepeated-1] != p_channel_status->NACKs[i])) { repeatedNACKs[noOfNACKsRepeated++] = p_channel_status->NACKs[i]; } } } } /* Copy NACKs from tap_info into channel status for next time! */ p_channel_status->noOfNACKs = 0; for (n=0; n < MIN(tap_info->noOfNACKs, MAX_NACKs); n++) { p_channel_status->NACKs[p_channel_status->noOfNACKs++] = tap_info->NACKs[n]; } if (noOfNACKsRepeated >= 1) { /* Create space for frame state_report */ p_report_in_frame = wmem_new(wmem_file_scope(), channel_repeated_nack_report); /* Copy in found duplicates */ for (n=0; n < MIN(tap_info->noOfNACKs, MAX_NACKs); n++) { p_report_in_frame->repeatedNACKs[n] = repeatedNACKs[n]; } p_report_in_frame->noOfNACKsRepeated = noOfNACKsRepeated; p_report_in_frame->previousFrameNum = p_channel_status->frameNum; /* Associate with this frame number */ g_hash_table_insert(repeated_nack_report_hash, get_report_hash_key(0, pinfo->fd->num, p_rlc_lte_info, TRUE), p_report_in_frame); /* Add state report for this frame into tree */ addChannelRepeatedNACKInfo(p_report_in_frame, p_rlc_lte_info, pinfo, tree, tvb); } /* Save frame number for next comparison */ p_channel_status->frameNum = pinfo->fd->num; } /* Check that the ACK is consistent with data the expected sequence number in the other direction */ static void checkChannelACKWindow(guint16 ack_sn, packet_info *pinfo, rlc_lte_info *p_rlc_lte_info, rlc_lte_tap_info *tap_info, proto_tree *tree, tvbuff_t *tvb) { channel_hash_key channel_key; channel_sequence_analysis_status *p_channel_status; sequence_analysis_report *p_report_in_frame = NULL; /* If find stat_report_in_frame already, use that and get out */ if (pinfo->fd->flags.visited) { p_report_in_frame = (sequence_analysis_report*)g_hash_table_lookup(sequence_analysis_report_hash, get_report_hash_key(0, pinfo->fd->num, p_rlc_lte_info, FALSE)); if (p_report_in_frame != NULL) { /* Add any info to tree */ addChannelSequenceInfo(p_report_in_frame, TRUE, p_rlc_lte_info, 0, FALSE, tap_info, pinfo, tree, tvb); return; } else { /* Give up - we must have tried already... */ return; } } /*******************************************************************/ /* Find an entry for this channel state (in the opposite direction */ channel_key.ueId = p_rlc_lte_info->ueid; channel_key.channelType = p_rlc_lte_info->channelType; channel_key.channelId = p_rlc_lte_info->channelId; channel_key.direction = (p_rlc_lte_info->direction == DIRECTION_UPLINK) ? DIRECTION_DOWNLINK : DIRECTION_UPLINK; /* Do the table lookup */ p_channel_status = (channel_sequence_analysis_status*)g_hash_table_lookup(sequence_analysis_channel_hash, &channel_key); /* Create table entry if necessary */ if (p_channel_status == NULL) { return; } /* Is it in the rx window? This test will catch if it's ahead, but we don't really know what the back of the tx window is... */ if (((1024 + p_channel_status->previousSequenceNumber+1 - ack_sn) % 1024) > 512) { /* Set result */ p_report_in_frame = wmem_new0(wmem_file_scope(), sequence_analysis_report); p_report_in_frame->state = ACK_Out_of_Window; p_report_in_frame->previousFrameNum = p_channel_status->previousFrameNum; p_report_in_frame->sequenceExpected = p_channel_status->previousSequenceNumber; p_report_in_frame->firstSN = ack_sn; /* Associate with this frame number */ g_hash_table_insert(sequence_analysis_report_hash, get_report_hash_key(0, pinfo->fd->num, p_rlc_lte_info, TRUE), p_report_in_frame); /* Add state report for this frame into tree */ addChannelSequenceInfo(p_report_in_frame, TRUE, p_rlc_lte_info, 0, FALSE, tap_info, pinfo, tree, tvb); } } /***************************************************/ /* Transparent mode PDU. Call RRC if configured to */ static void dissect_rlc_lte_tm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, rlc_lte_info *p_rlc_lte_info, proto_item *top_ti) { proto_item *raw_tm_ti; proto_item *tm_ti; /* Create hidden TM root */ tm_ti = proto_tree_add_string_format(tree, hf_rlc_lte_tm, tvb, offset, 0, "", "TM"); PROTO_ITEM_SET_HIDDEN(tm_ti); /* Remaining bytes are all data */ raw_tm_ti = proto_tree_add_item(tree, hf_rlc_lte_tm_data, tvb, offset, -1, ENC_NA); if (!global_rlc_lte_call_rrc_for_ccch) { write_pdu_label_and_info(top_ti, NULL, pinfo, " [%u-bytes]", tvb_reported_length_remaining(tvb, offset)); } if (global_rlc_lte_call_rrc_for_ccch) { tvbuff_t *rrc_tvb = tvb_new_subset_remaining(tvb, offset); volatile dissector_handle_t protocol_handle = 0; switch (p_rlc_lte_info->channelType) { case CHANNEL_TYPE_CCCH: if (p_rlc_lte_info->direction == DIRECTION_UPLINK) { protocol_handle = find_dissector("lte_rrc.ul_ccch"); } else { protocol_handle = find_dissector("lte_rrc.dl_ccch"); } break; case CHANNEL_TYPE_BCCH_BCH: protocol_handle = find_dissector("lte_rrc.bcch_bch"); break; case CHANNEL_TYPE_BCCH_DL_SCH: protocol_handle = find_dissector("lte_rrc.bcch_dl_sch"); break; case CHANNEL_TYPE_PCCH: protocol_handle = find_dissector("lte_rrc.pcch"); break; case CHANNEL_TYPE_SRB: case CHANNEL_TYPE_DRB: case CHANNEL_TYPE_MCCH: case CHANNEL_TYPE_MTCH: default: /* Shouldn't happen, just return... */ return; } /* Hide raw view of bytes */ PROTO_ITEM_SET_HIDDEN(raw_tm_ti); /* Call it (catch exceptions) */ TRY { call_dissector_only(protocol_handle, rrc_tvb, pinfo, tree, NULL); } CATCH_ALL { } ENDTRY } } /***************************************************/ /* Unacknowledged mode PDU */ static void dissect_rlc_lte_um(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, rlc_lte_info *p_rlc_lte_info, proto_item *top_ti, rlc_lte_tap_info *tap_info) { guint64 framing_info; gboolean first_includes_start; gboolean last_includes_end; guint64 fixed_extension; guint64 sn; gint start_offset = offset; proto_item *um_ti; proto_tree *um_header_tree; proto_item *um_header_ti; gboolean is_truncated = FALSE; proto_item *truncated_ti; rlc_channel_reassembly_info *reassembly_info = NULL; sequence_analysis_state seq_anal_state = SN_OK; /* Hidden UM root */ um_ti = proto_tree_add_string_format(tree, hf_rlc_lte_um, tvb, offset, 0, "", "UM"); PROTO_ITEM_SET_HIDDEN(um_ti); /* Add UM header subtree */ um_header_ti = proto_tree_add_string_format(tree, hf_rlc_lte_um_header, tvb, offset, 0, "", "UM header"); um_header_tree = proto_item_add_subtree(um_header_ti, ett_rlc_lte_um_header); /*******************************/ /* Fixed UM header */ if (p_rlc_lte_info->UMSequenceNumberLength == UM_SN_LENGTH_5_BITS) { /* Framing info (2 bits) */ proto_tree_add_bits_ret_val(um_header_tree, hf_rlc_lte_um_fi, tvb, offset*8, 2, &framing_info, ENC_BIG_ENDIAN); /* Extension (1 bit) */ proto_tree_add_bits_ret_val(um_header_tree, hf_rlc_lte_um_fixed_e, tvb, (offset*8) + 2, 1, &fixed_extension, ENC_BIG_ENDIAN); /* Sequence Number (5 bit) */ proto_tree_add_bits_ret_val(um_header_tree, hf_rlc_lte_um_sn, tvb, (offset*8) + 3, 5, &sn, ENC_BIG_ENDIAN); offset++; } else if (p_rlc_lte_info->UMSequenceNumberLength == UM_SN_LENGTH_10_BITS) { guint8 reserved; proto_item *ti; /* Check 3 Reserved bits */ reserved = (tvb_get_guint8(tvb, offset) & 0xe0) >> 5; ti = proto_tree_add_item(um_header_tree, hf_rlc_lte_um_fixed_reserved, tvb, offset, 1, ENC_BIG_ENDIAN); if (reserved != 0) { expert_add_info_format(pinfo, ti, &ei_rlc_lte_reserved_bits_not_zero, "RLC UM Fixed header Reserved bits not zero (found 0x%x)", reserved); } /* Framing info (2 bits) */ proto_tree_add_bits_ret_val(um_header_tree, hf_rlc_lte_um_fi, tvb, (offset*8)+3, 2, &framing_info, ENC_BIG_ENDIAN); /* Extension (1 bit) */ proto_tree_add_bits_ret_val(um_header_tree, hf_rlc_lte_um_fixed_e, tvb, (offset*8) + 5, 1, &fixed_extension, ENC_BIG_ENDIAN); /* Sequence Number (10 bits) */ proto_tree_add_bits_ret_val(um_header_tree, hf_rlc_lte_um_sn, tvb, (offset*8) + 6, 10, &sn, ENC_BIG_ENDIAN); offset += 2; } else { /* Invalid length of sequence number */ proto_tree_add_expert_format(um_header_tree, pinfo, &ei_rlc_lte_um_sn, tvb, 0, 0, "Invalid sequence number length (%u bits)", p_rlc_lte_info->UMSequenceNumberLength); return; } tap_info->sequenceNumber = (guint16)sn; /* Show SN in info column */ if ((p_rlc_lte_info->channelType == CHANNEL_TYPE_MCCH) || (p_rlc_lte_info->channelType == CHANNEL_TYPE_MTCH)) { write_pdu_label_and_info(top_ti, um_header_ti, pinfo, " sn=%-4u", (guint16)sn); } else { write_pdu_label_and_info(top_ti, um_header_ti, pinfo, " sn=%-4u", (guint16)sn); } proto_item_set_len(um_header_ti, offset-start_offset); /*************************************/ /* UM header extension */ if (fixed_extension) { offset = dissect_rlc_lte_extension_header(tvb, pinfo, um_header_tree, offset); } /* Extract these 2 flags from framing_info */ first_includes_start = ((guint8)framing_info & 0x02) == 0; last_includes_end = ((guint8)framing_info & 0x01) == 0; if (global_rlc_lte_headers_expected) { /* There might not be any data, if only headers (plus control data) were logged */ is_truncated = (tvb_reported_length_remaining(tvb, offset) == 0); truncated_ti = proto_tree_add_uint(tree, hf_rlc_lte_header_only, tvb, 0, 0, is_truncated); if (is_truncated) { int n; PROTO_ITEM_SET_GENERATED(truncated_ti); expert_add_info(pinfo, truncated_ti, &ei_rlc_lte_header_only); /* Show in the info column how long the data would be */ for (n=0; n < s_number_of_extensions; n++) { show_PDU_in_info(pinfo, top_ti, s_lengths[n], (n==0) ? first_includes_start : TRUE, TRUE); offset += s_lengths[n]; } /* Last one */ show_PDU_in_info(pinfo, top_ti, p_rlc_lte_info->pduLength - offset, (s_number_of_extensions == 0) ? first_includes_start : TRUE, last_includes_end); } else { PROTO_ITEM_SET_HIDDEN(truncated_ti); } } /* Show number of extensions in header root */ if (s_number_of_extensions > 0) { proto_item_append_text(um_header_ti, " (%u extensions)", s_number_of_extensions); } /* Call sequence analysis function now */ if (((global_rlc_lte_um_sequence_analysis == SEQUENCE_ANALYSIS_MAC_ONLY) && (p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0) != NULL)) || ((global_rlc_lte_um_sequence_analysis == SEQUENCE_ANALYSIS_RLC_ONLY) && (p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0) == NULL))) { guint16 lastSegmentOffset = offset; if (s_number_of_extensions >= 1) { int n; lastSegmentOffset = offset; for (n=0; n < s_number_of_extensions; n++) { lastSegmentOffset += s_lengths[n]; } } seq_anal_state = checkChannelSequenceInfo(pinfo, tvb, p_rlc_lte_info, FALSE, s_number_of_extensions+1, offset, s_number_of_extensions ? s_lengths[0] : p_rlc_lte_info->pduLength - offset, lastSegmentOffset, (guint16)sn, first_includes_start, last_includes_end, FALSE, /* UM doesn't re-segment */ tap_info, um_header_tree); } if (is_truncated) { return; } /*************************************/ /* Data */ reassembly_info = (rlc_channel_reassembly_info *)g_hash_table_lookup(reassembly_report_hash, get_report_hash_key((guint16)sn, pinfo->fd->num, p_rlc_lte_info, FALSE)); if (s_number_of_extensions > 0) { /* Show each data segment separately */ int n; for (n=0; n < s_number_of_extensions; n++) { show_PDU_in_tree(pinfo, tree, tvb, offset, s_lengths[n], p_rlc_lte_info, (n==0) ? first_includes_start : TRUE, (n==0) ? reassembly_info : NULL, seq_anal_state); show_PDU_in_info(pinfo, top_ti, s_lengths[n], (n==0) ? first_includes_start : TRUE, TRUE); tvb_ensure_bytes_exist(tvb, offset, s_lengths[n]); offset += s_lengths[n]; } } /* Final data element */ show_PDU_in_tree(pinfo, tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), p_rlc_lte_info, ((s_number_of_extensions == 0) ? first_includes_start : TRUE) && last_includes_end, (s_number_of_extensions == 0) ? reassembly_info : NULL, seq_anal_state); show_PDU_in_info(pinfo, top_ti, (guint16)tvb_reported_length_remaining(tvb, offset), (s_number_of_extensions == 0) ? first_includes_start : TRUE, last_includes_end); } /* Dissect an AM STATUS PDU */ static void dissect_rlc_lte_am_status_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *status_ti, int offset, proto_item *top_ti, rlc_lte_info *p_rlc_lte_info, rlc_lte_tap_info *tap_info) { guint8 cpt; guint64 ack_sn, nack_sn; guint16 nack_count = 0; guint64 e1 = 0, e2 = 0; guint64 so_start, so_end; int bit_offset = offset * 8; proto_item *ti; /****************************************************************/ /* Part of RLC control PDU header */ /* Control PDU Type (CPT) */ cpt = (tvb_get_guint8(tvb, offset) & 0xf0) >> 4; ti = proto_tree_add_item(tree, hf_rlc_lte_am_cpt, tvb, offset, 1, ENC_BIG_ENDIAN); if (cpt != 0) { /* Protest and stop - only know about STATUS PDUs */ expert_add_info_format(pinfo, ti, &ei_rlc_lte_am_cpt, "RLC Control frame type %u not handled", cpt); return; } /* The Status PDU itself starts 4 bits into the byte */ bit_offset += 4; /* ACK SN */ proto_tree_add_bits_ret_val(tree, hf_rlc_lte_am_ack_sn, tvb, bit_offset, 10, &ack_sn, ENC_BIG_ENDIAN); bit_offset += 10; write_pdu_label_and_info(top_ti, status_ti, pinfo, " ACK_SN=%-4u", (guint16)ack_sn); tap_info->ACKNo = (guint16)ack_sn; /* E1 */ proto_tree_add_bits_ret_val(tree, hf_rlc_lte_am_e1, tvb, bit_offset, 1, &e1, ENC_BIG_ENDIAN); /* Skip another bit to byte-align the next bit... */ bit_offset++; /* Optional, extra fields */ do { if (e1) { proto_item *nack_ti; /****************************/ /* Read NACK_SN, E1, E2 */ /* NACK_SN */ nack_ti = proto_tree_add_bits_ret_val(tree, hf_rlc_lte_am_nack_sn, tvb, bit_offset, 10, &nack_sn, ENC_BIG_ENDIAN); bit_offset += 10; write_pdu_label_and_info(top_ti, NULL, pinfo, " NACK_SN=%-4u", (guint16)nack_sn); /* We shouldn't NACK the ACK_SN! */ if (nack_sn == ack_sn) { expert_add_info_format(pinfo, nack_ti, &ei_rlc_lte_am_nack_sn_ack_same, "Status PDU shouldn't ACK and NACK the same sequence number (%" G_GINT64_MODIFIER "u)", ack_sn); } /* NACK should always be 'behind' the ACK */ if ((1024 + ack_sn - nack_sn) % 1024 > 512) { expert_add_info(pinfo, nack_ti, &ei_rlc_lte_am_nack_sn_ahead_ack); } /* Copy into struct, but don't exceed buffer */ if (nack_count < MAX_NACKs) { tap_info->NACKs[nack_count++] = (guint16)nack_sn; } else { /* Let it get bigger than the array for accurate stats... */ nack_count++; } /* E1 */ proto_tree_add_bits_ret_val(tree, hf_rlc_lte_am_e1, tvb, bit_offset, 1, &e1, ENC_BIG_ENDIAN); bit_offset++; /* E2 */ proto_tree_add_bits_ret_val(tree, hf_rlc_lte_am_e2, tvb, bit_offset, 1, &e2, ENC_BIG_ENDIAN); /* Report as expert info */ if (e2) { expert_add_info_format(pinfo, nack_ti, &ei_rlc_lte_am_nack_sn_partial, "Status PDU reports NACK (partial) on %s for UE %u", val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid); } else { expert_add_info_format(pinfo, nack_ti, &ei_rlc_lte_am_nack_sn, "Status PDU reports NACK on %s for UE %u", val_to_str_const(p_rlc_lte_info->direction, direction_vals, "Unknown"), p_rlc_lte_info->ueid); } bit_offset++; } if (e2) { /* Read SOstart, SOend */ proto_tree_add_bits_ret_val(tree, hf_rlc_lte_am_so_start, tvb, bit_offset, 15, &so_start, ENC_BIG_ENDIAN); bit_offset += 15; proto_tree_add_bits_ret_val(tree, hf_rlc_lte_am_so_end, tvb, bit_offset, 15, &so_end, ENC_BIG_ENDIAN); bit_offset += 15; if ((guint16)so_end == 0x7fff) { write_pdu_label_and_info(top_ti, NULL, pinfo, " (SOstart=%u SOend=<END-OF_PDU>)", (guint16)so_start); } else { write_pdu_label_and_info(top_ti, NULL, pinfo, " (SOstart=%u SOend=%u)", (guint16)so_start, (guint16)so_end); } /* Reset this flag here */ e2 = 0; } } while (e1 || e2); if (nack_count > 0) { proto_item *count_ti = proto_tree_add_uint(tree, hf_rlc_lte_am_nacks, tvb, 0, 1, nack_count); PROTO_ITEM_SET_GENERATED(count_ti); proto_item_append_text(status_ti, " (%u NACKs)", nack_count); tap_info->noOfNACKs = nack_count; } /* Check that we've reached the end of the PDU. If not, show malformed */ offset = (bit_offset+7) / 8; if (tvb_reported_length_remaining(tvb, offset) > 0) { expert_add_info_format(pinfo, status_ti, &ei_rlc_lte_bytes_after_status_pdu_complete, "%cL %u bytes remaining after Status PDU complete", (p_rlc_lte_info->direction == DIRECTION_UPLINK) ? 'U' : 'D', tvb_reported_length_remaining(tvb, offset)); } /* Set selected length of control tree */ proto_item_set_len(status_ti, offset); /* Repeated NACK analysis & check ACK-SN is in range */ if (((global_rlc_lte_am_sequence_analysis == SEQUENCE_ANALYSIS_MAC_ONLY) && (p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0) != NULL)) || ((global_rlc_lte_am_sequence_analysis == SEQUENCE_ANALYSIS_RLC_ONLY) && (p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0) == NULL))) { if (!is_mac_lte_frame_retx(pinfo, p_rlc_lte_info->direction)) { checkChannelRepeatedNACKInfo(pinfo, p_rlc_lte_info, tap_info, tree, tvb); checkChannelACKWindow((guint16)ack_sn, pinfo, p_rlc_lte_info, tap_info, tree, tvb); } } } /***************************************************/ /* Acknowledged mode PDU */ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, rlc_lte_info *p_rlc_lte_info, proto_item *top_ti, rlc_lte_tap_info *tap_info) { guint8 is_data; guint8 is_resegmented; guint8 polling; guint8 fixed_extension; guint8 framing_info; gboolean first_includes_start; gboolean last_includes_end; proto_item *am_ti; proto_tree *am_header_tree; proto_item *am_header_ti; gint start_offset = offset; guint16 sn; gboolean is_truncated = FALSE; proto_item *truncated_ti; rlc_channel_reassembly_info *reassembly_info = NULL; sequence_analysis_state seq_anal_state = SN_OK; /* Hidden AM root */ am_ti = proto_tree_add_string_format(tree, hf_rlc_lte_am, tvb, offset, 0, "", "AM"); PROTO_ITEM_SET_HIDDEN(am_ti); /* Add AM header subtree */ am_header_ti = proto_tree_add_string_format(tree, hf_rlc_lte_am_header, tvb, offset, 0, "", "AM Header "); am_header_tree = proto_item_add_subtree(am_header_ti, ett_rlc_lte_am_header); /* First bit is Data/Control flag */ is_data = (tvb_get_guint8(tvb, offset) & 0x80) >> 7; proto_tree_add_item(am_header_tree, hf_rlc_lte_am_data_control, tvb, offset, 1, ENC_BIG_ENDIAN); tap_info->isControlPDU = !is_data; if (!is_data) { /**********************/ /* Status PDU */ write_pdu_label_and_info_literal(top_ti, NULL, pinfo, " [CONTROL]"); /* Control PDUs are a completely separate format */ dissect_rlc_lte_am_status_pdu(tvb, pinfo, am_header_tree, am_header_ti, offset, top_ti, p_rlc_lte_info, tap_info); return; } /******************************/ /* Data PDU fixed header */ /* Re-segmentation Flag (RF) field */ is_resegmented = (tvb_get_guint8(tvb, offset) & 0x40) >> 6; proto_tree_add_item(am_header_tree, hf_rlc_lte_am_rf, tvb, offset, 1, ENC_BIG_ENDIAN); tap_info->isResegmented = is_resegmented; write_pdu_label_and_info_literal(top_ti, NULL, pinfo, (is_resegmented) ? " [DATA-SEGMENT]" : " [DATA]"); /* Polling bit */ polling = (tvb_get_guint8(tvb, offset) & 0x20) >> 5; proto_tree_add_item(am_header_tree, hf_rlc_lte_am_p, tvb, offset, 1, ENC_BIG_ENDIAN); write_pdu_label_and_info_literal(top_ti, NULL, pinfo, (polling) ? " (P) " : " "); if (polling) { proto_item_append_text(am_header_ti, " (P) "); } /* Framing Info */ framing_info = (tvb_get_guint8(tvb, offset) & 0x18) >> 3; proto_tree_add_item(am_header_tree, hf_rlc_lte_am_fi, tvb, offset, 1, ENC_BIG_ENDIAN); /* Extension bit */ fixed_extension = (tvb_get_guint8(tvb, offset) & 0x04) >> 2; proto_tree_add_item(am_header_tree, hf_rlc_lte_am_fixed_e, tvb, offset, 1, ENC_BIG_ENDIAN); /* Sequence Number */ sn = tvb_get_ntohs(tvb, offset) & 0x03ff; proto_tree_add_item(am_header_tree, hf_rlc_lte_am_fixed_sn, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; tap_info->sequenceNumber = sn; write_pdu_label_and_info(top_ti, am_header_ti, pinfo, "sn=%-4u", sn); /***************************************/ /* Dissect extra segment header fields */ if (is_resegmented) { guint16 segmentOffset; /* Last Segment Field (LSF) */ proto_tree_add_item(am_header_tree, hf_rlc_lte_am_segment_lsf, tvb, offset, 1, ENC_BIG_ENDIAN); /* SO */ segmentOffset = tvb_get_ntohs(tvb, offset) & 0x7fff; proto_tree_add_item(am_header_tree, hf_rlc_lte_am_segment_so, tvb, offset, 2, ENC_BIG_ENDIAN); write_pdu_label_and_info(top_ti, am_header_ti, pinfo, " SO=%u ", segmentOffset); offset += 2; } /*************************************/ /* AM header extension */ if (fixed_extension) { offset = dissect_rlc_lte_extension_header(tvb, pinfo, am_header_tree, offset); } /* Header is now complete */ proto_item_set_len(am_header_ti, offset-start_offset); /* Show number of extensions in header root */ if (s_number_of_extensions > 0) { proto_item_append_text(am_header_ti, " (%u extensions)", s_number_of_extensions); } /* Extract these 2 flags from framing_info */ first_includes_start = (framing_info & 0x02) == 0; last_includes_end = (framing_info & 0x01) == 0; /* There might not be any data, if only headers (plus control data) were logged */ if (global_rlc_lte_headers_expected) { is_truncated = (tvb_reported_length_remaining(tvb, offset) == 0); truncated_ti = proto_tree_add_uint(tree, hf_rlc_lte_header_only, tvb, 0, 0, is_truncated); if (is_truncated) { int n; PROTO_ITEM_SET_GENERATED(truncated_ti); expert_add_info(pinfo, truncated_ti, &ei_rlc_lte_header_only); /* Show in the info column how long the data would be */ for (n=0; n < s_number_of_extensions; n++) { show_PDU_in_info(pinfo, top_ti, s_lengths[n], (n==0) ? first_includes_start : TRUE, TRUE); offset += s_lengths[n]; } /* Last one */ show_PDU_in_info(pinfo, top_ti, p_rlc_lte_info->pduLength - offset, (s_number_of_extensions == 0) ? first_includes_start : TRUE, last_includes_end); } else { PROTO_ITEM_SET_HIDDEN(truncated_ti); } } /* Call sequence analysis function now */ if (((global_rlc_lte_am_sequence_analysis == SEQUENCE_ANALYSIS_MAC_ONLY) && (p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0) != NULL)) || ((global_rlc_lte_am_sequence_analysis == SEQUENCE_ANALYSIS_RLC_ONLY) && (p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0) == NULL))) { guint16 firstSegmentLength; guint16 lastSegmentOffset = offset; if (s_number_of_extensions >= 1) { int n; for (n=0; n < s_number_of_extensions; n++) { lastSegmentOffset += s_lengths[n]; } firstSegmentLength = s_lengths[0]; } else { firstSegmentLength = tvb_reported_length_remaining(tvb, offset); } seq_anal_state = checkChannelSequenceInfo(pinfo, tvb, p_rlc_lte_info, FALSE, s_number_of_extensions+1, offset, firstSegmentLength, lastSegmentOffset, (guint16)sn, first_includes_start, last_includes_end, is_resegmented, tap_info, tree); } if (is_truncated) { return; } /*************************************/ /* Data */ if (!first_includes_start) { reassembly_info = (rlc_channel_reassembly_info *)g_hash_table_lookup(reassembly_report_hash, get_report_hash_key((guint16)sn, pinfo->fd->num, p_rlc_lte_info, FALSE)); } if (s_number_of_extensions > 0) { /* Show each data segment separately */ int n; for (n=0; n < s_number_of_extensions; n++) { show_PDU_in_tree(pinfo, tree, tvb, offset, s_lengths[n], p_rlc_lte_info, (n==0) ? first_includes_start : TRUE, (n==0) ? reassembly_info : NULL, seq_anal_state); show_PDU_in_info(pinfo, top_ti, s_lengths[n], (n==0) ? first_includes_start : TRUE, TRUE); tvb_ensure_bytes_exist(tvb, offset, s_lengths[n]); offset += s_lengths[n]; } } /* Final data element */ if (tvb_reported_length_remaining(tvb, offset) > 0) { show_PDU_in_tree(pinfo, tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), p_rlc_lte_info, ((s_number_of_extensions == 0) ? first_includes_start : TRUE) && last_includes_end, (s_number_of_extensions == 0) ? reassembly_info : NULL, seq_anal_state); show_PDU_in_info(pinfo, top_ti, (guint16)tvb_reported_length_remaining(tvb, offset), (s_number_of_extensions == 0) ? first_includes_start : TRUE, last_includes_end); } else { /* Report that expected data was missing (unless we know it might happen) */ if (!global_rlc_lte_headers_expected) { if (s_number_of_extensions > 0) { expert_add_info(pinfo, am_header_ti, &ei_rlc_lte_am_data_no_data_beyond_extensions); } else { expert_add_info(pinfo, am_header_ti, &ei_rlc_lte_am_data_no_data); } } } } /* Heuristic dissector looks for supported framing protocol (see wiki page) */ static gboolean dissect_rlc_lte_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { gint offset = 0; struct rlc_lte_info *p_rlc_lte_info; tvbuff_t *rlc_tvb; guint8 tag = 0; gboolean infoAlreadySet = FALSE; gboolean umSeqNumLengthTagPresent = FALSE; /* This is a heuristic dissector, which means we get all the UDP * traffic not sent to a known dissector and not claimed by * a heuristic dissector called before us! */ if (!global_rlc_lte_heur) { return FALSE; } /* Do this again on re-dissection to re-discover offset of actual PDU */ /* Needs to be at least as long as: - the signature string - fixed header bytes - tag for data - at least one byte of RLC PDU payload */ if (tvb_captured_length_remaining(tvb, offset) < (gint)(strlen(RLC_LTE_START_STRING)+1+2)) { return FALSE; } /* OK, compare with signature string */ if (tvb_strneql(tvb, offset, RLC_LTE_START_STRING, (gint)strlen(RLC_LTE_START_STRING)) != 0) { return FALSE; } offset += (gint)strlen(RLC_LTE_START_STRING); /* If redissecting, use previous info struct (if available) */ p_rlc_lte_info = (rlc_lte_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc_lte, 0); if (p_rlc_lte_info == NULL) { /* Allocate new info struct for this frame */ p_rlc_lte_info = wmem_new0(wmem_file_scope(), struct rlc_lte_info); infoAlreadySet = FALSE; } else { infoAlreadySet = TRUE; } /* Read fixed fields */ p_rlc_lte_info->rlcMode = tvb_get_guint8(tvb, offset++); /* Read optional fields */ while (tag != RLC_LTE_PAYLOAD_TAG) { /* Process next tag */ tag = tvb_get_guint8(tvb, offset++); switch (tag) { case RLC_LTE_UM_SN_LENGTH_TAG: p_rlc_lte_info->UMSequenceNumberLength = tvb_get_guint8(tvb, offset); offset++; umSeqNumLengthTagPresent = TRUE; break; case RLC_LTE_DIRECTION_TAG: p_rlc_lte_info->direction = tvb_get_guint8(tvb, offset); offset++; break; case RLC_LTE_PRIORITY_TAG: p_rlc_lte_info->priority = tvb_get_guint8(tvb, offset); offset++; break; case RLC_LTE_UEID_TAG: p_rlc_lte_info->ueid = tvb_get_ntohs(tvb, offset); offset += 2; break; case RLC_LTE_CHANNEL_TYPE_TAG: p_rlc_lte_info->channelType = tvb_get_ntohs(tvb, offset); offset += 2; break; case RLC_LTE_CHANNEL_ID_TAG: p_rlc_lte_info->channelId = tvb_get_ntohs(tvb, offset); offset += 2; break; case RLC_LTE_PAYLOAD_TAG: /* Have reached data, so set payload length and get out of loop */ p_rlc_lte_info->pduLength= tvb_reported_length_remaining(tvb, offset); continue; default: /* It must be a recognised tag */ return FALSE; } } if ((p_rlc_lte_info->rlcMode == RLC_UM_MODE) && (umSeqNumLengthTagPresent == FALSE)) { /* Conditional field is not present */ return FALSE; } if (!infoAlreadySet) { /* Store info in packet */ p_add_proto_data(wmem_file_scope(), pinfo, proto_rlc_lte, 0, p_rlc_lte_info); } /**************************************/ /* OK, now dissect as RLC LTE */ /* Create tvb that starts at actual RLC PDU */ rlc_tvb = tvb_new_subset_remaining(tvb, offset); dissect_rlc_lte_common(rlc_tvb, pinfo, tree, TRUE); return TRUE; } /*****************************/ /* Main dissection function. */ /*****************************/ static void dissect_rlc_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { dissect_rlc_lte_common(tvb, pinfo, tree, FALSE); } static void dissect_rlc_lte_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_udp_framing) { proto_tree *rlc_lte_tree; proto_tree *context_tree; proto_item *top_ti; proto_item *context_ti; proto_item *ti; proto_item *mode_ti; gint offset = 0; struct rlc_lte_info *p_rlc_lte_info = NULL; /* Allocate and Zero tap struct */ rlc_lte_tap_info *tap_info = wmem_new0(wmem_packet_scope(), rlc_lte_tap_info); /* Set protocol name */ col_set_str(pinfo->cinfo, COL_PROTOCOL, "RLC-LTE"); /* Create protocol tree. */ top_ti = proto_tree_add_item(tree, proto_rlc_lte, tvb, offset, -1, ENC_NA); rlc_lte_tree = proto_item_add_subtree(top_ti, ett_rlc_lte); /* Look for packet info! */ p_rlc_lte_info = (rlc_lte_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc_lte, 0); /* Can't dissect anything without it... */ if (p_rlc_lte_info == NULL) { ti = proto_tree_add_text(rlc_lte_tree, tvb, offset, -1, "Can't dissect LTE RLC frame because no per-frame info was attached!"); PROTO_ITEM_SET_GENERATED(ti); return; } /* Clear info column when using UDP framing */ if (is_udp_framing) { col_clear(pinfo->cinfo, COL_INFO); } /*****************************************/ /* Show context information */ /* Create context root */ context_ti = proto_tree_add_string_format(rlc_lte_tree, hf_rlc_lte_context, tvb, offset, 0, "", "Context"); context_tree = proto_item_add_subtree(context_ti, ett_rlc_lte_context); PROTO_ITEM_SET_GENERATED(context_ti); ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_direction, tvb, 0, 0, p_rlc_lte_info->direction); PROTO_ITEM_SET_GENERATED(ti); mode_ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_mode, tvb, 0, 0, p_rlc_lte_info->rlcMode); PROTO_ITEM_SET_GENERATED(mode_ti); if (p_rlc_lte_info->ueid != 0) { ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_ueid, tvb, 0, 0, p_rlc_lte_info->ueid); PROTO_ITEM_SET_GENERATED(ti); } if ((p_rlc_lte_info->priority >= 1) && (p_rlc_lte_info->priority <=16)) { ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_priority, tvb, 0, 0, p_rlc_lte_info->priority); PROTO_ITEM_SET_GENERATED(ti); } ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_channel_type, tvb, 0, 0, p_rlc_lte_info->channelType); PROTO_ITEM_SET_GENERATED(ti); if ((p_rlc_lte_info->channelType == CHANNEL_TYPE_SRB) || (p_rlc_lte_info->channelType == CHANNEL_TYPE_DRB) || (p_rlc_lte_info->channelType == CHANNEL_TYPE_MTCH)) { ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_channel_id, tvb, 0, 0, p_rlc_lte_info->channelId); PROTO_ITEM_SET_GENERATED(ti); } ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_pdu_length, tvb, 0, 0, p_rlc_lte_info->pduLength); PROTO_ITEM_SET_GENERATED(ti); if (p_rlc_lte_info->rlcMode == RLC_UM_MODE) { ti = proto_tree_add_uint(context_tree, hf_rlc_lte_context_um_sn_length, tvb, 0, 0, p_rlc_lte_info->UMSequenceNumberLength); PROTO_ITEM_SET_GENERATED(ti); } /* Append highlights to top-level item */ if (p_rlc_lte_info->ueid != 0) { proto_item_append_text(top_ti, " UEId=%u", p_rlc_lte_info->ueid); col_append_fstr(pinfo->cinfo, COL_INFO, "UEId=%-4u ", p_rlc_lte_info->ueid); } /* Append context highlights to info column */ write_pdu_label_and_info(top_ti, NULL, pinfo, " [%s] [%s] ", (p_rlc_lte_info->direction == 0) ? "UL" : "DL", val_to_str_const(p_rlc_lte_info->rlcMode, rlc_mode_short_vals, "Unknown")); if (p_rlc_lte_info->channelId == 0) { write_pdu_label_and_info(top_ti, NULL, pinfo, "%s ", val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown")); } else { write_pdu_label_and_info(top_ti, NULL, pinfo, "%s:%-2u", val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"), p_rlc_lte_info->channelId); } /* Set context-info parts of tap struct */ tap_info->rlcMode = p_rlc_lte_info->rlcMode; tap_info->direction = p_rlc_lte_info->direction; tap_info->priority = p_rlc_lte_info->priority; tap_info->ueid = p_rlc_lte_info->ueid; tap_info->channelType = p_rlc_lte_info->channelType; tap_info->channelId = p_rlc_lte_info->channelId; tap_info->pduLength = p_rlc_lte_info->pduLength; tap_info->UMSequenceNumberLength = p_rlc_lte_info->UMSequenceNumberLength; tap_info->loggedInMACFrame = (p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0) != NULL); tap_info->time = pinfo->fd->abs_ts; /* Reset this count */ s_number_of_extensions = 0; /* Dissect the RLC PDU itself. Format depends upon mode... */ switch (p_rlc_lte_info->rlcMode) { case RLC_TM_MODE: dissect_rlc_lte_tm(tvb, pinfo, rlc_lte_tree, offset, p_rlc_lte_info, top_ti); break; case RLC_UM_MODE: dissect_rlc_lte_um(tvb, pinfo, rlc_lte_tree, offset, p_rlc_lte_info, top_ti, tap_info); break; case RLC_AM_MODE: dissect_rlc_lte_am(tvb, pinfo, rlc_lte_tree, offset, p_rlc_lte_info, top_ti, tap_info); break; case RLC_PREDEF: /* Predefined data (i.e. not containing a valid RLC header */ proto_tree_add_item(rlc_lte_tree, hf_rlc_lte_predefined_pdu, tvb, offset, -1, ENC_NA); write_pdu_label_and_info(top_ti, NULL, pinfo, " [%u-bytes]", tvb_reported_length_remaining(tvb, offset)); break; default: /* Error - unrecognised mode */ expert_add_info_format(pinfo, mode_ti, &ei_rlc_lte_context_mode, "Unrecognised RLC Mode set (%u)", p_rlc_lte_info->rlcMode); break; } /* Queue tap info */ tap_queue_packet(rlc_lte_tap, pinfo, tap_info); } /* Initializes the hash tables each time a new * file is loaded or re-loaded in wireshark */ static void rlc_lte_init_protocol(void) { /* Destroy any existing hashes. */ if (sequence_analysis_channel_hash) { g_hash_table_destroy(sequence_analysis_channel_hash); } if (sequence_analysis_report_hash) { g_hash_table_destroy(sequence_analysis_report_hash); } if (repeated_nack_channel_hash) { g_hash_table_destroy(repeated_nack_channel_hash); } if (repeated_nack_report_hash) { g_hash_table_destroy(repeated_nack_report_hash); } if (reassembly_report_hash) { g_hash_table_destroy(reassembly_report_hash); } /* Now create them over */ sequence_analysis_channel_hash = g_hash_table_new(rlc_channel_hash_func, rlc_channel_equal); sequence_analysis_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal); repeated_nack_channel_hash = g_hash_table_new(rlc_channel_hash_func, rlc_channel_equal); repeated_nack_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal); reassembly_report_hash = g_hash_table_new(rlc_result_hash_func, rlc_result_hash_equal); } /* Configure number of PDCP SN bits to use for DRB channels. TODO: currently assume all UEs/Channels will use the same SN length... */ void set_rlc_lte_drb_pdcp_seqnum_length(guint16 ueid _U_, guint8 drbid _U_, guint8 userplane_seqnum_length) { signalled_pdcp_sn_bits = userplane_seqnum_length; } void proto_register_rlc_lte(void) { static hf_register_info hf[] = { /**********************************/ /* Items for decoding context */ { &hf_rlc_lte_context, { "Context", "rlc-lte.context", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { &hf_rlc_lte_context_mode, { "RLC Mode", "rlc-lte.mode", FT_UINT8, BASE_DEC, VALS(rlc_mode_vals), 0x0, NULL, HFILL } }, { &hf_rlc_lte_context_direction, { "Direction", "rlc-lte.direction", FT_UINT8, BASE_DEC, VALS(direction_vals), 0x0, "Direction of message", HFILL } }, { &hf_rlc_lte_context_priority, { "Priority", "rlc-lte.priority", FT_UINT8, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_context_ueid, { "UEId", "rlc-lte.ueid", FT_UINT16, BASE_DEC, 0, 0x0, "User Equipment Identifier associated with message", HFILL } }, { &hf_rlc_lte_context_channel_type, { "Channel Type", "rlc-lte.channel-type", FT_UINT16, BASE_DEC, VALS(rlc_channel_type_vals), 0x0, "Channel Type associated with message", HFILL } }, { &hf_rlc_lte_context_channel_id, { "Channel ID", "rlc-lte.channel-id", FT_UINT16, BASE_DEC, 0, 0x0, "Channel ID associated with message", HFILL } }, { &hf_rlc_lte_context_pdu_length, { "PDU Length", "rlc-lte.pdu-length", FT_UINT16, BASE_DEC, 0, 0x0, "Length of PDU (in bytes)", HFILL } }, { &hf_rlc_lte_context_um_sn_length, { "UM Sequence number length", "rlc-lte.um-seqnum-length", FT_UINT8, BASE_DEC, 0, 0x0, "Length of UM sequence number in bits", HFILL } }, /* Transparent mode fields */ { &hf_rlc_lte_tm, { "TM", "rlc-lte.tm", FT_STRING, BASE_NONE, NULL, 0x0, "Transparent Mode", HFILL } }, { &hf_rlc_lte_tm_data, { "TM Data", "rlc-lte.tm.data", FT_BYTES, BASE_NONE, 0, 0x0, "Transparent Mode Data", HFILL } }, /* Unacknowledged mode fields */ { &hf_rlc_lte_um, { "UM", "rlc-lte.um", FT_STRING, BASE_NONE, NULL, 0x0, "Unacknowledged Mode", HFILL } }, { &hf_rlc_lte_um_header, { "UM Header", "rlc-lte.um.header", FT_STRING, BASE_NONE, NULL, 0x0, "Unacknowledged Mode Header", HFILL } }, { &hf_rlc_lte_um_fi, { "Framing Info", "rlc-lte.um.fi", FT_UINT8, BASE_HEX, VALS(framing_info_vals), 0x0, NULL, HFILL } }, { &hf_rlc_lte_um_fixed_e, { "Extension", "rlc-lte.um.fixed.e", FT_UINT8, BASE_HEX, VALS(fixed_extension_vals), 0x0, "Extension in fixed part of UM header", HFILL } }, { &hf_rlc_lte_um_sn, { "Sequence number", "rlc-lte.um.sn", FT_UINT8, BASE_DEC, 0, 0x0, "Unacknowledged Mode Sequence Number", HFILL } }, { &hf_rlc_lte_um_fixed_reserved, { "Reserved", "rlc-lte.um.reserved", FT_UINT8, BASE_DEC, 0, 0xe0, "Unacknowledged Mode Fixed header reserved bits", HFILL } }, { &hf_rlc_lte_um_data, { "UM Data", "rlc-lte.um.data", FT_BYTES, BASE_NONE, 0, 0x0, "Unacknowledged Mode Data", HFILL } }, { &hf_rlc_lte_extension_part, { "Extension Part", "rlc-lte.extension-part", FT_STRING, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_extension_e, { "Extension", "rlc-lte.extension.e", FT_UINT8, BASE_HEX, VALS(extension_extension_vals), 0x0, "Extension in extended part of the header", HFILL } }, { &hf_rlc_lte_extension_li, { "Length Indicator", "rlc-lte.extension.li", FT_UINT16, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_extension_padding, { "Padding", "rlc-lte.extension.padding", FT_UINT8, BASE_HEX, 0, 0x0f, "Extension header padding", HFILL } }, /* Acknowledged mode fields */ { &hf_rlc_lte_am, { "AM", "rlc-lte.am", FT_STRING, BASE_NONE, NULL, 0x0, "Acknowledged Mode", HFILL } }, { &hf_rlc_lte_am_header, { "AM Header", "rlc-lte.am.header", FT_STRING, BASE_NONE, NULL, 0x0, "Acknowledged Mode Header", HFILL } }, { &hf_rlc_lte_am_data_control, { "Frame type", "rlc-lte.am.frame-type", FT_UINT8, BASE_HEX, VALS(data_or_control_vals), 0x80, "AM Frame Type (Control or Data)", HFILL } }, { &hf_rlc_lte_am_rf, { "Re-segmentation Flag", "rlc-lte.am.rf", FT_UINT8, BASE_HEX, VALS(resegmentation_flag_vals), 0x40, "AM Re-segmentation Flag", HFILL } }, { &hf_rlc_lte_am_p, { "Polling Bit", "rlc-lte.am.p", FT_UINT8, BASE_HEX, VALS(polling_bit_vals), 0x20, NULL, HFILL } }, { &hf_rlc_lte_am_fi, { "Framing Info", "rlc-lte.am.fi", FT_UINT8, BASE_HEX, VALS(framing_info_vals), 0x18, "AM Framing Info", HFILL } }, { &hf_rlc_lte_am_fixed_e, { "Extension", "rlc-lte.am.fixed.e", FT_UINT8, BASE_HEX, VALS(fixed_extension_vals), 0x04, "Fixed Extension Bit", HFILL } }, { &hf_rlc_lte_am_fixed_sn, { "Sequence Number", "rlc-lte.am.fixed.sn", FT_UINT16, BASE_DEC, 0, 0x03ff, "AM Fixed Sequence Number", HFILL } }, { &hf_rlc_lte_am_segment_lsf, { "Last Segment Flag", "rlc-lte.am.segment.lsf", FT_UINT8, BASE_HEX, VALS(lsf_vals), 0x80, NULL, HFILL } }, { &hf_rlc_lte_am_segment_so, { "Segment Offset", "rlc-lte.am.segment.offset", FT_UINT16, BASE_DEC, 0, 0x7fff, NULL, HFILL } }, { &hf_rlc_lte_am_data, { "AM Data", "rlc-lte.am.data", FT_BYTES, BASE_NONE, 0, 0x0, "Acknowledged Mode Data", HFILL } }, { &hf_rlc_lte_am_cpt, { "Control PDU Type", "rlc-lte.am.cpt", FT_UINT8, BASE_HEX, VALS(control_pdu_type_vals), 0x70, "AM Control PDU Type", HFILL } }, { &hf_rlc_lte_am_ack_sn, { "ACK Sequence Number", "rlc-lte.am.ack-sn", FT_UINT16, BASE_DEC, 0, 0x0, "Sequence Number we expect to receive next", HFILL } }, { &hf_rlc_lte_am_e1, { "Extension bit 1", "rlc-lte.am.e1", FT_UINT8, BASE_HEX, VALS(am_e1_vals), 0x0, NULL, HFILL } }, { &hf_rlc_lte_am_e2, { "Extension bit 2", "rlc-lte.am.e2", FT_UINT8, BASE_HEX, VALS(am_e2_vals), 0x0, NULL, HFILL } }, { &hf_rlc_lte_am_nacks, { "Number of NACKs", "rlc-lte.am.nacks", FT_UINT16, BASE_DEC, 0, 0x0, "Number of NACKs in this status PDU", HFILL } }, { &hf_rlc_lte_am_nack_sn, { "NACK Sequence Number", "rlc-lte.am.nack-sn", FT_UINT16, BASE_DEC, 0, 0x0, "Negative Acknowledgement Sequence Number", HFILL } }, { &hf_rlc_lte_am_so_start, { "SO Start", "rlc-lte.am.so-start", FT_UINT16, BASE_DEC, 0, 0x0, "Segment Offset Start byte index", HFILL } }, { &hf_rlc_lte_am_so_end, { "SO End", "rlc-lte.am.so-end", FT_UINT16, BASE_DEC, 0, 0x0, "Segment Offset End byte index", HFILL } }, { &hf_rlc_lte_predefined_pdu, { "Predefined data", "rlc-lte.predefined-data", FT_BYTES, BASE_NONE, 0, 0x0, "Predefined test data", HFILL } }, /* Sequence analysis fields */ { &hf_rlc_lte_sequence_analysis, { "Sequence Analysis", "rlc-lte.sequence-analysis", FT_STRING, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_ok, { "OK", "rlc-lte.sequence-analysis.ok", FT_BOOLEAN, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_previous_frame, { "Previous frame for channel", "rlc-lte.sequence-analysis.previous-frame", FT_FRAMENUM, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_next_frame, { "Next frame for channel", "rlc-lte.sequence-analysis.next-frame", FT_FRAMENUM, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_expected_sn, { "Expected SN", "rlc-lte.sequence-analysis.expected-sn", FT_UINT16, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_framing_info_correct, { "Frame info continued correctly", "rlc-lte.sequence-analysis.framing-info-correct", FT_BOOLEAN, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_mac_retx, { "Frame retransmitted by MAC", "rlc-lte.sequence-analysis.mac-retx", FT_BOOLEAN, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_retx, { "Retransmitted frame", "rlc-lte.sequence-analysis.retx", FT_BOOLEAN, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_skipped, { "Skipped frames", "rlc-lte.sequence-analysis.skipped-frames", FT_BOOLEAN, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_repeated, { "Repeated frame", "rlc-lte.sequence-analysis.repeated-frame", FT_BOOLEAN, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_repeated_nack, { "Repeated NACK", "rlc-lte.sequence-analysis.repeated-nack", FT_UINT16, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_repeated_nack_original_frame, { "Frame with previous status PDU", "rlc-lte.sequence-analysis.repeated-nack.original-frame", FT_FRAMENUM, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_ack_out_of_range, { "Out of range ACK", "rlc-lte.sequence-analysis.ack-out-of-range", FT_BOOLEAN, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_sequence_analysis_ack_out_of_range_opposite_frame, { "Frame with most recent SN", "rlc-lte.sequence-analysis.ack-out-of-range.last-sn-frame", FT_FRAMENUM, BASE_NONE, 0, 0x0, NULL, HFILL } }, /* Reassembly fields */ { &hf_rlc_lte_reassembly_source, { "Reassembly Source", "rlc-lte.reassembly-info", FT_STRING, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_reassembly_source_number_of_segments, { "Number of segments", "rlc-lte.reassembly-info.number-of-segments", FT_UINT16, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_reassembly_source_total_length, { "Total length", "rlc-lte.reassembly-info.total-length", FT_UINT16, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_reassembly_source_segment, { "Segment", "rlc-lte.reassembly-info.segment", FT_NONE, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_reassembly_source_segment_sn, { "SN", "rlc-lte.reassembly-info.segment.sn", FT_UINT16, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_reassembly_source_segment_framenum, { "Frame", "rlc-lte.reassembly-info.segment.frame", FT_FRAMENUM, BASE_NONE, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_reassembly_source_segment_length, { "Length", "rlc-lte.reassembly-info.segment.length", FT_UINT32, BASE_DEC, 0, 0x0, NULL, HFILL } }, { &hf_rlc_lte_header_only, { "RLC PDU Header only", "rlc-lte.header-only", FT_UINT8, BASE_DEC, VALS(header_only_vals), 0x0, NULL, HFILL } }, }; static gint *ett[] = { &ett_rlc_lte, &ett_rlc_lte_context, &ett_rlc_lte_um_header, &ett_rlc_lte_am_header, &ett_rlc_lte_extension_part, &ett_rlc_lte_sequence_analysis, &ett_rlc_lte_reassembly_source, &ett_rlc_lte_reassembly_source_segment }; static ei_register_info ei[] = { { &ei_rlc_lte_sequence_analysis_last_segment_not_continued, { "rlc-lte.sequence-analysis.last-segment-not-continued", PI_SEQUENCE, PI_WARN, "Last segment of previous PDU was not continued for UE", EXPFILL }}, { &ei_rlc_lte_sequence_analysis_last_segment_complete, { "rlc-lte.sequence-analysis.last-segment-complete", PI_SEQUENCE, PI_WARN, "Last segment of previous PDU was complete, but new segment was not started on UE", EXPFILL }}, { &ei_rlc_lte_sequence_analysis_mac_retx, { "rlc-lte.sequence-analysis.mac-retx.expert", PI_SEQUENCE, PI_WARN, "AM Frame retransmitted due to MAC retx!", EXPFILL }}, { &ei_rlc_lte_sequence_analysis_retx, { "rlc-lte.sequence-analysis.retx.expert", PI_SEQUENCE, PI_WARN, "AM Frame retransmitted most likely in response to NACK", EXPFILL }}, { &ei_rlc_lte_sequence_analysis_repeated, { "rlc-lte.sequence-analysis.repeated-frame.expert", PI_SEQUENCE, PI_WARN, "AM SN Repeated - probably because didn't receive Status PDU?", EXPFILL }}, { &ei_rlc_lte_am_sn_missing, { "rlc-lte.sequence-analysis.am-sn.missing", PI_SEQUENCE, PI_WARN, "AM SNs missing", EXPFILL }}, { &ei_rlc_lte_sequence_analysis_ack_out_of_range_opposite_frame, { "rlc-lte.sequence-analysis.ack-out-of-range.last-sn-frame.expert", PI_SEQUENCE, PI_ERROR, "AM ACK for SN - but last received SN in other direction is X", EXPFILL }}, { &ei_rlc_lte_um_sn_missing, { "rlc-lte.sequence-analysis.um-sn.missing", PI_SEQUENCE, PI_WARN, "UM SNs missing", EXPFILL }}, { &ei_rlc_lte_um_sn_repeated, { "rlc-lte.sequence-analysis.um-sn.repeated", PI_SEQUENCE, PI_WARN, "UM SN repeated", EXPFILL }}, { &ei_rlc_lte_wrong_sequence_number, { "rlc-lte.wrong-sequence-number", PI_SEQUENCE, PI_WARN, "Wrong Sequence Number", EXPFILL }}, { &ei_rlc_lte_sequence_analysis_repeated_nack, { "rlc-lte.sequence-analysis.repeated-nack.expert", PI_SEQUENCE, PI_ERROR, "Same SN NACKd on successive Status PDUs", EXPFILL }}, { &ei_rlc_lte_reserved_bits_not_zero, { "rlc-lte.reserved-bits-not-zero", PI_MALFORMED, PI_ERROR, "Reserved bits not zero", EXPFILL }}, { &ei_rlc_lte_um_sn, { "rlc-lte.um.sn.invalid", PI_MALFORMED, PI_ERROR, "Invalid sequence number length", EXPFILL }}, { &ei_rlc_lte_header_only, { "rlc-lte.header-only.expert", PI_SEQUENCE, PI_NOTE, "RLC PDU SDUs have been omitted", EXPFILL }}, { &ei_rlc_lte_am_cpt, { "rlc-lte.am.cpt.invalid", PI_MALFORMED, PI_ERROR, "RLC Control frame type not handled", EXPFILL }}, { &ei_rlc_lte_am_nack_sn_ack_same, { "rlc-lte.am.nack-sn.ack-same", PI_MALFORMED, PI_ERROR, "Status PDU shouldn't ACK and NACK the same sequence number", EXPFILL }}, { &ei_rlc_lte_am_nack_sn_ahead_ack, { "rlc-lte.am.nack-sn.ahead-ack", PI_MALFORMED, PI_ERROR, "NACK must not be ahead of ACK in status PDU", EXPFILL }}, { &ei_rlc_lte_am_nack_sn_partial, { "rlc-lte.am.nack-sn.partial", PI_SEQUENCE, PI_WARN, "Status PDU reports NACK (partial)", EXPFILL }}, { &ei_rlc_lte_am_nack_sn, { "rlc-lte.am.nack-sn.expert", PI_SEQUENCE, PI_WARN, "Status PDU reports NACK", EXPFILL }}, { &ei_rlc_lte_bytes_after_status_pdu_complete, { "rlc-lte.bytes-after-status-pdu-complete", PI_MALFORMED, PI_ERROR, "bytes remaining after Status PDU complete", EXPFILL }}, { &ei_rlc_lte_am_data_no_data_beyond_extensions, { "rlc-lte.am-data.no-data-beyond-extensions", PI_MALFORMED, PI_ERROR, "AM data PDU doesn't contain any data beyond extensions", EXPFILL }}, { &ei_rlc_lte_am_data_no_data, { "rlc-lte.am-data.no-data", PI_MALFORMED, PI_ERROR, "AM data PDU doesn't contain any data", EXPFILL }}, { &ei_rlc_lte_context_mode, { "rlc-lte.mode.invalid", PI_MALFORMED, PI_ERROR, "Unrecognised RLC Mode set", EXPFILL }}, }; static const enum_val_t sequence_analysis_vals[] = { {"no-analysis", "No-Analysis", FALSE}, {"mac-only", "Only-MAC-frames", SEQUENCE_ANALYSIS_MAC_ONLY}, {"rlc-only", "Only-RLC-frames", SEQUENCE_ANALYSIS_RLC_ONLY}, {NULL, NULL, -1} }; module_t *rlc_lte_module; expert_module_t* expert_rlc_lte; /* Register protocol. */ proto_rlc_lte = proto_register_protocol("RLC-LTE", "RLC-LTE", "rlc-lte"); proto_register_field_array(proto_rlc_lte, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); expert_rlc_lte = expert_register_protocol(proto_rlc_lte); expert_register_field_array(expert_rlc_lte, ei, array_length(ei)); /* Allow other dissectors to find this one by name. */ register_dissector("rlc-lte", dissect_rlc_lte, proto_rlc_lte); /* Register the tap name */ rlc_lte_tap = register_tap("rlc-lte"); /* Preferences */ rlc_lte_module = prefs_register_protocol(proto_rlc_lte, NULL); prefs_register_enum_preference(rlc_lte_module, "do_sequence_analysis_am", "Do sequence analysis for AM channels", "Attempt to keep track of PDUs for AM channels, and point out problems", &global_rlc_lte_am_sequence_analysis, sequence_analysis_vals, FALSE); prefs_register_enum_preference(rlc_lte_module, "do_sequence_analysis", "Do sequence analysis for UM channels", "Attempt to keep track of PDUs for UM channels, and point out problems", &global_rlc_lte_um_sequence_analysis, sequence_analysis_vals, FALSE); prefs_register_bool_preference(rlc_lte_module, "call_pdcp_for_srb", "Call PDCP dissector for SRB PDUs", "Call PDCP dissector for signalling PDUs. Note that without reassembly, it can" "only be called for complete PDUs (i.e. not segmented over RLC)", &global_rlc_lte_call_pdcp_for_srb); prefs_register_enum_preference(rlc_lte_module, "call_pdcp_for_drb", "Call PDCP dissector for DRB PDUs", "Call PDCP dissector for user-plane PDUs. Note that without reassembly, it can" "only be called for complete PDUs (i.e. not segmented over RLC)", &global_rlc_lte_call_pdcp_for_drb, pdcp_drb_col_vals, FALSE); prefs_register_bool_preference(rlc_lte_module, "call_rrc_for_ccch", "Call RRC dissector for CCCH PDUs", "Call RRC dissector for CCCH PDUs", &global_rlc_lte_call_rrc_for_ccch); prefs_register_bool_preference(rlc_lte_module, "call_rrc_for_mcch", "Call RRC dissector for MCCH PDUs", "Call RRC dissector for MCCH PDUs Note that without reassembly, it can" "only be called for complete PDUs (i.e. not segmented over RLC)", &global_rlc_lte_call_rrc_for_mcch); prefs_register_bool_preference(rlc_lte_module, "call_ip_for_mtch", "Call IP dissector for MTCH PDUs", "Call ip dissector for MTCH PDUs Note that without reassembly, it can" "only be called for complete PDUs (i.e. not segmented over RLC)", &global_rlc_lte_call_ip_for_mtch); prefs_register_bool_preference(rlc_lte_module, "heuristic_rlc_lte_over_udp", "Try Heuristic LTE-RLC over UDP framing", "When enabled, use heuristic dissector to find RLC-LTE frames sent with " "UDP framing", &global_rlc_lte_heur); prefs_register_bool_preference(rlc_lte_module, "header_only_mode", "May see RLC headers only", "When enabled, if data is not present, don't report as an error, but instead " "add expert info to indicate that headers were omitted", &global_rlc_lte_headers_expected); prefs_register_bool_preference(rlc_lte_module, "reassembly", "Attempt SDU reassembly", "When enabled, attempts to re-assemble upper-layer SDUs that are split over " "more than one RLC PDU. Note: does not currently support out-of-order or " "re-segmentation. N.B. sequence analysis must also be turned on in order " "for reassembly to work", &global_rlc_lte_reassembly); register_init_routine(&rlc_lte_init_protocol); } void proto_reg_handoff_rlc_lte(void) { /* Add as a heuristic UDP dissector */ heur_dissector_add("udp", dissect_rlc_lte_heur, proto_rlc_lte); pdcp_lte_handle = find_dissector("pdcp-lte"); ip_handle = find_dissector("ip"); }
jfzazo/wireshark-hwgen
src/epan/dissectors/packet-rlc-lte.c
C
gpl-2.0
148,365
[ 30522, 1013, 1008, 23964, 2005, 8318, 2063, 1054, 15472, 4487, 20939, 3366, 14905, 2135, 1008, 1008, 3235, 8785, 3111, 2239, 1008, 1008, 14666, 8167, 2243, 1011, 2897, 4026, 17908, 2099, 1008, 2011, 9659, 22863, 2015, 1026, 9659, 1030, 1466...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 * as React from "react"; import { IActionProps, IIntentProps, IProps } from "../../common/props"; export interface IToastProps extends IProps, IIntentProps { /** * Action to display in a minimal button. The toast is dismissed automatically when the * user clicks the action button. Note that the `intent` prop is ignored (the action button * cannot have its own intent color that might conflict with the toast's intent). Omit this * prop to omit the action button. */ action?: IActionProps; /** Name of icon to appear before message. Specify only the part of the name after `pt-icon-`. */ iconName?: string; /** Message to display in the body of the toast. */ message: string | JSX.Element; /** * Callback invoked when the toast is dismissed, either by the user or by the timeout. * The value of the argument indicates whether the toast was closed because the timeout expired. */ onDismiss?: (didTimeoutExpire: boolean) => void; /** * Milliseconds to wait before automatically dismissing toast. * Providing a value <= 0 will disable the timeout (this is discouraged). * @default 5000 */ timeout?: number; } export declare class Toast extends React.Component<IToastProps, {}> { static defaultProps: IToastProps; displayName: string; private timeoutId; render(): JSX.Element; componentDidMount(): void; componentDidUpdate(prevProps: IToastProps): void; componentWillUnmount(): void; private maybeRenderActionButton(); private maybeRenderIcon(); private handleActionClick; private handleCloseClick; private triggerDismiss(didTimeoutExpire); private startTimeout; private clearTimeout; } export declare const ToastFactory: React.ComponentFactory<IToastProps & { children?: React.ReactNode; }, Toast>;
BenGoldstein88/MidiTester
src/assets/@blueprintjs/core/dist/components/toast/toast.d.ts
TypeScript
mit
1,864
[ 30522, 12324, 1008, 2004, 10509, 2013, 1000, 10509, 1000, 1025, 12324, 1063, 24264, 7542, 21572, 30524, 18981, 2015, 1010, 2462, 10111, 3372, 21572, 4523, 1063, 1013, 1008, 1008, 1008, 2895, 2000, 4653, 1999, 1037, 10124, 6462, 1012, 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...
using System; using System.Collections.Generic; using Newtonsoft.Json.Linq; namespace MeteorPCL { public class JsonDeserializeHelper { private IDataSubscriber _subscriber; public JsonDeserializeHelper(IDataSubscriber subscriber) { this._subscriber = subscriber; } public void Deserialize(string jsonItem) { JObject jObj = JObject.Parse(jsonItem); this._subscriber.DataReceived(jObj); } } }
shauncampbell/MeteorPCL
JsonDeserializeHelper.cs
C#
mit
420
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 8446, 6499, 6199, 1012, 1046, 3385, 1012, 11409, 4160, 1025, 3415, 15327, 23879, 15042, 2140, 1063, 2270, 2465, 1046, 3385, 6155, 11610, 3669, 4371, 16001, 4842, 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...
# Coniothyrium obovoideum P. Karst. SPECIES #### Status ACCEPTED #### According to Index Fungorum #### Published in null #### Original name Coniothyrium obovoideum P. Karst. ### Remarks null
mdoering/backbone
life/Fungi/Ascomycota/Dothideomycetes/Pleosporales/Leptosphaeriaceae/Coniothyrium/Coniothyrium obovoideum/README.md
Markdown
apache-2.0
195
[ 30522, 1001, 9530, 25185, 10536, 18802, 27885, 16059, 5178, 2819, 1052, 1012, 10556, 12096, 1012, 2427, 1001, 1001, 1001, 1001, 3570, 3970, 1001, 1001, 1001, 1001, 2429, 2000, 5950, 4569, 20255, 30524, 1001, 1001, 1001, 1001, 2434, 2171, 95...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 net.nopattern.cordova.brightcoveplayer; /** * Created by peterchin on 6/9/16. */ public enum Cmd { LOAD, LOADED, DISABLE, ENABLE, PAUSE, PLAY, HIDE, SHOW, SEEK, RATE, RESUME, REPOSITION };
MedStudy/brightcove-player-plugin
src/android/Cmd.java
Java
apache-2.0
248
[ 30522, 7427, 5658, 1012, 2053, 4502, 12079, 2078, 1012, 11601, 7103, 1012, 4408, 3597, 3726, 13068, 2121, 1025, 1013, 1008, 1008, 1008, 2580, 2011, 2848, 17231, 2006, 1020, 1013, 1023, 1013, 2385, 1012, 1008, 1013, 2270, 4372, 2819, 4642, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 // autoload_psr4.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'), 'Zizaco\\Entrust\\' => array($vendorDir . '/zizaco/entrust/src/Entrust'), 'XdgBaseDir\\' => array($vendorDir . '/dnoegel/php-xdg-base-dir/src'), 'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'), 'TijsVerkoyen\\CssToInlineStyles\\' => array($vendorDir . '/tijsverkoyen/css-to-inline-styles/src'), 'Tests\\' => array($baseDir . '/tests'), 'Symfony\\Polyfill\\Util\\' => array($vendorDir . '/symfony/polyfill-util'), 'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'), 'Symfony\\Polyfill\\Php56\\' => array($vendorDir . '/symfony/polyfill-php56'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), 'Symfony\\Contracts\\' => array($vendorDir . '/symfony/contracts'), 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'), 'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'), 'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'), 'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'), 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), 'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'), 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'), 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'), 'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'), 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'), 'Symfony\\Component\\ClassLoader\\' => array($vendorDir . '/symfony/class-loader'), 'SuperClosure\\' => array($vendorDir . '/jeremeamia/SuperClosure/src'), 'Ramsey\\Uuid\\' => array($vendorDir . '/ramsey/uuid/src'), 'Psy\\' => array($vendorDir . '/psy/psysh/src'), 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), 'Predis\\' => array($vendorDir . '/predis/predis/src'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'), 'Mews\\Captcha\\' => array($vendorDir . '/mews/captcha/src'), 'League\\Fractal\\' => array($vendorDir . '/league/fractal/src'), 'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'), 'Laravel\\Tinker\\' => array($vendorDir . '/laravel/tinker/src'), 'JakubOnderka\\PhpConsoleHighlighter\\' => array($vendorDir . '/jakub-onderka/php-console-highlighter/src'), 'JakubOnderka\\PhpConsoleColor\\' => array($vendorDir . '/jakub-onderka/php-console-color/src'), 'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'), 'Illuminate\\' => array($vendorDir . '/laravel/framework/src/Illuminate'), 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'), 'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), 'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Common/Inflector'), 'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations'), 'Dingo\\Blueprint\\' => array($vendorDir . '/dingo/blueprint/src'), 'Dingo\\Api\\' => array($vendorDir . '/dingo/api/src'), 'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'), 'Cron\\' => array($vendorDir . '/mtdowling/cron-expression/src/Cron'), 'Barryvdh\\LaravelIdeHelper\\' => array($vendorDir . '/barryvdh/laravel-ide-helper/src'), 'App\\' => array($baseDir . '/app'), '' => array($vendorDir . '/nesbot/carbon/src'), );
wqer1019/student-work
vendor/composer/autoload_psr4.php
PHP
mit
4,510
[ 30522, 1026, 1029, 25718, 1013, 1013, 8285, 11066, 1035, 8827, 2099, 2549, 1012, 25718, 1030, 7013, 2011, 4543, 1002, 21431, 4305, 2099, 1027, 16101, 18442, 1006, 16101, 18442, 1006, 1035, 1035, 5371, 1035, 1035, 1007, 1007, 1025, 1002, 224...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 System.Collections.Generic; using KellermanSoftware.CompareNetObjects; using KellermanSoftware.CompareNetObjects.TypeComparers; using ProtoBuf; namespace Abc.Zebus.Testing.Comparison { internal static class ComparisonExtensions { public static bool DeepCompare<T>(this T firstObj, T secondObj, params string[] elementsToIgnore) { var comparer = CreateComparer(); comparer.Config.MembersToIgnore.AddRange(elementsToIgnore); return comparer.Compare(firstObj, secondObj).AreEqual; } public static CompareLogic CreateComparer() { return new CompareLogic { Config = { CompareStaticProperties = false, CompareStaticFields = false, CustomComparers = { // TODO : Is this still used? new EquatableComparer() }, AttributesToIgnore = new List<Type> { typeof(ProtoIgnoreAttribute) }, } }; } private class EquatableComparer : BaseTypeComparer { public EquatableComparer() : base(RootComparerFactory.GetRootComparer()) { } public override bool IsTypeMatch(Type type1, Type type2) { if (type1 != type2) return false; return typeof(IEquatable<>).MakeGenericType(type1).IsAssignableFrom(type1); } public override void CompareType(CompareParms parms) { if (!Equals(parms.Object1, parms.Object2)) AddDifference(parms); } } } }
biarne-a/Zebus
src/Abc.Zebus.Testing/Comparison/ComparisonExtensions.cs
C#
mit
1,822
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 16155, 15154, 15794, 8059, 1012, 12826, 7159, 16429, 20614, 2015, 1025, 2478, 16155, 15154, 15794, 8059, 1012, 12826, 7159, 16429, 20614, 2015, 1012, 2828, 9006, 19362,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 /* * Created by tpay.com. * Date: 19.06.2017 * Time: 11:13 */ namespace tpayLibs\src\_class_tpay\Validators\PaymentTypes; use tpayLibs\src\_class_tpay\Validators\PaymentTypesInterface; use tpayLibs\src\Dictionaries\Payments\CardFieldsDictionary; class PaymentTypeCard implements PaymentTypesInterface { public function getRequestFields() { return CardFieldsDictionary::REQUEST_FIELDS; } public function getResponseFields() { return CardFieldsDictionary::RESPONSE_FIELDS; } }
tpaycom/transferuj
tpayLibs/src/_class_tpay/Validators/PaymentTypes/PaymentTypeCard.php
PHP
mit
530
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 2580, 2011, 1056, 4502, 2100, 1012, 4012, 1012, 1008, 3058, 1024, 2539, 1012, 5757, 1012, 2418, 1008, 2051, 1024, 2340, 1024, 2410, 1008, 1013, 3415, 15327, 1056, 4502, 8516, 12322, 2015, 1032, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.intellij.util.xml.stubs.builder; import com.intellij.ide.highlighter.XmlFileType; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.psi.stubs.BinaryFileStubBuilder; import com.intellij.psi.stubs.Stub; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.semantic.SemService; import com.intellij.util.indexing.FileBasedIndexImpl; import com.intellij.util.indexing.FileContent; import com.intellij.util.xml.*; import com.intellij.util.xml.impl.DomApplicationComponent; import com.intellij.util.xml.impl.DomManagerImpl; import com.intellij.util.xml.stubs.FileStub; import com.intellij.xml.util.XmlUtil; /** * @author Dmitry Avdeev * Date: 8/2/12 */ public class DomStubBuilder implements BinaryFileStubBuilder { private static final Logger LOG = Logger.getInstance(DomStubBuilder.class); @Override public boolean acceptsFile(VirtualFile file) { FileType fileType = file.getFileType(); return fileType == XmlFileType.INSTANCE && !FileBasedIndexImpl.isProjectOrWorkspaceFile(file, fileType); } @Override public Stub buildStubTree(FileContent fileContent) { PsiFile psiFile = fileContent.getPsiFile(); if (!(psiFile instanceof XmlFile)) return null; Document document = FileDocumentManager.getInstance().getCachedDocument(fileContent.getFile()); Project project = fileContent.getProject(); if (project == null) { project = psiFile.getProject(); } if (document != null) { PsiFile existingPsi = PsiDocumentManager.getInstance(project).getPsiFile(document); if (existingPsi instanceof XmlFile) { psiFile = existingPsi; } } XmlFile xmlFile = (XmlFile)psiFile; try { XmlUtil.BUILDING_DOM_STUBS.set(Boolean.TRUE); DomFileElement<? extends DomElement> fileElement = DomManager.getDomManager(project).getFileElement(xmlFile); if (fileElement == null || !fileElement.getFileDescription().hasStubs()) return null; XmlFileHeader header = DomService.getInstance().getXmlFileHeader(xmlFile); if (header.getRootTagLocalName() == null) { LOG.error("null root tag for " + fileElement + " for " + fileContent.getFile()); } FileStub fileStub = new FileStub(header); XmlTag rootTag = xmlFile.getRootTag(); if (rootTag != null) { new DomStubBuilderVisitor(DomManagerImpl.getDomManager(project)).visitXmlElement(rootTag, fileStub, 0); } return fileStub; } finally { XmlUtil.BUILDING_DOM_STUBS.set(Boolean.FALSE); SemService.getSemService(project).clearCache(); } } @Override public int getStubVersion() { return 21 + DomApplicationComponent.getInstance().getCumulativeVersion(); } }
Lekanich/intellij-community
xml/dom-impl/src/com/intellij/util/xml/stubs/builder/DomStubBuilder.java
Java
apache-2.0
3,675
[ 30522, 1013, 1008, 1008, 9385, 2456, 1011, 2325, 6892, 10024, 7076, 1055, 1012, 1054, 1012, 1051, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 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 org.scriptonbasestar.tool.collection.joiner; import org.junit.Assert; import org.junit.Test; import org.scriptonbasestar.tool.collection.builder.ListBuilder; import java.util.List; /** * @author archmagece * @since 2017-09-06 */ public class JoinerTest { @Test public void test_Joiner_run() { //given List<String> list = ListBuilder.create("33", "fefe", "fww", "jiojio", "sdfjjksfkjfld").build(); //when String result = Joiner.<String>on(",").append(list).join(); //then System.out.println(result); String expectedString = "33,fefe,fww,jiojio,sdfjjksfkjfld"; Assert.assertEquals(result, expectedString); } }
ScriptonBasestar-Lib/sb-tool-jvm
collection/src/test/java/org/scriptonbasestar/tool/collection/joiner/JoinerTest.java
Java
apache-2.0
644
[ 30522, 7427, 8917, 1012, 5896, 2239, 15058, 14117, 1012, 6994, 1012, 3074, 1012, 3693, 2121, 1025, 12324, 8917, 1012, 12022, 4183, 1012, 20865, 1025, 12324, 8917, 1012, 12022, 4183, 1012, 3231, 1025, 12324, 8917, 1012, 5896, 2239, 15058, 14...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
#container{ width: 750px; margin: 0 auto; text-align: left; } #header { position: relative; top:2px; } #menu{ float: left; width: 150px; } #anchorMenu{ position: fixed; top: auto; width: 8em; left: auto; margin: -2.5em 0 0 0; z-index: 5; overflow: hidden; padding-top: 20px; } #mainArea{ padding-top: 5px; float: left; width: 570px } #footer{ clear: both; text-align: center; font-size: 80%; padding-left: 33.3% } body{ text-align: center; font-family: arial; background: #FFF; padding: 0; } a:link, a:visited { display: block; color:rgb(41,136,126); text-decoration:none; background-color: #EBEBE6; width: 130px; text-align: left; padding: 3px; } a:hover, a:active { color: white; background-color:#7A991A; } a:hover.anchor, a:active.anchor { color: white; background-color:brown; } a.w3c{ width: 83px; } h2, h4{ margin: 8px; } ul li{ font-size: 15px; } table{ border:0px solid black; text-align: left; } td.padded{ border:0px solid black; padding: 0px 0px 38px 0px; width:25% } h3.headings{ text-align: left; } h4.subHead{ text-align:left; } p{ text-align:left; font-size: 15px; } p.profile{ text-align:left; font-weight: bold; font-size: 15px; } .center{ text-align: center; } .padded{ padding-left: 110px; }
mbonez006/me
initial-me/cs15020/mycss.css
CSS
mit
1,306
[ 30522, 1001, 11661, 1063, 9381, 1024, 9683, 2361, 2595, 1025, 7785, 1024, 1014, 8285, 1025, 3793, 1011, 25705, 1024, 2187, 1025, 1065, 1001, 20346, 1063, 2597, 1024, 5816, 1025, 2327, 1024, 1016, 2361, 2595, 1025, 1065, 1001, 30524, 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...
/******************************************************************************* * Copyright (C) 2009-2020 Human Media Interaction, University of Twente, the Netherlands * * This file is part of the Articulated Social Agents Platform BML realizer (ASAPRealizer). * * ASAPRealizer is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License (LGPL) as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ASAPRealizer 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 Lesser General Public License * along with ASAPRealizer. If not, see http://www.gnu.org/licenses/. ******************************************************************************/ package asap.realizerembodiments; import hmi.environmentbase.Embodiment; import hmi.util.Clock; /** * provides access to the scheduling clock of a VH */ public interface SchedulingClockEmbodiment extends Embodiment { Clock getSchedulingClock(); }
ArticulatedSocialAgentsPlatform/AsapRealizer
Environments/AsapRealizerEmbodiments/src/asap/realizerembodiments/SchedulingClockEmbodiment.java
Java
lgpl-3.0
1,270
[ 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...
/* * 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.ignite.internal.processors.query.schema; import java.util.List; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException; import org.apache.ignite.internal.processors.cache.KeyCacheObject; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException; import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow; import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter; import org.apache.ignite.internal.util.lang.GridCursor; import org.apache.ignite.internal.util.typedef.internal.S; import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTED; import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING; import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.RENTING; /** * Traversor operating all primary and backup partitions of given cache. */ @SuppressWarnings("ForLoopReplaceableByForEach") public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor { /** Count of rows, being processed within a single checkpoint lock. */ private static final int BATCH_SIZE = 1000; /** Cache context. */ private final GridCacheContext cctx; /** Row filter. */ private final SchemaIndexCacheFilter rowFilter; /** Cancellation token. */ private final SchemaIndexOperationCancellationToken cancel; /** * Constructor. * @param cctx Cache context. */ public SchemaIndexCacheVisitorImpl(GridCacheContext cctx) { this(cctx, null, null); } /** * Constructor. * @param cctx Cache context. * @param cancel Cancellation token. */ public SchemaIndexCacheVisitorImpl(GridCacheContext cctx, SchemaIndexCacheFilter rowFilter, SchemaIndexOperationCancellationToken cancel) { this.rowFilter = rowFilter; this.cancel = cancel; if (cctx.isNear()) cctx = ((GridNearCacheAdapter)cctx.cache()).dht().context(); this.cctx = cctx; } /** {@inheritDoc} */ @Override public void visit(SchemaIndexCacheVisitorClosure clo) throws IgniteCheckedException { assert clo != null; List<GridDhtLocalPartition> parts = cctx.topology().localPartitions(); for (int i = 0, size = parts.size(); i < size; i++) processPartition(parts.get(i), clo); } /** * Process partition. * * @param part Partition. * @param clo Index closure. * @throws IgniteCheckedException If failed. */ private void processPartition(GridDhtLocalPartition part, SchemaIndexCacheVisitorClosure clo) throws IgniteCheckedException { checkCancelled(); boolean reserved = false; if (part != null && part.state() != EVICTED) reserved = (part.state() == OWNING || part.state() == RENTING) && part.reserve(); if (!reserved) return; try { GridCursor<? extends CacheDataRow> cursor = part.dataStore().cursor(cctx.cacheId(), null, null, CacheDataRowAdapter.RowData.KEY_ONLY); boolean locked = false; try { int cntr = 0; while (cursor.next()) { KeyCacheObject key = cursor.get().key(); if (!locked) { cctx.shared().database().checkpointReadLock(); locked = true; } processKey(key, clo); if (++cntr % BATCH_SIZE == 0) { cctx.shared().database().checkpointReadUnlock(); locked = false; } if (part.state() == RENTING) break; } } finally { if (locked) cctx.shared().database().checkpointReadUnlock(); } } finally { part.release(); } } /** * Process single key. * * @param key Key. * @param clo Closure. * @throws IgniteCheckedException If failed. */ private void processKey(KeyCacheObject key, SchemaIndexCacheVisitorClosure clo) throws IgniteCheckedException { while (true) { try { checkCancelled(); GridCacheEntryEx entry = cctx.cache().entryEx(key); try { entry.updateIndex(rowFilter, clo); } finally { cctx.evicts().touch(entry, AffinityTopologyVersion.NONE); } break; } catch (GridDhtInvalidPartitionException ignore) { break; } catch (GridCacheEntryRemovedException ignored) { // No-op. } } } /** * Check if visit process is not cancelled. * * @throws IgniteCheckedException If cancelled. */ private void checkCancelled() throws IgniteCheckedException { if (cancel != null && cancel.isCancelled()) throw new IgniteCheckedException("Index creation was cancelled."); } /** {@inheritDoc} */ @Override public String toString() { return S.toString(SchemaIndexCacheVisitorImpl.class, this); } }
dream-x/ignite
modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
Java
apache-2.0
6,759
[ 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...
<html lang="en"> <head> <title>Invoking GDB - Debugging with GDB</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Debugging with GDB"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Invocation.html#Invocation" title="Invocation"> <link rel="next" href="Quitting-GDB.html#Quitting-GDB" title="Quitting GDB"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1988-2013 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Free Software'' and ``Free Software Needs Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts as in (a) below. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom.'' --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> <link rel="stylesheet" type="text/css" href="../cs.css"> </head> <body> <div class="node"> <a name="Invoking-GDB"></a> <p> Next:&nbsp;<a rel="next" accesskey="n" href="Quitting-GDB.html#Quitting-GDB">Quitting GDB</a>, Up:&nbsp;<a rel="up" accesskey="u" href="Invocation.html#Invocation">Invocation</a> <hr> </div> <h3 class="section">2.1 Invoking <span class="sc">gdb</span></h3> <p>Invoke <span class="sc">gdb</span> by running the program <code>gdb</code>. Once started, <span class="sc">gdb</span> reads commands from the terminal until you tell it to exit. <p>You can also run <code>gdb</code> with a variety of arguments and options, to specify more of your debugging environment at the outset. <p>The command-line options described here are designed to cover a variety of situations; in some environments, some of these options may effectively be unavailable. <p>The most usual way to start <span class="sc">gdb</span> is with one argument, specifying an executable program: <pre class="smallexample"> gdb <var>program</var> </pre> <p class="noindent">You can also start with both an executable program and a core file specified: <pre class="smallexample"> gdb <var>program</var> <var>core</var> </pre> <p>You can, instead, specify a process ID as a second argument, if you want to debug a running process: <pre class="smallexample"> gdb <var>program</var> 1234 </pre> <p class="noindent">would attach <span class="sc">gdb</span> to process <code>1234</code> (unless you also have a file named <samp><span class="file">1234</span></samp>; <span class="sc">gdb</span> does check for a core file first). <p>Taking advantage of the second command-line argument requires a fairly complete operating system; when you use <span class="sc">gdb</span> as a remote debugger attached to a bare board, there may not be any notion of &ldquo;process&rdquo;, and there is often no way to get a core dump. <span class="sc">gdb</span> will warn you if it is unable to attach or to read core dumps. <p>You can optionally have <code>gdb</code> pass any arguments after the executable file to the inferior using <code>--args</code>. This option stops option processing. <pre class="smallexample"> gdb --args gcc -O2 -c foo.c </pre> <p>This will cause <code>gdb</code> to debug <code>gcc</code>, and to set <code>gcc</code>'s command-line arguments (see <a href="Arguments.html#Arguments">Arguments</a>) to &lsquo;<samp><span class="samp">-O2 -c foo.c</span></samp>&rsquo;. <p>You can run <code>gdb</code> without printing the front material, which describes <span class="sc">gdb</span>'s non-warranty, by specifying <code>-silent</code>: <pre class="smallexample"> gdb -silent </pre> <p class="noindent">You can further control how <span class="sc">gdb</span> starts up by using command-line options. <span class="sc">gdb</span> itself can remind you of the options available. <p class="noindent">Type <pre class="smallexample"> gdb -help </pre> <p class="noindent">to display all available options and briefly describe their use (&lsquo;<samp><span class="samp">gdb -h</span></samp>&rsquo; is a shorter equivalent). <p>All options and command line arguments you give are processed in sequential order. The order makes a difference when the &lsquo;<samp><span class="samp">-x</span></samp>&rsquo; option is used. <ul class="menu"> <li><a accesskey="1" href="File-Options.html#File-Options">File Options</a>: Choosing files <li><a accesskey="2" href="Mode-Options.html#Mode-Options">Mode Options</a>: Choosing modes <li><a accesskey="3" href="Startup.html#Startup">Startup</a>: What <span class="sc">gdb</span> does during startup </ul> </body></html>
hajuuk/asuswrt
release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/gdb/Invoking-GDB.html
HTML
gpl-2.0
5,498
[ 30522, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 1999, 22776, 1043, 18939, 1011, 2139, 8569, 12588, 2007, 1043, 18939, 1026, 1013, 2516, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 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...
class CreateAddresses < ActiveRecord::Migration def change create_table :addresses do |t| t.string :address1 t.string :address2 t.string :city t.string :province t.string :country t.string :postal_code t.references :addressable, polymorphic: true, index: true t.timestamps null: false end end end
joatuapp/joatu-v2
db/migrate/20150213210056_create_addresses.rb
Ruby
gpl-3.0
359
[ 30522, 2465, 3443, 4215, 16200, 11393, 2015, 1026, 3161, 2890, 27108, 2094, 1024, 1024, 9230, 13366, 2689, 3443, 1035, 2795, 1024, 11596, 2079, 1064, 1056, 1064, 1056, 1012, 5164, 1024, 4769, 2487, 1056, 1012, 5164, 1024, 4769, 2475, 1056, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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>menhirlib: 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.14.0 / menhirlib - 20200211</a></li> </ul> </div> </div> </div> <div class="article"> <div class="row"> <div class="col-md-12"> <a href="../..">« Up</a> <h1> menhirlib <small> 20200211 <span class="label label-info">Not compatible 👼</span> </small> </h1> <p>📅 <em><script>document.write(moment("2021-12-03 21:53:52 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2021-12-03 21:53:52 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 conf-gmp 3 Virtual package relying on a GMP lib system installation coq 8.14.0 Formal proof management system dune 2.9.1 Fast, portable, and opinionated build system ocaml 4.06.1 The OCaml compiler (virtual package) ocaml-base-compiler 4.06.1 Official 4.06.1 release ocaml-config 1 OCaml Switch Configuration ocaml-secondary-compiler 4.08.1-1 OCaml 4.08.1 Secondary Switch Compiler ocamlfind 1.9.1 A library manager for OCaml ocamlfind-secondary 1.9.1 Adds support for ocaml-secondary-compiler to ocamlfind zarith 1.12 Implements arithmetic and logical operations over arbitrary-precision integers # opam file: opam-version: &quot;2.0&quot; synopsis: &quot;A support library for verified Coq parsers produced by Menhir&quot; maintainer: &quot;francois.pottier@inria.fr&quot; authors: [ &quot;Jacques-Henri Jourdan &lt;jacques-henri.jourdan@lri.fr&gt;&quot; ] homepage: &quot;https://gitlab.inria.fr/fpottier/menhir&quot; dev-repo: &quot;git+https://gitlab.inria.fr/fpottier/menhir.git&quot; bug-reports: &quot;jacques-henri.jourdan@lri.fr&quot; license: &quot;LGPL-3.0-or-later&quot; build: [ [make &quot;-C&quot; &quot;coq-menhirlib&quot; &quot;-j%{jobs}%&quot;] ] install: [ [make &quot;-C&quot; &quot;coq-menhirlib&quot; &quot;install&quot;] ] depends: [ &quot;coq&quot; { &gt;= &quot;8.7&quot; &amp; &lt; &quot;8.12&quot; } ] conflicts: [ &quot;menhir&quot; { != &quot;20200211&quot; } ] tags: [ &quot;date:2020-02-11&quot; &quot;logpath:MenhirLib&quot; ] url { src: &quot;https://gitlab.inria.fr/fpottier/menhir/-/archive/20200211/archive.tar.gz&quot; checksum: [ &quot;md5=01577e5f15380c35bdaa8fd818204560&quot; &quot;sha512=a686c4b047d5236c425afcd7f179964191268ff448b8d18510579d742a7256855049bc4fe568bb8f1b0d6cbfb758d95cd05e621e3410b75245bb799d623725d6&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-menhirlib.20200211 coq.8.14.0</code></dd> <dt>Return code</dt> <dd>5120</dd> <dt>Output</dt> <dd><pre>[NOTE] Package coq is already installed (current version is 8.14.0). The following dependencies couldn&#39;t be met: - coq-menhirlib -&gt; coq &lt; 8.12 -&gt; ocaml &lt; 4.06.0 base of this switch (use `--unlock-base&#39; to force) Your request can&#39;t be satisfied: - No available version of coq satisfies the constraints 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-menhirlib.20200211</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"> Sources are on <a href="https://github.com/coq-bench">GitHub</a> © Guillaume Claret 🐣 </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.06.1-2.0.5/released/8.14.0/menhirlib/20200211.html
HTML
mit
7,258
[ 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, 30524, 1027, 1015, 1000, 1028, 1026, 2516, 1028, 2273, 11961, 29521, 1024, 2025, 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> <title>nwSGM</title> <body bgcolor="#000066" text="#FFFF00" link="#8888FF" vlink="#FF0000"> <h1><em>nwSGM</em></h1> <hr> <p> <b><em>Segment generator</em></b> <p> <hr> </body> </html>
rangsimanketkaew/NWChem
doc/nwahtml/nwargos_nwSGM.html
HTML
mit
191
[ 30522, 1026, 16129, 1028, 1026, 2516, 1028, 22064, 28745, 2213, 1026, 1013, 2516, 1028, 1026, 2303, 1038, 18195, 12898, 2099, 1027, 1000, 1001, 2199, 2692, 28756, 1000, 3793, 1027, 1000, 1001, 21461, 4246, 8889, 1000, 4957, 1027, 1000, 1001...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 powerorm package. * * (c) Eddilbert Macharia <edd.cowan@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Eddmash\PowerOrm\Model; class Delete { const CASCADE = 'CASCADE'; const PROTECT = 'PROTECT'; const DONOTHING = 'DONOTHIN'; const SETNULL = 'SETNULL'; const SETDEFAULT = 'SETDEFAULT'; }
eddmash/powerorm
src/Model/Delete.php
PHP
mit
455
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 1996, 2373, 2953, 2213, 7427, 1012, 1008, 1008, 1006, 1039, 1007, 3968, 4305, 23373, 24532, 10980, 1026, 3968, 2094, 1012, 25752, 1030, 20917, 4014, 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...
subroutine smooth_bruckner(y_bkg, y, n, smooth_points, iterations) ! extracts a background of pattern/pattern by using an ! intelligent moving average filter. Whereby for each point it is ! checked whether the y-value is larger than the average - if it is ! it will be replaced by the local average ! y_bkg: is the output array with size n ! y: is the input array with size n ! smooth_points: are the half of the window size for averaging ! iterations: number of iterations of running the algorithm implicit none integer, intent(in) :: n integer, intent(in) :: smooth_points integer, intent(in) :: iterations double precision, intent(in), dimension(0:n-1) :: y double precision, intent(out), dimension(0:n-1) :: y_bkg double precision, dimension(0:n+2*smooth_points-1) :: y_extended double precision :: window_avg double precision :: y_new integer :: i, j double precision :: window_size ! creating an extended y with having size n + 2*smooth_points y_extended(0:smooth_points-1) = y(0) y_extended(smooth_points:n+smooth_points-1) = y y_extended(smooth_points+n:2*smooth_points+n-1) = y(n-1) ! actual algorithm: window_size = 2*smooth_points + 1 do j=0, iterations-1 window_avg = sum(y_extended(0:2*smooth_points))/(2*smooth_points+1) do i=smooth_points, (n-smooth_points-3) if (y_extended(i)>window_avg) then y_new = window_avg ! updating central value in average (first bracket) ! and shifting average by one index (second bracket) window_avg = window_avg + ((window_avg-y_extended(i)) + & (y_extended(i+smooth_points+1)-y_extended(i - smooth_points))) & /window_size y_extended(i) = y_new else ! shifting average by one index window_avg = window_avg + (y_extended(i+smooth_points+1)-y_extended(i - smooth_points))/window_size end if end do end do y_bkg = y_extended(smooth_points:n+smooth_points-1) end subroutine
Dioptas/Dioptas
dioptas/model/util/smooth_bruckner.f95
FORTRAN
gpl-3.0
2,061
[ 30522, 4942, 22494, 10196, 5744, 1035, 7987, 12722, 3678, 1006, 1061, 1035, 23923, 2290, 1010, 1061, 1010, 1050, 1010, 5744, 1035, 2685, 1010, 27758, 2015, 1007, 999, 27059, 1037, 4281, 1997, 5418, 1013, 5418, 2011, 2478, 2019, 999, 9414, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var React = _interopRequireWildcard(require("react")); var _createSvgIcon = _interopRequireDefault(require("../../utils/createSvgIcon")); var _jsxRuntime = require("react/jsx-runtime"); /** * @ignore - internal component. */ var _default = (0, _createSvgIcon.default)( /*#__PURE__*/(0, _jsxRuntime.jsx)("path", { d: "M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z" }), 'Star'); exports.default = _default;
cdnjs/cdnjs
ajax/libs/material-ui/5.0.0-alpha.36/node/internal/svg-icons/Star.js
JavaScript
mit
738
[ 30522, 1000, 2224, 9384, 1000, 1025, 13075, 1035, 6970, 7361, 2890, 15549, 5596, 12879, 23505, 1027, 5478, 1006, 1000, 1030, 11561, 2140, 1013, 2448, 7292, 1013, 2393, 2545, 1013, 6970, 7361, 2890, 15549, 5596, 12879, 23505, 1000, 1007, 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...
package featureflag_test import ( "errors" fakeflag "github.com/cloudfoundry/cli/cf/api/feature_flags/fakes" "github.com/cloudfoundry/cli/cf/command_registry" "github.com/cloudfoundry/cli/cf/configuration/core_config" testcmd "github.com/cloudfoundry/cli/testhelpers/commands" testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" . "github.com/cloudfoundry/cli/testhelpers/matchers" testreq "github.com/cloudfoundry/cli/testhelpers/requirements" testterm "github.com/cloudfoundry/cli/testhelpers/terminal" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("enable-feature-flag command", func() { var ( ui *testterm.FakeUI requirementsFactory *testreq.FakeReqFactory configRepo core_config.Repository flagRepo *fakeflag.FakeFeatureFlagRepository deps command_registry.Dependency ) updateCommandDependency := func(pluginCall bool) { deps.Ui = ui deps.RepoLocator = deps.RepoLocator.SetFeatureFlagRepository(flagRepo) deps.Config = configRepo command_registry.Commands.SetCommand(command_registry.Commands.FindCommand("enable-feature-flag").SetDependency(deps, pluginCall)) } BeforeEach(func() { ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true} flagRepo = &fakeflag.FakeFeatureFlagRepository{} }) runCommand := func(args ...string) bool { return testcmd.RunCliCommand("enable-feature-flag", args, requirementsFactory, updateCommandDependency, false) } Describe("requirements", func() { It("requires the user to be logged in", func() { requirementsFactory.LoginSuccess = false Expect(runCommand()).ToNot(HavePassedRequirements()) }) It("fails with usage if a single feature is not specified", func() { runCommand() Expect(ui.Outputs).To(ContainSubstrings( []string{"Incorrect Usage", "Requires an argument"}, )) }) }) Describe("when logged in", func() { BeforeEach(func() { flagRepo.UpdateReturns(nil) }) It("Sets the flag", func() { runCommand("user_org_creation") flag, set := flagRepo.UpdateArgsForCall(0) Expect(flag).To(Equal("user_org_creation")) Expect(set).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"Setting status of user_org_creation as my-user..."}, []string{"OK"}, []string{"Feature user_org_creation Enabled."}, )) }) Context("when an error occurs", func() { BeforeEach(func() { flagRepo.UpdateReturns(errors.New("An error occurred.")) }) It("fails with an error", func() { runCommand("i-dont-exist") Expect(ui.Outputs).To(ContainSubstrings( []string{"FAILED"}, []string{"An error occurred."}, )) }) }) }) })
Zouuup/cli
cf/commands/featureflag/enable_feature_flag_test.go
GO
apache-2.0
2,796
[ 30522, 7427, 3444, 10258, 8490, 1035, 3231, 12324, 1006, 1000, 10697, 1000, 8275, 10258, 8490, 1000, 21025, 2705, 12083, 1012, 4012, 1013, 6112, 14876, 8630, 2854, 1013, 18856, 2072, 1013, 12935, 1013, 17928, 1013, 3444, 1035, 9245, 1013, 8...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* testIO.c */ #include "../Coords.h" #include "../../timings.h" /*--------------------------------------------------------------------*/ int main ( int argc, char *argv[] ) /* -------------------------------------------------- test Coords_readFromFile and Coords_writeToFile, useful for translating between formatted *.coordsf and binary *.coordsb files. created -- 95dec17, cca -------------------------------------------------- */ { int msglvl, rc ; Coords coords ; FILE *msgFile ; if ( argc != 5 ) { fprintf(stdout, "\n\n usage : testIO msglvl msgFile inFile outFile" "\n msglvl -- message level" "\n msgFile -- message file" "\n inFile -- input file, must be *.coordsf or *.coordsb" "\n outFile -- output file, must be *.coordsf or *.coordsb" "\n") ; return(0) ; } msglvl = atoi(argv[1]) ; if ( strcmp(argv[2], "stdout") == 0 ) { msgFile = stdout ; } else if ( (msgFile = fopen(argv[2], "a")) == NULL ) { fprintf(stderr, "\n fatal error in %s" "\n unable to open file %s\n", argv[0], argv[2]) ; return(-1) ; } fprintf(msgFile, "\n testIO " "\n msglvl -- %d" "\n msgFile -- %s" "\n inFile -- %s" "\n outFile -- %s" "\n", msglvl, argv[2], argv[3], argv[4]) ; fflush(msgFile) ; /* ---------------------- set the default fields ---------------------- */ Coords_setDefaultFields(&coords) ; if ( msglvl > 1 ) { fprintf(msgFile, "\n\n after setting default fields") ; Coords_writeForHumanEye(&coords, msgFile) ; fflush(msgFile) ; } /* ------------------------- read in the Coords object ------------------------- */ if ( strcmp(argv[3], "none") == 0 ) { fprintf(msgFile, "\n no file to read from\n") ; exit(0) ; } rc = Coords_readFromFile(&coords, argv[3]) ; fprintf(msgFile, "\n return value %d from Coords_readFromFile(%p,%s)", rc, &coords, argv[3]) ; if ( rc != 1 ) { exit(-1) ; } if ( msglvl > 1 ) { fprintf(msgFile, "\n\n after reading Coords object from file %s", argv[3]) ; Coords_writeForHumanEye(&coords, msgFile) ; fflush(msgFile) ; } /* --------------------------- write out the Coords object --------------------------- */ if ( strcmp(argv[4], "none") != 0 ) { rc = Coords_writeToFile(&coords, argv[4]) ; fprintf(msgFile, "\n return value %d from Coords_writeToFile(%p,%s)", rc, &coords, argv[4]) ; } fprintf(msgFile, "\n") ; fclose(msgFile) ; return(1) ; } /*--------------------------------------------------------------------*/
zagl/ccx-user
application/SPOOLES.2.2/Coords/drivers/testIO.c
C
gpl-2.0
2,628
[ 30522, 1013, 1008, 3231, 3695, 1012, 1039, 1008, 1013, 1001, 2421, 1000, 1012, 1012, 1013, 2522, 8551, 2015, 1012, 1044, 1000, 1001, 2421, 1000, 1012, 1012, 1013, 1012, 1012, 1013, 10984, 2015, 1012, 1044, 1000, 1013, 1008, 1011, 1011, 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...
<md-dialog aria-label="Mango (Fruit)"> <md-content class="md-padding" layout="column"> <h3> Add a category </h3> <md-input-container flex> <label>Name</label> <input ng-model="cate.name" placeholder="Category name"> </md-input-container> <md-input-container flex> <label>Description</label> <input ng-model="cate.description" placeholder="Category description"> </md-input-container> </md-content> <div class="md-dialog-actions" layout="row"> <span flex></span> <md-button ng-click="cancel()"> Cancel </md-button> <md-button ng-click="add()" class="md-primary"> Add </md-button> </div> </md-dialog>
vunguyen2712/bookmark
public/addCate.html
HTML
mit
641
[ 30522, 1026, 9108, 1011, 13764, 8649, 9342, 1011, 3830, 1027, 1000, 24792, 1006, 5909, 1007, 1000, 1028, 1026, 9108, 1011, 4180, 2465, 1027, 1000, 9108, 1011, 11687, 4667, 1000, 9621, 1027, 1000, 5930, 1000, 1028, 1026, 1044, 2509, 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...
-- Omitted = auto-detect. Test UTF-8 without BOM. IMPORT CSV '<FILES>\utf8.csv' INTO table1; SELECT * FROM table1; -- Omitted = auto-detect. Test UTF-8 with BOM. IMPORT CSV '<FILES>\utf8bom.csv' INTO table2; SELECT * FROM table2; -- Omitted = auto-detect. Test UTF-16. IMPORT CSV '<FILES>\utf16.csv' INTO table3; SELECT * FROM table3; -- 0 = auto-detect. Test UTF-8 without BOM. IMPORT CSV '<FILES>\utf8.csv' INTO table4 OPTIONS (FILE_ENCODING: 0); SELECT * FROM table4; -- 0 = auto-detect. Test UTF-8 with BOM. IMPORT CSV '<FILES>\utf8bom.csv' INTO table5 OPTIONS (FILE_ENCODING: 0); SELECT * FROM table5; -- 0 = auto-detect. Test UTF-16. IMPORT CSV '<FILES>\utf16.csv' INTO table6 OPTIONS (FILE_ENCODING: 0); SELECT * FROM table6; -- 65001 = UTF-8. Test without BOM. IMPORT CSV '<FILES>\utf8.csv' INTO table7 OPTIONS (FILE_ENCODING: 65001); SELECT * FROM table7; -- 65001 = UTF-8. Test with BOM. IMPORT CSV '<FILES>\utf8bom.csv' INTO table8 OPTIONS (FILE_ENCODING: 65001); SELECT * FROM table8; -- 1200 = UTF-16 IMPORT CSV '<FILES>\utf16.csv' INTO table9 OPTIONS (FILE_ENCODING: 1200); SELECT * FROM table9; -- 932 = Shift-JIS IMPORT CSV '<FILES>\shiftjis.csv' INTO table10 OPTIONS (FILE_ENCODING: 932); SELECT * FROM table10; --output-- foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - foo,bar 111,HELLO 222,WORLD - 日,本,語 いつ神戸に来るのか教えて下さい,ABC社のガードナー氏は,2月20日から27日までマリオットホテルに滞在中で ぜひあなたに会いたいとのことです,彼は、詩人ではなくて小説家だ,3人のうちの1人が芝刈り機で私の庭を大雑把にさっと刈り -
electroly/sqlnotebook
src/Tests/scripts/IMPORT CSV FILE_ENCODING.sql
SQL
mit
1,867
[ 30522, 1011, 1011, 16647, 1027, 8285, 1011, 11487, 1012, 3231, 21183, 2546, 1011, 1022, 2302, 8945, 2213, 1012, 12324, 20116, 2615, 1005, 1026, 6764, 1028, 1032, 21183, 2546, 2620, 1012, 20116, 2615, 1005, 2046, 2795, 2487, 1025, 7276, 1008...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 graphics.basicShapes; import graphics.genMath.Math3D; import graphics.geoShapes.GeoLine; import java.util.ArrayList; public class Vector3D extends Point3D { private double zen; private double azi; public Vector3D() { } public Vector3D(double x, double y, double z) { super(x, y, z); } public Vector3D(double x, double y, double z, double zen, double azi) { this(x, y, z); this.setZenith(zen); this.setAzimuth(azi); } public String toString() { return "Vector3D[" + getX() + "," + getY() + "," + getZ() + "," + this.getZenith() + "," + this.getAzumith() + "]"; } public GeoLine getPerpendicularLine() { return new GeoLine(this, Math3D.rotatePoint(this, 100, 90, 0)); } Polygon3D perpPlane; public Polygon3D getPerpendicularPlane() { if (perpPlane != null) { return perpPlane; } Point3D r1 = Math3D.rotatePoint(this, 1000, getZenith() + 90, 0); Point3D r2 = Math3D.rotatePoint(this, 1000, getZenith(), -90 - this.getAzumith()); Point3D r3 = Math3D.rotatePoint(this, 1000, getZenith() - 90, 0); Point3D r4 = Math3D.rotatePoint(this, 1000, getZenith(), 90 - this.getAzumith()); ArrayList<Point3D> rt = new ArrayList<Point3D>(); rt.add(r1); rt.add(r2); rt.add(r3); rt.add(r4); return new Polygon3D(rt); } public void turnToFace(Point3D p) { this.setZenith(Math3D.getZenithFrom(this, p)); this.setAzimuth(Math3D.getAzimuthFrom(this, p)); } public void putWithinBounds() { // removed because it wasn't doing anything. // double z = getZenith() % 360; // if (maxZenithRot != 999 && maxZenithRot > 360 && z > maxZenithRot % // 360) { // z = maxZenithRot % 360; // } // this.zen = (Math.max(Math.min(z, maxZenithRot), minZenithRot)); // double a = getAzumith() % 360; // if (maxAzumithRot != 999 && maxAzumithRot > 360 && z > maxAzumithRot // % 360) { // z = maxAzumithRot % 360; // } // this.azi = (Math.max(Math.min(a, maxAzumithRot), minAzumithRot)); } public void rotateZenith(double degrees) { this.setZenith(getZenith() + degrees); } public void rotateAzumith(double degrees) { this.setAzimuth(getAzumith() + degrees); } public void setZenith(double xr) { this.zen = xr; putWithinBounds(); } public double getZenith() { return zen; } public void setAzimuth(double yr) { this.azi = yr; putWithinBounds(); } public double getAzumith() { return azi; } }
dfcf93/RPICS
NaturalLanguageProcessing/src/graphics/basicShapes/Vector3D.java
Java
mit
2,402
[ 30522, 7427, 8389, 1012, 24078, 3270, 10374, 1025, 12324, 8389, 1012, 8991, 18900, 2232, 1012, 8785, 29097, 1025, 12324, 8389, 1012, 20248, 7377, 10374, 1012, 20248, 4179, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 9140, 9863, 1025, 2270, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 System.Collections.Generic; using System.Linq; using System.IO; public class OddLInes { static void Main() { string[] textLines = File.ReadAllLines("input.txt"); List<string> oddLines = new List<string>(); for (int i = 0; i < textLines.Length; i++) { if (i % 2 == 0) { oddLines.Add(textLines[i]); } } File.WriteAllLines("output.txt", oddLines); } }
komitoff/Softuni-Programming-Fundamentals
FilesAndExceptions_Lab/E1.OddLines/OddLInes.cs
C#
mit
488
[ 30522, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 2291, 1012, 11409, 4160, 1025, 2478, 2291, 1012, 22834, 1025, 2270, 2465, 5976, 12735, 1063, 10763, 11675, 2364, 1006, 1007, 1063, 5164, 1031, 1033, 3793, 12735, 1027...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 2012, Adam L. Davis, all rights reserved. */ package com.adamldavis.z.java; import static java.util.Arrays.asList; import groovy.lang.Binding; import groovy.lang.GroovyShell; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import com.adamldavis.z.editor.Playground; public class GroovyPlay implements Runnable { private File script; private GroovyShell shell; private final List<String> out = Collections .synchronizedList(new LinkedList<String>()); private final Map<Pattern, String> methodMap = new HashMap<Pattern, String>(); Pattern assign = Pattern.compile("([\\w\\.]+) = ([^/]*)"); Pattern eq = Pattern.compile("\\(([^\\s]+) == ([^/]*)\\)"); Pattern neq = Pattern.compile("\\((\\w+) != ([^/]*)\\)"); Pattern ret = Pattern.compile("return ([^/]*)"); Pattern params1 = Pattern.compile("def (\\w+)\\((\\w+)\\)"); Pattern params2 = Pattern.compile("def (\\w+)\\((\\w+), (\\w+)\\)"); Pattern println = Pattern.compile("println ([^/]*)"); final List<Pattern> patterns = asList(assign, eq, neq, ret, params1, params2, println); final List<Pattern> paramPatterns = asList(params1, params2); public GroovyPlay(File script) { Binding binding = new Binding(); binding.setVariable("script_path", script.getAbsolutePath()); binding.setVariable("_out_", out); shell = new GroovyShell(binding); this.script = script; methodMap.put(assign, "replAssign"); methodMap.put(eq, "replEq"); methodMap.put(neq, "replNeq"); methodMap.put(ret, "replReturn"); methodMap.put(params1, "replParams"); methodMap.put(params2, "replParams"); methodMap.put(println, "replPrintln"); } @Override public void run() { try { shell.evaluate(modify(script)); } catch (IOException e) { throw new RuntimeException(e); } } private File modify(File script) { File file = null; try { file = File.createTempFile("modified", ".groovy"); List<String> code = FileUtils.readLines(script); List<String> result = new LinkedList<String>(); int i = 0; // line# for (String line : code) { boolean foundMatch = false; for (Pattern patt : patterns) { if (patt.matcher(line).find()) { result.add(handle(line, patt, i)); foundMatch = true; break; } } if (!foundMatch) { result.add(line); } i++; } result.add("def replAssign(a, b, n) {_out_.add(\"$n:$a = $b\" as String); }"); result.add("def replNeq(a, b, n) {_out_.add(\"$n:$a != $b\" as String); a != b}"); result.add("def replEq(a, b, n) {_out_.add(\"$n:$a == $b\" as String); a == b}"); result.add("def replReturn(a, n) {_out_.add(\"$n:return $a\" as String); a}"); result.add("def replParams(n, m, ... a) {_out_.add(n + ':def ' + m + ' ' + a.join(', '))}"); result.add("def replPrintln(a, n) {_out_.add(\"$n:println $a\" as String); println a}"); FileUtils.writeLines(file, result); } catch (IOException e) { e.printStackTrace(); } return file; } // converts the LOC to use a repl private String handle(String line, Pattern pattern, int n) { String methodName = methodMap.get(pattern); Matcher m = pattern.matcher(line); m.find(); int start = m.start(), end = m.end(); if (pattern == ret || pattern == println) { return line.substring(0, start) + methodName + "(" + m.group(1) + "," + n + ")"; } else if (pattern == assign) { // refers to left side only, so side-effects don't occur twice return line + ";" + methodName + "('" + m.group(1) + "'," + m.group(1) + "," + n + ");"; } else if (pattern == params1) { return line + methodName + "(" + n + ",'" + m.group(1) + "'," + m.group(2) + ");"; } else if (pattern == params2) { return line + methodName + "(" + n + ",'" + m.group(1) + "'," + m.group(2) + "," + m.group(3) + ");"; } else { return line.substring(0, start) + "(" + methodName + "(" + m.group(1) + "," + m.group(2) + "," + n + "))" + line.substring(end); } } public List<String> getOut() { return out; } /** Test main. */ public static void main(String[] args) { try { File file = File.createTempFile("temp", ".groovy"); IOUtils.copy(Playground.class.getResourceAsStream("/lcm.groovy"), new FileOutputStream(file)); file = new GroovyPlay(file).modify(file); IOUtils.copy(new FileInputStream(file), System.out); } catch (IOException e) { e.printStackTrace(); } } }
adamd/z
src/com/adamldavis/z/java/GroovyPlay.java
Java
bsd-2-clause
4,720
[ 30522, 1013, 1008, 1008, 9385, 2262, 1010, 4205, 1048, 1012, 4482, 1010, 2035, 2916, 9235, 1012, 1008, 1013, 7427, 4012, 1012, 4205, 15150, 11365, 1012, 1062, 1012, 9262, 1025, 12324, 10763, 9262, 1012, 21183, 4014, 1012, 27448, 1012, 2004,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* * drivers/media/platform/samsung/mfc5/s5p_mfc_opr_v5.c * * Samsung MFC (Multi Function Codec - FIMV) driver * This file contains hw related functions. * * Kamil Debski, Copyright (c) 2011 Samsung Electronics * 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 "s5p_mfc_common.h" #include "s5p_mfc_cmd.h" #include "s5p_mfc_ctrl.h" #include "s5p_mfc_debug.h" #include "s5p_mfc_intr.h" #include "s5p_mfc_pm.h" #include "s5p_mfc_opr.h" #include "s5p_mfc_opr_v5.h" #include <asm/cacheflush.h> #include <linux/delay.h> #include <linux/dma-mapping.h> #include <linux/err.h> #include <linux/firmware.h> #include <linux/io.h> #include <linux/jiffies.h> #include <linux/mm.h> #include <linux/sched.h> #define OFFSETA(x) (((x) - dev->bank1) >> MFC_OFFSET_SHIFT) #define OFFSETB(x) (((x) - dev->bank2) >> MFC_OFFSET_SHIFT) /* Allocate temporary buffers for decoding */ static int s5p_mfc_alloc_dec_temp_buffers_v5(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv; int ret; ctx->dsc.size = buf_size->dsc; ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->dsc); if (ret) { mfc_err("Failed to allocate temporary buffer\n"); return ret; } BUG_ON(ctx->dsc.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1)); memset(ctx->dsc.virt, 0, ctx->dsc.size); wmb(); return 0; } /* Release temporary buffers for decoding */ static void s5p_mfc_release_dec_desc_buffer_v5(struct s5p_mfc_ctx *ctx) { s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->dsc); } /* Allocate codec buffers */ static int s5p_mfc_alloc_codec_buffers_v5(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; unsigned int enc_ref_y_size = 0; unsigned int enc_ref_c_size = 0; unsigned int guard_width, guard_height; int ret; if (ctx->type == MFCINST_DECODER) { mfc_debug(2, "Luma size:%d Chroma size:%d MV size:%d\n", ctx->luma_size, ctx->chroma_size, ctx->mv_size); mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count); } else if (ctx->type == MFCINST_ENCODER) { enc_ref_y_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) * ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); enc_ref_y_size = ALIGN(enc_ref_y_size, S5P_FIMV_NV12MT_SALIGN); if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) { enc_ref_c_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) * ALIGN(ctx->img_height >> 1, S5P_FIMV_NV12MT_VALIGN); enc_ref_c_size = ALIGN(enc_ref_c_size, S5P_FIMV_NV12MT_SALIGN); } else { guard_width = ALIGN(ctx->img_width + 16, S5P_FIMV_NV12MT_HALIGN); guard_height = ALIGN((ctx->img_height >> 1) + 4, S5P_FIMV_NV12MT_VALIGN); enc_ref_c_size = ALIGN(guard_width * guard_height, S5P_FIMV_NV12MT_SALIGN); } mfc_debug(2, "recon luma size: %d chroma size: %d\n", enc_ref_y_size, enc_ref_c_size); } else { return -EINVAL; } /* Codecs have different memory requirements */ switch (ctx->codec_mode) { case S5P_MFC_CODEC_H264_DEC: ctx->bank1.size = ALIGN(S5P_FIMV_DEC_NB_IP_SIZE + S5P_FIMV_DEC_VERT_NB_MV_SIZE, S5P_FIMV_DEC_BUF_ALIGN); ctx->bank2.size = ctx->total_dpb_count * ctx->mv_size; break; case S5P_MFC_CODEC_MPEG4_DEC: ctx->bank1.size = ALIGN(S5P_FIMV_DEC_NB_DCAC_SIZE + S5P_FIMV_DEC_UPNB_MV_SIZE + S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE + S5P_FIMV_DEC_STX_PARSER_SIZE + S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE, S5P_FIMV_DEC_BUF_ALIGN); ctx->bank2.size = 0; break; case S5P_MFC_CODEC_VC1RCV_DEC: case S5P_MFC_CODEC_VC1_DEC: ctx->bank1.size = ALIGN(S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE + S5P_FIMV_DEC_UPNB_MV_SIZE + S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE + S5P_FIMV_DEC_NB_DCAC_SIZE + 3 * S5P_FIMV_DEC_VC1_BITPLANE_SIZE, S5P_FIMV_DEC_BUF_ALIGN); ctx->bank2.size = 0; break; case S5P_MFC_CODEC_MPEG2_DEC: ctx->bank1.size = 0; ctx->bank2.size = 0; break; case S5P_MFC_CODEC_H263_DEC: ctx->bank1.size = ALIGN(S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE + S5P_FIMV_DEC_UPNB_MV_SIZE + S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE + S5P_FIMV_DEC_NB_DCAC_SIZE, S5P_FIMV_DEC_BUF_ALIGN); ctx->bank2.size = 0; break; case S5P_MFC_CODEC_H264_ENC: ctx->bank1.size = (enc_ref_y_size * 2) + S5P_FIMV_ENC_UPMV_SIZE + S5P_FIMV_ENC_COLFLG_SIZE + S5P_FIMV_ENC_INTRAMD_SIZE + S5P_FIMV_ENC_NBORINFO_SIZE; ctx->bank2.size = (enc_ref_y_size * 2) + (enc_ref_c_size * 4) + S5P_FIMV_ENC_INTRAPRED_SIZE; break; case S5P_MFC_CODEC_MPEG4_ENC: ctx->bank1.size = (enc_ref_y_size * 2) + S5P_FIMV_ENC_UPMV_SIZE + S5P_FIMV_ENC_COLFLG_SIZE + S5P_FIMV_ENC_ACDCCOEF_SIZE; ctx->bank2.size = (enc_ref_y_size * 2) + (enc_ref_c_size * 4); break; case S5P_MFC_CODEC_H263_ENC: ctx->bank1.size = (enc_ref_y_size * 2) + S5P_FIMV_ENC_UPMV_SIZE + S5P_FIMV_ENC_ACDCCOEF_SIZE; ctx->bank2.size = (enc_ref_y_size * 2) + (enc_ref_c_size * 4); break; default: break; } /* Allocate only if memory from bank 1 is necessary */ if (ctx->bank1.size > 0) { ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->bank1); if (ret) { mfc_err("Failed to allocate Bank1 temporary buffer\n"); return ret; } BUG_ON(ctx->bank1.dma & ((1 << MFC_BANK1_ALIGN_ORDER) - 1)); } /* Allocate only if memory from bank 2 is necessary */ if (ctx->bank2.size > 0) { ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_r, &ctx->bank2); if (ret) { mfc_err("Failed to allocate Bank2 temporary buffer\n"); s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->bank1); return ret; } BUG_ON(ctx->bank2.dma & ((1 << MFC_BANK2_ALIGN_ORDER) - 1)); } return 0; } /* Release buffers allocated for codec */ static void s5p_mfc_release_codec_buffers_v5(struct s5p_mfc_ctx *ctx) { s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->bank1); s5p_mfc_release_priv_buf(ctx->dev->mem_dev_r, &ctx->bank2); } /* Allocate memory for instance data buffer */ static int s5p_mfc_alloc_instance_buffer_v5(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv; int ret; if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC || ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) ctx->ctx.size = buf_size->h264_ctx; else ctx->ctx.size = buf_size->non_h264_ctx; ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->ctx); if (ret) { mfc_err("Failed to allocate instance buffer\n"); return ret; } ctx->ctx.ofs = OFFSETA(ctx->ctx.dma); /* Zero content of the allocated memory */ memset(ctx->ctx.virt, 0, ctx->ctx.size); wmb(); /* Initialize shared memory */ ctx->shm.size = buf_size->shm; ret = s5p_mfc_alloc_priv_buf(dev->mem_dev_l, &ctx->shm); if (ret) { mfc_err("Failed to allocate shared memory buffer\n"); return ret; } /* shared memory offset only keeps the offset from base (port a) */ ctx->shm.ofs = ctx->shm.dma - dev->bank1; BUG_ON(ctx->shm.ofs & ((1 << MFC_BANK1_ALIGN_ORDER) - 1)); memset(ctx->shm.virt, 0, buf_size->shm); wmb(); return 0; } /* Release instance buffer */ static void s5p_mfc_release_instance_buffer_v5(struct s5p_mfc_ctx *ctx) { s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->ctx); s5p_mfc_release_priv_buf(ctx->dev->mem_dev_l, &ctx->shm); } static int s5p_mfc_alloc_dev_context_buffer_v5(struct s5p_mfc_dev *dev) { /* NOP */ return 0; } static void s5p_mfc_release_dev_context_buffer_v5(struct s5p_mfc_dev *dev) { /* NOP */ } static void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data, unsigned int ofs) { writel(data, (ctx->shm.virt + ofs)); wmb(); } static unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx, unsigned int ofs) { rmb(); return readl(ctx->shm.virt + ofs); } static void s5p_mfc_dec_calc_dpb_size_v5(struct s5p_mfc_ctx *ctx) { unsigned int guard_width, guard_height; ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN); ctx->buf_height = ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); mfc_debug(2, "SEQ Done: Movie dimensions %dx%d, buffer dimensions: %dx%d\n", ctx->img_width, ctx->img_height, ctx->buf_width, ctx->buf_height); if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) { ctx->luma_size = ALIGN(ctx->buf_width * ctx->buf_height, S5P_FIMV_DEC_BUF_ALIGN); ctx->chroma_size = ALIGN(ctx->buf_width * ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12MT_VALIGN), S5P_FIMV_DEC_BUF_ALIGN); ctx->mv_size = ALIGN(ctx->buf_width * ALIGN((ctx->buf_height >> 2), S5P_FIMV_NV12MT_VALIGN), S5P_FIMV_DEC_BUF_ALIGN); } else { guard_width = ALIGN(ctx->img_width + 24, S5P_FIMV_NV12MT_HALIGN); guard_height = ALIGN(ctx->img_height + 16, S5P_FIMV_NV12MT_VALIGN); ctx->luma_size = ALIGN(guard_width * guard_height, S5P_FIMV_DEC_BUF_ALIGN); guard_width = ALIGN(ctx->img_width + 16, S5P_FIMV_NV12MT_HALIGN); guard_height = ALIGN((ctx->img_height >> 1) + 4, S5P_FIMV_NV12MT_VALIGN); ctx->chroma_size = ALIGN(guard_width * guard_height, S5P_FIMV_DEC_BUF_ALIGN); ctx->mv_size = 0; } } static void s5p_mfc_enc_calc_src_size_v5(struct s5p_mfc_ctx *ctx) { if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) { ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN); ctx->luma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN) * ALIGN(ctx->img_height, S5P_FIMV_NV12M_LVALIGN); ctx->chroma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12M_HALIGN) * ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12M_CVALIGN); ctx->luma_size = ALIGN(ctx->luma_size, S5P_FIMV_NV12M_SALIGN); ctx->chroma_size = ALIGN(ctx->chroma_size, S5P_FIMV_NV12M_SALIGN); } else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT) { ctx->buf_width = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN); ctx->luma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) * ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); ctx->chroma_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) * ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12MT_VALIGN); ctx->luma_size = ALIGN(ctx->luma_size, S5P_FIMV_NV12MT_SALIGN); ctx->chroma_size = ALIGN(ctx->chroma_size, S5P_FIMV_NV12MT_SALIGN); } } /* Set registers for decoding temporary buffers */ static void s5p_mfc_set_dec_desc_buffer(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv; mfc_write(dev, OFFSETA(ctx->dsc.dma), S5P_FIMV_SI_CH0_DESC_ADR); mfc_write(dev, buf_size->dsc, S5P_FIMV_SI_CH0_DESC_SIZE); } /* Set registers for shared buffer */ static void s5p_mfc_set_shared_buffer(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; mfc_write(dev, ctx->shm.ofs, S5P_FIMV_SI_CH0_HOST_WR_ADR); } /* Set registers for decoding stream buffer */ static int s5p_mfc_set_dec_stream_buffer_v5(struct s5p_mfc_ctx *ctx, int buf_addr, unsigned int start_num_byte, unsigned int buf_size) { struct s5p_mfc_dev *dev = ctx->dev; mfc_write(dev, OFFSETA(buf_addr), S5P_FIMV_SI_CH0_SB_ST_ADR); mfc_write(dev, ctx->dec_src_buf_size, S5P_FIMV_SI_CH0_CPB_SIZE); mfc_write(dev, buf_size, S5P_FIMV_SI_CH0_SB_FRM_SIZE); s5p_mfc_write_info_v5(ctx, start_num_byte, START_BYTE_NUM); return 0; } /* Set decoding frame buffer */ static int s5p_mfc_set_dec_frame_buffer_v5(struct s5p_mfc_ctx *ctx) { unsigned int frame_size, i; unsigned int frame_size_ch, frame_size_mv; struct s5p_mfc_dev *dev = ctx->dev; unsigned int dpb; size_t buf_addr1, buf_addr2; int buf_size1, buf_size2; buf_addr1 = ctx->bank1.dma; buf_size1 = ctx->bank1.size; buf_addr2 = ctx->bank2.dma; buf_size2 = ctx->bank2.size; dpb = mfc_read(dev, S5P_FIMV_SI_CH0_DPB_CONF_CTRL) & ~S5P_FIMV_DPB_COUNT_MASK; mfc_write(dev, ctx->total_dpb_count | dpb, S5P_FIMV_SI_CH0_DPB_CONF_CTRL); s5p_mfc_set_shared_buffer(ctx); switch (ctx->codec_mode) { case S5P_MFC_CODEC_H264_DEC: mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_VERT_NB_MV_ADR); buf_addr1 += S5P_FIMV_DEC_VERT_NB_MV_SIZE; buf_size1 -= S5P_FIMV_DEC_VERT_NB_MV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_NB_IP_ADR); buf_addr1 += S5P_FIMV_DEC_NB_IP_SIZE; buf_size1 -= S5P_FIMV_DEC_NB_IP_SIZE; break; case S5P_MFC_CODEC_MPEG4_DEC: mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_NB_DCAC_ADR); buf_addr1 += S5P_FIMV_DEC_NB_DCAC_SIZE; buf_size1 -= S5P_FIMV_DEC_NB_DCAC_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_UP_NB_MV_ADR); buf_addr1 += S5P_FIMV_DEC_UPNB_MV_SIZE; buf_size1 -= S5P_FIMV_DEC_UPNB_MV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_SA_MV_ADR); buf_addr1 += S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE; buf_size1 -= S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_SP_ADR); buf_addr1 += S5P_FIMV_DEC_STX_PARSER_SIZE; buf_size1 -= S5P_FIMV_DEC_STX_PARSER_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_OT_LINE_ADR); buf_addr1 += S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE; buf_size1 -= S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE; break; case S5P_MFC_CODEC_H263_DEC: mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_OT_LINE_ADR); buf_addr1 += S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE; buf_size1 -= S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_UP_NB_MV_ADR); buf_addr1 += S5P_FIMV_DEC_UPNB_MV_SIZE; buf_size1 -= S5P_FIMV_DEC_UPNB_MV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_SA_MV_ADR); buf_addr1 += S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE; buf_size1 -= S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_NB_DCAC_ADR); buf_addr1 += S5P_FIMV_DEC_NB_DCAC_SIZE; buf_size1 -= S5P_FIMV_DEC_NB_DCAC_SIZE; break; case S5P_MFC_CODEC_VC1_DEC: case S5P_MFC_CODEC_VC1RCV_DEC: mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_NB_DCAC_ADR); buf_addr1 += S5P_FIMV_DEC_NB_DCAC_SIZE; buf_size1 -= S5P_FIMV_DEC_NB_DCAC_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_OT_LINE_ADR); buf_addr1 += S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE; buf_size1 -= S5P_FIMV_DEC_OVERLAP_TRANSFORM_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_UP_NB_MV_ADR); buf_addr1 += S5P_FIMV_DEC_UPNB_MV_SIZE; buf_size1 -= S5P_FIMV_DEC_UPNB_MV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_SA_MV_ADR); buf_addr1 += S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE; buf_size1 -= S5P_FIMV_DEC_SUB_ANCHOR_MV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_BITPLANE3_ADR); buf_addr1 += S5P_FIMV_DEC_VC1_BITPLANE_SIZE; buf_size1 -= S5P_FIMV_DEC_VC1_BITPLANE_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_BITPLANE2_ADR); buf_addr1 += S5P_FIMV_DEC_VC1_BITPLANE_SIZE; buf_size1 -= S5P_FIMV_DEC_VC1_BITPLANE_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_VC1_BITPLANE1_ADR); buf_addr1 += S5P_FIMV_DEC_VC1_BITPLANE_SIZE; buf_size1 -= S5P_FIMV_DEC_VC1_BITPLANE_SIZE; break; case S5P_MFC_CODEC_MPEG2_DEC: break; default: mfc_err("Unknown codec for decoding (%x)\n", ctx->codec_mode); return -EINVAL; } frame_size = ctx->luma_size; frame_size_ch = ctx->chroma_size; frame_size_mv = ctx->mv_size; mfc_debug(2, "Frm size: %d ch: %d mv: %d\n", frame_size, frame_size_ch, frame_size_mv); for (i = 0; i < ctx->total_dpb_count; i++) { /* Bank2 */ mfc_debug(2, "Luma %d: %x\n", i, ctx->dst_bufs[i].cookie.raw.luma); mfc_write(dev, OFFSETB(ctx->dst_bufs[i].cookie.raw.luma), S5P_FIMV_DEC_LUMA_ADR + i * 4); mfc_debug(2, "\tChroma %d: %x\n", i, ctx->dst_bufs[i].cookie.raw.chroma); mfc_write(dev, OFFSETA(ctx->dst_bufs[i].cookie.raw.chroma), S5P_FIMV_DEC_CHROMA_ADR + i * 4); if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) { mfc_debug(2, "\tBuf2: %x, size: %d\n", buf_addr2, buf_size2); mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_H264_MV_ADR + i * 4); buf_addr2 += frame_size_mv; buf_size2 -= frame_size_mv; } } mfc_debug(2, "Buf1: %u, buf_size1: %d\n", buf_addr1, buf_size1); mfc_debug(2, "Buf 1/2 size after: %d/%d (frames %d)\n", buf_size1, buf_size2, ctx->total_dpb_count); if (buf_size1 < 0 || buf_size2 < 0) { mfc_debug(2, "Not enough memory has been allocated\n"); return -ENOMEM; } s5p_mfc_write_info_v5(ctx, frame_size, ALLOC_LUMA_DPB_SIZE); s5p_mfc_write_info_v5(ctx, frame_size_ch, ALLOC_CHROMA_DPB_SIZE); if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC) s5p_mfc_write_info_v5(ctx, frame_size_mv, ALLOC_MV_SIZE); mfc_write(dev, ((S5P_FIMV_CH_INIT_BUFS & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); return 0; } /* Set registers for encoding stream buffer */ static int s5p_mfc_set_enc_stream_buffer_v5(struct s5p_mfc_ctx *ctx, unsigned long addr, unsigned int size) { struct s5p_mfc_dev *dev = ctx->dev; mfc_write(dev, OFFSETA(addr), S5P_FIMV_ENC_SI_CH0_SB_ADR); mfc_write(dev, size, S5P_FIMV_ENC_SI_CH0_SB_SIZE); return 0; } static void s5p_mfc_set_enc_frame_buffer_v5(struct s5p_mfc_ctx *ctx, unsigned long y_addr, unsigned long c_addr) { struct s5p_mfc_dev *dev = ctx->dev; mfc_write(dev, OFFSETB(y_addr), S5P_FIMV_ENC_SI_CH0_CUR_Y_ADR); mfc_write(dev, OFFSETB(c_addr), S5P_FIMV_ENC_SI_CH0_CUR_C_ADR); } static void s5p_mfc_get_enc_frame_buffer_v5(struct s5p_mfc_ctx *ctx, unsigned long *y_addr, unsigned long *c_addr) { struct s5p_mfc_dev *dev = ctx->dev; *y_addr = dev->bank2 + (mfc_read(dev, S5P_FIMV_ENCODED_Y_ADDR) << MFC_OFFSET_SHIFT); *c_addr = dev->bank2 + (mfc_read(dev, S5P_FIMV_ENCODED_C_ADDR) << MFC_OFFSET_SHIFT); } /* Set encoding ref & codec buffer */ static int s5p_mfc_set_enc_ref_buffer_v5(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; size_t buf_addr1, buf_addr2; size_t buf_size1, buf_size2; unsigned int enc_ref_y_size, enc_ref_c_size; unsigned int guard_width, guard_height; int i; buf_addr1 = ctx->bank1.dma; buf_size1 = ctx->bank1.size; buf_addr2 = ctx->bank2.dma; buf_size2 = ctx->bank2.size; enc_ref_y_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) * ALIGN(ctx->img_height, S5P_FIMV_NV12MT_VALIGN); enc_ref_y_size = ALIGN(enc_ref_y_size, S5P_FIMV_NV12MT_SALIGN); if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) { enc_ref_c_size = ALIGN(ctx->img_width, S5P_FIMV_NV12MT_HALIGN) * ALIGN((ctx->img_height >> 1), S5P_FIMV_NV12MT_VALIGN); enc_ref_c_size = ALIGN(enc_ref_c_size, S5P_FIMV_NV12MT_SALIGN); } else { guard_width = ALIGN(ctx->img_width + 16, S5P_FIMV_NV12MT_HALIGN); guard_height = ALIGN((ctx->img_height >> 1) + 4, S5P_FIMV_NV12MT_VALIGN); enc_ref_c_size = ALIGN(guard_width * guard_height, S5P_FIMV_NV12MT_SALIGN); } mfc_debug(2, "buf_size1: %d, buf_size2: %d\n", buf_size1, buf_size2); switch (ctx->codec_mode) { case S5P_MFC_CODEC_H264_ENC: for (i = 0; i < 2; i++) { mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_ENC_REF0_LUMA_ADR + (4 * i)); buf_addr1 += enc_ref_y_size; buf_size1 -= enc_ref_y_size; mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_ENC_REF2_LUMA_ADR + (4 * i)); buf_addr2 += enc_ref_y_size; buf_size2 -= enc_ref_y_size; } for (i = 0; i < 4; i++) { mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_ENC_REF0_CHROMA_ADR + (4 * i)); buf_addr2 += enc_ref_c_size; buf_size2 -= enc_ref_c_size; } mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_UP_MV_ADR); buf_addr1 += S5P_FIMV_ENC_UPMV_SIZE; buf_size1 -= S5P_FIMV_ENC_UPMV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_COZERO_FLAG_ADR); buf_addr1 += S5P_FIMV_ENC_COLFLG_SIZE; buf_size1 -= S5P_FIMV_ENC_COLFLG_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_UP_INTRA_MD_ADR); buf_addr1 += S5P_FIMV_ENC_INTRAMD_SIZE; buf_size1 -= S5P_FIMV_ENC_INTRAMD_SIZE; mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_H264_UP_INTRA_PRED_ADR); buf_addr2 += S5P_FIMV_ENC_INTRAPRED_SIZE; buf_size2 -= S5P_FIMV_ENC_INTRAPRED_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H264_NBOR_INFO_ADR); buf_addr1 += S5P_FIMV_ENC_NBORINFO_SIZE; buf_size1 -= S5P_FIMV_ENC_NBORINFO_SIZE; mfc_debug(2, "buf_size1: %d, buf_size2: %d\n", buf_size1, buf_size2); break; case S5P_MFC_CODEC_MPEG4_ENC: for (i = 0; i < 2; i++) { mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_ENC_REF0_LUMA_ADR + (4 * i)); buf_addr1 += enc_ref_y_size; buf_size1 -= enc_ref_y_size; mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_ENC_REF2_LUMA_ADR + (4 * i)); buf_addr2 += enc_ref_y_size; buf_size2 -= enc_ref_y_size; } for (i = 0; i < 4; i++) { mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_ENC_REF0_CHROMA_ADR + (4 * i)); buf_addr2 += enc_ref_c_size; buf_size2 -= enc_ref_c_size; } mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_UP_MV_ADR); buf_addr1 += S5P_FIMV_ENC_UPMV_SIZE; buf_size1 -= S5P_FIMV_ENC_UPMV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_COZERO_FLAG_ADR); buf_addr1 += S5P_FIMV_ENC_COLFLG_SIZE; buf_size1 -= S5P_FIMV_ENC_COLFLG_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_MPEG4_ACDC_COEF_ADR); buf_addr1 += S5P_FIMV_ENC_ACDCCOEF_SIZE; buf_size1 -= S5P_FIMV_ENC_ACDCCOEF_SIZE; mfc_debug(2, "buf_size1: %d, buf_size2: %d\n", buf_size1, buf_size2); break; case S5P_MFC_CODEC_H263_ENC: for (i = 0; i < 2; i++) { mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_ENC_REF0_LUMA_ADR + (4 * i)); buf_addr1 += enc_ref_y_size; buf_size1 -= enc_ref_y_size; mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_ENC_REF2_LUMA_ADR + (4 * i)); buf_addr2 += enc_ref_y_size; buf_size2 -= enc_ref_y_size; } for (i = 0; i < 4; i++) { mfc_write(dev, OFFSETB(buf_addr2), S5P_FIMV_ENC_REF0_CHROMA_ADR + (4 * i)); buf_addr2 += enc_ref_c_size; buf_size2 -= enc_ref_c_size; } mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_UP_MV_ADR); buf_addr1 += S5P_FIMV_ENC_UPMV_SIZE; buf_size1 -= S5P_FIMV_ENC_UPMV_SIZE; mfc_write(dev, OFFSETA(buf_addr1), S5P_FIMV_H263_ACDC_COEF_ADR); buf_addr1 += S5P_FIMV_ENC_ACDCCOEF_SIZE; buf_size1 -= S5P_FIMV_ENC_ACDCCOEF_SIZE; mfc_debug(2, "buf_size1: %d, buf_size2: %d\n", buf_size1, buf_size2); break; default: mfc_err("Unknown codec set for encoding: %d\n", ctx->codec_mode); return -EINVAL; } return 0; } static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_enc_params *p = &ctx->enc_params; unsigned int reg; unsigned int shm; /* width */ mfc_write(dev, ctx->img_width, S5P_FIMV_ENC_HSIZE_PX); /* height */ mfc_write(dev, ctx->img_height, S5P_FIMV_ENC_VSIZE_PX); /* pictype : enable, IDR period */ reg = mfc_read(dev, S5P_FIMV_ENC_PIC_TYPE_CTRL); reg |= (1 << 18); reg &= ~(0xFFFF); reg |= p->gop_size; mfc_write(dev, reg, S5P_FIMV_ENC_PIC_TYPE_CTRL); mfc_write(dev, 0, S5P_FIMV_ENC_B_RECON_WRITE_ON); /* multi-slice control */ /* multi-slice MB number or bit size */ mfc_write(dev, p->slice_mode, S5P_FIMV_ENC_MSLICE_CTRL); if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) { mfc_write(dev, p->slice_mb, S5P_FIMV_ENC_MSLICE_MB); } else if (p->slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES) { mfc_write(dev, p->slice_bit, S5P_FIMV_ENC_MSLICE_BIT); } else { mfc_write(dev, 0, S5P_FIMV_ENC_MSLICE_MB); mfc_write(dev, 0, S5P_FIMV_ENC_MSLICE_BIT); } /* cyclic intra refresh */ mfc_write(dev, p->intra_refresh_mb, S5P_FIMV_ENC_CIR_CTRL); /* memory structure cur. frame */ if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) mfc_write(dev, 0, S5P_FIMV_ENC_MAP_FOR_CUR); else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT) mfc_write(dev, 3, S5P_FIMV_ENC_MAP_FOR_CUR); /* padding control & value */ reg = mfc_read(dev, S5P_FIMV_ENC_PADDING_CTRL); if (p->pad) { /** enable */ reg |= (1 << 31); /** cr value */ reg &= ~(0xFF << 16); reg |= (p->pad_cr << 16); /** cb value */ reg &= ~(0xFF << 8); reg |= (p->pad_cb << 8); /** y value */ reg &= ~(0xFF); reg |= (p->pad_luma); } else { /** disable & all value clear */ reg = 0; } mfc_write(dev, reg, S5P_FIMV_ENC_PADDING_CTRL); /* rate control config. */ reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG); /** frame-level rate control */ reg &= ~(0x1 << 9); reg |= (p->rc_frame << 9); mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG); /* bit rate */ if (p->rc_frame) mfc_write(dev, p->rc_bitrate, S5P_FIMV_ENC_RC_BIT_RATE); else mfc_write(dev, 0, S5P_FIMV_ENC_RC_BIT_RATE); /* reaction coefficient */ if (p->rc_frame) mfc_write(dev, p->rc_reaction_coeff, S5P_FIMV_ENC_RC_RPARA); shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); /* seq header ctrl */ shm &= ~(0x1 << 3); shm |= (p->seq_hdr_mode << 3); /* frame skip mode */ shm &= ~(0x3 << 1); shm |= (p->frame_skip_mode << 1); s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); /* fixed target bit */ s5p_mfc_write_info_v5(ctx, p->fixed_target_bit, RC_CONTROL_CONFIG); return 0; } static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_enc_params *p = &ctx->enc_params; struct s5p_mfc_h264_enc_params *p_264 = &p->codec.h264; unsigned int reg; unsigned int shm; s5p_mfc_set_enc_params(ctx); /* pictype : number of B */ reg = mfc_read(dev, S5P_FIMV_ENC_PIC_TYPE_CTRL); /* num_b_frame - 0 ~ 2 */ reg &= ~(0x3 << 16); reg |= (p->num_b_frame << 16); mfc_write(dev, reg, S5P_FIMV_ENC_PIC_TYPE_CTRL); /* profile & level */ reg = mfc_read(dev, S5P_FIMV_ENC_PROFILE); /* level */ reg &= ~(0xFF << 8); reg |= (p_264->level << 8); /* profile - 0 ~ 2 */ reg &= ~(0x3F); reg |= p_264->profile; mfc_write(dev, reg, S5P_FIMV_ENC_PROFILE); /* interlace */ mfc_write(dev, p_264->interlace, S5P_FIMV_ENC_PIC_STRUCT); /* height */ if (p_264->interlace) mfc_write(dev, ctx->img_height >> 1, S5P_FIMV_ENC_VSIZE_PX); /* loopfilter ctrl */ mfc_write(dev, p_264->loop_filter_mode, S5P_FIMV_ENC_LF_CTRL); /* loopfilter alpha offset */ if (p_264->loop_filter_alpha < 0) { reg = 0x10; reg |= (0xFF - p_264->loop_filter_alpha) + 1; } else { reg = 0x00; reg |= (p_264->loop_filter_alpha & 0xF); } mfc_write(dev, reg, S5P_FIMV_ENC_ALPHA_OFF); /* loopfilter beta offset */ if (p_264->loop_filter_beta < 0) { reg = 0x10; reg |= (0xFF - p_264->loop_filter_beta) + 1; } else { reg = 0x00; reg |= (p_264->loop_filter_beta & 0xF); } mfc_write(dev, reg, S5P_FIMV_ENC_BETA_OFF); /* entropy coding mode */ if (p_264->entropy_mode == V4L2_MPEG_VIDEO_H264_ENTROPY_MODE_CABAC) mfc_write(dev, 1, S5P_FIMV_ENC_H264_ENTROPY_MODE); else mfc_write(dev, 0, S5P_FIMV_ENC_H264_ENTROPY_MODE); /* number of ref. picture */ reg = mfc_read(dev, S5P_FIMV_ENC_H264_NUM_OF_REF); /* num of ref. pictures of P */ reg &= ~(0x3 << 5); reg |= (p_264->num_ref_pic_4p << 5); /* max number of ref. pictures */ reg &= ~(0x1F); reg |= p_264->max_ref_pic; mfc_write(dev, reg, S5P_FIMV_ENC_H264_NUM_OF_REF); /* 8x8 transform enable */ mfc_write(dev, p_264->_8x8_transform, S5P_FIMV_ENC_H264_TRANS_FLAG); /* rate control config. */ reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG); /* macroblock level rate control */ reg &= ~(0x1 << 8); reg |= (p->rc_mb << 8); /* frame QP */ reg &= ~(0x3F); reg |= p_264->rc_frame_qp; mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG); /* frame rate */ if (p->rc_frame && p->rc_framerate_denom) mfc_write(dev, p->rc_framerate_num * 1000 / p->rc_framerate_denom, S5P_FIMV_ENC_RC_FRAME_RATE); else mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE); /* max & min value of QP */ reg = mfc_read(dev, S5P_FIMV_ENC_RC_QBOUND); /* max QP */ reg &= ~(0x3F << 8); reg |= (p_264->rc_max_qp << 8); /* min QP */ reg &= ~(0x3F); reg |= p_264->rc_min_qp; mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND); /* macroblock adaptive scaling features */ if (p->rc_mb) { reg = mfc_read(dev, S5P_FIMV_ENC_RC_MB_CTRL); /* dark region */ reg &= ~(0x1 << 3); reg |= (p_264->rc_mb_dark << 3); /* smooth region */ reg &= ~(0x1 << 2); reg |= (p_264->rc_mb_smooth << 2); /* static region */ reg &= ~(0x1 << 1); reg |= (p_264->rc_mb_static << 1); /* high activity region */ reg &= ~(0x1); reg |= p_264->rc_mb_activity; mfc_write(dev, reg, S5P_FIMV_ENC_RC_MB_CTRL); } if (!p->rc_frame && !p->rc_mb) { shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP); shm &= ~(0xFFF); shm |= ((p_264->rc_b_frame_qp & 0x3F) << 6); shm |= (p_264->rc_p_frame_qp & 0x3F); s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP); } /* extended encoder ctrl */ shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); /* AR VUI control */ shm &= ~(0x1 << 15); shm |= (p_264->vui_sar << 1); s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); if (p_264->vui_sar) { /* aspect ration IDC */ shm = s5p_mfc_read_info_v5(ctx, SAMPLE_ASPECT_RATIO_IDC); shm &= ~(0xFF); shm |= p_264->vui_sar_idc; s5p_mfc_write_info_v5(ctx, shm, SAMPLE_ASPECT_RATIO_IDC); if (p_264->vui_sar_idc == 0xFF) { /* sample AR info */ shm = s5p_mfc_read_info_v5(ctx, EXTENDED_SAR); shm &= ~(0xFFFFFFFF); shm |= p_264->vui_ext_sar_width << 16; shm |= p_264->vui_ext_sar_height; s5p_mfc_write_info_v5(ctx, shm, EXTENDED_SAR); } } /* intra picture period for H.264 */ shm = s5p_mfc_read_info_v5(ctx, H264_I_PERIOD); /* control */ shm &= ~(0x1 << 16); shm |= (p_264->open_gop << 16); /* value */ if (p_264->open_gop) { shm &= ~(0xFFFF); shm |= p_264->open_gop_size; } s5p_mfc_write_info_v5(ctx, shm, H264_I_PERIOD); /* extended encoder ctrl */ shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); /* vbv buffer size */ if (p->frame_skip_mode == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) { shm &= ~(0xFFFF << 16); shm |= (p_264->cpb_size << 16); } s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); return 0; } static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_enc_params *p = &ctx->enc_params; struct s5p_mfc_mpeg4_enc_params *p_mpeg4 = &p->codec.mpeg4; unsigned int reg; unsigned int shm; unsigned int framerate; s5p_mfc_set_enc_params(ctx); /* pictype : number of B */ reg = mfc_read(dev, S5P_FIMV_ENC_PIC_TYPE_CTRL); /* num_b_frame - 0 ~ 2 */ reg &= ~(0x3 << 16); reg |= (p->num_b_frame << 16); mfc_write(dev, reg, S5P_FIMV_ENC_PIC_TYPE_CTRL); /* profile & level */ reg = mfc_read(dev, S5P_FIMV_ENC_PROFILE); /* level */ reg &= ~(0xFF << 8); reg |= (p_mpeg4->level << 8); /* profile - 0 ~ 2 */ reg &= ~(0x3F); reg |= p_mpeg4->profile; mfc_write(dev, reg, S5P_FIMV_ENC_PROFILE); /* quarter_pixel */ mfc_write(dev, p_mpeg4->quarter_pixel, S5P_FIMV_ENC_MPEG4_QUART_PXL); /* qp */ if (!p->rc_frame) { shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP); shm &= ~(0xFFF); shm |= ((p_mpeg4->rc_b_frame_qp & 0x3F) << 6); shm |= (p_mpeg4->rc_p_frame_qp & 0x3F); s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP); } /* frame rate */ if (p->rc_frame) { if (p->rc_framerate_denom > 0) { framerate = p->rc_framerate_num * 1000 / p->rc_framerate_denom; mfc_write(dev, framerate, S5P_FIMV_ENC_RC_FRAME_RATE); shm = s5p_mfc_read_info_v5(ctx, RC_VOP_TIMING); shm &= ~(0xFFFFFFFF); shm |= (1 << 31); shm |= ((p->rc_framerate_num & 0x7FFF) << 16); shm |= (p->rc_framerate_denom & 0xFFFF); s5p_mfc_write_info_v5(ctx, shm, RC_VOP_TIMING); } } else { mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE); } /* rate control config. */ reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG); /* frame QP */ reg &= ~(0x3F); reg |= p_mpeg4->rc_frame_qp; mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG); /* max & min value of QP */ reg = mfc_read(dev, S5P_FIMV_ENC_RC_QBOUND); /* max QP */ reg &= ~(0x3F << 8); reg |= (p_mpeg4->rc_max_qp << 8); /* min QP */ reg &= ~(0x3F); reg |= p_mpeg4->rc_min_qp; mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND); /* extended encoder ctrl */ shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); /* vbv buffer size */ if (p->frame_skip_mode == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) { shm &= ~(0xFFFF << 16); shm |= (p->vbv_size << 16); } s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); return 0; } static int s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_enc_params *p = &ctx->enc_params; struct s5p_mfc_mpeg4_enc_params *p_h263 = &p->codec.mpeg4; unsigned int reg; unsigned int shm; s5p_mfc_set_enc_params(ctx); /* qp */ if (!p->rc_frame) { shm = s5p_mfc_read_info_v5(ctx, P_B_FRAME_QP); shm &= ~(0xFFF); shm |= (p_h263->rc_p_frame_qp & 0x3F); s5p_mfc_write_info_v5(ctx, shm, P_B_FRAME_QP); } /* frame rate */ if (p->rc_frame && p->rc_framerate_denom) mfc_write(dev, p->rc_framerate_num * 1000 / p->rc_framerate_denom, S5P_FIMV_ENC_RC_FRAME_RATE); else mfc_write(dev, 0, S5P_FIMV_ENC_RC_FRAME_RATE); /* rate control config. */ reg = mfc_read(dev, S5P_FIMV_ENC_RC_CONFIG); /* frame QP */ reg &= ~(0x3F); reg |= p_h263->rc_frame_qp; mfc_write(dev, reg, S5P_FIMV_ENC_RC_CONFIG); /* max & min value of QP */ reg = mfc_read(dev, S5P_FIMV_ENC_RC_QBOUND); /* max QP */ reg &= ~(0x3F << 8); reg |= (p_h263->rc_max_qp << 8); /* min QP */ reg &= ~(0x3F); reg |= p_h263->rc_min_qp; mfc_write(dev, reg, S5P_FIMV_ENC_RC_QBOUND); /* extended encoder ctrl */ shm = s5p_mfc_read_info_v5(ctx, EXT_ENC_CONTROL); /* vbv buffer size */ if (p->frame_skip_mode == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) { shm &= ~(0xFFFF << 16); shm |= (p->vbv_size << 16); } s5p_mfc_write_info_v5(ctx, shm, EXT_ENC_CONTROL); return 0; } /* Initialize decoding */ static int s5p_mfc_init_decode_v5(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; s5p_mfc_set_shared_buffer(ctx); /* Setup loop filter, for decoding this is only valid for MPEG4 */ if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_DEC) mfc_write(dev, ctx->loop_filter_mpeg4, S5P_FIMV_ENC_LF_CTRL); else mfc_write(dev, 0, S5P_FIMV_ENC_LF_CTRL); mfc_write(dev, ((ctx->slice_interface & S5P_FIMV_SLICE_INT_MASK) << S5P_FIMV_SLICE_INT_SHIFT) | (ctx->display_delay_enable << S5P_FIMV_DDELAY_ENA_SHIFT) | ((ctx->display_delay & S5P_FIMV_DDELAY_VAL_MASK) << S5P_FIMV_DDELAY_VAL_SHIFT), S5P_FIMV_SI_CH0_DPB_CONF_CTRL); mfc_write(dev, ((S5P_FIMV_CH_SEQ_HEADER & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); return 0; } static void s5p_mfc_set_flush(struct s5p_mfc_ctx *ctx, int flush) { struct s5p_mfc_dev *dev = ctx->dev; unsigned int dpb; if (flush) dpb = mfc_read(dev, S5P_FIMV_SI_CH0_DPB_CONF_CTRL) | ( S5P_FIMV_DPB_FLUSH_MASK << S5P_FIMV_DPB_FLUSH_SHIFT); else dpb = mfc_read(dev, S5P_FIMV_SI_CH0_DPB_CONF_CTRL) & ~(S5P_FIMV_DPB_FLUSH_MASK << S5P_FIMV_DPB_FLUSH_SHIFT); mfc_write(dev, dpb, S5P_FIMV_SI_CH0_DPB_CONF_CTRL); } /* Decode a single frame */ static int s5p_mfc_decode_one_frame_v5(struct s5p_mfc_ctx *ctx, enum s5p_mfc_decode_arg last_frame) { struct s5p_mfc_dev *dev = ctx->dev; mfc_write(dev, ctx->dec_dst_flag, S5P_FIMV_SI_CH0_RELEASE_BUF); s5p_mfc_set_shared_buffer(ctx); s5p_mfc_set_flush(ctx, ctx->dpb_flush_flag); /* Issue different commands to instance basing on whether it * is the last frame or not. */ switch (last_frame) { case MFC_DEC_FRAME: mfc_write(dev, ((S5P_FIMV_CH_FRAME_START & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); break; case MFC_DEC_LAST_FRAME: mfc_write(dev, ((S5P_FIMV_CH_LAST_FRAME & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); break; case MFC_DEC_RES_CHANGE: mfc_write(dev, ((S5P_FIMV_CH_FRAME_START_REALLOC & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); break; } mfc_debug(2, "Decoding a usual frame\n"); return 0; } static int s5p_mfc_init_encode_v5(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; if (ctx->codec_mode == S5P_MFC_CODEC_H264_ENC) s5p_mfc_set_enc_params_h264(ctx); else if (ctx->codec_mode == S5P_MFC_CODEC_MPEG4_ENC) s5p_mfc_set_enc_params_mpeg4(ctx); else if (ctx->codec_mode == S5P_MFC_CODEC_H263_ENC) s5p_mfc_set_enc_params_h263(ctx); else { mfc_err("Unknown codec for encoding (%x)\n", ctx->codec_mode); return -EINVAL; } s5p_mfc_set_shared_buffer(ctx); mfc_write(dev, ((S5P_FIMV_CH_SEQ_HEADER << 16) & 0x70000) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); return 0; } /* Encode a single frame */ static int s5p_mfc_encode_one_frame_v5(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; int cmd; /* memory structure cur. frame */ if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12M) mfc_write(dev, 0, S5P_FIMV_ENC_MAP_FOR_CUR); else if (ctx->src_fmt->fourcc == V4L2_PIX_FMT_NV12MT) mfc_write(dev, 3, S5P_FIMV_ENC_MAP_FOR_CUR); s5p_mfc_set_shared_buffer(ctx); if (ctx->state == MFCINST_FINISHING) cmd = S5P_FIMV_CH_LAST_FRAME; else cmd = S5P_FIMV_CH_FRAME_START; mfc_write(dev, ((cmd & S5P_FIMV_CH_MASK) << S5P_FIMV_CH_SHIFT) | (ctx->inst_no), S5P_FIMV_SI_CH0_INST_ID); return 0; } static int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev) { unsigned long flags; int new_ctx; int cnt; spin_lock_irqsave(&dev->condlock, flags); new_ctx = (dev->curr_ctx + 1) % MFC_NUM_CONTEXTS; cnt = 0; while (!test_bit(new_ctx, &dev->ctx_work_bits)) { new_ctx = (new_ctx + 1) % MFC_NUM_CONTEXTS; if (++cnt > MFC_NUM_CONTEXTS) { /* No contexts to run */ spin_unlock_irqrestore(&dev->condlock, flags); return -EAGAIN; } } spin_unlock_irqrestore(&dev->condlock, flags); return new_ctx; } static void s5p_mfc_run_res_change(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); dev->curr_ctx = ctx->num; s5p_mfc_decode_one_frame_v5(ctx, MFC_DEC_RES_CHANGE); } static int s5p_mfc_run_dec_frame(struct s5p_mfc_ctx *ctx, int last_frame) { struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_buf *temp_vb; unsigned long flags; unsigned int index; if (ctx->state == MFCINST_FINISHING) { last_frame = MFC_DEC_LAST_FRAME; s5p_mfc_set_dec_stream_buffer_v5(ctx, 0, 0, 0); dev->curr_ctx = ctx->num; s5p_mfc_decode_one_frame_v5(ctx, last_frame); return 0; } spin_lock_irqsave(&dev->irqlock, flags); /* Frames are being decoded */ if (list_empty(&ctx->src_queue)) { mfc_debug(2, "No src buffers\n"); spin_unlock_irqrestore(&dev->irqlock, flags); return -EAGAIN; } /* Get the next source buffer */ temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); temp_vb->flags |= MFC_BUF_FLAG_USED; s5p_mfc_set_dec_stream_buffer_v5(ctx, vb2_dma_contig_plane_dma_addr(temp_vb->b, 0), ctx->consumed_stream, temp_vb->b->v4l2_planes[0].bytesused); spin_unlock_irqrestore(&dev->irqlock, flags); index = temp_vb->b->v4l2_buf.index; dev->curr_ctx = ctx->num; if (temp_vb->b->v4l2_planes[0].bytesused == 0) { last_frame = MFC_DEC_LAST_FRAME; mfc_debug(2, "Setting ctx->state to FINISHING\n"); ctx->state = MFCINST_FINISHING; } s5p_mfc_decode_one_frame_v5(ctx, last_frame); return 0; } static int s5p_mfc_run_enc_frame(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; unsigned long flags; struct s5p_mfc_buf *dst_mb; struct s5p_mfc_buf *src_mb; unsigned long src_y_addr, src_c_addr, dst_addr; unsigned int dst_size; spin_lock_irqsave(&dev->irqlock, flags); if (list_empty(&ctx->src_queue) && ctx->state != MFCINST_FINISHING) { mfc_debug(2, "no src buffers\n"); spin_unlock_irqrestore(&dev->irqlock, flags); return -EAGAIN; } if (list_empty(&ctx->dst_queue)) { mfc_debug(2, "no dst buffers\n"); spin_unlock_irqrestore(&dev->irqlock, flags); return -EAGAIN; } if (list_empty(&ctx->src_queue)) { /* send null frame */ s5p_mfc_set_enc_frame_buffer_v5(ctx, dev->bank2, dev->bank2); src_mb = NULL; } else { src_mb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); src_mb->flags |= MFC_BUF_FLAG_USED; if (src_mb->b->v4l2_planes[0].bytesused == 0) { /* send null frame */ s5p_mfc_set_enc_frame_buffer_v5(ctx, dev->bank2, dev->bank2); ctx->state = MFCINST_FINISHING; } else { src_y_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 0); src_c_addr = vb2_dma_contig_plane_dma_addr(src_mb->b, 1); s5p_mfc_set_enc_frame_buffer_v5(ctx, src_y_addr, src_c_addr); if (src_mb->flags & MFC_BUF_FLAG_EOS) ctx->state = MFCINST_FINISHING; } } dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); dst_mb->flags |= MFC_BUF_FLAG_USED; dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0); dst_size = vb2_plane_size(dst_mb->b, 0); s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); spin_unlock_irqrestore(&dev->irqlock, flags); dev->curr_ctx = ctx->num; mfc_debug(2, "encoding buffer with index=%d state=%d\n", src_mb ? src_mb->b->v4l2_buf.index : -1, ctx->state); s5p_mfc_encode_one_frame_v5(ctx); return 0; } static void s5p_mfc_run_init_dec(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; unsigned long flags; struct s5p_mfc_buf *temp_vb; /* Initializing decoding - parsing header */ spin_lock_irqsave(&dev->irqlock, flags); mfc_debug(2, "Preparing to init decoding\n"); temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); s5p_mfc_set_dec_desc_buffer(ctx); mfc_debug(2, "Header size: %d\n", temp_vb->b->v4l2_planes[0].bytesused); s5p_mfc_set_dec_stream_buffer_v5(ctx, vb2_dma_contig_plane_dma_addr(temp_vb->b, 0), 0, temp_vb->b->v4l2_planes[0].bytesused); spin_unlock_irqrestore(&dev->irqlock, flags); dev->curr_ctx = ctx->num; s5p_mfc_init_decode_v5(ctx); } static void s5p_mfc_run_init_enc(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; unsigned long flags; struct s5p_mfc_buf *dst_mb; unsigned long dst_addr; unsigned int dst_size; s5p_mfc_set_enc_ref_buffer_v5(ctx); spin_lock_irqsave(&dev->irqlock, flags); dst_mb = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); dst_addr = vb2_dma_contig_plane_dma_addr(dst_mb->b, 0); dst_size = vb2_plane_size(dst_mb->b, 0); s5p_mfc_set_enc_stream_buffer_v5(ctx, dst_addr, dst_size); spin_unlock_irqrestore(&dev->irqlock, flags); dev->curr_ctx = ctx->num; s5p_mfc_init_encode_v5(ctx); } static int s5p_mfc_run_init_dec_buffers(struct s5p_mfc_ctx *ctx) { struct s5p_mfc_dev *dev = ctx->dev; unsigned long flags; struct s5p_mfc_buf *temp_vb; int ret; /* * Header was parsed now starting processing * First set the output frame buffers */ if (ctx->capture_state != QUEUE_BUFS_MMAPED) { mfc_err("It seems that not all destionation buffers were " "mmaped\nMFC requires that all destination are mmaped " "before starting processing\n"); return -EAGAIN; } spin_lock_irqsave(&dev->irqlock, flags); if (list_empty(&ctx->src_queue)) { mfc_err("Header has been deallocated in the middle of" " initialization\n"); spin_unlock_irqrestore(&dev->irqlock, flags); return -EIO; } temp_vb = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); mfc_debug(2, "Header size: %d\n", temp_vb->b->v4l2_planes[0].bytesused); s5p_mfc_set_dec_stream_buffer_v5(ctx, vb2_dma_contig_plane_dma_addr(temp_vb->b, 0), 0, temp_vb->b->v4l2_planes[0].bytesused); spin_unlock_irqrestore(&dev->irqlock, flags); dev->curr_ctx = ctx->num; ret = s5p_mfc_set_dec_frame_buffer_v5(ctx); if (ret) { mfc_err("Failed to alloc frame mem\n"); ctx->state = MFCINST_ERROR; } return ret; } /* Try running an operation on hardware */ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev) { struct s5p_mfc_ctx *ctx; int new_ctx; unsigned int ret = 0; if (test_bit(0, &dev->enter_suspend)) { mfc_debug(1, "Entering suspend so do not schedule any jobs\n"); return; } /* Check whether hardware is not running */ if (test_and_set_bit(0, &dev->hw_lock) != 0) { /* This is perfectly ok, the scheduled ctx should wait */ mfc_debug(1, "Couldn't lock HW\n"); return; } /* Choose the context to run */ new_ctx = s5p_mfc_get_new_ctx(dev); if (new_ctx < 0) { /* No contexts to run */ if (test_and_clear_bit(0, &dev->hw_lock) == 0) { mfc_err("Failed to unlock hardware\n"); return; } mfc_debug(1, "No ctx is scheduled to be run\n"); return; } ctx = dev->ctx[new_ctx]; /* Got context to run in ctx */ /* * Last frame has already been sent to MFC. * Now obtaining frames from MFC buffer */ s5p_mfc_clock_on(); s5p_mfc_clean_ctx_int_flags(ctx); if (ctx->type == MFCINST_DECODER) { s5p_mfc_set_dec_desc_buffer(ctx); switch (ctx->state) { case MFCINST_FINISHING: s5p_mfc_run_dec_frame(ctx, MFC_DEC_LAST_FRAME); break; case MFCINST_RUNNING: ret = s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME); break; case MFCINST_INIT: ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, ctx); break; case MFCINST_RETURN_INST: ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, ctx); break; case MFCINST_GOT_INST: s5p_mfc_run_init_dec(ctx); break; case MFCINST_HEAD_PARSED: ret = s5p_mfc_run_init_dec_buffers(ctx); mfc_debug(1, "head parsed\n"); break; case MFCINST_RES_CHANGE_INIT: s5p_mfc_run_res_change(ctx); break; case MFCINST_RES_CHANGE_FLUSH: s5p_mfc_run_dec_frame(ctx, MFC_DEC_FRAME); break; case MFCINST_RES_CHANGE_END: mfc_debug(2, "Finished remaining frames after resolution change\n"); ctx->capture_state = QUEUE_FREE; mfc_debug(2, "Will re-init the codec\n"); s5p_mfc_run_init_dec(ctx); break; default: ret = -EAGAIN; } } else if (ctx->type == MFCINST_ENCODER) { switch (ctx->state) { case MFCINST_FINISHING: case MFCINST_RUNNING: ret = s5p_mfc_run_enc_frame(ctx); break; case MFCINST_INIT: ret = s5p_mfc_hw_call(dev->mfc_cmds, open_inst_cmd, ctx); break; case MFCINST_RETURN_INST: ret = s5p_mfc_hw_call(dev->mfc_cmds, close_inst_cmd, ctx); break; case MFCINST_GOT_INST: s5p_mfc_run_init_enc(ctx); break; default: ret = -EAGAIN; } } else { mfc_err("Invalid context type: %d\n", ctx->type); ret = -EAGAIN; } if (ret) { /* Free hardware lock */ if (test_and_clear_bit(0, &dev->hw_lock) == 0) mfc_err("Failed to unlock hardware\n"); /* This is in deed imporant, as no operation has been * scheduled, reduce the clock count as no one will * ever do this, because no interrupt related to this try_run * will ever come from hardware. */ s5p_mfc_clock_off(); } } static void s5p_mfc_cleanup_queue_v5(struct list_head *lh, struct vb2_queue *vq) { struct s5p_mfc_buf *b; int i; while (!list_empty(lh)) { b = list_entry(lh->next, struct s5p_mfc_buf, list); for (i = 0; i < b->b->num_planes; i++) vb2_set_plane_payload(b->b, i, 0); vb2_buffer_done(b->b, VB2_BUF_STATE_ERROR); list_del(&b->list); } } static void s5p_mfc_clear_int_flags_v5(struct s5p_mfc_dev *dev) { mfc_write(dev, 0, S5P_FIMV_RISC_HOST_INT); mfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD); mfc_write(dev, 0xffff, S5P_FIMV_SI_RTN_CHID); } static int s5p_mfc_get_dspl_y_adr_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_DISPLAY_Y_ADR) << MFC_OFFSET_SHIFT; } static int s5p_mfc_get_dec_y_adr_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_DECODE_Y_ADR) << MFC_OFFSET_SHIFT; } static int s5p_mfc_get_dspl_status_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_DISPLAY_STATUS); } static int s5p_mfc_get_dec_status_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_DECODE_STATUS); } static int s5p_mfc_get_dec_frame_type_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_DECODE_FRAME_TYPE) & S5P_FIMV_DECODE_FRAME_MASK; } static int s5p_mfc_get_disp_frame_type_v5(struct s5p_mfc_ctx *ctx) { return (s5p_mfc_read_info_v5(ctx, DISP_PIC_FRAME_TYPE) >> S5P_FIMV_SHARED_DISP_FRAME_TYPE_SHIFT) & S5P_FIMV_DECODE_FRAME_MASK; } static int s5p_mfc_get_consumed_stream_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_CONSUMED_BYTES); } static int s5p_mfc_get_int_reason_v5(struct s5p_mfc_dev *dev) { int reason; reason = mfc_read(dev, S5P_FIMV_RISC2HOST_CMD) & S5P_FIMV_RISC2HOST_CMD_MASK; switch (reason) { case S5P_FIMV_R2H_CMD_OPEN_INSTANCE_RET: reason = S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET; break; case S5P_FIMV_R2H_CMD_CLOSE_INSTANCE_RET: reason = S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET; break; case S5P_FIMV_R2H_CMD_SEQ_DONE_RET: reason = S5P_MFC_R2H_CMD_SEQ_DONE_RET; break; case S5P_FIMV_R2H_CMD_FRAME_DONE_RET: reason = S5P_MFC_R2H_CMD_FRAME_DONE_RET; break; case S5P_FIMV_R2H_CMD_SLICE_DONE_RET: reason = S5P_MFC_R2H_CMD_SLICE_DONE_RET; break; case S5P_FIMV_R2H_CMD_SYS_INIT_RET: reason = S5P_MFC_R2H_CMD_SYS_INIT_RET; break; case S5P_FIMV_R2H_CMD_FW_STATUS_RET: reason = S5P_MFC_R2H_CMD_FW_STATUS_RET; break; case S5P_FIMV_R2H_CMD_SLEEP_RET: reason = S5P_MFC_R2H_CMD_SLEEP_RET; break; case S5P_FIMV_R2H_CMD_WAKEUP_RET: reason = S5P_MFC_R2H_CMD_WAKEUP_RET; break; case S5P_FIMV_R2H_CMD_INIT_BUFFERS_RET: reason = S5P_MFC_R2H_CMD_INIT_BUFFERS_RET; break; case S5P_FIMV_R2H_CMD_ENC_COMPLETE_RET: reason = S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET; break; case S5P_FIMV_R2H_CMD_ERR_RET: reason = S5P_MFC_R2H_CMD_ERR_RET; break; default: reason = S5P_MFC_R2H_CMD_EMPTY; } return reason; } static int s5p_mfc_get_int_err_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_RISC2HOST_ARG2); } static int s5p_mfc_err_dec_v5(unsigned int err) { return (err & S5P_FIMV_ERR_DEC_MASK) >> S5P_FIMV_ERR_DEC_SHIFT; } static int s5p_mfc_err_dspl_v5(unsigned int err) { return (err & S5P_FIMV_ERR_DSPL_MASK) >> S5P_FIMV_ERR_DSPL_SHIFT; } static int s5p_mfc_get_img_width_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_HRESOL); } static int s5p_mfc_get_img_height_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_VRESOL); } static int s5p_mfc_get_dpb_count_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_SI_BUF_NUMBER); } static int s5p_mfc_get_mv_count_v5(struct s5p_mfc_dev *dev) { /* NOP */ return -1; } static int s5p_mfc_get_inst_no_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_RISC2HOST_ARG1); } static int s5p_mfc_get_enc_strm_size_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_ENC_SI_STRM_SIZE); } static int s5p_mfc_get_enc_slice_type_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_ENC_SI_SLICE_TYPE); } static int s5p_mfc_get_enc_dpb_count_v5(struct s5p_mfc_dev *dev) { return -1; } static int s5p_mfc_get_enc_pic_count_v5(struct s5p_mfc_dev *dev) { return mfc_read(dev, S5P_FIMV_ENC_SI_PIC_CNT); } static int s5p_mfc_get_sei_avail_status_v5(struct s5p_mfc_ctx *ctx) { return s5p_mfc_read_info_v5(ctx, FRAME_PACK_SEI_AVAIL); } static int s5p_mfc_get_mvc_num_views_v5(struct s5p_mfc_dev *dev) { return -1; } static int s5p_mfc_get_mvc_view_id_v5(struct s5p_mfc_dev *dev) { return -1; } static unsigned int s5p_mfc_get_pic_type_top_v5(struct s5p_mfc_ctx *ctx) { return s5p_mfc_read_info_v5(ctx, PIC_TIME_TOP); } static unsigned int s5p_mfc_get_pic_type_bot_v5(struct s5p_mfc_ctx *ctx) { return s5p_mfc_read_info_v5(ctx, PIC_TIME_BOT); } static unsigned int s5p_mfc_get_crop_info_h_v5(struct s5p_mfc_ctx *ctx) { return s5p_mfc_read_info_v5(ctx, CROP_INFO_H); } static unsigned int s5p_mfc_get_crop_info_v_v5(struct s5p_mfc_ctx *ctx) { return s5p_mfc_read_info_v5(ctx, CROP_INFO_V); } /* Initialize opr function pointers for MFC v5 */ static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = { .alloc_dec_temp_buffers = s5p_mfc_alloc_dec_temp_buffers_v5, .release_dec_desc_buffer = s5p_mfc_release_dec_desc_buffer_v5, .alloc_codec_buffers = s5p_mfc_alloc_codec_buffers_v5, .release_codec_buffers = s5p_mfc_release_codec_buffers_v5, .alloc_instance_buffer = s5p_mfc_alloc_instance_buffer_v5, .release_instance_buffer = s5p_mfc_release_instance_buffer_v5, .alloc_dev_context_buffer = s5p_mfc_alloc_dev_context_buffer_v5, .release_dev_context_buffer = s5p_mfc_release_dev_context_buffer_v5, .dec_calc_dpb_size = s5p_mfc_dec_calc_dpb_size_v5, .enc_calc_src_size = s5p_mfc_enc_calc_src_size_v5, .set_dec_stream_buffer = s5p_mfc_set_dec_stream_buffer_v5, .set_dec_frame_buffer = s5p_mfc_set_dec_frame_buffer_v5, .set_enc_stream_buffer = s5p_mfc_set_enc_stream_buffer_v5, .set_enc_frame_buffer = s5p_mfc_set_enc_frame_buffer_v5, .get_enc_frame_buffer = s5p_mfc_get_enc_frame_buffer_v5, .set_enc_ref_buffer = s5p_mfc_set_enc_ref_buffer_v5, .init_decode = s5p_mfc_init_decode_v5, .init_encode = s5p_mfc_init_encode_v5, .encode_one_frame = s5p_mfc_encode_one_frame_v5, .try_run = s5p_mfc_try_run_v5, .cleanup_queue = s5p_mfc_cleanup_queue_v5, .clear_int_flags = s5p_mfc_clear_int_flags_v5, .write_info = s5p_mfc_write_info_v5, .read_info = s5p_mfc_read_info_v5, .get_dspl_y_adr = s5p_mfc_get_dspl_y_adr_v5, .get_dec_y_adr = s5p_mfc_get_dec_y_adr_v5, .get_dspl_status = s5p_mfc_get_dspl_status_v5, .get_dec_status = s5p_mfc_get_dec_status_v5, .get_dec_frame_type = s5p_mfc_get_dec_frame_type_v5, .get_disp_frame_type = s5p_mfc_get_disp_frame_type_v5, .get_consumed_stream = s5p_mfc_get_consumed_stream_v5, .get_int_reason = s5p_mfc_get_int_reason_v5, .get_int_err = s5p_mfc_get_int_err_v5, .err_dec = s5p_mfc_err_dec_v5, .err_dspl = s5p_mfc_err_dspl_v5, .get_img_width = s5p_mfc_get_img_width_v5, .get_img_height = s5p_mfc_get_img_height_v5, .get_dpb_count = s5p_mfc_get_dpb_count_v5, .get_mv_count = s5p_mfc_get_mv_count_v5, .get_inst_no = s5p_mfc_get_inst_no_v5, .get_enc_strm_size = s5p_mfc_get_enc_strm_size_v5, .get_enc_slice_type = s5p_mfc_get_enc_slice_type_v5, .get_enc_dpb_count = s5p_mfc_get_enc_dpb_count_v5, .get_enc_pic_count = s5p_mfc_get_enc_pic_count_v5, .get_sei_avail_status = s5p_mfc_get_sei_avail_status_v5, .get_mvc_num_views = s5p_mfc_get_mvc_num_views_v5, .get_mvc_view_id = s5p_mfc_get_mvc_view_id_v5, .get_pic_type_top = s5p_mfc_get_pic_type_top_v5, .get_pic_type_bot = s5p_mfc_get_pic_type_bot_v5, .get_crop_info_h = s5p_mfc_get_crop_info_h_v5, .get_crop_info_v = s5p_mfc_get_crop_info_v_v5, }; struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v5(void) { return &s5p_mfc_ops_v5; }
abhijeet-dev/linux-samsung
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
C
gpl-2.0
54,280
[ 30522, 1013, 1008, 1008, 6853, 1013, 2865, 1013, 4132, 1013, 19102, 1013, 1049, 11329, 2629, 1013, 1055, 2629, 2361, 1035, 1049, 11329, 1035, 6728, 2099, 1035, 1058, 2629, 1012, 1039, 1008, 1008, 19102, 1049, 11329, 1006, 4800, 3853, 3642, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
exports.LOADING = "LOADING"; exports.ERROR = "ERROR"; exports.SUCCESS = "SUCCESS"; exports.FETCH = "FETCH"; exports.CREATE = "CREATE"; exports.UPDATE = "UPDATE"; exports.DELETE = "DELETE"; exports.SET_EDIT_MODE = "SET_EDIT_MODE"; exports.SET_ADD_MODE = "SET_ADD_MODE"; exports.CLOSE_FORM = "CLOSE_FORM"; exports.SET_PAGE = "SET_PAGE"
Em-Ant/fcc-options-app
client/src/constants/actionTypes/modelActionTypes.js
JavaScript
mit
334
[ 30522, 14338, 1012, 10578, 1027, 1000, 10578, 1000, 1025, 14338, 1012, 7561, 1027, 1000, 7561, 1000, 1025, 14338, 1012, 3112, 1027, 1000, 3112, 1000, 1025, 14338, 1012, 18584, 1027, 1000, 18584, 1000, 1025, 14338, 1012, 3443, 1027, 1000, 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...
<?php /** * @author Björn Schießle <bjoern@schiessle.org> * @author Joas Schilling <coding@schilljs.com> * @author phisch <git@philippschaffrath.de> * @author Roeland Jago Douma <rullzer@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2017, ownCloud GmbH * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ namespace OC\Share20; use OCP\Files\File; use OCP\Share\IShareProvider; use OC\Share20\Exception\InvalidShare; use OC\Share20\Exception\ProviderException; use OCP\Share\Exceptions\ShareNotFound; use OC\Share20\Exception\BackendError; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IGroup; use OCP\IGroupManager; use OCP\IUserManager; use OCP\Files\IRootFolder; use OCP\IDBConnection; use OCP\Files\Node; /** * Class DefaultShareProvider * * @package OC\Share20 */ class DefaultShareProvider implements IShareProvider { // Special share type for user modified group shares const SHARE_TYPE_USERGROUP = 2; /** @var IDBConnection */ private $dbConn; /** @var IUserManager */ private $userManager; /** @var IGroupManager */ private $groupManager; /** @var IRootFolder */ private $rootFolder; /** * DefaultShareProvider constructor. * * @param IDBConnection $connection * @param IUserManager $userManager * @param IGroupManager $groupManager * @param IRootFolder $rootFolder */ public function __construct( IDBConnection $connection, IUserManager $userManager, IGroupManager $groupManager, IRootFolder $rootFolder) { $this->dbConn = $connection; $this->userManager = $userManager; $this->groupManager = $groupManager; $this->rootFolder = $rootFolder; } /** * Return the identifier of this provider. * * @return string Containing only [a-zA-Z0-9] */ public function identifier() { return 'ocinternal'; } /** * Share a path * * @param \OCP\Share\IShare $share * @return \OCP\Share\IShare The share object * @throws ShareNotFound * @throws InvalidArgumentException if the share validation failed * @throws \Exception */ public function create(\OCP\Share\IShare $share) { $this->validate($share); $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share'); $qb->setValue('share_type', $qb->createNamedParameter($share->getShareType())); if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { //Set the UID of the user we share with $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith())); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { //Set the GID of the group we share with $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith())); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { //Set the token of the share $qb->setValue('token', $qb->createNamedParameter($share->getToken())); //If a password is set store it if ($share->getPassword() !== null) { $qb->setValue('share_with', $qb->createNamedParameter($share->getPassword())); } //If an expiration date is set store it if ($share->getExpirationDate() !== null) { $qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime')); } if (method_exists($share, 'getParent')) { $qb->setValue('parent', $qb->createNamedParameter($share->getParent())); } // Set user-defined name $qb->setValue('share_name', $qb->createNamedParameter($share->getName())); } else { throw new \Exception('invalid share type!'); } // Set what is shares $qb->setValue('item_type', $qb->createParameter('itemType')); if ($share->getNode() instanceof \OCP\Files\File) { $qb->setParameter('itemType', 'file'); } else { $qb->setParameter('itemType', 'folder'); } // Set the file id $qb->setValue('item_source', $qb->createNamedParameter($share->getNode()->getId())); $qb->setValue('file_source', $qb->createNamedParameter($share->getNode()->getId())); // set the permissions $qb->setValue('permissions', $qb->createNamedParameter($share->getPermissions())); // Set who created this share $qb->setValue('uid_initiator', $qb->createNamedParameter($share->getSharedBy())); // Set who is the owner of this file/folder (and this the owner of the share) $qb->setValue('uid_owner', $qb->createNamedParameter($share->getShareOwner())); // Set the file target $qb->setValue('file_target', $qb->createNamedParameter($share->getTarget())); // Set the time this share was created $qb->setValue('stime', $qb->createNamedParameter(time())); // insert the data and fetch the id of the share $this->dbConn->beginTransaction(); $qb->execute(); $id = $this->dbConn->lastInsertId('*PREFIX*share'); // Now fetch the inserted share and create a complete share object $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') ->from('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); $cursor = $qb->execute(); $data = $cursor->fetch(); $this->dbConn->commit(); $cursor->closeCursor(); if ($data === false) { throw new ShareNotFound(); } $share = $this->createShare($data); return $share; } /** * Update a share * * @param \OCP\Share\IShare $share * @return \OCP\Share\IShare The share object * @throws InvalidArgumentException if the share validation failed */ public function update(\OCP\Share\IShare $share) { $this->validate($share); if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { /* * We allow updating the recipient on user shares. */ $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->set('share_with', $qb->createNamedParameter($share->getSharedWith())) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) ->execute(); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) ->execute(); /* * Update all user defined group shares */ $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) ->execute(); /* * Now update the permissions for all children that have not set it to 0 */ $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0))) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->execute(); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->set('share_with', $qb->createNamedParameter($share->getPassword())) ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('token', $qb->createNamedParameter($share->getToken())) ->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE)) ->set('share_name', $qb->createNamedParameter($share->getName())) ->execute(); } return $share; } /** * Get all children of this share * FIXME: remove once https://github.com/owncloud/core/pull/21660 is in * * @param \OCP\Share\IShare $parent * @return \OCP\Share\IShare[] */ public function getChildren(\OCP\Share\IShare $parent) { $children = []; $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') ->from('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($parent->getId()))) ->andWhere( $qb->expr()->in( 'share_type', $qb->createNamedParameter([ \OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK, ], IQueryBuilder::PARAM_INT_ARRAY) ) ) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->orderBy('id'); $cursor = $qb->execute(); while($data = $cursor->fetch()) { $children[] = $this->createShare($data); } $cursor->closeCursor(); return $children; } /** * Delete a share * * @param \OCP\Share\IShare $share */ public function delete(\OCP\Share\IShare $share) { $qb = $this->dbConn->getQueryBuilder(); $qb->delete('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))); /* * If the share is a group share delete all possible * user defined groups shares. */ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { $qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))); } $qb->execute(); } /** * Unshare a share from the recipient. If this is a group share * this means we need a special entry in the share db. * * @param \OCP\Share\IShare $share * @param string $recipient UserId of recipient * @throws BackendError * @throws ProviderException */ public function deleteFromSelf(\OCP\Share\IShare $share, $recipient) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { $group = $this->groupManager->get($share->getSharedWith()); $user = $this->userManager->get($recipient); if (is_null($group)) { throw new ProviderException('Group "' . $share->getSharedWith() . '" does not exist'); } if (!$group->inGroup($user)) { throw new ProviderException('Recipient not in receiving group'); } // Try to fetch user specific share $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('*') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->execute(); $data = $stmt->fetch(); /* * Check if there already is a user specific group share. * If there is update it (if required). */ if ($data === false) { $qb = $this->dbConn->getQueryBuilder(); $type = $share->getNode() instanceof \OCP\Files\File ? 'file' : 'folder'; //Insert new share $qb->insert('share') ->values([ 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP), 'share_with' => $qb->createNamedParameter($recipient), 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), 'parent' => $qb->createNamedParameter($share->getId()), 'item_type' => $qb->createNamedParameter($type), 'item_source' => $qb->createNamedParameter($share->getNode()->getId()), 'file_source' => $qb->createNamedParameter($share->getNode()->getId()), 'file_target' => $qb->createNamedParameter($share->getTarget()), 'permissions' => $qb->createNamedParameter(0), 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()), ])->execute(); } else if ($data['permissions'] !== 0) { // Update existing usergroup share $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->set('permissions', $qb->createNamedParameter(0)) ->where($qb->expr()->eq('id', $qb->createNamedParameter($data['id']))) ->execute(); } } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { if ($share->getSharedWith() !== $recipient) { throw new ProviderException('Recipient does not match'); } // We can just delete user and link shares $this->delete($share); } else { throw new ProviderException('Invalid shareType'); } } /** * @inheritdoc */ public function move(\OCP\Share\IShare $share, $recipient) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { // Just update the target $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->set('file_target', $qb->createNamedParameter($share->getTarget())) ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->execute(); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { // Check if there is a usergroup share $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('id') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->setMaxResults(1) ->execute(); $data = $stmt->fetch(); $stmt->closeCursor(); if ($data === false) { // No usergroup share yet. Create one. $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share') ->values([ 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP), 'share_with' => $qb->createNamedParameter($recipient), 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), 'parent' => $qb->createNamedParameter($share->getId()), 'item_type' => $qb->createNamedParameter($share->getNode() instanceof File ? 'file' : 'folder'), 'item_source' => $qb->createNamedParameter($share->getNode()->getId()), 'file_source' => $qb->createNamedParameter($share->getNode()->getId()), 'file_target' => $qb->createNamedParameter($share->getTarget()), 'permissions' => $qb->createNamedParameter($share->getPermissions()), 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()), ])->execute(); } else { // Already a usergroup share. Update it. $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->set('file_target', $qb->createNamedParameter($share->getTarget())) ->where($qb->expr()->eq('id', $qb->createNamedParameter($data['id']))) ->execute(); } } return $share; } /** * @inheritdoc */ public function getAllSharesBy($userId, $shareTypes, $nodeIDs, $reshares) { $shares = []; $qb = $this->dbConn->getQueryBuilder(); $nodeIdsChunks = array_chunk($nodeIDs, 100); foreach ($nodeIdsChunks as $nodeIdsChunk) { $qb->select('*') ->from('share') ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); $orX = $qb->expr()->orX(); foreach ($shareTypes as $shareType) { $orX->add($qb->expr()->eq('share_type', $qb->createNamedParameter($shareType))); } $qb->andWhere($orX); /** * Reshares for this user are shares where they are the owner. */ if ($reshares === false) { $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))); } else { $qb->andWhere( $qb->expr()->orX( $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) ) ); } $qb->andWhere($qb->expr()->in('file_source', $qb->createParameter('file_source_ids'))); $qb->setParameter('file_source_ids', $nodeIdsChunk, IQueryBuilder::PARAM_INT_ARRAY); $qb->orderBy('id'); $cursor = $qb->execute(); while($data = $cursor->fetch()) { $shares[] = $this->createShare($data); } $cursor->closeCursor(); } return $shares; } /** * @inheritdoc */ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') ->from('share') ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter($shareType))); /** * Reshares for this user are shares where they are the owner. */ if ($reshares === false) { $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))); } else { $qb->andWhere( $qb->expr()->orX( $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) ) ); } if ($node !== null) { $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); } if ($limit !== -1) { $qb->setMaxResults($limit); } $qb->setFirstResult($offset); $qb->orderBy('id'); $cursor = $qb->execute(); $shares = []; while($data = $cursor->fetch()) { $shares[] = $this->createShare($data); } $cursor->closeCursor(); return $shares; } /** * @inheritdoc */ public function getShareById($id, $recipientId = null) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') ->from('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) ->andWhere( $qb->expr()->in( 'share_type', $qb->createNamedParameter([ \OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK, ], IQueryBuilder::PARAM_INT_ARRAY) ) ) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); $cursor = $qb->execute(); $data = $cursor->fetch(); $cursor->closeCursor(); if ($data === false) { throw new ShareNotFound(); } try { $share = $this->createShare($data); } catch (InvalidShare $e) { throw new ShareNotFound(); } // If the recipient is set for a group share resolve to that user if ($recipientId !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { $resolvedShares = $this->resolveGroupShares([$share], $recipientId); if (count($resolvedShares) === 1){ // If we pass to resolveGroupShares() an with one element, // we expect to receive exactly one element, otherwise it is error $share = $resolvedShares[0]; } else { throw new ProviderException("ResolveGroupShares() returned wrong result"); } } return $share; } /** * Get shares for a given path * * @param \OCP\Files\Node $path * @return \OCP\Share\IShare[] */ public function getSharesByPath(Node $path) { $qb = $this->dbConn->getQueryBuilder(); $cursor = $qb->select('*') ->from('share') ->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId()))) ->andWhere( $qb->expr()->orX( $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)), $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)) ) ) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->execute(); $shares = []; while($data = $cursor->fetch()) { $shares[] = $this->createShare($data); } $cursor->closeCursor(); return $shares; } /** * Returns whether the given database result can be interpreted as * a share with accessible file (not trashed, not deleted) */ private function isAccessibleResult($data) { // exclude shares leading to deleted file entries if ($data['fileid'] === null) { return false; } // exclude shares leading to trashbin on home storages $pathSections = explode('/', $data['path'], 2); // FIXME: would not detect rare md5'd home storage case properly if ($pathSections[0] !== 'files' && explode(':', $data['storage_string_id'], 2)[0] === 'home') { return false; } return true; } /** * @inheritdoc */ public function getSharedWith($userId, $shareType, $node, $limit, $offset) { /** @var Share[] $shares */ $shares = []; if ($shareType === \OCP\Share::SHARE_TYPE_USER) { //Get shares directly with this user $qb = $this->dbConn->getQueryBuilder(); $qb->select('s.*', 'f.fileid', 'f.path') ->selectAlias('st.id', 'storage_string_id') ->from('share', 's') ->leftJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')) ->leftJoin('f', 'storages', 'st', $qb->expr()->eq('f.storage', 'st.numeric_id')); // Order by id $qb->orderBy('s.id'); // Set limit and offset if ($limit !== -1) { $qb->setMaxResults($limit); } $qb->setFirstResult($offset); $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); // Filter by node if provided if ($node !== null) { $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); } $cursor = $qb->execute(); while($data = $cursor->fetch()) { if ($this->isAccessibleResult($data)) { $shares[] = $this->createShare($data); } } $cursor->closeCursor(); } else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { $user = $this->userManager->get($userId); $allGroups = $this->groupManager->getUserGroups($user, 'sharing'); /** @var Share[] $shares2 */ $shares2 = []; $start = 0; while(true) { $groups = array_slice($allGroups, $start, 100); $start += 100; if ($groups === []) { break; } $qb = $this->dbConn->getQueryBuilder(); $qb->select('s.*', 'f.fileid', 'f.path') ->selectAlias('st.id', 'storage_string_id') ->from('share', 's') ->leftJoin('s', 'filecache', 'f', $qb->expr()->eq('s.file_source', 'f.fileid')) ->leftJoin('f', 'storages', 'st', $qb->expr()->eq('f.storage', 'st.numeric_id')) ->orderBy('s.id') ->setFirstResult(0); if ($limit !== -1) { $qb->setMaxResults($limit - count($shares)); } // Filter by node if provided if ($node !== null) { $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); } $groups = array_map(function(IGroup $group) { return $group->getGID(); }, $groups); $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) ->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter( $groups, IQueryBuilder::PARAM_STR_ARRAY ))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); $cursor = $qb->execute(); while($data = $cursor->fetch()) { if ($offset > 0) { $offset--; continue; } if ($this->isAccessibleResult($data)) { $shares2[] = $this->createShare($data); } } $cursor->closeCursor(); } //Resolve all group shares to user specific shares if (!empty($shares2)) { $resolvedGroupShares = $this->resolveGroupShares($shares2, $userId); $shares = array_merge($shares, $resolvedGroupShares); } } else { throw new BackendError('Invalid backend'); } return $shares; } /** * Get a share by token * * @param string $token * @return \OCP\Share\IShare * @throws ShareNotFound */ public function getShareByToken($token) { $qb = $this->dbConn->getQueryBuilder(); $cursor = $qb->select('*') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))) ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )) ->execute(); $data = $cursor->fetch(); if ($data === false) { throw new ShareNotFound(); } try { $share = $this->createShare($data); } catch (InvalidShare $e) { throw new ShareNotFound(); } return $share; } /** * Create a share object from an database row * * @param mixed[] $data * @return \OCP\Share\IShare * @throws InvalidShare */ private function createShare($data) { $share = new Share($this->rootFolder, $this->userManager); $share->setId((int)$data['id']) ->setShareType((int)$data['share_type']) ->setPermissions((int)$data['permissions']) ->setTarget($data['file_target']) ->setMailSend((bool)$data['mail_send']); $shareTime = new \DateTime(); $shareTime->setTimestamp((int)$data['stime']); $share->setShareTime($shareTime); if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { $share->setSharedWith($data['share_with']); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { $share->setSharedWith($data['share_with']); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { $share->setPassword($data['share_with']); $share->setToken($data['token']); } $share->setSharedBy($data['uid_initiator']); $share->setShareOwner($data['uid_owner']); $share->setNodeId((int)$data['file_source']); $share->setNodeType($data['item_type']); $share->setName($data['share_name']); if ($data['expiration'] !== null) { $expiration = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expiration']); $share->setExpirationDate($expiration); } $share->setProviderId($this->identifier()); return $share; } /** * Will return two maps: * - $chunkedShareIds responsible to split shareIds into chunks containing 100 elements * e.g. $chunkedShareIds { { "4", "52", "54",... }[100], { .. }[2] }[2] * * - $shareIdToShareMap responsible to split shareIds into chunks containing 100 elements * e.g. $shareIdToShareMap { "4" => IShare, "52" => IShare, "54" => IShare, ... }[102] * * @param \OCP\Share\IShare[] $shares * @return array $chunkedSharesToMaps e.g { $chunkedShareIds, $shareIdToShareMap }[2] */ private function chunkSharesToMaps($shares) { $chunkedShareIds = []; $shareIdToShareMap = []; $chunkId = 0; $shareNo = 0; foreach($shares as $share) { // Map unique shareIds to IShare $shareId = $share->getId(); $shareIdToShareMap[$shareId] = $share; // Chunk shareId array if ($shareNo >= 100) { // If we have over 100 shares in the array, start next chunk $shareNo = 0; $chunkId++; } else { // Increase number of shares in current array $shareNo++; } $chunkedShareIds[$chunkId][] = $shareId; } $chunkedSharesToMaps = array($chunkedShareIds, $shareIdToShareMap); return $chunkedSharesToMaps; } /** * Resolve a group shares to a user specific share. * Thus if the user moved their group share make sure this is properly reflected here, * If $shares array contains exactly 2 elements, where * only 1 will be changed(resolved), it returns exactly 2 elements, containing the resolved one. * * @param \OCP\Share\IShare[] $shares e.g. { IShare, IShare }[2] * @param string $userId * @return \OCP\Share\IShare[] $resolvedShares * @throws ProviderException */ private function resolveGroupShares($shares, $userId) { $qb = $this->dbConn->getQueryBuilder(); list($chunkedShareIds, $shareIdToShareMap) = $this->chunkSharesToMaps($shares); foreach($chunkedShareIds as $shareIdsChunk) { $qb->select('*') ->from('share') ->where($qb->expr()->in('parent', $qb->createNamedParameter( $shareIdsChunk, IQueryBuilder::PARAM_STR_ARRAY ))) ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) )); $stmt = $qb->execute(); // Resolve $shareIdToShareMap array containing group shares $shareParents = []; while($data = $stmt->fetch()) { // Get share parent $shareParent = $data['parent']; // Ensure uniquenes of parents if (!isset($shareParents[$shareParent])) { $shareParents[] = $shareParent; } else { throw new ProviderException('Parent of share should be unique'); } // Resolve only shares contained in the map. // This will ensure that we return the same amount of shares in the input as in the output // If $shareParent is contained in $shareIdToShareMap, it means that needs resolving if (isset($shareIdToShareMap[$shareParent])) { $share = $shareIdToShareMap[$shareParent]; $share->setPermissions(intval($data['permissions'])); $share->setTarget($data['file_target']); } } $stmt->closeCursor(); } $resolvedShares = array_values($shareIdToShareMap); return $resolvedShares; } /** * A user is deleted from the system * So clean up the relevant shares. * * @param string $uid * @param int $shareType */ public function userDeleted($uid, $shareType) { $qb = $this->dbConn->getQueryBuilder(); $qb->delete('share'); if ($shareType === \OCP\Share::SHARE_TYPE_USER) { /* * Delete all user shares that are owned by this user * or that are received by this user */ $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER))); $qb->andWhere( $qb->expr()->orX( $qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)), $qb->expr()->eq('share_with', $qb->createNamedParameter($uid)) ) ); } else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { /* * Delete all group shares that are owned by this user * Or special user group shares that are received by this user */ $qb->where( $qb->expr()->andX( $qb->expr()->orX( $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)), $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)) ), $qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)) ) ); $qb->orWhere( $qb->expr()->andX( $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)), $qb->expr()->eq('share_with', $qb->createNamedParameter($uid)) ) ); } else if ($shareType === \OCP\Share::SHARE_TYPE_LINK) { /* * Delete all link shares owned by this user. * And all link shares initiated by this user (until #22327 is in) */ $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))); $qb->andWhere( $qb->expr()->orX( $qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)), $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($uid)) ) ); } $qb->execute(); } /** * Delete all shares received by this group. As well as any custom group * shares for group members. * * @param string $gid */ public function groupDeleted($gid) { /* * First delete all custom group shares for group members */ $qb = $this->dbConn->getQueryBuilder(); $qb->select('id') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); $cursor = $qb->execute(); $ids = []; while($row = $cursor->fetch()) { $ids[] = (int)$row['id']; } $cursor->closeCursor(); if (!empty($ids)) { $chunks = array_chunk($ids, 100); foreach ($chunks as $chunk) { $qb->delete('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); $qb->execute(); } } /* * Now delete all the group shares */ $qb = $this->dbConn->getQueryBuilder(); $qb->delete('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); $qb->execute(); } /** * Delete custom group shares to this group for this user * * @param string $uid * @param string $gid */ public function userDeletedFromGroup($uid, $gid) { /* * Get all group shares */ $qb = $this->dbConn->getQueryBuilder(); $qb->select('id') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid))); $cursor = $qb->execute(); $ids = []; while($row = $cursor->fetch()) { $ids[] = (int)$row['id']; } $cursor->closeCursor(); if (!empty($ids)) { $chunks = array_chunk($ids, 100); foreach ($chunks as $chunk) { /* * Delete all special shares wit this users for the found group shares */ $qb->delete('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($uid))) ->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); $qb->execute(); } } } /** * Check whether the share object fits the expectations of this provider * * @param IShare $share share * * @throws InvalidArgumentException if the share validation failed */ private function validate($share) { if (!is_null($share->getName()) && strlen($share->getName()) > 64) { throw new \InvalidArgumentException('Share name cannot be more than 64 characters'); } // TODO: add more early validation for fields instead of relying on the DB } }
jacklicn/owncloud
lib/private/Share20/DefaultShareProvider.php
PHP
agpl-3.0
36,376
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 1030, 3166, 24998, 8040, 4048, 2063, 19310, 2571, 1026, 1038, 5558, 11795, 1030, 8040, 4048, 7971, 2571, 1012, 8917, 1028, 1008, 1030, 3166, 8183, 3022, 8040, 7100, 2075, 1026, 16861, 1030, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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.wangsong.activiti.controller; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.task.Task; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.wangsong.activiti.model.Leave; import com.wangsong.activiti.service.ActivitiService; import com.wangsong.activiti.service.LeaveService; import com.wangsong.common.controller.BaseController; import com.wangsong.common.model.Page; import com.wangsong.common.util.ByteToInputStream; import com.wangsong.common.util.UserUtil; import com.wangsong.system.model.User; /** * 字典controller * @author ty * @date 2015年1月13日 */ @Controller @RequestMapping("activiti/bpm") public class BPMController extends BaseController{ @Autowired private ActivitiService workflowService; /** * 默认页面 */ @RequestMapping(value="/toList") public String list() { return "activiti/bpm/list"; } /** * 获取字典json */ @RequestMapping(value="/list") @ResponseBody public Map<String, Object> dictList(HttpServletRequest request) { Page<Map<String, Object>> page = getPage(request); page= workflowService.findTaskListByUserId(page,((User)UserUtil.getUser()).getId().toString()); return getEasyUIData(page); } @RequestMapping(value="/commentList") @ResponseBody public Map<String, Object> list(HttpServletRequest request,String businessKey) { Page<Map<String, Object>> page = getPage(request); List<Map<String, Object>> commentList =workflowService.findCommentByBusinessKey(businessKey); page.setResult(commentList); page.setTotalCount(commentList.size()); return getEasyUIData(page); } /** * 修改字典跳转 * * @param id * @param model * @return */ @RequestMapping(value = "/toUpdate") public String updateForm(String id, Model model) { String url = workflowService.findTaskFormKeyByTaskId(id); String sid = workflowService.findIdByTaskId(id); return "redirect:"+url+"?id="+sid+"&display=yes"; } @RequestMapping(value = "/toViewImage") public String toViewImage(String taskId,Model model) { ProcessDefinition pd = workflowService.findProcessDefinitionByTaskId(taskId); model.addAttribute("deploymentId", pd.getDeploymentId()); model.addAttribute("diagramResourceName",pd.getDiagramResourceName()); Map<String, Object> map = workflowService.findCoordingByTaskId(taskId); model.addAttribute("acs", map); return "activiti/bpm/viewImage"; } @RequestMapping(value="/viewImage") public void viewImage(String deploymentId,String diagramResourceName,HttpServletResponse response) throws Exception{ //2:获取资源文件表(act_ge_bytearray)中资源图片输入流InputStream byte[] bt= workflowService.findImageInputStream(deploymentId,diagramResourceName); InputStream in = ByteToInputStream.byte2Input(bt); //3:从response对象获取输出流 OutputStream out = response.getOutputStream(); //4:将输入流中的数据读取出来,写到输出流中 for(int b=-1;(b=in.read())!=-1;){ out.write(b); } out.close(); in.close(); //将图写到页面上,用输出流写 } }
chenyiming/learn
dubbo-app/dubbo-app-web/src/main/java/com/wangsong/activiti/controller/BPMController.java
Java
mit
3,925
[ 30522, 7427, 4012, 1012, 7418, 3385, 2290, 1012, 2552, 12848, 25090, 1012, 11486, 1025, 12324, 9262, 1012, 22834, 1012, 20407, 25379, 1025, 12324, 9262, 1012, 22834, 1012, 27852, 25379, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 9140, 9863, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 The go-ethereum Authors // This file is part of the go-ethereum library. // // The go-ethereum library 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. // // The go-ethereum library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. package types import ( "bytes" "fmt" "io" "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/rlp" ) type Receipt struct { PostState []byte CumulativeGasUsed *big.Int Bloom Bloom TxHash common.Hash ContractAddress common.Address logs state.Logs GasUsed *big.Int } func NewReceipt(root []byte, cumulativeGasUsed *big.Int) *Receipt { return &Receipt{PostState: common.CopyBytes(root), CumulativeGasUsed: new(big.Int).Set(cumulativeGasUsed)} } func (self *Receipt) SetLogs(logs state.Logs) { self.logs = logs } func (self *Receipt) Logs() state.Logs { return self.logs } func (self *Receipt) EncodeRLP(w io.Writer) error { return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs}) } func (self *Receipt) DecodeRLP(s *rlp.Stream) error { var r struct { PostState []byte CumulativeGasUsed *big.Int Bloom Bloom TxHash common.Hash ContractAddress common.Address Logs state.Logs GasUsed *big.Int } if err := s.Decode(&r); err != nil { return err } self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, self.logs, self.GasUsed = r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, r.Logs, r.GasUsed return nil } type ReceiptForStorage Receipt func (self *ReceiptForStorage) EncodeRLP(w io.Writer) error { storageLogs := make([]*state.LogForStorage, len(self.logs)) for i, log := range self.logs { storageLogs[i] = (*state.LogForStorage)(log) } return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, storageLogs, self.GasUsed}) } func (self *Receipt) RlpEncode() []byte { bytes, err := rlp.EncodeToBytes(self) if err != nil { fmt.Println("TMP -- RECEIPT ENCODE ERROR", err) } return bytes } func (self *Receipt) Cmp(other *Receipt) bool { if bytes.Compare(self.PostState, other.PostState) != 0 { return false } return true } func (self *Receipt) String() string { return fmt.Sprintf("receipt{med=%x cgas=%v bloom=%x logs=%v}", self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs) } type Receipts []*Receipt func (self Receipts) RlpEncode() []byte { bytes, err := rlp.EncodeToBytes(self) if err != nil { fmt.Println("TMP -- RECEIPTS ENCODE ERROR", err) } return bytes } func (self Receipts) Len() int { return len(self) } func (self Receipts) GetRlp(i int) []byte { return common.Rlp(self[i]) }
crazyquark/go-ethereum
core/types/receipt.go
GO
gpl-3.0
3,431
[ 30522, 1013, 1013, 9385, 2297, 1996, 2175, 1011, 28855, 14820, 6048, 1013, 1013, 2023, 5371, 2003, 2112, 1997, 1996, 2175, 1011, 28855, 14820, 3075, 1012, 1013, 1013, 1013, 1013, 1996, 2175, 1011, 28855, 14820, 3075, 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...
/* * Copyright 2009 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.template.soy; import com.google.inject.AbstractModule; import com.google.inject.assistedinject.FactoryModuleBuilder; import com.google.template.soy.SoyFileSet.SoyFileSetFactory; import com.google.template.soy.basicdirectives.BasicDirectivesModule; import com.google.template.soy.basicfunctions.BasicFunctionsModule; import com.google.template.soy.bididirectives.BidiDirectivesModule; import com.google.template.soy.bidifunctions.BidiFunctionsModule; import com.google.template.soy.i18ndirectives.I18nDirectivesModule; import com.google.template.soy.javasrc.internal.JavaSrcModule; import com.google.template.soy.jssrc.internal.JsSrcModule; import com.google.template.soy.parsepasses.CheckFunctionCallsVisitor; import com.google.template.soy.parsepasses.PerformAutoescapeVisitor; import com.google.template.soy.parsepasses.contextautoesc.ContextualAutoescaper; import com.google.template.soy.shared.internal.SharedModule; import com.google.template.soy.tofu.internal.TofuModule; /** * Guice module for Soy's programmatic interface. * * @author Kai Huang */ public class SoyModule extends AbstractModule { @Override protected void configure() { // Install requisite modules. install(new SharedModule()); install(new TofuModule()); install(new JsSrcModule()); install(new JavaSrcModule()); // Bindings for when explicit dependencies are required. bind(CheckFunctionCallsVisitor.class); bind(ContextualAutoescaper.class); bind(PerformAutoescapeVisitor.class); // Install default directive and function modules. install(new BasicDirectivesModule()); install(new BidiDirectivesModule()); install(new BasicFunctionsModule()); install(new BidiFunctionsModule()); install(new I18nDirectivesModule()); // Bind providers of factories (created via assisted inject). install(new FactoryModuleBuilder().build(SoyFileSetFactory.class)); // The static injection of SoyFileSetFactory into SoyFileSet.Builder is what allows the Soy // compiler to use Guice even if the user of the Soy API does not use Guice. requestStaticInjection(SoyFileSet.Builder.class); // Mark the fact that Guice has been initialized. requestStaticInjection(GuiceInitializer.class); } }
core9/closure-templates
src/impl/java/com/google/template/soy/SoyModule.java
Java
apache-2.0
2,866
[ 30522, 1013, 1008, 1008, 9385, 2268, 8224, 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, 3272, 1999, 12646, 2007, 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...
/* ** 2004 May 22 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains macros and a little bit of code that is common to ** all of the platform-specific files (os_*.c) and is #included into those ** files. ** ** This file should be #included by the os_*.c files only. It is not a ** general purpose header file. */ /* ** At least two bugs have slipped in because we changed the MEMORY_DEBUG ** macro to SQLITE_DEBUG and some older makefiles have not yet made the ** switch. The following code should catch this problem at compile-time. */ #ifdef MEMORY_DEBUG # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." #endif /* * When testing, this global variable stores the location of the * pending-byte in the database file. */ #ifdef SQLITE_TEST unsigned int sqlite3_pending_byte = 0x40000000; #endif #ifdef SQLITE_DEBUG int sqlite3_os_trace = 0; #define OSTRACE1(X) if( sqlite3_os_trace ) sqlite3DebugPrintf(X) #define OSTRACE2(X,Y) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y) #define OSTRACE3(X,Y,Z) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z) #define OSTRACE4(X,Y,Z,A) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A) #define OSTRACE5(X,Y,Z,A,B) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A,B) #define OSTRACE6(X,Y,Z,A,B,C) \ if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C) #define OSTRACE7(X,Y,Z,A,B,C,D) \ if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D) #else #define OSTRACE1(X) #define OSTRACE2(X,Y) #define OSTRACE3(X,Y,Z) #define OSTRACE4(X,Y,Z,A) #define OSTRACE5(X,Y,Z,A,B) #define OSTRACE6(X,Y,Z,A,B,C) #define OSTRACE7(X,Y,Z,A,B,C,D) #endif /* ** Macros for performance tracing. Normally turned off. Only works ** on i486 hardware. */ #ifdef SQLITE_PERFORMANCE_TRACE __inline__ unsigned long long int hwtime(void){ unsigned long long int x; __asm__("rdtsc\n\t" "mov %%edx, %%ecx\n\t" :"=A" (x)); return x; } static unsigned long long int g_start; static unsigned int elapse; #define TIMER_START g_start=hwtime() #define TIMER_END elapse=hwtime()-g_start #define TIMER_ELAPSED elapse #else #define TIMER_START #define TIMER_END #define TIMER_ELAPSED 0 #endif /* ** If we compile with the SQLITE_TEST macro set, then the following block ** of code will give us the ability to simulate a disk I/O error. This ** is used for testing the I/O recovery logic. */ #ifdef SQLITE_TEST int sqlite3_io_error_hit = 0; int sqlite3_io_error_pending = 0; int sqlite3_io_error_persist = 0; int sqlite3_diskfull_pending = 0; int sqlite3_diskfull = 0; #define SimulateIOError(CODE) \ if( sqlite3_io_error_pending || sqlite3_io_error_hit ) \ if( sqlite3_io_error_pending-- == 1 \ || (sqlite3_io_error_persist && sqlite3_io_error_hit) ) \ { local_ioerr(); CODE; } static void local_ioerr(){ IOTRACE(("IOERR\n")); sqlite3_io_error_hit = 1; } #define SimulateDiskfullError(CODE) \ if( sqlite3_diskfull_pending ){ \ if( sqlite3_diskfull_pending == 1 ){ \ local_ioerr(); \ sqlite3_diskfull = 1; \ sqlite3_io_error_hit = 1; \ CODE; \ }else{ \ sqlite3_diskfull_pending--; \ } \ } #else #define SimulateIOError(A) #define SimulateDiskfullError(A) #endif /* ** When testing, keep a count of the number of open files. */ #ifdef SQLITE_TEST int sqlite3_open_file_count = 0; #define OpenCounter(X) sqlite3_open_file_count+=(X) #else #define OpenCounter(X) #endif /* ** sqlite3GenericMalloc ** sqlite3GenericRealloc ** sqlite3GenericOsFree ** sqlite3GenericAllocationSize ** ** Implementation of the os level dynamic memory allocation interface in terms ** of the standard malloc(), realloc() and free() found in many operating ** systems. No rocket science here. ** ** There are two versions of these four functions here. The version ** implemented here is only used if memory-management or memory-debugging is ** enabled. This version allocates an extra 8-bytes at the beginning of each ** block and stores the size of the allocation there. ** ** If neither memory-management or debugging is enabled, the second ** set of implementations is used instead. */ #if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || defined (SQLITE_MEMDEBUG) void *sqlite3GenericMalloc(int n){ char *p = (char *)malloc(n+8); assert(n>0); assert(sizeof(int)<=8); if( p ){ *(int *)p = n; p += 8; } return (void *)p; } void *sqlite3GenericRealloc(void *p, int n){ char *p2 = ((char *)p - 8); assert(n>0); p2 = (char*)realloc(p2, n+8); if( p2 ){ *(int *)p2 = n; p2 += 8; } return (void *)p2; } void sqlite3GenericFree(void *p){ assert(p); free((void *)((char *)p - 8)); } int sqlite3GenericAllocationSize(void *p){ return p ? *(int *)((char *)p - 8) : 0; } #else void *sqlite3GenericMalloc(int n){ char *p = (char *)malloc(n); return (void *)p; } void *sqlite3GenericRealloc(void *p, int n){ assert(n>0); p = realloc(p, n); return p; } void sqlite3GenericFree(void *p){ assert(p); free(p); } /* Never actually used, but needed for the linker */ int sqlite3GenericAllocationSize(void *p){ return 0; } #endif /* ** The default size of a disk sector */ #ifndef PAGER_SECTOR_SIZE # define PAGER_SECTOR_SIZE 512 #endif
graydon/monotone
sqlite/os_common.h
C
gpl-2.0
5,586
[ 30522, 1013, 1008, 1008, 1008, 2432, 2089, 2570, 1008, 1008, 1008, 1008, 1996, 3166, 5860, 19771, 5244, 9385, 2000, 2023, 3120, 3642, 1012, 1999, 2173, 1997, 1008, 1008, 1037, 3423, 5060, 1010, 2182, 2003, 1037, 13301, 1024, 1008, 1008, 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...
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.fileEditor.impl; import com.intellij.AppTopics; import com.intellij.CommonBundle; import com.intellij.application.options.CodeStyle; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.TransactionGuard; import com.intellij.openapi.application.TransactionGuardImpl; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.command.UndoConfirmationPolicy; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.ex.DocumentEx; import com.intellij.openapi.editor.ex.PrioritizedDocumentListener; import com.intellij.openapi.editor.impl.DocumentImpl; import com.intellij.openapi.editor.impl.EditorFactoryImpl; import com.intellij.openapi.editor.impl.TrailingSpacesStripper; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.fileEditor.*; import com.intellij.openapi.fileEditor.impl.text.TextEditorImpl; import com.intellij.openapi.fileTypes.BinaryFileTypeDecompilers; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.UnknownFileType; import com.intellij.openapi.project.*; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.encoding.EncodingManager; import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem; import com.intellij.pom.core.impl.PomModelImpl; import com.intellij.psi.AbstractFileViewProvider; import com.intellij.psi.ExternalChangeAction; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.PsiFileImpl; import com.intellij.testFramework.LightVirtualFile; import com.intellij.ui.UIBundle; import com.intellij.ui.components.JBScrollPane; import com.intellij.util.ExceptionUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import javax.swing.*; import java.awt.*; import java.io.IOException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.nio.charset.Charset; import java.util.List; import java.util.*; public class FileDocumentManagerImpl extends FileDocumentManager implements VirtualFileListener, VetoableProjectManagerListener, SafeWriteRequestor { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl"); public static final Key<Document> HARD_REF_TO_DOCUMENT_KEY = Key.create("HARD_REF_TO_DOCUMENT_KEY"); private static final Key<String> LINE_SEPARATOR_KEY = Key.create("LINE_SEPARATOR_KEY"); private static final Key<VirtualFile> FILE_KEY = Key.create("FILE_KEY"); private static final Key<Boolean> MUST_RECOMPUTE_FILE_TYPE = Key.create("Must recompute file type"); private static final Key<Boolean> BIG_FILE_PREVIEW = Key.create("BIG_FILE_PREVIEW"); private final Set<Document> myUnsavedDocuments = ContainerUtil.newConcurrentSet(); private final MessageBus myBus; private static final Object lock = new Object(); private final FileDocumentManagerListener myMultiCaster; private final TrailingSpacesStripper myTrailingSpacesStripper = new TrailingSpacesStripper(); private boolean myOnClose; private volatile MemoryDiskConflictResolver myConflictResolver = new MemoryDiskConflictResolver(); private final PrioritizedDocumentListener myPhysicalDocumentChangeTracker = new PrioritizedDocumentListener() { @Override public int getPriority() { return Integer.MIN_VALUE; } @Override public void documentChanged(DocumentEvent e) { final Document document = e.getDocument(); if (!ApplicationManager.getApplication().hasWriteAction(ExternalChangeAction.ExternalDocumentChange.class)) { myUnsavedDocuments.add(document); } final Runnable currentCommand = CommandProcessor.getInstance().getCurrentCommand(); Project project = currentCommand == null ? null : CommandProcessor.getInstance().getCurrentCommandProject(); if (project == null) project = ProjectUtil.guessProjectForFile(getFile(document)); String lineSeparator = CodeStyle.getProjectOrDefaultSettings(project).getLineSeparator(); document.putUserData(LINE_SEPARATOR_KEY, lineSeparator); // avoid documents piling up during batch processing if (areTooManyDocumentsInTheQueue(myUnsavedDocuments)) { saveAllDocumentsLater(); } } }; public FileDocumentManagerImpl(@NotNull VirtualFileManager virtualFileManager, @NotNull ProjectManager projectManager) { virtualFileManager.addVirtualFileListener(this); projectManager.addProjectManagerListener(this); myBus = ApplicationManager.getApplication().getMessageBus(); myBus.connect().subscribe(ProjectManager.TOPIC, this); InvocationHandler handler = (proxy, method, args) -> { multiCast(method, args); return null; }; final ClassLoader loader = FileDocumentManagerListener.class.getClassLoader(); myMultiCaster = (FileDocumentManagerListener)Proxy.newProxyInstance(loader, new Class[]{FileDocumentManagerListener.class}, handler); } private static void unwrapAndRethrow(@NotNull Exception e) { Throwable unwrapped = e; if (e instanceof InvocationTargetException) { unwrapped = e.getCause() == null ? e : e.getCause(); } ExceptionUtil.rethrowUnchecked(unwrapped); LOG.error(unwrapped); } @SuppressWarnings("OverlyBroadCatchBlock") private void multiCast(@NotNull Method method, Object[] args) { try { method.invoke(myBus.syncPublisher(AppTopics.FILE_DOCUMENT_SYNC), args); } catch (ClassCastException e) { LOG.error("Arguments: "+ Arrays.toString(args), e); } catch (Exception e) { unwrapAndRethrow(e); } // Allows pre-save document modification for (FileDocumentManagerListener listener : getListeners()) { try { method.invoke(listener, args); } catch (Exception e) { unwrapAndRethrow(e); } } // stripping trailing spaces try { method.invoke(myTrailingSpacesStripper, args); } catch (Exception e) { unwrapAndRethrow(e); } } @Override @Nullable public Document getDocument(@NotNull final VirtualFile file) { ApplicationManager.getApplication().assertReadAccessAllowed(); DocumentEx document = (DocumentEx)getCachedDocument(file); if (document == null) { if (!file.isValid() || file.isDirectory() || isBinaryWithoutDecompiler(file)) return null; boolean tooLarge = FileUtilRt.isTooLarge(file.getLength()); if (file.getFileType().isBinary() && tooLarge) return null; final CharSequence text = tooLarge ? LoadTextUtil.loadText(file, getPreviewCharCount(file)) : LoadTextUtil.loadText(file); synchronized (lock) { document = (DocumentEx)getCachedDocument(file); if (document != null) return document; // Double checking document = (DocumentEx)createDocument(text, file); document.setModificationStamp(file.getModificationStamp()); document.putUserData(BIG_FILE_PREVIEW, tooLarge ? Boolean.TRUE : null); final FileType fileType = file.getFileType(); document.setReadOnly(tooLarge || !file.isWritable() || fileType.isBinary()); if (!(file instanceof LightVirtualFile || file.getFileSystem() instanceof NonPhysicalFileSystem)) { document.addDocumentListener(myPhysicalDocumentChangeTracker); } if (file instanceof LightVirtualFile) { registerDocument(document, file); } else { document.putUserData(FILE_KEY, file); cacheDocument(file, document); } } myMultiCaster.fileContentLoaded(file, document); } return document; } public static boolean areTooManyDocumentsInTheQueue(@NotNull Collection<? extends Document> documents) { if (documents.size() > 100) return true; int totalSize = 0; for (Document document : documents) { totalSize += document.getTextLength(); if (totalSize > FileUtilRt.LARGE_FOR_CONTENT_LOADING) return true; } return false; } @NotNull private static Document createDocument(@NotNull CharSequence text, @NotNull VirtualFile file) { boolean acceptSlashR = file instanceof LightVirtualFile && StringUtil.indexOf(text, '\r') >= 0; boolean freeThreaded = Boolean.TRUE.equals(file.getUserData(AbstractFileViewProvider.FREE_THREADED)); DocumentImpl document = (DocumentImpl)((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(text, acceptSlashR, freeThreaded); document.documentCreatedFrom(file); return document; } @Override @Nullable public Document getCachedDocument(@NotNull VirtualFile file) { Document hard = file.getUserData(HARD_REF_TO_DOCUMENT_KEY); return hard != null ? hard : getDocumentFromCache(file); } public static void registerDocument(@NotNull final Document document, @NotNull VirtualFile virtualFile) { synchronized (lock) { document.putUserData(FILE_KEY, virtualFile); virtualFile.putUserData(HARD_REF_TO_DOCUMENT_KEY, document); } } @Override @Nullable public VirtualFile getFile(@NotNull Document document) { return document.getUserData(FILE_KEY); } @TestOnly public void dropAllUnsavedDocuments() { if (!ApplicationManager.getApplication().isUnitTestMode()) { throw new RuntimeException("This method is only for test mode!"); } ApplicationManager.getApplication().assertWriteAccessAllowed(); if (!myUnsavedDocuments.isEmpty()) { myUnsavedDocuments.clear(); fireUnsavedDocumentsDropped(); } } private void saveAllDocumentsLater() { // later because some document might have been blocked by PSI right now ApplicationManager.getApplication().invokeLater(() -> { if (ApplicationManager.getApplication().isDisposed()) { return; } final Document[] unsavedDocuments = getUnsavedDocuments(); for (Document document : unsavedDocuments) { VirtualFile file = getFile(document); if (file == null) continue; Project project = ProjectUtil.guessProjectForFile(file); if (project == null) continue; if (PsiDocumentManager.getInstance(project).isDocumentBlockedByPsi(document)) continue; saveDocument(document); } }); } @Override public void saveAllDocuments() { saveAllDocuments(true); } /** * @param isExplicit caused by user directly (Save action) or indirectly (e.g. Compile) */ public void saveAllDocuments(boolean isExplicit) { ApplicationManager.getApplication().assertIsDispatchThread(); ((TransactionGuardImpl)TransactionGuard.getInstance()).assertWriteActionAllowed(); myMultiCaster.beforeAllDocumentsSaving(); if (myUnsavedDocuments.isEmpty()) return; final Map<Document, IOException> failedToSave = new HashMap<>(); final Set<Document> vetoed = new HashSet<>(); while (true) { int count = 0; for (Document document : myUnsavedDocuments) { if (failedToSave.containsKey(document)) continue; if (vetoed.contains(document)) continue; try { doSaveDocument(document, isExplicit); } catch (IOException e) { //noinspection ThrowableResultOfMethodCallIgnored failedToSave.put(document, e); } catch (SaveVetoException e) { vetoed.add(document); } count++; } if (count == 0) break; } if (!failedToSave.isEmpty()) { handleErrorsOnSave(failedToSave); } } @Override public void saveDocument(@NotNull final Document document) { saveDocument(document, true); } public void saveDocument(@NotNull final Document document, final boolean explicit) { ApplicationManager.getApplication().assertIsDispatchThread(); ((TransactionGuardImpl)TransactionGuard.getInstance()).assertWriteActionAllowed(); if (!myUnsavedDocuments.contains(document)) return; try { doSaveDocument(document, explicit); } catch (IOException e) { handleErrorsOnSave(Collections.singletonMap(document, e)); } catch (SaveVetoException ignored) { } } @Override public void saveDocumentAsIs(@NotNull Document document) { VirtualFile file = getFile(document); boolean spaceStrippingEnabled = true; if (file != null) { spaceStrippingEnabled = TrailingSpacesStripper.isEnabled(file); TrailingSpacesStripper.setEnabled(file, false); } try { saveDocument(document); } finally { if (file != null) { TrailingSpacesStripper.setEnabled(file, spaceStrippingEnabled); } } } private static class SaveVetoException extends Exception {} private void doSaveDocument(@NotNull final Document document, boolean isExplicit) throws IOException, SaveVetoException { VirtualFile file = getFile(document); if (LOG.isTraceEnabled()) LOG.trace("saving: " + file); if (file == null || file instanceof LightVirtualFile || file.isValid() && !isFileModified(file)) { removeFromUnsaved(document); return; } if (file.isValid() && needsRefresh(file)) { LOG.trace(" refreshing..."); file.refresh(false, false); if (!myUnsavedDocuments.contains(document)) return; } if (!maySaveDocument(file, document, isExplicit)) { throw new SaveVetoException(); } LOG.trace(" writing..."); WriteAction.run(() -> doSaveDocumentInWriteAction(document, file)); LOG.trace(" done"); } private boolean maySaveDocument(@NotNull VirtualFile file, @NotNull Document document, boolean isExplicit) { return !myConflictResolver.hasConflict(file) && Arrays.stream(Extensions.getExtensions(FileDocumentSynchronizationVetoer.EP_NAME)).allMatch(vetoer -> vetoer.maySaveDocument(document, isExplicit)); } private void doSaveDocumentInWriteAction(@NotNull final Document document, @NotNull final VirtualFile file) throws IOException { if (!file.isValid()) { removeFromUnsaved(document); return; } if (!file.equals(getFile(document))) { registerDocument(document, file); } boolean saveNeeded = false; IOException ioException = null; try { saveNeeded = isSaveNeeded(document, file); } catch (IOException e) { // in case of corrupted VFS try to stay consistent ioException = e; } if (!saveNeeded) { if (document instanceof DocumentEx) { ((DocumentEx)document).setModificationStamp(file.getModificationStamp()); } removeFromUnsaved(document); updateModifiedProperty(file); if (ioException != null) throw ioException; return; } PomModelImpl.guardPsiModificationsIn(() -> { myMultiCaster.beforeDocumentSaving(document); LOG.assertTrue(file.isValid()); String text = document.getText(); String lineSeparator = getLineSeparator(document, file); if (!lineSeparator.equals("\n")) { text = StringUtil.convertLineSeparators(text, lineSeparator); } Project project = ProjectLocator.getInstance().guessProjectForFile(file); LoadTextUtil.write(project, file, this, text, document.getModificationStamp()); myUnsavedDocuments.remove(document); LOG.assertTrue(!myUnsavedDocuments.contains(document)); myTrailingSpacesStripper.clearLineModificationFlags(document); }); } private static void updateModifiedProperty(@NotNull VirtualFile file) { for (Project project : ProjectManager.getInstance().getOpenProjects()) { FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); for (FileEditor editor : fileEditorManager.getAllEditors(file)) { if (editor instanceof TextEditorImpl) { ((TextEditorImpl)editor).updateModifiedProperty(); } } } } private void removeFromUnsaved(@NotNull Document document) { myUnsavedDocuments.remove(document); fireUnsavedDocumentsDropped(); LOG.assertTrue(!myUnsavedDocuments.contains(document)); } private static boolean isSaveNeeded(@NotNull Document document, @NotNull VirtualFile file) throws IOException { if (file.getFileType().isBinary() || document.getTextLength() > 1000 * 1000) { // don't compare if the file is too big return true; } byte[] bytes = file.contentsToByteArray(); CharSequence loaded = LoadTextUtil.getTextByBinaryPresentation(bytes, file, false, false); return !Comparing.equal(document.getCharsSequence(), loaded); } private static boolean needsRefresh(@NotNull VirtualFile file) { final VirtualFileSystem fs = file.getFileSystem(); return fs instanceof NewVirtualFileSystem && file.getTimeStamp() != ((NewVirtualFileSystem)fs).getTimeStamp(file); } @NotNull public static String getLineSeparator(@NotNull Document document, @NotNull VirtualFile file) { String lineSeparator = LoadTextUtil.getDetectedLineSeparator(file); if (lineSeparator == null) { lineSeparator = document.getUserData(LINE_SEPARATOR_KEY); assert lineSeparator != null : document; } return lineSeparator; } @Override @NotNull public String getLineSeparator(@Nullable VirtualFile file, @Nullable Project project) { String lineSeparator = file == null ? null : LoadTextUtil.getDetectedLineSeparator(file); if (lineSeparator == null) { lineSeparator = CodeStyle.getProjectOrDefaultSettings(project).getLineSeparator(); } return lineSeparator; } @Override public boolean requestWriting(@NotNull Document document, Project project) { final VirtualFile file = getInstance().getFile(document); if (project != null && file != null && file.isValid()) { return !file.getFileType().isBinary() && ReadonlyStatusHandler.ensureFilesWritable(project, file); } if (document.isWritable()) { return true; } document.fireReadOnlyModificationAttempt(); return false; } @Override public void reloadFiles(@NotNull final VirtualFile... files) { for (VirtualFile file : files) { if (file.exists()) { final Document doc = getCachedDocument(file); if (doc != null) { reloadFromDisk(doc); } } } } @Override @NotNull public Document[] getUnsavedDocuments() { if (myUnsavedDocuments.isEmpty()) { return Document.EMPTY_ARRAY; } List<Document> list = new ArrayList<>(myUnsavedDocuments); return list.toArray(Document.EMPTY_ARRAY); } @Override public boolean isDocumentUnsaved(@NotNull Document document) { return myUnsavedDocuments.contains(document); } @Override public boolean isFileModified(@NotNull VirtualFile file) { final Document doc = getCachedDocument(file); return doc != null && isDocumentUnsaved(doc) && doc.getModificationStamp() != file.getModificationStamp(); } @Override public boolean isPartialPreviewOfALargeFile(@NotNull Document document) { return document.getUserData(BIG_FILE_PREVIEW) == Boolean.TRUE; } @Override public void propertyChanged(@NotNull VirtualFilePropertyEvent event) { final VirtualFile file = event.getFile(); if (VirtualFile.PROP_WRITABLE.equals(event.getPropertyName())) { final Document document = getCachedDocument(file); if (document != null) { ApplicationManager.getApplication().runWriteAction((ExternalChangeAction)() -> document.setReadOnly(!file.isWritable())); } } else if (VirtualFile.PROP_NAME.equals(event.getPropertyName())) { Document document = getCachedDocument(file); if (document != null) { // a file is linked to a document - chances are it is an "unknown text file" now if (isBinaryWithoutDecompiler(file)) { unbindFileFromDocument(file, document); } } } } private void unbindFileFromDocument(@NotNull VirtualFile file, @NotNull Document document) { removeDocumentFromCache(file); file.putUserData(HARD_REF_TO_DOCUMENT_KEY, null); document.putUserData(FILE_KEY, null); } private static boolean isBinaryWithDecompiler(@NotNull VirtualFile file) { final FileType ft = file.getFileType(); return ft.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(ft) != null; } private static boolean isBinaryWithoutDecompiler(@NotNull VirtualFile file) { final FileType fileType = file.getFileType(); return fileType.isBinary() && BinaryFileTypeDecompilers.INSTANCE.forFileType(fileType) == null; } private static final Key<Document> DOCUMENT_WAS_SAVED_TEMPORARILY = Key.create("DOCUMENT_WAS_SAVED_TEMPORARILY"); @Override public void beforeContentsChange(@NotNull VirtualFileEvent event) { VirtualFile virtualFile = event.getFile(); // check file type in second order to avoid content detection running if (virtualFile.getLength() == 0 && virtualFile.getFileType() == UnknownFileType.INSTANCE) { virtualFile.putUserData(MUST_RECOMPUTE_FILE_TYPE, Boolean.TRUE); } if (ourConflictsSolverEnabled) { myConflictResolver.beforeContentChange(event); } Document document = getCachedDocument(virtualFile); if (document == null && DocumentImpl.areRangeMarkersRetainedFor(virtualFile)) { // re-create document with the old contents prior to this event // then contentChanged() will diff the document with the new contents and update the markers document = getDocument(virtualFile); } // save document strongly to make it live until contentChanged() virtualFile.putUserData(DOCUMENT_WAS_SAVED_TEMPORARILY, document); } @Override public void contentsChanged(@NotNull VirtualFileEvent event) { final VirtualFile virtualFile = event.getFile(); final Document document = getCachedDocument(virtualFile); // remove strong ref to allow document to gc virtualFile.putUserData(DOCUMENT_WAS_SAVED_TEMPORARILY, null); if (event.isFromSave()) return; if (document == null || isBinaryWithDecompiler(virtualFile)) { myMultiCaster.fileWithNoDocumentChanged(virtualFile); // This will generate PSI event at FileManagerImpl } if (document != null && (document.getModificationStamp() == event.getOldModificationStamp() || !isDocumentUnsaved(document))) { reloadFromDisk(document); } } @Override public void reloadFromDisk(@NotNull final Document document) { ApplicationManager.getApplication().assertIsDispatchThread(); final VirtualFile file = getFile(document); assert file != null; if (!fireBeforeFileContentReload(file, document)) { return; } final Project project = ProjectLocator.getInstance().guessProjectForFile(file); boolean[] isReloadable = {isReloadable(file, document, project)}; if (isReloadable[0]) { CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction( new ExternalChangeAction.ExternalDocumentChange(document, project) { @Override public void run() { if (!isBinaryWithoutDecompiler(file)) { LoadTextUtil.clearCharsetAutoDetectionReason(file); file.setBOM(null); // reset BOM in case we had one and the external change stripped it away file.setCharset(null, null, false); boolean wasWritable = document.isWritable(); document.setReadOnly(false); boolean tooLarge = FileUtilRt.isTooLarge(file.getLength()); isReloadable[0] = isReloadable(file, document, project); if (isReloadable[0]) { CharSequence reloaded = tooLarge ? LoadTextUtil.loadText(file, getPreviewCharCount(file)) : LoadTextUtil.loadText(file); ((DocumentEx)document).replaceText(reloaded, file.getModificationStamp()); document.putUserData(BIG_FILE_PREVIEW, tooLarge ? Boolean.TRUE : null); } document.setReadOnly(!wasWritable); } } } ), UIBundle.message("file.cache.conflict.action"), null, UndoConfirmationPolicy.REQUEST_CONFIRMATION); } if (isReloadable[0]) { myMultiCaster.fileContentReloaded(file, document); } else { unbindFileFromDocument(file, document); myMultiCaster.fileWithNoDocumentChanged(file); } myUnsavedDocuments.remove(document); } private static boolean isReloadable(@NotNull VirtualFile file, @NotNull Document document, @Nullable Project project) { PsiFile cachedPsiFile = project == null ? null : PsiDocumentManager.getInstance(project).getCachedPsiFile(document); return !(FileUtilRt.isTooLarge(file.getLength()) && file.getFileType().isBinary()) && (cachedPsiFile == null || cachedPsiFile instanceof PsiFileImpl || isBinaryWithDecompiler(file)); } @TestOnly void setAskReloadFromDisk(@NotNull Disposable disposable, @NotNull MemoryDiskConflictResolver newProcessor) { final MemoryDiskConflictResolver old = myConflictResolver; myConflictResolver = newProcessor; Disposer.register(disposable, () -> myConflictResolver = old); } @Override public void fileDeleted(@NotNull VirtualFileEvent event) { Document doc = getCachedDocument(event.getFile()); if (doc != null) { myTrailingSpacesStripper.documentDeleted(doc); } } public static boolean recomputeFileTypeIfNecessary(@NotNull VirtualFile virtualFile) { if (virtualFile.getUserData(MUST_RECOMPUTE_FILE_TYPE) != null) { virtualFile.getFileType(); virtualFile.putUserData(MUST_RECOMPUTE_FILE_TYPE, null); return true; } return false; } @Override public boolean canClose(@NotNull Project project) { if (!myUnsavedDocuments.isEmpty()) { myOnClose = true; try { saveAllDocuments(); } finally { myOnClose = false; } } return myUnsavedDocuments.isEmpty(); } private void fireUnsavedDocumentsDropped() { myMultiCaster.unsavedDocumentsDropped(); } private boolean fireBeforeFileContentReload(@NotNull VirtualFile file, @NotNull Document document) { for (FileDocumentSynchronizationVetoer vetoer : Extensions.getExtensions(FileDocumentSynchronizationVetoer.EP_NAME)) { try { if (!vetoer.mayReloadFileContent(file, document)) { return false; } } catch (Exception e) { LOG.error(e); } } myMultiCaster.beforeFileContentReload(file, document); return true; } @NotNull private static List<FileDocumentManagerListener> getListeners() { return FileDocumentManagerListener.EP_NAME.getExtensionList(); } private static int getPreviewCharCount(@NotNull VirtualFile file) { Charset charset = EncodingManager.getInstance().getEncoding(file, false); float bytesPerChar = charset == null ? 2 : charset.newEncoder().averageBytesPerChar(); return (int)(FileUtilRt.LARGE_FILE_PREVIEW_SIZE / bytesPerChar); } private void handleErrorsOnSave(@NotNull Map<Document, IOException> failures) { if (ApplicationManager.getApplication().isUnitTestMode()) { IOException ioException = ContainerUtil.getFirstItem(failures.values()); if (ioException != null) { throw new RuntimeException(ioException); } return; } for (IOException exception : failures.values()) { LOG.warn(exception); } final String text = StringUtil.join(failures.values(), Throwable::getMessage, "\n"); final DialogWrapper dialog = new DialogWrapper(null) { { init(); setTitle(UIBundle.message("cannot.save.files.dialog.title")); } @Override protected void createDefaultActions() { super.createDefaultActions(); myOKAction.putValue(Action.NAME, UIBundle .message(myOnClose ? "cannot.save.files.dialog.ignore.changes" : "cannot.save.files.dialog.revert.changes")); myOKAction.putValue(DEFAULT_ACTION, null); if (!myOnClose) { myCancelAction.putValue(Action.NAME, CommonBundle.getCloseButtonText()); } } @Override protected JComponent createCenterPanel() { final JPanel panel = new JPanel(new BorderLayout(0, 5)); panel.add(new JLabel(UIBundle.message("cannot.save.files.dialog.message")), BorderLayout.NORTH); final JTextPane area = new JTextPane(); area.setText(text); area.setEditable(false); area.setMinimumSize(new Dimension(area.getMinimumSize().width, 50)); panel.add(new JBScrollPane(area, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER); return panel; } }; if (dialog.showAndGet()) { for (Document document : failures.keySet()) { reloadFromDisk(document); } } } private final Map<VirtualFile, Document> myDocumentCache = ContainerUtil.createConcurrentWeakValueMap(); //temp setter for Rider 2017.1 public static boolean ourConflictsSolverEnabled = true; private void cacheDocument(@NotNull VirtualFile file, @NotNull Document document) { myDocumentCache.put(file, document); } private void removeDocumentFromCache(@NotNull VirtualFile file) { myDocumentCache.remove(file); } private Document getDocumentFromCache(@NotNull VirtualFile file) { return myDocumentCache.get(file); } }
sabi0/intellij-community
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImpl.java
Java
apache-2.0
30,349
[ 30522, 1013, 1013, 9385, 2456, 1011, 2760, 6892, 10024, 7076, 1055, 1012, 1054, 1012, 1051, 1012, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1996, 15895, 1016, 1012, 1014, 6105, 2008, 2064, 2022, 2179, 1999, 1996, 6105, 5371, 1012, 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...
using CinchORM.AccessLayer; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace CinchORM { public class CinchMapping { public List<string> Columns { get; set; } public string ColumnsString { get { if(this.Columns == null || Columns.Count == 0) throw new ApplicationException(String.Format("Could not build ColumnsString because the objects ValuesQueryParams is null or empty"), new NullReferenceException()); return string.Join(",", this.Columns); } } public string QueryString { get; set; } public List<string> ValuesQueryParams { get; set; } public string InsertValuesQueryParamsString { get { if(this.ValuesQueryParams == null || this.ValuesQueryParams.Count == 0) throw new ApplicationException(String.Format("Could not build ValuesQueryParamsString because the objects ValuesQueryParams is null or empty"), new NullReferenceException()); return string.Join(",", this.ValuesQueryParams); } } public string UpdateValuesQueryParamsString { get { if (this.ValuesQueryParams == null || this.ValuesQueryParams.Count == 0 || this.Columns == null || Columns.Count == 0) throw new ApplicationException(String.Format("Could not build ValuesQueryParamsString because the objects ValuesQueryParams is null or empty"), new NullReferenceException()); string updateValuesQueryParamsString = null; for (int i = 0; i < this.Columns.Count; i++) { string col = this.Columns[i]; string val = this.ValuesQueryParams[i]; updateValuesQueryParamsString = String.Format("{0}{1} = {2},", updateValuesQueryParamsString, col, val); } if (updateValuesQueryParamsString.Substring(updateValuesQueryParamsString.Length - 1, 1) == ",") return updateValuesQueryParamsString.Substring(0, updateValuesQueryParamsString.Length - 1); return updateValuesQueryParamsString; } } public List<SqlParameter> SqlParams { get; set; } } public static class Mapper { internal static Dictionary<string, CinchMapping> _cinchMappingCache = new Dictionary<string, CinchMapping>(); public static CinchMapping MapProperties<T>(T obj, List<string> cols = null) where T : ModelBase { string cacheKey = String.Format("{0}_{1}", obj.ObjName, String.Join("-", cols.ToArray())); CinchMapping cinchMapping = null; if(!_cinchMappingCache.ContainsKey(cacheKey)) { PropertyInfo[] props = obj.GetType().GetProperties(); List<string> columns = new List<string>(); List<string> valuesQueryParams = new List<string>(); List<SqlParameter> sqlParams = new List<SqlParameter>(); int i = 1; foreach (PropertyInfo prop in props) { if (prop.Attributes.GetAttributeFrom<CinchIgnoreAttribute>(prop) != null || prop.DeclaringType == typeof(ModelBase) || (cols != null && cols.Contains(prop.Name))) continue; #if NET40 object value = prop.GetValue(obj, null); #else object value = prop.GetValue(obj); #endif if (value == null) continue; Type t = prop.PropertyType; string placeholder = String.Format("val{0}", i); columns.Add(String.Format("{0}{1}{2}", SpecialCharacters.ColumnBegin, prop.Name, SpecialCharacters.ColumnEnd)); valuesQueryParams.Add(String.Format("{0}{1}", SpecialCharacters.ParamPrefix, placeholder)); sqlParams.AddParameter(placeholder, Conversion.GetSqlDbType(t), value); i++; } cinchMapping = new CinchMapping() { Columns = columns, ValuesQueryParams = valuesQueryParams, SqlParams = sqlParams }; _cinchMappingCache.Add(cacheKey, cinchMapping); } else { cinchMapping = _cinchMappingCache[cacheKey]; } return cinchMapping; } public static CinchMapping MapQuery<T>(T obj, string query, object[] param) where T : ModelBase { string cacheKey = String.Format("{0}_{1}_{2}", obj.ObjName, query, String.Join("-", param)); CinchMapping cinchMapping = null; if(!_cinchMappingCache.ContainsKey(cacheKey)) { cinchMapping = new CinchMapping() { QueryString = query }; if (param != null && param.Count() > 0) { //where clause has params, but no param values were passed in. if (!String.IsNullOrWhiteSpace(query) && query.IndexOf('@') > -1 && param.Count() <= 0) throw new ApplicationException(String.Format("Could not execute Find for {0} because the parameters array is empty", obj.ObjName), new NullReferenceException()); //param counts don't match else if (query.Count(c => c == '@') != param.Count()) throw new ApplicationException(String.Format("Could not execute Find for {0} because the number of parameters in the where clause and parameters array do not match", obj.ObjName), new NullReferenceException()); List<SqlParameter> sqlParams = BuildParamsFromString(query, param); cinchMapping.SqlParams = sqlParams; } _cinchMappingCache.Add(cacheKey, cinchMapping); } else { cinchMapping = _cinchMappingCache[cacheKey]; } return cinchMapping; } public static CinchMapping MapQuery(string query, object[] param) { string cacheKey = String.Format("{0}_{1}", query, String.Join("-", param)); CinchMapping cinchMapping = null; if (!_cinchMappingCache.ContainsKey(cacheKey)) { cinchMapping = new CinchMapping() { QueryString = query }; if (param != null && param.Count() > 0) { //where clause has params, but no param values were passed in. if (!String.IsNullOrWhiteSpace(query) && query.IndexOf('@') > -1 && param.Count() <= 0) throw new ApplicationException(String.Format("Could not execute Find for \"{0}\" because the parameters array is empty", query), new NullReferenceException()); //param counts don't match else if (query.Count(c => c == '@') != param.Count()) throw new ApplicationException(String.Format("Could not execute Find for \"{0}\" because the number of parameters in the where clause and parameters array do not match", query), new NullReferenceException()); List<SqlParameter> sqlParams = BuildParamsFromString(query, param); cinchMapping.SqlParams = sqlParams; } _cinchMappingCache.Add(cacheKey, cinchMapping); } else { cinchMapping = _cinchMappingCache[cacheKey]; } return cinchMapping; } private static List<SqlParameter> BuildParamsFromString(string query, object[] param) { Regex regex = new Regex("@[A-Za-z0-9]+"); MatchCollection matches = regex.Matches(query); //param matches don't match param array if (matches.Count != param.Count()) throw new ApplicationException(String.Format("Could not build Params because the number of parameters in the where clause and parameters array do not match"), new NullReferenceException()); List<SqlParameter> sqlParams = new List<SqlParameter>(); for (int i = 0; i < matches.Count; i++) { Match match = matches[i]; object value = param[i]; //add sql param sqlParams.AddParameter(match.Value, Conversion.GetSqlDbType(value.GetType()), value); } return sqlParams; } } }
pimbrouwers/cinch
Cinch/Mapping/Mapper.cs
C#
mit
9,003
[ 30522, 2478, 25022, 12680, 2953, 2213, 1012, 3229, 24314, 1025, 2478, 2291, 1025, 2478, 2291, 1012, 6407, 1012, 12391, 1025, 2478, 2291, 1012, 2951, 1025, 2478, 2291, 30524, 2291, 1012, 3793, 1025, 2478, 2291, 1012, 3793, 1012, 3180, 10288,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ /* NetworkManager Connection editor -- Connection editor for NetworkManager * * 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., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Copyright 2012 Red Hat, Inc. */ #ifndef __PAGE_MASTER_H__ #define __PAGE_MASTER_H__ #include <nm-connection.h> #include <glib.h> #include <glib-object.h> #include "ce-page.h" #include "connection-helpers.h" #define CE_TYPE_PAGE_MASTER (ce_page_master_get_type ()) #define CE_PAGE_MASTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CE_TYPE_PAGE_MASTER, CEPageMaster)) #define CE_PAGE_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CE_TYPE_PAGE_MASTER, CEPageMasterClass)) #define CE_IS_PAGE_MASTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CE_TYPE_PAGE_MASTER)) #define CE_IS_PAGE_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CE_TYPE_PAGE_MASTER)) #define CE_PAGE_MASTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CE_TYPE_PAGE_MASTER, CEPageMasterClass)) typedef struct { CEPage parent; gboolean aggregating; } CEPageMaster; typedef struct { CEPageClass parent; /* signals */ void (*create_connection) (CEPageMaster *self, NMConnection *connection); void (*connection_added) (CEPageMaster *self, NMConnection *connection); void (*connection_removed) (CEPageMaster *self, NMConnection *connection); /* methods */ void (*add_slave) (CEPageMaster *self, NewConnectionResultFunc result_func); } CEPageMasterClass; GType ce_page_master_get_type (void); gboolean ce_page_master_has_slaves (CEPageMaster *self); #endif /* __PAGE_MASTER_H__ */
pavlix/nm-applet
src/connection-editor/page-master.h
C
gpl-2.0
2,296
[ 30522, 1013, 1008, 1011, 1008, 1011, 5549, 1024, 1039, 1025, 21628, 1011, 9381, 1024, 1018, 1025, 30524, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, 1008, 2009, 2104, 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...
module Msplex module Resource class Service DEFINED_ACTION = { list: { type: :get, params: false, }, create: { type: :post, params: true, }, get: { type: :get, params: true, }, update: { type: :patch, params: true, }, delete: { type: :delete, params: true, }, } attr_reader :name, :actions def self.read_schema(path) schema = Utils.symbolize_keys(YAML.load_file(path)) self.new(schema[:name], schema[:actions]) end def initialize(name, actions) @name = name @actions = actions end def compose(database) { build: "services/#{@name}", environment: [ "RACK_ENV=production", "VIRTUAL_HOST=#{@name}" ], links: links(database), } end def compose_service_name @compose_service_name ||= "#{@name}_service" end def app_rb(database) <<-APPRB #{database.definitions.join("\n")} class App < Sinatra::Base configure do register Sinatra::ActiveRecordExtension use Rack::Session::Cookie, expire_after: 3600, secret: "salt" end helpers do def csrf_meta_tag Rack::Csrf.csrf_metatag(env) end def param_str(parameters) parameters.map { |key, value| key.to_s + "=" + CGI.escape(value.to_s) }.join("&") end def http_get(endpoint, parameters = {}) uri = URI.parse(parameters.length > 0 ? endpoint + "?" + param_str(parameters) : endpoint) JSON.parse(Net::HTTP.get_response(uri).body, symbolize_names: true) rescue { error: true } end def http_post(endpoint, parameters) uri = URI.parse(endpoint) JSON.parse(Net::HTTP.post_form(uri, parameters).body, symbolize_names: true) rescue { error: true } end def endpoint_of(service, action) "http://" << service << "/" << action end end #{Utils.indent(endpoint(database), 2)} end APPRB end def config_ru <<-CONFIGRU require "rubygems" require "bundler" Bundler.require require "./app.rb" run App CONFIGRU end def dockerfile <<-DOCKERFILE FROM #{image} MAINTAINER Your Name <you@example.com> ENV RACK_ENV production WORKDIR /usr/src/app COPY Gemfile /usr/src/app/ COPY Gemfile.lock /usr/src/app/ RUN bundle install -j4 --without development test --deployment COPY . /usr/src/app EXPOSE 80 ENTRYPOINT ["./entrypoint.sh"] CMD ["bundle", "exec", "rackup", "-p", "80"] DOCKERFILE end def entrypoint_sh <<-ENTRYPOINT #!/bin/bash bundle exec rake db:create bundle exec rake db:migrate exec $@ ENTRYPOINT end def gemfile(database) <<-GEMFILE.gsub(/^$/, "") source "https://rubygems.org" gem "activesupport", require: "active_support/all" gem "activerecord", "~> 4.2.5" gem "sinatra", "~> 1.4.6", require: "sinatra/base" gem "sinatra-activerecord", require: "sinatra/activerecord" gem "slim", "~> 3.0.6" gem "rack_csrf", require: "rack/csrf" gem "rake" gem "thin", "~> 1.6.4" #{db_gem(database)} group :development do gem "sinatra-reloader", require: "sinatra/reloader" end GEMFILE end def gemfile_lock(database) <<-GEMFILE_LOCK GEM remote: https://rubygems.org/ specs: activemodel (4.2.5) activesupport (= 4.2.5) builder (~> 3.1) activerecord (4.2.5) activemodel (= 4.2.5) activesupport (= 4.2.5) arel (~> 6.0) activesupport (4.2.5) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) backports (3.6.7) builder (3.2.2) daemons (1.2.3) eventmachine (1.0.9.1) i18n (0.7.0) json (1.8.3) minitest (5.8.3) multi_json (1.11.2) pg (0.18.3) rack (1.6.4) rack-protection (1.5.3) rack rack-test (0.6.3) rack (>= 1.0) rack_csrf (2.5.0) rack (>= 1.1.0) rake (10.5.0) sinatra (1.4.6) rack (~> 1.4) rack-protection (~> 1.4) tilt (>= 1.3, < 3) sinatra-activerecord (2.0.9) activerecord (>= 3.2) sinatra (~> 1.0) sinatra-contrib (1.4.6) backports (>= 2.0) multi_json rack-protection rack-test sinatra (~> 1.4.0) tilt (>= 1.3, < 3) sinatra-reloader (1.0) sinatra-contrib slim (3.0.6) temple (~> 0.7.3) tilt (>= 1.3.3, < 2.1) temple (0.7.6) thin (1.6.4) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (~> 1.0) thread_safe (0.3.5) tilt (2.0.2) tzinfo (1.2.2) thread_safe (~> 0.1) PLATFORMS ruby DEPENDENCIES activerecord (~> 4.2.5) activesupport pg (= 0.18.3) rack_csrf rake sinatra (~> 1.4.6) sinatra-activerecord sinatra-reloader slim (~> 3.0.6) thin (~> 1.6.4) BUNDLED WITH 1.11.2 GEMFILE_LOCK end def image "ruby:2.3.0" end def rakefile <<-RAKEFILE require "sinatra" require "sinatra/activerecord" require "sinatra/activerecord/rake" namespace :db do task :load_config do require "./app" end end RAKEFILE end private def db_gem(database) database ? "gem #{database.gem[:gem].inspect}, #{database.gem[:version].inspect}" : "" end def endpoint(database) actions.map do |action| if DEFINED_ACTION.keys.include?(action[:type].to_sym) defined = DEFINED_ACTION[action[:type].to_sym] db_action = defined[:params] ? database.send(action[:type], action[:table], {}) : database.send(action[:type], action[:table]) <<-ENDPOINT #{defined[:type]} "/#{action[:table]}" do content_type :json result = {} #{defined[:params] ? Utils.indent(database.params(action[:table]), 2) : ""} #{Utils.indent(db_action, 2)} result.to_json end ENDPOINT else # TODO "" end end.join("\n") end def links(database) database ? ["#{database.compose_service_name}:db"] : [] end end end end
dtan4/msplex
lib/msplex/resource/service.rb
Ruby
mit
6,248
[ 30522, 11336, 5796, 19386, 11336, 7692, 2465, 2326, 4225, 1035, 2895, 1027, 1063, 2862, 1024, 1063, 2828, 1024, 1024, 2131, 1010, 11498, 5244, 1024, 6270, 1010, 1065, 1010, 3443, 1024, 1063, 2828, 1024, 1024, 2695, 1010, 11498, 5244, 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...
package org.sdmlib.openbank.util; import org.sdmlib.models.pattern.PatternObject; import org.sdmlib.openbank.FeeValue; import org.sdmlib.openbank.TransactionTypeEnum; import org.sdmlib.models.pattern.AttributeConstraint; import org.sdmlib.models.pattern.Pattern; import java.math.BigInteger; import org.sdmlib.openbank.util.BankPO; import org.sdmlib.openbank.Bank; import org.sdmlib.openbank.util.FeeValuePO; public class FeeValuePO extends PatternObject<FeeValuePO, FeeValue> { public FeeValueSet allMatches() { this.setDoAllMatches(true); FeeValueSet matches = new FeeValueSet(); while (this.getPattern().getHasMatch()) { matches.add((FeeValue) this.getCurrentMatch()); this.getPattern().findMatch(); } return matches; } public FeeValuePO(){ newInstance(null); } public FeeValuePO(FeeValue... hostGraphObject) { if(hostGraphObject==null || hostGraphObject.length<1){ return ; } newInstance(null, hostGraphObject); } public FeeValuePO(String modifier) { this.setModifier(modifier); } public FeeValuePO createTransTypeCondition(TransactionTypeEnum value) { new AttributeConstraint() .withAttrName(FeeValue.PROPERTY_TRANSTYPE) .withTgtValue(value) .withSrc(this) .withModifier(this.getPattern().getModifier()) .withPattern(this.getPattern()); super.filterAttr(); return this; } public FeeValuePO createTransTypeAssignment(TransactionTypeEnum value) { new AttributeConstraint() .withAttrName(FeeValue.PROPERTY_TRANSTYPE) .withTgtValue(value) .withSrc(this) .withModifier(Pattern.CREATE) .withPattern(this.getPattern()); super.filterAttr(); return this; } public TransactionTypeEnum getTransType() { if (this.getPattern().getHasMatch()) { return ((FeeValue) getCurrentMatch()).getTransType(); } return null; } public FeeValuePO withTransType(TransactionTypeEnum value) { if (this.getPattern().getHasMatch()) { ((FeeValue) getCurrentMatch()).setTransType(value); } return this; } public FeeValuePO createPercentCondition(BigInteger value) { new AttributeConstraint() .withAttrName(FeeValue.PROPERTY_PERCENT) .withTgtValue(value) .withSrc(this) .withModifier(this.getPattern().getModifier()) .withPattern(this.getPattern()); super.filterAttr(); return this; } public FeeValuePO createPercentAssignment(BigInteger value) { new AttributeConstraint() .withAttrName(FeeValue.PROPERTY_PERCENT) .withTgtValue(value) .withSrc(this) .withModifier(Pattern.CREATE) .withPattern(this.getPattern()); super.filterAttr(); return this; } public BigInteger getPercent() { if (this.getPattern().getHasMatch()) { return ((FeeValue) getCurrentMatch()).getPercent(); } return null; } public FeeValuePO withPercent(BigInteger value) { if (this.getPattern().getHasMatch()) { ((FeeValue) getCurrentMatch()).setPercent(value); } return this; } public BankPO createBankPO() { BankPO result = new BankPO(new Bank[]{}); result.setModifier(this.getPattern().getModifier()); super.hasLink(FeeValue.PROPERTY_BANK, result); return result; } public BankPO createBankPO(String modifier) { BankPO result = new BankPO(new Bank[]{}); result.setModifier(modifier); super.hasLink(FeeValue.PROPERTY_BANK, result); return result; } public FeeValuePO createBankLink(BankPO tgt) { return hasLinkConstraint(tgt, FeeValue.PROPERTY_BANK); } public FeeValuePO createBankLink(BankPO tgt, String modifier) { return hasLinkConstraint(tgt, FeeValue.PROPERTY_BANK, modifier); } public Bank getBank() { if (this.getPattern().getHasMatch()) { return ((FeeValue) this.getCurrentMatch()).getBank(); } return null; } }
SWE443-TeamRed/open-bank
open-bank/src/main/java/org/sdmlib/openbank/util/FeeValuePO.java
Java
mit
4,269
[ 30522, 7427, 8917, 1012, 17371, 19968, 12322, 1012, 2330, 9299, 1012, 21183, 4014, 1025, 12324, 8917, 1012, 17371, 19968, 12322, 1012, 4275, 1012, 5418, 1012, 5418, 16429, 20614, 1025, 12324, 8917, 1012, 17371, 19968, 12322, 1012, 2330, 9299,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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...
/* mgrp_test.c * * Test messenger group broadcast/receive functionality and concurrency. * Each thread broadcasts a counter from 0 to ITERS, to all other threads * (but not itself). * Every receiving thread should sum received integers into a per-thread * rx_sum variable. * Every thread should accumulate the same rx_sum, which is: * (ITERS -1) * ITERS * (THREAD_CNT -1) * 0.5 * (see memorywell/test/well_test.c for more details). * * (c) 2018 Sirio Balmelli and Anthony Soenen */ #include <ndebug.h> #include <posigs.h> /* use atomic PSG kill flag as a global error flag */ #include <pcg_rand.h> #include <messenger.h> #include <pthread.h> #include <stdbool.h> #include <unistd.h> #include <fcntl.h> #define THREAD_CNT 2 #define ITERS 2 /* How many messages each thread should send. * TODO: increase once registration/rcu issue is resolved. */ /* thread() */ void *thread(void* arg) { struct mgrp *group = arg; int pvc[2] = { 0, 0 }; size_t rx_sum = 0, rx_i = 0; size_t message; NB_die_if( pipe(pvc) || fcntl(pvc[0], F_SETFL, fcntl(pvc[0], F_GETFL) | O_NONBLOCK) , ""); NB_die_if( mgrp_subscribe(group, pvc[1]) , ""); /* Don't start broadcasting until everyone is subscribed. * We could use pthread_barrier_t but that's not implemented on macOS, * and anyways messenger()'s mgrp_count uses acquire/release semantics. */ while (mgrp_count(group) != THREAD_CNT && !psg_kill_check()) sched_yield(); /* generate ITERS broadcasts; receive others' broadcasts */ for (size_t i = 0; i < ITERS && !psg_kill_check(); i++) { NB_die_if( mgrp_broadcast(group, pvc[1], &i, sizeof(i)) , ""); while ((mg_recv(pvc[0], &message) > 0) && !psg_kill_check()) { rx_sum += message; rx_i++; sched_yield(); /* prevent deadlock: give other threads a chance to write */ } errno = 0; /* _should_ be EINVAL: don't pollute later prints */ } /* wait for all other senders */ while (rx_i < ITERS * (THREAD_CNT -1) && !psg_kill_check()) { if ((mg_recv(pvc[0], &message) > 0)) { rx_sum += message; rx_i++; } else { sched_yield(); } } die: NB_err_if( mgrp_unsubscribe(group, pvc[1]) , "fd %d unsubscribe fail", pvc[1]); if (err_cnt) psg_kill(); if (pvc[0]) { close(pvc[1]); close(pvc[0]); } return (void *)rx_sum; } /* main() */ int main() { int err_cnt = 0; struct mgrp *group = NULL; pthread_t threads[THREAD_CNT]; NB_die_if(!( group = mgrp_new() ), ""); /* run all threads */ for (unsigned int i=0; i < THREAD_CNT; i++) { NB_die_if(pthread_create(&threads[i], NULL, thread, group), ""); } /* test results */ size_t expected = (ITERS -1) * ITERS * (THREAD_CNT -1) * 0.5; for (unsigned int i=0; i < THREAD_CNT; i++) { size_t rx_sum; NB_die_if( pthread_join(threads[i], (void **)&rx_sum) , ""); NB_err_if(rx_sum != expected, "thread %zu != expected %zu", rx_sum, expected); } die: mgrp_free(group); err_cnt += psg_kill_check(); /* return any error from any thread */ return err_cnt; }
siriobalmelli/nonlibc
test/mgrp_test.c
C
lgpl-2.1
3,010
[ 30522, 1013, 1008, 11460, 14536, 1035, 3231, 1012, 1039, 1008, 1008, 3231, 11981, 2177, 3743, 1013, 4374, 15380, 1998, 24154, 1012, 1008, 2169, 11689, 8960, 1037, 4675, 2013, 1014, 2000, 2009, 2545, 1010, 2000, 2035, 2060, 16457, 1008, 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...