code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
package com.sanction.thunder;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sanction.thunder.authentication.Key;
import io.dropwizard.Configuration;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
public class ThunderConfiguration extends Configuration {
@NotNull
@Valid
@JsonProperty("dynamo-endpoint")
private final String dynamoEndpoint = null;
public String getDynamoEndpoint() {
return dynamoEndpoint;
}
@NotNull
@Valid
@JsonProperty("approved-keys")
private final List<Key> approvedKeys = null;
public List<Key> getApprovedKeys() {
return approvedKeys;
}
}
| NickEckert/thunder | application/src/main/java/com/sanction/thunder/ThunderConfiguration.java | Java | mit | 672 | [
30522,
7427,
4012,
1012,
2624,
7542,
1012,
8505,
1025,
12324,
4012,
1012,
5514,
2595,
19968,
1012,
4027,
1012,
5754,
17287,
3508,
1012,
1046,
3385,
21572,
4842,
3723,
1025,
12324,
4012,
1012,
2624,
7542,
1012,
8505,
1012,
27280,
1012,
3145,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Cloudpad
module Starter
VERSION = "0.0.1"
end
end
| agquick/cloudpad-starter | lib/cloudpad/starter/version.rb | Ruby | mit | 65 | [
30522,
11336,
6112,
15455,
11336,
11753,
2544,
1027,
1000,
1014,
1012,
1014,
1012,
1015,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
#!/bin/sh
# AwesomeTTS text-to-speech add-on for Anki
# Copyright (C) 2010-Present Anki AwesomeTTS Development Team
#
# 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/>.
addon_id="301952613"
set -e
if [ -z "$1" ]
then
echo 'Please specify your Anki addons directory.' 1>&2
echo 1>&2
echo " Usage: $0 <target>" 1>&2
echo " e.g.: $0 ~/.local/share/Anki2/addons21" 1>&2
exit 1
fi
target=${1%/}
case $target in
*/addons21)
;;
*)
echo 'Expected target path to end in "/addons21".' 1>&2
exit 1
esac
case $target in
/*)
;;
*)
target=$PWD/$target
esac
if [ ! -d "$target" ]
then
echo "$target is not a directory." 1>&2
exit 1
fi
mkdir -p "$target/$addon_id"
if [ -f "$target/$addon_id/awesometts/config.db" ]
then
echo 'Saving configuration...'
saveConf=$(mktemp /tmp/config.XXXXXXXXXX.db)
cp -v "$target/$addon_id/awesometts/config.db" "$saveConf"
fi
if [ -d "$target/$addon_id/awesometts/.cache" ]
then
echo 'Saving cache...'
saveCache=$(mktemp -d /tmp/anki_cacheXXXXXXXXXX)
cp -rv "$target/$addon_id/awesometts/.cache/*" "$saveCache/"
fi
echo 'Cleaning up...'
rm -fv "$target/$addon_id/__init__.py"*
rm -rfv "$target/$addon_id/awesometts"
oldPwd=$PWD
cd "$(dirname "$0")/.." || exit 1
echo 'Linking...'
ln -sv "$PWD/$addon_id/__init__.py" "$target"
ln -sv "$PWD/$addon_id/awesometts" "$target"
cd "$oldPwd" || exit 1
if [ -n "$saveConf" ]
then
echo 'Restoring configuration...'
mv -v "$saveConf" "$target/$addon_id/awesometts/config.db"
fi
if [ -n "$saveCache" ]
then
echo 'Restoring cache...'
mv -rv "$saveConf/*" "$target/$addon_id/awesometts/.cache/"
fi
| AwesomeTTS/awesometts-anki-addon | tools/symlink.sh | Shell | gpl-3.0 | 2,285 | [
30522,
1001,
999,
1013,
8026,
1013,
14021,
1001,
12476,
4779,
2015,
3793,
1011,
2000,
1011,
4613,
5587,
1011,
2006,
2005,
2019,
3211,
1001,
9385,
1006,
1039,
1007,
2230,
1011,
2556,
2019,
3211,
12476,
4779,
2015,
2458,
2136,
1001,
1001,
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... |
<style type="text/css">
p {
text-align: justify;
}
</style>
<section class="content-header">
<h1>
Paragraf
<small>Control</small>
</h1>
<?php echo anchor('dashboard/Paragraf/print_','Print', array('target' => '_blank')); ?>
<i class="btn btn-xs fa fa-print bg-green" id="printul"></i>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active">Paragraf</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="box box-widget">
<div class="box-body">
<?php
foreach($bab as $b):
?>
<section class="col-md-12">
<div class="box box-default collapsed-box">
<div class="box-header with-border" data-widget="collapse" data-toggle="tooltip" title="Lihat" id="box_header" data-id="<?=$b->id?>"><i class="fa fa-plus"></i>
<h3 class="box-title">BAB <?=$b->no?> <?=$b->txt?></h3>
<i class="fa fa-spinner fa-pulse pull-right" style="display: none;" id="spin_head"></i>
</div><!-- /.box-header -->
<div class="box-body" id="isi_sub_bab_dan_header">
</div><!-- /.box-body -->
<div style="display: none;" class="overlay" id="load_box">
<i class="fa fa-refresh fa-spin"></i>
</div>
</div><!-- /.box -->
</section>
<?php endforeach;?>
</div>
</div>
</div>
<!-- /.row -->
</section>
<!-- /.content -->
<div class="modal fade" id="basic" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title">Default Modal</h4>
</div>
<div class="modal-body">
<!-- <div class="modal-body" id="isi_modal"> -->
<!-- <p>One fine body…</p> -->
</div>
<div class="modal-footer">
<!-- <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button> -->
<button class="btn btn-primary" id="simpan">OK</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal --> | farzhilman/eren | views/contents/8/paragraf/index_page_pisah.php | PHP | apache-2.0 | 2,786 | [
30522,
1026,
2806,
2828,
1027,
1000,
3793,
1013,
20116,
2015,
1000,
1028,
1052,
1063,
3793,
1011,
25705,
1024,
16114,
1025,
1065,
1026,
1013,
2806,
1028,
1026,
2930,
2465,
1027,
1000,
4180,
1011,
20346,
1000,
1028,
1026,
1044,
2487,
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... |
---
place: "Düsseldorf"
title: "senseBox-Workshop bei edulabsNRW"
link: "https://www.meetup.com/de-DE/edulabsKB/"
starting-date: 2018-11-22
ending-date: 2018-11-22
---
| sensebox/sensebox.github.io | _events/edulabs.md | Markdown | mit | 169 | [
30522,
1011,
1011,
1011,
2173,
1024,
1000,
18160,
1000,
2516,
1024,
1000,
3168,
8758,
1011,
8395,
21388,
3968,
7068,
5910,
16118,
2860,
1000,
4957,
1024,
1000,
16770,
1024,
1013,
1013,
7479,
1012,
3113,
6279,
1012,
4012,
1013,
2139,
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... |
var Location = function (jsonInFeed) {
var jsonContent = JSON.parse(jsonInFeed);
this.globalid = jsonContent.identifier[0].value;
this.name = jsonContent.name;
this.parentId = jsonContent.managingOrganization.reference;
this.fullName = function () {
var fullName = this.parent.fullName() + ', ' + this.name;
// FIXME: we shouldn't need this once Evan fixed RapidPro db restriction
if (fullName.length > 64) {
fullName = fullName.substring(0, 62) + '..';
}
return fullName;
};
this.groups = function () {
return [this.fullName()].concat(this.parent.groups());
};
};
Location.loadAll = function (url) {
var FeedReader = require(__dirname + '/feed-reader');
var feedReader = new FeedReader(Location, url);
return feedReader.loadAll();
};
module.exports = Location;
| openhie/mhero-synch | app/location.js | JavaScript | apache-2.0 | 870 | [
30522,
13075,
3295,
1027,
3853,
1006,
1046,
3385,
2378,
7959,
2098,
1007,
1063,
13075,
1046,
3385,
8663,
6528,
2102,
1027,
1046,
3385,
1012,
11968,
3366,
1006,
1046,
3385,
2378,
7959,
2098,
1007,
1025,
2023,
1012,
3795,
3593,
1027,
1046,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 foo() {
var x = 2;
var xxx = 1;
if (xxx) {
console.log(xxx + x);
}
}
| babel/babili | packages/babel-plugin-minify-mangle-names/__tests__/fixtures/name-collisions/actual.js | JavaScript | mit | 90 | [
30522,
3853,
29379,
1006,
1007,
1063,
13075,
1060,
1027,
1016,
1025,
13075,
22038,
2595,
1027,
1015,
1025,
2065,
1006,
22038,
2595,
1007,
1063,
10122,
1012,
8833,
1006,
22038,
2595,
1009,
1060,
1007,
1025,
1065,
1065,
102,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright (c) 2008-2013, Northwestern University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of the Northwestern University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
*/
#ifndef _ALTOVA_INCLUDED_AIMXML_ALTOVA_iso_ALTOVA_CUVP_II
#define _ALTOVA_INCLUDED_AIMXML_ALTOVA_iso_ALTOVA_CUVP_II
#include "type_iso.CANY.h"
namespace AIMXML
{
namespace iso
{
class CUVP_II : public ::AIMXML::iso::CANY
{
public:
AIMXML_EXPORT CUVP_II(xercesc::DOMNode* const& init);
AIMXML_EXPORT CUVP_II(CUVP_II const& init);
void operator=(CUVP_II const& other) { m_node = other.m_node; }
static altova::meta::ComplexType StaticInfo() { return altova::meta::ComplexType(types + _altova_ti_iso_altova_CUVP_II); }
MemberAttribute<double,_altova_mi_iso_altova_CUVP_II_altova_probability, 0, 0> probability; // probability Cdouble
MemberElement<iso::CII, _altova_mi_iso_altova_CUVP_II_altova_value2> value2;
struct value2 { typedef Iterator<iso::CII> iterator; };
AIMXML_EXPORT void SetXsiType();
};
} // namespace iso
} // namespace AIMXML
#endif // _ALTOVA_INCLUDED_AIMXML_ALTOVA_iso_ALTOVA_CUVP_II
| NCIP/annotation-and-image-markup | AIMToolkit_v4.1.0_rv44/source/AIMLib/AIMXML/type_iso.CUVP_II.h | C | bsd-3-clause | 2,446 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2263,
1011,
2286,
1010,
7855,
2118,
2035,
2916,
9235,
1012,
25707,
1998,
2224,
1999,
3120,
1998,
12441,
3596,
1010,
30524,
19771,
5017,
1012,
25707,
2015,
1999,
12441,
2433,
2442,
21376,
1996,
2682... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 READONLY = false
// How much labor you generate per minute
var LABORGENRATE = 2;
if (READONLY){
// This is just for setting up a display-only example of this app
Characters = new Meteor.Collection(null)
Timers = new Meteor.Collection(null)
} else {
Characters = new Meteor.Collection("characters");
Timers = new Meteor.Collection("timers");
}
DayStrings = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;1
}
return str;
}
function formattime(hour, minutes) {
if (hour >= 12) {
ampm = 'pm'
} else {
ampm = 'am'
}
hour = hour % 12;
if (hour == 0) {
hour = 12;
}
return hour+":"+pad(minutes,2)+ampm;
}
function parsetimerlength(timerstring) {
var totaltime = 0;
// Find days
var re = /(\d+) ?(?:days|day|d)/g;
var matches = re.exec(timerstring);
if(matches) {
totaltime += (Number(matches[1]) * 86400);
}
// Find hours
var re = /(\d+) ?(?:hours|hour|h|hr|hrs)/g;
var matches = re.exec(timerstring);
if(matches) {
totaltime += (Number(matches[1]) * 3600);
}
// Find minutes
var re = /(\d+) ?(?:minutes|minute|min|m)/g;
var matches = re.exec(timerstring);
if(matches) {
totaltime += (Number(matches[1]) * 60);
}
// Find seconds
var re = /(\d+) ?(?:seconds|second|secs|sec|s)/g;
var matches = re.exec(timerstring);
if(matches) {
totaltime += Number(matches[1]);
}
return totaltime;
}
function maxtime(now, max) {
return Date.now() + (max - now) * 1000 * 60 / LABORGENRATE;
}
if (Meteor.isClient) {
var highestMaxLabor = function () {
var highestchar = Characters.findOne({owner: Session.get('sessionid')}, {sort: {labormax: -1}})
if (highestchar)
return highestchar.labormax;
else
return 1000;
};
Session.set('sessionid', location.search);
// When editing a character name, ID of the character
Session.set('editing_charactername', null);
// When editing current labor, ID of the character
Session.set('editing_characterlabor', null);
// When editing current labormax, ID of the character
Session.set('editing_characterlabormax', null);
/* New version
Deps.autorun(function () {
Meteor.subscribe("characters");
});
*/
Meteor.autosubscribe(function () {
Meteor.subscribe('characters', {owner: Session.get('sessionid')});
Meteor.subscribe('timers', {owner: Session.get('sessionid')});
});
if (READONLY) {
// Super duper quickl and dirty hack for creating a read-only version of the app to show as an example from GitHub
newchar = Characters.insert({name: 'OverloadUT', labor: 4000, labormax: 4320, labortimestamp: Date.now(), maxtime: maxtime(4320, 4000), owner: Session.get('sessionid')});
newchar = Characters.insert({name: 'DiscoC', labor: 2400, labormax: 1650, labortimestamp: Date.now(), maxtime: maxtime(1650, 2400), owner: Session.get('sessionid')});
newchar = Characters.insert({name: 'RoughRaptors', labor: 1250, labormax: 5000, labortimestamp: Date.now(), maxtime: maxtime(5000, 1250), owner: Session.get('sessionid')});
var length = 3600
var percent = 0.75
Timers.insert({name: 'Strawberries', starttime: Date.now() - percent * length * 1000, timerlength: length, owner: Session.get('sessionid'), endtime: Date.now() + (1-percent) * length * 1000});
var length = 3600 * 72
var percent = 0.10
Timers.insert({name: 'Pine trees', starttime: Date.now() - percent * length * 1000, timerlength: length, owner: Session.get('sessionid'), endtime: Date.now() + (1-percent) * length * 1000});
var length = 3600 * 18
var percent = 0.90
Timers.insert({name: 'Cows', starttime: Date.now() - percent * length * 1000, timerlength: length, owner: Session.get('sessionid'), endtime: Date.now() + (1-percent) * length * 1000});
var length = 3600 * 24 * 7
var percent = 0.5
Timers.insert({name: 'Pay Taxes', starttime: Date.now() - percent * length * 1000, timerlength: length, owner: Session.get('sessionid'), endtime: Date.now() + (1-percent) * length * 1000});
var length = 3600 * 7
var percent = 1.5
Timers.insert({name: 'Goats', starttime: Date.now() - percent * length * 1000, timerlength: length, owner: Session.get('sessionid'), endtime: Date.now() + (1-percent) * length * 1000});
}
//{//////// Helpers for in-place editing //////////
// Returns an event map that handles the "escape" and "return" keys and
// "blur" events on a text input (given by selector) and interprets them
// as "ok" or "cancel".
var okCancelEvents = function (selector, callbacks) {
var ok = callbacks.ok || function () {};
var cancel = callbacks.cancel || function () {};
var events = {};
events['keyup '+selector+', keydown '+selector+', focusout '+selector] =
function (evt) {
if (evt.type === "keydown" && evt.which === 27) {
// escape = cancel
cancel.call(this, evt);
} else if (evt.type === "keyup" && evt.which === 13 ||
evt.type === "focusout") {
// blur/return/enter = ok/submit if non-empty
var value = String(evt.target.value || "");
if (value)
ok.call(this, value, evt);
else
cancel.call(this, evt);
}
};
return events;
};
var activateInput = function (input) {
input.focus();
input.select();
};
//} END IN-PLACE EDITING HELPERS
//{///////// NEED SESSION PAGE ///////////
Template.needsession.events({
'click input.sessionnamesubmit' : function () {
window.location = Meteor.absoluteUrl('?' + $("#sessionname").val())
}
});
//} END NEED SESSION PAGE
//{//////////// MAIN TEMPLATE //////////////
Template.main.need_session = function () {
return Session.get('sessionid') == "" || Session.get('sessionid') == "?undefined" || Session.get('sessionid') == "?";
};
Template.main.is_readonly = function () {
return READONLY;
};
Template.main.show_timers = function() {
//TODO: Make a way for the user to pick which modules are visible
return true;
}
//} END MAIN TEMPLATE
//{//////////// TIMERS LIST ///////////////////
// When editing timer name, ID of the timer
Session.set('editing_timername', null);
// When editing timer length, ID of the timer
Session.set('editing_timertimeleft', null);
// Preference to hide seconds from timers
Session.setDefault('pref_show_seconds', false);
var timersTimerDep = new Deps.Dependency;
var timersTimerUpdate = function () {
timersTimerDep.changed();
};
Meteor.setInterval(timersTimerUpdate, 1000);
Template.timers.timers = function () {
return Timers.find({owner: Session.get('sessionid')}, {sort: {endtime: 1}});
};
Template.timers.events({
'click a.add' : function () {
var newtimer = Timers.insert({name: 'Timer', starttime: Date.now(), timerlength: 3600, owner: Session.get('sessionid'), endtime: Date.now() + 3600 * 1000});
Session.set('editing_timername', newtimer);
Meteor.flush(); // force DOM redraw, so we can focus the edit field
activateInput($("#timer-name-input"));
},
'click th.timeleft' : function () {
Session.set('pref_show_seconds', !Session.get('pref_show_seconds'));
}
});
//} END TIMERS LIST
//{////////// EACH TIMER //////////////
Template.timer.displaytimeleft = function() {
return this.timerlength;
};
Template.timer.timerdone = function() {
return (this.endtime <= Date.now())
};
var format_time_left = function(totalsecondsleft) {
var daysleft = Math.floor(totalsecondsleft / 60 / 60 / 24);
var hoursleft = Math.floor(totalsecondsleft / 60 / 60 % 24);
var minutesleft = Math.floor(totalsecondsleft / 60 % 60);
var secondsleft = Math.floor(totalsecondsleft % 60);
var timestring = '';
if(totalsecondsleft > 86400) {
timestring += daysleft + 'd ';
}
if(totalsecondsleft > 3600) {
timestring += hoursleft + 'h ';
}
if(totalsecondsleft > 60) {
timestring += minutesleft + 'm ';
}
if (Session.get('pref_show_seconds')) {
timestring += secondsleft + 's';
}
return timestring;
}
Template.timer.timeleft = function() {
timersTimerDep.depend();
var totalsecondsleft = Math.abs((this.timerlength*1000 - (Date.now() - this.starttime)) / 1000);
return format_time_left(totalsecondsleft);
}
Template.timer.timeleftinput = function() {
if(this.endtime <= Date.now()) {
// Timer finished, so show the original timer length
return format_time_left(this.timerlength);
} else {
// Timer not finished, so show the current time left
var totalsecondsleft = Math.abs((this.timerlength*1000 - (Date.now() - this.starttime)) / 1000);
return format_time_left(totalsecondsleft);
}
}
Template.timer.endtimestring = function() {
timersTimerDep.depend();
var date = new Date(this.endtime);
var hour = date.getHours();
var minutes = date.getMinutes();
var day = date.getDay();
var hoursleft = Math.floor(Math.abs((this.endtime - Date.now()) / 1000 / 60 / 60))
var minutesleft = Math.floor(Math.abs((this.endtime - Date.now()) / 1000 / 60 % 60))
return DayStrings[day] + ' ' + formattime(hour,minutes);
}
Template.timer.percentage = function() {
timersTimerDep.depend();
var end = this.starttime + this.timerlength * 1000;
var now = Date.now();
return Math.min(100,Math.floor((now - this.starttime) / (end - this.starttime) * 100));
}
Template.timer.events({
'click a.remove' : function () {
Timers.remove({_id: this._id});
},
'click div.name': function (evt, tmpl) { // start editing list name
Session.set('editing_timername', this._id);
Meteor.flush(); // force DOM redraw, so we can focus the edit field
activateInput(tmpl.find("#timer-name-input"));
},
'click div.timeleft': function (evt, tmpl) { // start editing list name
Session.set('editing_timertimeleft', this._id);
Meteor.flush(); // force DOM redraw, so we can focus the edit field
activateInput(tmpl.find("#timer-timeleft-input"));
}
});
Template.timer.events(okCancelEvents(
'#timer-name-input', {
ok: function (value) {
Timers.update(this._id, {$set: {name: value}});
Session.set('editing_timername', null);
},
cancel: function () {
Session.set('editing_timername', null);
}
}
));
Template.timer.events(okCancelEvents(
'#timer-timeleft-input', {
ok: function (value) {
var timerlength = parsetimerlength(value);
Timers.update(this._id, {$set: {timerlength: timerlength, starttime: Date.now(), endtime: Date.now() + timerlength * 1000}});
Session.set('editing_timertimeleft', null);
},
cancel: function () {
Session.set('editing_timertimeleft', null);
}
}
));
Template.timer.editingname = function () {
return Session.equals('editing_timername', this._id);
};
Template.timer.editingtimeleft = function () {
return Session.equals('editing_timertimeleft', this._id);
};
//} END EACH TIMER
//{///////// CHARACTERS LIST //////////
// Preference to hide seconds from timers
Session.setDefault('pref_scale_maxlabor', true);
Session.setDefault('pref_sort_maxtime', false);
Template.characters.characters = function () {
if(Session.get('pref_sort_maxtime')) {
return Characters.find({owner: Session.get('sessionid')}, {sort: {maxtime: 1}});
} else {
return Characters.find({owner: Session.get('sessionid')}, {});
}
};
Template.characters.events({
'click a.add' : function () {
var newmaxtime = Date.now() + (this.labormax - this.labor) * 1000 * 60 / LABORGENRATE;
var newchar = Characters.insert({name: 'NewCharacter', labor: 50, labormax: 1000, labortimestamp: Date.now(), maxtime: newmaxtime, owner: Session.get('sessionid')});
Session.set('editing_charactername', newchar);
Meteor.flush(); // force DOM redraw, so we can focus the edit field
activateInput($("#character-name-input"));
},
'click th.labor' : function () {
Session.set('pref_scale_maxlabor', !Session.get('pref_scale_maxlabor'))
},
'click th.maxtime' : function () {
Session.set('pref_sort_maxtime', !Session.get('pref_sort_maxtime'))
}
});
//}
//{///////// EACH CHARACTER ///////////
var timerDep = new Deps.Dependency;
var timerUpdate = function () {
timerDep.changed();
};
Meteor.setInterval(timerUpdate, 60000 / LABORGENRATE);
Template.character.currentlabor = function() {
timerDep.depend();
var currentlabor = Math.floor((Date.now() - this.labortimestamp) / 1000 / 60 * LABORGENRATE) + this.labor;
return currentlabor;
};
Template.character.currentlaborcapped = function() {
timerDep.depend();
return Math.min(this.labormax,Math.floor((Date.now() - this.labortimestamp) / 1000 / 60 * LABORGENRATE) + this.labor);
};
// Returns the percentage of max labor, in integer format (50 for 50%)
Template.character.percentage = function() {
timerDep.depend();
var currentlabor = Math.floor((Date.now() - this.labortimestamp) / 1000 / 60 * LABORGENRATE) + this.labor;
return Math.min(100,Math.floor(currentlabor / this.labormax * 100))
};
// Returns the percentage of this character's max labor compared to,
// the character with the MOST max labor. Integer format (50 for 50%)
Template.character.percentagemax = function() {
if(Session.get('pref_scale_maxlabor')) {
return Math.min(100,Math.floor(this.labormax / highestMaxLabor() * 100))
} else {
return 100;
}
};
Template.character.laborcapped = function() {
timerDep.depend();
var currentlabor = Math.floor((Date.now() - this.labortimestamp) / 1000 / 60 * LABORGENRATE) + this.labor;
return (currentlabor >= this.labormax);
}
Template.character.laborwaste = function() {
timerDep.depend();
var currentlabor = Math.floor((Date.now() - this.labortimestamp) / 1000 / 60 * LABORGENRATE) + this.labor;
return Math.max(0,currentlabor - this.labormax);
}
Template.character.maxtimestring = function() {
var maxtimestamp = this.labortimestamp + (this.labormax - this.labor) * 1000 * 60 / LABORGENRATE;
var date = new Date(maxtimestamp);
var hour = date.getHours();
var minutes = date.getMinutes();
var day = date.getDay();
var hoursleft = Math.floor(Math.abs((maxtimestamp - Date.now()) / 1000 / 60 / 60))
var minutesleft = Math.floor(Math.abs((maxtimestamp - Date.now()) / 1000 / 60 % 60))
return DayStrings[day] + " " + formattime(hour,minutes)+" ("+hoursleft+"h "+minutesleft+"m)";
};
Template.character.events({
'click a.remove' : function () {
Characters.remove({_id: this._id});
},
'click div.name': function (evt, tmpl) { // start editing list name
Session.set('editing_charactername', this._id);
Meteor.flush(); // force DOM redraw, so we can focus the edit field
activateInput(tmpl.find("#character-name-input"));
},
'click div.labor': function (evt, tmpl) { // start editing list name
Session.set('editing_characterlabor', this._id);
Meteor.flush(); // force DOM redraw, so we can focus the edit field
activateInput(tmpl.find("#character-labor-input"));
},
'click div.labormax': function (evt, tmpl) { // start editing list name
Session.set('editing_characterlabormax', this._id);
Meteor.flush(); // force DOM redraw, so we can focus the edit field
activateInput(tmpl.find("#character-labormax-input"));
}
});
Template.character.events(okCancelEvents(
'#character-name-input', {
ok: function (value) {
Characters.update(this._id, {$set: {name: value}});
Session.set('editing_charactername', null);
},
cancel: function () {
Session.set('editing_charactername', null);
}
}
));
Template.character.events(okCancelEvents(
'#character-labor-input', {
ok: function (value) {
var newmaxtime = Date.now() + (this.labormax - Number(value)) * 1000 * 60 / LABORGENRATE;
Characters.update(this._id, {$set: {labor: Number(value), labortimestamp: Date.now(), maxtime: newmaxtime}});
Session.set('editing_characterlabor', null);
},
cancel: function () {
Session.set('editing_characterlabor', null);
}
}
));
Template.character.events(okCancelEvents(
'#character-labormax-input', {
ok: function (value) {
var newmaxtime = Date.now() + (Number(value) - this.labor) * 1000 * 60 / LABORGENRATE;
Characters.update(this._id, {$set: {labormax: Number(value), maxtime: newmaxtime}});
Session.set('editing_characterlabormax', null);
},
cancel: function () {
Session.set('editing_characterlabormax', null);
}
}
));
Template.character.editingname = function () {
return Session.equals('editing_charactername', this._id);
};
Template.character.editinglabor = function () {
return Session.equals('editing_characterlabor', this._id);
};
Template.character.editinglabormax = function () {
return Session.equals('editing_characterlabormax', this._id);
};
//} END EACH CHARACTER
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
// Upgrade database from earlier version
Timers.find({}, {}).fetch().forEach(function(timer) {
if (timer.endtime == null) {
console.log('Updating timer ' + timer._id);
Timers.update(timer._id, {$set: {endtime: timer.starttime + timer.timerlength * 1000}});
}
});
// Upgrade database from earlier version
Characters.find({}, {}).fetch().forEach(function(character) {
if (character.maxtime == null) {
console.log('Updating character ' + character._id);
var newmaxtime = character.labortimestamp + (character.labormax - character.labor) * 1000 * 60 / LABORGENRATE;
Characters.update(character._id, {$set: {maxtime: newmaxtime}});
}
});
});
} | OverloadUT/LaborTracker | LaborTracker.js | JavaScript | mit | 18,428 | [
30522,
13075,
3191,
2239,
2135,
1027,
6270,
1013,
1013,
2129,
2172,
4450,
2017,
9699,
2566,
3371,
13075,
4450,
6914,
11657,
1027,
1016,
1025,
2065,
1006,
3191,
2239,
2135,
1007,
1063,
1013,
1013,
2023,
2003,
2074,
2005,
4292,
2039,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 (1.8.0_25) on Thu Feb 02 09:05:26 ICT 2017 -->
<title>com.eggdigital.android.eggrating Class Hierarchy</title>
<meta name="date" content="2017-02-02">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="com.eggdigital.android.eggrating Class Hierarchy";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></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><a href="../../../../com/eggdigital/eggrating/package-tree.html">Next</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/eggdigital/android/eggrating/package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.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 class="title">Hierarchy For Package com.eggdigital.android.eggrating</h1>
<span class="packageHierarchyLabel">Package Hierarchies:</span>
<ul class="horizontal">
<li><a href="../../../../overview-tree.html">All Packages</a></li>
</ul>
</div>
<div class="contentContainer">
<h2 title="Class Hierarchy">Class Hierarchy</h2>
<ul>
<li type="circle">java.lang.Object
<ul>
<li type="circle">com.eggdigital.android.eggrating.<a href="../../../../com/eggdigital/android/eggrating/Constants.html" title="class in com.eggdigital.android.eggrating"><span class="typeNameLink">Constants</span></a></li>
<li type="circle">com.eggdigital.android.eggrating.<a href="../../../../com/eggdigital/android/eggrating/EggRating.html" title="class in com.eggdigital.android.eggrating"><span class="typeNameLink">EggRating</span></a></li>
<li type="circle">com.eggdigital.android.eggrating.<a href="../../../../com/eggdigital/android/eggrating/EggRating.Configuration.html" title="class in com.eggdigital.android.eggrating"><span class="typeNameLink">EggRating.Configuration</span></a></li>
</ul>
</li>
</ul>
<h2 title="Interface Hierarchy">Interface Hierarchy</h2>
<ul>
<li type="circle">com.eggdigital.android.eggrating.<a href="../../../../com/eggdigital/android/eggrating/EggRating.OnSelectCallBack.html" title="interface in com.eggdigital.android.eggrating"><span class="typeNameLink">EggRating.OnSelectCallBack</span></a></li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></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><a href="../../../../com/eggdigital/eggrating/package-tree.html">Next</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/eggdigital/android/eggrating/package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.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>
| ppyzza/EggRating | docs/com/eggdigital/android/eggrating/package-tree.html | HTML | apache-2.0 | 5,337 | [
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... |
// Mark Stankus 1999 (c)
// TestIO.c
#include "Source.hpp"
#include "Sink.hpp"
#include "Command.hpp"
#include "MyOstream.hpp"
void _GetInteger(Source & so, Sink & si) {
int x;
so >> x;
so.shouldBeEnd();
GBStream << "integer:" << x << '\n';
si.noOutput();
};
AddingCommand temp1TestIO("GetInteger",1,_GetInteger);
void _DoNothing(Source & so, Sink & si) {
so.shouldBeEnd();
si.noOutput();
};
AddingCommand temp2TestIO("DoNothing",0,_DoNothing);
void _GetSymbol(Source & so, Sink & si) {
symbolGB x;
so >> x;
so.shouldBeEnd();
GBStream << "symbol:" << x.value().chars() << '\n';
si.noOutput();
};
AddingCommand temp3TestIO("GetSymbol",1,_GetSymbol);
void _GetString(Source & so, Sink & si) {
symbolGB x;
so >> x;
so.shouldBeEnd();
GBStream << "symbol:" << x.value().chars() << '\n';
si.noOutput();
};
AddingCommand temp4TestIO("GetString",1,_GetString);
void _GetListInt(Source & so, Sink & si) {
int x;
Source so2(so.inputNamedFunction("List"));
while(!so2.eoi()) {
so2 >> x;
GBStream << "integer from list:" << x << '\n';
};
so.shouldBeEnd();
si.noOutput();
};
AddingCommand temp5TestIO("GetListInt",1,_GetListInt);
void _PutInteger(Source & so, Sink & si) {
so.shouldBeEnd();
si << 7;
};
AddingCommand temp6TestIO("PutInteger",0,_PutInteger);
void _PutSymbol(Source & so, Sink & si) {
symbolGB x("hi");
so.shouldBeEnd();
si << x;
};
AddingCommand temp7TestIO("PutSymbol",1,_PutSymbol);
void _PutString(Source & so, Sink & si) {
symbolGB x("there");
so.shouldBeEnd();
si << x;
};
AddingCommand temp8TestIO("PutString",1,_PutString);
void _PutListInt(Source & so, Sink & si) {
so.shouldBeEnd();
Sink si2(si.outputFunction("List",4));
si2 << 1;
si2 << 2;
si2 << 3;
si2 << 4;
};
AddingCommand temp9TestIO("PutListInt",1,_PutListInt);
| mcdeoliveira/NC | NCGB/Compile/src/OBSOLETE2009/TestIO.c | C | gpl-3.0 | 1,834 | [
30522,
1013,
1013,
2928,
9761,
22332,
2639,
1006,
1039,
1007,
1013,
1013,
3231,
3695,
1012,
1039,
1001,
2421,
1000,
3120,
1012,
6522,
2361,
1000,
1001,
2421,
1000,
7752,
1012,
6522,
2361,
1000,
1001,
2421,
1000,
3094,
1012,
6522,
2361,
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... |
<?php
namespace Sega\AppBundle\Command\Util;
use Dcs\DcsBaseCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Gaia\Bundle\HandlerSocketBundle\Parameter\Query;
use Gaia\Bundle\HandlerSocketBundle\Parameter\Table;
/**
* Symfonyコマンド実行のサンプル
* [参考] http://docs.symfony.gr.jp/symfony2/cookbook/console.html
*
* 実行方法
* [vagrant@localhost symfony]$ pwd
* /home/vagrant/public/symfony
* [vagrant@localhost symfony]$ php app/console sega:sample:test --user_id=1
*
*/
class ClearActionDataCommand extends DcsBaseCommand {
const DELDAY = 3; // この日数より前の情報を削除する
function configure() {
$this
->setName('arpg:clear_action_data')
->setDescription(self::DELDAY.'日以上古い、アクション情報を削除する')
;
}
function main(InputInterface $input, OutputInterface $output) {
$output->writeln(self::DELDAY."日以上古いアクションデータを削除");
$time = 3600*24*self::DELDAY;
$time = date("Y-m-d H:i:s",time()-$time);
$output->writeln('アクションブースト削除');
while(true){
$num = $this->getSql()->executeUpdate(
"delete from action_boost where create_date < ? limit 100",
[$time]
);
if($num < 1)
break;
$output->write('.');
sleep(1);
}
$output->writeln('');
$output->writeln('アクションガチャ削除');
while(true){
$num = $this->getSql()->executeUpdate(
"delete from action_gacha where create_date < ? limit 100",
[$time]
);
if($num < 1)
break;
$output->write('.');
sleep(1);
}
$output->writeln('');
$output->writeln('部屋削除');
while(true){
$num = $this->getSql()->executeUpdate(
"delete from action_room where `limit` < ? limit 100",
[$time]
);
if($num < 1)
break;
$output->write('.');
sleep(1);
}
$output->writeln('');
$output->writeln('マルチチケット削除');
while(true){
$num = $this->getSql()->executeUpdate(
"delete from action_ticket where create_time < ? limit 100",
[$time]
);
if($num < 1)
break;
$output->write('.');
sleep(1);
}
$output->writeln('');
$output->writeln('ガチャゲッター削除');
while(true){
$num = $this->getSql()->executeUpdate(
"delete from gacha_getter where get_date < ? limit 100",
[$time]
);
if($num < 1)
break;
$output->write('.');
sleep(1);
}
$output->writeln('');
$output->writeln('ゴースト履歴削除');
while(true){
$num = $this->getSql()->executeUpdate(
"delete from box_ghost where open_time < ? limit 100",
[$time]
);
if($num < 1)
break;
$output->write('.');
sleep(1);
}
$output->writeln('');
$output->writeln('ポップアップ削除');
$popup = $this->get('Arpg.Logic.PlayerData.HomePopup');
$t = new \Dcs\Arpg\Time();
$t->setMySQLDateTime($time);
$t = $popup->convertTime($t);
while(true){
$num = $this->getSql()->executeUpdate(
"delete from box_home_popup where time < ?",
[$t]
);
if($num < 1)
break;
$output->write('.');
sleep(1);
}
$output->writeln('');
$output->writeln('削除完了');
}
} | fusioncop/symfony | src/Sega/AppBundle/Command/Util/ClearActionDataCommand.php | PHP | mit | 3,330 | [
30522,
1026,
1029,
25718,
3415,
15327,
16562,
1032,
10439,
27265,
2571,
1032,
3094,
1032,
21183,
4014,
1025,
2224,
5887,
2015,
1032,
5887,
19022,
11022,
9006,
2386,
2094,
1025,
2224,
25353,
2213,
14876,
4890,
1032,
6922,
1032,
10122,
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... |
/* Intel PRO/1000 Linux driver
* Copyright(c) 1999 - 2015 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
* Contact Information:
* Linux NICS <linux.nics@intel.com>
* e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*/
/* 82562G 10/100 Network Connection
* 82562G-2 10/100 Network Connection
* 82562GT 10/100 Network Connection
* 82562GT-2 10/100 Network Connection
* 82562V 10/100 Network Connection
* 82562V-2 10/100 Network Connection
* 82566DC-2 Gigabit Network Connection
* 82566DC Gigabit Network Connection
* 82566DM-2 Gigabit Network Connection
* 82566DM Gigabit Network Connection
* 82566MC Gigabit Network Connection
* 82566MM Gigabit Network Connection
* 82567LM Gigabit Network Connection
* 82567LF Gigabit Network Connection
* 82567V Gigabit Network Connection
* 82567LM-2 Gigabit Network Connection
* 82567LF-2 Gigabit Network Connection
* 82567V-2 Gigabit Network Connection
* 82567LF-3 Gigabit Network Connection
* 82567LM-3 Gigabit Network Connection
* 82567LM-4 Gigabit Network Connection
* 82577LM Gigabit Network Connection
* 82577LC Gigabit Network Connection
* 82578DM Gigabit Network Connection
* 82578DC Gigabit Network Connection
* 82579LM Gigabit Network Connection
* 82579V Gigabit Network Connection
* Ethernet Connection I217-LM
* Ethernet Connection I217-V
* Ethernet Connection I218-V
* Ethernet Connection I218-LM
* Ethernet Connection (2) I218-LM
* Ethernet Connection (2) I218-V
* Ethernet Connection (3) I218-LM
* Ethernet Connection (3) I218-V
*/
#include "e1000.h"
/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
/* Offset 04h HSFSTS */
union ich8_hws_flash_status
{
struct ich8_hsfsts
{
u16 flcdone: 1; /* bit 0 Flash Cycle Done */
u16 flcerr: 1; /* bit 1 Flash Cycle Error */
u16 dael: 1; /* bit 2 Direct Access error Log */
u16 berasesz: 2; /* bit 4:3 Sector Erase Size */
u16 flcinprog: 1; /* bit 5 flash cycle in Progress */
u16 reserved1: 2; /* bit 13:6 Reserved */
u16 reserved2: 6; /* bit 13:6 Reserved */
u16 fldesvalid: 1; /* bit 14 Flash Descriptor Valid */
u16 flockdn: 1; /* bit 15 Flash Config Lock-Down */
} hsf_status;
u16 regval;
};
/* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
/* Offset 06h FLCTL */
union ich8_hws_flash_ctrl
{
struct ich8_hsflctl
{
u16 flcgo: 1; /* 0 Flash Cycle Go */
u16 flcycle: 2; /* 2:1 Flash Cycle */
u16 reserved: 5; /* 7:3 Reserved */
u16 fldbcount: 2; /* 9:8 Flash Data Byte Count */
u16 flockdn: 6; /* 15:10 Reserved */
} hsf_ctrl;
u16 regval;
};
/* ICH Flash Region Access Permissions */
union ich8_hws_flash_regacc
{
struct ich8_flracc
{
u32 grra: 8; /* 0:7 GbE region Read Access */
u32 grwa: 8; /* 8:15 GbE region Write Access */
u32 gmrag: 8; /* 23:16 GbE Master Read Access Grant */
u32 gmwag: 8; /* 31:24 GbE Master Write Access Grant */
} hsf_flregacc;
u16 regval;
};
/* ICH Flash Protected Region */
union ich8_flash_protected_range
{
struct ich8_pr
{
u32 base: 13; /* 0:12 Protected Range Base */
u32 reserved1: 2; /* 13:14 Reserved */
u32 rpe: 1; /* 15 Read Protection Enable */
u32 limit: 13; /* 16:28 Protected Range Limit */
u32 reserved2: 2; /* 29:30 Reserved */
u32 wpe: 1; /* 31 Write Protection Enable */
} range;
u32 regval;
};
static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
u32 offset, u8 byte);
static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
u8 *data);
static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
u16 *data);
static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
u8 size, u16 *data);
static s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
u32 *data);
static s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw,
u32 offset, u32 *data);
static s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw,
u32 offset, u32 data);
static s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
u32 offset, u32 dword);
static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
static int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index);
static int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index);
static u32 e1000_rar_get_count_pch_lpt(struct e1000_hw *hw);
static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force);
static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw);
static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state);
static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
{
return readw(hw->flash_address + reg);
}
static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
{
return readl(hw->flash_address + reg);
}
static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
{
writew(val, hw->flash_address + reg);
}
static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
{
writel(val, hw->flash_address + reg);
}
#define er16flash(reg) __er16flash(hw, (reg))
#define er32flash(reg) __er32flash(hw, (reg))
#define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
#define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
/**
* e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
* @hw: pointer to the HW structure
*
* Test access to the PHY registers by reading the PHY ID registers. If
* the PHY ID is already known (e.g. resume path) compare it with known ID,
* otherwise assume the read PHY ID is correct if it is valid.
*
* Assumes the sw/fw/hw semaphore is already acquired.
**/
static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
{
u16 phy_reg = 0;
u32 phy_id = 0;
s32 ret_val = 0;
u16 retry_count;
u32 mac_reg = 0;
for (retry_count = 0; retry_count < 2; retry_count++)
{
ret_val = e1e_rphy_locked(hw, MII_PHYSID1, &phy_reg);
if (ret_val || (phy_reg == 0xFFFF))
{
continue;
}
phy_id = (u32)(phy_reg << 16);
ret_val = e1e_rphy_locked(hw, MII_PHYSID2, &phy_reg);
if (ret_val || (phy_reg == 0xFFFF))
{
phy_id = 0;
continue;
}
phy_id |= (u32)(phy_reg & PHY_REVISION_MASK);
break;
}
if (hw->phy.id)
{
if (hw->phy.id == phy_id)
{
goto out;
}
}
else if (phy_id)
{
hw->phy.id = phy_id;
hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK);
goto out;
}
/* In case the PHY needs to be in mdio slow mode,
* set slow mode and try to get the PHY id again.
*/
if (hw->mac.type < e1000_pch_lpt)
{
hw->phy.ops.release(hw);
ret_val = e1000_set_mdio_slow_mode_hv(hw);
if (!ret_val)
{
ret_val = e1000e_get_phy_id(hw);
}
hw->phy.ops.acquire(hw);
}
if (ret_val)
{
return false;
}
out:
if ((hw->mac.type == e1000_pch_lpt) || (hw->mac.type == e1000_pch_spt))
{
/* Only unforce SMBus if ME is not active */
if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
{
/* Unforce SMBus mode in PHY */
e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg);
phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg);
/* Unforce SMBus mode in MAC */
mac_reg = er32(CTRL_EXT);
mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
ew32(CTRL_EXT, mac_reg);
}
}
return true;
}
/**
* e1000_toggle_lanphypc_pch_lpt - toggle the LANPHYPC pin value
* @hw: pointer to the HW structure
*
* Toggling the LANPHYPC pin value fully power-cycles the PHY and is
* used to reset the PHY to a quiescent state when necessary.
**/
static void e1000_toggle_lanphypc_pch_lpt(struct e1000_hw *hw)
{
u32 mac_reg;
/* Set Phy Config Counter to 50msec */
mac_reg = er32(FEXTNVM3);
mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
ew32(FEXTNVM3, mac_reg);
/* Toggle LANPHYPC Value bit */
mac_reg = er32(CTRL);
mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE;
mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE;
ew32(CTRL, mac_reg);
e1e_flush();
usleep_range(10, 20);
mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
ew32(CTRL, mac_reg);
e1e_flush();
if (hw->mac.type < e1000_pch_lpt)
{
msleep(50);
}
else
{
u16 count = 20;
do
{
usleep_range(5000, 10000);
}
while (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LPCD) && count--);
msleep(30);
}
}
/**
* e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
* @hw: pointer to the HW structure
*
* Workarounds/flow necessary for PHY initialization during driver load
* and resume paths.
**/
static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)
{
struct e1000_adapter *adapter = hw->adapter;
u32 mac_reg, fwsm = er32(FWSM);
s32 ret_val;
/* Gate automatic PHY configuration by hardware on managed and
* non-managed 82579 and newer adapters.
*/
e1000_gate_hw_phy_config_ich8lan(hw, true);
/* It is not possible to be certain of the current state of ULP
* so forcibly disable it.
*/
hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_unknown;
e1000_disable_ulp_lpt_lp(hw, true);
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
e_dbg("Failed to initialize PHY flow\n");
goto out;
}
/* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
* inaccessible and resetting the PHY is not blocked, toggle the
* LANPHYPC Value bit to force the interconnect to PCIe mode.
*/
switch (hw->mac.type)
{
case e1000_pch_lpt:
case e1000_pch_spt:
if (e1000_phy_is_accessible_pchlan(hw))
{
break;
}
/* Before toggling LANPHYPC, see if PHY is accessible by
* forcing MAC to SMBus mode first.
*/
mac_reg = er32(CTRL_EXT);
mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
ew32(CTRL_EXT, mac_reg);
/* Wait 50 milliseconds for MAC to finish any retries
* that it might be trying to perform from previous
* attempts to acknowledge any phy read requests.
*/
msleep(50);
/* fall-through */
case e1000_pch2lan:
if (e1000_phy_is_accessible_pchlan(hw))
{
break;
}
/* fall-through */
case e1000_pchlan:
if ((hw->mac.type == e1000_pchlan) &&
(fwsm & E1000_ICH_FWSM_FW_VALID))
{
break;
}
if (hw->phy.ops.check_reset_block(hw))
{
e_dbg("Required LANPHYPC toggle blocked by ME\n");
ret_val = -E1000_ERR_PHY;
break;
}
/* Toggle LANPHYPC Value bit */
e1000_toggle_lanphypc_pch_lpt(hw);
if (hw->mac.type >= e1000_pch_lpt)
{
if (e1000_phy_is_accessible_pchlan(hw))
{
break;
}
/* Toggling LANPHYPC brings the PHY out of SMBus mode
* so ensure that the MAC is also out of SMBus mode
*/
mac_reg = er32(CTRL_EXT);
mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
ew32(CTRL_EXT, mac_reg);
if (e1000_phy_is_accessible_pchlan(hw))
{
break;
}
ret_val = -E1000_ERR_PHY;
}
break;
default:
break;
}
hw->phy.ops.release(hw);
if (!ret_val)
{
/* Check to see if able to reset PHY. Print error if not */
if (hw->phy.ops.check_reset_block(hw))
{
e_err("Reset blocked by ME\n");
goto out;
}
/* Reset the PHY before any access to it. Doing so, ensures
* that the PHY is in a known good state before we read/write
* PHY registers. The generic reset is sufficient here,
* because we haven't determined the PHY type yet.
*/
ret_val = e1000e_phy_hw_reset_generic(hw);
if (ret_val)
{
goto out;
}
/* On a successful reset, possibly need to wait for the PHY
* to quiesce to an accessible state before returning control
* to the calling function. If the PHY does not quiesce, then
* return E1000E_BLK_PHY_RESET, as this is the condition that
* the PHY is in.
*/
ret_val = hw->phy.ops.check_reset_block(hw);
if (ret_val)
{
e_err("ME blocked access to PHY after reset\n");
}
}
out:
/* Ungate automatic PHY configuration on non-managed 82579 */
if ((hw->mac.type == e1000_pch2lan) &&
!(fwsm & E1000_ICH_FWSM_FW_VALID))
{
usleep_range(10000, 20000);
e1000_gate_hw_phy_config_ich8lan(hw, false);
}
return ret_val;
}
/**
* e1000_init_phy_params_pchlan - Initialize PHY function pointers
* @hw: pointer to the HW structure
*
* Initialize family-specific PHY parameters and function pointers.
**/
static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
{
struct e1000_phy_info *phy = &hw->phy;
s32 ret_val;
phy->addr = 1;
phy->reset_delay_us = 100;
phy->ops.set_page = e1000_set_page_igp;
phy->ops.read_reg = e1000_read_phy_reg_hv;
phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked;
phy->ops.read_reg_page = e1000_read_phy_reg_page_hv;
phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan;
phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan;
phy->ops.write_reg = e1000_write_phy_reg_hv;
phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked;
phy->ops.write_reg_page = e1000_write_phy_reg_page_hv;
phy->ops.power_up = e1000_power_up_phy_copper;
phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
phy->id = e1000_phy_unknown;
ret_val = e1000_init_phy_workarounds_pchlan(hw);
if (ret_val)
{
return ret_val;
}
if (phy->id == e1000_phy_unknown)
switch (hw->mac.type)
{
default:
ret_val = e1000e_get_phy_id(hw);
if (ret_val)
{
return ret_val;
}
if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
{
break;
}
/* fall-through */
case e1000_pch2lan:
case e1000_pch_lpt:
case e1000_pch_spt:
/* In case the PHY needs to be in mdio slow mode,
* set slow mode and try to get the PHY id again.
*/
ret_val = e1000_set_mdio_slow_mode_hv(hw);
if (ret_val)
{
return ret_val;
}
ret_val = e1000e_get_phy_id(hw);
if (ret_val)
{
return ret_val;
}
break;
}
phy->type = e1000e_get_phy_type_from_id(phy->id);
switch (phy->type)
{
case e1000_phy_82577:
case e1000_phy_82579:
case e1000_phy_i217:
phy->ops.check_polarity = e1000_check_polarity_82577;
phy->ops.force_speed_duplex =
e1000_phy_force_speed_duplex_82577;
phy->ops.get_cable_length = e1000_get_cable_length_82577;
phy->ops.get_info = e1000_get_phy_info_82577;
phy->ops.commit = e1000e_phy_sw_reset;
break;
case e1000_phy_82578:
phy->ops.check_polarity = e1000_check_polarity_m88;
phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
phy->ops.get_cable_length = e1000e_get_cable_length_m88;
phy->ops.get_info = e1000e_get_phy_info_m88;
break;
default:
ret_val = -E1000_ERR_PHY;
break;
}
return ret_val;
}
/**
* e1000_init_phy_params_ich8lan - Initialize PHY function pointers
* @hw: pointer to the HW structure
*
* Initialize family-specific PHY parameters and function pointers.
**/
static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
{
struct e1000_phy_info *phy = &hw->phy;
s32 ret_val;
u16 i = 0;
phy->addr = 1;
phy->reset_delay_us = 100;
phy->ops.power_up = e1000_power_up_phy_copper;
phy->ops.power_down = e1000_power_down_phy_copper_ich8lan;
/* We may need to do this twice - once for IGP and if that fails,
* we'll set BM func pointers and try again
*/
ret_val = e1000e_determine_phy_address(hw);
if (ret_val)
{
phy->ops.write_reg = e1000e_write_phy_reg_bm;
phy->ops.read_reg = e1000e_read_phy_reg_bm;
ret_val = e1000e_determine_phy_address(hw);
if (ret_val)
{
e_dbg("Cannot determine PHY addr. Erroring out\n");
return ret_val;
}
}
phy->id = 0;
while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
(i++ < 100))
{
usleep_range(1000, 2000);
ret_val = e1000e_get_phy_id(hw);
if (ret_val)
{
return ret_val;
}
}
/* Verify phy id */
switch (phy->id)
{
case IGP03E1000_E_PHY_ID:
phy->type = e1000_phy_igp_3;
phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
phy->ops.get_info = e1000e_get_phy_info_igp;
phy->ops.check_polarity = e1000_check_polarity_igp;
phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
break;
case IFE_E_PHY_ID:
case IFE_PLUS_E_PHY_ID:
case IFE_C_E_PHY_ID:
phy->type = e1000_phy_ife;
phy->autoneg_mask = E1000_ALL_NOT_GIG;
phy->ops.get_info = e1000_get_phy_info_ife;
phy->ops.check_polarity = e1000_check_polarity_ife;
phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
break;
case BME1000_E_PHY_ID:
phy->type = e1000_phy_bm;
phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
phy->ops.read_reg = e1000e_read_phy_reg_bm;
phy->ops.write_reg = e1000e_write_phy_reg_bm;
phy->ops.commit = e1000e_phy_sw_reset;
phy->ops.get_info = e1000e_get_phy_info_m88;
phy->ops.check_polarity = e1000_check_polarity_m88;
phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
break;
default:
return -E1000_ERR_PHY;
}
return 0;
}
/**
* e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
* @hw: pointer to the HW structure
*
* Initialize family-specific NVM parameters and function
* pointers.
**/
static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
{
struct e1000_nvm_info *nvm = &hw->nvm;
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u32 gfpreg, sector_base_addr, sector_end_addr;
u16 i;
u32 nvm_size;
nvm->type = e1000_nvm_flash_sw;
if (hw->mac.type == e1000_pch_spt)
{
/* in SPT, gfpreg doesn't exist. NVM size is taken from the
* STRAP register. This is because in SPT the GbE Flash region
* is no longer accessed through the flash registers. Instead,
* the mechanism has changed, and the Flash region access
* registers are now implemented in GbE memory space.
*/
nvm->flash_base_addr = 0;
nvm_size = (((er32(STRAP) >> 1) & 0x1F) + 1)
* NVM_SIZE_MULTIPLIER;
nvm->flash_bank_size = nvm_size / 2;
/* Adjust to word count */
nvm->flash_bank_size /= sizeof(u16);
/* Set the base address for flash register access */
hw->flash_address = hw->hw_addr + E1000_FLASH_BASE_ADDR;
}
else
{
/* Can't read flash registers if register set isn't mapped. */
if (!hw->flash_address)
{
e_dbg("ERROR: Flash registers not mapped\n");
return -E1000_ERR_CONFIG;
}
gfpreg = er32flash(ICH_FLASH_GFPREG);
/* sector_X_addr is a "sector"-aligned address (4096 bytes)
* Add 1 to sector_end_addr since this sector is included in
* the overall size.
*/
sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
/* flash_base_addr is byte-aligned */
nvm->flash_base_addr = sector_base_addr
<< FLASH_SECTOR_ADDR_SHIFT;
/* find total size of the NVM, then cut in half since the total
* size represents two separate NVM banks.
*/
nvm->flash_bank_size = ((sector_end_addr - sector_base_addr)
<< FLASH_SECTOR_ADDR_SHIFT);
nvm->flash_bank_size /= 2;
/* Adjust to word count */
nvm->flash_bank_size /= sizeof(u16);
}
nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
/* Clear shadow ram */
for (i = 0; i < nvm->word_size; i++)
{
dev_spec->shadow_ram[i].modified = false;
dev_spec->shadow_ram[i].value = 0xFFFF;
}
return 0;
}
/**
* e1000_init_mac_params_ich8lan - Initialize MAC function pointers
* @hw: pointer to the HW structure
*
* Initialize family-specific MAC parameters and function
* pointers.
**/
static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)
{
struct e1000_mac_info *mac = &hw->mac;
/* Set media type function pointer */
hw->phy.media_type = e1000_media_type_copper;
/* Set mta register count */
mac->mta_reg_count = 32;
/* Set rar entry count */
mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
if (mac->type == e1000_ich8lan)
{
mac->rar_entry_count--;
}
/* FWSM register */
mac->has_fwsm = true;
/* ARC subsystem not supported */
mac->arc_subsystem_valid = false;
/* Adaptive IFS supported */
mac->adaptive_ifs = true;
/* LED and other operations */
switch (mac->type)
{
case e1000_ich8lan:
case e1000_ich9lan:
case e1000_ich10lan:
/* check management mode */
mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
/* ID LED init */
mac->ops.id_led_init = e1000e_id_led_init_generic;
/* blink LED */
mac->ops.blink_led = e1000e_blink_led_generic;
/* setup LED */
mac->ops.setup_led = e1000e_setup_led_generic;
/* cleanup LED */
mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
/* turn on/off LED */
mac->ops.led_on = e1000_led_on_ich8lan;
mac->ops.led_off = e1000_led_off_ich8lan;
break;
case e1000_pch2lan:
mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES;
mac->ops.rar_set = e1000_rar_set_pch2lan;
/* fall-through */
case e1000_pch_lpt:
case e1000_pch_spt:
case e1000_pchlan:
/* check management mode */
mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
/* ID LED init */
mac->ops.id_led_init = e1000_id_led_init_pchlan;
/* setup LED */
mac->ops.setup_led = e1000_setup_led_pchlan;
/* cleanup LED */
mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
/* turn on/off LED */
mac->ops.led_on = e1000_led_on_pchlan;
mac->ops.led_off = e1000_led_off_pchlan;
break;
default:
break;
}
if ((mac->type == e1000_pch_lpt) || (mac->type == e1000_pch_spt))
{
mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES;
mac->ops.rar_set = e1000_rar_set_pch_lpt;
mac->ops.setup_physical_interface =
e1000_setup_copper_link_pch_lpt;
mac->ops.rar_get_count = e1000_rar_get_count_pch_lpt;
}
/* Enable PCS Lock-loss workaround for ICH8 */
if (mac->type == e1000_ich8lan)
{
e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
}
return 0;
}
/**
* __e1000_access_emi_reg_locked - Read/write EMI register
* @hw: pointer to the HW structure
* @addr: EMI address to program
* @data: pointer to value to read/write from/to the EMI address
* @read: boolean flag to indicate read or write
*
* This helper function assumes the SW/FW/HW Semaphore is already acquired.
**/
static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address,
u16 *data, bool read)
{
s32 ret_val;
ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address);
if (ret_val)
{
return ret_val;
}
if (read)
{
ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data);
}
else
{
ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data);
}
return ret_val;
}
/**
* e1000_read_emi_reg_locked - Read Extended Management Interface register
* @hw: pointer to the HW structure
* @addr: EMI address to program
* @data: value to be read from the EMI address
*
* Assumes the SW/FW/HW Semaphore is already acquired.
**/
s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data)
{
return __e1000_access_emi_reg_locked(hw, addr, data, true);
}
/**
* e1000_write_emi_reg_locked - Write Extended Management Interface register
* @hw: pointer to the HW structure
* @addr: EMI address to program
* @data: value to be written to the EMI address
*
* Assumes the SW/FW/HW Semaphore is already acquired.
**/
s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data)
{
return __e1000_access_emi_reg_locked(hw, addr, &data, false);
}
/**
* e1000_set_eee_pchlan - Enable/disable EEE support
* @hw: pointer to the HW structure
*
* Enable/disable EEE based on setting in dev_spec structure, the duplex of
* the link and the EEE capabilities of the link partner. The LPI Control
* register bits will remain set only if/when link is up.
*
* EEE LPI must not be asserted earlier than one second after link is up.
* On 82579, EEE LPI should not be enabled until such time otherwise there
* can be link issues with some switches. Other devices can have EEE LPI
* enabled immediately upon link up since they have a timer in hardware which
* prevents LPI from being asserted too early.
**/
s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
{
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
s32 ret_val;
u16 lpa, pcs_status, adv, adv_addr, lpi_ctrl, data;
switch (hw->phy.type)
{
case e1000_phy_82579:
lpa = I82579_EEE_LP_ABILITY;
pcs_status = I82579_EEE_PCS_STATUS;
adv_addr = I82579_EEE_ADVERTISEMENT;
break;
case e1000_phy_i217:
lpa = I217_EEE_LP_ABILITY;
pcs_status = I217_EEE_PCS_STATUS;
adv_addr = I217_EEE_ADVERTISEMENT;
break;
default:
return 0;
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
ret_val = e1e_rphy_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);
if (ret_val)
{
goto release;
}
/* Clear bits that enable EEE in various speeds */
lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK;
/* Enable EEE if not disabled by user */
if (!dev_spec->eee_disable)
{
/* Save off link partner's EEE ability */
ret_val = e1000_read_emi_reg_locked(hw, lpa,
&dev_spec->eee_lp_ability);
if (ret_val)
{
goto release;
}
/* Read EEE advertisement */
ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &adv);
if (ret_val)
{
goto release;
}
/* Enable EEE only for speeds in which the link partner is
* EEE capable and for which we advertise EEE.
*/
if (adv & dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED)
{
lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE;
}
if (adv & dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED)
{
e1e_rphy_locked(hw, MII_LPA, &data);
if (data & LPA_100FULL)
{
lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE;
}
else
/* EEE is not supported in 100Half, so ignore
* partner's EEE in 100 ability if full-duplex
* is not advertised.
*/
dev_spec->eee_lp_ability &=
~I82579_EEE_100_SUPPORTED;
}
}
if (hw->phy.type == e1000_phy_82579)
{
ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
&data);
if (ret_val)
{
goto release;
}
data &= ~I82579_LPI_100_PLL_SHUT;
ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
data);
}
/* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
if (ret_val)
{
goto release;
}
ret_val = e1e_wphy_locked(hw, I82579_LPI_CTRL, lpi_ctrl);
release:
hw->phy.ops.release(hw);
return ret_val;
}
/**
* e1000_k1_workaround_lpt_lp - K1 workaround on Lynxpoint-LP
* @hw: pointer to the HW structure
* @link: link up bool flag
*
* When K1 is enabled for 1Gbps, the MAC can miss 2 DMA completion indications
* preventing further DMA write requests. Workaround the issue by disabling
* the de-assertion of the clock request when in 1Gpbs mode.
* Also, set appropriate Tx re-transmission timeouts for 10 and 100Half link
* speeds in order to avoid Tx hangs.
**/
static s32 e1000_k1_workaround_lpt_lp(struct e1000_hw *hw, bool link)
{
u32 fextnvm6 = er32(FEXTNVM6);
u32 status = er32(STATUS);
s32 ret_val = 0;
u16 reg;
if (link && (status & E1000_STATUS_SPEED_1000))
{
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
ret_val =
e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
®);
if (ret_val)
{
goto release;
}
ret_val =
e1000e_write_kmrn_reg_locked(hw,
E1000_KMRNCTRLSTA_K1_CONFIG,
reg &
~E1000_KMRNCTRLSTA_K1_ENABLE);
if (ret_val)
{
goto release;
}
usleep_range(10, 20);
ew32(FEXTNVM6, fextnvm6 | E1000_FEXTNVM6_REQ_PLL_CLK);
ret_val =
e1000e_write_kmrn_reg_locked(hw,
E1000_KMRNCTRLSTA_K1_CONFIG,
reg);
release:
hw->phy.ops.release(hw);
}
else
{
/* clear FEXTNVM6 bit 8 on link down or 10/100 */
fextnvm6 &= ~E1000_FEXTNVM6_REQ_PLL_CLK;
if ((hw->phy.revision > 5) || !link ||
((status & E1000_STATUS_SPEED_100) &&
(status & E1000_STATUS_FD)))
{
goto update_fextnvm6;
}
ret_val = e1e_rphy(hw, I217_INBAND_CTRL, ®);
if (ret_val)
{
return ret_val;
}
/* Clear link status transmit timeout */
reg &= ~I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_MASK;
if (status & E1000_STATUS_SPEED_100)
{
/* Set inband Tx timeout to 5x10us for 100Half */
reg |= 5 << I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
/* Do not extend the K1 entry latency for 100Half */
fextnvm6 &= ~E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
}
else
{
/* Set inband Tx timeout to 50x10us for 10Full/Half */
reg |= 50 <<
I217_INBAND_CTRL_LINK_STAT_TX_TIMEOUT_SHIFT;
/* Extend the K1 entry latency for 10 Mbps */
fextnvm6 |= E1000_FEXTNVM6_ENABLE_K1_ENTRY_CONDITION;
}
ret_val = e1e_wphy(hw, I217_INBAND_CTRL, reg);
if (ret_val)
{
return ret_val;
}
update_fextnvm6:
ew32(FEXTNVM6, fextnvm6);
}
return ret_val;
}
/**
* e1000_platform_pm_pch_lpt - Set platform power management values
* @hw: pointer to the HW structure
* @link: bool indicating link status
*
* Set the Latency Tolerance Reporting (LTR) values for the "PCIe-like"
* GbE MAC in the Lynx Point PCH based on Rx buffer size and link speed
* when link is up (which must not exceed the maximum latency supported
* by the platform), otherwise specify there is no LTR requirement.
* Unlike true-PCIe devices which set the LTR maximum snoop/no-snoop
* latencies in the LTR Extended Capability Structure in the PCIe Extended
* Capability register set, on this device LTR is set by writing the
* equivalent snoop/no-snoop latencies in the LTRV register in the MAC and
* set the SEND bit to send an Intel On-chip System Fabric sideband (IOSF-SB)
* message to the PMC.
**/
static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
{
u32 reg = link << (E1000_LTRV_REQ_SHIFT + E1000_LTRV_NOSNOOP_SHIFT) |
link << E1000_LTRV_REQ_SHIFT | E1000_LTRV_SEND;
u16 lat_enc = 0; /* latency encoded */
if (link)
{
u16 speed, duplex, scale = 0;
u16 max_snoop, max_nosnoop;
u16 max_ltr_enc; /* max LTR latency encoded */
u64 value;
u32 rxa;
if (!hw->adapter->max_frame_size)
{
e_dbg("max_frame_size not set.\n");
return -E1000_ERR_CONFIG;
}
hw->mac.ops.get_link_up_info(hw, &speed, &duplex);
if (!speed)
{
e_dbg("Speed not set.\n");
return -E1000_ERR_CONFIG;
}
/* Rx Packet Buffer Allocation size (KB) */
rxa = er32(PBA) & E1000_PBA_RXA_MASK;
/* Determine the maximum latency tolerated by the device.
*
* Per the PCIe spec, the tolerated latencies are encoded as
* a 3-bit encoded scale (only 0-5 are valid) multiplied by
* a 10-bit value (0-1023) to provide a range from 1 ns to
* 2^25*(2^10-1) ns. The scale is encoded as 0=2^0ns,
* 1=2^5ns, 2=2^10ns,...5=2^25ns.
*/
rxa *= 512;
value = (rxa > hw->adapter->max_frame_size) ?
(rxa - hw->adapter->max_frame_size) * (16000 / speed) :
0;
while (value > PCI_LTR_VALUE_MASK)
{
scale++;
value = DIV_ROUND_UP(value, BIT(5));
}
if (scale > E1000_LTRV_SCALE_MAX)
{
e_dbg("Invalid LTR latency scale %d\n", scale);
return -E1000_ERR_CONFIG;
}
lat_enc = (u16)((scale << PCI_LTR_SCALE_SHIFT) | value);
/* Determine the maximum latency tolerated by the platform */
pci_read_config_word(hw->adapter->pdev, E1000_PCI_LTR_CAP_LPT,
&max_snoop);
pci_read_config_word(hw->adapter->pdev,
E1000_PCI_LTR_CAP_LPT + 2, &max_nosnoop);
max_ltr_enc = max_t(u16, max_snoop, max_nosnoop);
if (lat_enc > max_ltr_enc)
{
lat_enc = max_ltr_enc;
}
}
/* Set Snoop and No-Snoop latencies the same */
reg |= lat_enc | (lat_enc << E1000_LTRV_NOSNOOP_SHIFT);
ew32(LTRV, reg);
return 0;
}
/**
* e1000_enable_ulp_lpt_lp - configure Ultra Low Power mode for LynxPoint-LP
* @hw: pointer to the HW structure
* @to_sx: boolean indicating a system power state transition to Sx
*
* When link is down, configure ULP mode to significantly reduce the power
* to the PHY. If on a Manageability Engine (ME) enabled system, tell the
* ME firmware to start the ULP configuration. If not on an ME enabled
* system, configure the ULP mode by software.
*/
s32 e1000_enable_ulp_lpt_lp(struct e1000_hw *hw, bool to_sx)
{
u32 mac_reg;
s32 ret_val = 0;
u16 phy_reg;
u16 oem_reg = 0;
if ((hw->mac.type < e1000_pch_lpt) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_LM) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_V) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM2) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V2) ||
(hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_on))
{
return 0;
}
if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID)
{
/* Request ME configure ULP mode in the PHY */
mac_reg = er32(H2ME);
mac_reg |= E1000_H2ME_ULP | E1000_H2ME_ENFORCE_SETTINGS;
ew32(H2ME, mac_reg);
goto out;
}
if (!to_sx)
{
int i = 0;
/* Poll up to 5 seconds for Cable Disconnected indication */
while (!(er32(FEXT) & E1000_FEXT_PHY_CABLE_DISCONNECTED))
{
/* Bail if link is re-acquired */
if (er32(STATUS) & E1000_STATUS_LU)
{
return -E1000_ERR_PHY;
}
if (i++ == 100)
{
break;
}
msleep(50);
}
e_dbg("CABLE_DISCONNECTED %s set after %dmsec\n",
(er32(FEXT) &
E1000_FEXT_PHY_CABLE_DISCONNECTED) ? "" : "not", i * 50);
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
goto out;
}
/* Force SMBus mode in PHY */
ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
if (ret_val)
{
goto release;
}
phy_reg |= CV_SMB_CTRL_FORCE_SMBUS;
e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
/* Force SMBus mode in MAC */
mac_reg = er32(CTRL_EXT);
mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
ew32(CTRL_EXT, mac_reg);
/* Si workaround for ULP entry flow on i127/rev6 h/w. Enable
* LPLU and disable Gig speed when entering ULP
*/
if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6))
{
ret_val = e1000_read_phy_reg_hv_locked(hw, HV_OEM_BITS,
&oem_reg);
if (ret_val)
{
goto release;
}
phy_reg = oem_reg;
phy_reg |= HV_OEM_BITS_LPLU | HV_OEM_BITS_GBE_DIS;
ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
phy_reg);
if (ret_val)
{
goto release;
}
}
/* Set Inband ULP Exit, Reset to SMBus mode and
* Disable SMBus Release on PERST# in PHY
*/
ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
if (ret_val)
{
goto release;
}
phy_reg |= (I218_ULP_CONFIG1_RESET_TO_SMBUS |
I218_ULP_CONFIG1_DISABLE_SMB_PERST);
if (to_sx)
{
if (er32(WUFC) & E1000_WUFC_LNKC)
{
phy_reg |= I218_ULP_CONFIG1_WOL_HOST;
}
else
{
phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
}
phy_reg |= I218_ULP_CONFIG1_STICKY_ULP;
phy_reg &= ~I218_ULP_CONFIG1_INBAND_EXIT;
}
else
{
phy_reg |= I218_ULP_CONFIG1_INBAND_EXIT;
phy_reg &= ~I218_ULP_CONFIG1_STICKY_ULP;
phy_reg &= ~I218_ULP_CONFIG1_WOL_HOST;
}
e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
/* Set Disable SMBus Release on PERST# in MAC */
mac_reg = er32(FEXTNVM7);
mac_reg |= E1000_FEXTNVM7_DISABLE_SMB_PERST;
ew32(FEXTNVM7, mac_reg);
/* Commit ULP changes in PHY by starting auto ULP configuration */
phy_reg |= I218_ULP_CONFIG1_START;
e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
if ((hw->phy.type == e1000_phy_i217) && (hw->phy.revision == 6) &&
to_sx && (er32(STATUS) & E1000_STATUS_LU))
{
ret_val = e1000_write_phy_reg_hv_locked(hw, HV_OEM_BITS,
oem_reg);
if (ret_val)
{
goto release;
}
}
release:
hw->phy.ops.release(hw);
out:
if (ret_val)
{
e_dbg("Error in ULP enable flow: %d\n", ret_val);
}
else
{
hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_on;
}
return ret_val;
}
/**
* e1000_disable_ulp_lpt_lp - unconfigure Ultra Low Power mode for LynxPoint-LP
* @hw: pointer to the HW structure
* @force: boolean indicating whether or not to force disabling ULP
*
* Un-configure ULP mode when link is up, the system is transitioned from
* Sx or the driver is unloaded. If on a Manageability Engine (ME) enabled
* system, poll for an indication from ME that ULP has been un-configured.
* If not on an ME enabled system, un-configure the ULP mode by software.
*
* During nominal operation, this function is called when link is acquired
* to disable ULP mode (force=false); otherwise, for example when unloading
* the driver or during Sx->S0 transitions, this is called with force=true
* to forcibly disable ULP.
*/
static s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
{
s32 ret_val = 0;
u32 mac_reg;
u16 phy_reg;
int i = 0;
if ((hw->mac.type < e1000_pch_lpt) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_LM) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPT_I217_V) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM2) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V2) ||
(hw->dev_spec.ich8lan.ulp_state == e1000_ulp_state_off))
{
return 0;
}
if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID)
{
if (force)
{
/* Request ME un-configure ULP mode in the PHY */
mac_reg = er32(H2ME);
mac_reg &= ~E1000_H2ME_ULP;
mac_reg |= E1000_H2ME_ENFORCE_SETTINGS;
ew32(H2ME, mac_reg);
}
/* Poll up to 300msec for ME to clear ULP_CFG_DONE. */
while (er32(FWSM) & E1000_FWSM_ULP_CFG_DONE)
{
if (i++ == 30)
{
ret_val = -E1000_ERR_PHY;
goto out;
}
usleep_range(10000, 20000);
}
e_dbg("ULP_CONFIG_DONE cleared after %dmsec\n", i * 10);
if (force)
{
mac_reg = er32(H2ME);
mac_reg &= ~E1000_H2ME_ENFORCE_SETTINGS;
ew32(H2ME, mac_reg);
}
else
{
/* Clear H2ME.ULP after ME ULP configuration */
mac_reg = er32(H2ME);
mac_reg &= ~E1000_H2ME_ULP;
ew32(H2ME, mac_reg);
}
goto out;
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
goto out;
}
if (force)
/* Toggle LANPHYPC Value bit */
{
e1000_toggle_lanphypc_pch_lpt(hw);
}
/* Unforce SMBus mode in PHY */
ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL, &phy_reg);
if (ret_val)
{
/* The MAC might be in PCIe mode, so temporarily force to
* SMBus mode in order to access the PHY.
*/
mac_reg = er32(CTRL_EXT);
mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS;
ew32(CTRL_EXT, mac_reg);
msleep(50);
ret_val = e1000_read_phy_reg_hv_locked(hw, CV_SMB_CTRL,
&phy_reg);
if (ret_val)
{
goto release;
}
}
phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS;
e1000_write_phy_reg_hv_locked(hw, CV_SMB_CTRL, phy_reg);
/* Unforce SMBus mode in MAC */
mac_reg = er32(CTRL_EXT);
mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS;
ew32(CTRL_EXT, mac_reg);
/* When ULP mode was previously entered, K1 was disabled by the
* hardware. Re-Enable K1 in the PHY when exiting ULP.
*/
ret_val = e1000_read_phy_reg_hv_locked(hw, HV_PM_CTRL, &phy_reg);
if (ret_val)
{
goto release;
}
phy_reg |= HV_PM_CTRL_K1_ENABLE;
e1000_write_phy_reg_hv_locked(hw, HV_PM_CTRL, phy_reg);
/* Clear ULP enabled configuration */
ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
if (ret_val)
{
goto release;
}
phy_reg &= ~(I218_ULP_CONFIG1_IND |
I218_ULP_CONFIG1_STICKY_ULP |
I218_ULP_CONFIG1_RESET_TO_SMBUS |
I218_ULP_CONFIG1_WOL_HOST |
I218_ULP_CONFIG1_INBAND_EXIT |
I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
I218_ULP_CONFIG1_DISABLE_SMB_PERST);
e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
/* Commit ULP changes by starting auto ULP configuration */
phy_reg |= I218_ULP_CONFIG1_START;
e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
/* Clear Disable SMBus Release on PERST# in MAC */
mac_reg = er32(FEXTNVM7);
mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
ew32(FEXTNVM7, mac_reg);
release:
hw->phy.ops.release(hw);
if (force)
{
e1000_phy_hw_reset(hw);
msleep(50);
}
out:
if (ret_val)
{
e_dbg("Error in ULP disable flow: %d\n", ret_val);
}
else
{
hw->dev_spec.ich8lan.ulp_state = e1000_ulp_state_off;
}
return ret_val;
}
/**
* e1000_check_for_copper_link_ich8lan - Check for link (Copper)
* @hw: pointer to the HW structure
*
* Checks to see of the link status of the hardware has changed. If a
* change in link status has been detected, then we read the PHY registers
* to get the current speed/duplex if link exists.
**/
static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
{
struct e1000_mac_info *mac = &hw->mac;
s32 ret_val, tipg_reg = 0;
u16 emi_addr, emi_val = 0;
bool link;
u16 phy_reg;
/* We only want to go out to the PHY registers to see if Auto-Neg
* has completed and/or if our link status has changed. The
* get_link_status flag is set upon receiving a Link Status
* Change or Rx Sequence Error interrupt.
*/
if (!mac->get_link_status)
{
return 0;
}
/* First we want to see if the MII Status Register reports
* link. If so, then we want to get the current speed/duplex
* of the PHY.
*/
ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
if (ret_val)
{
return ret_val;
}
if (hw->mac.type == e1000_pchlan)
{
ret_val = e1000_k1_gig_workaround_hv(hw, link);
if (ret_val)
{
return ret_val;
}
}
/* When connected at 10Mbps half-duplex, some parts are excessively
* aggressive resulting in many collisions. To avoid this, increase
* the IPG and reduce Rx latency in the PHY.
*/
if (((hw->mac.type == e1000_pch2lan) ||
(hw->mac.type == e1000_pch_lpt) ||
(hw->mac.type == e1000_pch_spt)) && link)
{
u16 speed, duplex;
e1000e_get_speed_and_duplex_copper(hw, &speed, &duplex);
tipg_reg = er32(TIPG);
tipg_reg &= ~E1000_TIPG_IPGT_MASK;
if (duplex == HALF_DUPLEX && speed == SPEED_10)
{
tipg_reg |= 0xFF;
/* Reduce Rx latency in analog PHY */
emi_val = 0;
}
else if (hw->mac.type == e1000_pch_spt &&
duplex == FULL_DUPLEX && speed != SPEED_1000)
{
tipg_reg |= 0xC;
emi_val = 1;
}
else
{
/* Roll back the default values */
tipg_reg |= 0x08;
emi_val = 1;
}
ew32(TIPG, tipg_reg);
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
if (hw->mac.type == e1000_pch2lan)
{
emi_addr = I82579_RX_CONFIG;
}
else
{
emi_addr = I217_RX_CONFIG;
}
ret_val = e1000_write_emi_reg_locked(hw, emi_addr, emi_val);
if (hw->mac.type == e1000_pch_lpt ||
hw->mac.type == e1000_pch_spt)
{
u16 phy_reg;
e1e_rphy_locked(hw, I217_PLL_CLOCK_GATE_REG, &phy_reg);
phy_reg &= ~I217_PLL_CLOCK_GATE_MASK;
if (speed == SPEED_100 || speed == SPEED_10)
{
phy_reg |= 0x3E8;
}
else
{
phy_reg |= 0xFA;
}
e1e_wphy_locked(hw, I217_PLL_CLOCK_GATE_REG, phy_reg);
}
hw->phy.ops.release(hw);
if (ret_val)
{
return ret_val;
}
if (hw->mac.type == e1000_pch_spt)
{
u16 data;
u16 ptr_gap;
if (speed == SPEED_1000)
{
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
ret_val = e1e_rphy_locked(hw,
PHY_REG(776, 20),
&data);
if (ret_val)
{
hw->phy.ops.release(hw);
return ret_val;
}
ptr_gap = (data & (0x3FF << 2)) >> 2;
if (ptr_gap < 0x18)
{
data &= ~(0x3FF << 2);
data |= (0x18 << 2);
ret_val =
e1e_wphy_locked(hw,
PHY_REG(776, 20),
data);
}
hw->phy.ops.release(hw);
if (ret_val)
{
return ret_val;
}
}
else
{
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
ret_val = e1e_wphy_locked(hw,
PHY_REG(776, 20),
0xC023);
hw->phy.ops.release(hw);
if (ret_val)
{
return ret_val;
}
}
}
}
/* I217 Packet Loss issue:
* ensure that FEXTNVM4 Beacon Duration is set correctly
* on power up.
* Set the Beacon Duration for I217 to 8 usec
*/
if ((hw->mac.type == e1000_pch_lpt) || (hw->mac.type == e1000_pch_spt))
{
u32 mac_reg;
mac_reg = er32(FEXTNVM4);
mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
ew32(FEXTNVM4, mac_reg);
}
/* Work-around I218 hang issue */
if ((hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_LM3) ||
(hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V3))
{
ret_val = e1000_k1_workaround_lpt_lp(hw, link);
if (ret_val)
{
return ret_val;
}
}
if ((hw->mac.type == e1000_pch_lpt) ||
(hw->mac.type == e1000_pch_spt))
{
/* Set platform power management values for
* Latency Tolerance Reporting (LTR)
*/
ret_val = e1000_platform_pm_pch_lpt(hw, link);
if (ret_val)
{
return ret_val;
}
}
/* Clear link partner's EEE ability */
hw->dev_spec.ich8lan.eee_lp_ability = 0;
/* FEXTNVM6 K1-off workaround */
if (hw->mac.type == e1000_pch_spt)
{
u32 pcieanacfg = er32(PCIEANACFG);
u32 fextnvm6 = er32(FEXTNVM6);
if (pcieanacfg & E1000_FEXTNVM6_K1_OFF_ENABLE)
{
fextnvm6 |= E1000_FEXTNVM6_K1_OFF_ENABLE;
}
else
{
fextnvm6 &= ~E1000_FEXTNVM6_K1_OFF_ENABLE;
}
ew32(FEXTNVM6, fextnvm6);
}
if (!link)
{
return 0; /* No link detected */
}
mac->get_link_status = false;
switch (hw->mac.type)
{
case e1000_pch2lan:
ret_val = e1000_k1_workaround_lv(hw);
if (ret_val)
{
return ret_val;
}
/* fall-thru */
case e1000_pchlan:
if (hw->phy.type == e1000_phy_82578)
{
ret_val = e1000_link_stall_workaround_hv(hw);
if (ret_val)
{
return ret_val;
}
}
/* Workaround for PCHx parts in half-duplex:
* Set the number of preambles removed from the packet
* when it is passed from the PHY to the MAC to prevent
* the MAC from misinterpreting the packet type.
*/
e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg);
phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK;
if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD)
{
phy_reg |= BIT(HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT);
}
e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg);
break;
default:
break;
}
/* Check if there was DownShift, must be checked
* immediately after link-up
*/
e1000e_check_downshift(hw);
/* Enable/Disable EEE after link up */
if (hw->phy.type > e1000_phy_82579)
{
ret_val = e1000_set_eee_pchlan(hw);
if (ret_val)
{
return ret_val;
}
}
/* If we are forcing speed/duplex, then we simply return since
* we have already determined whether we have link or not.
*/
if (!mac->autoneg)
{
return -E1000_ERR_CONFIG;
}
/* Auto-Neg is enabled. Auto Speed Detection takes care
* of MAC speed/duplex configuration. So we only need to
* configure Collision Distance in the MAC.
*/
mac->ops.config_collision_dist(hw);
/* Configure Flow Control now that Auto-Neg has completed.
* First, we need to restore the desired flow control
* settings because we may have had to re-autoneg with a
* different link partner.
*/
ret_val = e1000e_config_fc_after_link_up(hw);
if (ret_val)
{
e_dbg("Error configuring flow control\n");
}
return ret_val;
}
static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
s32 rc;
rc = e1000_init_mac_params_ich8lan(hw);
if (rc)
{
return rc;
}
rc = e1000_init_nvm_params_ich8lan(hw);
if (rc)
{
return rc;
}
switch (hw->mac.type)
{
case e1000_ich8lan:
case e1000_ich9lan:
case e1000_ich10lan:
rc = e1000_init_phy_params_ich8lan(hw);
break;
case e1000_pchlan:
case e1000_pch2lan:
case e1000_pch_lpt:
case e1000_pch_spt:
rc = e1000_init_phy_params_pchlan(hw);
break;
default:
break;
}
if (rc)
{
return rc;
}
/* Disable Jumbo Frame support on parts with Intel 10/100 PHY or
* on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
*/
if ((adapter->hw.phy.type == e1000_phy_ife) ||
((adapter->hw.mac.type >= e1000_pch2lan) &&
(!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK))))
{
adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
adapter->max_hw_frame_size = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN;
hw->mac.ops.blink_led = NULL;
}
if ((adapter->hw.mac.type == e1000_ich8lan) &&
(adapter->hw.phy.type != e1000_phy_ife))
{
adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
}
/* Enable workaround for 82579 w/ ME enabled */
if ((adapter->hw.mac.type == e1000_pch2lan) &&
(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
{
adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA;
}
return 0;
}
static DEFINE_MUTEX(nvm_mutex);
/**
* e1000_acquire_nvm_ich8lan - Acquire NVM mutex
* @hw: pointer to the HW structure
*
* Acquires the mutex for performing NVM operations.
**/
static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw __always_unused *hw)
{
mutex_lock(&nvm_mutex);
return 0;
}
/**
* e1000_release_nvm_ich8lan - Release NVM mutex
* @hw: pointer to the HW structure
*
* Releases the mutex used while performing NVM operations.
**/
static void e1000_release_nvm_ich8lan(struct e1000_hw __always_unused *hw)
{
mutex_unlock(&nvm_mutex);
}
/**
* e1000_acquire_swflag_ich8lan - Acquire software control flag
* @hw: pointer to the HW structure
*
* Acquires the software control flag for performing PHY and select
* MAC CSR accesses.
**/
static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
{
u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
s32 ret_val = 0;
if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE,
&hw->adapter->state))
{
e_dbg("contention for Phy access\n");
return -E1000_ERR_PHY;
}
while (timeout)
{
extcnf_ctrl = er32(EXTCNF_CTRL);
if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
{
break;
}
mdelay(1);
timeout--;
}
if (!timeout)
{
e_dbg("SW has already locked the resource.\n");
ret_val = -E1000_ERR_CONFIG;
goto out;
}
timeout = SW_FLAG_TIMEOUT;
extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
ew32(EXTCNF_CTRL, extcnf_ctrl);
while (timeout)
{
extcnf_ctrl = er32(EXTCNF_CTRL);
if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
{
break;
}
mdelay(1);
timeout--;
}
if (!timeout)
{
e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
er32(FWSM), extcnf_ctrl);
extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
ew32(EXTCNF_CTRL, extcnf_ctrl);
ret_val = -E1000_ERR_CONFIG;
goto out;
}
out:
if (ret_val)
{
clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
}
return ret_val;
}
/**
* e1000_release_swflag_ich8lan - Release software control flag
* @hw: pointer to the HW structure
*
* Releases the software control flag for performing PHY and select
* MAC CSR accesses.
**/
static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
{
u32 extcnf_ctrl;
extcnf_ctrl = er32(EXTCNF_CTRL);
if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
{
extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
ew32(EXTCNF_CTRL, extcnf_ctrl);
}
else
{
e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
}
clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
}
/**
* e1000_check_mng_mode_ich8lan - Checks management mode
* @hw: pointer to the HW structure
*
* This checks if the adapter has any manageability enabled.
* This is a function pointer entry point only called by read/write
* routines for the PHY and NVM parts.
**/
static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
{
u32 fwsm;
fwsm = er32(FWSM);
return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
((fwsm & E1000_FWSM_MODE_MASK) ==
(E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
}
/**
* e1000_check_mng_mode_pchlan - Checks management mode
* @hw: pointer to the HW structure
*
* This checks if the adapter has iAMT enabled.
* This is a function pointer entry point only called by read/write
* routines for the PHY and NVM parts.
**/
static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
{
u32 fwsm;
fwsm = er32(FWSM);
return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
(fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
}
/**
* e1000_rar_set_pch2lan - Set receive address register
* @hw: pointer to the HW structure
* @addr: pointer to the receive address
* @index: receive address array register
*
* Sets the receive address array register at index to the address passed
* in by addr. For 82579, RAR[0] is the base address register that is to
* contain the MAC address but RAR[1-6] are reserved for manageability (ME).
* Use SHRA[0-3] in place of those reserved for ME.
**/
static int e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index)
{
u32 rar_low, rar_high;
/* HW expects these in little endian so we reverse the byte order
* from network order (big endian) to little endian
*/
rar_low = ((u32)addr[0] |
((u32)addr[1] << 8) |
((u32)addr[2] << 16) | ((u32)addr[3] << 24));
rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
/* If MAC address zero, no need to set the AV bit */
if (rar_low || rar_high)
{
rar_high |= E1000_RAH_AV;
}
if (index == 0)
{
ew32(RAL(index), rar_low);
e1e_flush();
ew32(RAH(index), rar_high);
e1e_flush();
return 0;
}
/* RAR[1-6] are owned by manageability. Skip those and program the
* next address into the SHRA register array.
*/
if (index < (u32)(hw->mac.rar_entry_count))
{
s32 ret_val;
ret_val = e1000_acquire_swflag_ich8lan(hw);
if (ret_val)
{
goto out;
}
ew32(SHRAL(index - 1), rar_low);
e1e_flush();
ew32(SHRAH(index - 1), rar_high);
e1e_flush();
e1000_release_swflag_ich8lan(hw);
/* verify the register updates */
if ((er32(SHRAL(index - 1)) == rar_low) &&
(er32(SHRAH(index - 1)) == rar_high))
{
return 0;
}
e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
(index - 1), er32(FWSM));
}
out:
e_dbg("Failed to write receive address at index %d\n", index);
return -E1000_ERR_CONFIG;
}
/**
* e1000_rar_get_count_pch_lpt - Get the number of available SHRA
* @hw: pointer to the HW structure
*
* Get the number of available receive registers that the Host can
* program. SHRA[0-10] are the shared receive address registers
* that are shared between the Host and manageability engine (ME).
* ME can reserve any number of addresses and the host needs to be
* able to tell how many available registers it has access to.
**/
static u32 e1000_rar_get_count_pch_lpt(struct e1000_hw *hw)
{
u32 wlock_mac;
u32 num_entries;
wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK;
wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
switch (wlock_mac)
{
case 0:
/* All SHRA[0..10] and RAR[0] available */
num_entries = hw->mac.rar_entry_count;
break;
case 1:
/* Only RAR[0] available */
num_entries = 1;
break;
default:
/* SHRA[0..(wlock_mac - 1)] available + RAR[0] */
num_entries = wlock_mac + 1;
break;
}
return num_entries;
}
/**
* e1000_rar_set_pch_lpt - Set receive address registers
* @hw: pointer to the HW structure
* @addr: pointer to the receive address
* @index: receive address array register
*
* Sets the receive address register array at index to the address passed
* in by addr. For LPT, RAR[0] is the base address register that is to
* contain the MAC address. SHRA[0-10] are the shared receive address
* registers that are shared between the Host and manageability engine (ME).
**/
static int e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index)
{
u32 rar_low, rar_high;
u32 wlock_mac;
/* HW expects these in little endian so we reverse the byte order
* from network order (big endian) to little endian
*/
rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) |
((u32)addr[2] << 16) | ((u32)addr[3] << 24));
rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
/* If MAC address zero, no need to set the AV bit */
if (rar_low || rar_high)
{
rar_high |= E1000_RAH_AV;
}
if (index == 0)
{
ew32(RAL(index), rar_low);
e1e_flush();
ew32(RAH(index), rar_high);
e1e_flush();
return 0;
}
/* The manageability engine (ME) can lock certain SHRAR registers that
* it is using - those registers are unavailable for use.
*/
if (index < hw->mac.rar_entry_count)
{
wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK;
wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT;
/* Check if all SHRAR registers are locked */
if (wlock_mac == 1)
{
goto out;
}
if ((wlock_mac == 0) || (index <= wlock_mac))
{
s32 ret_val;
ret_val = e1000_acquire_swflag_ich8lan(hw);
if (ret_val)
{
goto out;
}
ew32(SHRAL_PCH_LPT(index - 1), rar_low);
e1e_flush();
ew32(SHRAH_PCH_LPT(index - 1), rar_high);
e1e_flush();
e1000_release_swflag_ich8lan(hw);
/* verify the register updates */
if ((er32(SHRAL_PCH_LPT(index - 1)) == rar_low) &&
(er32(SHRAH_PCH_LPT(index - 1)) == rar_high))
{
return 0;
}
}
}
out:
e_dbg("Failed to write receive address at index %d\n", index);
return -E1000_ERR_CONFIG;
}
/**
* e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
* @hw: pointer to the HW structure
*
* Checks if firmware is blocking the reset of the PHY.
* This is a function pointer entry point only called by
* reset routines.
**/
static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
{
bool blocked = false;
int i = 0;
while ((blocked = !(er32(FWSM) & E1000_ICH_FWSM_RSPCIPHY)) &&
(i++ < 30))
{
usleep_range(10000, 20000);
}
return blocked ? E1000_BLK_PHY_RESET : 0;
}
/**
* e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
* @hw: pointer to the HW structure
*
* Assumes semaphore already acquired.
*
**/
static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
{
u16 phy_data;
u32 strap = er32(STRAP);
u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>
E1000_STRAP_SMT_FREQ_SHIFT;
s32 ret_val;
strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
if (ret_val)
{
return ret_val;
}
phy_data &= ~HV_SMB_ADDR_MASK;
phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
if (hw->phy.type == e1000_phy_i217)
{
/* Restore SMBus frequency */
if (freq--)
{
phy_data &= ~HV_SMB_ADDR_FREQ_MASK;
phy_data |= (freq & BIT(0)) <<
HV_SMB_ADDR_FREQ_LOW_SHIFT;
phy_data |= (freq & BIT(1)) <<
(HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1);
}
else
{
e_dbg("Unsupported SMB frequency in PHY\n");
}
}
return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
}
/**
* e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
* @hw: pointer to the HW structure
*
* SW should configure the LCD from the NVM extended configuration region
* as a workaround for certain parts.
**/
static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
{
struct e1000_phy_info *phy = &hw->phy;
u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
s32 ret_val = 0;
u16 word_addr, reg_data, reg_addr, phy_page = 0;
/* Initialize the PHY from the NVM on ICH platforms. This
* is needed due to an issue where the NVM configuration is
* not properly autoloaded after power transitions.
* Therefore, after each PHY reset, we will load the
* configuration data out of the NVM manually.
*/
switch (hw->mac.type)
{
case e1000_ich8lan:
if (phy->type != e1000_phy_igp_3)
{
return ret_val;
}
if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
(hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C))
{
sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
break;
}
/* Fall-thru */
case e1000_pchlan:
case e1000_pch2lan:
case e1000_pch_lpt:
case e1000_pch_spt:
sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
break;
default:
return ret_val;
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
data = er32(FEXTNVM);
if (!(data & sw_cfg_mask))
{
goto release;
}
/* Make sure HW does not configure LCD from PHY
* extended configuration before SW configuration
*/
data = er32(EXTCNF_CTRL);
if ((hw->mac.type < e1000_pch2lan) &&
(data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE))
{
goto release;
}
cnf_size = er32(EXTCNF_SIZE);
cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
if (!cnf_size)
{
goto release;
}
cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
if (((hw->mac.type == e1000_pchlan) &&
!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) ||
(hw->mac.type > e1000_pchlan))
{
/* HW configures the SMBus address and LEDs when the
* OEM and LCD Write Enable bits are set in the NVM.
* When both NVM bits are cleared, SW will configure
* them instead.
*/
ret_val = e1000_write_smbus_addr(hw);
if (ret_val)
{
goto release;
}
data = er32(LEDCTL);
ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
(u16)data);
if (ret_val)
{
goto release;
}
}
/* Configure LCD from extended configuration region. */
/* cnf_base_addr is in DWORD */
word_addr = (u16)(cnf_base_addr << 1);
for (i = 0; i < cnf_size; i++)
{
ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1, ®_data);
if (ret_val)
{
goto release;
}
ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
1, ®_addr);
if (ret_val)
{
goto release;
}
/* Save off the PHY page for future writes. */
if (reg_addr == IGP01E1000_PHY_PAGE_SELECT)
{
phy_page = reg_data;
continue;
}
reg_addr &= PHY_REG_MASK;
reg_addr |= phy_page;
ret_val = e1e_wphy_locked(hw, (u32)reg_addr, reg_data);
if (ret_val)
{
goto release;
}
}
release:
hw->phy.ops.release(hw);
return ret_val;
}
/**
* e1000_k1_gig_workaround_hv - K1 Si workaround
* @hw: pointer to the HW structure
* @link: link up bool flag
*
* If K1 is enabled for 1Gbps, the MAC might stall when transitioning
* from a lower speed. This workaround disables K1 whenever link is at 1Gig
* If link is down, the function will restore the default K1 setting located
* in the NVM.
**/
static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
{
s32 ret_val = 0;
u16 status_reg = 0;
bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
if (hw->mac.type != e1000_pchlan)
{
return 0;
}
/* Wrap the whole flow with the sw flag */
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
/* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
if (link)
{
if (hw->phy.type == e1000_phy_82578)
{
ret_val = e1e_rphy_locked(hw, BM_CS_STATUS,
&status_reg);
if (ret_val)
{
goto release;
}
status_reg &= (BM_CS_STATUS_LINK_UP |
BM_CS_STATUS_RESOLVED |
BM_CS_STATUS_SPEED_MASK);
if (status_reg == (BM_CS_STATUS_LINK_UP |
BM_CS_STATUS_RESOLVED |
BM_CS_STATUS_SPEED_1000))
{
k1_enable = false;
}
}
if (hw->phy.type == e1000_phy_82577)
{
ret_val = e1e_rphy_locked(hw, HV_M_STATUS, &status_reg);
if (ret_val)
{
goto release;
}
status_reg &= (HV_M_STATUS_LINK_UP |
HV_M_STATUS_AUTONEG_COMPLETE |
HV_M_STATUS_SPEED_MASK);
if (status_reg == (HV_M_STATUS_LINK_UP |
HV_M_STATUS_AUTONEG_COMPLETE |
HV_M_STATUS_SPEED_1000))
{
k1_enable = false;
}
}
/* Link stall fix for link up */
ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x0100);
if (ret_val)
{
goto release;
}
}
else
{
/* Link stall fix for link down */
ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x4100);
if (ret_val)
{
goto release;
}
}
ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
release:
hw->phy.ops.release(hw);
return ret_val;
}
/**
* e1000_configure_k1_ich8lan - Configure K1 power state
* @hw: pointer to the HW structure
* @enable: K1 state to configure
*
* Configure the K1 power state based on the provided parameter.
* Assumes semaphore already acquired.
*
* Success returns 0, Failure returns -E1000_ERR_PHY (-2)
**/
s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
{
s32 ret_val;
u32 ctrl_reg = 0;
u32 ctrl_ext = 0;
u32 reg = 0;
u16 kmrn_reg = 0;
ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
&kmrn_reg);
if (ret_val)
{
return ret_val;
}
if (k1_enable)
{
kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
}
else
{
kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
}
ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
kmrn_reg);
if (ret_val)
{
return ret_val;
}
usleep_range(20, 40);
ctrl_ext = er32(CTRL_EXT);
ctrl_reg = er32(CTRL);
reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
reg |= E1000_CTRL_FRCSPD;
ew32(CTRL, reg);
ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
e1e_flush();
usleep_range(20, 40);
ew32(CTRL, ctrl_reg);
ew32(CTRL_EXT, ctrl_ext);
e1e_flush();
usleep_range(20, 40);
return 0;
}
/**
* e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
* @hw: pointer to the HW structure
* @d0_state: boolean if entering d0 or d3 device state
*
* SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
* collectively called OEM bits. The OEM Write Enable bit and SW Config bit
* in NVM determines whether HW should configure LPLU and Gbe Disable.
**/
static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
{
s32 ret_val = 0;
u32 mac_reg;
u16 oem_reg;
if (hw->mac.type < e1000_pchlan)
{
return ret_val;
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
if (hw->mac.type == e1000_pchlan)
{
mac_reg = er32(EXTCNF_CTRL);
if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
{
goto release;
}
}
mac_reg = er32(FEXTNVM);
if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
{
goto release;
}
mac_reg = er32(PHY_CTRL);
ret_val = e1e_rphy_locked(hw, HV_OEM_BITS, &oem_reg);
if (ret_val)
{
goto release;
}
oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
if (d0_state)
{
if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
{
oem_reg |= HV_OEM_BITS_GBE_DIS;
}
if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
{
oem_reg |= HV_OEM_BITS_LPLU;
}
}
else
{
if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE |
E1000_PHY_CTRL_NOND0A_GBE_DISABLE))
{
oem_reg |= HV_OEM_BITS_GBE_DIS;
}
if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU |
E1000_PHY_CTRL_NOND0A_LPLU))
{
oem_reg |= HV_OEM_BITS_LPLU;
}
}
/* Set Restart auto-neg to activate the bits */
if ((d0_state || (hw->mac.type != e1000_pchlan)) &&
!hw->phy.ops.check_reset_block(hw))
{
oem_reg |= HV_OEM_BITS_RESTART_AN;
}
ret_val = e1e_wphy_locked(hw, HV_OEM_BITS, oem_reg);
release:
hw->phy.ops.release(hw);
return ret_val;
}
/**
* e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
* @hw: pointer to the HW structure
**/
static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
{
s32 ret_val;
u16 data;
ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
if (ret_val)
{
return ret_val;
}
data |= HV_KMRN_MDIO_SLOW;
ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
return ret_val;
}
/**
* e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
* done after every PHY reset.
**/
static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
{
s32 ret_val = 0;
u16 phy_data;
if (hw->mac.type != e1000_pchlan)
{
return 0;
}
/* Set MDIO slow mode before any other MDIO access */
if (hw->phy.type == e1000_phy_82577)
{
ret_val = e1000_set_mdio_slow_mode_hv(hw);
if (ret_val)
{
return ret_val;
}
}
if (((hw->phy.type == e1000_phy_82577) &&
((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1)))
{
/* Disable generation of early preamble */
ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
if (ret_val)
{
return ret_val;
}
/* Preamble tuning for SSC */
ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204);
if (ret_val)
{
return ret_val;
}
}
if (hw->phy.type == e1000_phy_82578)
{
/* Return registers to default by doing a soft reset then
* writing 0x3140 to the control register.
*/
if (hw->phy.revision < 2)
{
e1000e_phy_sw_reset(hw);
ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);
}
}
/* Select page 0 */
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
hw->phy.addr = 1;
ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
hw->phy.ops.release(hw);
if (ret_val)
{
return ret_val;
}
/* Configure the K1 Si workaround during phy reset assuming there is
* link so that it disables K1 if link is in 1Gbps.
*/
ret_val = e1000_k1_gig_workaround_hv(hw, true);
if (ret_val)
{
return ret_val;
}
/* Workaround for link disconnects on a busy hub in half duplex */
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
ret_val = e1e_rphy_locked(hw, BM_PORT_GEN_CFG, &phy_data);
if (ret_val)
{
goto release;
}
ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF);
if (ret_val)
{
goto release;
}
/* set MSE higher to enable link to stay up when noise is high */
ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);
release:
hw->phy.ops.release(hw);
return ret_val;
}
/**
* e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
* @hw: pointer to the HW structure
**/
void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
{
u32 mac_reg;
u16 i, phy_reg = 0;
s32 ret_val;
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return;
}
ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg);
if (ret_val)
{
goto release;
}
/* Copy both RAL/H (rar_entry_count) and SHRAL/H to PHY */
for (i = 0; i < (hw->mac.rar_entry_count); i++)
{
mac_reg = er32(RAL(i));
hw->phy.ops.write_reg_page(hw, BM_RAR_L(i),
(u16)(mac_reg & 0xFFFF));
hw->phy.ops.write_reg_page(hw, BM_RAR_M(i),
(u16)((mac_reg >> 16) & 0xFFFF));
mac_reg = er32(RAH(i));
hw->phy.ops.write_reg_page(hw, BM_RAR_H(i),
(u16)(mac_reg & 0xFFFF));
hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i),
(u16)((mac_reg & E1000_RAH_AV)
>> 16));
}
e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg);
release:
hw->phy.ops.release(hw);
}
/**
* e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
* with 82579 PHY
* @hw: pointer to the HW structure
* @enable: flag to enable/disable workaround when enabling/disabling jumbos
**/
s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
{
s32 ret_val = 0;
u16 phy_reg, data;
u32 mac_reg;
u16 i;
if (hw->mac.type < e1000_pch2lan)
{
return 0;
}
/* disable Rx path while enabling/disabling workaround */
e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | BIT(14));
if (ret_val)
{
return ret_val;
}
if (enable)
{
/* Write Rx addresses (rar_entry_count for RAL/H, and
* SHRAL/H) and initial CRC values to the MAC
*/
for (i = 0; i < hw->mac.rar_entry_count; i++)
{
u8 mac_addr[ETH_ALEN] = { 0 };
u32 addr_high, addr_low;
addr_high = er32(RAH(i));
if (!(addr_high & E1000_RAH_AV))
{
continue;
}
addr_low = er32(RAL(i));
mac_addr[0] = (addr_low & 0xFF);
mac_addr[1] = ((addr_low >> 8) & 0xFF);
mac_addr[2] = ((addr_low >> 16) & 0xFF);
mac_addr[3] = ((addr_low >> 24) & 0xFF);
mac_addr[4] = (addr_high & 0xFF);
mac_addr[5] = ((addr_high >> 8) & 0xFF);
ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr));
}
/* Write Rx addresses to the PHY */
e1000_copy_rx_addrs_to_phy_ich8lan(hw);
/* Enable jumbo frame workaround in the MAC */
mac_reg = er32(FFLT_DBG);
mac_reg &= ~BIT(14);
mac_reg |= (7 << 15);
ew32(FFLT_DBG, mac_reg);
mac_reg = er32(RCTL);
mac_reg |= E1000_RCTL_SECRC;
ew32(RCTL, mac_reg);
ret_val = e1000e_read_kmrn_reg(hw,
E1000_KMRNCTRLSTA_CTRL_OFFSET,
&data);
if (ret_val)
{
return ret_val;
}
ret_val = e1000e_write_kmrn_reg(hw,
E1000_KMRNCTRLSTA_CTRL_OFFSET,
data | BIT(0));
if (ret_val)
{
return ret_val;
}
ret_val = e1000e_read_kmrn_reg(hw,
E1000_KMRNCTRLSTA_HD_CTRL,
&data);
if (ret_val)
{
return ret_val;
}
data &= ~(0xF << 8);
data |= (0xB << 8);
ret_val = e1000e_write_kmrn_reg(hw,
E1000_KMRNCTRLSTA_HD_CTRL,
data);
if (ret_val)
{
return ret_val;
}
/* Enable jumbo frame workaround in the PHY */
e1e_rphy(hw, PHY_REG(769, 23), &data);
data &= ~(0x7F << 5);
data |= (0x37 << 5);
ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
if (ret_val)
{
return ret_val;
}
e1e_rphy(hw, PHY_REG(769, 16), &data);
data &= ~BIT(13);
ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
if (ret_val)
{
return ret_val;
}
e1e_rphy(hw, PHY_REG(776, 20), &data);
data &= ~(0x3FF << 2);
data |= (E1000_TX_PTR_GAP << 2);
ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
if (ret_val)
{
return ret_val;
}
ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100);
if (ret_val)
{
return ret_val;
}
e1e_rphy(hw, HV_PM_CTRL, &data);
ret_val = e1e_wphy(hw, HV_PM_CTRL, data | BIT(10));
if (ret_val)
{
return ret_val;
}
}
else
{
/* Write MAC register values back to h/w defaults */
mac_reg = er32(FFLT_DBG);
mac_reg &= ~(0xF << 14);
ew32(FFLT_DBG, mac_reg);
mac_reg = er32(RCTL);
mac_reg &= ~E1000_RCTL_SECRC;
ew32(RCTL, mac_reg);
ret_val = e1000e_read_kmrn_reg(hw,
E1000_KMRNCTRLSTA_CTRL_OFFSET,
&data);
if (ret_val)
{
return ret_val;
}
ret_val = e1000e_write_kmrn_reg(hw,
E1000_KMRNCTRLSTA_CTRL_OFFSET,
data & ~BIT(0));
if (ret_val)
{
return ret_val;
}
ret_val = e1000e_read_kmrn_reg(hw,
E1000_KMRNCTRLSTA_HD_CTRL,
&data);
if (ret_val)
{
return ret_val;
}
data &= ~(0xF << 8);
data |= (0xB << 8);
ret_val = e1000e_write_kmrn_reg(hw,
E1000_KMRNCTRLSTA_HD_CTRL,
data);
if (ret_val)
{
return ret_val;
}
/* Write PHY register values back to h/w defaults */
e1e_rphy(hw, PHY_REG(769, 23), &data);
data &= ~(0x7F << 5);
ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
if (ret_val)
{
return ret_val;
}
e1e_rphy(hw, PHY_REG(769, 16), &data);
data |= BIT(13);
ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
if (ret_val)
{
return ret_val;
}
e1e_rphy(hw, PHY_REG(776, 20), &data);
data &= ~(0x3FF << 2);
data |= (0x8 << 2);
ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
if (ret_val)
{
return ret_val;
}
ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
if (ret_val)
{
return ret_val;
}
e1e_rphy(hw, HV_PM_CTRL, &data);
ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~BIT(10));
if (ret_val)
{
return ret_val;
}
}
/* re-enable Rx path after enabling/disabling workaround */
return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~BIT(14));
}
/**
* e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
* done after every PHY reset.
**/
static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
{
s32 ret_val = 0;
if (hw->mac.type != e1000_pch2lan)
{
return 0;
}
/* Set MDIO slow mode before any other MDIO access */
ret_val = e1000_set_mdio_slow_mode_hv(hw);
if (ret_val)
{
return ret_val;
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
/* set MSE higher to enable link to stay up when noise is high */
ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);
if (ret_val)
{
goto release;
}
/* drop link after 5 times MSE threshold was reached */
ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);
release:
hw->phy.ops.release(hw);
return ret_val;
}
/**
* e1000_k1_gig_workaround_lv - K1 Si workaround
* @hw: pointer to the HW structure
*
* Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
* Disable K1 in 1000Mbps and 100Mbps
**/
static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
{
s32 ret_val = 0;
u16 status_reg = 0;
if (hw->mac.type != e1000_pch2lan)
{
return 0;
}
/* Set K1 beacon duration based on 10Mbs speed */
ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
if (ret_val)
{
return ret_val;
}
if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
== (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
{
if (status_reg &
(HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100))
{
u16 pm_phy_reg;
/* LV 1G/100 Packet drop issue wa */
ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
if (ret_val)
{
return ret_val;
}
pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
if (ret_val)
{
return ret_val;
}
}
else
{
u32 mac_reg;
mac_reg = er32(FEXTNVM4);
mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
ew32(FEXTNVM4, mac_reg);
}
}
return ret_val;
}
/**
* e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
* @hw: pointer to the HW structure
* @gate: boolean set to true to gate, false to ungate
*
* Gate/ungate the automatic PHY configuration via hardware; perform
* the configuration via software instead.
**/
static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
{
u32 extcnf_ctrl;
if (hw->mac.type < e1000_pch2lan)
{
return;
}
extcnf_ctrl = er32(EXTCNF_CTRL);
if (gate)
{
extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
}
else
{
extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
}
ew32(EXTCNF_CTRL, extcnf_ctrl);
}
/**
* e1000_lan_init_done_ich8lan - Check for PHY config completion
* @hw: pointer to the HW structure
*
* Check the appropriate indication the MAC has finished configuring the
* PHY after a software reset.
**/
static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
{
u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
/* Wait for basic configuration completes before proceeding */
do
{
data = er32(STATUS);
data &= E1000_STATUS_LAN_INIT_DONE;
usleep_range(100, 200);
}
while ((!data) && --loop);
/* If basic configuration is incomplete before the above loop
* count reaches 0, loading the configuration from NVM will
* leave the PHY in a bad state possibly resulting in no link.
*/
if (loop == 0)
{
e_dbg("LAN_INIT_DONE not set, increase timeout\n");
}
/* Clear the Init Done bit for the next init event */
data = er32(STATUS);
data &= ~E1000_STATUS_LAN_INIT_DONE;
ew32(STATUS, data);
}
/**
* e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
* @hw: pointer to the HW structure
**/
static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
{
s32 ret_val = 0;
u16 reg;
if (hw->phy.ops.check_reset_block(hw))
{
return 0;
}
/* Allow time for h/w to get to quiescent state after reset */
usleep_range(10000, 20000);
/* Perform any necessary post-reset workarounds */
switch (hw->mac.type)
{
case e1000_pchlan:
ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
if (ret_val)
{
return ret_val;
}
break;
case e1000_pch2lan:
ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
if (ret_val)
{
return ret_val;
}
break;
default:
break;
}
/* Clear the host wakeup bit after lcd reset */
if (hw->mac.type >= e1000_pchlan)
{
e1e_rphy(hw, BM_PORT_GEN_CFG, ®);
reg &= ~BM_WUC_HOST_WU_BIT;
e1e_wphy(hw, BM_PORT_GEN_CFG, reg);
}
/* Configure the LCD with the extended configuration region in NVM */
ret_val = e1000_sw_lcd_config_ich8lan(hw);
if (ret_val)
{
return ret_val;
}
/* Configure the LCD with the OEM bits in NVM */
ret_val = e1000_oem_bits_config_ich8lan(hw, true);
if (hw->mac.type == e1000_pch2lan)
{
/* Ungate automatic PHY configuration on non-managed 82579 */
if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
{
usleep_range(10000, 20000);
e1000_gate_hw_phy_config_ich8lan(hw, false);
}
/* Set EEE LPI Update Timer to 200usec */
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return ret_val;
}
ret_val = e1000_write_emi_reg_locked(hw,
I82579_LPI_UPDATE_TIMER,
0x1387);
hw->phy.ops.release(hw);
}
return ret_val;
}
/**
* e1000_phy_hw_reset_ich8lan - Performs a PHY reset
* @hw: pointer to the HW structure
*
* Resets the PHY
* This is a function pointer entry point called by drivers
* or other shared routines.
**/
static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
{
s32 ret_val = 0;
/* Gate automatic PHY configuration by hardware on non-managed 82579 */
if ((hw->mac.type == e1000_pch2lan) &&
!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
{
e1000_gate_hw_phy_config_ich8lan(hw, true);
}
ret_val = e1000e_phy_hw_reset_generic(hw);
if (ret_val)
{
return ret_val;
}
return e1000_post_phy_reset_ich8lan(hw);
}
/**
* e1000_set_lplu_state_pchlan - Set Low Power Link Up state
* @hw: pointer to the HW structure
* @active: true to enable LPLU, false to disable
*
* Sets the LPLU state according to the active flag. For PCH, if OEM write
* bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
* the phy speed. This function will manually set the LPLU bit and restart
* auto-neg as hw would do. D3 and D0 LPLU will call the same function
* since it configures the same bit.
**/
static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
{
s32 ret_val;
u16 oem_reg;
ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
if (ret_val)
{
return ret_val;
}
if (active)
{
oem_reg |= HV_OEM_BITS_LPLU;
}
else
{
oem_reg &= ~HV_OEM_BITS_LPLU;
}
if (!hw->phy.ops.check_reset_block(hw))
{
oem_reg |= HV_OEM_BITS_RESTART_AN;
}
return e1e_wphy(hw, HV_OEM_BITS, oem_reg);
}
/**
* e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
* @hw: pointer to the HW structure
* @active: true to enable LPLU, false to disable
*
* Sets the LPLU D0 state according to the active flag. When
* activating LPLU this function also disables smart speed
* and vice versa. LPLU will not be activated unless the
* device autonegotiation advertisement meets standards of
* either 10 or 10/100 or 10/100/1000 at all duplexes.
* This is a function pointer entry point only called by
* PHY setup routines.
**/
static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
{
struct e1000_phy_info *phy = &hw->phy;
u32 phy_ctrl;
s32 ret_val = 0;
u16 data;
if (phy->type == e1000_phy_ife)
{
return 0;
}
phy_ctrl = er32(PHY_CTRL);
if (active)
{
phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
ew32(PHY_CTRL, phy_ctrl);
if (phy->type != e1000_phy_igp_3)
{
return 0;
}
/* Call gig speed drop workaround on LPLU before accessing
* any PHY registers
*/
if (hw->mac.type == e1000_ich8lan)
{
e1000e_gig_downshift_workaround_ich8lan(hw);
}
/* When LPLU is enabled, we should disable SmartSpeed */
ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
if (ret_val)
{
return ret_val;
}
data &= ~IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
if (ret_val)
{
return ret_val;
}
}
else
{
phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
ew32(PHY_CTRL, phy_ctrl);
if (phy->type != e1000_phy_igp_3)
{
return 0;
}
/* LPLU and SmartSpeed are mutually exclusive. LPLU is used
* during Dx states where the power conservation is most
* important. During driver activity we should enable
* SmartSpeed, so performance is maintained.
*/
if (phy->smart_speed == e1000_smart_speed_on)
{
ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
&data);
if (ret_val)
{
return ret_val;
}
data |= IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
data);
if (ret_val)
{
return ret_val;
}
}
else if (phy->smart_speed == e1000_smart_speed_off)
{
ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
&data);
if (ret_val)
{
return ret_val;
}
data &= ~IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
data);
if (ret_val)
{
return ret_val;
}
}
}
return 0;
}
/**
* e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
* @hw: pointer to the HW structure
* @active: true to enable LPLU, false to disable
*
* Sets the LPLU D3 state according to the active flag. When
* activating LPLU this function also disables smart speed
* and vice versa. LPLU will not be activated unless the
* device autonegotiation advertisement meets standards of
* either 10 or 10/100 or 10/100/1000 at all duplexes.
* This is a function pointer entry point only called by
* PHY setup routines.
**/
static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
{
struct e1000_phy_info *phy = &hw->phy;
u32 phy_ctrl;
s32 ret_val = 0;
u16 data;
phy_ctrl = er32(PHY_CTRL);
if (!active)
{
phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
ew32(PHY_CTRL, phy_ctrl);
if (phy->type != e1000_phy_igp_3)
{
return 0;
}
/* LPLU and SmartSpeed are mutually exclusive. LPLU is used
* during Dx states where the power conservation is most
* important. During driver activity we should enable
* SmartSpeed, so performance is maintained.
*/
if (phy->smart_speed == e1000_smart_speed_on)
{
ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
&data);
if (ret_val)
{
return ret_val;
}
data |= IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
data);
if (ret_val)
{
return ret_val;
}
}
else if (phy->smart_speed == e1000_smart_speed_off)
{
ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
&data);
if (ret_val)
{
return ret_val;
}
data &= ~IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
data);
if (ret_val)
{
return ret_val;
}
}
}
else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
(phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
(phy->autoneg_advertised == E1000_ALL_10_SPEED))
{
phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
ew32(PHY_CTRL, phy_ctrl);
if (phy->type != e1000_phy_igp_3)
{
return 0;
}
/* Call gig speed drop workaround on LPLU before accessing
* any PHY registers
*/
if (hw->mac.type == e1000_ich8lan)
{
e1000e_gig_downshift_workaround_ich8lan(hw);
}
/* When LPLU is enabled, we should disable SmartSpeed */
ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
if (ret_val)
{
return ret_val;
}
data &= ~IGP01E1000_PSCFR_SMART_SPEED;
ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
}
return ret_val;
}
/**
* e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
* @hw: pointer to the HW structure
* @bank: pointer to the variable that returns the active bank
*
* Reads signature byte from the NVM using the flash access registers.
* Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
**/
static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
{
u32 eecd;
struct e1000_nvm_info *nvm = &hw->nvm;
u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
u32 nvm_dword = 0;
u8 sig_byte = 0;
s32 ret_val;
switch (hw->mac.type)
{
case e1000_pch_spt:
bank1_offset = nvm->flash_bank_size;
act_offset = E1000_ICH_NVM_SIG_WORD;
/* set bank to 0 in case flash read fails */
*bank = 0;
/* Check bank 0 */
ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset,
&nvm_dword);
if (ret_val)
{
return ret_val;
}
sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
E1000_ICH_NVM_SIG_VALUE)
{
*bank = 0;
return 0;
}
/* Check bank 1 */
ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset +
bank1_offset,
&nvm_dword);
if (ret_val)
{
return ret_val;
}
sig_byte = (u8)((nvm_dword & 0xFF00) >> 8);
if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
E1000_ICH_NVM_SIG_VALUE)
{
*bank = 1;
return 0;
}
e_dbg("ERROR: No valid NVM bank present\n");
return -E1000_ERR_NVM;
case e1000_ich8lan:
case e1000_ich9lan:
eecd = er32(EECD);
if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
E1000_EECD_SEC1VAL_VALID_MASK)
{
if (eecd & E1000_EECD_SEC1VAL)
{
*bank = 1;
}
else
{
*bank = 0;
}
return 0;
}
e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
/* fall-thru */
default:
/* set bank to 0 in case flash read fails */
*bank = 0;
/* Check bank 0 */
ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
&sig_byte);
if (ret_val)
{
return ret_val;
}
if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
E1000_ICH_NVM_SIG_VALUE)
{
*bank = 0;
return 0;
}
/* Check bank 1 */
ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
bank1_offset,
&sig_byte);
if (ret_val)
{
return ret_val;
}
if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
E1000_ICH_NVM_SIG_VALUE)
{
*bank = 1;
return 0;
}
e_dbg("ERROR: No valid NVM bank present\n");
return -E1000_ERR_NVM;
}
}
/**
* e1000_read_nvm_spt - NVM access for SPT
* @hw: pointer to the HW structure
* @offset: The offset (in bytes) of the word(s) to read.
* @words: Size of data to read in words.
* @data: pointer to the word(s) to read at offset.
*
* Reads a word(s) from the NVM
**/
static s32 e1000_read_nvm_spt(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data)
{
struct e1000_nvm_info *nvm = &hw->nvm;
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u32 act_offset;
s32 ret_val = 0;
u32 bank = 0;
u32 dword = 0;
u16 offset_to_read;
u16 i;
if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
(words == 0))
{
e_dbg("nvm parameter(s) out of bounds\n");
ret_val = -E1000_ERR_NVM;
goto out;
}
nvm->ops.acquire(hw);
ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
if (ret_val)
{
e_dbg("Could not detect valid bank, assuming bank 0\n");
bank = 0;
}
act_offset = (bank) ? nvm->flash_bank_size : 0;
act_offset += offset;
ret_val = 0;
for (i = 0; i < words; i += 2)
{
if (words - i == 1)
{
if (dev_spec->shadow_ram[offset + i].modified)
{
data[i] =
dev_spec->shadow_ram[offset + i].value;
}
else
{
offset_to_read = act_offset + i -
((act_offset + i) % 2);
ret_val =
e1000_read_flash_dword_ich8lan(hw,
offset_to_read,
&dword);
if (ret_val)
{
break;
}
if ((act_offset + i) % 2 == 0)
{
data[i] = (u16)(dword & 0xFFFF);
}
else
{
data[i] = (u16)((dword >> 16) & 0xFFFF);
}
}
}
else
{
offset_to_read = act_offset + i;
if (!(dev_spec->shadow_ram[offset + i].modified) ||
!(dev_spec->shadow_ram[offset + i + 1].modified))
{
ret_val =
e1000_read_flash_dword_ich8lan(hw,
offset_to_read,
&dword);
if (ret_val)
{
break;
}
}
if (dev_spec->shadow_ram[offset + i].modified)
data[i] =
dev_spec->shadow_ram[offset + i].value;
else
{
data[i] = (u16)(dword & 0xFFFF);
}
if (dev_spec->shadow_ram[offset + i].modified)
data[i + 1] =
dev_spec->shadow_ram[offset + i + 1].value;
else
{
data[i + 1] = (u16)(dword >> 16 & 0xFFFF);
}
}
}
nvm->ops.release(hw);
out:
if (ret_val)
{
e_dbg("NVM read error: %d\n", ret_val);
}
return ret_val;
}
/**
* e1000_read_nvm_ich8lan - Read word(s) from the NVM
* @hw: pointer to the HW structure
* @offset: The offset (in bytes) of the word(s) to read.
* @words: Size of data to read in words
* @data: Pointer to the word(s) to read at offset.
*
* Reads a word(s) from the NVM using the flash access registers.
**/
static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data)
{
struct e1000_nvm_info *nvm = &hw->nvm;
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u32 act_offset;
s32 ret_val = 0;
u32 bank = 0;
u16 i, word;
if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
(words == 0))
{
e_dbg("nvm parameter(s) out of bounds\n");
ret_val = -E1000_ERR_NVM;
goto out;
}
nvm->ops.acquire(hw);
ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
if (ret_val)
{
e_dbg("Could not detect valid bank, assuming bank 0\n");
bank = 0;
}
act_offset = (bank) ? nvm->flash_bank_size : 0;
act_offset += offset;
ret_val = 0;
for (i = 0; i < words; i++)
{
if (dev_spec->shadow_ram[offset + i].modified)
{
data[i] = dev_spec->shadow_ram[offset + i].value;
}
else
{
ret_val = e1000_read_flash_word_ich8lan(hw,
act_offset + i,
&word);
if (ret_val)
{
break;
}
data[i] = word;
}
}
nvm->ops.release(hw);
out:
if (ret_val)
{
e_dbg("NVM read error: %d\n", ret_val);
}
return ret_val;
}
/**
* e1000_flash_cycle_init_ich8lan - Initialize flash
* @hw: pointer to the HW structure
*
* This function does initial flash setup so that a new read/write/erase cycle
* can be started.
**/
static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
{
union ich8_hws_flash_status hsfsts;
s32 ret_val = -E1000_ERR_NVM;
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
/* Check if the flash descriptor is valid */
if (!hsfsts.hsf_status.fldesvalid)
{
e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
return -E1000_ERR_NVM;
}
/* Clear FCERR and DAEL in hw status by writing 1 */
hsfsts.hsf_status.flcerr = 1;
hsfsts.hsf_status.dael = 1;
if (hw->mac.type == e1000_pch_spt)
{
ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval & 0xFFFF);
}
else
{
ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
}
/* Either we should have a hardware SPI cycle in progress
* bit to check against, in order to start a new cycle or
* FDONE bit should be changed in the hardware so that it
* is 1 after hardware reset, which can then be used as an
* indication whether a cycle is in progress or has been
* completed.
*/
if (!hsfsts.hsf_status.flcinprog)
{
/* There is no cycle running at present,
* so we can start a cycle.
* Begin by setting Flash Cycle Done.
*/
hsfsts.hsf_status.flcdone = 1;
if (hw->mac.type == e1000_pch_spt)
{
ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval & 0xFFFF);
}
else
{
ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
}
ret_val = 0;
}
else
{
s32 i;
/* Otherwise poll for sometime so the current
* cycle has a chance to end before giving up.
*/
for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++)
{
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
if (!hsfsts.hsf_status.flcinprog)
{
ret_val = 0;
break;
}
udelay(1);
}
if (!ret_val)
{
/* Successful in waiting for previous cycle to timeout,
* now set the Flash Cycle Done.
*/
hsfsts.hsf_status.flcdone = 1;
if (hw->mac.type == e1000_pch_spt)
ew32flash(ICH_FLASH_HSFSTS,
hsfsts.regval & 0xFFFF);
else
{
ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
}
}
else
{
e_dbg("Flash controller busy, cannot get access\n");
}
}
return ret_val;
}
/**
* e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
* @hw: pointer to the HW structure
* @timeout: maximum time to wait for completion
*
* This function starts a flash cycle and waits for its completion.
**/
static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
{
union ich8_hws_flash_ctrl hsflctl;
union ich8_hws_flash_status hsfsts;
u32 i = 0;
/* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
if (hw->mac.type == e1000_pch_spt)
{
hsflctl.regval = er32flash(ICH_FLASH_HSFSTS) >> 16;
}
else
{
hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
}
hsflctl.hsf_ctrl.flcgo = 1;
if (hw->mac.type == e1000_pch_spt)
{
ew32flash(ICH_FLASH_HSFSTS, hsflctl.regval << 16);
}
else
{
ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
}
/* wait till FDONE bit is set to 1 */
do
{
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
if (hsfsts.hsf_status.flcdone)
{
break;
}
udelay(1);
}
while (i++ < timeout);
if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr)
{
return 0;
}
return -E1000_ERR_NVM;
}
/**
* e1000_read_flash_dword_ich8lan - Read dword from flash
* @hw: pointer to the HW structure
* @offset: offset to data location
* @data: pointer to the location for storing the data
*
* Reads the flash dword at offset into data. Offset is converted
* to bytes before read.
**/
static s32 e1000_read_flash_dword_ich8lan(struct e1000_hw *hw, u32 offset,
u32 *data)
{
/* Must convert word offset into bytes. */
offset <<= 1;
return e1000_read_flash_data32_ich8lan(hw, offset, data);
}
/**
* e1000_read_flash_word_ich8lan - Read word from flash
* @hw: pointer to the HW structure
* @offset: offset to data location
* @data: pointer to the location for storing the data
*
* Reads the flash word at offset into data. Offset is converted
* to bytes before read.
**/
static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
u16 *data)
{
/* Must convert offset into bytes. */
offset <<= 1;
return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
}
/**
* e1000_read_flash_byte_ich8lan - Read byte from flash
* @hw: pointer to the HW structure
* @offset: The offset of the byte to read.
* @data: Pointer to a byte to store the value read.
*
* Reads a single byte from the NVM using the flash access registers.
**/
static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
u8 *data)
{
s32 ret_val;
u16 word = 0;
/* In SPT, only 32 bits access is supported,
* so this function should not be called.
*/
if (hw->mac.type == e1000_pch_spt)
{
return -E1000_ERR_NVM;
}
else
{
ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
}
if (ret_val)
{
return ret_val;
}
*data = (u8)word;
return 0;
}
/**
* e1000_read_flash_data_ich8lan - Read byte or word from NVM
* @hw: pointer to the HW structure
* @offset: The offset (in bytes) of the byte or word to read.
* @size: Size of data to read, 1=byte 2=word
* @data: Pointer to the word to store the value read.
*
* Reads a byte or word from the NVM using the flash access registers.
**/
static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
u8 size, u16 *data)
{
union ich8_hws_flash_status hsfsts;
union ich8_hws_flash_ctrl hsflctl;
u32 flash_linear_addr;
u32 flash_data = 0;
s32 ret_val = -E1000_ERR_NVM;
u8 count = 0;
if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
{
return -E1000_ERR_NVM;
}
flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
hw->nvm.flash_base_addr);
do
{
udelay(1);
/* Steps */
ret_val = e1000_flash_cycle_init_ich8lan(hw);
if (ret_val)
{
break;
}
hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
/* 0b/1b corresponds to 1 or 2 byte size, respectively. */
hsflctl.hsf_ctrl.fldbcount = size - 1;
hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
ret_val =
e1000_flash_cycle_ich8lan(hw,
ICH_FLASH_READ_COMMAND_TIMEOUT);
/* Check if FCERR is set to 1, if set to 1, clear it
* and try the whole sequence a few more times, else
* read in (shift in) the Flash Data0, the order is
* least significant byte first msb to lsb
*/
if (!ret_val)
{
flash_data = er32flash(ICH_FLASH_FDATA0);
if (size == 1)
{
*data = (u8)(flash_data & 0x000000FF);
}
else if (size == 2)
{
*data = (u16)(flash_data & 0x0000FFFF);
}
break;
}
else
{
/* If we've gotten here, then things are probably
* completely hosed, but if the error condition is
* detected, it won't hurt to give it another try...
* ICH_FLASH_CYCLE_REPEAT_COUNT times.
*/
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
if (hsfsts.hsf_status.flcerr)
{
/* Repeat for some time before giving up. */
continue;
}
else if (!hsfsts.hsf_status.flcdone)
{
e_dbg("Timeout error - flash cycle did not complete.\n");
break;
}
}
}
while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
return ret_val;
}
/**
* e1000_read_flash_data32_ich8lan - Read dword from NVM
* @hw: pointer to the HW structure
* @offset: The offset (in bytes) of the dword to read.
* @data: Pointer to the dword to store the value read.
*
* Reads a byte or word from the NVM using the flash access registers.
**/
static s32 e1000_read_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
u32 *data)
{
union ich8_hws_flash_status hsfsts;
union ich8_hws_flash_ctrl hsflctl;
u32 flash_linear_addr;
s32 ret_val = -E1000_ERR_NVM;
u8 count = 0;
if (offset > ICH_FLASH_LINEAR_ADDR_MASK ||
hw->mac.type != e1000_pch_spt)
{
return -E1000_ERR_NVM;
}
flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
hw->nvm.flash_base_addr);
do
{
udelay(1);
/* Steps */
ret_val = e1000_flash_cycle_init_ich8lan(hw);
if (ret_val)
{
break;
}
/* In SPT, This register is in Lan memory space, not flash.
* Therefore, only 32 bit access is supported
*/
hsflctl.regval = er32flash(ICH_FLASH_HSFSTS) >> 16;
/* 0b/1b corresponds to 1 or 2 byte size, respectively. */
hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
/* In SPT, This register is in Lan memory space, not flash.
* Therefore, only 32 bit access is supported
*/
ew32flash(ICH_FLASH_HSFSTS, (u32)hsflctl.regval << 16);
ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
ret_val =
e1000_flash_cycle_ich8lan(hw,
ICH_FLASH_READ_COMMAND_TIMEOUT);
/* Check if FCERR is set to 1, if set to 1, clear it
* and try the whole sequence a few more times, else
* read in (shift in) the Flash Data0, the order is
* least significant byte first msb to lsb
*/
if (!ret_val)
{
*data = er32flash(ICH_FLASH_FDATA0);
break;
}
else
{
/* If we've gotten here, then things are probably
* completely hosed, but if the error condition is
* detected, it won't hurt to give it another try...
* ICH_FLASH_CYCLE_REPEAT_COUNT times.
*/
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
if (hsfsts.hsf_status.flcerr)
{
/* Repeat for some time before giving up. */
continue;
}
else if (!hsfsts.hsf_status.flcdone)
{
e_dbg("Timeout error - flash cycle did not complete.\n");
break;
}
}
}
while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
return ret_val;
}
/**
* e1000_write_nvm_ich8lan - Write word(s) to the NVM
* @hw: pointer to the HW structure
* @offset: The offset (in bytes) of the word(s) to write.
* @words: Size of data to write in words
* @data: Pointer to the word(s) to write at offset.
*
* Writes a byte or word to the NVM using the flash access registers.
**/
static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
u16 *data)
{
struct e1000_nvm_info *nvm = &hw->nvm;
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u16 i;
if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
(words == 0))
{
e_dbg("nvm parameter(s) out of bounds\n");
return -E1000_ERR_NVM;
}
nvm->ops.acquire(hw);
for (i = 0; i < words; i++)
{
dev_spec->shadow_ram[offset + i].modified = true;
dev_spec->shadow_ram[offset + i].value = data[i];
}
nvm->ops.release(hw);
return 0;
}
/**
* e1000_update_nvm_checksum_spt - Update the checksum for NVM
* @hw: pointer to the HW structure
*
* The NVM checksum is updated by calling the generic update_nvm_checksum,
* which writes the checksum to the shadow ram. The changes in the shadow
* ram are then committed to the EEPROM by processing each bank at a time
* checking for the modified bit and writing only the pending changes.
* After a successful commit, the shadow ram is cleared and is ready for
* future writes.
**/
static s32 e1000_update_nvm_checksum_spt(struct e1000_hw *hw)
{
struct e1000_nvm_info *nvm = &hw->nvm;
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
s32 ret_val;
u32 dword = 0;
ret_val = e1000e_update_nvm_checksum_generic(hw);
if (ret_val)
{
goto out;
}
if (nvm->type != e1000_nvm_flash_sw)
{
goto out;
}
nvm->ops.acquire(hw);
/* We're writing to the opposite bank so if we're on bank 1,
* write to bank 0 etc. We also need to erase the segment that
* is going to be written
*/
ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
if (ret_val)
{
e_dbg("Could not detect valid bank, assuming bank 0\n");
bank = 0;
}
if (bank == 0)
{
new_bank_offset = nvm->flash_bank_size;
old_bank_offset = 0;
ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
if (ret_val)
{
goto release;
}
}
else
{
old_bank_offset = nvm->flash_bank_size;
new_bank_offset = 0;
ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
if (ret_val)
{
goto release;
}
}
for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i += 2)
{
/* Determine whether to write the value stored
* in the other NVM bank or a modified value stored
* in the shadow RAM
*/
ret_val = e1000_read_flash_dword_ich8lan(hw,
i + old_bank_offset,
&dword);
if (dev_spec->shadow_ram[i].modified)
{
dword &= 0xffff0000;
dword |= (dev_spec->shadow_ram[i].value & 0xffff);
}
if (dev_spec->shadow_ram[i + 1].modified)
{
dword &= 0x0000ffff;
dword |= ((dev_spec->shadow_ram[i + 1].value & 0xffff)
<< 16);
}
if (ret_val)
{
break;
}
/* If the word is 0x13, then make sure the signature bits
* (15:14) are 11b until the commit has completed.
* This will allow us to write 10b which indicates the
* signature is valid. We want to do this after the write
* has completed so that we don't mark the segment valid
* while the write is still in progress
*/
if (i == E1000_ICH_NVM_SIG_WORD - 1)
{
dword |= E1000_ICH_NVM_SIG_MASK << 16;
}
/* Convert offset to bytes. */
act_offset = (i + new_bank_offset) << 1;
usleep_range(100, 200);
/* Write the data to the new bank. Offset in words */
act_offset = i + new_bank_offset;
ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset,
dword);
if (ret_val)
{
break;
}
}
/* Don't bother writing the segment valid bits if sector
* programming failed.
*/
if (ret_val)
{
/* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
e_dbg("Flash commit failed.\n");
goto release;
}
/* Finally validate the new segment by setting bit 15:14
* to 10b in word 0x13 , this can be done without an
* erase as well since these bits are 11 to start with
* and we need to change bit 14 to 0b
*/
act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
/*offset in words but we read dword */
--act_offset;
ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
if (ret_val)
{
goto release;
}
dword &= 0xBFFFFFFF;
ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
if (ret_val)
{
goto release;
}
/* And invalidate the previously valid segment by setting
* its signature word (0x13) high_byte to 0b. This can be
* done without an erase because flash erase sets all bits
* to 1's. We can write 1's to 0's without an erase
*/
act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
/* offset in words but we read dword */
act_offset = old_bank_offset + E1000_ICH_NVM_SIG_WORD - 1;
ret_val = e1000_read_flash_dword_ich8lan(hw, act_offset, &dword);
if (ret_val)
{
goto release;
}
dword &= 0x00FFFFFF;
ret_val = e1000_retry_write_flash_dword_ich8lan(hw, act_offset, dword);
if (ret_val)
{
goto release;
}
/* Great! Everything worked, we can now clear the cached entries. */
for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++)
{
dev_spec->shadow_ram[i].modified = false;
dev_spec->shadow_ram[i].value = 0xFFFF;
}
release:
nvm->ops.release(hw);
/* Reload the EEPROM, or else modifications will not appear
* until after the next adapter reset.
*/
if (!ret_val)
{
nvm->ops.reload(hw);
usleep_range(10000, 20000);
}
out:
if (ret_val)
{
e_dbg("NVM update error: %d\n", ret_val);
}
return ret_val;
}
/**
* e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
* @hw: pointer to the HW structure
*
* The NVM checksum is updated by calling the generic update_nvm_checksum,
* which writes the checksum to the shadow ram. The changes in the shadow
* ram are then committed to the EEPROM by processing each bank at a time
* checking for the modified bit and writing only the pending changes.
* After a successful commit, the shadow ram is cleared and is ready for
* future writes.
**/
static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
{
struct e1000_nvm_info *nvm = &hw->nvm;
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
s32 ret_val;
u16 data = 0;
ret_val = e1000e_update_nvm_checksum_generic(hw);
if (ret_val)
{
goto out;
}
if (nvm->type != e1000_nvm_flash_sw)
{
goto out;
}
nvm->ops.acquire(hw);
/* We're writing to the opposite bank so if we're on bank 1,
* write to bank 0 etc. We also need to erase the segment that
* is going to be written
*/
ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
if (ret_val)
{
e_dbg("Could not detect valid bank, assuming bank 0\n");
bank = 0;
}
if (bank == 0)
{
new_bank_offset = nvm->flash_bank_size;
old_bank_offset = 0;
ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
if (ret_val)
{
goto release;
}
}
else
{
old_bank_offset = nvm->flash_bank_size;
new_bank_offset = 0;
ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
if (ret_val)
{
goto release;
}
}
for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++)
{
if (dev_spec->shadow_ram[i].modified)
{
data = dev_spec->shadow_ram[i].value;
}
else
{
ret_val = e1000_read_flash_word_ich8lan(hw, i +
old_bank_offset,
&data);
if (ret_val)
{
break;
}
}
/* If the word is 0x13, then make sure the signature bits
* (15:14) are 11b until the commit has completed.
* This will allow us to write 10b which indicates the
* signature is valid. We want to do this after the write
* has completed so that we don't mark the segment valid
* while the write is still in progress
*/
if (i == E1000_ICH_NVM_SIG_WORD)
{
data |= E1000_ICH_NVM_SIG_MASK;
}
/* Convert offset to bytes. */
act_offset = (i + new_bank_offset) << 1;
usleep_range(100, 200);
/* Write the bytes to the new bank. */
ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
act_offset,
(u8)data);
if (ret_val)
{
break;
}
usleep_range(100, 200);
ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
act_offset + 1,
(u8)(data >> 8));
if (ret_val)
{
break;
}
}
/* Don't bother writing the segment valid bits if sector
* programming failed.
*/
if (ret_val)
{
/* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
e_dbg("Flash commit failed.\n");
goto release;
}
/* Finally validate the new segment by setting bit 15:14
* to 10b in word 0x13 , this can be done without an
* erase as well since these bits are 11 to start with
* and we need to change bit 14 to 0b
*/
act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
if (ret_val)
{
goto release;
}
data &= 0xBFFF;
ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
act_offset * 2 + 1,
(u8)(data >> 8));
if (ret_val)
{
goto release;
}
/* And invalidate the previously valid segment by setting
* its signature word (0x13) high_byte to 0b. This can be
* done without an erase because flash erase sets all bits
* to 1's. We can write 1's to 0's without an erase
*/
act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
if (ret_val)
{
goto release;
}
/* Great! Everything worked, we can now clear the cached entries. */
for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++)
{
dev_spec->shadow_ram[i].modified = false;
dev_spec->shadow_ram[i].value = 0xFFFF;
}
release:
nvm->ops.release(hw);
/* Reload the EEPROM, or else modifications will not appear
* until after the next adapter reset.
*/
if (!ret_val)
{
nvm->ops.reload(hw);
usleep_range(10000, 20000);
}
out:
if (ret_val)
{
e_dbg("NVM update error: %d\n", ret_val);
}
return ret_val;
}
/**
* e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
* @hw: pointer to the HW structure
*
* Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
* If the bit is 0, that the EEPROM had been modified, but the checksum was not
* calculated, in which case we need to calculate the checksum and set bit 6.
**/
static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
{
s32 ret_val;
u16 data;
u16 word;
u16 valid_csum_mask;
/* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
* the checksum needs to be fixed. This bit is an indication that
* the NVM was prepared by OEM software and did not calculate
* the checksum...a likely scenario.
*/
switch (hw->mac.type)
{
case e1000_pch_lpt:
case e1000_pch_spt:
word = NVM_COMPAT;
valid_csum_mask = NVM_COMPAT_VALID_CSUM;
break;
default:
word = NVM_FUTURE_INIT_WORD1;
valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM;
break;
}
ret_val = e1000_read_nvm(hw, word, 1, &data);
if (ret_val)
{
return ret_val;
}
if (!(data & valid_csum_mask))
{
data |= valid_csum_mask;
ret_val = e1000_write_nvm(hw, word, 1, &data);
if (ret_val)
{
return ret_val;
}
ret_val = e1000e_update_nvm_checksum(hw);
if (ret_val)
{
return ret_val;
}
}
return e1000e_validate_nvm_checksum_generic(hw);
}
/**
* e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
* @hw: pointer to the HW structure
*
* To prevent malicious write/erase of the NVM, set it to be read-only
* so that the hardware ignores all write/erase cycles of the NVM via
* the flash control registers. The shadow-ram copy of the NVM will
* still be updated, however any updates to this copy will not stick
* across driver reloads.
**/
void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
{
struct e1000_nvm_info *nvm = &hw->nvm;
union ich8_flash_protected_range pr0;
union ich8_hws_flash_status hsfsts;
u32 gfpreg;
nvm->ops.acquire(hw);
gfpreg = er32flash(ICH_FLASH_GFPREG);
/* Write-protect GbE Sector of NVM */
pr0.regval = er32flash(ICH_FLASH_PR0);
pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
pr0.range.wpe = true;
ew32flash(ICH_FLASH_PR0, pr0.regval);
/* Lock down a subset of GbE Flash Control Registers, e.g.
* PR0 to prevent the write-protection from being lifted.
* Once FLOCKDN is set, the registers protected by it cannot
* be written until FLOCKDN is cleared by a hardware reset.
*/
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
hsfsts.hsf_status.flockdn = true;
ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
nvm->ops.release(hw);
}
/**
* e1000_write_flash_data_ich8lan - Writes bytes to the NVM
* @hw: pointer to the HW structure
* @offset: The offset (in bytes) of the byte/word to read.
* @size: Size of data to read, 1=byte 2=word
* @data: The byte(s) to write to the NVM.
*
* Writes one/two bytes to the NVM using the flash access registers.
**/
static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
u8 size, u16 data)
{
union ich8_hws_flash_status hsfsts;
union ich8_hws_flash_ctrl hsflctl;
u32 flash_linear_addr;
u32 flash_data = 0;
s32 ret_val;
u8 count = 0;
if (hw->mac.type == e1000_pch_spt)
{
if (size != 4 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
{
return -E1000_ERR_NVM;
}
}
else
{
if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
{
return -E1000_ERR_NVM;
}
}
flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
hw->nvm.flash_base_addr);
do
{
udelay(1);
/* Steps */
ret_val = e1000_flash_cycle_init_ich8lan(hw);
if (ret_val)
{
break;
}
/* In SPT, This register is in Lan memory space, not
* flash. Therefore, only 32 bit access is supported
*/
if (hw->mac.type == e1000_pch_spt)
{
hsflctl.regval = er32flash(ICH_FLASH_HSFSTS) >> 16;
}
else
{
hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
}
/* 0b/1b corresponds to 1 or 2 byte size, respectively. */
hsflctl.hsf_ctrl.fldbcount = size - 1;
hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
/* In SPT, This register is in Lan memory space,
* not flash. Therefore, only 32 bit access is
* supported
*/
if (hw->mac.type == e1000_pch_spt)
{
ew32flash(ICH_FLASH_HSFSTS, hsflctl.regval << 16);
}
else
{
ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
}
ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
if (size == 1)
{
flash_data = (u32)data & 0x00FF;
}
else
{
flash_data = (u32)data;
}
ew32flash(ICH_FLASH_FDATA0, flash_data);
/* check if FCERR is set to 1 , if set to 1, clear it
* and try the whole sequence a few more times else done
*/
ret_val =
e1000_flash_cycle_ich8lan(hw,
ICH_FLASH_WRITE_COMMAND_TIMEOUT);
if (!ret_val)
{
break;
}
/* If we're here, then things are most likely
* completely hosed, but if the error condition
* is detected, it won't hurt to give it another
* try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
*/
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
if (hsfsts.hsf_status.flcerr)
/* Repeat for some time before giving up. */
{
continue;
}
if (!hsfsts.hsf_status.flcdone)
{
e_dbg("Timeout error - flash cycle did not complete.\n");
break;
}
}
while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
return ret_val;
}
/**
* e1000_write_flash_data32_ich8lan - Writes 4 bytes to the NVM
* @hw: pointer to the HW structure
* @offset: The offset (in bytes) of the dwords to read.
* @data: The 4 bytes to write to the NVM.
*
* Writes one/two/four bytes to the NVM using the flash access registers.
**/
static s32 e1000_write_flash_data32_ich8lan(struct e1000_hw *hw, u32 offset,
u32 data)
{
union ich8_hws_flash_status hsfsts;
union ich8_hws_flash_ctrl hsflctl;
u32 flash_linear_addr;
s32 ret_val;
u8 count = 0;
if (hw->mac.type == e1000_pch_spt)
{
if (offset > ICH_FLASH_LINEAR_ADDR_MASK)
{
return -E1000_ERR_NVM;
}
}
flash_linear_addr = ((ICH_FLASH_LINEAR_ADDR_MASK & offset) +
hw->nvm.flash_base_addr);
do
{
udelay(1);
/* Steps */
ret_val = e1000_flash_cycle_init_ich8lan(hw);
if (ret_val)
{
break;
}
/* In SPT, This register is in Lan memory space, not
* flash. Therefore, only 32 bit access is supported
*/
if (hw->mac.type == e1000_pch_spt)
hsflctl.regval = er32flash(ICH_FLASH_HSFSTS)
>> 16;
else
{
hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
}
hsflctl.hsf_ctrl.fldbcount = sizeof(u32) - 1;
hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
/* In SPT, This register is in Lan memory space,
* not flash. Therefore, only 32 bit access is
* supported
*/
if (hw->mac.type == e1000_pch_spt)
{
ew32flash(ICH_FLASH_HSFSTS, hsflctl.regval << 16);
}
else
{
ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
}
ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
ew32flash(ICH_FLASH_FDATA0, data);
/* check if FCERR is set to 1 , if set to 1, clear it
* and try the whole sequence a few more times else done
*/
ret_val =
e1000_flash_cycle_ich8lan(hw,
ICH_FLASH_WRITE_COMMAND_TIMEOUT);
if (!ret_val)
{
break;
}
/* If we're here, then things are most likely
* completely hosed, but if the error condition
* is detected, it won't hurt to give it another
* try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
*/
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
if (hsfsts.hsf_status.flcerr)
/* Repeat for some time before giving up. */
{
continue;
}
if (!hsfsts.hsf_status.flcdone)
{
e_dbg("Timeout error - flash cycle did not complete.\n");
break;
}
}
while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
return ret_val;
}
/**
* e1000_write_flash_byte_ich8lan - Write a single byte to NVM
* @hw: pointer to the HW structure
* @offset: The index of the byte to read.
* @data: The byte to write to the NVM.
*
* Writes a single byte to the NVM using the flash access registers.
**/
static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
u8 data)
{
u16 word = (u16)data;
return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
}
/**
* e1000_retry_write_flash_dword_ich8lan - Writes a dword to NVM
* @hw: pointer to the HW structure
* @offset: The offset of the word to write.
* @dword: The dword to write to the NVM.
*
* Writes a single dword to the NVM using the flash access registers.
* Goes through a retry algorithm before giving up.
**/
static s32 e1000_retry_write_flash_dword_ich8lan(struct e1000_hw *hw,
u32 offset, u32 dword)
{
s32 ret_val;
u16 program_retries;
/* Must convert word offset into bytes. */
offset <<= 1;
ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
if (!ret_val)
{
return ret_val;
}
for (program_retries = 0; program_retries < 100; program_retries++)
{
e_dbg("Retrying Byte %8.8X at offset %u\n", dword, offset);
usleep_range(100, 200);
ret_val = e1000_write_flash_data32_ich8lan(hw, offset, dword);
if (!ret_val)
{
break;
}
}
if (program_retries == 100)
{
return -E1000_ERR_NVM;
}
return 0;
}
/**
* e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
* @hw: pointer to the HW structure
* @offset: The offset of the byte to write.
* @byte: The byte to write to the NVM.
*
* Writes a single byte to the NVM using the flash access registers.
* Goes through a retry algorithm before giving up.
**/
static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
u32 offset, u8 byte)
{
s32 ret_val;
u16 program_retries;
ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
if (!ret_val)
{
return ret_val;
}
for (program_retries = 0; program_retries < 100; program_retries++)
{
e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
usleep_range(100, 200);
ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
if (!ret_val)
{
break;
}
}
if (program_retries == 100)
{
return -E1000_ERR_NVM;
}
return 0;
}
/**
* e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
* @hw: pointer to the HW structure
* @bank: 0 for first bank, 1 for second bank, etc.
*
* Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
* bank N is 4096 * N + flash_reg_addr.
**/
static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
{
struct e1000_nvm_info *nvm = &hw->nvm;
union ich8_hws_flash_status hsfsts;
union ich8_hws_flash_ctrl hsflctl;
u32 flash_linear_addr;
/* bank size is in 16bit words - adjust to bytes */
u32 flash_bank_size = nvm->flash_bank_size * 2;
s32 ret_val;
s32 count = 0;
s32 j, iteration, sector_size;
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
/* Determine HW Sector size: Read BERASE bits of hw flash status
* register
* 00: The Hw sector is 256 bytes, hence we need to erase 16
* consecutive sectors. The start index for the nth Hw sector
* can be calculated as = bank * 4096 + n * 256
* 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
* The start index for the nth Hw sector can be calculated
* as = bank * 4096
* 10: The Hw sector is 8K bytes, nth sector = bank * 8192
* (ich9 only, otherwise error condition)
* 11: The Hw sector is 64K bytes, nth sector = bank * 65536
*/
switch (hsfsts.hsf_status.berasesz)
{
case 0:
/* Hw sector size 256 */
sector_size = ICH_FLASH_SEG_SIZE_256;
iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
break;
case 1:
sector_size = ICH_FLASH_SEG_SIZE_4K;
iteration = 1;
break;
case 2:
sector_size = ICH_FLASH_SEG_SIZE_8K;
iteration = 1;
break;
case 3:
sector_size = ICH_FLASH_SEG_SIZE_64K;
iteration = 1;
break;
default:
return -E1000_ERR_NVM;
}
/* Start with the base address, then add the sector offset. */
flash_linear_addr = hw->nvm.flash_base_addr;
flash_linear_addr += (bank) ? flash_bank_size : 0;
for (j = 0; j < iteration; j++)
{
do
{
u32 timeout = ICH_FLASH_ERASE_COMMAND_TIMEOUT;
/* Steps */
ret_val = e1000_flash_cycle_init_ich8lan(hw);
if (ret_val)
{
return ret_val;
}
/* Write a value 11 (block Erase) in Flash
* Cycle field in hw flash control
*/
if (hw->mac.type == e1000_pch_spt)
hsflctl.regval =
er32flash(ICH_FLASH_HSFSTS) >> 16;
else
{
hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
}
hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
if (hw->mac.type == e1000_pch_spt)
ew32flash(ICH_FLASH_HSFSTS,
hsflctl.regval << 16);
else
{
ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
}
/* Write the last 24 bits of an index within the
* block into Flash Linear address field in Flash
* Address.
*/
flash_linear_addr += (j * sector_size);
ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
ret_val = e1000_flash_cycle_ich8lan(hw, timeout);
if (!ret_val)
{
break;
}
/* Check if FCERR is set to 1. If 1,
* clear it and try the whole sequence
* a few more times else Done
*/
hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
if (hsfsts.hsf_status.flcerr)
/* repeat for some time before giving up */
{
continue;
}
else if (!hsfsts.hsf_status.flcdone)
{
return ret_val;
}
}
while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
}
return 0;
}
/**
* e1000_valid_led_default_ich8lan - Set the default LED settings
* @hw: pointer to the HW structure
* @data: Pointer to the LED settings
*
* Reads the LED default settings from the NVM to data. If the NVM LED
* settings is all 0's or F's, set the LED default to a valid LED default
* setting.
**/
static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
{
s32 ret_val;
ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
if (ret_val)
{
e_dbg("NVM Read Error\n");
return ret_val;
}
if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
{
*data = ID_LED_DEFAULT_ICH8LAN;
}
return 0;
}
/**
* e1000_id_led_init_pchlan - store LED configurations
* @hw: pointer to the HW structure
*
* PCH does not control LEDs via the LEDCTL register, rather it uses
* the PHY LED configuration register.
*
* PCH also does not have an "always on" or "always off" mode which
* complicates the ID feature. Instead of using the "on" mode to indicate
* in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
* use "link_up" mode. The LEDs will still ID on request if there is no
* link based on logic in e1000_led_[on|off]_pchlan().
**/
static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
{
struct e1000_mac_info *mac = &hw->mac;
s32 ret_val;
const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
u16 data, i, temp, shift;
/* Get default ID LED modes */
ret_val = hw->nvm.ops.valid_led_default(hw, &data);
if (ret_val)
{
return ret_val;
}
mac->ledctl_default = er32(LEDCTL);
mac->ledctl_mode1 = mac->ledctl_default;
mac->ledctl_mode2 = mac->ledctl_default;
for (i = 0; i < 4; i++)
{
temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
shift = (i * 5);
switch (temp)
{
case ID_LED_ON1_DEF2:
case ID_LED_ON1_ON2:
case ID_LED_ON1_OFF2:
mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
mac->ledctl_mode1 |= (ledctl_on << shift);
break;
case ID_LED_OFF1_DEF2:
case ID_LED_OFF1_ON2:
case ID_LED_OFF1_OFF2:
mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
mac->ledctl_mode1 |= (ledctl_off << shift);
break;
default:
/* Do nothing */
break;
}
switch (temp)
{
case ID_LED_DEF1_ON2:
case ID_LED_ON1_ON2:
case ID_LED_OFF1_ON2:
mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
mac->ledctl_mode2 |= (ledctl_on << shift);
break;
case ID_LED_DEF1_OFF2:
case ID_LED_ON1_OFF2:
case ID_LED_OFF1_OFF2:
mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
mac->ledctl_mode2 |= (ledctl_off << shift);
break;
default:
/* Do nothing */
break;
}
}
return 0;
}
/**
* e1000_get_bus_info_ich8lan - Get/Set the bus type and width
* @hw: pointer to the HW structure
*
* ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
* register, so the the bus width is hard coded.
**/
static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
{
struct e1000_bus_info *bus = &hw->bus;
s32 ret_val;
ret_val = e1000e_get_bus_info_pcie(hw);
/* ICH devices are "PCI Express"-ish. They have
* a configuration space, but do not contain
* PCI Express Capability registers, so bus width
* must be hardcoded.
*/
if (bus->width == e1000_bus_width_unknown)
{
bus->width = e1000_bus_width_pcie_x1;
}
return ret_val;
}
/**
* e1000_reset_hw_ich8lan - Reset the hardware
* @hw: pointer to the HW structure
*
* Does a full reset of the hardware which includes a reset of the PHY and
* MAC.
**/
static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
{
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u16 kum_cfg;
u32 ctrl, reg;
s32 ret_val;
/* Prevent the PCI-E bus from sticking if there is no TLP connection
* on the last TLP read/write transaction when MAC is reset.
*/
ret_val = e1000e_disable_pcie_master(hw);
if (ret_val)
{
e_dbg("PCI-E Master disable polling has failed.\n");
}
e_dbg("Masking off all interrupts\n");
ew32(IMC, 0xffffffff);
/* Disable the Transmit and Receive units. Then delay to allow
* any pending transactions to complete before we hit the MAC
* with the global reset.
*/
ew32(RCTL, 0);
ew32(TCTL, E1000_TCTL_PSP);
e1e_flush();
usleep_range(10000, 20000);
/* Workaround for ICH8 bit corruption issue in FIFO memory */
if (hw->mac.type == e1000_ich8lan)
{
/* Set Tx and Rx buffer allocation to 8k apiece. */
ew32(PBA, E1000_PBA_8K);
/* Set Packet Buffer Size to 16k. */
ew32(PBS, E1000_PBS_16K);
}
if (hw->mac.type == e1000_pchlan)
{
/* Save the NVM K1 bit setting */
ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg);
if (ret_val)
{
return ret_val;
}
if (kum_cfg & E1000_NVM_K1_ENABLE)
{
dev_spec->nvm_k1_enabled = true;
}
else
{
dev_spec->nvm_k1_enabled = false;
}
}
ctrl = er32(CTRL);
if (!hw->phy.ops.check_reset_block(hw))
{
/* Full-chip reset requires MAC and PHY reset at the same
* time to make sure the interface between MAC and the
* external PHY is reset.
*/
ctrl |= E1000_CTRL_PHY_RST;
/* Gate automatic PHY configuration by hardware on
* non-managed 82579
*/
if ((hw->mac.type == e1000_pch2lan) &&
!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
{
e1000_gate_hw_phy_config_ich8lan(hw, true);
}
}
ret_val = e1000_acquire_swflag_ich8lan(hw);
e_dbg("Issuing a global reset to ich8lan\n");
ew32(CTRL, (ctrl | E1000_CTRL_RST));
/* cannot issue a flush here because it hangs the hardware */
msleep(20);
/* Set Phy Config Counter to 50msec */
if (hw->mac.type == e1000_pch2lan)
{
reg = er32(FEXTNVM3);
reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK;
reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;
ew32(FEXTNVM3, reg);
}
if (!ret_val)
{
clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state);
}
if (ctrl & E1000_CTRL_PHY_RST)
{
ret_val = hw->phy.ops.get_cfg_done(hw);
if (ret_val)
{
return ret_val;
}
ret_val = e1000_post_phy_reset_ich8lan(hw);
if (ret_val)
{
return ret_val;
}
}
/* For PCH, this write will make sure that any noise
* will be detected as a CRC error and be dropped rather than show up
* as a bad packet to the DMA engine.
*/
if (hw->mac.type == e1000_pchlan)
{
ew32(CRC_OFFSET, 0x65656565);
}
ew32(IMC, 0xffffffff);
er32(ICR);
reg = er32(KABGTXD);
reg |= E1000_KABGTXD_BGSQLBIAS;
ew32(KABGTXD, reg);
return 0;
}
/**
* e1000_init_hw_ich8lan - Initialize the hardware
* @hw: pointer to the HW structure
*
* Prepares the hardware for transmit and receive by doing the following:
* - initialize hardware bits
* - initialize LED identification
* - setup receive address registers
* - setup flow control
* - setup transmit descriptors
* - clear statistics
**/
static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
{
struct e1000_mac_info *mac = &hw->mac;
u32 ctrl_ext, txdctl, snoop;
s32 ret_val;
u16 i;
e1000_initialize_hw_bits_ich8lan(hw);
/* Initialize identification LED */
ret_val = mac->ops.id_led_init(hw);
/* An error is not fatal and we should not stop init due to this */
if (ret_val)
{
e_dbg("Error initializing identification LED\n");
}
/* Setup the receive address. */
e1000e_init_rx_addrs(hw, mac->rar_entry_count);
/* Zero out the Multicast HASH table */
e_dbg("Zeroing the MTA\n");
for (i = 0; i < mac->mta_reg_count; i++)
{
E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
}
/* The 82578 Rx buffer will stall if wakeup is enabled in host and
* the ME. Disable wakeup by clearing the host wakeup bit.
* Reset the phy after disabling host wakeup to reset the Rx buffer.
*/
if (hw->phy.type == e1000_phy_82578)
{
e1e_rphy(hw, BM_PORT_GEN_CFG, &i);
i &= ~BM_WUC_HOST_WU_BIT;
e1e_wphy(hw, BM_PORT_GEN_CFG, i);
ret_val = e1000_phy_hw_reset_ich8lan(hw);
if (ret_val)
{
return ret_val;
}
}
/* Setup link and flow control */
ret_val = mac->ops.setup_link(hw);
/* Set the transmit descriptor write-back policy for both queues */
txdctl = er32(TXDCTL(0));
txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
E1000_TXDCTL_FULL_TX_DESC_WB);
txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
ew32(TXDCTL(0), txdctl);
txdctl = er32(TXDCTL(1));
txdctl = ((txdctl & ~E1000_TXDCTL_WTHRESH) |
E1000_TXDCTL_FULL_TX_DESC_WB);
txdctl = ((txdctl & ~E1000_TXDCTL_PTHRESH) |
E1000_TXDCTL_MAX_TX_DESC_PREFETCH);
ew32(TXDCTL(1), txdctl);
/* ICH8 has opposite polarity of no_snoop bits.
* By default, we should use snoop behavior.
*/
if (mac->type == e1000_ich8lan)
{
snoop = PCIE_ICH8_SNOOP_ALL;
}
else
{
snoop = (u32)~(PCIE_NO_SNOOP_ALL);
}
e1000e_set_pcie_no_snoop(hw, snoop);
ctrl_ext = er32(CTRL_EXT);
ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
ew32(CTRL_EXT, ctrl_ext);
/* Clear all of the statistics registers (clear on read). It is
* important that we do this after we have tried to establish link
* because the symbol error count will increment wildly if there
* is no link.
*/
e1000_clear_hw_cntrs_ich8lan(hw);
return ret_val;
}
/**
* e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
* @hw: pointer to the HW structure
*
* Sets/Clears required hardware bits necessary for correctly setting up the
* hardware for transmit and receive.
**/
static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
{
u32 reg;
/* Extended Device Control */
reg = er32(CTRL_EXT);
reg |= BIT(22);
/* Enable PHY low-power state when MAC is at D3 w/o WoL */
if (hw->mac.type >= e1000_pchlan)
{
reg |= E1000_CTRL_EXT_PHYPDEN;
}
ew32(CTRL_EXT, reg);
/* Transmit Descriptor Control 0 */
reg = er32(TXDCTL(0));
reg |= BIT(22);
ew32(TXDCTL(0), reg);
/* Transmit Descriptor Control 1 */
reg = er32(TXDCTL(1));
reg |= BIT(22);
ew32(TXDCTL(1), reg);
/* Transmit Arbitration Control 0 */
reg = er32(TARC(0));
if (hw->mac.type == e1000_ich8lan)
{
reg |= BIT(28) | BIT(29);
}
reg |= BIT(23) | BIT(24) | BIT(26) | BIT(27);
ew32(TARC(0), reg);
/* Transmit Arbitration Control 1 */
reg = er32(TARC(1));
if (er32(TCTL) & E1000_TCTL_MULR)
{
reg &= ~BIT(28);
}
else
{
reg |= BIT(28);
}
reg |= BIT(24) | BIT(26) | BIT(30);
ew32(TARC(1), reg);
/* Device Status */
if (hw->mac.type == e1000_ich8lan)
{
reg = er32(STATUS);
reg &= ~BIT(31);
ew32(STATUS, reg);
}
/* work-around descriptor data corruption issue during nfs v2 udp
* traffic, just disable the nfs filtering capability
*/
reg = er32(RFCTL);
reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
/* Disable IPv6 extension header parsing because some malformed
* IPv6 headers can hang the Rx.
*/
if (hw->mac.type == e1000_ich8lan)
{
reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
}
ew32(RFCTL, reg);
/* Enable ECC on Lynxpoint */
if ((hw->mac.type == e1000_pch_lpt) ||
(hw->mac.type == e1000_pch_spt))
{
reg = er32(PBECCSTS);
reg |= E1000_PBECCSTS_ECC_ENABLE;
ew32(PBECCSTS, reg);
reg = er32(CTRL);
reg |= E1000_CTRL_MEHE;
ew32(CTRL, reg);
}
}
/**
* e1000_setup_link_ich8lan - Setup flow control and link settings
* @hw: pointer to the HW structure
*
* Determines which flow control settings to use, then configures flow
* control. Calls the appropriate media-specific link configuration
* function. Assuming the adapter has a valid link partner, a valid link
* should be established. Assumes the hardware has previously been reset
* and the transmitter and receiver are not enabled.
**/
static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
{
s32 ret_val;
if (hw->phy.ops.check_reset_block(hw))
{
return 0;
}
/* ICH parts do not have a word in the NVM to determine
* the default flow control setting, so we explicitly
* set it to full.
*/
if (hw->fc.requested_mode == e1000_fc_default)
{
/* Workaround h/w hang when Tx flow control enabled */
if (hw->mac.type == e1000_pchlan)
{
hw->fc.requested_mode = e1000_fc_rx_pause;
}
else
{
hw->fc.requested_mode = e1000_fc_full;
}
}
/* Save off the requested flow control mode for use later. Depending
* on the link partner's capabilities, we may or may not use this mode.
*/
hw->fc.current_mode = hw->fc.requested_mode;
e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode);
/* Continue to configure the copper link. */
ret_val = hw->mac.ops.setup_physical_interface(hw);
if (ret_val)
{
return ret_val;
}
ew32(FCTTV, hw->fc.pause_time);
if ((hw->phy.type == e1000_phy_82578) ||
(hw->phy.type == e1000_phy_82579) ||
(hw->phy.type == e1000_phy_i217) ||
(hw->phy.type == e1000_phy_82577))
{
ew32(FCRTV_PCH, hw->fc.refresh_time);
ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27),
hw->fc.pause_time);
if (ret_val)
{
return ret_val;
}
}
return e1000e_set_fc_watermarks(hw);
}
/**
* e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
* @hw: pointer to the HW structure
*
* Configures the kumeran interface to the PHY to wait the appropriate time
* when polling the PHY, then call the generic setup_copper_link to finish
* configuring the copper link.
**/
static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
{
u32 ctrl;
s32 ret_val;
u16 reg_data;
ctrl = er32(CTRL);
ctrl |= E1000_CTRL_SLU;
ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
ew32(CTRL, ctrl);
/* Set the mac to wait the maximum time between each iteration
* and increase the max iterations when polling the phy;
* this fixes erroneous timeouts at 10Mbps.
*/
ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
if (ret_val)
{
return ret_val;
}
ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
®_data);
if (ret_val)
{
return ret_val;
}
reg_data |= 0x3F;
ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
reg_data);
if (ret_val)
{
return ret_val;
}
switch (hw->phy.type)
{
case e1000_phy_igp_3:
ret_val = e1000e_copper_link_setup_igp(hw);
if (ret_val)
{
return ret_val;
}
break;
case e1000_phy_bm:
case e1000_phy_82578:
ret_val = e1000e_copper_link_setup_m88(hw);
if (ret_val)
{
return ret_val;
}
break;
case e1000_phy_82577:
case e1000_phy_82579:
ret_val = e1000_copper_link_setup_82577(hw);
if (ret_val)
{
return ret_val;
}
break;
case e1000_phy_ife:
ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, ®_data);
if (ret_val)
{
return ret_val;
}
reg_data &= ~IFE_PMC_AUTO_MDIX;
switch (hw->phy.mdix)
{
case 1:
reg_data &= ~IFE_PMC_FORCE_MDIX;
break;
case 2:
reg_data |= IFE_PMC_FORCE_MDIX;
break;
case 0:
default:
reg_data |= IFE_PMC_AUTO_MDIX;
break;
}
ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
if (ret_val)
{
return ret_val;
}
break;
default:
break;
}
return e1000e_setup_copper_link(hw);
}
/**
* e1000_setup_copper_link_pch_lpt - Configure MAC/PHY interface
* @hw: pointer to the HW structure
*
* Calls the PHY specific link setup function and then calls the
* generic setup_copper_link to finish configuring the link for
* Lynxpoint PCH devices
**/
static s32 e1000_setup_copper_link_pch_lpt(struct e1000_hw *hw)
{
u32 ctrl;
s32 ret_val;
ctrl = er32(CTRL);
ctrl |= E1000_CTRL_SLU;
ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
ew32(CTRL, ctrl);
ret_val = e1000_copper_link_setup_82577(hw);
if (ret_val)
{
return ret_val;
}
return e1000e_setup_copper_link(hw);
}
/**
* e1000_get_link_up_info_ich8lan - Get current link speed and duplex
* @hw: pointer to the HW structure
* @speed: pointer to store current link speed
* @duplex: pointer to store the current link duplex
*
* Calls the generic get_speed_and_duplex to retrieve the current link
* information and then calls the Kumeran lock loss workaround for links at
* gigabit speeds.
**/
static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
u16 *duplex)
{
s32 ret_val;
ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
if (ret_val)
{
return ret_val;
}
if ((hw->mac.type == e1000_ich8lan) &&
(hw->phy.type == e1000_phy_igp_3) && (*speed == SPEED_1000))
{
ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
}
return ret_val;
}
/**
* e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
* @hw: pointer to the HW structure
*
* Work-around for 82566 Kumeran PCS lock loss:
* On link status change (i.e. PCI reset, speed change) and link is up and
* speed is gigabit-
* 0) if workaround is optionally disabled do nothing
* 1) wait 1ms for Kumeran link to come up
* 2) check Kumeran Diagnostic register PCS lock loss bit
* 3) if not set the link is locked (all is good), otherwise...
* 4) reset the PHY
* 5) repeat up to 10 times
* Note: this is only called for IGP3 copper when speed is 1gb.
**/
static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
{
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u32 phy_ctrl;
s32 ret_val;
u16 i, data;
bool link;
if (!dev_spec->kmrn_lock_loss_workaround_enabled)
{
return 0;
}
/* Make sure link is up before proceeding. If not just return.
* Attempting this while link is negotiating fouled up link
* stability
*/
ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
if (!link)
{
return 0;
}
for (i = 0; i < 10; i++)
{
/* read once to clear */
ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
if (ret_val)
{
return ret_val;
}
/* and again to get new status */
ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
if (ret_val)
{
return ret_val;
}
/* check for PCS lock */
if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
{
return 0;
}
/* Issue PHY reset */
e1000_phy_hw_reset(hw);
mdelay(5);
}
/* Disable GigE link negotiation */
phy_ctrl = er32(PHY_CTRL);
phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
ew32(PHY_CTRL, phy_ctrl);
/* Call gig speed drop workaround on Gig disable before accessing
* any PHY registers
*/
e1000e_gig_downshift_workaround_ich8lan(hw);
/* unable to acquire PCS lock */
return -E1000_ERR_PHY;
}
/**
* e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
* @hw: pointer to the HW structure
* @state: boolean value used to set the current Kumeran workaround state
*
* If ICH8, set the current Kumeran workaround state (enabled - true
* /disabled - false).
**/
void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
bool state)
{
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
if (hw->mac.type != e1000_ich8lan)
{
e_dbg("Workaround applies to ICH8 only.\n");
return;
}
dev_spec->kmrn_lock_loss_workaround_enabled = state;
}
/**
* e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
* @hw: pointer to the HW structure
*
* Workaround for 82566 power-down on D3 entry:
* 1) disable gigabit link
* 2) write VR power-down enable
* 3) read it back
* Continue if successful, else issue LCD reset and repeat
**/
void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
{
u32 reg;
u16 data;
u8 retry = 0;
if (hw->phy.type != e1000_phy_igp_3)
{
return;
}
/* Try the workaround twice (if needed) */
do
{
/* Disable link */
reg = er32(PHY_CTRL);
reg |= (E1000_PHY_CTRL_GBE_DISABLE |
E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
ew32(PHY_CTRL, reg);
/* Call gig speed drop workaround on Gig disable before
* accessing any PHY registers
*/
if (hw->mac.type == e1000_ich8lan)
{
e1000e_gig_downshift_workaround_ich8lan(hw);
}
/* Write VR power-down enable */
e1e_rphy(hw, IGP3_VR_CTRL, &data);
data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
/* Read it back and test */
e1e_rphy(hw, IGP3_VR_CTRL, &data);
data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
{
break;
}
/* Issue PHY reset and repeat at most one more time */
reg = er32(CTRL);
ew32(CTRL, reg | E1000_CTRL_PHY_RST);
retry++;
}
while (retry);
}
/**
* e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
* @hw: pointer to the HW structure
*
* Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
* LPLU, Gig disable, MDIC PHY reset):
* 1) Set Kumeran Near-end loopback
* 2) Clear Kumeran Near-end loopback
* Should only be called for ICH8[m] devices with any 1G Phy.
**/
void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
{
s32 ret_val;
u16 reg_data;
if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife))
{
return;
}
ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
®_data);
if (ret_val)
{
return;
}
reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
reg_data);
if (ret_val)
{
return;
}
reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data);
}
/**
* e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
* @hw: pointer to the HW structure
*
* During S0 to Sx transition, it is possible the link remains at gig
* instead of negotiating to a lower speed. Before going to Sx, set
* 'Gig Disable' to force link speed negotiation to a lower speed based on
* the LPLU setting in the NVM or custom setting. For PCH and newer parts,
* the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
* needs to be written.
* Parts that support (and are linked to a partner which support) EEE in
* 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
* than 10Mbps w/o EEE.
**/
void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)
{
struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
u32 phy_ctrl;
s32 ret_val;
phy_ctrl = er32(PHY_CTRL);
phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE;
if (hw->phy.type == e1000_phy_i217)
{
u16 phy_reg, device_id = hw->adapter->pdev->device;
if ((device_id == E1000_DEV_ID_PCH_LPTLP_I218_LM) ||
(device_id == E1000_DEV_ID_PCH_LPTLP_I218_V) ||
(device_id == E1000_DEV_ID_PCH_I218_LM3) ||
(device_id == E1000_DEV_ID_PCH_I218_V3) ||
(hw->mac.type == e1000_pch_spt))
{
u32 fextnvm6 = er32(FEXTNVM6);
ew32(FEXTNVM6, fextnvm6 & ~E1000_FEXTNVM6_REQ_PLL_CLK);
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
goto out;
}
if (!dev_spec->eee_disable)
{
u16 eee_advert;
ret_val =
e1000_read_emi_reg_locked(hw,
I217_EEE_ADVERTISEMENT,
&eee_advert);
if (ret_val)
{
goto release;
}
/* Disable LPLU if both link partners support 100BaseT
* EEE and 100Full is advertised on both ends of the
* link, and enable Auto Enable LPI since there will
* be no driver to enable LPI while in Sx.
*/
if ((eee_advert & I82579_EEE_100_SUPPORTED) &&
(dev_spec->eee_lp_ability &
I82579_EEE_100_SUPPORTED) &&
(hw->phy.autoneg_advertised & ADVERTISE_100_FULL))
{
phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |
E1000_PHY_CTRL_NOND0A_LPLU);
/* Set Auto Enable LPI after link up */
e1e_rphy_locked(hw,
I217_LPI_GPIO_CTRL, &phy_reg);
phy_reg |= I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
e1e_wphy_locked(hw,
I217_LPI_GPIO_CTRL, phy_reg);
}
}
/* For i217 Intel Rapid Start Technology support,
* when the system is going into Sx and no manageability engine
* is present, the driver must configure proxy to reset only on
* power good. LPI (Low Power Idle) state must also reset only
* on power good, as well as the MTA (Multicast table array).
* The SMBus release must also be disabled on LCD reset.
*/
if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
{
/* Enable proxy to reset only on power good. */
e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg);
phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE;
e1e_wphy_locked(hw, I217_PROXY_CTRL, phy_reg);
/* Set bit enable LPI (EEE) to reset only on
* power good.
*/
e1e_rphy_locked(hw, I217_SxCTRL, &phy_reg);
phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET;
e1e_wphy_locked(hw, I217_SxCTRL, phy_reg);
/* Disable the SMB release on LCD reset. */
e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE;
e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
}
/* Enable MTA to reset for Intel Rapid Start Technology
* Support
*/
e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
phy_reg |= I217_CGFREG_ENABLE_MTA_RESET;
e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
release:
hw->phy.ops.release(hw);
}
out:
ew32(PHY_CTRL, phy_ctrl);
if (hw->mac.type == e1000_ich8lan)
{
e1000e_gig_downshift_workaround_ich8lan(hw);
}
if (hw->mac.type >= e1000_pchlan)
{
e1000_oem_bits_config_ich8lan(hw, false);
/* Reset PHY to activate OEM bits on 82577/8 */
if (hw->mac.type == e1000_pchlan)
{
e1000e_phy_hw_reset_generic(hw);
}
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return;
}
e1000_write_smbus_addr(hw);
hw->phy.ops.release(hw);
}
}
/**
* e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
* @hw: pointer to the HW structure
*
* During Sx to S0 transitions on non-managed devices or managed devices
* on which PHY resets are not blocked, if the PHY registers cannot be
* accessed properly by the s/w toggle the LANPHYPC value to power cycle
* the PHY.
* On i217, setup Intel Rapid Start Technology.
**/
void e1000_resume_workarounds_pchlan(struct e1000_hw *hw)
{
s32 ret_val;
if (hw->mac.type < e1000_pch2lan)
{
return;
}
ret_val = e1000_init_phy_workarounds_pchlan(hw);
if (ret_val)
{
e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val);
return;
}
/* For i217 Intel Rapid Start Technology support when the system
* is transitioning from Sx and no manageability engine is present
* configure SMBus to restore on reset, disable proxy, and enable
* the reset on MTA (Multicast table array).
*/
if (hw->phy.type == e1000_phy_i217)
{
u16 phy_reg;
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
e_dbg("Failed to setup iRST\n");
return;
}
/* Clear Auto Enable LPI after link up */
e1e_rphy_locked(hw, I217_LPI_GPIO_CTRL, &phy_reg);
phy_reg &= ~I217_LPI_GPIO_CTRL_AUTO_EN_LPI;
e1e_wphy_locked(hw, I217_LPI_GPIO_CTRL, phy_reg);
if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
{
/* Restore clear on SMB if no manageability engine
* is present
*/
ret_val = e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg);
if (ret_val)
{
goto release;
}
phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE;
e1e_wphy_locked(hw, I217_MEMPWR, phy_reg);
/* Disable Proxy */
e1e_wphy_locked(hw, I217_PROXY_CTRL, 0);
}
/* Enable reset on MTA */
ret_val = e1e_rphy_locked(hw, I217_CGFREG, &phy_reg);
if (ret_val)
{
goto release;
}
phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET;
e1e_wphy_locked(hw, I217_CGFREG, phy_reg);
release:
if (ret_val)
{
e_dbg("Error %d in resume workarounds\n", ret_val);
}
hw->phy.ops.release(hw);
}
}
/**
* e1000_cleanup_led_ich8lan - Restore the default LED operation
* @hw: pointer to the HW structure
*
* Return the LED back to the default configuration.
**/
static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
{
if (hw->phy.type == e1000_phy_ife)
{
return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
}
ew32(LEDCTL, hw->mac.ledctl_default);
return 0;
}
/**
* e1000_led_on_ich8lan - Turn LEDs on
* @hw: pointer to the HW structure
*
* Turn on the LEDs.
**/
static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
{
if (hw->phy.type == e1000_phy_ife)
return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
(IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
ew32(LEDCTL, hw->mac.ledctl_mode2);
return 0;
}
/**
* e1000_led_off_ich8lan - Turn LEDs off
* @hw: pointer to the HW structure
*
* Turn off the LEDs.
**/
static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
{
if (hw->phy.type == e1000_phy_ife)
return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
(IFE_PSCL_PROBE_MODE |
IFE_PSCL_PROBE_LEDS_OFF));
ew32(LEDCTL, hw->mac.ledctl_mode1);
return 0;
}
/**
* e1000_setup_led_pchlan - Configures SW controllable LED
* @hw: pointer to the HW structure
*
* This prepares the SW controllable LED for use.
**/
static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
{
return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1);
}
/**
* e1000_cleanup_led_pchlan - Restore the default LED operation
* @hw: pointer to the HW structure
*
* Return the LED back to the default configuration.
**/
static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
{
return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default);
}
/**
* e1000_led_on_pchlan - Turn LEDs on
* @hw: pointer to the HW structure
*
* Turn on the LEDs.
**/
static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
{
u16 data = (u16)hw->mac.ledctl_mode2;
u32 i, led;
/* If no link, then turn LED on by setting the invert bit
* for each LED that's mode is "link_up" in ledctl_mode2.
*/
if (!(er32(STATUS) & E1000_STATUS_LU))
{
for (i = 0; i < 3; i++)
{
led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
if ((led & E1000_PHY_LED0_MODE_MASK) !=
E1000_LEDCTL_MODE_LINK_UP)
{
continue;
}
if (led & E1000_PHY_LED0_IVRT)
{
data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
}
else
{
data |= (E1000_PHY_LED0_IVRT << (i * 5));
}
}
}
return e1e_wphy(hw, HV_LED_CONFIG, data);
}
/**
* e1000_led_off_pchlan - Turn LEDs off
* @hw: pointer to the HW structure
*
* Turn off the LEDs.
**/
static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
{
u16 data = (u16)hw->mac.ledctl_mode1;
u32 i, led;
/* If no link, then turn LED off by clearing the invert bit
* for each LED that's mode is "link_up" in ledctl_mode1.
*/
if (!(er32(STATUS) & E1000_STATUS_LU))
{
for (i = 0; i < 3; i++)
{
led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
if ((led & E1000_PHY_LED0_MODE_MASK) !=
E1000_LEDCTL_MODE_LINK_UP)
{
continue;
}
if (led & E1000_PHY_LED0_IVRT)
{
data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
}
else
{
data |= (E1000_PHY_LED0_IVRT << (i * 5));
}
}
}
return e1e_wphy(hw, HV_LED_CONFIG, data);
}
/**
* e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
* @hw: pointer to the HW structure
*
* Read appropriate register for the config done bit for completion status
* and configure the PHY through s/w for EEPROM-less parts.
*
* NOTE: some silicon which is EEPROM-less will fail trying to read the
* config done bit, so only an error is logged and continues. If we were
* to return with error, EEPROM-less silicon would not be able to be reset
* or change link.
**/
static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
{
s32 ret_val = 0;
u32 bank = 0;
u32 status;
e1000e_get_cfg_done_generic(hw);
/* Wait for indication from h/w that it has completed basic config */
if (hw->mac.type >= e1000_ich10lan)
{
e1000_lan_init_done_ich8lan(hw);
}
else
{
ret_val = e1000e_get_auto_rd_done(hw);
if (ret_val)
{
/* When auto config read does not complete, do not
* return with an error. This can happen in situations
* where there is no eeprom and prevents getting link.
*/
e_dbg("Auto Read Done did not complete\n");
ret_val = 0;
}
}
/* Clear PHY Reset Asserted bit */
status = er32(STATUS);
if (status & E1000_STATUS_PHYRA)
{
ew32(STATUS, status & ~E1000_STATUS_PHYRA);
}
else
{
e_dbg("PHY Reset Asserted not set - needs delay\n");
}
/* If EEPROM is not marked present, init the IGP 3 PHY manually */
if (hw->mac.type <= e1000_ich9lan)
{
if (!(er32(EECD) & E1000_EECD_PRES) &&
(hw->phy.type == e1000_phy_igp_3))
{
e1000e_phy_init_script_igp3(hw);
}
}
else
{
if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank))
{
/* Maybe we should do a basic PHY config */
e_dbg("EEPROM not present\n");
ret_val = -E1000_ERR_CONFIG;
}
}
return ret_val;
}
/**
* e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
* @hw: pointer to the HW structure
*
* In the case of a PHY power down to save power, or to turn off link during a
* driver unload, or wake on lan is not enabled, remove the link.
**/
static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
{
/* If the management interface is not enabled, then power down */
if (!(hw->mac.ops.check_mng_mode(hw) ||
hw->phy.ops.check_reset_block(hw)))
{
e1000_power_down_phy_copper(hw);
}
}
/**
* e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
* @hw: pointer to the HW structure
*
* Clears hardware counters specific to the silicon family and calls
* clear_hw_cntrs_generic to clear all general purpose counters.
**/
static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
{
u16 phy_data;
s32 ret_val;
e1000e_clear_hw_cntrs_base(hw);
er32(ALGNERRC);
er32(RXERRC);
er32(TNCRS);
er32(CEXTERR);
er32(TSCTC);
er32(TSCTFC);
er32(MGTPRC);
er32(MGTPDC);
er32(MGTPTC);
er32(IAC);
er32(ICRXOC);
/* Clear PHY statistics registers */
if ((hw->phy.type == e1000_phy_82578) ||
(hw->phy.type == e1000_phy_82579) ||
(hw->phy.type == e1000_phy_i217) ||
(hw->phy.type == e1000_phy_82577))
{
ret_val = hw->phy.ops.acquire(hw);
if (ret_val)
{
return;
}
ret_val = hw->phy.ops.set_page(hw,
HV_STATS_PAGE << IGP_PAGE_SHIFT);
if (ret_val)
{
goto release;
}
hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data);
hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data);
release:
hw->phy.ops.release(hw);
}
}
static const struct e1000_mac_operations ich8_mac_ops =
{
/* check_mng_mode dependent on mac type */
.check_for_link = e1000_check_for_copper_link_ich8lan,
/* cleanup_led dependent on mac type */
.clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
.get_bus_info = e1000_get_bus_info_ich8lan,
.set_lan_id = e1000_set_lan_id_single_port,
.get_link_up_info = e1000_get_link_up_info_ich8lan,
/* led_on dependent on mac type */
/* led_off dependent on mac type */
.update_mc_addr_list = e1000e_update_mc_addr_list_generic,
.reset_hw = e1000_reset_hw_ich8lan,
.init_hw = e1000_init_hw_ich8lan,
.setup_link = e1000_setup_link_ich8lan,
.setup_physical_interface = e1000_setup_copper_link_ich8lan,
/* id_led_init dependent on mac type */
.config_collision_dist = e1000e_config_collision_dist_generic,
.rar_set = e1000e_rar_set_generic,
.rar_get_count = e1000e_rar_get_count_generic,
};
static const struct e1000_phy_operations ich8_phy_ops =
{
.acquire = e1000_acquire_swflag_ich8lan,
.check_reset_block = e1000_check_reset_block_ich8lan,
.commit = NULL,
.get_cfg_done = e1000_get_cfg_done_ich8lan,
.get_cable_length = e1000e_get_cable_length_igp_2,
.read_reg = e1000e_read_phy_reg_igp,
.release = e1000_release_swflag_ich8lan,
.reset = e1000_phy_hw_reset_ich8lan,
.set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan,
.set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan,
.write_reg = e1000e_write_phy_reg_igp,
};
static const struct e1000_nvm_operations ich8_nvm_ops =
{
.acquire = e1000_acquire_nvm_ich8lan,
.read = e1000_read_nvm_ich8lan,
.release = e1000_release_nvm_ich8lan,
.reload = e1000e_reload_nvm_generic,
.update = e1000_update_nvm_checksum_ich8lan,
.valid_led_default = e1000_valid_led_default_ich8lan,
.validate = e1000_validate_nvm_checksum_ich8lan,
.write = e1000_write_nvm_ich8lan,
};
static const struct e1000_nvm_operations spt_nvm_ops =
{
.acquire = e1000_acquire_nvm_ich8lan,
.release = e1000_release_nvm_ich8lan,
.read = e1000_read_nvm_spt,
.update = e1000_update_nvm_checksum_spt,
.reload = e1000e_reload_nvm_generic,
.valid_led_default = e1000_valid_led_default_ich8lan,
.validate = e1000_validate_nvm_checksum_ich8lan,
.write = e1000_write_nvm_ich8lan,
};
const struct e1000_info e1000_ich8_info =
{
.mac = e1000_ich8lan,
.flags = FLAG_HAS_WOL
| FLAG_IS_ICH
| FLAG_HAS_CTRLEXT_ON_LOAD
| FLAG_HAS_AMT
| FLAG_HAS_FLASH
| FLAG_APME_IN_WUC,
.pba = 8,
.max_hw_frame_size = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN,
.get_variants = e1000_get_variants_ich8lan,
.mac_ops = &ich8_mac_ops,
.phy_ops = &ich8_phy_ops,
.nvm_ops = &ich8_nvm_ops,
};
const struct e1000_info e1000_ich9_info =
{
.mac = e1000_ich9lan,
.flags = FLAG_HAS_JUMBO_FRAMES
| FLAG_IS_ICH
| FLAG_HAS_WOL
| FLAG_HAS_CTRLEXT_ON_LOAD
| FLAG_HAS_AMT
| FLAG_HAS_FLASH
| FLAG_APME_IN_WUC,
.pba = 18,
.max_hw_frame_size = DEFAULT_JUMBO,
.get_variants = e1000_get_variants_ich8lan,
.mac_ops = &ich8_mac_ops,
.phy_ops = &ich8_phy_ops,
.nvm_ops = &ich8_nvm_ops,
};
const struct e1000_info e1000_ich10_info =
{
.mac = e1000_ich10lan,
.flags = FLAG_HAS_JUMBO_FRAMES
| FLAG_IS_ICH
| FLAG_HAS_WOL
| FLAG_HAS_CTRLEXT_ON_LOAD
| FLAG_HAS_AMT
| FLAG_HAS_FLASH
| FLAG_APME_IN_WUC,
.pba = 18,
.max_hw_frame_size = DEFAULT_JUMBO,
.get_variants = e1000_get_variants_ich8lan,
.mac_ops = &ich8_mac_ops,
.phy_ops = &ich8_phy_ops,
.nvm_ops = &ich8_nvm_ops,
};
const struct e1000_info e1000_pch_info =
{
.mac = e1000_pchlan,
.flags = FLAG_IS_ICH
| FLAG_HAS_WOL
| FLAG_HAS_CTRLEXT_ON_LOAD
| FLAG_HAS_AMT
| FLAG_HAS_FLASH
| FLAG_HAS_JUMBO_FRAMES
| FLAG_DISABLE_FC_PAUSE_TIME /* errata */
| FLAG_APME_IN_WUC,
.flags2 = FLAG2_HAS_PHY_STATS,
.pba = 26,
.max_hw_frame_size = 4096,
.get_variants = e1000_get_variants_ich8lan,
.mac_ops = &ich8_mac_ops,
.phy_ops = &ich8_phy_ops,
.nvm_ops = &ich8_nvm_ops,
};
const struct e1000_info e1000_pch2_info =
{
.mac = e1000_pch2lan,
.flags = FLAG_IS_ICH
| FLAG_HAS_WOL
| FLAG_HAS_HW_TIMESTAMP
| FLAG_HAS_CTRLEXT_ON_LOAD
| FLAG_HAS_AMT
| FLAG_HAS_FLASH
| FLAG_HAS_JUMBO_FRAMES
| FLAG_APME_IN_WUC,
.flags2 = FLAG2_HAS_PHY_STATS
| FLAG2_HAS_EEE,
.pba = 26,
.max_hw_frame_size = 9022,
.get_variants = e1000_get_variants_ich8lan,
.mac_ops = &ich8_mac_ops,
.phy_ops = &ich8_phy_ops,
.nvm_ops = &ich8_nvm_ops,
};
const struct e1000_info e1000_pch_lpt_info =
{
.mac = e1000_pch_lpt,
.flags = FLAG_IS_ICH
| FLAG_HAS_WOL
| FLAG_HAS_HW_TIMESTAMP
| FLAG_HAS_CTRLEXT_ON_LOAD
| FLAG_HAS_AMT
| FLAG_HAS_FLASH
| FLAG_HAS_JUMBO_FRAMES
| FLAG_APME_IN_WUC,
.flags2 = FLAG2_HAS_PHY_STATS
| FLAG2_HAS_EEE
| FLAG2_CHECK_SYSTIM_OVERFLOW,
.pba = 26,
.max_hw_frame_size = 9022,
.get_variants = e1000_get_variants_ich8lan,
.mac_ops = &ich8_mac_ops,
.phy_ops = &ich8_phy_ops,
.nvm_ops = &ich8_nvm_ops,
};
const struct e1000_info e1000_pch_spt_info =
{
.mac = e1000_pch_spt,
.flags = FLAG_IS_ICH
| FLAG_HAS_WOL
| FLAG_HAS_HW_TIMESTAMP
| FLAG_HAS_CTRLEXT_ON_LOAD
| FLAG_HAS_AMT
| FLAG_HAS_FLASH
| FLAG_HAS_JUMBO_FRAMES
| FLAG_APME_IN_WUC,
.flags2 = FLAG2_HAS_PHY_STATS
| FLAG2_HAS_EEE,
.pba = 26,
.max_hw_frame_size = 9022,
.get_variants = e1000_get_variants_ich8lan,
.mac_ops = &ich8_mac_ops,
.phy_ops = &ich8_phy_ops,
.nvm_ops = &spt_nvm_ops,
};
| williamfdevine/PrettyLinux | drivers/net/ethernet/intel/e1000e/ich8lan.c | C | gpl-3.0 | 169,375 | [
30522,
1013,
1008,
13420,
4013,
1013,
6694,
11603,
4062,
1008,
9385,
1006,
1039,
1007,
2639,
1011,
2325,
13420,
3840,
1012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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-2014 Eurocommercial Properties NV
*
*
* 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.estatio.module.lease.fixtures;
import javax.inject.Inject;
import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.fixturescripts.FixtureScript;
import org.isisaddons.module.security.dom.tenancy.ApplicationTenancyRepository;
import org.estatio.module.lease.dom.LeaseType;
import org.estatio.module.lease.dom.LeaseTypeRepository;
@Programmatic
public class LeaseTypeForItalyRefData extends FixtureScript {
private enum LeaseTypeData {
AA("Apparecchiature Automatic"),
AD("Affitto d'Azienda"),
CG("Comodato Gratuito"),
CO("Comodato"),
DH("Dehors"),
LO("Locazione"),
OA("Occup. Abusiva Affito"),
OL("Occup. Abusiva Locazione"),
PA("Progroga Affitto"),
PL("Progroga Locazione"),
PP("Pannelli Pubblicitari"),
PR("Precaria"),
SA("Scritt. Privata Affitto"),
SL("Scritt. Privata Locazione");
private final String title;
private LeaseTypeData(final String title) {
this.title = title;
}
public String title() {
return title;
}
}
@Override
protected void execute(ExecutionContext fixtureResults) {
for (LeaseTypeData ltd : LeaseTypeData.values()) {
createLeaseType(fixtureResults, ltd);
}
}
private void createLeaseType(ExecutionContext fixtureResults, LeaseTypeData ltd) {
final LeaseType leaseType = leaseTypeRepository.findOrCreate(ltd.name(), ltd.title(), applicationTenancyRepository.findByPath("/ITA"));
fixtureResults.addResult(this, leaseType.getReference(), leaseType);
}
// //////////////////////////////////////
@Inject
private LeaseTypeRepository leaseTypeRepository;
@Inject
private ApplicationTenancyRepository applicationTenancyRepository;
}
| estatio/estatio | estatioapp/app/src/main/java/org/estatio/module/lease/fixtures/LeaseTypeForItalyRefData.java | Java | apache-2.0 | 2,513 | [
30522,
1013,
1008,
1008,
1008,
9385,
2262,
1011,
2297,
9944,
9006,
5017,
13247,
5144,
1050,
2615,
1008,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1008,
1000,
6105,
1000,
1007,
1025,
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... |
import {rnaPlot} from './rnaplot.js';
export function rnaTreemapChart() {
var width = 550;
var height = 400;
function rnaTreemapNode(selection) {
// create a background rectangle for each RNA structure
selection.each(function(d) {
d3.select(this)
.attr('transform', function(d) { return 'translate(' + d.x + ',' + d.y + ')' })
.append('rect')
.classed('structure-background-rect', true)
.attr('width', function(d) { return Math.max(0, d.dx); })
.attr('height', function(d) { return Math.max(0, d.dy); })
// draw the actual RNA structure
var chart = rnaPlot()
.width( Math.max(0, d.dx))
.height( Math.max(0, d.dy))
.labelInterval(0)
.rnaEdgePadding(10)
.showNucleotideLabels(false);
if ('structure' in d) d3.select(this).call(chart)
});
}
var chart = function(selection) {
selection.each(function(data) {
console.log('data:', data)
// initialize the treemap structure
// sample input
// { 'name': 'blah',
// 'children: [{'structure': '..((..))',
// 'sequence': 'ACCGGCC',
// 'size': 50}]
// }
var treemap = d3.layout.treemap()
.size([width, height])
.sticky(false)
.value(function(d) { return d.size; });
// create a new <g> for each node in the treemap
// this may be a little redundant, since we expect the calling
// selection to contain their own g elements
var gEnter = d3.select(this).append('g');
var treemapGnodes = gEnter.datum(data).selectAll('.treemapNode')
.data(treemap.nodes)
.enter()
.append('g')
.attr('class', 'treemapNode')
.call(rnaTreemapNode);
});
};
chart.width = function(_) {
if (!arguments.length) return width;
width = _;
return chart;
}
chart.height = function(_) {
if (!arguments.length) return height;
height = _;
return chart;
}
return chart;
}
function rnaTreemapGridChart() {
var chart = function(selection) {
console.log('selection:', selection);
selection.each(function(data) {
console.log('data:', data);
});
}
return chart;
}
| pkerpedjiev/fornac | app/scripts/rnatreemap.js | JavaScript | apache-2.0 | 2,511 | [
30522,
12324,
1063,
12987,
24759,
4140,
1065,
2013,
1005,
1012,
1013,
12987,
24759,
4140,
1012,
1046,
2015,
1005,
1025,
9167,
3853,
12987,
13334,
2863,
15042,
10686,
1006,
1007,
1063,
13075,
9381,
1027,
13274,
1025,
13075,
4578,
1027,
4278,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#pragma mark Blocks
typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown
#pragma mark Named Structures
struct LogCategory {
int _field1;
int _field2;
char *_field3;
unsigned int _field4;
char *_field5;
char *_field6;
int _field7;
struct LogCategory *_field8;
struct LogOutput *_field9;
struct LogOutput *_field10;
unsigned long long _field11;
unsigned long long _field12;
unsigned int _field13;
unsigned int _field14;
};
struct LogOutput;
#pragma mark -
//
// File: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/CoreUtils.framework/CoreUtils
// UUID: 6D27FB3C-8FD9-3782-A853-5BA2D032CB04
//
// Arch: x86_64
// Current version: 1.0.0
// Compatibility version: 1.0.0
// Source version: 100.26.0.0.0
// Minimum iOS version: 8.0.0
// SDK version: 8.0.0
//
// Objective-C Garbage Collection: Unsupported
//
@protocol CBCentralManagerDelegate <NSObject>
- (void)centralManagerDidUpdateState:(CBCentralManager *)arg1;
@optional
- (void)centralManager:(CBCentralManager *)arg1 didDisconnectPeripheral:(CBPeripheral *)arg2 error:(NSError *)arg3;
- (void)centralManager:(CBCentralManager *)arg1 didFailToConnectPeripheral:(CBPeripheral *)arg2 error:(NSError *)arg3;
- (void)centralManager:(CBCentralManager *)arg1 didConnectPeripheral:(CBPeripheral *)arg2;
- (void)centralManager:(CBCentralManager *)arg1 didDiscoverPeripheral:(CBPeripheral *)arg2 advertisementData:(NSDictionary *)arg3 RSSI:(NSNumber *)arg4;
- (void)centralManager:(CBCentralManager *)arg1 didRetrieveConnectedPeripherals:(NSArray *)arg2;
- (void)centralManager:(CBCentralManager *)arg1 didRetrievePeripherals:(NSArray *)arg2;
- (void)centralManager:(CBCentralManager *)arg1 willRestoreState:(NSDictionary *)arg2;
@end
@protocol CBPeripheralManagerDelegate <NSObject>
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)arg1;
@optional
- (void)peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager *)arg1;
- (void)peripheralManager:(CBPeripheralManager *)arg1 didReceiveWriteRequests:(NSArray *)arg2;
- (void)peripheralManager:(CBPeripheralManager *)arg1 didReceiveReadRequest:(CBATTRequest *)arg2;
- (void)peripheralManager:(CBPeripheralManager *)arg1 central:(CBCentral *)arg2 didUnsubscribeFromCharacteristic:(CBCharacteristic *)arg3;
- (void)peripheralManager:(CBPeripheralManager *)arg1 central:(CBCentral *)arg2 didSubscribeToCharacteristic:(CBCharacteristic *)arg3;
- (void)peripheralManager:(CBPeripheralManager *)arg1 didAddService:(CBService *)arg2 error:(NSError *)arg3;
- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)arg1 error:(NSError *)arg2;
- (void)peripheralManager:(CBPeripheralManager *)arg1 willRestoreState:(NSDictionary *)arg2;
@end
@protocol NSObject
@property(readonly, copy) NSString *description;
@property(readonly) Class superclass;
@property(readonly) unsigned long long hash;
- (struct _NSZone *)zone;
- (unsigned long long)retainCount;
- (id)autorelease;
- (oneway void)release;
- (id)retain;
- (_Bool)respondsToSelector:(SEL)arg1;
- (_Bool)conformsToProtocol:(Protocol *)arg1;
- (_Bool)isMemberOfClass:(Class)arg1;
- (_Bool)isKindOfClass:(Class)arg1;
- (_Bool)isProxy;
- (id)performSelector:(SEL)arg1 withObject:(id)arg2 withObject:(id)arg3;
- (id)performSelector:(SEL)arg1 withObject:(id)arg2;
- (id)performSelector:(SEL)arg1;
- (id)self;
- (Class)class;
- (_Bool)isEqual:(id)arg1;
@optional
@property(readonly, copy) NSString *debugDescription;
@end
__attribute__((visibility("hidden")))
@interface BTLEAccessory : NSObject
{
CBPeripheral *_peripheral;
NSString *_name;
double _lastSeen;
int _lastRSSI;
}
@property int RSSI; // @synthesize RSSI=_lastRSSI;
@property double lastSeen; // @synthesize lastSeen=_lastSeen;
@property(copy) NSString *name; // @synthesize name=_name;
@property(retain) CBPeripheral *peripheral; // @synthesize peripheral=_peripheral;
- (void)dealloc;
- (id)initWithPeripheral:(id)arg1;
@end
@interface BTLEBrowser : NSObject <CBCentralManagerDelegate>
{
struct LogCategory *_ucat;
NSObject<OS_dispatch_queue> *_queue;
NSSet *_serviceUUIDs;
CDUnknownBlockType _foundHandler;
CDUnknownBlockType _lostHandler;
CDUnknownBlockType _updateHandler;
CDUnknownBlockType _stoppedHandler;
CBCentralManager *_centralManager;
_Bool _started;
NSMutableDictionary *_accessories;
NSObject<OS_dispatch_source> *_lostTimer;
}
@property(copy) CDUnknownBlockType stoppedHandler; // @synthesize stoppedHandler=_stoppedHandler;
@property(copy) CDUnknownBlockType updateHandler; // @synthesize updateHandler=_updateHandler;
@property(copy) CDUnknownBlockType lostHandler; // @synthesize lostHandler=_lostHandler;
@property(copy) CDUnknownBlockType foundHandler; // @synthesize foundHandler=_foundHandler;
@property(copy) NSSet *serviceUUIDs; // @synthesize serviceUUIDs=_serviceUUIDs;
@property struct LogCategory *logCategory; // @synthesize logCategory=_ucat;
@property(retain) NSObject<OS_dispatch_queue> *dispatchQueue; // @synthesize dispatchQueue=_queue;
- (void)_lostTimer;
- (void)centralManager:(id)arg1 didDiscoverPeripheral:(id)arg2 advertisementData:(id)arg3 RSSI:(id)arg4;
- (void)centralManagerDidUpdateState:(id)arg1;
- (void)_stop:(int)arg1;
- (void)stop;
- (void)_start;
- (void)start;
- (void)dealloc;
- (id)init;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
@interface BTLEClient : NSObject <CBCentralManagerDelegate>
{
struct LogCategory *_ucat;
NSObject<OS_dispatch_queue> *_queue;
NSDictionary *_accessoryInfo;
CDUnknownBlockType _connectHandler;
CDUnknownBlockType _disconnectHandler;
CBCentralManager *_centralManager;
CBPeripheral *_peripheral;
_Bool _connectPending;
NSMutableArray *_transactionQueue;
}
@property(copy) CDUnknownBlockType disconnectHandler; // @synthesize disconnectHandler=_disconnectHandler;
@property(copy) CDUnknownBlockType connectHandler; // @synthesize connectHandler=_connectHandler;
@property(copy) NSDictionary *accessoryInfo; // @synthesize accessoryInfo=_accessoryInfo;
@property struct LogCategory *logCategory; // @synthesize logCategory=_ucat;
@property(retain) NSObject<OS_dispatch_queue> *dispatchQueue; // @synthesize dispatchQueue=_queue;
- (void)centralManager:(id)arg1 didDisconnectPeripheral:(id)arg2 error:(id)arg3;
- (void)centralManager:(id)arg1 didFailToConnectPeripheral:(id)arg2 error:(id)arg3;
- (void)centralManager:(id)arg1 didConnectPeripheral:(id)arg2;
- (void)centralManagerDidUpdateState:(id)arg1;
- (void)_processTransactions;
- (void)writeData:(id)arg1 requestCharacteristic:(id)arg2 responseCharacteristic:(id)arg3 replyHandler:(CDUnknownBlockType)arg4;
- (void)writeData:(id)arg1 characteristic:(id)arg2 writeHandler:(CDUnknownBlockType)arg3;
- (void)readDataForCharacteristic:(id)arg1 readHandler:(CDUnknownBlockType)arg2;
- (void)_disconnect;
- (void)disconnect;
- (void)_connect2;
- (void)_connect;
- (void)connect;
- (void)dealloc;
- (id)init;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
__attribute__((visibility("hidden")))
@interface BTLEClientTransaction : NSObject
{
BTLEClient *_client;
NSString *_writeCharacteristic;
NSData *_writeData;
NSString *_readCharacteristic;
NSData *_readData;
CDUnknownBlockType _readHandler;
CDUnknownBlockType _writeHandler;
CDUnknownBlockType _replyHandler;
}
@property(copy) CDUnknownBlockType replyHandler; // @synthesize replyHandler=_replyHandler;
@property(copy) CDUnknownBlockType writeHandler; // @synthesize writeHandler=_writeHandler;
@property(copy) CDUnknownBlockType readHandler; // @synthesize readHandler=_readHandler;
@property(copy) NSData *readData; // @synthesize readData=_readData;
@property(copy) NSString *readCharacteristic; // @synthesize readCharacteristic=_readCharacteristic;
@property(copy) NSData *writeData; // @synthesize writeData=_writeData;
@property(copy) NSString *writeCharacteristic; // @synthesize writeCharacteristic=_writeCharacteristic;
@property(retain) BTLEClient *client; // @synthesize client=_client;
@end
@interface BTLEServer : NSObject <CBPeripheralManagerDelegate>
{
struct LogCategory *_ucat;
NSObject<OS_dispatch_queue> *_queue;
NSUUID *_advertiseUUID;
NSDictionary *_configuration;
NSMutableDictionary *_characteristics;
CDUnknownBlockType _readHandler;
CDUnknownBlockType _writeHandler;
CBPeripheralManager *_peripheralManager;
_Bool _started;
NSMutableDictionary *_pendingReplies;
}
@property(copy) CDUnknownBlockType writeHandler; // @synthesize writeHandler=_writeHandler;
@property(copy) CDUnknownBlockType readHandler; // @synthesize readHandler=_readHandler;
@property(copy) NSDictionary *configuration; // @synthesize configuration=_configuration;
@property struct LogCategory *logCategory; // @synthesize logCategory=_ucat;
@property(retain) NSObject<OS_dispatch_queue> *dispatchQueue; // @synthesize dispatchQueue=_queue;
@property(copy) NSUUID *advertiseUUID; // @synthesize advertiseUUID=_advertiseUUID;
- (void)completeWriteRequests:(id)arg1 status:(int)arg2;
- (void)completeReadRequest:(id)arg1 status:(int)arg2;
- (void)peripheralManagerIsReadyToUpdateSubscribers:(id)arg1;
- (void)peripheralManager:(id)arg1 didReceiveWriteRequests:(id)arg2;
- (void)peripheralManager:(id)arg1 didReceiveReadRequest:(id)arg2;
- (void)peripheralManager:(id)arg1 central:(id)arg2 didUnsubscribeFromCharacteristic:(id)arg3;
- (void)peripheralManager:(id)arg1 central:(id)arg2 didSubscribeToCharacteristic:(id)arg3;
- (void)peripheralManager:(id)arg1 didAddService:(id)arg2 error:(id)arg3;
- (void)peripheralManagerDidStartAdvertising:(id)arg1 error:(id)arg2;
- (void)peripheralManagerDidUpdateState:(id)arg1;
- (void)_stop:(int)arg1;
- (void)stop;
- (int)_start2;
- (void)_start;
- (void)start;
- (void)dealloc;
- (id)init;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
__attribute__((visibility("hidden")))
@interface BTLETransaction : NSObject
{
NSString *_identifier;
CBATTRequest *_request;
NSString *_replyCharacteristic;
NSData *_replyData;
_Bool _waitingToUpdate;
}
@property _Bool waitingToUpdate; // @synthesize waitingToUpdate=_waitingToUpdate;
@property(copy) NSData *replyData; // @synthesize replyData=_replyData;
@property(copy) NSString *replyCharacteristic; // @synthesize replyCharacteristic=_replyCharacteristic;
@property CBATTRequest *request; // @synthesize request=_request;
@property(copy) NSString *identifier; // @synthesize identifier=_identifier;
@property(copy) NSData *requestData;
@property(readonly) NSString *requestCharacteristic;
- (void)dealloc;
@end
__attribute__((visibility("hidden")))
@interface CAAnimationDelegateBlockHelper : NSObject
{
CDUnknownBlockType _animationDidStartBlock;
CDUnknownBlockType _animationDidStopBlock;
}
@property(copy) CDUnknownBlockType animationDidStopBlock; // @synthesize animationDidStopBlock=_animationDidStopBlock;
@property(copy) CDUnknownBlockType animationDidStartBlock; // @synthesize animationDidStartBlock=_animationDidStartBlock;
- (void)animationDidStop:(id)arg1 finished:(_Bool)arg2;
- (void)animationDidStart:(id)arg1;
- (void)dealloc;
@end
@interface WiFiScanner : NSObject
{
_Bool _started;
NSMutableSet *_devices;
_Bool _autoPoweredOn;
NSObject<OS_dispatch_source> *_scanTimer;
int _stopErr;
unsigned int _scanFlags;
NSObject<OS_dispatch_queue> *_queue;
struct LogCategory *_ucat;
CDUnknownBlockType _handler;
}
@property(copy) CDUnknownBlockType handler; // @synthesize handler=_handler;
@property unsigned int scanFlags; // @synthesize scanFlags=_scanFlags;
@property struct LogCategory *logCategory; // @synthesize logCategory=_ucat;
@property(retain) NSObject<OS_dispatch_queue> *dispatchQueue; // @synthesize dispatchQueue=_queue;
- (_Bool)_isUnconfiguredIE:(id)arg1;
- (void)_stop2;
- (void)_stop:(int)arg1;
- (void)stop;
- (void)start;
@property(readonly, copy) NSSet *devices;
- (void)dealloc;
- (id)init;
@end
| squarefrog/XVim | XcodeClasses/Xcode6.0/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/PrivateFrameworks/CoreUtils.h | C | mit | 12,821 | [
30522,
1013,
1013,
1013,
1013,
7013,
2011,
2465,
1011,
15653,
1017,
1012,
1019,
1006,
4185,
2978,
1007,
1012,
1013,
1013,
1013,
1013,
2465,
1011,
15653,
2003,
9385,
1006,
1039,
1007,
2722,
1011,
2687,
1010,
2456,
1011,
2541,
1010,
2432,
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... |
'use strict'
const Buffer = require('safe-buffer').Buffer
const crypto = require('crypto')
const Transform = require('stream').Transform
const SPEC_ALGORITHMS = ['sha256', 'sha384', 'sha512']
const BASE64_REGEX = /^[a-z0-9+/]+(?:=?=?)$/i
const SRI_REGEX = /^([^-]+)-([^?]+)([?\S*]*)$/
const STRICT_SRI_REGEX = /^([^-]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)*$/
const VCHAR_REGEX = /^[\x21-\x7E]+$/
class Hash {
get isHash () { return true }
constructor (hash, opts) {
const strict = !!(opts && opts.strict)
this.source = hash.trim()
// 3.1. Integrity metadata (called "Hash" by ssri)
// https://w3c.github.io/webappsec-subresource-integrity/#integrity-metadata-description
const match = this.source.match(
strict
? STRICT_SRI_REGEX
: SRI_REGEX
)
if (!match) { return }
if (strict && !SPEC_ALGORITHMS.some(a => a === match[1])) { return }
this.algorithm = match[1]
this.digest = match[2]
const rawOpts = match[3]
this.options = rawOpts ? rawOpts.slice(1).split('?') : []
}
hexDigest () {
return this.digest && Buffer.from(this.digest, 'base64').toString('hex')
}
toJSON () {
return this.toString()
}
toString (opts) {
if (opts && opts.strict) {
// Strict mode enforces the standard as close to the foot of the
// letter as it can.
if (!(
// The spec has very restricted productions for algorithms.
// https://www.w3.org/TR/CSP2/#source-list-syntax
SPEC_ALGORITHMS.some(x => x === this.algorithm) &&
// Usually, if someone insists on using a "different" base64, we
// leave it as-is, since there's multiple standards, and the
// specified is not a URL-safe variant.
// https://www.w3.org/TR/CSP2/#base64_value
this.digest.match(BASE64_REGEX) &&
// Option syntax is strictly visual chars.
// https://w3c.github.io/webappsec-subresource-integrity/#grammardef-option-expression
// https://tools.ietf.org/html/rfc5234#appendix-B.1
(this.options || []).every(opt => opt.match(VCHAR_REGEX))
)) {
return ''
}
}
const options = this.options && this.options.length
? `?${this.options.join('?')}`
: ''
return `${this.algorithm}-${this.digest}${options}`
}
}
class Integrity {
get isIntegrity () { return true }
toJSON () {
return this.toString()
}
toString (opts) {
opts = opts || {}
let sep = opts.sep || ' '
if (opts.strict) {
// Entries must be separated by whitespace, according to spec.
sep = sep.replace(/\S+/g, ' ')
}
return Object.keys(this).map(k => {
return this[k].map(hash => {
return Hash.prototype.toString.call(hash, opts)
}).filter(x => x.length).join(sep)
}).filter(x => x.length).join(sep)
}
concat (integrity, opts) {
const other = typeof integrity === 'string'
? integrity
: stringify(integrity, opts)
return parse(`${this.toString(opts)} ${other}`, opts)
}
hexDigest () {
return parse(this, {single: true}).hexDigest()
}
match (integrity, opts) {
const other = parse(integrity, opts)
const algo = other.pickAlgorithm(opts)
return (
this[algo] &&
other[algo] &&
this[algo].find(hash =>
other[algo].find(otherhash =>
hash.digest === otherhash.digest
)
)
) || false
}
pickAlgorithm (opts) {
const pickAlgorithm = (opts && opts.pickAlgorithm) || getPrioritizedHash
const keys = Object.keys(this)
if (!keys.length) {
throw new Error(`No algorithms available for ${
JSON.stringify(this.toString())
}`)
}
return keys.reduce((acc, algo) => {
return pickAlgorithm(acc, algo) || acc
})
}
}
module.exports.parse = parse
function parse (sri, opts) {
opts = opts || {}
if (typeof sri === 'string') {
return _parse(sri, opts)
} else if (sri.algorithm && sri.digest) {
const fullSri = new Integrity()
fullSri[sri.algorithm] = [sri]
return _parse(stringify(fullSri, opts), opts)
} else {
return _parse(stringify(sri, opts), opts)
}
}
function _parse (integrity, opts) {
// 3.4.3. Parse metadata
// https://w3c.github.io/webappsec-subresource-integrity/#parse-metadata
if (opts.single) {
return new Hash(integrity, opts)
}
return integrity.trim().split(/\s+/).reduce((acc, string) => {
const hash = new Hash(string, opts)
if (hash.algorithm && hash.digest) {
const algo = hash.algorithm
if (!acc[algo]) { acc[algo] = [] }
acc[algo].push(hash)
}
return acc
}, new Integrity())
}
module.exports.stringify = stringify
function stringify (obj, opts) {
if (obj.algorithm && obj.digest) {
return Hash.prototype.toString.call(obj, opts)
} else if (typeof obj === 'string') {
return stringify(parse(obj, opts), opts)
} else {
return Integrity.prototype.toString.call(obj, opts)
}
}
module.exports.fromHex = fromHex
function fromHex (hexDigest, algorithm, opts) {
const optString = (opts && opts.options && opts.options.length)
? `?${opts.options.join('?')}`
: ''
return parse(
`${algorithm}-${
Buffer.from(hexDigest, 'hex').toString('base64')
}${optString}`, opts
)
}
module.exports.fromData = fromData
function fromData (data, opts) {
opts = opts || {}
const algorithms = opts.algorithms || ['sha512']
const optString = opts.options && opts.options.length
? `?${opts.options.join('?')}`
: ''
return algorithms.reduce((acc, algo) => {
const digest = crypto.createHash(algo).update(data).digest('base64')
const hash = new Hash(
`${algo}-${digest}${optString}`,
opts
)
if (hash.algorithm && hash.digest) {
const algo = hash.algorithm
if (!acc[algo]) { acc[algo] = [] }
acc[algo].push(hash)
}
return acc
}, new Integrity())
}
module.exports.fromStream = fromStream
function fromStream (stream, opts) {
opts = opts || {}
const P = opts.Promise || Promise
const istream = integrityStream(opts)
return new P((resolve, reject) => {
stream.pipe(istream)
stream.on('error', reject)
istream.on('error', reject)
let sri
istream.on('integrity', s => { sri = s })
istream.on('end', () => resolve(sri))
istream.on('data', () => {})
})
}
module.exports.checkData = checkData
function checkData (data, sri, opts) {
opts = opts || {}
sri = parse(sri, opts)
if (!Object.keys(sri).length) {
if (opts.error) {
throw Object.assign(
new Error('No valid integrity hashes to check against'), {
code: 'EINTEGRITY'
}
)
} else {
return false
}
}
const algorithm = sri.pickAlgorithm(opts)
const digest = crypto.createHash(algorithm).update(data).digest('base64')
const newSri = parse({algorithm, digest})
const match = newSri.match(sri, opts)
if (match || !opts.error) {
return match
} else if (typeof opts.size === 'number' && (data.length !== opts.size)) {
const err = new Error(`data size mismatch when checking ${sri}.\n Wanted: ${opts.size}\n Found: ${data.length}`)
err.code = 'EBADSIZE'
err.found = data.length
err.expected = opts.size
err.sri = sri
throw err
} else {
const err = new Error(`Integrity checksum failed when using ${algorithm}: Wanted ${sri}, but got ${newSri}. (${data.length} bytes)`)
err.code = 'EINTEGRITY'
err.found = newSri
err.expected = sri
err.algorithm = algorithm
err.sri = sri
throw err
}
}
module.exports.checkStream = checkStream
function checkStream (stream, sri, opts) {
opts = opts || {}
const P = opts.Promise || Promise
const checker = integrityStream(Object.assign({}, opts, {
integrity: sri
}))
return new P((resolve, reject) => {
stream.pipe(checker)
stream.on('error', reject)
checker.on('error', reject)
let sri
checker.on('verified', s => { sri = s })
checker.on('end', () => resolve(sri))
checker.on('data', () => {})
})
}
module.exports.integrityStream = integrityStream
function integrityStream (opts) {
opts = opts || {}
// For verification
const sri = opts.integrity && parse(opts.integrity, opts)
const goodSri = sri && Object.keys(sri).length
const algorithm = goodSri && sri.pickAlgorithm(opts)
const digests = goodSri && sri[algorithm]
// Calculating stream
const algorithms = Array.from(
new Set(
(opts.algorithms || ['sha512'])
.concat(algorithm ? [algorithm] : [])
)
)
const hashes = algorithms.map(crypto.createHash)
let streamSize = 0
const stream = new Transform({
transform (chunk, enc, cb) {
streamSize += chunk.length
hashes.forEach(h => h.update(chunk, enc))
cb(null, chunk, enc)
}
}).on('end', () => {
const optString = (opts.options && opts.options.length)
? `?${opts.options.join('?')}`
: ''
const newSri = parse(hashes.map((h, i) => {
return `${algorithms[i]}-${h.digest('base64')}${optString}`
}).join(' '), opts)
// Integrity verification mode
const match = goodSri && newSri.match(sri, opts)
if (typeof opts.size === 'number' && streamSize !== opts.size) {
const err = new Error(`stream size mismatch when checking ${sri}.\n Wanted: ${opts.size}\n Found: ${streamSize}`)
err.code = 'EBADSIZE'
err.found = streamSize
err.expected = opts.size
err.sri = sri
stream.emit('error', err)
} else if (opts.integrity && !match) {
const err = new Error(`${sri} integrity checksum failed when using ${algorithm}: wanted ${digests} but got ${newSri}. (${streamSize} bytes)`)
err.code = 'EINTEGRITY'
err.found = newSri
err.expected = digests
err.algorithm = algorithm
err.sri = sri
stream.emit('error', err)
} else {
stream.emit('size', streamSize)
stream.emit('integrity', newSri)
match && stream.emit('verified', match)
}
})
return stream
}
module.exports.create = createIntegrity
function createIntegrity (opts) {
opts = opts || {}
const algorithms = opts.algorithms || ['sha512']
const optString = opts.options && opts.options.length
? `?${opts.options.join('?')}`
: ''
const hashes = algorithms.map(crypto.createHash)
return {
update: function (chunk, enc) {
hashes.forEach(h => h.update(chunk, enc))
return this
},
digest: function (enc) {
const integrity = algorithms.reduce((acc, algo) => {
const digest = hashes.shift().digest('base64')
const hash = new Hash(
`${algo}-${digest}${optString}`,
opts
)
if (hash.algorithm && hash.digest) {
const algo = hash.algorithm
if (!acc[algo]) { acc[algo] = [] }
acc[algo].push(hash)
}
return acc
}, new Integrity())
return integrity
}
}
}
const NODE_HASHES = new Set(crypto.getHashes())
// This is a Best Effort™ at a reasonable priority for hash algos
const DEFAULT_PRIORITY = [
'md5', 'whirlpool', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
// TODO - it's unclear _which_ of these Node will actually use as its name
// for the algorithm, so we guesswork it based on the OpenSSL names.
'sha3',
'sha3-256', 'sha3-384', 'sha3-512',
'sha3_256', 'sha3_384', 'sha3_512'
].filter(algo => NODE_HASHES.has(algo))
function getPrioritizedHash (algo1, algo2) {
return DEFAULT_PRIORITY.indexOf(algo1.toLowerCase()) >= DEFAULT_PRIORITY.indexOf(algo2.toLowerCase())
? algo1
: algo2
}
| veerhiremath7/veerhiremath7.github.io | node_modules/ssri/index.js | JavaScript | unlicense | 11,559 | [
30522,
1005,
2224,
9384,
1005,
9530,
3367,
17698,
1027,
5478,
1006,
1005,
3647,
1011,
17698,
1005,
1007,
1012,
17698,
9530,
3367,
19888,
2080,
1027,
5478,
1006,
1005,
19888,
2080,
1005,
1007,
9530,
3367,
10938,
1027,
5478,
1006,
1005,
5460,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.Text;
using System.Diagnostics;
namespace CSharpSyntax
{
public sealed partial class SwitchLabelSyntax : SyntaxNode
{
public CaseOrDefault Kind { get; set; }
private ExpressionSyntax _value;
public ExpressionSyntax Value
{
get { return _value; }
set
{
if (_value != null)
RemoveChild(_value);
_value = value;
if (_value != null)
AddChild(_value);
}
}
public SwitchLabelSyntax()
: base(SyntaxKind.SwitchLabel)
{
}
public override IEnumerable<SyntaxNode> ChildNodes()
{
if (Value != null)
yield return Value;
}
[DebuggerStepThrough]
public override void Accept(ISyntaxVisitor visitor)
{
if (!visitor.Done)
visitor.VisitSwitchLabel(this);
}
[DebuggerStepThrough]
public override T Accept<T>(ISyntaxVisitor<T> visitor)
{
return visitor.VisitSwitchLabel(this);
}
}
}
| modulexcite/CSharpSyntax | CSharpSyntax/Generated/SwitchLabelSyntax.cs | C# | lgpl-3.0 | 1,355 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
16474,
2015,
1025,
3415,
15327,
20116,
8167,
18075,
12380,
2595,
1063,
2270,
10203,
770... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 "pi_SharedTypes_0.h"
#include "GenericSharedDeclarations.h"
#include "queue_SharedTypes_0.h"
void pi_SharedTypes_0_mutexDestroy_3(pi_SharedTypes_0_FlaggedQueue_t* var)
{
pthread_mutex_destroy(&var->itemCount.mutex);
queue_SharedTypes_0_mutexDestroy_2(&var->queue);
pthread_mutex_destroy(&var->isFull.mutex);
pthread_mutex_destroy(&var->isFinished.mutex);
}
void pi_SharedTypes_0_mutexInit_6(pi_SharedTypes_0_SharedOf_ArrayOf_SharedOf_FlaggedQueue_0_0_t* var)
{
pthread_mutex_init(&var->mutex,&GenericSharedDeclarations_mutexAttribute_0);
pi_SharedTypes_0_mutexInit_5(((pi_SharedTypes_0_SharedOf_FlaggedQueue_0_t*)(var->value)), 20);
}
void pi_SharedTypes_0_mutexInit_4(pi_SharedTypes_0_SharedOf_FlaggedQueue_0_t* var)
{
pthread_mutex_init(&var->mutex,&GenericSharedDeclarations_mutexAttribute_0);
pi_SharedTypes_0_mutexInit_3(&var->value);
}
void pi_SharedTypes_0_mutexInit_5(pi_SharedTypes_0_SharedOf_FlaggedQueue_0_t* var, int32_t size_0)
{
for ( int32_t __i_1 = 0; __i_1 < size_0; __i_1++ )
{
pi_SharedTypes_0_mutexInit_4(&var[__i_1]);
}
}
void pi_SharedTypes_0_mutexDestroy_6(pi_SharedTypes_0_SharedOf_ArrayOf_SharedOf_FlaggedQueue_0_0_t* var)
{
pthread_mutex_destroy(&var->mutex);
pi_SharedTypes_0_mutexDestroy_5(((pi_SharedTypes_0_SharedOf_FlaggedQueue_0_t*)(var->value)), 20);
}
void pi_SharedTypes_0_mutexInit_3(pi_SharedTypes_0_FlaggedQueue_t* var)
{
pthread_mutex_init(&var->itemCount.mutex,&GenericSharedDeclarations_mutexAttribute_0);
queue_SharedTypes_0_mutexInit_2(&var->queue);
pthread_mutex_init(&var->isFull.mutex,&GenericSharedDeclarations_mutexAttribute_0);
pthread_mutex_init(&var->isFinished.mutex,&GenericSharedDeclarations_mutexAttribute_0);
}
void pi_SharedTypes_0_mutexDestroy_5(pi_SharedTypes_0_SharedOf_FlaggedQueue_0_t* var, int32_t size_0)
{
for ( int32_t __i_1 = 0; __i_1 < size_0; __i_1++ )
{
pi_SharedTypes_0_mutexDestroy_4(&var[__i_1]);
}
}
void pi_SharedTypes_0_mutexDestroy_4(pi_SharedTypes_0_SharedOf_FlaggedQueue_0_t* var)
{
pthread_mutex_destroy(&var->mutex);
pi_SharedTypes_0_mutexDestroy_3(&var->value);
}
| aloifolia/ParallelMbeddr | generated_programs/pi/optimized/pi_parallel_sync_extended/pi_SharedTypes_0.c | C | mit | 2,126 | [
30522,
1001,
2421,
1000,
14255,
1035,
4207,
13874,
2015,
1035,
1014,
1012,
1044,
1000,
1001,
2421,
1000,
12391,
7377,
5596,
3207,
20464,
25879,
8496,
1012,
1044,
1000,
1001,
2421,
1000,
24240,
1035,
4207,
13874,
2015,
1035,
1014,
1012,
1044... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
# Sphaeria corticola Fuckel, 1870 SPECIES
#### Status
SYNONYM
#### According to
The Catalogue of Life, 3rd January 2011
#### Published in
Jb. nassau. Ver. Naturk. 23-24: (1870)
#### Original name
Sphaeria corticola Fuckel, 1870
### Remarks
null | mdoering/backbone | life/Fungi/Ascomycota/Sordariomycetes/Xylariales/Amphisphaeriaceae/Discostroma/Discostroma corticola/ Syn. Sphaeria corticola/README.md | Markdown | apache-2.0 | 249 | [
30522,
1001,
11867,
25293,
4360,
2522,
28228,
26289,
6616,
2884,
1010,
6940,
2427,
1001,
1001,
1001,
1001,
3570,
10675,
1001,
1001,
1001,
1001,
2429,
2000,
1996,
10161,
1997,
2166,
1010,
3822,
2254,
2249,
1001,
1001,
1001,
1001,
2405,
1999,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
title: SVG 图形
type: 示例
order: 5
---
> 这个示例展示了对自定义组件、计算属性、双向绑定和 SVG 支持的结合。
<iframe width="100%" height="500" src="http://jsfiddle.net/yyx990803/bbt0f3nz/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
| zyj1022/vuejs.org | source/examples/svg.md | Markdown | mit | 311 | [
30522,
2516,
1024,
17917,
2290,
100,
100,
2828,
1024,
1923,
100,
2344,
1024,
1019,
1011,
1011,
1011,
1028,
100,
100,
1923,
100,
100,
1923,
100,
100,
100,
1822,
100,
100,
100,
1635,
100,
100,
100,
100,
1635,
100,
100,
100,
1822,
1796,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#
# Copyright (C) 2006-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=stunnel
PKG_VERSION:=5.20
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0+
PKG_MAINTAINER:=Michael Haas <haas@computerlinguist.org>
PKG_LICENSE_FILES:=COPYING COPYRIGHT.GPL
PKG_SOURCE_URL:=http://stunnel.cybermirror.org/archive/5.x/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_MD5SUM:=3264375026c2b496b5d258e243222de8
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/stunnel
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libopenssl +zlib
TITLE:=SSL TCP Wrapper
URL:=http://www.stunnel.org/
endef
define Package/stunnel/description
Stunnel is a program that allows you to encrypt arbitrary TCP
connections inside SSL (Secure Sockets Layer) available on both Unix
and Windows. Stunnel can allow you to secure non-SSL aware daemons and
protocols (like POP, IMAP, LDAP, etc) by having Stunnel provide the
encryption, requiring no changes to the daemon's code.
endef
define Package/stunnel/conffiles
/etc/stunnel/stunnel.conf
endef
CONFIGURE_ARGS+= \
--with-random=/dev/urandom \
--with-threads=fork \
--with-ssl=$(STAGING_DIR)/usr \
--disable-libwrap \
--disable-systemd
ifeq ($(CONFIG_IPV6),n)
CONFIGURE_ARGS+= \
--disable-ipv6
endif
define Build/Compile
mkdir -p $(PKG_INSTALL_DIR)/etc/stunnel
echo '#dummy' > $(PKG_INSTALL_DIR)/etc/stunnel/stunnel.pem
$(call Build/Compile/Default)
endef
define Package/stunnel/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/stunnel $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/lib/stunnel
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/stunnel/libstunnel.so $(1)/usr/lib/stunnel/
$(INSTALL_DIR) $(1)/etc/stunnel
$(INSTALL_CONF) ./files/stunnel.conf $(1)/etc/stunnel/stunnel.conf
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/stunnel.init $(1)/etc/init.d/stunnel
endef
$(eval $(call BuildPackage,stunnel))
| psidhu/packages | net/stunnel/Makefile | Makefile | gpl-2.0 | 2,031 | [
30522,
1001,
1001,
9385,
1006,
1039,
1007,
2294,
1011,
2297,
2330,
13088,
2102,
1012,
8917,
1001,
1001,
2023,
2003,
2489,
4007,
1010,
7000,
2104,
1996,
27004,
2236,
2270,
6105,
1058,
2475,
1012,
1001,
2156,
1013,
6105,
2005,
2062,
2592,
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... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
namespace POPconPasswd
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
POPcondecrypt pd = new POPcondecrypt();
List<passwordList> list = new List<passwordList>();
public MainWindow()
{
InitializeComponent();
}
private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
RadioButton rb = (RadioButton)sender;
if (rb == null)
return;
if (rb.Name.Equals("rbmanually"))
{
TBpassword.IsEnabled = true;
}
else
{
TBpassword.IsEnabled = false;
}
}
private void decrypt(object sender, RoutedEventArgs e)
{
if (rbmanually.IsChecked == true)
{
pd.setPassword(TBpassword.Text);
string pwd = pd.decrypt();
lbdecrypted.Content = pwd;
}
else
{
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\POPcon\\POP3");
foreach(var k in key.GetSubKeyNames())
{
RegistryKey rkey = key.OpenSubKey(k);
if (rkey != null)
{
string isencrypted = Convert.ToString(rkey.GetValue("PW_is_encrypted"));
if (isencrypted.Equals("2"))
{
string username = Convert.ToString(rkey.GetValue("Username"));
string password = Convert.ToString(rkey.GetValue("Password"));
pd.setPassword(password);
password = pd.decrypt();
list.Add(new passwordList(username, password));
}
}
}
}
DGpasswords.ItemsSource = list;
}
}
public class passwordList
{
public string Username { get; set; }
public string Password { get; set; }
public passwordList(string username,string password)
{
this.Username = username;
this.Password = password;
}
}
}
| subnetz/POPconPasswd | POPconPasswd/MainWindow.xaml.cs | C# | mit | 2,802 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
2478,
2291,
1012,
3645,
1025,
2478,
2291,
1012,
3645,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Queue(capacity) {
this.q = new Array(capacity);
this.next = 0;
this.size = 0;
this.isFull = function() {
return this.size >= this.q.length;
}
this.isEmpty = function() {
return this.size <= 0;
}
this.push = function(elt) {
if (this.isFull()) {
throw new Error("Can't push on a full queue!");
}
this.q[(this.next + this.size++) % this.q.length] = elt;
}
this.pop = function() {
if (this.isEmpty()) {
throw new Error("Can't pop from an empty queue!");
}
var ret = this.q[this.next];
this.next = (this.next + 1) % this.q.length;
--this.size;
return ret;
}
this.peek = function() {
if (this.isEmpty()) {
throw new Error("Can't peek at an empty queue!");
}
return this.q[this.next];
}
this.clear = function() {
this.next = this.size = 0;
}
return this;
}
| martyvona/jv-extension | queue.js | JavaScript | gpl-2.0 | 876 | [
30522,
3853,
24240,
1006,
3977,
1007,
1063,
2023,
1012,
1053,
1027,
2047,
9140,
1006,
3977,
1007,
1025,
2023,
1012,
2279,
1027,
1014,
1025,
2023,
1012,
2946,
1027,
1014,
1025,
2023,
1012,
2003,
3993,
2140,
1027,
3853,
1006,
1007,
1063,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.5.0_22) on Thu May 24 19:39:44 WET 2012 -->
<TITLE>
API Help (Apache JMeter API)
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="API Help (Apache JMeter API)";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Help</B></FONT> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Apache JMeter</b></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV
NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="index.html?help-doc.html" target="_top"><B>FRAMES</B></A>
<A HREF="help-doc.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<CENTER>
<H1>
How This API Document Is Organized</H1>
</CENTER>
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.<H3>
Overview</H3>
<BLOCKQUOTE>
<P>
The <A HREF="overview-summary.html">Overview</A> page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.</BLOCKQUOTE>
<H3>
Package</H3>
<BLOCKQUOTE>
<P>
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:<UL>
<LI>Interfaces (italic)<LI>Classes<LI>Enums<LI>Exceptions<LI>Errors<LI>Annotation Types</UL>
</BLOCKQUOTE>
<H3>
Class/Interface</H3>
<BLOCKQUOTE>
<P>
Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:<UL>
<LI>Class inheritance diagram<LI>Direct Subclasses<LI>All Known Subinterfaces<LI>All Known Implementing Classes<LI>Class/interface declaration<LI>Class/interface description
<P>
<LI>Nested Class Summary<LI>Field Summary<LI>Constructor Summary<LI>Method Summary
<P>
<LI>Field Detail<LI>Constructor Detail<LI>Method Detail</UL>
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.</BLOCKQUOTE>
</BLOCKQUOTE>
<H3>
Annotation Type</H3>
<BLOCKQUOTE>
<P>
Each annotation type has its own separate page with the following sections:<UL>
<LI>Annotation Type declaration<LI>Annotation Type description<LI>Required Element Summary<LI>Optional Element Summary<LI>Element Detail</UL>
</BLOCKQUOTE>
</BLOCKQUOTE>
<H3>
Enum</H3>
<BLOCKQUOTE>
<P>
Each enum has its own separate page with the following sections:<UL>
<LI>Enum declaration<LI>Enum description<LI>Enum Constant Summary<LI>Enum Constant Detail</UL>
</BLOCKQUOTE>
<H3>
Tree (Class Hierarchy)</H3>
<BLOCKQUOTE>
There is a <A HREF="overview-tree.html">Class Hierarchy</A> page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with <code>java.lang.Object</code>. The interfaces do not inherit from <code>java.lang.Object</code>.<UL>
<LI>When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.<LI>When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.</UL>
</BLOCKQUOTE>
<H3>
Deprecated API</H3>
<BLOCKQUOTE>
The <A HREF="deprecated-list.html">Deprecated API</A> page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.</BLOCKQUOTE>
<H3>
Index</H3>
<BLOCKQUOTE>
The <A HREF="index-all.html">Index</A> contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.</BLOCKQUOTE>
<H3>
Prev/Next</H3>
These links take you to the next or previous class, interface, package, or related page.<H3>
Frames/No Frames</H3>
These links show and hide the HTML frames. All pages are available with or without frames.
<P>
<H3>
Serialized Form</H3>
Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
<P>
<H3>
Constant Field Values</H3>
The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
<P>
<FONT SIZE="-1">
<EM>
This help file applies to API documentation generated using the standard doclet.</EM>
</FONT>
<BR>
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Package</FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Help</B></FONT> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Apache JMeter</b></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV
NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="index.html?help-doc.html" target="_top"><B>FRAMES</B></A>
<A HREF="help-doc.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright © 1998-2012 Apache Software Foundation. All Rights Reserved.
</BODY>
</HTML>
| telefonicaid/notification_server | test/jmeter/apache-jmeter-2.7/docs/api/help-doc.html | HTML | agpl-3.0 | 9,022 | [
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... |
<?php
namespace postitunload;
use postitunload\unloader as unloader;
$unloader=new unloader();
$unloader->postitdelete($unloader);
class unloader {
private $target;
public function __construct(){
if(isset($_POST['deletepostit'])){
$this->target=$_POST['deletepostit'];
}else{
die("Target não definido");
}
}
public function postitdelete(unloader $obj){
if(file_exists("../public/posted/".$obj->target."")){
$delete=unlink("../public/posted/".$obj->target."");
if($delete){
print_r("Postit deletado de ".$obj->target);
}
}
}
}
?> | brunonimos/webpostit-for-php | resources/postitunload.php | PHP | mit | 538 | [
30522,
1026,
1029,
25718,
3415,
15327,
2695,
4183,
4609,
11066,
1025,
2224,
2695,
4183,
4609,
11066,
1032,
4895,
11066,
2121,
2004,
4895,
11066,
2121,
1025,
1002,
4895,
11066,
2121,
1027,
2047,
4895,
11066,
2121,
1006,
1007,
1025,
1002,
489... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* WordPress CRON API
*
* @package WordPress
*/
/**
* Schedules a hook to run only once.
*
* Schedules a hook which will be executed once by the WordPress actions core at
* a time which you specify. The action will fire off when someone visits your
* WordPress site, if the schedule time has passed.
*
* @since 2.1.0
* @link http://codex.wordpress.org/Function_Reference/wp_schedule_single_event
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $hook Action hook to execute when cron is run.
* @param array $args Optional. Arguments to pass to the hook's callback function.
*/
function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
// don't schedule a duplicate if there's already an identical event due in the next 10 minutes
$next = wp_next_scheduled($hook, $args);
if ( $next && $next <= $timestamp + 600 )
return;
$crons = _get_cron_array();
$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args );
$event = apply_filters('schedule_event', $event);
// A plugin disallowed this event
if ( ! $event )
return false;
$key = md5(serialize($event->args));
$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args );
uksort( $crons, "strnatcasecmp" );
_set_cron_array( $crons );
}
/**
* Schedule a periodic event.
*
* Schedules a hook which will be executed by the WordPress actions core on a
* specific interval, specified by you. The action will trigger when someone
* visits your WordPress site, if the scheduled time has passed.
*
* Valid values for the recurrence are hourly, daily and twicedaily. These can
* be extended using the cron_schedules filter in wp_get_schedules().
*
* Use wp_next_scheduled() to prevent duplicates
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $recurrence How often the event should recur.
* @param string $hook Action hook to execute when cron is run.
* @param array $args Optional. Arguments to pass to the hook's callback function.
* @return bool|null False on failure, null when complete with scheduling event.
*/
function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
if ( !isset( $schedules[$recurrence] ) )
return false;
$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] );
$event = apply_filters('schedule_event', $event);
// A plugin disallowed this event
if ( ! $event )
return false;
$key = md5(serialize($event->args));
$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args, 'interval' => $event->interval );
uksort( $crons, "strnatcasecmp" );
_set_cron_array( $crons );
}
/**
* Reschedule a recurring event.
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $recurrence How often the event should recur.
* @param string $hook Action hook to execute when cron is run.
* @param array $args Optional. Arguments to pass to the hook's callback function.
* @return bool|null False on failure. Null when event is rescheduled.
*/
function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
$crons = _get_cron_array();
$schedules = wp_get_schedules();
$key = md5(serialize($args));
$interval = 0;
// First we try to get it from the schedule
if ( 0 == $interval )
$interval = $schedules[$recurrence]['interval'];
// Now we try to get it from the saved interval in case the schedule disappears
if ( 0 == $interval )
$interval = $crons[$timestamp][$hook][$key]['interval'];
// Now we assume something is wrong and fail to schedule
if ( 0 == $interval )
return false;
$now = time();
if ( $timestamp >= $now )
$timestamp = $now + $interval;
else
$timestamp = $now + ($interval - (($now - $timestamp) % $interval));
wp_schedule_event( $timestamp, $recurrence, $hook, $args );
}
/**
* Unschedule a previously scheduled cron job.
*
* The $timestamp and $hook parameters are required, so that the event can be
* identified.
*
* @since 2.1.0
*
* @param int $timestamp Timestamp for when to run the event.
* @param string $hook Action hook, the execution of which will be unscheduled.
* @param array $args Arguments to pass to the hook's callback function.
* Although not passed to a callback function, these arguments are used
* to uniquely identify the scheduled event, so they should be the same
* as those used when originally scheduling the event.
*/
function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
unset( $crons[$timestamp][$hook][$key] );
if ( empty($crons[$timestamp][$hook]) )
unset( $crons[$timestamp][$hook] );
if ( empty($crons[$timestamp]) )
unset( $crons[$timestamp] );
_set_cron_array( $crons );
}
/**
* Unschedule all cron jobs attached to a specific hook.
*
* @since 2.1.0
*
* @param string $hook Action hook, the execution of which will be unscheduled.
* @param array $args Optional. Arguments that were to be pass to the hook's callback function.
*/
function wp_clear_scheduled_hook( $hook, $args = array() ) {
// Backward compatibility
// Previously this function took the arguments as discrete vars rather than an array like the rest of the API
if ( !is_array($args) ) {
_deprecated_argument( __FUNCTION__, '3.0', __('This argument has changed to an array to match the behavior of the other cron functions.') );
$args = array_slice( func_get_args(), 1 );
}
while ( $timestamp = wp_next_scheduled( $hook, $args ) )
wp_unschedule_event( $timestamp, $hook, $args );
}
/**
* Retrieve the next timestamp for a cron event.
*
* @since 2.1.0
*
* @param string $hook Action hook to execute when cron is run.
* @param array $args Optional. Arguments to pass to the hook's callback function.
* @return bool|int The UNIX timestamp of the next time the scheduled event will occur.
*/
function wp_next_scheduled( $hook, $args = array() ) {
$crons = _get_cron_array();
$key = md5(serialize($args));
if ( empty($crons) )
return false;
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[$hook][$key] ) )
return $timestamp;
}
return false;
}
/**
* Send request to run cron through HTTP request that doesn't halt page loading.
*
* @since 2.1.0
*
* @return null Cron could not be spawned, because it is not needed to run.
*/
function spawn_cron( $local_time = 0 ) {
if ( !$local_time )
$local_time = time();
if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
return;
/*
* multiple processes on multiple web servers can run this code concurrently
* try to make this as atomic as possible by setting doing_cron switch
*/
$lock = get_transient('doing_cron');
if ( $lock > $local_time + 10*60 )
$lock = 0;
// don't run if another process is currently running it or more than once every 60 sec.
if ( $lock + WP_CRON_LOCK_TIMEOUT > $local_time )
return;
//sanity check
$crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > $local_time )
return;
if ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ) {
if ( !empty($_POST) || defined('DOING_AJAX') )
return;
$doing_wp_cron = $local_time;
set_transient( 'doing_cron', $doing_wp_cron );
ob_start();
wp_redirect( add_query_arg('doing_wp_cron', $doing_wp_cron, stripslashes($_SERVER['REQUEST_URI'])) );
echo ' ';
// flush any buffers and send the headers
while ( @ob_end_flush() );
flush();
WP_DEBUG ? include_once( ABSPATH . 'wp-cron.php' ) : @include_once( ABSPATH . 'wp-cron.php' );
return;
}
$doing_wp_cron = $local_time;
set_transient( 'doing_cron', $doing_wp_cron );
$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron=' . $doing_wp_cron;
wp_remote_post( $cron_url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true)) );
}
/**
* Run scheduled callbacks or spawn cron for all scheduled events.
*
* @since 2.1.0
*
* @return null When doesn't need to run Cron.
*/
function wp_cron() {
// Prevent infinite loops caused by lack of wp-cron.php
if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) )
return;
if ( false === $crons = _get_cron_array() )
return;
$local_time = time();
$keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > $local_time )
return;
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > $local_time ) break;
foreach ( (array) $cronhooks as $hook => $args ) {
if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
continue;
spawn_cron( $local_time );
break 2;
}
}
}
/**
* Retrieve supported and filtered Cron recurrences.
*
* The supported recurrences are 'hourly' and 'daily'. A plugin may add more by
* hooking into the 'cron_schedules' filter. The filter accepts an array of
* arrays. The outer array has a key that is the name of the schedule or for
* example 'weekly'. The value is an array with two keys, one is 'interval' and
* the other is 'display'.
*
* The 'interval' is a number in seconds of when the cron job should run. So for
* 'hourly', the time is 3600 or 60*60. For weekly, the value would be
* 60*60*24*7 or 604800. The value of 'interval' would then be 604800.
*
* The 'display' is the description. For the 'weekly' key, the 'display' would
* be <code>__('Once Weekly')</code>.
*
* For your plugin, you will be passed an array. you can easily add your
* schedule by doing the following.
* <code>
* // filter parameter variable name is 'array'
* $array['weekly'] = array(
* 'interval' => 604800,
* 'display' => __('Once Weekly')
* );
* </code>
*
* @since 2.1.0
*
* @return array
*/
function wp_get_schedules() {
$schedules = array(
'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
'twicedaily' => array( 'interval' => 43200, 'display' => __('Twice Daily') ),
'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ),
);
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
}
/**
* Retrieve Cron schedule for hook with arguments.
*
* @since 2.1.0
*
* @param string $hook Action hook to execute when cron is run.
* @param array $args Optional. Arguments to pass to the hook's callback function.
* @return string|bool False, if no schedule. Schedule on success.
*/
function wp_get_schedule($hook, $args = array()) {
$crons = _get_cron_array();
$key = md5(serialize($args));
if ( empty($crons) )
return false;
foreach ( $crons as $timestamp => $cron ) {
if ( isset( $cron[$hook][$key] ) )
return $cron[$hook][$key]['schedule'];
}
return false;
}
//
// Private functions
//
/**
* Retrieve cron info array option.
*
* @since 2.1.0
* @access private
*
* @return array CRON info array.
*/
function _get_cron_array() {
$cron = get_option('cron');
if ( ! is_array($cron) )
return false;
if ( !isset($cron['version']) )
$cron = _upgrade_cron_array($cron);
unset($cron['version']);
return $cron;
}
/**
* Updates the CRON option with the new CRON array.
*
* @since 2.1.0
* @access private
*
* @param array $cron Cron info array from {@link _get_cron_array()}.
*/
function _set_cron_array($cron) {
$cron['version'] = 2;
update_option( 'cron', $cron );
}
/**
* Upgrade a Cron info array.
*
* This function upgrades the Cron info array to version 2.
*
* @since 2.1.0
* @access private
*
* @param array $cron Cron info array from {@link _get_cron_array()}.
* @return array An upgraded Cron info array.
*/
function _upgrade_cron_array($cron) {
if ( isset($cron['version']) && 2 == $cron['version'])
return $cron;
$new_cron = array();
foreach ( (array) $cron as $timestamp => $hooks) {
foreach ( (array) $hooks as $hook => $args ) {
$key = md5(serialize($args['args']));
$new_cron[$timestamp][$hook][$key] = $args;
}
}
$new_cron['version'] = 2;
update_option( 'cron', $new_cron );
return $new_cron;
}
| andres-torres-marroquin/casa-camila | wp-includes/cron.php | PHP | gpl-2.0 | 12,428 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
2773,
20110,
13675,
2239,
17928,
1008,
1008,
1030,
7427,
2773,
20110,
1008,
1013,
1013,
1008,
1008,
1008,
20283,
1037,
8103,
2000,
2448,
2069,
2320,
1012,
1008,
1008,
20283,
1037,
8103,
2029... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
-- Unban a player banned with Punkbuster.
-- From kmod script.
-- params is parameters passed from et_ClientCommand function.
-- * params["arg1"] => guid
function execute_command(params)
params.say = "chat"
if params.nbArg < 2 then
printCmdMsg(params, "Useage: unban [guid]\n")
else
if tonumber(et.trap_Cvar_Get("sv_punkbuster")) == 1 then
et.trap_SendConsoleCommand(
et.EXEC_APPEND,
"pb_sv_unbanguid " .. params["arg1"] .. "\n"
)
et.trap_SendConsoleCommand(
et.EXEC_APPEND,
"pb_sv_UpdBanFile\n"
)
params.broadcast2allClients = true
params.noDisplayCmd = true
printCmdMsg(
params,
client[clientNum]["name"] .. " have been unbanned\n"
)
else
printCmdMsg(
params,
"Cannot unban with Punkbuster (Punkbuster is disable).\n"
)
end
end
return 1
end
| cyrillePrigent/kmod-ng | umod/command/client/unban.lua | Lua | gpl-2.0 | 1,059 | [
30522,
1011,
1011,
4895,
8193,
1037,
2447,
7917,
2007,
7196,
8286,
3334,
1012,
1011,
1011,
2013,
2463,
7716,
5896,
1012,
1011,
1011,
11498,
5244,
2003,
11709,
2979,
2013,
3802,
1035,
7396,
9006,
2386,
2094,
3853,
1012,
1011,
1011,
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... |
# Range Grouping for jQuery
## Overview
Simple plugin to group input ranges. The ranges will be limited by a shared max sum.
<img src="https://raw.githubusercontent.com/jhovgaard/jquery.rangegroup/master/jquery.rangegroup.gif" />
Live example: http://jsfiddle.net/pfcjjkb7/
## Usage
First include jQuery and the rangegroup file:
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.rangegroup.js" type="text/javascript"></script>
Second, add the `range-group` and `range-group-max-sum` attributes to your range element like this:
<input type="range" range-group="myGroup1" name="range1" range-group-max-sum="200" min="0" max="100">
<input type="range" range-group="myGroup1" name="range2" range-group-max-sum="200" min="0" max="100">
<input type="range" range-group="myGroup1" name="range3" range-group-max-sum="200" min="0" max="100">
Please notice if the max-sum values is different, the plugin will use the value set in the first input.
| jhovgaard/jquery.rangegroup | README.md | Markdown | mit | 994 | [
30522,
1001,
2846,
19765,
2005,
1046,
4226,
2854,
1001,
1001,
19184,
3722,
13354,
2378,
2000,
2177,
7953,
8483,
1012,
1996,
8483,
2097,
2022,
3132,
2011,
1037,
4207,
4098,
7680,
1012,
1026,
10047,
2290,
5034,
2278,
1027,
1000,
16770,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="utf-8" />
<title></title>
<meta name="author" content="xli" />
<meta name="description" content="该睡觉的睡觉,该吃药的吃药。๑乛◡乛๑" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@gohugoio" />
<meta name="twitter:title" content="" />
<meta name="twitter:description" content="该睡觉的睡觉,该吃药的吃药。๑乛◡乛๑" />
<meta name="twitter:image" content="https://xli.me/img/avatar.jpg" />
<meta property="og:type" content="article" />
<meta property="og:title" content="" />
<meta property="og:description" content="该睡觉的睡觉,该吃药的吃药。๑乛◡乛๑" />
<meta property="og:url" content="https://xli.me/post/s/2017/408/" />
<meta property="og:image" content="https://xli.me/img/avatar.jpg" />
<meta name="generator" content="Hugo 0.52" />
<link rel="canonical" href="https://xli.me/post/s/2017/408/" />
<link rel="alternative" href="https://xli.me/index.xml" title="Mr Fox" type="application/atom+xml" />
<meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="format-detection" content="telephone=no,email=no,adress=no" />
<meta http-equiv="Cache-Control" content="no-transform" />
<meta name="robots" content="index,follow" />
<meta name="referrer" content="origin-when-cross-origin" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Mr Fox" />
<meta name="msapplication-tooltip" content="Mr Fox" />
<meta name='msapplication-navbutton-color' content="#5fbf5e" />
<meta name="msapplication-TileColor" content="#5fbf5e" />
<meta name="msapplication-TileImage" content="/img/tile-image-windows.png" />
<link rel="icon" href="https://xli.me/img/favicon.ico" />
<link rel="icon" type="image/png" sizes="16x16" href="https://xli.me/img/favicon-16x16.png" />
<link rel="icon" type="image/png" sizes="32x32" href="https://xli.me/img/favicon-32x32.png" />
<link rel="icon" sizes="192x192" href="https://xli.me/img/touch-icon-android.png" />
<link rel="apple-touch-icon" href="https://xli.me/img/touch-icon-apple.png" />
<link rel="mask-icon" href="https://xli.me/img/safari-pinned-tab.svg" color="#5fbf5e" />
<link rel="stylesheet" href="//cdn.bootcss.com/video.js/6.2.8/alt/video-js-cdn.min.css" />
<link rel="stylesheet" href="https://xli.me/css/bundle.css" />
<!--[if lt IE 9]>
<script src="//cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<script src="//cdn.bootcss.com/video.js/6.2.8/ie8/videojs-ie8.min.js"></script>
<![endif]-->
<!--[if lte IE 11]>
<script src="//cdn.bootcss.com/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->
<script src="//cdn.bootcss.com/object-fit-images/3.2.3/ofi.min.js"></script>
<script src="//cdn.bootcss.com/smooth-scroll/12.1.4/js/smooth-scroll.polyfills.min.js"></script>
</head>
<body>
<div class="suspension">
<a title="Go to top" class="to-top is-hide"><span class="icon icon-up"></span></a>
</div>
<header class="site-header">
<img class="avatar" src="https://xli.me/img/avatar.jpg" alt="Avatar">
<h2 class="title">Mr Fox</h2>
<p class="subtitle">brief is life but love is long~</p>
<button class="menu-toggle" type="button">
<span class="icon icon-menu"></span>
</button>
<nav class="site-menu collapsed">
<h2 class="offscreen">Main Menu</h2>
<ul class="menu-list">
<li class="menu-item
is-active
">
<a href="https://xli.me/">首页</a>
</li>
<li class="menu-item
">
<a href="https://xli.me/tags/%E6%8A%80%E6%9C%AF/">技术</a>
</li>
<li class="menu-item
">
<a href="https://xli.me/tags/">分类</a>
</li>
<li class="menu-item
">
<a href="https://xli.me/about/">关于</a>
</li>
</ul>
</nav>
<nav class="social-menu collapsed">
<h2 class="offscreen">Social Networks</h2>
<ul class="social-list">
<li class="social-item">
<a href="mailto:kaidiren@gmail.com" title="Email"><span class="icon icon-email"></span></a>
</li>
<li class="social-item">
<a href="//github.com/kaidiren" title="GitHub"><span class="icon icon-github"></span></a>
</li>
<li class="social-item">
<a href="https://xli.me/index.xml"><span class="icon icon-rss" title="RSS"></span></a>
</li>
</ul>
</nav>
</header>
<section class="main post-detail">
<header class="post-header">
<h1 class="post-title"></h1>
<p class="post-meta">@xli · Jun 20, 2015 · 1 min read</p>
</header>
<article class="post-content"><p>该睡觉的睡觉,该吃药的吃药。๑乛◡乛๑</p>
</article>
<footer class="post-footer">
<p class="post-copyright">
</p>
</footer>
</section>
<footer class="site-footer">
<p>© 2017-2018 Mr Fox</p>
<p>Powered by <a href="https://gohugo.io/" target="_blank">Hugo</a> with theme <a href="https://github.com/laozhu/hugo-nuo" target="_blank">Nuo</a>.</p>
</footer>
<script async src="//cdn.bootcss.com/video.js/6.2.8/alt/video.novtt.min.js"></script>
<script async src="//cdn.bootcss.com/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
displayMath: [['$$','$$'], ['\[','\]']],
processEscapes: true,
processEnvironments: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
TeX: { equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js"] }
}
});
</script>
<script type="text/x-mathjax-config">
// Fix <code> tags after MathJax finishes running. This is a
// hack to overcome a shortcoming of Markdown. Discussion at
// https://github.com/mojombo/jekyll/issues/199
MathJax.Hub.Queue(() => {
MathJax.Hub.getAllJax().map(v => v.SourceElement().parentNode.className += ' has-jax');
});
</script>
<script src="https://xli.me/js/bundle.js"></script>
</body>
</html>
| kaidiren/D6 | public/post/s/2017/408/index.html | HTML | mit | 6,917 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
1062,
2232,
1011,
7003,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1013,
1028,
1026,
2516,
1028,
1026,
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... |
export const PAGINATION_PIECE_PREVIOUS = 'Previous'
export const PAGINATION_PIECE_ELLIPSIS = 'ellipsis'
export const PAGINATION_PIECE_PAGE_NUMBER = 'page-number'
export const PAGINATION_PIECE_NEXT = 'Next'
export const DEFAULT_MAX_PAGE_NUMBER_LINKS = 5
| uktrade/data-hub-fe-beta2 | src/client/components/Pagination/constants.js | JavaScript | mit | 254 | [
30522,
9167,
9530,
3367,
6643,
20876,
3508,
1035,
3538,
1035,
3025,
1027,
1005,
3025,
1005,
9167,
9530,
3367,
6643,
20876,
3508,
1035,
3538,
1035,
3449,
15000,
6190,
1027,
1005,
3449,
15000,
6190,
1005,
9167,
9530,
3367,
6643,
20876,
3508,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
@extends('admin.layouts.modal')
{{-- Content --}}
@section('content')
<!-- Tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#tab-general" data-toggle="tab">General</a></li>
</ul>
<!-- ./ tabs -->
{{-- Delete User Form --}}
<form class="form-horizontal" method="post" action="" autocomplete="off">
<!-- CSRF Token -->
<input type="hidden" name="_token" value="{{{ csrf_token() }}}" />
<input type="hidden" name="id" value="{{ $user->id }}" />
<!-- ./ csrf token -->
<!-- Form Actions -->
<div class="control-group">
<div class="controls">
<element class="btn-cancel close_popup">Cancel</element>
<button type="submit" class="btn btn-danger close_popup">Delete</button>
</div>
</div>
<!-- ./ form actions -->
</form>
@stop | mgathu1/groceryshopper | laravel/app/views/admin/users/delete.blade.php | PHP | mit | 905 | [
30522,
1030,
8908,
1006,
1005,
4748,
10020,
1012,
9621,
2015,
1012,
16913,
2389,
1005,
1007,
1063,
1063,
1011,
1011,
4180,
1011,
1011,
1065,
1065,
1030,
2930,
1006,
1005,
4180,
1005,
1007,
1026,
999,
1011,
1011,
21628,
2015,
1011,
1011,
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 (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.ui;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo;
import com.google.android.exoplayer2.trackselection.TrackSelectionUtil;
import com.google.android.exoplayer2.util.Assertions;
import java.util.Collections;
import java.util.List;
/** Builder for a dialog with a {@link TrackSelectionView}. */
public final class TrackSelectionDialogBuilder {
/** Callback which is invoked when a track selection has been made. */
public interface DialogCallback {
/**
* Called when tracks are selected.
*
* @param isDisabled Whether the renderer is disabled.
* @param overrides List of selected track selection overrides for the renderer.
*/
void onTracksSelected(boolean isDisabled, List<SelectionOverride> overrides);
}
private final Context context;
private final CharSequence title;
private final MappedTrackInfo mappedTrackInfo;
private final int rendererIndex;
private final DialogCallback callback;
private boolean allowAdaptiveSelections;
private boolean allowMultipleOverrides;
private boolean showDisableOption;
@Nullable private TrackNameProvider trackNameProvider;
private boolean isDisabled;
private List<SelectionOverride> overrides;
/**
* Creates a builder for a track selection dialog.
*
* @param context The context of the dialog.
* @param title The title of the dialog.
* @param mappedTrackInfo The {@link MappedTrackInfo} containing the track information.
* @param rendererIndex The renderer index in the {@code mappedTrackInfo} for which the track
* selection is shown.
* @param callback The {@link DialogCallback} invoked when a track selection has been made.
*/
public TrackSelectionDialogBuilder(
Context context,
CharSequence title,
MappedTrackInfo mappedTrackInfo,
int rendererIndex,
DialogCallback callback) {
this.context = context;
this.title = title;
this.mappedTrackInfo = mappedTrackInfo;
this.rendererIndex = rendererIndex;
this.callback = callback;
overrides = Collections.emptyList();
}
/**
* Creates a builder for a track selection dialog which automatically updates a {@link
* DefaultTrackSelector}.
*
* @param context The context of the dialog.
* @param title The title of the dialog.
* @param trackSelector A {@link DefaultTrackSelector} whose current selection is used to set up
* the dialog and which is updated when new tracks are selected in the dialog.
* @param rendererIndex The renderer index in the {@code trackSelector} for which the track
* selection is shown.
*/
public TrackSelectionDialogBuilder(
Context context, CharSequence title, DefaultTrackSelector trackSelector, int rendererIndex) {
this.context = context;
this.title = title;
this.mappedTrackInfo = Assertions.checkNotNull(trackSelector.getCurrentMappedTrackInfo());
this.rendererIndex = rendererIndex;
TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters();
isDisabled = selectionParameters.getRendererDisabled(rendererIndex);
SelectionOverride override =
selectionParameters.getSelectionOverride(rendererIndex, rendererTrackGroups);
overrides = override == null ? Collections.emptyList() : Collections.singletonList(override);
this.callback =
(newIsDisabled, newOverrides) ->
trackSelector.setParameters(
TrackSelectionUtil.updateParametersWithOverride(
selectionParameters,
rendererIndex,
rendererTrackGroups,
newIsDisabled,
newOverrides.isEmpty() ? null : newOverrides.get(0)));
}
/**
* Sets whether the selection is initially shown as disabled.
*
* @param isDisabled Whether the selection is initially shown as disabled.
* @return This builder, for convenience.
*/
public TrackSelectionDialogBuilder setIsDisabled(boolean isDisabled) {
this.isDisabled = isDisabled;
return this;
}
/**
* Sets the initial selection override to show.
*
* @param override The initial override to show, or null for no override.
* @return This builder, for convenience.
*/
public TrackSelectionDialogBuilder setOverride(@Nullable SelectionOverride override) {
return setOverrides(
override == null ? Collections.emptyList() : Collections.singletonList(override));
}
/**
* Sets the list of initial selection overrides to show.
*
* <p>Note that only the first override will be used unless {@link
* #setAllowMultipleOverrides(boolean)} is set to {@code true}.
*
* @param overrides The list of initial overrides to show. There must be at most one override for
* each track group.
* @return This builder, for convenience.
*/
public TrackSelectionDialogBuilder setOverrides(List<SelectionOverride> overrides) {
this.overrides = overrides;
return this;
}
/**
* Sets whether adaptive selections (consisting of more than one track) can be made.
*
* <p>For the selection view to enable adaptive selection it is necessary both for this feature to
* be enabled, and for the target renderer to support adaptation between the available tracks.
*
* @param allowAdaptiveSelections Whether adaptive selection is enabled.
* @return This builder, for convenience.
*/
public TrackSelectionDialogBuilder setAllowAdaptiveSelections(boolean allowAdaptiveSelections) {
this.allowAdaptiveSelections = allowAdaptiveSelections;
return this;
}
/**
* Sets whether multiple overrides can be set and selected, i.e. tracks from multiple track groups
* can be selected.
*
* @param allowMultipleOverrides Whether multiple track selection overrides are allowed.
* @return This builder, for convenience.
*/
public TrackSelectionDialogBuilder setAllowMultipleOverrides(boolean allowMultipleOverrides) {
this.allowMultipleOverrides = allowMultipleOverrides;
return this;
}
/**
* Sets whether an option is available for disabling the renderer.
*
* @param showDisableOption Whether the disable option is shown.
* @return This builder, for convenience.
*/
public TrackSelectionDialogBuilder setShowDisableOption(boolean showDisableOption) {
this.showDisableOption = showDisableOption;
return this;
}
/**
* Sets the {@link TrackNameProvider} used to generate the user visible name of each track and
* updates the view with track names queried from the specified provider.
*
* @param trackNameProvider The {@link TrackNameProvider} to use, or null to use the default.
*/
public TrackSelectionDialogBuilder setTrackNameProvider(
@Nullable TrackNameProvider trackNameProvider) {
this.trackNameProvider = trackNameProvider;
return this;
}
/** Builds the dialog. */
public AlertDialog build() {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
// Inflate with the builder's context to ensure the correct style is used.
LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
View dialogView = dialogInflater.inflate(R.layout.exo_track_selection_dialog, /* root= */ null);
TrackSelectionView selectionView = dialogView.findViewById(R.id.exo_track_selection_view);
selectionView.setAllowMultipleOverrides(allowMultipleOverrides);
selectionView.setAllowAdaptiveSelections(allowAdaptiveSelections);
selectionView.setShowDisableOption(showDisableOption);
if (trackNameProvider != null) {
selectionView.setTrackNameProvider(trackNameProvider);
}
selectionView.init(mappedTrackInfo, rendererIndex, isDisabled, overrides, /* listener= */ null);
Dialog.OnClickListener okClickListener =
(dialog, which) ->
callback.onTracksSelected(selectionView.getIsDisabled(), selectionView.getOverrides());
return builder
.setTitle(title)
.setView(dialogView)
.setPositiveButton(android.R.string.ok, okClickListener)
.setNegativeButton(android.R.string.cancel, null)
.create();
}
}
| stari4ek/ExoPlayer | library/ui/src/main/java/com/google/android/exoplayer2/ui/TrackSelectionDialogBuilder.java | Java | apache-2.0 | 9,338 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
10476,
1996,
11924,
2330,
3120,
2622,
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,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 {Observable} from 'rx'
import {TextField} from 'material-ui'
import ThemeManager from 'material-ui/lib/styles/theme-manager';
import MyRawTheme from '../components/Theme.js';
import ThemeDecorator from 'material-ui/lib/styles/theme-decorator';
import {compose} from 'recompose'
import {observeProps, createEventHandler} from 'rx-recompose'
import {clickable} from '../style.css'
import {View} from '../components'
let Search = compose(
// ASDFGHJKL:
ThemeDecorator(ThemeManager.getMuiTheme(MyRawTheme))
,
observeProps(props$ => {
// Create search query observable
let setQuery = createEventHandler()
let query$ = setQuery.share()
query$
// Only search for songs that are not only spaces 😂
.filter(x => x.trim() !== '')
// Only every 300 ms
.debounce(300)
// Get the `doSearch` method from props
.withLatestFrom(props$.pluck('doSearch'), (query, doSearch) => doSearch(query))
// Search for the query
.subscribe(func => {
func()
})
return {
// Pass down function to set the query
setQuery: Observable.just(setQuery),
// Pass down the current query value
query: query$.startWith(''),
// Pass down force-search function when pressing enter
doSearch: props$.pluck('doSearch'),
// Function to start playing song when clicked on
playSong: props$.pluck('playSong'),
// Searchresults to display
searchResults:
Observable.merge(
// Results from the search
props$.pluck('results$') // Get results observable
.distinctUntilChanged() // Only when unique
.flatMapLatest(x => x) // Morph into the results$
.startWith([]) // And set off with a empty array
,
query$
// When query is only spaces
.filter(x => x.trim() === '')
// Reset the results to empty array
.map(() => [])
),
}
})
)(({query, setQuery, searchResults, playSong, doSearch}) => (
<View>
<TextField
hintText="Search for a song! :D"
onChange={(e,value) => setQuery(e.target.value)}
value={query}
onEnterKeyDown={doSearch(query)}
fullWidth={true}
underlineStyle={{borderWidth: 2}}
/>
<View>
{ /* List all the results */ }
{ searchResults.map(result =>
<View
key={result.nid}
className={clickable}
// On click, reset the query and play the song!
onClick={() => {
playSong(result)()
setQuery('')
}}
// Same as setting the text, but more compact
children={`${result.title} - ${result.artist}`}
/>
)}
</View>
</View>
))
export default Search
| dralletje/Tonlist | client/components/Search.js | JavaScript | mit | 2,794 | [
30522,
12324,
10509,
2013,
1005,
10509,
1005,
12324,
1063,
27885,
8043,
12423,
1065,
2013,
1005,
1054,
30524,
1005,
1025,
12324,
11773,
8586,
6525,
4263,
2013,
1005,
3430,
1011,
21318,
1013,
5622,
2497,
1013,
6782,
1013,
4323,
1011,
25545,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 RoonApi = require("node-roon-api"),
RoonApiStatus = require("node-roon-api-status"),
RoonApiSettings = require("node-roon-api-settings"),
RoonApiSourceControl = require("node-roon-api-source-control"),
RoonApiVolumeControl = require("node-roon-api-volume-control"),
Yamaha = require("node-yamaha-avr");
var roon = new RoonApi({
extension_id: 'com.statesofpop.roon-yamaha',
display_name: "Yamaha Control",
display_version: "0.0.7",
publisher: 'states of pop',
email: 'hi@statesofpop.de',
website: 'https://github.com/statesofpop/roon-yamaha'
});
var yamaha = {
"default_device_name": "Yamaha",
"default_input": "HDMI1",
"volume": -50
};
var svc_status = new RoonApiStatus(roon);
var svc_volume = new RoonApiVolumeControl(roon);
var svc_source = new RoonApiSourceControl(roon);
var svc_settings = new RoonApiSettings(roon);
var volTimeout = null;
var mysettings = roon.load_config("settings") || {
receiver_url: "",
input: yamaha.default_input,
device_name: yamaha.default_device_name,
input_list: [
{ title: "HDMI 1", value: "HDMI1" },
{ title: "HDMI 2", value: "HDMI2" },
{ title: "HDMI 3", value: "HDMI3" },
{ title: "HDMI 4", value: "HDMI4" },
{ title: "HDMI 5", value: "HDMI5" },
{ title: "HDMI 6", value: "HDMI6" }
]
};
function makelayout(settings) {
var l = {
values: settings,
layout: [],
has_error: false
};
l.layout.push({
type: "string",
title: "Device name",
subtitle: "Changing this might take some time to take effect.",
setting: "device_name"
});
l.layout.push({
type: "dropdown",
title: "Input",
values: mysettings.input_list,
setting: "input"
});
let v = {
type: "string",
title: "Receiver IP",
subtitle: "Your device should be recognized automatically. If not, please configure your receiver to use a fixed IP-address.",
setting: "receiver_url"
};
if (settings.receiver_url != "" && settings.receiver_url.match(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/) === null) {
v.error = "Please enter a valid IP-address";
l.has_error = true;
}
l.layout.push(v);
return l;
}
var svc_settings = new RoonApiSettings(roon, {
get_settings: function(cb) {
cb(makelayout(mysettings));
},
save_settings: function(req, isdryrun, settings) {
let l = makelayout(settings.values);
req.send_complete(l.has_error ? "NotValid" : "Success", { settings: l });
if (!isdryrun && !l.has_error) {
mysettings = l.values;
svc_settings.update_settings(l);
roon.save_config("settings", mysettings);
}
}
});
svc_status.set_status("Initialising", false);
function update_status() {
if (yamaha.hid && yamaha.device_name) {
svc_status.set_status("Found Yamaha " + yamaha.device_name + " at " + yamaha.ip, false);
} else if (yamaha.hid && yamaha.ip) {
svc_status.set_status("Found Yamaha device at " + yamaha.ip, false);
} else if (yamaha.hid) {
svc_status.set_status("Found Yamaha device. Discovering…", false);
} else {
svc_status.set_status("Could not find Yamaha device.", true)
}
}
function check_status() {
if (yamaha.hid) {
yamaha.hid.getStatus()
.then( (result) => {
// exit if a change through roon is in progress
if (volTimeout) return;
// this seems to only get called on success
let vol_status = result["YAMAHA_AV"]["Main_Zone"][0]["Basic_Status"][0]["Volume"][0];
// should get current state first, to see if update is necessary
yamaha.svc_volume.update_state({
volume_value: vol_status["Lvl"][0]["Val"] / 10,
is_muted: (vol_status["Mute"] == "On")
});
update_status()
})
.catch( (error) => {
// this seems not to get called when device is offline
yamaha.hid == "";
svc_status.set_status("Could not find Yamaha device.", true);
});
}
}
function setup_yamaha() {
if (yamaha.hid) {
yamaha.hid = undefined;
}
if (yamaha.source_control) {
yamaha.source_control.destroy();
delete(yamaha.source_control);
}
if (yamaha.svc_volume) {
yamaha.svc_volume.destroy();
delete(yamaha.svc_volume);
}
yamaha.hid = new Yamaha(mysettings.receiver_url);
// should check whether the device is behind the given url
// only then start to discover.
yamaha.hid.discover()
.then( (ip) => {
yamaha.ip = ip;
update_status();
})
.catch( (error) => {
yamaha.hid = undefined;
svc_status.set_status("Could not find Yamaha device.", true)
});
try {
yamaha.hid.getSystemConfig().then(function(config) {
if (mysettings.device_name == yamaha.default_device_name) {
mysettings.device_name = config["YAMAHA_AV"]["System"][0]["Config"][0]["Model_Name"][0];
}
let inputs = config["YAMAHA_AV"]["System"][0]["Config"][0]["Name"][0]["Input"][0];
mysettings.input_list = [];
for (let key in inputs) {
mysettings.input_list.push({
"title": inputs[key][0].trim(),
"value": key.replace("_", "")
})
}
update_status();
})
} catch(e) {
// getting the device name is not critical, so let's continue
}
yamaha.svc_volume = svc_volume.new_device({
state: {
display_name: mysettings.device_name,
volume_type: "db",
volume_min: -87.5,
volume_max: -20,
volume_value: -50,
volume_step: 0.5,
is_muted: 0
},
set_volume: function (req, mode, value) {
let newvol = mode == "absolute" ? value : (yamaha.volume + value);
if (newvol < this.state.volume_min) newvol = this.state.volume_min;
else if (newvol > this.state.volume_max) newvol = this.state.volume_max;
yamaha.svc_volume.update_state({ volume_value: newvol });
clearTimeout(volTimeout);
volTimeout = setTimeout(() => {
// node-yamaha-avr sends full ints
yamaha.hid.setVolume( value * 10 );
clearTimeout(volTimeout);
volTimeout = null;
}, 500)
req.send_complete("Success");
},
set_mute: function (req, action) {
let is_muted = !this.state.is_muted;
yamaha.hid.setMute( (is_muted)? "on": "off" )
yamaha.svc_volume.update_state({ is_muted: is_muted });
req.send_complete("Success");
}
});
yamaha.source_control = svc_source.new_device({
state: {
display_name: mysettings.device_name,
supports_standby: true,
status: "selected",
},
convenience_switch: function (req) {
yamaha.hid.setInput(mysettings.input);
req.send_complete("Success");
},
standby: function (req) {
let state = this.state.status;
this.state.status = (state == "selected")? "standby": "selected";
yamaha.hid.setPower((state == "selected")? "off": "on");
req.send_complete("Success");
}
});
}
roon.init_services({
provided_services: [ svc_status, svc_settings, svc_volume, svc_source ]
});
setInterval(() => { if (!yamaha.hid) setup_yamaha(); }, 1000);
setInterval(() => { if (yamaha.hid) check_status(); }, 5000);
roon.start_discovery();
| statesofpop/roon-yamaha | app.js | JavaScript | apache-2.0 | 7,950 | [
30522,
13075,
20996,
7856,
8197,
1027,
5478,
1006,
1000,
13045,
1011,
20996,
2239,
1011,
17928,
1000,
1007,
1010,
20996,
7856,
18136,
29336,
2271,
1027,
5478,
1006,
1000,
13045,
1011,
20996,
2239,
1011,
17928,
1011,
3570,
1000,
1007,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#summarySpace {
position: absolute;
top: 50px;
left: 50%;
margin-left: -350px;
}
#summarySpace > div.source {
position: absolute;
width: 124px;
height: 93px;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
}
#summarySpace > div.sourceLarge {
position: absolute;
width: 267px;
height: 200px;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
z-index: 1;
}
#summarySpace > form {
position: absolute;
top: 20px;
left: 500px;
}
#summarySpace > form > button {
line-height: 20px;
font-size: 20px;
font-family: 'Indie Flower', cursive;
border: 2px solid #56A;
border-radius: 4px;
background: rgba(230,220,237,1);
height: 35px;
cursor: pointer;
}
#summarySpace > form > button:hover {
background: rgba(159,200,217,1);
}
#summarySpace > form > button:active {
background: rgba(139,180,197,1);;
}
#summarySpace > div.original {
top: 20px;
left: 289px;
}
#summarySpace > div.tier1 {
top: 197px;
left: 289px;
}
#summarySpace > div.tier2 {
top: 364px;
}
#summarySpace > div.tier2.left {
left: 122px;
}
#summarySpace > div.tier2.right {
left: 456px;
}
#summarySpace > div.tier3 {
top: 538px;
}
#summarySpace > div.tier3.farleft {
left: 31px;
}
#summarySpace > div.tier3.left {
left: 204px;
}
#summarySpace > div.tier3.right {
left: 372px;
}
#summarySpace > div.tier3.farright {
left: 542px;
}
#summarySpace > div.sourceLarge.original {
top: 0px;
left: 222px;
}
#summarySpace > div.sourceLarge.tier1 {
top: 157px;
left: 222px;
}
#summarySpace > div.sourceLarge.tier2 {
top: 314px;
}
#summarySpace > div.sourceLarge.tier2.left {
left: 55px;
}
#summarySpace > div.sourceLarge.tier2.right {
left: 389px;
}
#summarySpace > div.sourceLarge.tier3 {
top: 488px;
}
#summarySpace > div.sourceLarge.tier3.farleft {
left: 0px;
}
#summarySpace > div.sourceLarge.tier3.left {
left: 137px;
}
#summarySpace > div.sourceLarge.tier3.right {
left: 305px;
}
#summarySpace > div.sourceLarge.tier3.farright {
left: 432px;
}
#summarySpace > div.selected {
outline: 3px solid red;
}
#summarySpace > label.nametag {
position: absolute;
font-size: 30px;
font-weight: bold;
}
#summarySpace > label.nametag.order1 {
top: 200px;
left: 420px;
}
#summarySpace > label.nametag.order2 {
top: 370px;
left: -185px;
text-align: right;
width: 300px;
}
#summarySpace > label.nametag.order3 {
top: 370px;
left: 588px;
}
#summarySpace > label.nametag.order4 {
top: 545px;
left: -280px;
text-align: right;
width: 300px;
}
#summarySpace > label.nametag.order5 {
top: 635px;
left: 20px;
text-align: right;
width: 300px;
}
#summarySpace > label.nametag.order6 {
top: 635px;
left: 380px;
}
#summarySpace > label.nametag.order7 {
top: 545px;
left: 675px;
}
| Lochemage/ggj-2016 | client/static/css/summary.css | CSS | mit | 2,857 | [
30522,
1001,
12654,
23058,
1063,
2597,
1024,
7619,
1025,
2327,
1024,
2753,
2361,
2595,
1025,
2187,
1024,
2753,
1003,
1025,
7785,
1011,
2187,
1024,
1011,
8698,
2361,
2595,
1025,
1065,
1001,
12654,
23058,
1028,
4487,
2615,
1012,
3120,
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... |
/*
* Copyright (c) 2021 Citrix Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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 policy
/**
* Binding object which returns the resources bound to policystringmap_binding.
*/
type Policystringmapbinding struct {
/**
* Name of the string map to display. If a name is not provided, a list of all the configured string maps is shown.<br/>Minimum value =
*/
Name string `json:"name,omitempty"`
} | citrix/terraform-provider-netscaler | vendor/github.com/citrix/adc-nitro-go/resource/config/policy/policystringmap_binding.go | GO | apache-2.0 | 939 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
25682,
25022,
29184,
30524,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1012,
1008,
2017,
2089,
6855,
1037,
6100,
1997,
1996,
6105,
2012,
1008,
1008,
8299,
1024,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
START_ATF_NAMESPACE
typedef SLR_FLAGS __MIDL___MIDL_itf_shobjidl_0212_0001;
END_ATF_NAMESPACE
| goodwinxp/Yorozuya | library/ATF/__MIDL___MIDL_itf_shobjidl_0212_0001.hpp | C++ | mit | 250 | [
30522,
1013,
1013,
2023,
5371,
8285,
7013,
2011,
13354,
2378,
2005,
16096,
4013,
1012,
7013,
3642,
2069,
2005,
1060,
21084,
1012,
3531,
1010,
2123,
2102,
2689,
21118,
1001,
10975,
8490,
2863,
2320,
1001,
2421,
1026,
2691,
1013,
2691,
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) Pedram Pourang (aka Tsu Jan) 2014-2021 <tsujan2000@gmail.com>
*
* FeatherPad 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.
*
* FeatherPad 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/>.
*
* @license GPL-3.0+ <https://spdx.org/licenses/GPL-3.0+.html>
*/
#ifndef TABWIDGET_H
#define TABWIDGET_H
#include <QTabWidget>
#include <QTimerEvent>
#include <QKeyEvent>
#include "tabbar.h"
namespace FeatherPad {
class TabWidget : public QTabWidget
{
Q_OBJECT
public:
TabWidget (QWidget *parent = nullptr);
~TabWidget();
/* make it public */
TabBar* tabBar() const {return tb_;}
QWidget* getLastActiveTab();
void removeTab (int index);
void selectLastActiveTab();
void noTabDND() {
tb_->noTabDND();
}
signals:
void currentTabChanged (int curIndx);
void hasLastActiveTab (bool hasLastActive);
protected:
void timerEvent (QTimerEvent *event);
void keyPressEvent (QKeyEvent *event);
private slots:
void tabSwitch (int index);
private:
TabBar *tb_;
int timerId_;
int curIndx_;
/* This is the list of activated tabs, in the order of activation,
and is used for finding the last active tab: */
QList<QWidget*> activatedTabs_;
};
}
#endif // TABWIDGET_H
| tsujan/FeatherPad | featherpad/tabwidget.h | C | gpl-3.0 | 1,786 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
21877,
7265,
2213,
10364,
5654,
1006,
9875,
24529,
2226,
5553,
1007,
2297,
1011,
25682,
1026,
24529,
23049,
2319,
28332,
2692,
1030,
20917,
4014,
1012,
4012,
1028,
1008,
1008,
15550,
15455,
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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="0;url=help.php?module=questionnaire&file=fieldlength.html" />
<title>redirect</title>
</head>
<body>
<p>
しばらくお待ち下さい。
</p>
</body>
</html> | orvsd/moodle19 | mod/questionnaire/lang/ja_utf8/help/questionnaire/maxtextlength.html | HTML | gpl-2.0 | 442 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
9384,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "libmockspotify.h"
#include "util.h"
sp_track *
mocksp_track_create(const char *name, int num_artists, sp_artist **artists, sp_album *album,
int duration, int popularity, int disc, int index, sp_error error,
bool is_loaded, sp_track_availability availability, sp_track_offline_status status,
bool is_local, bool is_autolinked, sp_track *playable,
bool is_starred, bool is_placeholder)
{
sp_track *track = ALLOC(sp_track);
if ( ! playable)
{
playable = track;
}
track->name = strclone(name);
track->album = album;
track->duration = duration;
track->popularity = popularity;
track->disc = disc;
track->index = index;
track->error = error;
track->is_loaded = is_loaded;
track->availability = availability;
track->offline_status = status;
track->is_local = is_local;
track->is_autolinked = is_autolinked;
track->get_playable = playable;
track->is_starred = is_starred;
track->is_placeholder = is_placeholder;
track->artists = ALLOC_N(sp_artist *, num_artists);
track->num_artists = num_artists;
MEMCPY_N(track->artists, artists, sp_artist*, num_artists);
return track;
}
DEFINE_REFCOUNTERS_FOR(track);
DEFINE_READER(track, name, const char *);
DEFINE_READER(track, album, sp_album *);
DEFINE_READER(track, duration, int);
DEFINE_READER(track, popularity, int);
DEFINE_READER(track, disc, int);
DEFINE_READER(track, index, int);
DEFINE_READER(track, error, sp_error);
DEFINE_READER(track, is_loaded, bool);
DEFINE_READER(track, is_placeholder, bool);
DEFINE_SESSION_READER(track, get_playable, sp_track *);
DEFINE_SESSION_READER(track, is_local, bool);
DEFINE_SESSION_READER(track, is_autolinked, bool);
DEFINE_SESSION_READER(track, is_starred, bool);
DEFINE_READER(track, num_artists, int);
DEFINE_ARRAY_READER(track, artist, sp_artist *);
sp_track_availability
sp_track_get_availability(sp_session *UNUSED(session), sp_track *track)
{
return sp_track_is_loaded(track) ? track->availability : SP_TRACK_AVAILABILITY_UNAVAILABLE;
}
sp_track *
sp_localtrack_create(const char *artist, const char *title, const char *album, int length)
{
sp_artist *partist = mocksp_artist_create(artist, NULL, true);
sp_album *palbum = NULL;
if (strlen(album) > 0)
{
palbum = mocksp_album_create(album, partist, 2011, NULL, SP_ALBUMTYPE_UNKNOWN, 1, 1);
}
return mocksp_track_create(title, 1, &partist, palbum, length, 0, 0, 0, SP_ERROR_OK, true, SP_TRACK_AVAILABILITY_AVAILABLE, SP_TRACK_OFFLINE_DONE, true, false, NULL, false, false);
}
sp_error
sp_track_set_starred(sp_session *UNUSED(session), sp_track *const *tracks, int num_tracks, bool starred)
{
int i;
for (i = 0; i < num_tracks; i++)
{
tracks[i]->is_starred = starred;
}
return SP_ERROR_OK;
}
sp_track_offline_status
sp_track_offline_get_status(sp_track *track)
{
return track->offline_status;
}
| mopidy/libmockspotify | src/track.c | C | apache-2.0 | 2,989 | [
30522,
1001,
2421,
1000,
5622,
25526,
25384,
11008,
8757,
1012,
1044,
1000,
1001,
2421,
1000,
21183,
4014,
1012,
1044,
1000,
11867,
1035,
2650,
1008,
12934,
13102,
1035,
2650,
1035,
3443,
1006,
9530,
3367,
25869,
1008,
2171,
1010,
20014,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package parser
import (
"monkey/ast"
"monkey/token"
)
func (p *Parser) parseStringLiteralExpression() ast.Expression {
return &ast.StringLiteral{Token: p.curToken, Value: p.curToken.Literal}
}
func (p *Parser) parseInterpolatedString() ast.Expression {
is := &ast.InterpolatedString{Token: p.curToken, Value: p.curToken.Literal, ExprMap: make(map[byte]ast.Expression)}
key := "0"[0]
for {
if p.curTokenIs(token.LBRACE) {
p.nextToken()
expr := p.parseExpression(LOWEST)
is.ExprMap[key] = expr
key++
}
p.nextInterpToken()
if p.curTokenIs(token.ISTRING) {
break
}
}
return is
}
| mayoms/monkey | parser/strings.go | GO | mit | 612 | [
30522,
7427,
11968,
8043,
12324,
1006,
1000,
10608,
1013,
2004,
2102,
1000,
1000,
10608,
1013,
19204,
1000,
1007,
4569,
2278,
1006,
1052,
1008,
11968,
8043,
1007,
11968,
8583,
18886,
3070,
22779,
7941,
10288,
20110,
3258,
1006,
1007,
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... |
<!doctype html>
<html>
<head>
<title>
Tables
</title>
<meta charset="utf-8"/>
<link rel="stylesheet" href="../css/box.css" type="text/css">
</head>
<body>
<header>
<h1>
Tables
</h1>
</header>
<nav>
<ul>
<li>
<a href=".."> Home</a>
</li>
<li>
<a href="../listsandlinks/"> Lists and Links</a>
</li>
</ul>
</nav>
<main>
<h2>
Simple Grid
</h2>
<table border="1">
<thead>
<tr>
<th>
A
</th>
<th>
B
</th>
<th>
C
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
2
</td>
<td>
3
</td>
</tr>
<tr>
<td>
4
</td>
<td>
5
</td>
<td>
6
</td>
</tr>
<tr>
<td>
7
</td>
<td>
8
</td>
<td>
9
</td>
</tr>
<tr>
<td>
12
</td>
<td>
15
</td>
<td>
18
</td>
</tr>
</tbody>
</table>
<h2>
Calendar
</h2>
<table border="1">
<thead>
<tr>
<th colspan="7">December 2015 </th>
</tr>
</thead>
<tbody>
<tr>
<th>
Mon
</th>
<th>
Tue
</th>
<th>
Wed
</th>
<th>
Thu
</th>
<th>
Fri
</th>
<th>
Sat
</th>
<th>
Sun
</th>
</tr>
<tr>
<th>
</th>
<td>
1
</td>
<td>
2
</td>
<td>
3
</td>
<td>
4
</td>
<td>
5
</td>
<td>
6
</td>
</tr>
<tr>
<td>
7
</td>
<td>
8
</td>
<td>
9
</td>
<td>
10
</td>
<td>
11
</td>
<td>
12
</td>
<td>
13
</td>
</tr>
<tr>
<td>
14
</td>
<td>
15
</td>
<td>
16
</td>
<td>
17
</td>
<td>
18
</td>
<td>
19
</td>
<td>
20
</td>
</tr>
<tr>
<td>
21
</td>
<td>
22
</td>
<td>
23
</td>
<td>
24
</td>
<td>
25
</td>
<td>
26
</td>
<td>
27
</td>
</tr>
<tr>
<td>
28
</td>
<td>
29
</td>
<td>
30
</td>
<td>
31
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7"> Created by:Me!</td>
</tr>
</tfoot>
</table>
<h2>
Class Schedule
</h2>
<table border="1">
<thead>
<tr>
<th>Period</th>
<th>Class Info</th>
</tr>
</thead>
<tbody>
<tr>
<th rowspan="2"> 1</th>
<td> Mr.Kieffer</td>
</tr>
<tr>
<td> Computer Science </td>
</tr>
<tr>
<th rowspan="2"> 2</th>
<td> Mr.Knox </td>
</tr>
<tr>
<td> Ancient World History </td>
</tr>
</tbody>
</table>
</main>
<footer>
©2015 Punch Sethapanichsakul - CMIS Web Design
</footer>
</body>
</html>
| punch2177-cmis/punch2177-cmis-wd | tables/index.html | HTML | cc0-1.0 | 3,569 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
2516,
1028,
7251,
1026,
1013,
2516,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1013,
1028,
1026,
4957,
2128,
2140,
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... |
/*
* DefaultFileActionInstruction.cpp
*
* Created on: 5 août 2015
* Author: FrancisANDRE
*/
#include "ISO-8583/DFT/DefaultFileActionInstruction.h"
namespace ISO_8583 {
namespace MSG {
InstructionAcknowledge* DefaultFileActionInstruction::indication(BinaryInputStream& is, BinaryOutputStream& os) {
return NULL;
}
}
}
| Kampbell/ISO-8583 | cpp/code/ISO-8583/DFT/DefaultFileActionInstruction.cpp | C++ | agpl-3.0 | 337 | [
30522,
1013,
1008,
1008,
12398,
8873,
19738,
7542,
7076,
18300,
3258,
1012,
18133,
2361,
1008,
1008,
2580,
2006,
1024,
1019,
20118,
4904,
2325,
1008,
3166,
1024,
4557,
5685,
2890,
1008,
1013,
1001,
2421,
1000,
11163,
1011,
5594,
2620,
2509,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Downvote < ActiveRecord::Base
validates :post, presence: true
validates :user, presence: true
belongs_to :user, counter_cache: true
belongs_to :post
end
| sudharti/2cents | app/models/downvote.rb | Ruby | mit | 169 | [
30522,
2465,
2091,
22994,
2063,
1026,
3161,
2890,
27108,
2094,
1024,
1024,
2918,
9398,
8520,
1024,
2695,
1010,
3739,
1024,
2995,
9398,
8520,
1024,
5310,
1010,
3739,
1024,
2995,
7460,
1035,
2000,
1024,
5310,
1010,
4675,
1035,
17053,
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... |
<?php
/**
* Holds a fee state obtained from the API
*/
class FeeStateApi extends CRUDApiClient {
const NO_FEE_SELECTED = 0;
protected $name;
protected $isDefaultFee;
protected $isAccompanyingPersonFee;
protected $feeAmounts_id;
public static function getListWithCriteria(array $properties, $printErrorMessage = true) {
return parent::getListWithCriteriaForClass(__CLASS__, $properties, $printErrorMessage);
}
/**
* Returns the default fee state, if there is one
*
* @return FeeStateApi|null The default fee state, if found
*/
public static function getDefaultFee() {
return CRUDApiMisc::getFirstWherePropertyEquals(new FeeStateApi(), 'isDefaultFee', true);
}
/**
* Returns the accompanying person fee state, if there is one
*
* @return FeeStateApi|null The accompanying person fee state, if found
*/
public static function getAccompanyingPersonFee() {
return CRUDApiMisc::getFirstWherePropertyEquals(new FeeStateApi(), 'isAccompanyingPersonFee', true);
}
/**
* Returns the name of the fee state
*
* @return string The fee state name
*/
public function getName() {
return $this->name;
}
/**
* Returns the ids of all fee amounts belonging to this fee state
*
* @return int[] Returns fee amount ids
*/
public function getFeeAmountsId() {
return $this->feeAmounts_id;
}
/**
* Returns whether this fee is the default fee
*
* @return bool Returns true if this is the default fee
*/
public function isDefaultFee() {
return $this->isDefaultFee;
}
/**
* Returns whether this fee is the accompanying person fee
*
* @return bool Returns true if this is the accompanying person fee
*/
public function isAccompanyingPersonFee() {
return $this->isAccompanyingPersonFee;
}
/**
* Returns all fee amounts for this fee state
*
* @param int|null $date Returns only the fee amounts that are still valid from the given date
* If no date is given, the current date is used
* @param int|null $numDays When specified, returns only the fee amounts for this number of days
* @param bool $oneDateOnly Whether to only return results with the same youngest date
*
* @return FeeAmountApi[] The fee amounts that match the criteria
*/
public function getFeeAmounts($date = null, $numDays = null, $oneDateOnly = true) {
return FeeAmountApi::getFeeAmounts($this, $date, $numDays, $oneDateOnly);
}
public function __toString() {
return $this->getName();
}
} | IISH/drupal-module-conference | iishconference_basemodule/api/domain/FeeStateApi.class.php | PHP | gpl-2.0 | 2,522 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
4324,
1037,
7408,
2110,
4663,
2013,
1996,
17928,
1008,
1013,
2465,
9883,
12259,
9331,
2072,
8908,
13675,
14066,
24330,
8751,
3372,
1063,
9530,
3367,
2053,
1035,
7408,
1035,
3479,
1027,
1014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 main
import (
"github.com/robertkrimen/otto"
)
func evaluateScript(src string, payload []FinalInput) (string, error) {
javaScript := otto.New()
var evalFunc otto.Value
javaScript.Set("eval", func(call otto.FunctionCall) otto.Value {
evalFunc = call.Argument(0)
return otto.UndefinedValue()
})
javaScript.Run(src)
arg, err := javaScript.ToValue(payload)
if err != nil {
return "", err
}
ret, err := evalFunc.Call(otto.NullValue(), arg)
if err != nil {
return "", err
}
return ret.ToString()
}
| gophergala2016/scattr | evaluate.go | GO | mit | 525 | [
30522,
7427,
2364,
12324,
1006,
1000,
21025,
2705,
12083,
1012,
4012,
1013,
2728,
21638,
14428,
2078,
1013,
8064,
1000,
1007,
4569,
2278,
16157,
22483,
1006,
5034,
2278,
5164,
1010,
18093,
1031,
1033,
2345,
2378,
18780,
1007,
1006,
5164,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<!-- {{ \Illuminate\Support\Facades\Config::get('custom.html_developer_description') }} -->
<head>
<meta charset="utf-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<meta content="" name="description" />
<meta content="" name="author" />
<!-- start: Mobile Specific -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- end: Mobile Specific -->
<!-- ================== BEGIN BASE CSS STYLE ================== -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<link href="{{ asset('assets/plugins/jquery-ui/themes/base/minified/jquery-ui.min.css') }}" rel="stylesheet" type="text/css" >
<link href="{{ asset('assets/plugins/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" >
<link href="{{ asset('assets/plugins/font-awesome/css/font-awesome.min.css') }}" rel="stylesheet" type="text/css" >
<link href="{{ asset('assets/css/animate.min.css') }}" rel="stylesheet" type="text/css" >
<link href="{{ asset('assets/css/style.min.css') }}" rel="stylesheet" type="text/css" >
<link href="{{ asset('assets/css/style-responsive.min.css') }}" rel="stylesheet" type="text/css" >
<link href="{{ asset('assets/css/theme/default.css') }}" rel="stylesheet" type="text/css" id="theme">
<!-- ================== END BASE CSS STYLE ================== -->
<!-- ================== BEGIN PAGE CSS STYLE ================== -->
<link href="{{ asset('assets/plugins/jquery.countdown/jquery.countdown.css') }}" rel="stylesheet" type="text/css">
<!-- ================== END PAGE CSS STYLE ================== -->
<!-- ================== BEGIN BASE JS ================== -->
<script type="text/javascript" src="{{ URL::asset('assets/plugins/pace/pace.min.js') }}"></script>
<!-- ================== END BASE JS ================== -->
<link rel="shortcut icon" href="img/favicon.ico">
<title>Watch Over Me</title>
</head>
<body class="bg-white p-t-0 pace-top">
<!-- begin #page-loader -->
<div id="page-loader" class="fade in"><span class="spinner"></span></div>
<!-- end #page-loader -->
<!-- begin #page-container -->
<div id="page-container" class="fade">
<!-- begin coming-soon -->
<div class="coming-soon">
<div class="coming-soon-header">
<div class="bg-cover"></div>
<div class="brand">
<img src="{{ asset('img/overwatch.png') }}" width="70px"> WatchOver Me
</div>
<div class="timer">
<div id="timer"></div>
</div>
<div class="desc">
Nosso site está quase pronto e fornecerá boas ferramentas <br />para a comunidade de <b>OverWatch</b> brasileira.
</div>
</div>
<div class="coming-soon-content">
<div class="desc">
Cadastre-se agora para receber <b>benefícios</b> no lançamento.
</div>
<div class="input-group">
<input type="text" class="form-control" id="email" placeholder="Email Address" />
<div class="input-group-btn">
<button type="button" class="btn btn-success" id="subscribe-go">Quero</button>
</div>
</div>
<p class="help-block m-b-25"><i>Não fazemos spam. Seu email está seguro conosco.</i></p>
</div>
</div>
<!-- end coming-soon -->
</div>
<!-- end page container -->
<!-- ================== BEGIN BASE JS ================== -->
<script type="text/javascript" src="{{ URL::asset('assets/plugins/jquery/jquery-1.9.1.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/plugins/jquery/jquery-migrate-1.1.0.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/plugins/jquery-ui/ui/minified/jquery-ui.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/plugins/bootstrap/js/bootstrap.min.js') }}"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="{{ URL::asset('assets/crossbrowserjs/html5shiv.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/crossbrowserjs/respond.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/crossbrowserjs/excanvas.min.js') }}"></script>
<![endif]-->
<script type="text/javascript" src="{{ URL::asset('assets/plugins/slimscroll/jquery.slimscroll.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/plugins/jquery-cookie/jquery.cookie.js') }}"></script>
<!-- ================== END BASE JS ================== -->
<!-- ================== BEGIN PAGE LEVEL JS ================== -->
<script type="text/javascript" src="{{ URL::asset('assets/plugins/jquery.countdown/jquery.plugin.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/plugins/jquery.countdown/jquery.countdown.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/js/coming-soon.demo.min.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('assets/js/apps.min.js') }}"></script>
<!-- ================== END PAGE LEVEL JS ================== -->
<script>
$(document).ready(function() {
App.init();
ComingSoon.init();
$('#subscribe-go').click(function () {
var email = $('#email').val();
if (email.length <= 5) {
alert('Por favor, digite um email válido!');
}
else {
// Get the user profile
$.ajax({
url: "{{ route('pages.subscribe') }}",
type: "POST",
data: {
_token: '{{ csrf_token() }}',
email: email
},
}).done(function(data) {
alert('Agradecemos seu cadastro!\nVocê receberá em breve um email com novas informações.');
});
}
});
});
</script>
@if (getenv('APP_ENV') == 'production')
<script type="text/javascript" src="{{ URL::asset('js/analytics/analytics.js') }}"></script>
@endif
</body>
</html>
| vsouto/watchoverme | resources/views/pages/coming-soon.blade.php | PHP | apache-2.0 | 6,343 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
999,
1011,
1011,
1063,
1063,
1032,
5665,
12717,
12556,
1032,
2490,
1032,
28708,
1032,
9530,
8873,
2290,
1024,
1024,
2131,
1006,
1005,
7661,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* This code was generated by https://code.google.com/p/google-apis-client-generator/
* (build: 2013-06-05 16:09:48 UTC)
* on 2013-06-13 at 02:01:15 UTC
* Modify at your own risk.
*/
package it.rainbowbreeze.technogym.realtime.comm;
/**
* Businesscard request initializer for setting properties like key and userIp.
*
* <p>
* The simplest usage is to use it to set the key parameter:
* </p>
*
* <pre>
public static final GoogleClientRequestInitializer KEY_INITIALIZER =
new BusinesscardRequestInitializer(KEY);
* </pre>
*
* <p>
* There is also a constructor to set both the key and userIp parameters:
* </p>
*
* <pre>
public static final GoogleClientRequestInitializer INITIALIZER =
new BusinesscardRequestInitializer(KEY, USER_IP);
* </pre>
*
* <p>
* If you want to implement custom logic, extend it like this:
* </p>
*
* <pre>
public static class MyRequestInitializer extends BusinesscardRequestInitializer {
{@literal @}Override
public void initializeBusinesscardRequest(BusinesscardRequest{@literal <}?{@literal >} request)
throws IOException {
// custom logic
}
}
* </pre>
*
* <p>
* Finally, to set the key and userIp parameters and insert custom logic, extend it like this:
* </p>
*
* <pre>
public static class MyRequestInitializer2 extends BusinesscardRequestInitializer {
public MyKeyRequestInitializer() {
super(KEY, USER_IP);
}
{@literal @}Override
public void initializeBusinesscardRequest(BusinesscardRequest{@literal <}?{@literal >} request)
throws IOException {
// custom logic
}
}
* </pre>
*
* <p>
* Subclasses should be thread-safe.
* </p>
*
* @since 1.12
*/
public class RoomStateDataRequestInitializer extends com.google.api.client.googleapis.services.json.CommonGoogleJsonClientRequestInitializer {
public RoomStateDataRequestInitializer() {
super();
}
/**
* @param key API key or {@code null} to leave it unchanged
*/
public RoomStateDataRequestInitializer(String key) {
super(key);
}
/**
* @param key API key or {@code null} to leave it unchanged
* @param userIp user IP or {@code null} to leave it unchanged
*/
public RoomStateDataRequestInitializer(String key, String userIp) {
super(key, userIp);
}
@Override
public final void initializeJsonRequest(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest<?> request) throws java.io.IOException {
super.initializeJsonRequest(request);
initializeRoomStateDataRequest((RoomStateDataRequest<?>) request);
}
/**
* Initializes Businesscard request.
*
* <p>
* Default implementation does nothing. Called from
* {@link #initializeJsonRequest(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest)}.
* </p>
*
* @throws java.io.IOException I/O exception
*/
protected void initializeRoomStateDataRequest(RoomStateDataRequest<?> request) throws java.io.IOException {
}
}
| rainbowbreeze/hackathons | 130720-hackitaly/TechnogymRT/src/it/rainbowbreeze/technogym/realtime/comm/RoomStateDataRequestInitializer.java | Java | apache-2.0 | 3,567 | [
30522,
1013,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1008,
1999,
12646,
2007,
1996,
6105,
1012,
2017,
2089,
6855,
1037,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.Text;
using System.Threading.Tasks;
namespace UnitTests.Helpers.DocumentManager
{
public class DocIndex
{
public string Id { get; private set; }
public string FileName { get; private set; }
public string FilePath { get; private set; }
public string Folder { get; private set; }
public DocIndex(string id, string fileName, string filePath, string folderPath)
{
this.Id = id;
this.FileName = fileName;
this.FilePath = filePath;
this.Folder = folderPath;
}
}
public class DocumentFile
{
public string Id { get; private set; }
public string FileName { get; private set; }
public string FilePath { get; private set; }
public DocumentFile(string id, string fileName, string filePath)
{
this.Id = id;
this.FileName = fileName;
this.FilePath = filePath;
}
}
public class DocFileSimulator
{
public DocIndex DocumentIndex { get; private set; }
public DocumentFile DocumentFile1 { get; private set; }
public DocumentFile DocumentFile2 { get; private set; }
public DocumentFile DocumentFile3 { get; private set; }
public DocumentFile DocumentFile4 { get; private set; }
public DocFileSimulator()
{
this.DocumentIndex = new DocIndex("d33b59bd-54af-4f0b-967f-64084847b678", "document_index.xml", @"H:\ParentFolder\d33b59bd-54af-4f0b-967f-64084847b678\document_index.xml", @"H:\ParentFolder\d33b59bd-54af-4f0b-967f-64084847b678");
this.DocumentFile1 = new DocumentFile("f562810b-a1f7-4cf8-b370-dbaf87ff8759", "f562810b-a1f7-4cf8-b370-dbaf87ff8759.txt", @"H:\ParentFolder\d33b59bd-54af-4f0b-967f-64084847b678\f562810b-a1f7-4cf8-b370-dbaf87ff8759.txt");
this.DocumentFile2 = new DocumentFile("11334214-ca43-406b-9cae-f986c3c63332", "11334214-ca43-406b-9cae-f986c3c63332.txt", @"H:\ParentFolder\11334214-ca43-406b-9cae-f986c3c63332\11334214-ca43-406b-9cae-f986c3c63332.txt");
this.DocumentFile3 = new DocumentFile("37c1dba5-9da3-4222-af34-43f98c674d82", "37c1dba5-9da3-4222-af34-43f98c674d82.txt", @"H:\ParentFolder\37c1dba5-9da3-4222-af34-43f98c674d82\37c1dba5-9da3-4222-af34-43f98c674d82.txt");
this.DocumentFile4 = new DocumentFile("0f964889-a3ab-43d6-94a2-76e60cb9aae8", "0f964889-a3ab-43d6-94a2-76e60cb9aae8.txt", @"H:\ParentFolder\0f964889-a3ab-43d6-94a2-76e60cb9aae8\0f964889-a3ab-43d6-94a2-76e60cb9aae8.txt");
}
}
}
| bobbyache/CodeCat | Code/UnitTests/Legacy/old/Helpers/DocumentManager/DocFileSimulator.cs | C# | gpl-3.0 | 2,643 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
3415,
15327,
3131,
22199,
2015,
1012,
2393,
2545,
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) 2016 Turi
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD license. See the LICENSE file for details.
*/
#ifndef GRAPHLAB_SARRAY_READER_BUFFER
#define GRAPHLAB_SARRAY_READER_BUFFER
#include <memory>
#include <vector>
#include <sframe/sframe_constants.hpp>
namespace graphlab {
template <typename T>
class sarray;
/**
* A buffered reader reading from a range of an sarray<T>.
*
* \code
* sarray<flexible_type> mysarray = ...;
*
* // Reader for the first thousand lines
* sarray_reader_buffer<flexible_type> reader(mysarray, 0, 1000);
*
* while(reader.has_next()) {
* flexible_type val = reader.next();
* ... do some thing with val ...
* }
*
* // Reader for the entire sarray
* reader = sarray_reader_buffer<flexible_type>(mysarray, 0, (size_t)(-1));
* ...
* \endcode
*
* Internally, the reader maintains a vector as buffer, and when reading
* reaches the end of the buffer, refill the buffer by reading from sarray.
*/
template<typename T>
class sarray_reader_buffer {
public:
typedef T value_type;
sarray_reader_buffer() = default;
/// Construct from sarray reader with begin and end row.
sarray_reader_buffer(
std::shared_ptr<typename sarray<T>::reader_type> reader,
size_t row_start, size_t row_end,
size_t buffer_size = DEFAULT_SARRAY_READER_BUFFER_SIZE) {
init(reader, row_start, row_end, buffer_size);
}
void init(std::shared_ptr<typename sarray<T>::reader_type>& reader,
size_t row_start, size_t row_end,
size_t internal_buffer_size = DEFAULT_SARRAY_READER_BUFFER_SIZE) {
m_reader = reader;
m_buffer_pos = 0;
m_iter = row_start;
m_original_row_start = row_start;
m_row_start = row_start;
m_row_end = std::min(row_end, m_reader->size());
m_buffer_size = internal_buffer_size;
m_buffer.clear();
}
/// Return the next element in the reader.
value_type&& next();
/// Return true if the reader has more element.
bool has_next();
/// Return the buffer.
inline std::vector<value_type>& get_buffer() {return m_buffer;}
/// Return the Number of elements between row_start and row_end.
inline size_t size() {return m_row_end - m_original_row_start;}
/** Resets the buffer to the initial starting conditions. Reading
* from the buffer again will start from row_start.
*/
void clear();
private:
/// Refill the chunk buffer form the sarray reader.
void refill();
typedef typename sarray<T>::reader_type reader_type;
/// Buffer the prefetched elements.
std::vector<value_type> m_buffer;
/// The underlying reader as a data source.
std::shared_ptr<reader_type> m_reader;
/// Current position of the buffer reader.
size_t m_buffer_pos = 0;
/// The initial starting point. clear() will reset row_start to here.
size_t m_original_row_start = 0;
/// Start row of the remaining chunk.
size_t m_row_start = 0;
/// End row of the chunk.
size_t m_row_end = 0;
/// The size of the buffer vector
size_t m_buffer_size = 0;
/// The current iterator location
size_t m_iter = 0;
};
/// Return the next element in the chunk.
template<typename T>
T&& sarray_reader_buffer<T>::next() {
if (m_buffer_pos == m_buffer.size()) {
refill();
m_buffer_pos = 0;
}
DASSERT_LT(m_buffer_pos, m_buffer.size());
++m_iter;
return std::move(m_buffer[m_buffer_pos++]);
}
/// Return true if the chunk has remaining element.
template<typename T>
bool sarray_reader_buffer<T>::has_next() {
return m_iter < m_row_end;
}
/// Refill the chunk buffer form the sarray reader.
template<typename T>
void sarray_reader_buffer<T>::refill() {
size_t size_of_refill = std::min<size_t>(m_row_end - m_row_start, m_buffer_size);
m_reader->read_rows(m_row_start, m_row_start + size_of_refill, m_buffer);
m_row_start += size_of_refill;
}
template<typename T>
void sarray_reader_buffer<T>::clear() {
m_buffer.clear();
m_row_start = m_original_row_start;
m_iter = m_original_row_start;
m_buffer_pos = 0;
}
}
#endif
| ylow/SFrame | oss_src/sframe/sarray_reader_buffer.hpp | C++ | bsd-3-clause | 4,068 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2355,
10722,
3089,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
30524,
1035,
18906,
9447,
1035,
8068,
1035,
17698,
1001,
2421,
1026,
3638,
1028,
1001,
2421,
1026,
9207,
1028,
1001,
2421,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5072004
* @summary Test new rules for isValue
* @author Eamonn McManus
*/
import javax.management.openmbean.*;
public class IsValueTest {
private static String failed;
public static void main(String[] args) throws Exception {
CompositeType ctOld =
new CompositeType("same.type.name", "old",
new String[] {"int", "string"},
new String[] {"an int", "a string"},
new OpenType[] {SimpleType.INTEGER, SimpleType.STRING});
CompositeType ctNew =
new CompositeType("same.type.name", "new",
new String[] {"int", "int2", "string"},
new String[] {"an int", "another int", "a string"},
new OpenType[] {SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.STRING});
CompositeData cdOld =
new CompositeDataSupport(ctOld,
new String[] {"string", "int"},
new Object[] {"bar", 17});
CompositeData cdNew =
new CompositeDataSupport(ctNew,
new String[] {"int2", "int", "string"},
new Object[] {4, 3, "foo"});
// Check that adding fields doesn't make isValue return false
check(ctOld.isValue(cdNew), "isValue: " + ctOld + "[" + cdNew + "]");
// Check that removing fields does make isValue return false
check(!ctNew.isValue(cdOld), "isValue: " + ctNew + "[" + cdOld + "]");
// Check that we can add a contained CompositeData with extra fields
// inside another CompositeData
CompositeType ctWrapOld =
new CompositeType("wrapper", "wrapper",
new String[] {"wrapped"},
new String[] {"wrapped"},
new OpenType[] {ctOld});
try {
new CompositeDataSupport(ctWrapOld,
new String[] {"wrapped"},
new Object[] {cdNew});
check(true, "CompositeDataSupport containing CompositeDataSupport");
} catch (Exception e) {
e.printStackTrace(System.out);
check(false, "CompositeDataSupport containing CompositeDataSupport: " + e);
}
// ...but not the contrary
CompositeType ctWrapNew =
new CompositeType("wrapper", "wrapper",
new String[] {"wrapped"},
new String[] {"wrapped"},
new OpenType[] {ctNew});
try {
new CompositeDataSupport(ctWrapNew,
new String[] {"wrapped"},
new Object[] {cdOld});
check(false, "CompositeDataSupport containing old did not get exception");
} catch (OpenDataException e) {
check(true, "CompositeDataSupport containing old got expected exception: " + e);
}
// Check that a TabularData can get an extended CompositeData row
TabularType ttOld =
new TabularType("tabular", "tabular", ctOld, new String[] {"int"});
TabularData tdOld =
new TabularDataSupport(ttOld);
try {
tdOld.put(cdNew);
check(true, "TabularDataSupport adding extended CompositeData");
} catch (Exception e) {
e.printStackTrace(System.out);
check(false, "TabularDataSupport adding extended CompositeData: " + e);
}
// Check that an extended TabularData can be put into a CompositeData
TabularType ttNew =
new TabularType("tabular", "tabular", ctNew, new String[] {"int"});
TabularData tdNew =
new TabularDataSupport(ttNew);
CompositeType cttWrap =
new CompositeType("wrapTT", "wrapTT",
new String[] {"wrapped"},
new String[] {"wrapped"},
new OpenType[] {ttOld});
try {
new CompositeDataSupport(cttWrap,
new String[] {"wrapped"},
new Object[] {tdNew});
check(true, "CompositeDataSupport adding extended TabularData");
} catch (Exception e) {
e.printStackTrace(System.out);
check(false, "CompositeDataSupport adding extended TabularData: " + e);
}
if (failed != null)
throw new Exception("TEST FAILED: " + failed);
}
private static void check(boolean value, String what) {
if (value)
System.out.println("OK: " + what);
else {
failed = what;
System.out.println("FAILED: " + what);
}
}
}
| rokn/Count_Words_2015 | testing/openjdk2/jdk/test/javax/management/openmbean/IsValueTest.java | Java | mit | 5,585 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2294,
1010,
14721,
1998,
1013,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
2079,
2025,
11477,
2030,
6366,
9385,
14444,
2030,
2023,
5371,
20346,
1012,
1008,
1008,
2023,
3642,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <stdexcept>
#include <boost/program_options.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tuple/tuple.hpp>
#include <btl/fasta_writer.h>
#include "ereal.h"
#include "dna_sequence.h"
#include "main_io.h"
#include "io.h"
#include "dna_alignment_sequence.h"
#include "rda_functions.h"
#include "krda_improve.h"
#include "needleman.h"
#include "nw_model_parameters.h"
#include "alignment_functions.h"
#include "utility.h"
#include "annotation.h"
#define PARAMETER_ERROR 1
// forward declare version variable
extern const char* build_string;
int main( int argc, char* argv[] ) {
// load program options
using namespace boost::program_options;
using namespace std;
string program_name("rda build ");
program_name += string(build_string);
options_description desc("Allowed options");
desc.add_options()
( "help", "produce help message" )
( "target,t", value<string>(), "first sequence" )
( "query,q", value<string>(), "second sequence" )
( "out,o", value<string>(), "output alignment file" )
( "parameter-file,p", value<string>(), "set parameters from file" )
( "align-method", value<unsigned int>()->default_value(0), "alignment method: 0 RDA, 1 needleman" )
( "block-size,k", value<unsigned int>()->default_value(40), "maximum block size" )
( "block-breaks", "add pure gap sites as block breaks" )
( "output-maf", "output alignment in MAF format")
;
variables_map vm;
store( parse_command_line( argc, argv, desc ), vm );
notify(vm);
if( (argc < 2) || vm.count("help")) {
cout << program_name << endl << desc << endl;
return 1;
}
require_option( vm, "target", PARAMETER_ERROR );
require_option( vm, "query", PARAMETER_ERROR );
unsigned int K = vm.count("block-size") ? vm["block-size"].as<unsigned int>() : 40;
// precompute lookup tables
ereal::init();
try {
dna_sequence_ptr target,query;
target = load_sequence( vm["target"].as<string>() );
query = load_sequence( vm["query"].as<string>() );
require_size_above( *target, 1 );
require_size_above( *query, 1 );
krda_improve<needleman> krda;
krda.set_k(K);
needleman nw;
// load parameter file if needed
if( vm.count("parameter-file") ) {
nw_model_parameters_ptr mp = load_parameters_from_file( vm["parameter-file"].as<string>() );
krda.set_parameters( *mp );
nw.set_s( mp->pr_open, mp->p, mp->q );
nw.set_mean_gap_length( mp->mean_gap_length );
}
if( vm.count("block-breaks") ) krda.set_block_marker( true );
// build final alignment by aligning each identified region with needleman wunch
dna_alignment_sequence_ptr alignmenta = new_dna_alignment_sequence();
dna_alignment_sequence_ptr alignmentb = new_dna_alignment_sequence();
pairwise_dna_alignment final = pairwise_dna_alignment( alignmenta, alignmentb, 0 );
dna_sequence_region_ptr alla = new_dna_sequence_region(target), allb = new_dna_sequence_region(query);
vector< pair<dna_sequence_region_ptr,dna_sequence_region_ptr> > training_set;
training_set.push_back( make_pair(alla,allb) );
// open output file now so that if there is a problem we don't waste time aligning stuff
ofstream out_file;
if( vm.count("out") ) {
out_file.open( vm["out"].as<string>().c_str(), ios::out|ios::trunc );
if( out_file.fail() ) {
cerr << "unable to open " << vm["out"].as<string>() << " for writing" << endl;
return 4;
}
}
annotation_ptr myann;
switch( vm["align-method"].as<unsigned int>() ) {
case 1:
final = nw.align(*alla,*allb);
break;
case 0:
final = krda.align(*alla,*allb);
break;
default:
throw runtime_error("unknown alignment method");
}
// label alignments
final.a->tags["accession"] = target->tags["accession"];
final.b->tags["accession"] = query->tags["accession"];
string info = program_name;
switch( vm["align-method"].as<unsigned int>() ) {
case 1:
info += string(" nm score=") + boost::lexical_cast<string>((double)final.score);
break;
case 0:
info += string(" rda k=") + boost::lexical_cast<string>(K);
info += string(" score=") + boost::lexical_cast<string>((double)final.score);
}
final.a->tags["description"] = final.b->tags["description"] = info;
ostream *out = vm.count("out") ? &out_file : &cout;
if( vm.count("output-maf") ) {
// Output MAF format.
*out << "##maf version=1" << endl;
*out << "a score=" << final.score << endl;
*out << "s " << final.a->tags["accession"] << "\t0\t" << target->data.size() << "\t+\t" << target->data.size() << "\t";
for( dna_alignment_sequence_data::const_iterator j = final.a->data.begin(); j != final.a->data.end(); ++j ) *out << *j;
*out << endl;
*out << "s " << final.b->tags["accession"] << "\t0\t" << query->data.size() << "\t+\t" << query->data.size() << "\t";
for( dna_alignment_sequence_data::const_iterator j = final.b->data.begin(); j != final.b->data.end(); ++j ) *out << *j;
*out << endl;
} else {
*out << btl::fasta_writer( *final.a );
*out << btl::fasta_writer( *final.b );
}
if( vm.count("out") ) out_file.close();
} catch( exception &e ) {
cerr << "FATAL: " << e.what() << endl;
}
return 0;
}
| akhudek/feast | src/rda/rda_main.cc | C++ | mit | 5,604 | [
30522,
1001,
2421,
1026,
16380,
25379,
1028,
1001,
2421,
1026,
1042,
21422,
1028,
1001,
2421,
1026,
9207,
1028,
1001,
2421,
1026,
5164,
1028,
1001,
2421,
1026,
2358,
3207,
2595,
3401,
13876,
1028,
1001,
2421,
1026,
12992,
1013,
2565,
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... |
import time
import midipy as midi
midi.open(128, 0, "midipy test", 0)
for (note, t) in [(48,0.5),(48,0.5),(50,1.0),(48,1.0),(53,1.0),(52,1.0),
(48,0.5),(48,0.5),(50,1.0),(48,1.0),(55,1.0),(53,1.0)]:
midi.note_on(note,127)
time.sleep(t/2)
midi.note_off(note,127)
midi.close()
| tcoxon/wiitar | midipy_src/test.py | Python | gpl-2.0 | 311 | [
30522,
12324,
2051,
12324,
22265,
7685,
2004,
22265,
22265,
1012,
2330,
1006,
11899,
1010,
1014,
1010,
1000,
22265,
7685,
3231,
1000,
1010,
1014,
1007,
2005,
1006,
3602,
1010,
1056,
1007,
1999,
1031,
1006,
4466,
1010,
1014,
1012,
1019,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// Visopsys
// Copyright (C) 1998-2015 J. Andrew McLaughlin
//
// 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.
//
// cmdwin.c
//
// This command will create a new command window
/* This is the text that appears when a user requests help about this program
<help>
-- cmdwin --
Open a new command window.
Usage:
cmdwin
(Only available in graphics mode)
This command will open a new text window running a new instance of the
'vsh' command shell.
</help>
*/
#include <errno.h>
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/api.h>
#include <sys/env.h>
#include <sys/font.h>
#include <sys/paths.h>
#include <sys/window.h>
#define _(string) gettext(string)
#define WINDOW_TITLE _("Command Window")
static int shellProcessId = 0;
objectKey window = NULL;
static void refreshWindow(void)
{
// We got a 'window refresh' event (probably because of a language switch),
// so we need to update things
// Re-get the language setting
setlocale(LC_ALL, getenv(ENV_LANG));
textdomain("cmdwin");
// Refresh the window title
windowSetTitle(window, WINDOW_TITLE);
}
static void eventHandler(objectKey key, windowEvent *event)
{
// Check for window events.
if (key == window)
{
// Check for window refresh
if (event->type == EVENT_WINDOW_REFRESH)
refreshWindow();
// Check for the window being closed
else if (event->type == EVENT_WINDOW_CLOSE)
// The window is being closed by a GUI event. Just kill our shell
// process -- the main process will stop blocking and do the rest
// of the shutdown.
multitaskerKillProcess(shellProcessId, 0 /* no force */);
}
}
int main(int argc, char *argv[])
{
int status = 0;
int myProcessId = 0;
int myPrivilege = 0;
componentParameters params;
int rows = 25;
objectKey textArea = NULL;
setlocale(LC_ALL, getenv(ENV_LANG));
textdomain("cmdwin");
// Only work in graphics mode
if (!graphicsAreEnabled())
{
printf(_("\nThe \"%s\" command only works in graphics mode\n"),
(argc? argv[0] : ""));
errno = ERR_NOTINITIALIZED;
return (status = errno);
}
myProcessId = multitaskerGetCurrentProcessId();
myPrivilege = multitaskerGetProcessPrivilege(myProcessId);
// Load a shell process
shellProcessId = loaderLoadProgram(PATH_PROGRAMS "/vsh", myPrivilege);
if (shellProcessId < 0)
{
printf("%s", _("Unable to load shell\n"));
errno = shellProcessId;
return (status = shellProcessId);
}
// Create a new window
window = windowNew(myProcessId, WINDOW_TITLE);
// Put a text area in the window
memset(¶ms, 0, sizeof(componentParameters));
params.gridWidth = 1;
params.gridHeight = 1;
params.padLeft = 1;
params.padRight = 1;
params.padTop = 1;
params.padBottom = 1;
params.orientationX = orient_center;
params.orientationY = orient_middle;
params.flags |= WINDOW_COMPFLAG_STICKYFOCUS;
status = fileFind(PATH_SYSTEM_FONTS "/xterm-normal-10.vbf", NULL);
if (status >= 0)
status = fontLoadSystem("xterm-normal-10.vbf", "xterm-normal-10",
&(params.font), 1);
if (status < 0)
{
params.font = NULL;
// The system font can comfortably show more rows
rows = 40;
}
textArea = windowNewTextArea(window, 80, rows, 200, ¶ms);
windowComponentFocus(textArea);
// Use the text area for all our input and output
windowSetTextOutput(textArea);
// Go live.
windowSetVisible(window, 1);
// Register an event handler to catch window close events
windowRegisterEventHandler(window, &eventHandler);
// Run the GUI as a thread
windowGuiThread();
// Execute the shell
status = loaderExecProgram(shellProcessId, 1 /* block */);
// If we get to here, the shell has exited.
// Stop our GUI thread
windowGuiStop();
// Destroy the window
windowDestroy(window);
// Done
return (status);
}
| buddywithgol/visopsys | utils/src/programs/cmdwin.c | C | gpl-2.0 | 4,481 | [
30522,
1013,
1013,
1013,
1013,
25292,
11923,
7274,
1013,
1013,
9385,
1006,
1039,
1007,
2687,
1011,
2325,
1046,
1012,
4080,
23720,
1013,
1013,
1013,
1013,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 EffectsList = [
['复古效果', 'sketch', 'dorsy', '2013-10-12'],
['黄色调效果', 'yellowStyle', 'dorsy', '2013-10-12'],
['缩小', 'mini', 'dorsy', '2013-10-12']
];
var EffectTmp = ' <li data-ename="{name}">\
<img src="style/image/effect/{name}.png" />\
<h3>{cnname}</h3>\
<div class="itemInfo">\
<span class="author lightFont">{author}</span>\
<span class="date lightFont">{date}</span>\
</div>\
</li>\
';
| hangfang/ihelper.since.love | static/public/js/photo/effectsList.js | JavaScript | mit | 475 | [
30522,
13075,
3896,
9863,
1027,
1031,
1031,
1005,
100,
1789,
100,
100,
1005,
1010,
1005,
11080,
1005,
1010,
1005,
2079,
2869,
2100,
1005,
1010,
1005,
2286,
1011,
2184,
1011,
2260,
1005,
1033,
1010,
1031,
1005,
100,
100,
100,
100,
100,
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... |
#!/usr/bin/env python
# coding=utf-8
"""598. Split Divisibilities
https://projecteuler.net/problem=598
Consider the number 48.
There are five pairs of integers $a$ and $b$ ($a \leq b$) such that $a \times
b=48$: (1,48), (2,24), (3,16), (4,12) and (6,8).
It can be seen that both 6 and 8 have 4 divisors.
So of those five pairs one consists of two integers with the same number of
divisors.
In general:
Let $C(n)$ be the number of pairs of positive integers $a \times b=n$, ($a
\leq b$) such that $a$ and $b$ have the same number of divisors;
so $C(48)=1$.
You are given $C(10!)=3$: (1680, 2160), (1800, 2016) and (1890,1920).
Find $C(100!)$
"""
| openqt/algorithms | projecteuler/pe598-split-divisibilities.py | Python | gpl-3.0 | 660 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
18750,
1001,
16861,
1027,
21183,
2546,
1011,
1022,
1000,
1000,
1000,
5354,
2620,
1012,
3975,
4487,
11365,
12322,
18622,
7368,
16770,
1024,
1013,
1013,
2622,
13765,
3917,
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... |
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
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.
******************************************************************************/
#ifndef ETL_CPP11_INCLUDED
#define ETL_CPP11_INCLUDED
//*****************************************************************************
// Generic C++11
//*****************************************************************************
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_GENERIC
#define ETL_CPP11_SUPPORTED 1
#define ETL_CPP14_SUPPORTED 0
#define ETL_CPP17_SUPPORTED 0
#define ETL_NO_NULLPTR_SUPPORT 0
#define ETL_NO_LARGE_CHAR_SUPPORT 0
#define ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
#endif
| DanielRahme/LED-matrix-8x8 | library/inc/etl/profiles/cpp11.h | C | gpl-3.0 | 1,872 | [
30522,
1013,
1013,
1013,
1032,
5371,
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,
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... |
<?php
# Inlcuir comentários e informações sobre o sistema
#
################################################################################
# CHANGELOG #
################################################################################
# incluir um changelog
################################################################################
include ("../../includes/include_geral.inc.php");
include ("../../includes/include_geral_II.inc.php");
//$hoje = datab(time());
?>
<HTML>
<BODY bgcolor=<?php print BODY_COLOR?>>
<TABLE bgcolor="black" cellspacing="1" border="1" cellpadding="1" align="center" width="100%">
<TD bgcolor=<?php print TD_COLOR?>>
<TABLE cellspacing="0" border="0" cellpadding="0" bgcolor=<?php print TD_COLOR?>>
<TR>
<?php
$cor1 = TD_COLOR;
print "<TD bgcolor=$cor1 nowrap><b>OcoMon - Módulo de Ocorrências</b></TD>";
echo menu_usuario();
if ($s_usuario=='admin')
{
echo menu_admin();
}
?>
</TR>
</TABLE>
</TD>
</TABLE>
<BR>
<B>Relatório de ocorrências por equipamento - COM BUG</B>
<BR>
<FORM method="POST" action=mostra_relatorio_periodo_equipamento.php>
<TABLE border="1" align="center" width="100%" bgcolor=<?php print BODY_COLOR?>>
<TR>
<TABLE border="1" align="center" width="100%" bgcolor=<?php print TD_COLOR?>>
<TD width="20%" align="left" bgcolor=<?php print TD_COLOR?>>Data abertura (inicial):</TD>
<TD width="30%" align="left" bgcolor=<?php print BODY_COLOR?>><?php print "<INPUT type=text name=data_inicial value=\"$hoje\" size=15 maxlength=15>";?></TD>
<TD width="20%" align="left" bgcolor=<?php print TD_COLOR?>>Data abertura (final):</TD>
<TD width="30%" align="left" bgcolor=<?php print BODY_COLOR?>><?php print "<INPUT type=text name=data_final value=\"$hoje\" size=15 maxlength=15>";?></TD>
</TABLE>
</TR>
<TR>
<TABLE border="0" cellpadding="0" cellspacing="0" align="center" width="100%" bgcolor=<?php print TD_COLOR?>>
<BR>
<TD align="center" width="50%" bgcolor=<?php print BODY_COLOR?>><input type="submit" value=" Ok " name="ok" onclick="ok=sim">
<input type="hidden" name="rodou" value="sim">
</TD>
<TD align="center" width="50%" bgcolor=<?php print BODY_COLOR?>><INPUT type="reset" value="Cancelar" name="cancelar"></TD>
</TABLE>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
| danfmsouza/yipservicedesk | ocomon/geral/relatorio_periodo_equipamento.php | PHP | gpl-2.0 | 2,865 | [
30522,
1026,
1029,
25718,
1001,
1999,
15472,
10179,
2099,
2272,
12380,
9488,
2015,
1041,
12367,
22684,
2229,
17540,
2890,
1051,
24761,
18532,
2050,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
1001,
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... |
#!/usr/bin/env perl
use strict;
my $libPath = $0;
$libPath =~ s/[^\/]+$//;
$libPath .= "lib";
print STDERR "libpath: $libPath\n";
my $cmd = "java -Xmx300M -cp $libPath JsyntenyView @ARGV";
exec $cmd;
die "ERROR, couldn't exec $cmd\n";
| asherkhb/coge | bin/dagchainer/DAGCHAINER/Java_XY_plotter/run_XYplot.pl | Perl | bsd-2-clause | 243 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
4372,
2615,
2566,
2140,
2224,
9384,
1025,
2026,
1002,
5622,
2497,
15069,
1027,
1002,
1014,
1025,
1002,
5622,
2497,
15069,
1027,
1066,
1055,
1013,
1031,
1034,
1032,
1013,
1033,
1009,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>scripts/SuccessiveMelodicIntervals.js</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
<link rel="icon" href="../assets/favicon.ico">
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="doc">
<div id="hd" class="yui3-g header">
<div class="yui3-u-3-4">
<h1><img src="../assets/css/logo.png" title="" width="117" height="52"></h1>
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: </em>
</div>
</div>
<div id="bd" class="yui3-g">
<div class="yui3-u-1-4">
<div id="docs-sidebar" class="sidebar apidocs">
<div id="api-list">
<h2 class="off-left">APIs</h2>
<div id="api-tabview" class="tabview">
<ul class="tabs">
<li><a href="#api-classes">Classes</a></li>
<li><a href="#api-modules">Modules</a></li>
</ul>
<div id="api-tabview-filter">
<input type="search" id="api-filter" placeholder="Type to filter APIs">
</div>
<div id="api-tabview-panel">
<ul id="api-classes" class="apis classes">
<li><a href="../classes/MusicSnippet.html">MusicSnippet</a></li>
<li><a href="../classes/Note.html">Note</a></li>
<li><a href="../classes/QuestionGenerator.html">QuestionGenerator</a></li>
<li><a href="../classes/SuccessiveMelodicIntervals.html">SuccessiveMelodicIntervals</a></li>
</ul>
<ul id="api-modules" class="apis modules">
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="yui3-u-3-4">
<div id="api-options">
Show:
<label for="api-show-inherited">
<input type="checkbox" id="api-show-inherited" checked>
Inherited
</label>
<label for="api-show-protected">
<input type="checkbox" id="api-show-protected">
Protected
</label>
<label for="api-show-private">
<input type="checkbox" id="api-show-private">
Private
</label>
<label for="api-show-deprecated">
<input type="checkbox" id="api-show-deprecated">
Deprecated
</label>
</div>
<div class="apidocs">
<div id="docs-main">
<div class="content">
<h1 class="file-heading">File: scripts/SuccessiveMelodicIntervals.js</h1>
<div class="file">
<pre class="code prettyprint linenums">
/**
* Generates a series of four random twelve-tone notes.
* @class SuccessiveMelodicIntervals
* @constructor
*/
function SuccessiveMelodicIntervals(numNotes) {
const DEFAULT_LENGTH = 4;
var length;
if (numNotes == null || numNotes < 2 || numNotes > 11) {
length = DEFAULT_LENGTH;
} else {
length = numNotes;
}
var g = Math.random();
var notes = generateMelody();
// var answers = calculateAnswers();
/**
* @method getAnswers
* @return {String[]} intervals
*/
this.getAnswers = function() {
var answers = []
for (var i = 0; i < notes.length - 1; i++) {
answers.push(notes[i].getInterval(notes[i+1]));
}
return answers;
}
/**
* Returns the notes as Strings
* @method getNotes
* @return {String[]} notes
*/
this.getNotes = function() {
var notes1 = [];
for (var i = 0; i < notes.length; i++) {
notes1.push(notes[i].toString());
}
return notes1;
}
/**
* Generates a 4-note 12-tone melody using backtracking.
* @method generateMelody
* @return {Note[]} notes
*/
function generateMelody() {
var paletteIndices = [];
for (var k = 0; k < length; k++) {
paletteIndices.push(0);
}
var melody = [];
var i = 0;
while (melody[length - 1] == null) {
var palette;
if (i == 0) {
melody.push(getStartingNote());
// console.log(melody[i].toString());
i++;
continue;
} else palette = getPalette(melody[i-1], i);
for (var j = paletteIndices[i]; j < palette.length; j++) {
melody.push(palette[j]);
// Check if valid
if (validateSMI(melody)) {
// console.log(melody[i].toString());
//
// console.log("valid " + i);
// It worked!
// Update palette of indices in case we need to backtrack later.
paletteIndices[i] = j + 1;
break;
} else {
// console.log("invalid " + i);
// if didn't work
melody.pop();
// continue iterating until we find something that works
}
}
if (melody[i] == null) {
// We made it through the whole palette and nothing worked
if (i == 0) {
// If no starting notes worked, nothing will
// Will never happen in the SMI domain
// Still need to write safe code.
break;
}
// Clean palette index array
paletteIndices[i] = 0;
// Prepare index
i--;
// Remove the previous element because it does not lead us anywhere
// Won't happen in this domain. Again, just writing safe code.
melody.pop();
} else {
// Move on to the next note!
i++;
}
}
return melody;
}
/**
* Create a palette of notes to try based on previous note.
* @method getPalette
* @param {Integer} melody current index
* @return {Note[]} palette
*/
function getPalette(previousNote, i) {
var palette = [];
// document.write("<br>palette:<br>");
var lowestnote = new Note("G", 3);
var highestnote = new Note("F", 5);
var direction = true;
for (var j = -6; j < 7; j++) {
var notetoadd = previousNote.getNextNote(j, direction);
if (notetoadd == null) continue;
var lowcomp = lowestnote.compareTo(notetoadd);
var highcomp = highestnote.compareTo(notetoadd);
var ord = ordinal(notetoadd.getNotename());
if (isNaN(lowcomp) || isNaN(highcomp) || lowcomp >= 0 || highcomp <= 0
|| ord < 9 || ord > 25) {
// Do not add notes that are out of bounds.
// Do not use double sharps, double flats or weird spellings.
} else {
palette.push(notetoadd);
}
if (j == 6 && direction) {
// Now add all notes in the descending direction.
j = -7;
direction = false;
}
}
return shuffleNotes(palette, g * i);
}
/**
* Picks a random starting note. Use notes 9 through 25 (Gb—A#)
* @method getStartingPalette
* @return {Note} palette
*/
function getStartingNote() {
var rand = Math.floor((Math.random() * 16) + 9);
var notename = NOTES[rand];
return new Note(notename, 4);
}
/**
* Seeded shuffle.
* @param shuffleNotes
* @param {Note[]} notes to shuffle
* @param {Integer} seed
* @return {Note[]} shuffled notes
*/
function shuffleNotes(notes, seed) {
Math.seedrandom(seed);
var shuffled = [];
var strikeList = [];
while (shuffled.length < notes.length) {
var rand = Math.floor(Math.random() * notes.length);
if (strikeList.indexOf(rand) == -1) {
// We have not used this number yet! Add to shuffled list
shuffled.push(notes[rand]);
// Strike out this number
strikeList.push(rand);
} else {
// We have already used this number. Keep going!
}
}
return shuffled;
}
}
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
| kbarber-ups/Capstone | out/files/scripts_SuccessiveMelodicIntervals.js.html | HTML | mit | 9,170 | [
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,
2516,
1028,
14546,
1013,
11165,
10199,
7716,
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... |
/////////////////////////////////////////////////////////////////////////////
// Name: webview.cpp
// Purpose: wxWebView sample
// Author: Marianne Gagnon
// Copyright: (c) 2010 Marianne Gagnon, Steven Lamerton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if !wxUSE_WEBVIEW_WEBKIT && !wxUSE_WEBVIEW_IE
#error "A wxWebView backend is required by this sample"
#endif
#include "wx/artprov.h"
#include "wx/cmdline.h"
#include "wx/notifmsg.h"
#include "wx/settings.h"
#include "wx/webview.h"
#include "wx/webviewarchivehandler.h"
#include "wx/webviewfshandler.h"
#include "wx/infobar.h"
#include "wx/filesys.h"
#include "wx/fs_arc.h"
#include "wx/fs_mem.h"
#ifndef wxHAS_IMAGES_IN_RESOURCES
#include "../sample.xpm"
#endif
#if wxUSE_STC
#include "wx/stc/stc.h"
#else
#error "wxStyledTextControl is needed by this sample"
#endif
#if defined(__WXMSW__) || defined(__WXOSX__)
#include "stop.xpm"
#include "refresh.xpm"
#endif
#include "wxlogo.xpm"
//We map menu items to their history items
WX_DECLARE_HASH_MAP(int, wxSharedPtr<wxWebViewHistoryItem>,
wxIntegerHash, wxIntegerEqual, wxMenuHistoryMap);
class WebApp : public wxApp
{
public:
WebApp() :
m_url("http://www.wxwidgets.org")
{
}
virtual bool OnInit() wxOVERRIDE;
#if wxUSE_CMDLINE_PARSER
virtual void OnInitCmdLine(wxCmdLineParser& parser) wxOVERRIDE
{
wxApp::OnInitCmdLine(parser);
parser.AddParam("URL to open",
wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_OPTIONAL);
}
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) wxOVERRIDE
{
if ( !wxApp::OnCmdLineParsed(parser) )
return false;
if ( parser.GetParamCount() )
m_url = parser.GetParam(0);
return true;
}
#endif // wxUSE_CMDLINE_PARSER
private:
wxString m_url;
};
class WebFrame : public wxFrame
{
public:
WebFrame(const wxString& url);
virtual ~WebFrame();
void UpdateState();
void OnIdle(wxIdleEvent& evt);
void OnUrl(wxCommandEvent& evt);
void OnBack(wxCommandEvent& evt);
void OnForward(wxCommandEvent& evt);
void OnStop(wxCommandEvent& evt);
void OnReload(wxCommandEvent& evt);
void OnClearHistory(wxCommandEvent& evt);
void OnEnableHistory(wxCommandEvent& evt);
void OnNavigationRequest(wxWebViewEvent& evt);
void OnNavigationComplete(wxWebViewEvent& evt);
void OnDocumentLoaded(wxWebViewEvent& evt);
void OnNewWindow(wxWebViewEvent& evt);
void OnTitleChanged(wxWebViewEvent& evt);
void OnViewSourceRequest(wxCommandEvent& evt);
void OnViewTextRequest(wxCommandEvent& evt);
void OnToolsClicked(wxCommandEvent& evt);
void OnSetZoom(wxCommandEvent& evt);
void OnError(wxWebViewEvent& evt);
void OnPrint(wxCommandEvent& evt);
void OnCut(wxCommandEvent& evt);
void OnCopy(wxCommandEvent& evt);
void OnPaste(wxCommandEvent& evt);
void OnUndo(wxCommandEvent& evt);
void OnRedo(wxCommandEvent& evt);
void OnMode(wxCommandEvent& evt);
void OnZoomLayout(wxCommandEvent& evt);
void OnHistory(wxCommandEvent& evt);
void OnScrollLineUp(wxCommandEvent&) { m_browser->LineUp(); }
void OnScrollLineDown(wxCommandEvent&) { m_browser->LineDown(); }
void OnScrollPageUp(wxCommandEvent&) { m_browser->PageUp(); }
void OnScrollPageDown(wxCommandEvent&) { m_browser->PageDown(); }
void OnRunScript(wxCommandEvent& evt);
void OnClearSelection(wxCommandEvent& evt);
void OnDeleteSelection(wxCommandEvent& evt);
void OnSelectAll(wxCommandEvent& evt);
void OnLoadScheme(wxCommandEvent& evt);
void OnUseMemoryFS(wxCommandEvent& evt);
void OnFind(wxCommandEvent& evt);
void OnFindDone(wxCommandEvent& evt);
void OnFindText(wxCommandEvent& evt);
void OnFindOptions(wxCommandEvent& evt);
void OnEnableContextMenu(wxCommandEvent& evt);
private:
wxTextCtrl* m_url;
wxWebView* m_browser;
wxToolBar* m_toolbar;
wxToolBarToolBase* m_toolbar_back;
wxToolBarToolBase* m_toolbar_forward;
wxToolBarToolBase* m_toolbar_stop;
wxToolBarToolBase* m_toolbar_reload;
wxToolBarToolBase* m_toolbar_tools;
wxToolBarToolBase* m_find_toolbar_done;
wxToolBarToolBase* m_find_toolbar_next;
wxToolBarToolBase* m_find_toolbar_previous;
wxToolBarToolBase* m_find_toolbar_options;
wxMenuItem* m_find_toolbar_wrap;
wxMenuItem* m_find_toolbar_highlight;
wxMenuItem* m_find_toolbar_matchcase;
wxMenuItem* m_find_toolbar_wholeword;
wxMenu* m_tools_menu;
wxMenu* m_tools_history_menu;
wxMenuItem* m_tools_layout;
wxMenuItem* m_tools_tiny;
wxMenuItem* m_tools_small;
wxMenuItem* m_tools_medium;
wxMenuItem* m_tools_large;
wxMenuItem* m_tools_largest;
wxMenuItem* m_tools_handle_navigation;
wxMenuItem* m_tools_handle_new_window;
wxMenuItem* m_tools_enable_history;
wxMenuItem* m_edit_cut;
wxMenuItem* m_edit_copy;
wxMenuItem* m_edit_paste;
wxMenuItem* m_edit_undo;
wxMenuItem* m_edit_redo;
wxMenuItem* m_edit_mode;
wxMenuItem* m_scroll_line_up;
wxMenuItem* m_scroll_line_down;
wxMenuItem* m_scroll_page_up;
wxMenuItem* m_scroll_page_down;
wxMenuItem* m_selection_clear;
wxMenuItem* m_selection_delete;
wxMenuItem* m_find;
wxMenuItem* m_context_menu;
wxInfoBar *m_info;
wxStaticText* m_info_text;
wxTextCtrl* m_find_ctrl;
wxToolBar* m_find_toolbar;
wxMenuHistoryMap m_histMenuItems;
wxString m_findText;
int m_findFlags, m_findCount;
};
class SourceViewDialog : public wxDialog
{
public:
SourceViewDialog(wxWindow* parent, wxString source);
};
wxIMPLEMENT_APP(WebApp);
// ============================================================================
// implementation
// ============================================================================
bool WebApp::OnInit()
{
if ( !wxApp::OnInit() )
return false;
//Required for virtual file system archive and memory support
wxFileSystem::AddHandler(new wxArchiveFSHandler);
wxFileSystem::AddHandler(new wxMemoryFSHandler);
// Create the memory files
wxImage::AddHandler(new wxPNGHandler);
wxMemoryFSHandler::AddFile("logo.png",
wxBitmap(wxlogo_xpm), wxBITMAP_TYPE_PNG);
wxMemoryFSHandler::AddFile("page1.htm",
"<html><head><title>File System Example</title>"
"<link rel='stylesheet' type='text/css' href='memory:test.css'>"
"</head><body><h1>Page 1</h1>"
"<p><img src='memory:logo.png'></p>"
"<p>Some text about <a href='memory:page2.htm'>Page 2</a>.</p></body>");
wxMemoryFSHandler::AddFile("page2.htm",
"<html><head><title>File System Example</title>"
"<link rel='stylesheet' type='text/css' href='memory:test.css'>"
"</head><body><h1>Page 2</h1>"
"<p><a href='memory:page1.htm'>Page 1</a> was better.</p></body>");
wxMemoryFSHandler::AddFile("test.css", "h1 {color: red;}");
WebFrame *frame = new WebFrame(m_url);
frame->Show();
return true;
}
WebFrame::WebFrame(const wxString& url) :
wxFrame(NULL, wxID_ANY, "wxWebView Sample")
{
// set the frame icon
SetIcon(wxICON(sample));
SetTitle("wxWebView Sample");
wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
// Create the toolbar
m_toolbar = CreateToolBar(wxTB_TEXT);
m_toolbar->SetToolBitmapSize(wxSize(32, 32));
wxBitmap back = wxArtProvider::GetBitmap(wxART_GO_BACK , wxART_TOOLBAR);
wxBitmap forward = wxArtProvider::GetBitmap(wxART_GO_FORWARD , wxART_TOOLBAR);
#ifdef __WXGTK__
wxBitmap stop = wxArtProvider::GetBitmap("gtk-stop", wxART_TOOLBAR);
#else
wxBitmap stop = wxBitmap(stop_xpm);
#endif
#ifdef __WXGTK__
wxBitmap refresh = wxArtProvider::GetBitmap("gtk-refresh", wxART_TOOLBAR);
#else
wxBitmap refresh = wxBitmap(refresh_xpm);
#endif
m_toolbar_back = m_toolbar->AddTool(wxID_ANY, _("Back"), back);
m_toolbar_forward = m_toolbar->AddTool(wxID_ANY, _("Forward"), forward);
m_toolbar_stop = m_toolbar->AddTool(wxID_ANY, _("Stop"), stop);
m_toolbar_reload = m_toolbar->AddTool(wxID_ANY, _("Reload"), refresh);
m_url = new wxTextCtrl(m_toolbar, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(400, -1), wxTE_PROCESS_ENTER );
m_toolbar->AddControl(m_url, _("URL"));
m_toolbar_tools = m_toolbar->AddTool(wxID_ANY, _("Menu"), wxBitmap(wxlogo_xpm));
m_toolbar->Realize();
// Set find values.
m_findFlags = wxWEBVIEW_FIND_DEFAULT;
m_findText = wxEmptyString;
m_findCount = 0;
// Create panel for find toolbar.
wxPanel* panel = new wxPanel(this);
topsizer->Add(panel, wxSizerFlags().Expand());
// Create sizer for panel.
wxBoxSizer* panel_sizer = new wxBoxSizer(wxVERTICAL);
panel->SetSizer(panel_sizer);
// Create the find toolbar.
m_find_toolbar = new wxToolBar(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxTB_TEXT|wxTB_HORZ_LAYOUT);
m_find_toolbar->Hide();
panel_sizer->Add(m_find_toolbar, wxSizerFlags().Expand());
// Create find control.
m_find_ctrl = new wxTextCtrl(m_find_toolbar, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(140,-1), wxTE_PROCESS_ENTER);
//Find options menu
wxMenu* findmenu = new wxMenu;
m_find_toolbar_wrap = findmenu->AppendCheckItem(wxID_ANY,"Wrap");
m_find_toolbar_matchcase = findmenu->AppendCheckItem(wxID_ANY,"Match Case");
m_find_toolbar_wholeword = findmenu->AppendCheckItem(wxID_ANY,"Entire Word");
m_find_toolbar_highlight = findmenu->AppendCheckItem(wxID_ANY,"Highlight");
// Add find toolbar tools.
m_find_toolbar->SetToolSeparation(7);
m_find_toolbar_done = m_find_toolbar->AddTool(wxID_ANY, "Close", wxArtProvider::GetBitmap(wxART_CROSS_MARK));
m_find_toolbar->AddSeparator();
m_find_toolbar->AddControl(m_find_ctrl, "Find");
m_find_toolbar->AddSeparator();
m_find_toolbar_next = m_find_toolbar->AddTool(wxID_ANY, "Next", wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_TOOLBAR, wxSize(16,16)));
m_find_toolbar_previous = m_find_toolbar->AddTool(wxID_ANY, "Previous", wxArtProvider::GetBitmap(wxART_GO_UP, wxART_TOOLBAR, wxSize(16,16)));
m_find_toolbar->AddSeparator();
m_find_toolbar_options = m_find_toolbar->AddTool(wxID_ANY, "Options", wxArtProvider::GetBitmap(wxART_PLUS, wxART_TOOLBAR, wxSize(16,16)), "", wxITEM_DROPDOWN);
m_find_toolbar_options->SetDropdownMenu(findmenu);
m_find_toolbar->Realize();
// Create the info panel
m_info = new wxInfoBar(this);
topsizer->Add(m_info, wxSizerFlags().Expand());
// Create the webview
m_browser = wxWebView::New(this, wxID_ANY, url);
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
//We register the wxfs:// protocol for testing purposes
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
//And the memory: file system
m_browser->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
SetSizer(topsizer);
//Set a more sensible size for web browsing
SetSize(wxSize(800, 600));
// Create a log window
new wxLogWindow(this, _("Logging"), true, false);
// Create the Tools menu
m_tools_menu = new wxMenu();
wxMenuItem* print = m_tools_menu->Append(wxID_ANY , _("Print"));
wxMenuItem* viewSource = m_tools_menu->Append(wxID_ANY , _("View Source"));
wxMenuItem* viewText = m_tools_menu->Append(wxID_ANY, _("View Text"));
m_tools_menu->AppendSeparator();
m_tools_layout = m_tools_menu->AppendCheckItem(wxID_ANY, _("Use Layout Zoom"));
m_tools_tiny = m_tools_menu->AppendCheckItem(wxID_ANY, _("Tiny"));
m_tools_small = m_tools_menu->AppendCheckItem(wxID_ANY, _("Small"));
m_tools_medium = m_tools_menu->AppendCheckItem(wxID_ANY, _("Medium"));
m_tools_large = m_tools_menu->AppendCheckItem(wxID_ANY, _("Large"));
m_tools_largest = m_tools_menu->AppendCheckItem(wxID_ANY, _("Largest"));
m_tools_menu->AppendSeparator();
m_tools_handle_navigation = m_tools_menu->AppendCheckItem(wxID_ANY, _("Handle Navigation"));
m_tools_handle_new_window = m_tools_menu->AppendCheckItem(wxID_ANY, _("Handle New Windows"));
m_tools_menu->AppendSeparator();
//Find
m_find = m_tools_menu->Append(wxID_ANY, _("Find"));
m_tools_menu->AppendSeparator();
//History menu
m_tools_history_menu = new wxMenu();
wxMenuItem* clearhist = m_tools_history_menu->Append(wxID_ANY, _("Clear History"));
m_tools_enable_history = m_tools_history_menu->AppendCheckItem(wxID_ANY, _("Enable History"));
m_tools_history_menu->AppendSeparator();
m_tools_menu->AppendSubMenu(m_tools_history_menu, "History");
//Create an editing menu
wxMenu* editmenu = new wxMenu();
m_edit_cut = editmenu->Append(wxID_ANY, _("Cut"));
m_edit_copy = editmenu->Append(wxID_ANY, _("Copy"));
m_edit_paste = editmenu->Append(wxID_ANY, _("Paste"));
editmenu->AppendSeparator();
m_edit_undo = editmenu->Append(wxID_ANY, _("Undo"));
m_edit_redo = editmenu->Append(wxID_ANY, _("Redo"));
editmenu->AppendSeparator();
m_edit_mode = editmenu->AppendCheckItem(wxID_ANY, _("Edit Mode"));
m_tools_menu->AppendSeparator();
m_tools_menu->AppendSubMenu(editmenu, "Edit");
wxMenu* scroll_menu = new wxMenu;
m_scroll_line_up = scroll_menu->Append(wxID_ANY, "Line &up");
m_scroll_line_down = scroll_menu->Append(wxID_ANY, "Line &down");
m_scroll_page_up = scroll_menu->Append(wxID_ANY, "Page u&p");
m_scroll_page_down = scroll_menu->Append(wxID_ANY, "Page d&own");
m_tools_menu->AppendSubMenu(scroll_menu, "Scroll");
wxMenuItem* script = m_tools_menu->Append(wxID_ANY, _("Run Script"));
//Selection menu
wxMenu* selection = new wxMenu();
m_selection_clear = selection->Append(wxID_ANY, _("Clear Selection"));
m_selection_delete = selection->Append(wxID_ANY, _("Delete Selection"));
wxMenuItem* selectall = selection->Append(wxID_ANY, _("Select All"));
editmenu->AppendSubMenu(selection, "Selection");
wxMenuItem* loadscheme = m_tools_menu->Append(wxID_ANY, _("Custom Scheme Example"));
wxMenuItem* usememoryfs = m_tools_menu->Append(wxID_ANY, _("Memory File System Example"));
m_context_menu = m_tools_menu->AppendCheckItem(wxID_ANY, _("Enable Context Menu"));
//By default we want to handle navigation and new windows
m_tools_handle_navigation->Check();
m_tools_handle_new_window->Check();
m_tools_enable_history->Check();
if(!m_browser->CanSetZoomType(wxWEBVIEW_ZOOM_TYPE_LAYOUT))
m_tools_layout->Enable(false);
// Connect the toolbar events
Connect(m_toolbar_back->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnBack), NULL, this );
Connect(m_toolbar_forward->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnForward), NULL, this );
Connect(m_toolbar_stop->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnStop), NULL, this );
Connect(m_toolbar_reload->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnReload),NULL, this );
Connect(m_toolbar_tools->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnToolsClicked), NULL, this );
Connect(m_url->GetId(), wxEVT_TEXT_ENTER,
wxCommandEventHandler(WebFrame::OnUrl), NULL, this );
// Connect find toolbar events.
Connect(m_find_toolbar_done->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnFindDone), NULL, this );
Connect(m_find_toolbar_next->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnFindText), NULL, this );
Connect(m_find_toolbar_previous->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnFindText), NULL, this );
// Connect find control events.
Connect(m_find_ctrl->GetId(), wxEVT_TEXT,
wxCommandEventHandler(WebFrame::OnFindText), NULL, this );
Connect(m_find_ctrl->GetId(), wxEVT_TEXT_ENTER,
wxCommandEventHandler(WebFrame::OnFindText), NULL, this );
// Connect the webview events
Connect(m_browser->GetId(), wxEVT_WEBVIEW_NAVIGATING,
wxWebViewEventHandler(WebFrame::OnNavigationRequest), NULL, this);
Connect(m_browser->GetId(), wxEVT_WEBVIEW_NAVIGATED,
wxWebViewEventHandler(WebFrame::OnNavigationComplete), NULL, this);
Connect(m_browser->GetId(), wxEVT_WEBVIEW_LOADED,
wxWebViewEventHandler(WebFrame::OnDocumentLoaded), NULL, this);
Connect(m_browser->GetId(), wxEVT_WEBVIEW_ERROR,
wxWebViewEventHandler(WebFrame::OnError), NULL, this);
Connect(m_browser->GetId(), wxEVT_WEBVIEW_NEWWINDOW,
wxWebViewEventHandler(WebFrame::OnNewWindow), NULL, this);
Connect(m_browser->GetId(), wxEVT_WEBVIEW_TITLE_CHANGED,
wxWebViewEventHandler(WebFrame::OnTitleChanged), NULL, this);
// Connect the menu events
Connect(viewSource->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnViewSourceRequest), NULL, this );
Connect(viewText->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnViewTextRequest), NULL, this );
Connect(print->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnPrint), NULL, this );
Connect(m_tools_layout->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnZoomLayout), NULL, this );
Connect(m_tools_tiny->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this );
Connect(m_tools_small->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this );
Connect(m_tools_medium->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this );
Connect(m_tools_large->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this );
Connect(m_tools_largest->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this );
Connect(clearhist->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnClearHistory), NULL, this );
Connect(m_tools_enable_history->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnEnableHistory), NULL, this );
Connect(m_edit_cut->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnCut), NULL, this );
Connect(m_edit_copy->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnCopy), NULL, this );
Connect(m_edit_paste->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnPaste), NULL, this );
Connect(m_edit_undo->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnUndo), NULL, this );
Connect(m_edit_redo->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRedo), NULL, this );
Connect(m_edit_mode->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnMode), NULL, this );
Connect(m_scroll_line_up->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollLineUp), NULL, this );
Connect(m_scroll_line_down->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollLineDown), NULL, this );
Connect(m_scroll_page_up->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollPageUp), NULL, this );
Connect(m_scroll_page_down->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollPageDown), NULL, this );
Connect(script->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScript), NULL, this );
Connect(m_selection_clear->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnClearSelection), NULL, this );
Connect(m_selection_delete->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnDeleteSelection), NULL, this );
Connect(selectall->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnSelectAll), NULL, this );
Connect(loadscheme->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnLoadScheme), NULL, this );
Connect(usememoryfs->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnUseMemoryFS), NULL, this );
Connect(m_find->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnFind), NULL, this );
Connect(m_context_menu->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnEnableContextMenu), NULL, this );
//Connect the idle events
Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(WebFrame::OnIdle), NULL, this);
}
WebFrame::~WebFrame()
{
delete m_tools_menu;
}
/**
* Method that retrieves the current state from the web control and updates the GUI
* the reflect this current state.
*/
void WebFrame::UpdateState()
{
m_toolbar->EnableTool( m_toolbar_back->GetId(), m_browser->CanGoBack() );
m_toolbar->EnableTool( m_toolbar_forward->GetId(), m_browser->CanGoForward() );
if (m_browser->IsBusy())
{
m_toolbar->EnableTool( m_toolbar_stop->GetId(), true );
}
else
{
m_toolbar->EnableTool( m_toolbar_stop->GetId(), false );
}
SetTitle( m_browser->GetCurrentTitle() );
m_url->SetValue( m_browser->GetCurrentURL() );
}
void WebFrame::OnIdle(wxIdleEvent& WXUNUSED(evt))
{
if(m_browser->IsBusy())
{
wxSetCursor(wxCURSOR_ARROWWAIT);
m_toolbar->EnableTool(m_toolbar_stop->GetId(), true);
}
else
{
wxSetCursor(wxNullCursor);
m_toolbar->EnableTool(m_toolbar_stop->GetId(), false);
}
}
/**
* Callback invoked when user entered an URL and pressed enter
*/
void WebFrame::OnUrl(wxCommandEvent& WXUNUSED(evt))
{
m_browser->LoadURL( m_url->GetValue() );
m_browser->SetFocus();
UpdateState();
}
/**
* Callback invoked when user pressed the "back" button
*/
void WebFrame::OnBack(wxCommandEvent& WXUNUSED(evt))
{
m_browser->GoBack();
UpdateState();
}
/**
* Callback invoked when user pressed the "forward" button
*/
void WebFrame::OnForward(wxCommandEvent& WXUNUSED(evt))
{
m_browser->GoForward();
UpdateState();
}
/**
* Callback invoked when user pressed the "stop" button
*/
void WebFrame::OnStop(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Stop();
UpdateState();
}
/**
* Callback invoked when user pressed the "reload" button
*/
void WebFrame::OnReload(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Reload();
UpdateState();
}
void WebFrame::OnClearHistory(wxCommandEvent& WXUNUSED(evt))
{
m_browser->ClearHistory();
UpdateState();
}
void WebFrame::OnEnableHistory(wxCommandEvent& WXUNUSED(evt))
{
m_browser->EnableHistory(m_tools_enable_history->IsChecked());
UpdateState();
}
void WebFrame::OnCut(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Cut();
}
void WebFrame::OnCopy(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Copy();
}
void WebFrame::OnPaste(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Paste();
}
void WebFrame::OnUndo(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Undo();
}
void WebFrame::OnRedo(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Redo();
}
void WebFrame::OnMode(wxCommandEvent& WXUNUSED(evt))
{
m_browser->SetEditable(m_edit_mode->IsChecked());
}
void WebFrame::OnLoadScheme(wxCommandEvent& WXUNUSED(evt))
{
wxFileName helpfile("../help/doc.zip");
helpfile.MakeAbsolute();
wxString path = helpfile.GetFullPath();
//Under MSW we need to flip the slashes
path.Replace("\\", "/");
path = "wxfs:///" + path + ";protocol=zip/doc.htm";
m_browser->LoadURL(path);
}
void WebFrame::OnUseMemoryFS(wxCommandEvent& WXUNUSED(evt))
{
m_browser->LoadURL("memory:page1.htm");
}
void WebFrame::OnEnableContextMenu(wxCommandEvent& evt)
{
m_browser->EnableContextMenu(evt.IsChecked());
}
void WebFrame::OnFind(wxCommandEvent& WXUNUSED(evt))
{
wxString value = m_browser->GetSelectedText();
if(value.Len() > 150)
{
value.Truncate(150);
}
m_find_ctrl->SetValue(value);
if(!m_find_toolbar->IsShown()){
m_find_toolbar->Show(true);
SendSizeEvent();
}
m_find_ctrl->SelectAll();
}
void WebFrame::OnFindDone(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Find("");
m_find_toolbar->Show(false);
SendSizeEvent();
}
void WebFrame::OnFindText(wxCommandEvent& evt)
{
int flags = 0;
if(m_find_toolbar_wrap->IsChecked())
flags |= wxWEBVIEW_FIND_WRAP;
if(m_find_toolbar_wholeword->IsChecked())
flags |= wxWEBVIEW_FIND_ENTIRE_WORD;
if(m_find_toolbar_matchcase->IsChecked())
flags |= wxWEBVIEW_FIND_MATCH_CASE;
if(m_find_toolbar_highlight->IsChecked())
flags |= wxWEBVIEW_FIND_HIGHLIGHT_RESULT;
if(m_find_toolbar_previous->GetId() == evt.GetId())
flags |= wxWEBVIEW_FIND_BACKWARDS;
wxString find_text = m_find_ctrl->GetValue();
long count = m_browser->Find(find_text, flags);
if(m_findText != find_text)
{
m_findCount = count;
m_findText = find_text;
}
if(count != wxNOT_FOUND || find_text.IsEmpty())
{
m_find_ctrl->SetBackgroundColour(*wxWHITE);
}
else
{
m_find_ctrl->SetBackgroundColour(wxColour(255, 101, 101));
}
m_find_ctrl->Refresh();
//Log the result, note that count is zero indexed.
if(count != m_findCount)
{
count++;
}
wxLogMessage("Searching for:%s current match:%i/%i", m_findText.c_str(), count, m_findCount);
}
/**
* Callback invoked when there is a request to load a new page (for instance
* when the user clicks a link)
*/
void WebFrame::OnNavigationRequest(wxWebViewEvent& evt)
{
if(m_info->IsShown())
{
m_info->Dismiss();
}
wxLogMessage("%s", "Navigation request to '" + evt.GetURL() + "' (target='" +
evt.GetTarget() + "')");
wxASSERT(m_browser->IsBusy());
//If we don't want to handle navigation then veto the event and navigation
//will not take place, we also need to stop the loading animation
if(!m_tools_handle_navigation->IsChecked())
{
evt.Veto();
m_toolbar->EnableTool( m_toolbar_stop->GetId(), false );
}
else
{
UpdateState();
}
}
/**
* Callback invoked when a navigation request was accepted
*/
void WebFrame::OnNavigationComplete(wxWebViewEvent& evt)
{
wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
UpdateState();
}
/**
* Callback invoked when a page is finished loading
*/
void WebFrame::OnDocumentLoaded(wxWebViewEvent& evt)
{
//Only notify if the document is the main frame, not a subframe
if(evt.GetURL() == m_browser->GetCurrentURL())
{
wxLogMessage("%s", "Document loaded; url='" + evt.GetURL() + "'");
}
UpdateState();
}
/**
* On new window, we veto to stop extra windows appearing
*/
void WebFrame::OnNewWindow(wxWebViewEvent& evt)
{
wxLogMessage("%s", "New window; url='" + evt.GetURL() + "'");
//If we handle new window events then just load them in this window as we
//are a single window browser
if(m_tools_handle_new_window->IsChecked())
m_browser->LoadURL(evt.GetURL());
UpdateState();
}
void WebFrame::OnTitleChanged(wxWebViewEvent& evt)
{
SetTitle(evt.GetString());
wxLogMessage("%s", "Title changed; title='" + evt.GetString() + "'");
}
/**
* Invoked when user selects the "View Source" menu item
*/
void WebFrame::OnViewSourceRequest(wxCommandEvent& WXUNUSED(evt))
{
SourceViewDialog dlg(this, m_browser->GetPageSource());
dlg.ShowModal();
}
/**
* Invoked when user selects the "View Text" menu item
*/
void WebFrame::OnViewTextRequest(wxCommandEvent& WXUNUSED(evt))
{
wxDialog textViewDialog(this, wxID_ANY, "Page Text",
wxDefaultPosition, wxSize(700,500),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
wxStyledTextCtrl* text = new wxStyledTextCtrl(&textViewDialog, wxID_ANY);
text->SetText(m_browser->GetPageText());
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(text, 1, wxEXPAND);
SetSizer(sizer);
textViewDialog.ShowModal();
}
/**
* Invoked when user selects the "Menu" item
*/
void WebFrame::OnToolsClicked(wxCommandEvent& WXUNUSED(evt))
{
if(m_browser->GetCurrentURL() == "")
return;
m_tools_tiny->Check(false);
m_tools_small->Check(false);
m_tools_medium->Check(false);
m_tools_large->Check(false);
m_tools_largest->Check(false);
wxWebViewZoom zoom = m_browser->GetZoom();
switch (zoom)
{
case wxWEBVIEW_ZOOM_TINY:
m_tools_tiny->Check();
break;
case wxWEBVIEW_ZOOM_SMALL:
m_tools_small->Check();
break;
case wxWEBVIEW_ZOOM_MEDIUM:
m_tools_medium->Check();
break;
case wxWEBVIEW_ZOOM_LARGE:
m_tools_large->Check();
break;
case wxWEBVIEW_ZOOM_LARGEST:
m_tools_largest->Check();
break;
}
m_edit_cut->Enable(m_browser->CanCut());
m_edit_copy->Enable(m_browser->CanCopy());
m_edit_paste->Enable(m_browser->CanPaste());
m_edit_undo->Enable(m_browser->CanUndo());
m_edit_redo->Enable(m_browser->CanRedo());
m_selection_clear->Enable(m_browser->HasSelection());
m_selection_delete->Enable(m_browser->HasSelection());
m_context_menu->Check(m_browser->IsContextMenuEnabled());
//Firstly we clear the existing menu items, then we add the current ones
wxMenuHistoryMap::const_iterator it;
for( it = m_histMenuItems.begin(); it != m_histMenuItems.end(); ++it )
{
m_tools_history_menu->Destroy(it->first);
}
m_histMenuItems.clear();
wxVector<wxSharedPtr<wxWebViewHistoryItem> > back = m_browser->GetBackwardHistory();
wxVector<wxSharedPtr<wxWebViewHistoryItem> > forward = m_browser->GetForwardHistory();
wxMenuItem* item;
unsigned int i;
for(i = 0; i < back.size(); i++)
{
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, back[i]->GetTitle());
m_histMenuItems[item->GetId()] = back[i];
Connect(item->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnHistory), NULL, this );
}
wxString title = m_browser->GetCurrentTitle();
if ( title.empty() )
title = "(untitled)";
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, title);
item->Check();
//No need to connect the current item
m_histMenuItems[item->GetId()] = wxSharedPtr<wxWebViewHistoryItem>(new wxWebViewHistoryItem(m_browser->GetCurrentURL(), m_browser->GetCurrentTitle()));
for(i = 0; i < forward.size(); i++)
{
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, forward[i]->GetTitle());
m_histMenuItems[item->GetId()] = forward[i];
Connect(item->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnHistory), NULL, this );
}
wxPoint position = ScreenToClient( wxGetMousePosition() );
PopupMenu(m_tools_menu, position.x, position.y);
}
/**
* Invoked when user selects the zoom size in the menu
*/
void WebFrame::OnSetZoom(wxCommandEvent& evt)
{
if (evt.GetId() == m_tools_tiny->GetId())
{
m_browser->SetZoom(wxWEBVIEW_ZOOM_TINY);
}
else if (evt.GetId() == m_tools_small->GetId())
{
m_browser->SetZoom(wxWEBVIEW_ZOOM_SMALL);
}
else if (evt.GetId() == m_tools_medium->GetId())
{
m_browser->SetZoom(wxWEBVIEW_ZOOM_MEDIUM);
}
else if (evt.GetId() == m_tools_large->GetId())
{
m_browser->SetZoom(wxWEBVIEW_ZOOM_LARGE);
}
else if (evt.GetId() == m_tools_largest->GetId())
{
m_browser->SetZoom(wxWEBVIEW_ZOOM_LARGEST);
}
else
{
wxFAIL;
}
}
void WebFrame::OnZoomLayout(wxCommandEvent& WXUNUSED(evt))
{
if(m_tools_layout->IsChecked())
m_browser->SetZoomType(wxWEBVIEW_ZOOM_TYPE_LAYOUT);
else
m_browser->SetZoomType(wxWEBVIEW_ZOOM_TYPE_TEXT);
}
void WebFrame::OnHistory(wxCommandEvent& evt)
{
m_browser->LoadHistoryItem(m_histMenuItems[evt.GetId()]);
}
void WebFrame::OnRunScript(wxCommandEvent& WXUNUSED(evt))
{
wxTextEntryDialog dialog(this, "Enter JavaScript to run.", wxGetTextFromUserPromptStr, "", wxOK|wxCANCEL|wxCENTRE|wxTE_MULTILINE);
if(dialog.ShowModal() == wxID_OK)
{
m_browser->RunScript(dialog.GetValue());
}
}
void WebFrame::OnClearSelection(wxCommandEvent& WXUNUSED(evt))
{
m_browser->ClearSelection();
}
void WebFrame::OnDeleteSelection(wxCommandEvent& WXUNUSED(evt))
{
m_browser->DeleteSelection();
}
void WebFrame::OnSelectAll(wxCommandEvent& WXUNUSED(evt))
{
m_browser->SelectAll();
}
/**
* Callback invoked when a loading error occurs
*/
void WebFrame::OnError(wxWebViewEvent& evt)
{
#define WX_ERROR_CASE(type) \
case type: \
category = #type; \
break;
wxString category;
switch (evt.GetInt())
{
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CONNECTION);
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_CERTIFICATE);
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_AUTH);
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_SECURITY);
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_NOT_FOUND);
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_REQUEST);
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_USER_CANCELLED);
WX_ERROR_CASE(wxWEBVIEW_NAV_ERR_OTHER);
}
wxLogMessage("%s", "Error; url='" + evt.GetURL() + "', error='" + category + " (" + evt.GetString() + ")'");
//Show the info bar with an error
m_info->ShowMessage(_("An error occurred loading ") + evt.GetURL() + "\n" +
"'" + category + "'", wxICON_ERROR);
UpdateState();
}
/**
* Invoked when user selects "Print" from the menu
*/
void WebFrame::OnPrint(wxCommandEvent& WXUNUSED(evt))
{
m_browser->Print();
}
SourceViewDialog::SourceViewDialog(wxWindow* parent, wxString source) :
wxDialog(parent, wxID_ANY, "Source Code",
wxDefaultPosition, wxSize(700,500),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
wxStyledTextCtrl* text = new wxStyledTextCtrl(this, wxID_ANY);
text->SetMarginWidth(1, 30);
text->SetMarginType(1, wxSTC_MARGIN_NUMBER);
text->SetText(source);
text->StyleClearAll();
text->SetLexer(wxSTC_LEX_HTML);
text->StyleSetForeground(wxSTC_H_DOUBLESTRING, wxColour(255,0,0));
text->StyleSetForeground(wxSTC_H_SINGLESTRING, wxColour(255,0,0));
text->StyleSetForeground(wxSTC_H_ENTITY, wxColour(255,0,0));
text->StyleSetForeground(wxSTC_H_TAG, wxColour(0,150,0));
text->StyleSetForeground(wxSTC_H_TAGUNKNOWN, wxColour(0,150,0));
text->StyleSetForeground(wxSTC_H_ATTRIBUTE, wxColour(0,0,150));
text->StyleSetForeground(wxSTC_H_ATTRIBUTEUNKNOWN, wxColour(0,0,150));
text->StyleSetForeground(wxSTC_H_COMMENT, wxColour(150,150,150));
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(text, 1, wxEXPAND);
SetSizer(sizer);
}
| adouble42/nemesis-current | wxWidgets-3.1.0/samples/webview/webview.cpp | C++ | bsd-2-clause | 35,469 | [
30522,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
1013,
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... |
namespace TestADB
{
partial class SetDeviceToGroupForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.SetDevicesToGroup = new System.Windows.Forms.Button();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.groupsPanel = new System.Windows.Forms.FlowLayoutPanel();
this.devicesPanel = new System.Windows.Forms.FlowLayoutPanel();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.splitContainer2);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(885, 675);
this.panel1.TabIndex = 0;
//
// splitContainer2
//
this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.flowLayoutPanel1);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.SetDevicesToGroup);
this.splitContainer2.Size = new System.Drawing.Size(885, 675);
this.splitContainer2.SplitterDistance = 624;
this.splitContainer2.SplitterWidth = 1;
this.splitContainer2.TabIndex = 1;
//
// SetDevicesToGroup
//
this.SetDevicesToGroup.Location = new System.Drawing.Point(748, 3);
this.SetDevicesToGroup.Name = "SetDevicesToGroup";
this.SetDevicesToGroup.Size = new System.Drawing.Size(125, 41);
this.SetDevicesToGroup.TabIndex = 0;
this.SetDevicesToGroup.Text = "设 置";
this.SetDevicesToGroup.UseVisualStyleBackColor = true;
this.SetDevicesToGroup.Click += new System.EventHandler(this.SetDevicesToGroup_Click);
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Controls.Add(this.groupBox1);
this.flowLayoutPanel1.Controls.Add(this.groupBox2);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(885, 624);
this.flowLayoutPanel1.TabIndex = 0;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.groupsPanel);
this.groupBox1.Location = new System.Drawing.Point(3, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(238, 618);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "分组";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.devicesPanel);
this.groupBox2.Location = new System.Drawing.Point(247, 3);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(635, 618);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "设备";
//
// groupsPanel
//
this.groupsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupsPanel.Location = new System.Drawing.Point(3, 17);
this.groupsPanel.Name = "groupsPanel";
this.groupsPanel.Size = new System.Drawing.Size(232, 598);
this.groupsPanel.TabIndex = 0;
//
// devicesPanel
//
this.devicesPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.devicesPanel.Location = new System.Drawing.Point(3, 17);
this.devicesPanel.Name = "devicesPanel";
this.devicesPanel.Size = new System.Drawing.Size(629, 598);
this.devicesPanel.TabIndex = 0;
//
// SetDeviceToGroupForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(885, 675);
this.Controls.Add(this.panel1);
this.Name = "SetDeviceToGroupForm";
this.Text = "SetDeviceToGroupForm";
this.Load += new System.EventHandler(this.SetDeviceToGroupForm_Load);
this.FormClosed += SetDeviceToGroupForm_FormClosed;
this.panel1.ResumeLayout(false);
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.Button SetDevicesToGroup;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.FlowLayoutPanel groupsPanel;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.FlowLayoutPanel devicesPanel;
}
} | samwen/GroupControl | TestADB/TestADB/TestADB/SetDeviceToGroupForm.Designer.cs | C# | mit | 7,574 | [
30522,
3415,
15327,
3231,
4215,
2497,
1063,
7704,
2465,
2275,
24844,
6610,
3406,
17058,
14192,
1063,
1013,
1013,
1013,
1026,
12654,
1028,
1013,
1013,
1013,
3223,
5859,
8023,
1012,
1013,
1013,
1013,
1026,
1013,
12654,
1028,
2797,
2291,
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... |
Stagehand.redis = Redis.current
Stagehand.token = "pivotal tracker api token"
Stagehand.project_id = "pivotal tracker project id"
| wegowise/stagehand | lib/rails/generators/stagehand/templates/initializer.rb | Ruby | mit | 140 | [
30522,
2754,
11774,
1012,
2417,
2483,
1027,
2417,
2483,
1012,
2783,
2754,
11774,
1012,
19204,
1027,
1000,
20369,
27080,
17928,
19204,
1000,
2754,
11774,
1012,
2622,
1035,
8909,
1027,
1000,
20369,
27080,
2622,
8909,
1000,
102,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 { useBackend, useSharedState } from '../backend';
import { Box, Button, Dimmer, Icon, LabeledList, Section, Tabs } from '../components';
import { Window } from '../layouts';
export const Limbgrower = (props, context) => {
const { act, data } = useBackend(context);
const {
reagents = [],
total_reagents,
max_reagents,
categories = [],
busy,
} = data;
const [tab, setTab] = useSharedState(
context, 'category', categories[0]?.name);
const designList = categories
.find(category => category.name === tab)
?.designs || [];
return (
<Window
title="Limb Grower"
width={400}
height={550}>
{!!busy && (
<Dimmer fontSize="32px">
<Icon name="cog" spin={1} />
{' Building...'}
</Dimmer>
)}
<Window.Content scrollable>
<Section title="Reagents">
<Box mb={1}>
{total_reagents} / {max_reagents} reagent capacity used.
</Box>
<LabeledList>
{reagents.map(reagent => (
<LabeledList.Item
key={reagent.reagent_name}
label={reagent.reagent_name}
buttons={(
<Button.Confirm
textAlign="center"
width="120px"
content="Remove Reagent"
color="bad"
onClick={() => act('empty_reagent', {
reagent_type: reagent.reagent_type,
})} />
)}>
{reagent.reagent_amount}u
</LabeledList.Item>
))}
</LabeledList>
</Section>
<Section title="Designs">
<Tabs>
{categories.map(category => (
<Tabs.Tab
fluid
key={category.name}
selected={tab === category.name}
onClick={() => setTab(category.name)}>
{category.name}
</Tabs.Tab>
))}
</Tabs>
<LabeledList>
{designList.map(design => (
<LabeledList.Item
key={design.name}
label={design.name}
buttons={(
<Button
content="Make"
color="good"
onClick={() => act('make_limb', {
design_id: design.id,
active_tab: design.parent_category,
})} />
)}>
{design.needed_reagents.map(reagent => (
<Box key={reagent.name}>
{reagent.name}: {reagent.amount}u
</Box>
))}
</LabeledList.Item>
))}
</LabeledList>
</Section>
</Window.Content>
</Window>
);
};
| Bawhoppen/-tg-station | tgui/packages/tgui/interfaces/Limbgrower.js | JavaScript | agpl-3.0 | 2,874 | [
30522,
12324,
1063,
2224,
5963,
10497,
1010,
3594,
8167,
2098,
9153,
2618,
1065,
2013,
1005,
1012,
1012,
1013,
2067,
10497,
1005,
1025,
12324,
1063,
3482,
1010,
6462,
1010,
11737,
5017,
1010,
12696,
1010,
12599,
9863,
1010,
2930,
1010,
2162... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Prajna\Components;
use \Prajna\Traits\XmlRpcHelper;
class Secret
{
use XmlRpcHelper;
protected $session_id;
public function __construct($client){
$this->client = $client;
$this->session_id = $this->client->session_id;
}
public function get_all(){
return $this->doCall('secret.get_all',array(
$this->session_id
));
}
public function get_all_records(){
return $this->doCall('secret.get_all_records',array(
$this->session_id
));
}
public function get_uuid($secret){
return $this->doCall('secret.get_uuid',array(
$this->session_id,
$secret
));
}
public function get_value($secret){
return $this->doCall('secret.get_value',array(
$this->session_id,
$secret
));
}
public function set_value($secret,$value){
return $this->doCall('secret.set_value',array(
$this->session_id,
$secret,
$value
));
}
public function get_other_config($secret){
return $this->doCall('secret.get_other_config',array(
$this->session_id,
$secret
));
}
public function set_other_config($secret,Array $config){
return $this->doCall('secret.set_other_config',array(
$this->session_id,
$secret,
$config
));
}
public function add_to_other_config($secret,$key,$value){
return $this->doCall('secret.add_to_other_config',array(
$this->session_id,
$secret,
$key,
$value
));
}
public function remove_from_other_config($secret,$key){
return $this->doCall('secret.remove_from_other_config',array(
$this->session_id,
$secret,
$key
));
}
public function create($PIF,$args){
return $this->doCall('secret.create',array(
$this->session_id,
$args
));
}
public function destroy($secret){
return $this->doCall('secret.destroy',array(
$this->session_id,
$secret
));
}
public function get_by_uuid($uuid){
return $this->doCall('secret.get_by_uuid',array(
$this->session_id,
$uuid
));
}
public function get_record($secret){
return $this->doCall('secret.get_record',array(
$this->session_id,
$secret
));
}
}
| cameronjacobson/Prajna | src/Prajna/Components/Secret.php | PHP | bsd-2-clause | 2,237 | [
30522,
1026,
1029,
25718,
3415,
15327,
10975,
13006,
2532,
1032,
6177,
1025,
2224,
1032,
10975,
13006,
2532,
1032,
12955,
1032,
20950,
14536,
15721,
4842,
1025,
2465,
3595,
1063,
2224,
20950,
14536,
15721,
4842,
1025,
5123,
1002,
5219,
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... |
function HistoryAssistant() {
}
HistoryAssistant.prototype.setup = function() {
this.appMenuModel = {
visible: true,
items: [
{ label: $L("About"), command: 'about' },
{ label: $L("Help"), command: 'tutorial' },
]
};
this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems: true}, this.appMenuModel);
var attributes = {};
this.model = {
//backgroundImage : 'images/glacier.png',
background: 'black',
onLeftFunction : this.wentLeft.bind(this),
onRightFunction : this.wentRight.bind(this)
}
this.controller.setupWidget('historydiv', attributes, this.model);
this.myPhotoDivElement = $('historydiv');
this.timestamp = new Date().getTime();
var env = Mojo.Environment.DeviceInfo;
if (env.screenHeight <= 400)
this.myPhotoDivElement.style.height = "372px";
}
HistoryAssistant.prototype.wentLeft = function(event){
this.timestamp = this.timestamp - (1000*60*60*24);
var timenow = new Date(this.timestamp);
var timenowstring = "";
var Ayear = timenow.getUTCFullYear();
var Amonth = timenow.getUTCMonth()+1;
if(Amonth.toString().length < 2)
Amonth = "0" + Amonth;
var Aday = timenow.getUTCDate();
if(Aday.toString().length < 2)
Aday = "0" + Aday;
/*var Ahours = timenow.getUTCHours();
if(Ahours.toString().length < 2)
Ahours = "0" + Ahours;*/
Ahours = "00";
if (this.timestamp > 1276146000000) {
if (this.timestamp > 1276146000000 + (1000 * 60 * 60 * 24)) {
this.myPhotoDivElement.mojo.leftUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday - 1) + Ahours + ".png");
}
this.myPhotoDivElement.mojo.centerUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday) + Ahours + ".png");
this.myPhotoDivElement.mojo.rightUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday + 1) + Ahours + ".png");
}
$('text').innerHTML = "<center>Histoy Of Pixels - " + Ayear + " / " + Amonth + " / " + Aday + "</center>";
}
HistoryAssistant.prototype.wentRight = function(event){
this.timestamp = this.timestamp + (1000*60*60*24);
var timenow = new Date(this.timestamp);
var timenowstring = "";
var Ayear = timenow.getUTCFullYear();
var Amonth = timenow.getUTCMonth()+1;
if(Amonth.toString().length < 2)
Amonth = "0" + Amonth;
var Aday = timenow.getUTCDate();
if(Aday.toString().length < 2)
Aday = "0" + Aday;
/*var Ahours = timenow.getUTCHours();
if(Ahours.toString().length < 2)
Ahours = "0" + Ahours;*/
Ahours = "00";
if (this.timestamp < new Date().getTime()) {
this.myPhotoDivElement.mojo.leftUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday - 1) + Ahours + ".png");
this.myPhotoDivElement.mojo.centerUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday) + Ahours + ".png");
if (this.timestamp + (1000*60*60*24) < new Date().getTime()) {
this.myPhotoDivElement.mojo.rightUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday + 1) + Ahours + ".png");
}
}
$('text').innerHTML = "<center>Histoy Of Pixels - " + Ayear + " / " + Amonth + " / " + Aday + "</center>";
}
HistoryAssistant.prototype.activate = function(event) {
var timenow = new Date(this.timestamp);
var timenowstring = "";
var Ayear = timenow.getUTCFullYear();
var Amonth = timenow.getUTCMonth()+1;
if(Amonth.toString().length < 2)
Amonth = "0" + Amonth;
var Aday = timenow.getUTCDate();
if(Aday.toString().length < 2)
Aday = "0" + Aday;
/*var Ahours = timenow.getUTCHours();
if(Ahours.toString().length < 2)
Ahours = "0" + Ahours;*/
Ahours = "00";
this.myPhotoDivElement.mojo.leftUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday-1) + Ahours + ".png");
this.myPhotoDivElement.mojo.centerUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday) + Ahours + ".png");
//this.myPhotoDivElement.mojo.rightUrlProvided("http://100ps.omoco.de/100pixels/history/" + Ayear + Amonth + (Aday+1) + Ahours + ".png");
$('text').innerHTML = "<center>Histoy Of Pixels - " + Ayear + " / " + Amonth + " / " + Aday + "</center>";
}
HistoryAssistant.prototype.deactivate = function(event) {
}
HistoryAssistant.prototype.cleanup = function(event) {
}
HistoryAssistant.prototype.handleCommand = function(event){
if(event.type == Mojo.Event.command) {
switch (event.command) {
case 'about':
Mojo.Controller.stageController.pushScene("about");
break;
case 'tutorial':
this.controller.showAlertDialog({
onChoose: function(value) {},
title:"Help",
message:"This is the history of all pixels user have every created. Every night there is made a new snapshot.<br><br>Flip the image left or right to go through the history. Zoom into the image for more details.",
allowHTMLMessage: true,
choices:[ {label:'OK', value:'OK', type:'color'} ]
});
break;
}
}
} | sebastianha/webos-app_de.omoco.100pixels | app/assistants/history-assistant.js | JavaScript | gpl-3.0 | 4,982 | [
30522,
3853,
2381,
12054,
23137,
2102,
1006,
1007,
1063,
1065,
2381,
12054,
23137,
2102,
1012,
8773,
1012,
16437,
1027,
3853,
1006,
1007,
1063,
2023,
1012,
10439,
3549,
2819,
10244,
2140,
1027,
1063,
5710,
1024,
2995,
30524,
1033,
1065,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE>
<html>
<head>
</head>
<body onload="">
<div id="container">
<h2>Your seat reservations</h2>
<table>
<thead><tr>
<th>Passenger name</th><th>Meal</th><th>Surcharge</th><th></th>
</tr></thead>
<tbody data-bind="foreach: seats">
<tr>
<td data-bind="text: name"></td>
<td data-bind="text: meal().mealName"></td>
<td data-bind="text: meal().price"></td>
</tr>
</tbody>
</table>
</div>
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js'></script>
<script>
// Class to represent a row in the seat reservations grid
function SeatReservation(name, initialMeal) {
var self = this;
self.name = name;
self.meal = ko.observable(initialMeal);
}
// Overall viewmodel for this screen, along with initial state
function ReservationsViewModel() {
var self = this;
// Non-editable catalog data - would come from the server
self.availableMeals = [
{ mealName: "Standard (sandwich)", price: 0 },
{ mealName: "Premium (lobster)", price: 34.95 },
{ mealName: "Ultimate (whole zebra)", price: 290 }
];
// Editable data
self.seats = ko.observableArray([
new SeatReservation("Steve", self.availableMeals[0]),
new SeatReservation("Bert", self.availableMeals[0])
]);
}
ko.applyBindings(new ReservationsViewModel());</script>
</body>
</html> | kgoe/html | archives/knockout/20150427_ko_003.html | HTML | gpl-3.0 | 1,835 | [
30522,
1026,
999,
9986,
13874,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
1013,
2132,
1028,
1026,
2303,
2006,
11066,
1027,
1000,
1000,
1028,
1026,
4487,
2615,
8909,
1027,
1000,
11661,
1000,
1028,
1026,
1044,
2475,
1028,
2115,
2835,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
export * from './results.handler';
| olimungo/planning-poker | src/pages/common/handlers/results-handler/index.ts | TypeScript | gpl-3.0 | 35 | [
30522,
9167,
1008,
2013,
1005,
1012,
1013,
3463,
1012,
28213,
1005,
1025,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.Text;
namespace GuruComponents.Netrix.Events
{
/// <summary>
/// SaveEventArgs provides information about the current save process.
/// </summary>
public class SaveEventArgs : LoadEventArgs
{
/// <summary>
/// Constructor. It's build by Save event handler and not intendet to being called from user's code.
/// </summary>
/// <param name="encoding"></param>
/// <param name="url"></param>
public SaveEventArgs(Encoding encoding, string url) : base(encoding, url)
{
}
/// <summary>
/// Set another encoding temporarily, if used within the <see cref="IHtmlEditor.Saving">Saving</see> event.
/// </summary>
/// <param name="encoding"></param>
public void SetEncoding(Encoding encoding)
{
_encoding = encoding;
}
}
}
| joergkrause/netrix | NetrixPackage/Core/Events/SaveEventArgs.cs | C# | mit | 820 | [
30522,
2478,
2291,
1012,
3793,
1025,
3415,
15327,
11972,
9006,
29513,
7666,
1012,
5658,
17682,
1012,
2824,
1063,
1013,
1013,
1013,
1026,
12654,
1028,
1013,
1013,
1013,
3828,
18697,
12380,
10623,
2015,
3640,
2592,
2055,
1996,
2783,
3828,
283... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 2016, Yahoo Inc.
// Copyrights licensed under the New BSD License.
// See the accompanying LICENSE file for terms.
//
// ## Stability: 0 - Unstable
package github.com.jminusminus.core;
public class Arrays {
// Appends to the given array the given string.
//
// Exmaple:
//
// ```java
// String[] a = new String[]{"a", "b"};
//
// String[] a = Arrays.append(a, "c");
// // returns a,b,c
// ```
public static String[] append(String[] a, String b) {
int len = a.length;
String[] c = new String[len + 1];
System.arraycopy(a, 0, c, 0, a.length);
c[len] = b;
return c;
}
// Appends to the given array the given array.
//
// Exmaple:
//
// ```java
// String[] a = new String[]{"a", "b"};
// String[] a = new String[]{"c", "d"};
//
// String[] a = Arrays.append(a, b);
// // returns a,b,c,d
// ```
public static String[] append(String[] a, String[] b) {
int len = a.length + b.length;
String[] c = new String[len];
System.arraycopy(a, 0, c, 0, a.length);
System.arraycopy(b, 0, c, a.length, b.length);
return c;
}
// Slice the given array upto and including `end`.
//
// Exmaple:
//
// ```java
// String[] a = new String[]{"a", "b", "c", "d"};
//
// String[] s = Arrays.slice(a, 3);
// // returns a,b,c
//
// String[] s = Arrays.slice(a, -2);
// // returns a,b
// ```
public static String[] slice(String[] a, int end) {
if (end < 0) {
end = a.length + end;
}
return Arrays.slice(a, 0, end);
}
// Slice the given array after `start` upto and including `end`.
//
// Exmaple:
//
// ```java
// String[] a = new String[]{"a", "b", "c", "d"};
//
// String[] s = Arrays.slice(a, 0, 4);
// // a,b,c,d
//
// String[] s = Arrays.slice(a, 1, 3);
// // b,c
//
// String[] s = Arrays.slice(a, 1, -1);
// // b,c
// ```
public static String[] slice(String[] a, int start, int end) {
int len = a.length;
if (start > len) {
return new String[0];
}
if (start < 0) {
start = 0;
}
if (end > len) {
end = len - 1;
}
if (end < 0) {
end = a.length + end;
}
String[] b = new String[end - start];
System.arraycopy(a, start, b, 0, b.length);
return b;
}
}
| jminusminus/core | Arrays.java | Java | bsd-3-clause | 2,540 | [
30522,
1013,
1013,
1013,
1013,
9385,
2355,
1010,
20643,
4297,
1012,
1013,
1013,
9385,
2015,
7000,
2104,
1996,
2047,
18667,
2094,
6105,
1012,
1013,
1013,
2156,
1996,
10860,
6105,
5371,
2005,
3408,
1012,
1013,
1013,
1013,
1013,
1001,
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 { connect } from "react-redux"
import { RoadmapPage } from "../components/roadmap-page/roadmap-page"
const getActiveRoadmap = (roadmaps: any[], activeRoadmapId: number) => {
return roadmaps[activeRoadmapId]
}
const mapStateToProps = (state: any, ownProps: any) => {
return {
roadmap: getActiveRoadmap(state.roadmaps, ownProps.params.id)
}
}
export const ActiveRoadmapPage = connect(
mapStateToProps
)(RoadmapPage) | conan007ai/roadmap | client/src/containers/active-roadmap-page.tsx | TypeScript | gpl-3.0 | 447 | [
30522,
12324,
1063,
7532,
1065,
2013,
1000,
10509,
1011,
2417,
5602,
1000,
12324,
1063,
2346,
2863,
13944,
3351,
1065,
2013,
1000,
1012,
1012,
1013,
6177,
1013,
2346,
2863,
2361,
1011,
3931,
1013,
2346,
2863,
2361,
1011,
3931,
1000,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "fixed/impl/basic_allocation_sources.hpp"
#include "fixed/impl/fixed_def.hpp"
#include "fixed/impl/fixed_type_traits.hpp"
#include "catch.hpp"
#include "test_struct.hpp"
TEST_CASE("test fixed allocation_source", "[alloc]")
{
static_assert(fixed::_impl::is_allocation_source<fixed::_impl::empty_source>::value, "empty source is supposed to be allocation_source");
static_assert(fixed::_impl::is_allocation_source_v<fixed::_impl::empty_source>, "empty source is supposed to be allocation_source");
static_assert(!fixed::_impl::is_allocation_source<test>::value, "test is not supposed to be allocation_source");
static_assert(!fixed::_impl::is_allocation_source_v<test>, "test is not supposed to be allocation_source");
}
| Surrog/fixed-container | test/test_alloc_source.cpp | C++ | mit | 737 | [
30522,
1001,
2421,
1000,
4964,
1013,
17727,
2140,
1013,
3937,
1035,
16169,
1035,
4216,
1012,
6522,
2361,
1000,
1001,
2421,
1000,
4964,
1013,
17727,
2140,
1013,
4964,
1035,
13366,
1012,
6522,
2361,
1000,
1001,
2421,
1000,
4964,
1013,
17727,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.1 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2011 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM 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 and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2011
* $Id$
*
*/
require_once 'CRM/Logging/Differ.php';
class CRM_Logging_Reverter
{
private $db;
private $log_conn_id;
private $log_date;
function __construct($log_conn_id, $log_date)
{
$dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
$this->db = $dsn['database'];
$this->log_conn_id = $log_conn_id;
$this->log_date = $log_date;
}
function revert($tables)
{
// FIXME: split off the table → DAO mapping to a GenCode-generated class
$daos = array(
'civicrm_address' => 'CRM_Core_DAO_Address',
'civicrm_contact' => 'CRM_Contact_DAO_Contact',
'civicrm_email' => 'CRM_Core_DAO_Email',
'civicrm_im' => 'CRM_Core_DAO_IM',
'civicrm_openid' => 'CRM_Core_DAO_OpenID',
'civicrm_phone' => 'CRM_Core_DAO_Phone',
'civicrm_website' => 'CRM_Core_DAO_Website',
'civicrm_contribution' => 'CRM_Contribute_DAO_Contribution',
);
// get custom data tables, columns and types
$ctypes = array();
$dao = CRM_Core_DAO::executeQuery('SELECT table_name, column_name, data_type FROM civicrm_custom_group cg JOIN civicrm_custom_field cf ON (cf.custom_group_id = cg.id)');
while ($dao->fetch()) {
if (!isset($ctypes[$dao->table_name])) $ctypes[$dao->table_name] = array('entity_id' => 'Integer');
$ctypes[$dao->table_name][$dao->column_name] = $dao->data_type;
}
$differ = new CRM_Logging_Differ($this->log_conn_id, $this->log_date);
$diffs = $differ->diffsInTables($tables);
$deletes = array();
$reverts = array();
foreach ($diffs as $table => $changes) {
foreach ($changes as $change) {
switch ($change['action']) {
case 'Insert':
if (!isset($deletes[$table])) $deletes[$table] = array();
$deletes[$table][] = $change['id'];
break;
case 'Delete':
case 'Update':
if (!isset($reverts[$table])) $reverts[$table] = array();
if (!isset($reverts[$table][$change['id']])) $reverts[$table][$change['id']] = array('log_action' => $change['action']);
$reverts[$table][$change['id']][$change['field']] = $change['from'];
break;
}
}
}
// revert inserts by deleting
foreach ($deletes as $table => $ids) {
CRM_Core_DAO::executeQuery("DELETE FROM `$table` WHERE id IN (" . implode(', ', array_unique($ids)) . ')');
}
// revert updates by updating to previous values
foreach ($reverts as $table => $row) {
switch (true) {
// DAO-based tables
case in_array($table, array_keys($daos)):
require_once str_replace('_', DIRECTORY_SEPARATOR, $daos[$table]) . '.php';
eval("\$dao = new {$daos[$table]};");
foreach ($row as $id => $changes) {
$dao->id = $id;
foreach ($changes as $field => $value) {
if ($field == 'log_action') continue;
if (empty($value) and $value !== 0 and $value !== '0') $value = 'null';
$dao->$field = $value;
}
$changes['log_action'] == 'Delete' ? $dao->insert() : $dao->update();
$dao->reset();
}
break;
// custom data tables
case in_array($table, array_keys($ctypes)):
foreach ($row as $id => $changes) {
$inserts = array('id' => '%1');
$updates = array();
$params = array(1 => array($id, 'Integer'));
$counter = 2;
foreach ($changes as $field => $value) {
if (!isset($ctypes[$table][$field])) continue; // don’t try reverting a field that’s no longer there
switch ($ctypes[$table][$field]) {
case 'Date':
$value = substr(CRM_Utils_Date::isoToMysql($value), 0, 8);
break;
case 'Timestamp':
$value = CRM_Utils_Date::isoToMysql($value);
break;
}
$inserts[$field] = "%$counter";
$updates[] = "$field = %$counter";
$params[$counter] = array($value, $ctypes[$table][$field]);
$counter++;
}
if ($changes['log_action'] == 'Delete') {
$sql = "INSERT INTO `$table` (" . implode(', ', array_keys($inserts)) . ') VALUES (' . implode(', ', $inserts) . ')';
} else {
$sql = "UPDATE `$table` SET " . implode(', ', $updates) . ' WHERE id = %1';
}
CRM_Core_DAO::executeQuery($sql, $params);
}
break;
}
}
// CRM-7353: if nothing altered civicrm_contact, touch it; this will
// make sure there’s an entry in log_civicrm_contact for this revert
if (empty($diffs['civicrm_contact'])) {
$query = "
SELECT id FROM `{$this->db}`.log_civicrm_contact
WHERE log_conn_id = %1 AND log_date BETWEEN DATE_SUB(%2, INTERVAL 10 SECOND) AND DATE_ADD(%2, INTERVAL 10 SECOND)
ORDER BY log_date DESC LIMIT 1
";
$params = array(
1 => array($this->log_conn_id, 'Integer'),
2 => array($this->log_date, 'String'),
);
$cid = CRM_Core_DAO::singleValueQuery($query, $params);
if (!$cid) return;
require_once 'CRM/Contact/DAO/Contact.php';
$dao = new CRM_Contact_DAO_Contact;
$dao->id = $cid;
if ($dao->find(true)) {
// CRM-8102: MySQL can’t parse its own dates
$dao->birth_date = CRM_Utils_Date::isoToMysql($dao->birth_date);
$dao->deceased_date = CRM_Utils_Date::isoToMysql($dao->deceased_date);
$dao->save();
}
}
}
}
| jblanford/Uber-Web-Site | sites/all/modules/civicrm/CRM/Logging/Reverter.php | PHP | gpl-2.0 | 8,305 | [
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... |
<?php
/****
event.php - Model_Event
-----------
author: Mike Elsmore<mike@elsmore.me>
****/
class Model_Event extends Model_Database {
// Things to make life easier
protected $_table = 'event';
protected $_primary = 'event_id';
} | ukmadlz/ents24-widget | model/event.php | PHP | mit | 235 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1008,
2724,
1012,
25718,
1011,
2944,
1035,
2724,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
3166,
1024,
3505,
3449,
25855,
2890,
1026,
3505,
1030,
3449,
25855,
2890,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 Sample
VERSION = '1.2'
end
| pavolzbell/bump | spec/fixtures/inputs/gem-2-version-numbers.rb | Ruby | mit | 36 | [
30522,
11336,
7099,
2544,
1027,
1005,
1015,
1012,
1016,
1005,
2203,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.kohsuke.github;
import java.io.IOException;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
/**
* Base class for creating or updating a discussion.
*
* @param <S>
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S}
* the same as {@link GHLabel}, this builder will commit changes after each call to
* {@link #with(String, Object)}.
*/
class GHDiscussionBuilder<S> extends AbstractBuilder<GHDiscussion, S> {
private final GHTeam team;
/**
*
* @param intermediateReturnType
* Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If
* {@link S} the same as {@link GHDiscussion}, this builder will commit changes after each call to
* {@link #with(String, Object)}.
* @param team
* the GitHub team. Updates will be sent to the root of this team.
* @param baseInstance
* instance on which to base this builder. If {@code null} a new instance will be created.
*/
protected GHDiscussionBuilder(@Nonnull Class<S> intermediateReturnType,
@Nonnull GHTeam team,
@CheckForNull GHDiscussion baseInstance) {
super(GHDiscussion.class, intermediateReturnType, team.root(), baseInstance);
this.team = team;
if (baseInstance != null) {
requester.with("title", baseInstance.getTitle());
requester.with("body", baseInstance.getBody());
}
}
/**
* Title for this discussion.
*
* @param value
* title of discussion
* @return either a continuing builder or an updated {@link GHDiscussion}
* @throws IOException
* if there is an I/O Exception
*/
@Nonnull
public S title(String value) throws IOException {
return with("title", value);
}
/**
* Body content for this discussion.
*
* @param value
* body of discussion*
* @return either a continuing builder or an updated {@link GHDiscussion}
* @throws IOException
* if there is an I/O Exception
*/
@Nonnull
public S body(String value) throws IOException {
return with("body", value);
}
/**
* {@inheritDoc}
*/
@Nonnull
@Override
public GHDiscussion done() throws IOException {
return super.done().wrapUp(team);
}
}
| kohsuke/github-api | src/main/java/org/kohsuke/github/GHDiscussionBuilder.java | Java | mit | 2,529 | [
30522,
7427,
8917,
1012,
12849,
7898,
15851,
1012,
21025,
2705,
12083,
1025,
12324,
9262,
1012,
22834,
1012,
22834,
10288,
24422,
1025,
12324,
9262,
2595,
1012,
5754,
17287,
3508,
1012,
4638,
29278,
11231,
3363,
1025,
12324,
9262,
2595,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { Factory, faker } from 'ember-cli-mirage';
export default Factory.extend({
survey_type: 'Biological Resources',
duplicator_label: 'Observation(s)',
fully_editable: true,
name() {
return faker.name.jobType();
},
status() {
return faker.list.random('draft', 'active', 'inactive')();
}
});
| kristenhazard/hanuman | frontend/mirage/factories/survey-template.js | JavaScript | mit | 318 | [
30522,
12324,
1063,
4713,
1010,
8275,
2099,
1065,
2013,
1005,
7861,
5677,
1011,
18856,
2072,
1011,
21483,
1005,
1025,
9167,
12398,
4713,
1012,
7949,
1006,
1063,
5002,
1035,
2828,
1024,
1005,
6897,
4219,
1005,
1010,
4241,
24759,
5555,
4263,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 sys
import collections
class GeocoderResult(collections.Iterator):
"""
A geocoder resultset to iterate through address results.
Exemple:
results = Geocoder.geocode('paris, us')
for result in results:
print(result.formatted_address, result.location)
Provide shortcut to ease field retrieval, looking at 'types' in each
'address_components'.
Example:
result.country
result.postal_code
You can also choose a different property to display for each lookup type.
Example:
result.country__short_name
By default, use 'long_name' property of lookup type, so:
result.country
and:
result.country__long_name
are equivalent.
"""
attribute_mapping = {
"state": "administrative_area_level_1",
"province": "administrative_area_level_1",
"city": "locality",
"county": "administrative_area_level_2",
}
def __init__(self, data):
"""
Creates instance of GeocoderResult from the provided JSON data array
"""
self.data = data
self.len = len(self.data)
self.current_index = 0
self.current_data = self.data[0]
def __len__(self):
return self.len
def __iter__(self):
return self
def return_next(self):
if self.current_index >= self.len:
raise StopIteration
self.current_data = self.data[self.current_index]
self.current_index += 1
return self
def __getitem__(self, key):
"""
Accessing GeocoderResult by index will return a GeocoderResult
with just one data entry
"""
return GeocoderResult([self.data[key]])
def __unicode__(self):
return self.formatted_address
if sys.version_info[0] >= 3: # Python 3
def __str__(self):
return self.__unicode__()
def __next__(self):
return self.return_next()
else: # Python 2
def __str__(self):
return self.__unicode__().encode('utf8')
def next(self):
return self.return_next()
@property
def count(self):
return self.len
@property
def coordinates(self):
"""
Return a (latitude, longitude) coordinate pair of the current result
"""
location = self.current_data['geometry']['location']
return location['lat'], location['lng']
@property
def latitude(self):
return self.coordinates[0]
@property
def longitude(self):
return self.coordinates[1]
@property
def raw(self):
"""
Returns the full result set in dictionary format
"""
return self.data
@property
def valid_address(self):
"""
Returns true if queried address is valid street address
"""
return self.current_data['types'] == ['street_address']
@property
def formatted_address(self):
return self.current_data['formatted_address']
def __getattr__(self, name):
lookup = name.split('__')
attribute = lookup[0]
if (attribute in GeocoderResult.attribute_mapping):
attribute = GeocoderResult.attribute_mapping[attribute]
try:
prop = lookup[1]
except IndexError:
prop = 'long_name'
for elem in self.current_data['address_components']:
if attribute in elem['types']:
return elem[prop]
class GeocoderError(Exception):
"""Base class for errors in the :mod:`pygeocoder` module.
Methods of the :class:`Geocoder` raise this when something goes wrong.
"""
#: See http://code.google.com/apis/maps/documentation/geocoding/index.html#StatusCodes
#: for information on the meaning of these status codes.
G_GEO_OK = "OK"
G_GEO_ZERO_RESULTS = "ZERO_RESULTS"
G_GEO_OVER_QUERY_LIMIT = "OVER_QUERY_LIMIT"
G_GEO_REQUEST_DENIED = "REQUEST_DENIED"
G_GEO_MISSING_QUERY = "INVALID_REQUEST"
def __init__(self, status, url=None, response=None):
"""Create an exception with a status and optional full response.
:param status: Either a ``G_GEO_`` code or a string explaining the
exception.
:type status: int or string
:param url: The query URL that resulted in the error, if any.
:type url: string
:param response: The actual response returned from Google, if any.
:type response: dict
"""
Exception.__init__(self, status) # Exception is an old-school class
self.status = status
self.url = url
self.response = response
def __str__(self):
"""Return a string representation of this :exc:`GeocoderError`."""
return 'Error %s\nQuery: %s' % (self.status, self.url)
def __unicode__(self):
"""Return a unicode representation of this :exc:`GeocoderError`."""
return unicode(self.__str__())
| zoeren/pygeocoder | pygeolib.py | Python | bsd-3-clause | 4,972 | [
30522,
12324,
25353,
2015,
12324,
6407,
2465,
20248,
16044,
14343,
23722,
2102,
1006,
6407,
1012,
2009,
6906,
4263,
1007,
1024,
1000,
1000,
1000,
1037,
20248,
16044,
2099,
3463,
3388,
2000,
2009,
22139,
2083,
4769,
3463,
1012,
4654,
6633,
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... |
#ifndef ALIPRIMARYPIONCUTS_H
#define ALIPRIMARYPIONCUTS_H
// Class handling all kinds of selection cuts for primary
// Authors: Svein Lindal, Daniel Lohner *
#include "AliAODpidUtil.h"
#include "AliAODTrack.h"
#include "AliESDtrack.h"
#include "AliVTrack.h"
#include "AliAODTrack.h"
#include "AliMCEvent.h"
#include "AliAnalysisCuts.h"
#include "AliESDtrackCuts.h"
#include "TH1F.h"
class AliESDEvent;
class AliAODEvent;
class AliConversionPhotonBase;
class AliKFVertex;
class AliKFParticle;
class TH1F;
class TH2F;
class AliPIDResponse;
class AliAnalysisCuts;
class iostream;
class TList;
class AliAnalysisManager;
using namespace std;
class AliPrimaryPionCuts : public AliAnalysisCuts {
public:
enum cutIds {
kEtaCut,
kClsITSCut,
kClsTPCCut,
kDCACut,
kPtCut,
kPidedxSigmaITSCut,
kPidedxSigmaTPCCut,
kPiTOFSigmaPID,
kMassCut,
kNCuts
};
enum pionCuts {
kPionIn=0,
kNoTracks,
kTrackCuts,
kdEdxCuts,
kPionOut
};
Bool_t SetCutIds(TString cutString);
Int_t fCuts[kNCuts];
Bool_t SetCut(cutIds cutID, Int_t cut);
Bool_t UpdateCutString();
static const char * fgkCutNames[kNCuts];
Bool_t InitializeCutsFromCutString(const TString analysisCutSelection);
AliPrimaryPionCuts(const char *name="PionCuts", const char * title="Pion Cuts");
virtual ~AliPrimaryPionCuts(); //virtual destructor
virtual Bool_t IsSelected(TObject* /*obj*/){return kTRUE;}
virtual Bool_t IsSelected(TList* /*list*/) {return kTRUE;}
TString GetCutNumber();
// Cut Selection
Bool_t PionIsSelectedMC(Int_t labelParticle,AliMCEvent *mcEvent);
Bool_t TrackIsSelected(AliESDtrack* lTrack);
Bool_t PionIsSelected(AliESDtrack* lTrack);
static AliPrimaryPionCuts * GetStandardCuts2010PbPb();
static AliPrimaryPionCuts * GetStandardCuts2010pp();
Bool_t InitPIDResponse();
void SetPIDResponse(AliPIDResponse * pidResponse) {fPIDResponse = pidResponse;}
AliPIDResponse * GetPIDResponse() { return fPIDResponse;}
void PrintCuts();
void PrintCutsWithValues();
void SetLightOutput( Bool_t flag ){fDoLightOutput = flag; return;}
void InitCutHistograms(TString name="",Bool_t preCut = kTRUE,TString cutName="");
void SetFillCutHistograms(TString name="",Bool_t preCut = kTRUE,TString cutName=""){if(!fHistograms){InitCutHistograms(name,preCut,cutName);};}
TList *GetCutHistograms(){return fHistograms;}
static AliVTrack * GetTrack(AliVEvent * event, Int_t label);
///Cut functions
Bool_t dEdxCuts(AliVTrack * track);
Bool_t SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut);
Bool_t SetITSdEdxCutPionLine(Int_t ededxSigmaCut);
Bool_t SetITSClusterCut(Int_t clsITSCut);
Bool_t SetTPCClusterCut(Int_t clsTPCCut);
Bool_t SetEtaCut(Int_t etaCut);
Bool_t SetPtCut(Int_t ptCut);
Bool_t SetDCACut(Int_t dcaCut);
void SetEtaShift(Double_t etaShift){fEtaShift = etaShift;}
Bool_t SetTOFPionPIDCut(Int_t TOFelectronPID);
Bool_t SetMassCut(Int_t massCut);
Double_t GetMassCut(){return fMassCut;}
// Request Flags
Double_t GetEtaCut(){ return fEtaCut;}
Double_t GetNFindableClustersTPC(AliESDtrack* lTrack);
Bool_t DoWeights(){return fDoWeights;}
Bool_t DoMassCut(){return fDoMassCut;}
protected:
TList *fHistograms;
Bool_t fDoLightOutput; ///< switch for running light output, kFALSE -> normal mode, kTRUE -> light mode
AliPIDResponse *fPIDResponse;
AliESDtrackCuts *fEsdTrackCuts;
Double_t fEtaCut; //eta cutç
Double_t fEtaShift;
Bool_t fDoEtaCut;
Double_t fPtCut;
Double_t fMinClsTPC; // minimum clusters in the TPC
Double_t fChi2PerClsTPC; // maximum Chi2 per cluster in the TPC
Bool_t fRequireTPCRefit; // require a refit in the TPC
Double_t fMinClsTPCToF; // minimum clusters to findable clusters
Bool_t fDodEdxSigmaITSCut; // flag to use the dEdxCut ITS based on sigmas
Bool_t fDodEdxSigmaTPCCut; // flag to use the dEdxCut TPC based on sigmas
Bool_t fDoTOFsigmaCut; // flag to use TOF pid cut RRnewTOF
Double_t fPIDnSigmaAbovePionLineITS; // sigma cut ITS
Double_t fPIDnSigmaBelowPionLineITS; // sigma cut ITS
Double_t fPIDnSigmaAbovePionLineTPC; // sigma cut TPC
Double_t fPIDnSigmaBelowPionLineTPC; // sigma cut TPC
Double_t fPIDnSigmaAbovePionLineTOF; // sigma cut TOF
Double_t fPIDnSigmaBelowPionLineTOF; // sigma cut TOF
Bool_t fUseCorrectedTPCClsInfo; // flag to use corrected tpc cl info
Bool_t fUseTOFpid; // flag to use tof pid
Bool_t fRequireTOF; //flg to analyze only tracks with TOF signal
Bool_t fDoMassCut;
Double_t fMassCut;
Bool_t fDoWeights;
Double_t fMaxDCAToVertexZ;
// Histograms
TObjString *fCutString; // cut number used for analysis
TString fCutStringRead;
TH1F *fHistCutIndex; // bookkeeping for cuts
TH1F *fHistdEdxCuts; // bookkeeping for dEdx cuts
TH2F *fHistITSdEdxbefore; // ITS dEdx before cuts
TH2F *fHistITSdEdxafter;
TH2F *fHistTPCdEdxbefore; // TPC dEdx before cuts
TH2F *fHistTPCdEdxafter; // TPC dEdx after cuts
TH2F *fHistTPCdEdxSignalbefore; //TPC dEdx signal before
TH2F *fHistTPCdEdxSignalafter; //TPC dEdx signal after
TH2F *fHistTOFbefore; // TOF after cuts
TH2F *fHistTOFafter; // TOF after cuts
TH2F *fHistTrackDCAxyPtbefore;
TH2F *fHistTrackDCAxyPtafter;
TH2F *fHistTrackDCAzPtbefore;
TH2F *fHistTrackDCAzPtafter;
TH2F *fHistTrackNFindClsPtTPCbefore;
TH2F *fHistTrackNFindClsPtTPCafter;
TString fStringITSClusterCut;
private:
AliPrimaryPionCuts(const AliPrimaryPionCuts&); // not implemented
AliPrimaryPionCuts& operator=(const AliPrimaryPionCuts&); // not implemented
ClassDef(AliPrimaryPionCuts,6)
};
#endif
| AudreyFrancisco/AliPhysics | PWGGA/GammaConv/AliPrimaryPionCuts.h | C | bsd-3-clause | 5,614 | [
30522,
1001,
2065,
13629,
2546,
4862,
18098,
9581,
2854,
22071,
12273,
16446,
1035,
1044,
1001,
9375,
4862,
18098,
9581,
2854,
22071,
12273,
16446,
1035,
1044,
1013,
1013,
2465,
8304,
2035,
7957,
1997,
4989,
7659,
2005,
3078,
1013,
1013,
60... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
/// <reference path="../../src/bobril.d.ts"/>
/// <reference path="../../src/bobril.mouse.d.ts"/>
module MouseOwnerApp {
var button: IBobrilComponent = {
init(ctx: any, me: IBobrilNode): void {
ctx.backColor = "#f0f0f0";
},
render(ctx: any, me: IBobrilNode): void {
me.tag = "div";
me.style = b.assign({}, ctx.data.style);
me.children = ctx.data.children;
me.style.backgroundColor = ctx.backColor;
},
onMouseDown(ctx: any): boolean {
ctx.backColor = "red";
b.registerMouseOwner(ctx);
b.invalidate(ctx);
return true;
},
onMouseUp(ctx: any): boolean {
ctx.backColor = "#f0f0f0";
if (b.isMouseOwner(ctx)) {
b.releaseMouseOwner();
}
b.invalidate(ctx);
return true;
}
};
function twice(obj: any): any[] { return [obj, b.cloneNode(obj)]; }
b.init(() => {
return twice({
tag: "div",
style: { height: 500, width: 500, border: "solid 1px", position: "relative", cssFloat: "left" },
children: {
component: button, data: {
style: { width: 120, height: 20, position: "absolute", border: "1px solid #000", left: 190, top: 240 },
children: "Click and drag out"
}
}
});
});
}
| klesta490/Bobril | examples/mouseowner/app.ts | TypeScript | mit | 1,468 | [
30522,
1013,
1013,
1013,
1026,
4431,
4130,
1027,
1000,
1012,
1012,
1013,
1012,
1012,
1013,
5034,
2278,
1013,
3960,
15928,
1012,
1040,
1012,
24529,
1000,
1013,
1028,
1013,
1013,
1013,
1026,
4431,
4130,
1027,
1000,
1012,
1012,
1013,
1012,
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... |
[](https://circleci.com/gh/eris-ltd/2gather)
## 2gather -- A Distributed Video Sharing Application
A video sharing DApp (distributed application) which uses smart contracts to structure the application's logic, a distributed file store system to share the content between application users, and BTC to incentivize content creation.
## Introduction
Briefly, (because this is a Readme) there are three major pieces to this application. For a more detailed description of the DApp logic please [see Andreas' blog post on the topic](https://eng.erisindustries.com/tutorials/2015/04/07/2gather/). For a more detailed description of how we operate the blockchain network please [see Casey's blog post on the topic](https://eng.erisindustries.com/blockchains/2015/04/01/peer-server-networks-current-paradigm/).
### Video Files
This DApp makes use of [IPFS](http://ipfs.io) to store, share, and distribute video files. IPFS works on the concept of immutable hashes. These are unstructured data in the form of video files.
### Application Logic
The logic for the application, which remembers and utilizes immutable hashes stored, shared, and distributed by the IPFS protocol, resides in Eris Industries' `erisdb` system, a smart contract enabled, smart contract [controlled blockchain](https://thelonious.io).
### View Layer
The view layer for 2gather is an Angular application which is ran in any compatible web browser. The user interface (aka, view layer) makes JS calls back to the Decerver hosted middlewear layer which provides a routing framework, method framework, and connection to both the `erisdb` and `ipfs` systems.
## State of Development
This DApp is in active development. Here is what we have done and not done.
* ~~contracts suite~~
* ~~deployment controller (.pdx)~~
* ~~api specification~~
* ~~api routing framework~~
* ~~api methods framework~~
* ~~api connections framework~~
* ~~test suite blockchain~~
* ~~continuous integration system~~
* ~~fig files for production~~
* ~~fig files for testing~~
* ~~build prototype view layer~~
* ~~connect prototype view to API endpoints~~
* ~~display BTC addresses for [ProTipHQ](https://www.indiegogo.com/projects/protip-peer-to-peer-tipping-for-the-web) integration~~
* production blockchain
* add a ChangeTip functionality ...?
### Warning
This distributed application (DApp) is ready for wider beta testing.
Please note, however, that the blockchain it uses may have to be reset from time to time. We do not currently have a backup/export/import functionality for smart contract housed information (yet), so at this time when the blockchain resets all videos are lost and will have to be readded.
## Installation
In general there are three ways in which to install the 2gather distributed application, an easy way (which we recommend), a medium way, and a hard way.
### Low Difficulty Installation
**Dependencies**: for the easy installation there are 2 required dependencies: [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/).
Docker is a run anywhere container solution which we feel makes development, deployment, testing, and running of distributed applications a breeze. We are moving most of our development, testing, and usage efforts for Eris Industries to use a container-based paradigm. Given the complexity of getting p2p software running, Docker containers provide an excellent mechanism for handling the building and running of distributed applications.
Docker Compose (recently renamed from the `fig` tool which was purchased by Docker last year) is a way to compose groups of containers and makes running those containers ultra simple. The first time you `docker-compose up` it will take a while to download and configure the base images. After that it will be ultra fast due to Docker's intelligent caching features.
[Install Docker](http://docs.docker.com/installation/). Install instructions will vary by platform. **NOTE** Eris Industries requires a docker version >= 1.4 to work properly. We highly recommend that you install docker version 1.5.
Ubuntu:
```bash
$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh
```
[Install Docker Compose](https://docs.docker.com/compose/#installation-and-set-up):
64 bit Linux && OSX:
```bash
$ curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
```
If you run into problems on linux, execute the `curl` command from a sudo shell.
Make sure Docker is installed properly:
```bash
$ (sudo) docker version
```
Alternatively:
```bash
$ (sudo) pip install -U docker-compose
```
**Go Vroom**: Once you have Docker and Docker-Compose installed the rest is ultra simple.
First clone this repository:
```bash
$ git clone https://github.com/eris-ltd/2gather
$ cd 2gather
```
```bash
$ (sudo) docker-compose -f docker-compose-get.yml up
```
N.B. If you do not have `git` installed and do not want to install it, then you can simply copy and paste the contents of [this file](https://github.com/eris-ltd/2gather/blob/master/docker-compose-get.yml) into a `docker-compose.yml` file in any directory and then start the DApp with:
```bash
$ (sudo) docker-compose up
```
Whichever command sequence you use, you should now have the DApp running in your terminal window. After that simply go to any web browser to [play with 2gather](http://localhost:3000/2gather).
### Medium Difficulty Installation
**Dependencies**: this method requires Docker and Docker-Compose to be installed (please see above for installation instructions). Once those are installed then clone this repository:
```bash
git clone git@github.com:eris-ltd/2gather.git
cd 2gather
```
Next, you'll need to install the front end dependencies. We use the [Bower](http://bower.io/) package manager to manage our front end dependencies. Note that Bower is a [Node.js](https://nodejs.org/) program and Bower depends on Node.
```bash
bower install
```
**Go Vroom**: At this point there are two possible compositions of the containers which you can use. The composition we suggest starting with is the testing containers which will deploy your own chain locally along with all of the contracts required for the DApp and allow you to begin operating the DApp on a local chain.
```bash
(sudo) docker-compose -f spec/docker-compose.yml up
```
The second way you could work is to link into the public testing chain which we use. Note, the production blockchain will be released when we have finalized the testing cycle. See the `Status` section above. To work with the public test chain
```bash
(sudo) docker-compose up
```
Note that depending on your system setup `sudo` command may or may not be necessary.
Note that when using the testing composition with the `-f spec/docker-compose.yml` flag, you will want to wait about 60 seconds after the containers boot before working with the API. This is to allow the chain to be established and the contracts to be deployed.
#### Warning When Using Containers
**NOTE**: When using containers, the keys do not persist. In addition, the usernames are tied to a public key address. So if you use a container and then restart the container you will get a new key so you will have to reregister with a *new* username unless you deleted your old username before exiting the containers before -- as only one username is allowed per chain and each username is tied to a public key address.
The containers are for rapid prototyping and testing and so we do not see this as a problem as it is using containers how they should be used. We are working toward moving keys as close as possible to the user (ideally, in the browser), but that work will be ongoing for quite some time.
If you wish to persist your username then you will have to use the High Difficulty Installation below or export a volume which contains the keys (the latter of which we'd love any bug reports on).
### High Difficulty Installation
While we **highly** encourage folks to begin using a container based system for working with distributed applications, we understand that not everyone will want to do that.
2gather works just as well outside of containers.
#### Step 1: Get the tools
Follow our [Go VROOM Guide Here](https://decerver.io/tutorials/).
Follow IPFS's [Guide Here](https://github.com/ipfs/go-ipfs).
You'll need to install the front end dependencies as well. We use the [Bower](http://bower.io/) package manager to manage our front end dependencies. Note that Bower is a [Node.js](https://nodejs.org/) program and Bower depends on Node.
You will also need the `jq` program installed.
On Ubuntu:
```bash
sudo apt-get install jq
```
On OSX:
```bash
brew install jq
```
For other systems see the [JQ download page](http://stedolan.github.io/jq/download/).
#### Step 2: Install the DApp
Clone this repository into your `~/.decerver/dapps` folder:
```bash
git clone git@github.com:eris-ltd/2gather.git ~/.decerver/dapps/2gather
cd ~/.decerver/dapps/2gather
```
Install the front end dependencies:
```bash
bower install
```
#### Step 3: Start IPFS
Make sure that an IPFS gateway is running and is write accessible on port 8080.
```bash
ipfs daemon -writable
```
Note that IPFS daemon command will block in a terminal, so you will need to run it in a separate terminal window.
#### Step 4a: Roll your own Chain (Optional)
If you would like a chain for testing, then execute the `spec/teststart.sh` file. That will establish a new chain with proper configuration for local testing.
#### Step 4b: Connect to the Public Test Chain (Optional)
If you would like to connect to the public test chain then execute the `./start.sh` file.
### Running the app
When the DApp is running, open [http://localhost:3000/2gather/](http://localhost:3000/2gather/) in a browser.
## License
GPL. See LICENSE.txt file.
## Contributions
We are happy to accept contributions to this template distributed applications with the proviso that any and all contributions will be licensed GPL by Eris Industries.
Even better than contributions to this template, please press the big FORK button at the top and make the DApp your own. Do cool shit with it.
Run it on your own chain. Connect with your own community. And **most importantly** HAVE FUN!
Enjoy DApp-ing! :)
| AronVanAmmers/2gather | README.md | Markdown | gpl-3.0 | 10,431 | [
30522,
1031,
999,
1031,
4418,
25022,
1033,
1006,
16770,
1024,
1013,
1013,
4418,
6895,
1012,
4012,
1013,
1043,
2232,
1013,
9413,
2483,
1011,
5183,
1013,
1016,
20697,
5886,
1012,
17917,
2290,
1029,
2806,
1027,
17917,
2290,
1007,
1033,
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 XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>LCD I2C: I2CLCD-mkjdz.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">LCD I2C
 <span id="projectnumber">V004</span>
</div>
<div id="projectbrief">This is the project synopsis</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_ef17207d069a71f169fdde842b8bccd0.html">SOFTWARE</a></li><li class="navelem"><a class="el" href="dir_a89ded6bd3a15fff6c0452f4f60ad0ac.html">BOOSTC</a></li><li class="navelem"><a class="el" href="dir_b63de4a40dd7f8ea4d5abf4a63b4b013.html">PIC12F683</a></li><li class="navelem"><a class="el" href="dir_aea64c4aecdbfe3d5c0a0a33fec8ebeb.html">INC</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">I2CLCD-mkjdz.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="_i2_c_l_c_d-mkjdz_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="preprocessor">#ifndef __I2CLCD_MKJDZ_H__</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="preprocessor"></span><span class="preprocessor">#define __I2CLCD_MKJDZ_H__</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="preprocessor"></span></div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="preprocessor">#include <system.h></span></div>
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="preprocessor">#include "i2c.h"</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> </div>
<div class="line"><a name="l00007"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#ab86126dc606c0ccfda0aadc00cef0b96"> 7</a></span> <span class="preprocessor">#define DIN 1</span></div>
<div class="line"><a name="l00008"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a0b93cd51079c0fa8e21ee4faf2da1a27"> 8</a></span> <span class="preprocessor"></span><span class="preprocessor">#define DOUT 0</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="preprocessor"></span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment">// I2C address of the PCF8574 on the mkjdz board.</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment">// This is hard wired. PCB tracks will need to be cut</span></div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">// and jumpered to change I2C address.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> </div>
<div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a999a63fa69161b7804561f9c5b65d5ae"> 14</a></span> <span class="preprocessor">#define I2C_LCD_ADDR 0b01000000 //PCF8574</span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="preprocessor"></span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment">// How the mkjdz board connects the PCF8754 to the LCD P0 - P7 are PCF8754 I/O bit Nos</span></div>
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">// refer datasheet for pin Nos.</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> </div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#ad56db5f232729525befc45c92ca24a55"> 19</a></span> <span class="preprocessor">#define I2C_LCD_BL 7 // Backlight - P7</span></div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a5f08cf7e1d45f6b1137270bdc6411137"> 20</a></span> <span class="preprocessor"></span><span class="preprocessor">#define I2C_LCD_RS 6 // RS - P6 Register select. 0 = cmd write 1 = data write</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a762b2f505fc185452ae0aa956a922935"> 21</a></span> <span class="preprocessor"></span><span class="preprocessor">#define I2C_LCD_RW 5 // RW - P5 Read/Write 0 = write to display 1 = read from display</span></div>
<div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a6c39378be76c041f2b1975baf1eb8f76"> 22</a></span> <span class="preprocessor"></span><span class="preprocessor">#define I2C_LCD_EN 4 // EN - P4 Enable</span></div>
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor"></span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment">// LCD is run in 4 bit mode</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  </div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a2caf763b95853fd6f72160cab86a0231"> 26</a></span> <span class="preprocessor">#define I2C_LCD_D7 3 // D7 - P3 LCD Data bit 7</span></div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#aacb318f58995032c7460c2958a11383b"> 27</a></span> <span class="preprocessor"></span><span class="preprocessor">#define I2C_LCD_D6 2 // D6 - P2 LCD Data bit 6</span></div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a6e8cd3aeb8cb5a16066eedeb8b227255"> 28</a></span> <span class="preprocessor"></span><span class="preprocessor">#define I2C_LCD_D5 1 // D5 - P1 LCD Data bit 5</span></div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#abad718e229ce6cdb9681a741946d45a8"> 29</a></span> <span class="preprocessor"></span><span class="preprocessor">#define I2C_LCD_D4 0 // D4 - P0 LCD Data bit 4</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="preprocessor"></span></div>
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span> </div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#a0a5ceb9ceb914e08d345410b561cb37a"> 32</a></span> <span class="preprocessor">#define CMD 0x10 // for mkjdz board was 0x20</span></div>
<div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="_i2_c_l_c_d-mkjdz_8h.html#aad9ae913bdfab20dd94ad04ee2d5b045"> 33</a></span> <span class="preprocessor"></span><span class="preprocessor">#define DATA 0x50 // for mkjdz board was 0x30</span></div>
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor"></span></div>
<div class="line"><a name="l00035"></a><span class="lineno"> 35</span> <span class="comment">/*</span></div>
<div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="comment"></span></div>
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment">#define I2C_LCD_LINES 2</span></div>
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="comment">#define I2C_LCD_CHARS 16</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span> <span class="comment">#define I2C_LCD_EDELAY 10 //was 40</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span> <span class="comment"></span></div>
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="comment"></span></div>
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span> <span class="comment">#define I2C_LCD_CLEAR 0x01 // Clear Display</span></div>
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span> <span class="comment">#define I2C_LCD_HOME 0x02 // Cursor to Home position</span></div>
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> <span class="comment">#define I2C_LCD_CUR_ON 0x0E // Switch Cursor ON</span></div>
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span> <span class="comment">#define I2C_LCD_CUR_OFF 0x0C // Switch Cursor OFF</span></div>
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span> <span class="comment">#define I2C_LCD_CUR_BLINK 0x0F // Cursor plus blink</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="comment"></span></div>
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="comment">#define I2C_LCD_DISP_ON 0x0C // Display ON - 2 line mode</span></div>
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span> <span class="comment">#define I2C_LCD_DISP_OFF 0x08 // Display off</span></div>
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span> <span class="comment">#define I2C_LCD_LINE1 0x80 // Line 1 position 1</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span> <span class="comment">#define I2C_LCD_LINE2 0xC0 // Line 2 position 1</span></div>
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span> <span class="comment"></span></div>
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span> <span class="comment">#define set_dd_ram 0x80 // Line 1 position 1</span></div>
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span> <span class="comment">#define cursor_shift_right 0x14 // Move cursor right</span></div>
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span> <span class="comment">#define cursor_shift_left 0x10 // Move cursor left</span></div>
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="comment">#define display_shift_right 0x1C // Scroll display right</span></div>
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span> <span class="comment">#define display_shift_left 0x18 // Scroll display left</span></div>
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span> <span class="comment"></span></div>
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="comment"></span></div>
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="comment"></span></div>
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="comment">#define LCD_cmd(cbyte) (LCD_wbyte((cbyte),(CMD)))</span></div>
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="comment">#define LCD_data(cbyte) (LCD_wbyte((cbyte),(DATA)))</span></div>
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="comment"></span></div>
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span> <span class="comment"></span></div>
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="comment">void i2c_lcd_strobe(char lbyte);</span></div>
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span> <span class="comment">void i2c_lcd_wbyte(char lbyte,char act);</span></div>
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="comment">void i2c_lcd_init(void);</span></div>
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="comment">void i2c_lcd_printf(const char* text);</span></div>
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span> <span class="comment">void i2c_lcd_printb(char* lbuff);</span></div>
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="comment">void i2c_lcd_printn(long lnum,char cnum,char dp,char x,char y);</span></div>
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="comment">*/</span></div>
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div>
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span> <span class="preprocessor">#endif //__I2CLCD_MKJDZ_H__</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Dec 11 2013 15:05:56 for LCD I2C by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
| peterjwilliamson/PIC-12F1840-TOOLS | 001-Bootloader/DOCS/html/_i2_c_l_c_d-mkjdz_8h_source.html | HTML | bsd-3-clause | 17,041 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 "msm_fb.h"
#include "mipi_dsi.h"
#include "mipi_himax.h"
#include <linux/gpio.h>
static struct msm_panel_info pinfo;
#define DSI_BIT_CLK_406MHZ
static struct mipi_dsi_phy_ctrl dsi_video_mode_phy_db = {
/* 480*800, RGB888, 2 Lane 65 fps cmd mode */
#if defined(DSI_BIT_CLK_337MHZ)
/* regulator */
{0x03, 0x0a, 0x04, 0x00, 0x20}, /* Fixed values */
/* timing */
{0x66, 0x26, 0x15, 0x00, 0x17, 0x8C, 0x1E, 0x8B,
0x17, 0x03, 0x04, 0xa0},
/* phy ctrl */
{0x5f, 0x00, 0x00, 0x10}, /* Fixed values */
/* strength */
{0xff, 0x00, 0x06, 0x00}, /* Fixed values */
/* pll control */
{0x00, 0x50, 0x01, 0x1a, 0x00, 0x50, 0x48, 0x63,
0x41, 0x0f, 0x03, 0x00, 0x14, 0x03, 0x00, 0x02,
0x00, 0x20, 0x00, 0x01 },
#elif defined(DSI_BIT_CLK_325MHZ)
/* regulator */
{0x03, 0x0A, 0x04, 0x00, 0x20}, /* Fixed values */
/* timing */
{0x66, 0x26, 0x16, 0x00, 0x18, 0x8D, 0x1E, 0x8C,
0x18, 0x03, 0x04, 0xA0},
/* phy ctrl */
{0x5F, 0x00, 0x00, 0x10}, /* Fixed values */
/* strength */
{0xFF, 0x00, 0x06, 0x00}, /* Fixed values */
/* pll control */
{0x00, 0x5E, 0x01, 0x1A, 0x00, 0x50, 0x48, 0x63,
0x41, 0x0F, 0x03, 0x00, 0x14, 0x03, 0x00, 0x02,
0x00, 0x20, 0x00, 0x01 },
#elif defined(DSI_BIT_CLK_349MHZ)
/* regulator */
{0x03, 0x0A, 0x04, 0x00, 0x20}, /* Fixed values */
/* timing */
{0x66, 0x26, 0x16, 0x00, 0x18, 0x8D, 0x1E, 0x8B,
0x18, 0x03, 0x04, 0xA0},
/* phy ctrl */
{0x5F, 0x00, 0x00, 0x10}, /* Fixed values */
/* strength */
{0xFF, 0x00, 0x06, 0x00}, /* Fixed values */
/* pll control */
{0x00, 0xF9, 0xB0, 0xDA, 0x00, 0x50, 0x48, 0x63,
0x41, 0x0F, 0x03, 0x00, 0x14, 0x03, 0x00, 0x02,
0x00, 0x20, 0x00, 0x01 },
#elif defined(DSI_BIT_CLK_406MHZ)
#if defined(CONFIG_FB_MSM_MIPI_DSI_HIMAX) && !defined(CONFIG_MACH_LGE_FX3_VZW) && !defined(CONFIG_MACH_LGE_FX3Q_TMUS)
/* regulator */
{0x03, 0x0A, 0x04, 0x00, 0x20}, /* Fixed values */
/* timing */
{0x75, 0x2F, 0x11, 0x00, 0x3D, 0x44, 0x15, 0x32,
0x1D, 0x03, 0x04, 0xA0},
/* phy ctrl */
{0x5F, 0x00, 0x00, 0x10}, /* Fixed values */
/* strength */
{0xFF, 0x00, 0x06, 0x00}, /* Fixed values */
/* pll control */
{0x00, 0xF9, 0xB0, 0xDA, 0x00, 0x50, 0x48, 0x63,
0x41, 0x0F, 0x03, 0x00, 0x14, 0x03, 0x00, 0x02,
0x00, 0x20, 0x00, 0x01 },
#else
/* regulator */
{0x03, 0x0A, 0x04, 0x00, 0x20}, /* Fixed values */
/* timing */
{0x66, 0x26, 0x1A, 0x00, 0x1D, 0x91, 0x1E, 0x8D,
0x1D, 0x03, 0x04, 0xA0},
/* phy ctrl */
{0x5F, 0x00, 0x00, 0x10}, /* Fixed values */
/* strength */
{0xFF, 0x00, 0x06, 0x00}, /* Fixed values */
/* pll control */
{0x00, 0xF9, 0xB0, 0xDA, 0x00, 0x50, 0x48, 0x63,
0x41, 0x0F, 0x03, 0x00, 0x14, 0x03, 0x00, 0x02,
0x00, 0x20, 0x00, 0x01 },
#endif
#endif
};
static int __init mipi_video_himax_h8379a_wvga_pt_init(void)
{
int ret;
#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
if (msm_fb_detect_client("mipi_video_himax_hd"))
return 0;
#endif
pinfo.xres = 480;
pinfo.yres = 800;
pinfo.type = MIPI_VIDEO_PANEL;
pinfo.pdest = DISPLAY_1;
pinfo.wait_cycle = 0;
pinfo.bpp = 24;
/* QCT Limitation :
* All proch values must be a multiple of 4. 2011.01.20 */
#if defined(DSI_BIT_CLK_337MHZ)
pinfo.lcdc.h_back_porch = 20;
pinfo.lcdc.h_front_porch = 16;
pinfo.lcdc.h_pulse_width = 4;
pinfo.lcdc.v_back_porch = 22;
pinfo.lcdc.v_front_porch = 8;
pinfo.lcdc.v_pulse_width = 1;
#elif defined(DSI_BIT_CLK_325MHZ)
pinfo.lcdc.h_back_porch = 42;
pinfo.lcdc.h_front_porch = 56;
pinfo.lcdc.h_pulse_width = 20;
pinfo.lcdc.v_back_porch = 7;
pinfo.lcdc.v_front_porch = 8;
pinfo.lcdc.v_pulse_width = 1;
#elif defined(DSI_BIT_CLK_349MHZ)
pinfo.lcdc.h_back_porch = 42;
pinfo.lcdc.h_front_porch = 56;
pinfo.lcdc.h_pulse_width = 16;
pinfo.lcdc.v_back_porch = 7;
pinfo.lcdc.v_front_porch = 8;
pinfo.lcdc.v_pulse_width = 1;
#elif defined(DSI_BIT_CLK_406MHZ)
{
int lcd_maker_id = 0;
lcd_maker_id = gpio_get_value_cansleep(89);
if(lcd_maker_id) //Tovis LCD
{
pinfo.lcdc.h_back_porch = 64;
pinfo.lcdc.h_front_porch = 136;
pinfo.lcdc.h_pulse_width = 4;
pinfo.lcdc.v_back_porch = 11;
pinfo.lcdc.v_front_porch = 13;
pinfo.lcdc.v_pulse_width = 2;
}
else //LGD
{
pinfo.lcdc.h_back_porch = 64;
pinfo.lcdc.h_front_porch = 144;
pinfo.lcdc.h_pulse_width = 4;
pinfo.lcdc.v_back_porch = 5;
pinfo.lcdc.v_front_porch = 8;
pinfo.lcdc.v_pulse_width = 2;
}
}
#endif
pinfo.lcdc.border_clr = 0; /* blk */
pinfo.lcdc.underflow_clr = 0xff; /* blue */
pinfo.lcdc.hsync_skew = 0;
#ifdef CONFIG_LGE_BACKLIGHT_LM3533
pinfo.bl_max = 0xFF;
pinfo.bl_min = 0;
#else
pinfo.bl_max = 0xFF;
#ifdef CONFIG_MACH_MSM8960_L2S
pinfo.bl_default = 0x28;
#endif
pinfo.bl_min = 1;
#endif
pinfo.fb_num = 2;
pinfo.mipi.mode = DSI_VIDEO_MODE;
pinfo.mipi.pulse_mode_hsa_he = FALSE;
pinfo.mipi.hfp_power_stop = TRUE;
pinfo.mipi.hbp_power_stop = TRUE;
pinfo.mipi.hsa_power_stop = TRUE;
pinfo.mipi.eof_bllp_power_stop = TRUE;
pinfo.mipi.bllp_power_stop = TRUE;
pinfo.mipi.traffic_mode = DSI_NON_BURST_SYNCH_EVENT;
pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
pinfo.mipi.vc = 0;
pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB;
pinfo.mipi.data_lane0 = TRUE;
pinfo.mipi.data_lane1 = TRUE;
pinfo.mipi.dlane_swap = 0x01;
#if defined(DSI_BIT_CLK_337MHZ)
pinfo.mipi.t_clk_post = 0x22;
pinfo.mipi.t_clk_pre = 0x33;
pinfo.clk_rate = 337000000;
pinfo.mipi.frame_rate = 65;
#elif defined(DSI_BIT_CLK_325MHZ)
pinfo.mipi.t_clk_post = 0x22;
pinfo.mipi.t_clk_pre = 0x34;
pinfo.clk_rate = 351340000;
pinfo.mipi.frame_rate = 60;
#elif defined(DSI_BIT_CLK_349MHZ)
pinfo.mipi.t_clk_post = 0x22;
pinfo.mipi.t_clk_pre = 0x34;
pinfo.clk_rate = 348990000;
pinfo.mipi.frame_rate = 60;
#elif defined(DSI_BIT_CLK_406MHZ)
pinfo.mipi.t_clk_post = 0x22;
pinfo.mipi.t_clk_pre = 0x35;
pinfo.clk_rate = 406560000;
pinfo.mipi.frame_rate = 60;
#endif
pinfo.mipi.stream = 0; /* dma_p */
pinfo.mipi.mdp_trigger = 0;/* DSI_CMD_TRIGGER_SW; */
pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW;
pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db;
ret = mipi_himax_device_register(&pinfo, MIPI_DSI_PRIM,
MIPI_DSI_PANEL_WVGA_PT);
if (ret)
printk(KERN_ERR "%s: failed to register device!\n", __func__);
return ret;
}
module_init(mipi_video_himax_h8379a_wvga_pt_init);
| playfulgod/kernel_lge_fx3 | drivers/video/msm/mipi_himax_h8379a_video_wvga_pt.c | C | gpl-2.0 | 6,936 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2268,
1011,
2230,
1010,
3642,
13158,
7057,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>The Xavante Lua Web Server Manual</title>
<link rel="stylesheet" href="doc.css" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="container">
<div id="product">
<div id="product_logo"><a href="http://www.keplerproject.org">
<img alt="Xavante logo" src="xavante.gif" width="128" height="128"/></a>
</div>
<div id="product_name"><big><strong>Xavante</strong></big></div>
<div id="product_description">A Lua Web Server with WSAPI support</div>
</div> <!-- id="product" -->
<div id="main">
<div id="navigation">
<h1>Xavante</h1>
<ul>
<li><a href="index.html">Home</a>
<ul>
<li><a href="index.html#over">Overview</a></li>
<li><a href="index.html#status">Status</a></li>
<li><a href="index.html#download">Download</a></li>
<li><a href="index.html#dependencies">Dependencies</a></li>
<li><a href="index.html#history">History</a></li>
<li><a href="index.html#credits">Credits</a></li>
<li><a href="index.html#contact">Contact us</a></li>
</ul>
</li>
<li><strong>Manual</strong>
<ul>
<li><a href="manual.html#install">Installing</a></li>
<li><a href="manual.html#config">Configuring</a></li>
<li><a href="manual.html#running">Running</a></li>
</ul>
</li>
<li><a href="sajax.html">Sajax</a></li>
<li><a href="http://luaforge.net/projects/xavante/">Project</a>
<ul>
<li><a href="http://luaforge.net/tracker/?group_id=6">Bug Tracker</a></li>
<li><a href="http://luaforge.net/scm/?group_id=6">CVS</a></li>
</ul>
</li>
<li><a href="license.html">License</a></li>
</ul>
</div> <!-- id="navigation" -->
<div id="content">
<h2><a name="install"></a>Installing</h2>
<p>You can install Xavante using <a href="http://www.luarocks.org">LuaRocks</a>:</p>
<pre class="example">
luarocks install xavante
</pre>
<p>The "xavante" package installs Xavante as a library. To run Xavante as an application please install <a href="http://wsapi.luaforge.net">WSAPI</a>:</p>
<pre class="example">
luarocks install wsapi-xavante
</pre>
<h2><a name="config"></a>Configuring</h2>
<p>
After the Xavante module is loaded, it needs to be configured before
being able to serve requests. You need to register the handlers
using the <code>xavante.HTTP</code> constructor.
</p>
<p>
<code>xavante.HTTP</code> defines <em>virtualhosts</em> for each site
that will be served. Each virtualhost can define a set of <em>rules</em>
for it.
Each rule matches a <em>URL Lua pattern</em> with a handler.
Xavante currently offers a <strong>file handler</strong>,
a <strong>redirect handler</strong> and
a <strong>CGILua handler</strong> for general files, URL
remapping and CGILua scripts respectively.
</p>
<p>A typical use would be:</p>
<pre class="example">
local hfile = require "xavante.filehandler"
local hcgi = require "xavante.cgiluahandler"
local hredir = require "xavante.redirecthandler"
local xavante = require "xavante"
-- Define here where Xavante HTTP documents scripts are located
local webDir = XAVANTE_WEB
local simplerules = {
{ -- URI remapping example
match = "^[^%./]*/$",
with = hredir,
params = {"index.lp"}
},
{ -- cgiluahandler example
match = {"%.lp$", "%.lp/.*$", "%.lua$", "%.lua/.*$" },
with = hcgi.makeHandler (webDir)
},
{ -- filehandler example
match = ".",
with = hfile,
params = {baseDir = webDir}
},
}
xavante.HTTP{
server = {host = "*", port = 8080},
defaultHost = {
rules = simplerules
},
}
</pre>
<p>Note the use of <code>webDir</code> both to set the base directory
for the file handler and for the CGILua scripts. These paths should contain the
desired directories in your structure.</p>
<p>To use virtual hosts with Xavante, the call to <code>xavante.HTTP</code>
would be changed to something like</p>
<pre class="example">
xavante.HTTP{
server = {host = "*", port = 8080},
defaultHost = {},
virtualhosts = {
["www.sitename.com"] = simplerules
}
}
</pre>
<h2><a name="running"></a>Running</h2>
<p>
If you are using Xavante as a module, then to start it you need to call
<code>xavante.start([checkfunction[, timeout]])</code> passing an optional
checking function and connection timeout value. The checking function, if
present, will be called periodically to check if Xavante should continue to
run. This function can be also used for maintenance tasks or as a callback to
your application.
</p>
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<p><a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.0!</a></p>
<p><small>$Id: manual.html,v 1.46 2008/05/23 20:18:58 carregal Exp $</small></p>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
| arventwei/WioEngine | Tools/jamplus/src/luaplus/Src/Modules/xavante/doc/us/manual.html | HTML | mit | 5,232 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
11039,
19968,
1015,
1012,
1014,
9384,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* 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.camel.impl;
import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
/**
* @version $Revision$
*/
public class DefaultCamelContextAutoStartupTest extends TestSupport {
public void testAutoStartupFalse() throws Exception {
DefaultCamelContext camel = new DefaultCamelContext(new SimpleRegistry());
camel.disableJMX();
camel.setAutoStartup(false);
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").routeId("foo").to("mock:result");
}
});
camel.start();
assertEquals(true, camel.isStarted());
assertEquals(1, camel.getRoutes().size());
assertEquals(true, camel.getRouteStatus("foo").isStopped());
// now start the routes
camel.startRoute("foo");
assertEquals(true, camel.getRouteStatus("foo").isStarted());
// and now its started we can test that it works by sending in a message to the route
MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
camel.createProducerTemplate().sendBody("direct:start", "Hello World");
mock.assertIsSatisfied();
camel.stop();
}
public void testAutoStartupTrue() throws Exception {
DefaultCamelContext camel = new DefaultCamelContext(new SimpleRegistry());
camel.disableJMX();
camel.setAutoStartup(true);
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").routeId("foo").to("mock:result");
}
});
camel.start();
assertEquals(true, camel.isStarted());
assertEquals(1, camel.getRoutes().size());
assertEquals(true, camel.getRouteStatus("foo").isStarted());
MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
camel.createProducerTemplate().sendBody("direct:start", "Hello World");
mock.assertIsSatisfied();
camel.stop();
}
}
| kingargyle/turmeric-bot | camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextAutoStartupTest.java | Java | apache-2.0 | 3,088 | [
30522,
1013,
1008,
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,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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) 2014 Jolla Ltd, author: <robin.burchell@jollamobile.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <systemd/sd-journal.h>
#include <syslog.h>
int main(int argc, char **argv)
{
sd_journal_send("MESSAGE=%s", "test message",
"PRIORITY=%i", LOG_INFO,
"CODE_FUNC=%s", "unknown",
"CODE_LINE=%d", 0,
"CODE_FILE=%s", "foo.c",
NULL);
return 0;
}
| geminy/aidear | oss/qt/qt-everywhere-opensource-src-5.9.0/qtbase/config.tests/unix/journald/journald.c | C | gpl-3.0 | 2,321 | [
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... |
package Eac.event;
import Eac.Eac;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.item.ItemStack;
public class EacOnItemPickup extends Eac {
@SubscribeEvent
public void EacOnItemPickup(PlayerEvent.ItemPickupEvent e) {
if (e.pickedUp.getEntityItem().isItemEqual(new ItemStack(oreAir))) {
e.player.addStat(airoremined, 1);
}
else if (e.pickedUp.getEntityItem().isItemEqual(new ItemStack(oreShadow))) {
e.player.addStat(shadoworemined, 1);
}
}
}
| EacMods/Eac | src/main/java/Eac/event/EacOnItemPickup.java | Java | gpl-3.0 | 596 | [
30522,
7427,
19413,
2278,
1012,
2724,
1025,
12324,
19413,
2278,
1012,
19413,
2278,
1025,
12324,
18133,
2860,
1012,
16913,
2015,
1012,
4718,
2140,
1012,
2691,
1012,
2724,
11774,
3917,
1012,
4942,
29234,
18697,
3372,
1025,
12324,
18133,
2860,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 UnityEngine;
using System.Collections;
namespace MagicalFX
{
public class FX_SpawnDirection : MonoBehaviour
{
public int Number = 10;
public float Frequency = 1;
public bool FixRotation = false;
public bool Normal;
public GameObject FXSpawn;
public float LifeTime = 0;
public float TimeSpawn = 0;
private float timeTemp;
public bool UseObjectForward = true;
public Vector3 Direction = Vector3.forward;
void Start ()
{
counter = 0;
timeTemp = Time.time;
if (TimeSpawn <= 0) {
for (int i=0; i<Number-1; i++) {
if (UseObjectForward) {
Direction = this.transform.forward;
}
Spawn (this.transform.position + (Direction * Frequency * i));
}
Destroy(this.gameObject);
}
}
private int counter = 0;
void Update ()
{
if(counter >= Number-1)
Destroy(this.gameObject);
if (TimeSpawn > 0.0f) {
if (Time.time > timeTemp + TimeSpawn) {
if (UseObjectForward) {
Direction = this.transform.forward;
}
Spawn (this.transform.position + (Direction * Frequency * counter));
counter+=1;
timeTemp = Time.time;
}
}
}
void Spawn (Vector3 position)
{
if (FXSpawn != null) {
Quaternion rotate = this.transform.rotation;
if (!FixRotation)
rotate = FXSpawn.transform.rotation;
GameObject fx = (GameObject)GameObject.Instantiate (FXSpawn, position, rotate);
if (Normal)
fx.transform.forward = this.transform.forward;
if (LifeTime > 0)
GameObject.Destroy (fx.gameObject, LifeTime);
}
}
}
}
| yimogod/boom | trunk/effect/Assets/Magical/Sources/Scripts/FX_SpawnDirection.cs | C# | apache-2.0 | 1,578 | [
30522,
2478,
8499,
13159,
3170,
1025,
2478,
2291,
1012,
6407,
1025,
3415,
15327,
8687,
2546,
2595,
1063,
2270,
2465,
23292,
1035,
25645,
4305,
2890,
7542,
1024,
18847,
4783,
3270,
25500,
3126,
1063,
2270,
20014,
2193,
1027,
2184,
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... |
#include <stdio.h>
#define _gc() getchar_unlocked()
#define _pc(x) putchar_unlocked(x)
#define NL() putchar_unlocked('\n')
#define SS(x) scanf("%s",&x)
#define PS(x) printf("%s",x)
#define SC(x) scanf("%c",&x)
#define PC(x) scanf("%c",x)
typedef long long int I;
inline I getint(){I x=0,c=_gc();while(!(c>='0'&&c<='9')){c=_gc();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c-'0');c=_gc();}return x;}
inline void putint(I n){I N=n,r=n,c=0;if(N==0){_pc('0');return;}while(r%10==0){c++;r/=10;}r=0;while(N!=0){r=(r<<3)+(r<<1)+N%10;N/=10;}while(r!=0){_pc(r%10+'0');r/=10;}while(c--){_pc('0');}}
int main(){
return 0;
} | Eden55555/code-in-c-language | codesnippet/C.c | C | mit | 613 | [
30522,
1001,
2421,
1026,
2358,
20617,
1012,
1044,
1028,
1001,
9375,
1035,
1043,
2278,
1006,
1007,
2131,
7507,
2099,
1035,
14058,
1006,
1007,
1001,
9375,
1035,
7473,
1006,
1060,
1007,
2404,
7507,
2099,
1035,
14058,
1006,
1060,
1007,
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... |
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
namespace NUnitTestExamples
{
[TestFixture]
public class UnitTest1
{
[Test]
[ExpectedException(typeof(InvalidDataException), ExpectedMessage = "hey!")]
public void TestMethod1()
{
new MyClass().Foo();
}
}
public class MyClass
{
public void Foo()
{
throw new InvalidDataException("hey!");
}
}
}
| VioletTape/Trainings | NET-008_UnitTestsCustomized/ExpectedExceptionFail/NUnitTestExamples/Class1.cs | C# | gpl-2.0 | 600 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
22834,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
3793,
1025,
2478,
2291,
1012,
11689,
2075,
1012,
8518,
1025,
2478,
16634,
4183,
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... |
/*
* Author: patiphat mana-u-krid (dew)
* E-Mail: dewtx29@gmail.com
* facebook: https://www.facebook.com/dewddminecraft
*/
package dewddgetaway;
import java.util.Random;
import java.util.Stack;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class dewgetaway2 implements Listener {
class chatx implements Runnable {
Player p = null;
String message = "";
public void run() {
String m[] = message.split("\\s+");
if (m[0].equalsIgnoreCase("/dewgetawayrun")) {
staticarea.dslb.loaddewsetlistblockfile();
isruntick = !isruntick;
dprint.r.printAll("isruntick = " + Boolean.toString(isruntick));
getawayticktock time = new getawayticktock();
time.setName("getaway");
time.start();
return;
}
if (m[0].equalsIgnoreCase("/dewgetaway")) {
if (m.length == 1) { // it's mean toggle your self
if (p.hasPermission(pgetaway) == false) {
p.sendMessage("you don't have permission " + pgetaway);
return;
}
int getid = getfreeselect(p.getName());
nn.isrun[getid] = !nn.isrun[getid];
p.sendMessage(nn.playername[getid] + " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
}
else if (m.length == 2) { // it's mean have player name
if (p.hasPermission(pgetaway) == false) {
p.sendMessage("you don't have permission " + pgetaway);
return;
}
if (m[1].equalsIgnoreCase(p.getName()) == false) {
if (p.hasPermission(pgetawayother) == false) {
p.sendMessage("you don't have permission "
+ pgetaway);
return;
}
}
if (m[1].equalsIgnoreCase("@a") == true) {
// it's mean toggle everyone
for (Player p2 : Bukkit.getOnlinePlayers()) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = !nn.isrun[getid];
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
}
}
else {
// find that player
for (Player p2 : Bukkit.getOnlinePlayers()) {
if (p2.getName().toLowerCase()
.indexOf(m[1].toLowerCase()) > -1) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = !nn.isrun[getid];
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
break;
}
}
return;
}
}
else if (m.length == 3) {
// it's mean player 0|1
if (p.hasPermission(pgetaway) == false) {
p.sendMessage("you don't have permission " + pgetaway);
return;
}
if (m[1].equalsIgnoreCase(p.getName()) == false) {
if (p.hasPermission(pgetawayother) == false) {
p.sendMessage("you don't have permission "
+ pgetaway);
return;
}
}
if (m[2].equalsIgnoreCase("0") == false
&& m[2].equalsIgnoreCase("1") == false) {
p.sendMessage("argument 3 must be 0 or 1");
return;
}
boolean togglemode = false;
if (m[2].equalsIgnoreCase("1") == true) togglemode = true;
if (m[1].equalsIgnoreCase("@a") == true) {
// it's mean toggle everyone
for (Player p2 : Bukkit.getOnlinePlayers()) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = togglemode;
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
}
return;
}
else {
// find that player
for (Player p2 : Bukkit.getOnlinePlayers()) {
if (p2.getName().toLowerCase()
.indexOf(m[1].toLowerCase()) > -1) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = togglemode;
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
break;
}
}
return;
}
}
}
}
}
class ddata {
public String playername[];
public boolean isrun[];
}
class getawaytick2 implements Runnable {
public void run() {
long starttime = System.currentTimeMillis();
long endtime = 0;
// loop everyone
// printAll("tick");
for (int i = 0; i < ddatamax; i++) {
if (nn.isrun[i] == true) {
// printAll("found nn = true at " + i);
if (nn.playername[i].equalsIgnoreCase("") == false) {
// printAll(" nn name empty == false at " + i);
// search that player
Player p2 = null;
for (Player p3 : Bukkit.getOnlinePlayers()) {
if (p3.getName().equalsIgnoreCase(nn.playername[i])) {
p2 = p3;
break;
}
}
if (p2 == null) {
// printAll("p2 = null " + i);
continue;
}
// printAll("foundn p2");
double td = 0;
Block b = null;
Block b2 = null;
for (int x = -ra; x <= ra; x++) {
for (int y = -ra; y <= ra; y++) {
for (int z = -ra; z <= ra; z++) {
endtime = System.currentTimeMillis();
if (endtime - starttime > 250) return;
if (dewddtps.tps.getTPS() < 18) {
return;
}
b = p2.getLocation().getBlock()
.getRelative(x, y, z);
// b2 is looking
td = distance3d(b.getX(), b.getY(),
b.getZ(),
p2.getLocation().getBlockX(), p2
.getLocation().getBlockY(),
p2.getLocation().getBlockZ());
// printAll("radi td " + td);
if (td > ra) {
continue;
}
// check this block
// b =
// p2.getLocation().getBlock().getRelative(x,y,z);
boolean bll = blockdewset(b.getTypeId());
if (bll == false) {
continue;
}
// check sign
for (int nx = -1; nx <= 1; nx++) {
for (int ny = -1; ny <= 1; ny++) {
for (int nz = -1; nz <= 1; nz++) {
if (b.getRelative(nx, ny, nz)
.getTypeId() == 0) {
continue;
}
if (b.getRelative(nx, ny, nz)
.getTypeId() == 63
|| b.getRelative(nx,
ny, nz)
.getTypeId() == 68
|| b.getRelative(nx,
ny, nz)
.getType()
.isBlock() == false
|| blockdewset(b
.getRelative(
nx, ny,
nz)
.getTypeId()) == false) {
bll = false;
if (bll == false) {
break;
}
}
if (bll == false) {
break;
}
}
}
if (bll == false) {
break;
}
}
if (bll == false) {
continue;
}
// printAll("adding " + b.getX() + "," +
// b.getY() + "," + b.getZ());
// move it
b2 = getran(b, 1);
saveb xx = new saveb();
xx.b1id = b.getTypeId();
xx.b1data = b.getData();
xx.b1x = b.getX();
xx.b1y = b.getY();
xx.b1z = b.getZ();
xx.b2id = b2.getTypeId();
xx.b2data = b2.getData();
xx.b2x = b2.getX();
xx.b2y = b2.getY();
xx.b2z = b2.getZ();
xx.w = b.getWorld().getName();
bd.push(xx);
// added queue
// switch that block
b.setTypeId(xx.b2id);
b.setData(xx.b2data);
b2.setTypeId(xx.b1id);
b2.setData(xx.b1data);
}
}
}
// if found player
// search neary block at player it's sholud be move
// or not
// if yes add to queue
// and loop again to should it's roll back or not
// We should't use quere
// We should use array
}
}
}
// after add quere
dprint.r.printC("bd size = " + bd.size());
for (int gx = 0; gx <= 300; gx++) {
// this is rollback block
if (bd.size() == 0) {
bd.trimToSize();
return;
}
endtime = System.currentTimeMillis();
if (endtime - starttime > 250) return;
if (dewddtps.tps.getTPS() < 18) {
return;
}
// printC("before peek " + bd.size());
saveb ttt = bd.peek();
// printC("after peek " + bd.size());
Block b3 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b1x, ttt.b1y,
ttt.b1z);
Block b4 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b2x, ttt.b2y,
ttt.b2z);
boolean isp = false;
isp = isplayernearblock(b3, ra) || isplayernearblock(b4, ra);
if (isp == true) {
return;
}
ttt = bd.pop();
b3 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b1x, ttt.b1y,
ttt.b1z);
b4 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b2x, ttt.b2y,
ttt.b2z);
b4.setTypeId(ttt.b2id);
b4.setData(ttt.b2data);
b3.setTypeId(ttt.b1id);
b3.setData(ttt.b1data);
}
// if not player near rollback
// check
// is't there have player near that block ?
}
}
class getawayticktock extends Thread {
public void run() {
while (isruntick == true) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
getawaytick2 eee = new getawaytick2();
Bukkit.getScheduler().scheduleSyncDelayedTask(ac, eee);
}
}
}
class saveb {
public int b1id = 0;
public byte b1data = 0;
public int b1x = 0;
public int b1y = 0;
public int b1z = 0;
public int b2id = 0;
public byte b2data = 0;
public int b2x = 0;
public int b2y = 0;
public int b2z = 0;
public String w = "";
}
boolean isruntick = false;
JavaPlugin ac = null;
int ra = 5;
int ddatamax = 29;
ddata nn = new ddata();
String pgetaway = "dewdd.getaway.use";
String pgetawayother = "dewdd.getaway.use.other";
Stack<saveb> bd = new Stack<saveb>();
// Queue<saveb> bd= new LinkedList<saveb>();
Random rnd = new Random();
public dewgetaway2() {
nn.playername = new String[ddatamax];
nn.isrun = new boolean[ddatamax];
for (int i = 0; i < ddatamax; i++) {
nn.playername[i] = "";
nn.isrun[i] = false;
}
}
public boolean blockdewset(int blockid) {
return staticarea.dslb.isdewset(blockid)
&& staticarea.dslb.isdewinventoryblock(blockid) == false
&& blockid != 0 && blockid != 8 && blockid != 9
&& blockid != 10 && blockid != 11;
}
public int distance2d(int x1, int z1, int x2, int z2) {
double t1 = Math.pow(x1 - x2, 2);
double t2 = Math.pow(z1 - z2, 2);
double t3 = Math.pow(t1 + t2, 0.5);
int t4 = (int) t3;
return t4;
}
public double distance3d(int x1, int y1, int z1, int x2, int y2, int z2) {
double t1 = Math.pow(x1 - x2, 2);
double t2 = Math.pow(z1 - z2, 2);
double t3 = Math.pow(y1 - y2, 2);
double t5 = Math.pow(t1 + t2 + t3, 0.5);
return t5;
}
@EventHandler
public void eventja(PlayerCommandPreprocessEvent event) {
chatx a = new chatx();
a.p = event.getPlayer();
a.message = event.getMessage();
Bukkit.getScheduler().scheduleSyncDelayedTask(ac, a);
}
public int getfreeselect(String sname) {
// clean exited player
boolean foundx = false;
for (int i = 0; i < ddatamax; i++) {
foundx = false;
for (Player pr : Bukkit.getOnlinePlayers()) {
if (nn.playername[i].equalsIgnoreCase(pr.getName())) {
foundx = true;
break;
}
}
if (foundx == false) {
nn.playername[i] = "";
nn.isrun[i] = false;
}
}
// clean
for (int i = 0; i < ddatamax; i++) {
if (nn.playername[i].equalsIgnoreCase(sname)) {
return i;
}
}
for (int i = 0; i < ddatamax; i++) {
if (nn.playername[i].equalsIgnoreCase("")) {
nn.playername[i] = sname;
return i;
}
}
return -1;
}
public Block getran(Block b, int ra) {
Block b2 = b;
int tx = 0;
int ty = 0;
int tz = 0;
int counttry = 0;
do {
counttry++;
tx = rnd.nextInt(ra * 2) - (ra * 1);
ty = rnd.nextInt(ra * 2) - (ra * 1);
tz = rnd.nextInt(ra * 2) - (ra * 1);
if (ty < 1) ty = 1;
if (ty > 254) ty = 254;
b2 = b.getRelative(tx, ty, tz);
if (counttry >= 100) {
counttry = 0;
ra = ra + 1;
}
}
while (b2.getLocation().distance(b.getLocation()) < ra || b2 == b
|| b2.getTypeId() != 0);
return b2;
}
public boolean isplayernearblock(Block bh, int ra) {
for (Player uu : bh.getWorld().getPlayers()) {
if (nn.isrun[getfreeselect(uu.getName())] == false) continue;
if (uu.getLocation().distance(bh.getLocation()) <= ra) {
return true;
}
}
return false;
}
} // class
| dewtx29/dewdd_minecraft_plugins | old/dewdd_getaway/src/dewddgetaway/dewgetaway2.java | Java | gpl-3.0 | 13,351 | [
30522,
1013,
1008,
1008,
3166,
1024,
6986,
11514,
12707,
24951,
1011,
1057,
1011,
1047,
14615,
1006,
24903,
1007,
1008,
1041,
1011,
5653,
1024,
24903,
2102,
2595,
24594,
1030,
20917,
4014,
1012,
4012,
1008,
9130,
1024,
16770,
1024,
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... |
t = PryTheme.create :name => 'pry-modern-16', :color_model => 16 do
author :name => 'Kyrylo Silin', :email => 'silin@kyrylo.org'
description 'Simplied version of pry-modern-256'
define_theme do
class_ 'bright_magenta'
class_variable 'bright_cyan'
comment 'blue'
constant 'bright_blue'
error 'black', 'white'
float 'bright_red'
global_variable 'bright_yellow'
inline_delimiter 'bright_green'
instance_variable 'bright_cyan'
integer 'bright_blue'
keyword 'bright_red'
method 'bright_yellow'
predefined_constant 'bright_cyan'
symbol 'bright_green'
regexp do
self_ 'bright_red'
char 'bright_red'
content 'magenta'
delimiter 'red'
modifier 'red'
escape 'red'
end
shell do
self_ 'bright_green'
char 'bright_green'
content 'green'
delimiter 'green'
escape 'green'
end
string do
self_ 'bright_green'
char 'bright_green'
content 'green'
delimiter 'green'
escape 'green'
end
end
end
PryTheme::ThemeList.add_theme(t)
| americanhanko/dotfiles | config/.pry/themes/pry-modern-16.prytheme.rb | Ruby | mit | 1,095 | [
30522,
1056,
1027,
29198,
10760,
4168,
1012,
3443,
1024,
2171,
1027,
1028,
1005,
29198,
1011,
2715,
1011,
2385,
1005,
1010,
1024,
3609,
1035,
2944,
1027,
1028,
2385,
2079,
3166,
1024,
2171,
1027,
1028,
1005,
18712,
23320,
2080,
9033,
4115,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 IBM Corp.
*
* 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.ibmcloud.contest.phonebook;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
/**
* Throw a 400 status code
*/
public class BadRequestException extends WebApplicationException {
private static final long serialVersionUID = 1L;
public BadRequestException() {
super(Response.status(Status.BAD_REQUEST).build());
}
}
| ibmkendrick/phonebookdemo-v2 | src/main/java/com/ibmcloud/contest/phonebook/BadRequestException.java | Java | apache-2.0 | 1,011 | [
30522,
1013,
1008,
1008,
1008,
9385,
2325,
9980,
13058,
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,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
| tlake/data-structures-mk2 | tests/test_insertion_sort.py | Python | mit | 1,008 | [
30522,
1001,
1011,
1008,
1011,
16861,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
2013,
1035,
1035,
2925,
1035,
1035,
12324,
27260,
1035,
18204,
2015,
12324,
1052,
17250,
3367,
2013,
5090,
1012,
23851,
1035,
4066,
12324,
23851,
1035,
4066,
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 by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package hdf.hdf5lib.callbacks;
public interface H5D_iterate_t {
/** public ArrayList iterdata = new ArrayList();
* Any derived interfaces must define the single public variable as above.
*/
}
| biospi/seamass-windeps | src/hdf5-1.10.0-patch1/java/src/hdf/hdf5lib/callbacks/H5D_iterate_t.java | Java | apache-2.0 | 1,308 | [
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... |
/*
* Jinx is Copyright 2010-2020 by Jeremy Brooks and Contributors
*
* Jinx 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.
*
* Jinx 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 Jinx. If not, see <http://www.gnu.org/licenses/>.
*/
package net.jeremybrooks.jinx.api;
import net.jeremybrooks.jinx.Jinx;
import net.jeremybrooks.jinx.JinxException;
import net.jeremybrooks.jinx.JinxUtils;
import net.jeremybrooks.jinx.response.Response;
import net.jeremybrooks.jinx.response.photos.notes.Note;
import java.util.Map;
import java.util.TreeMap;
/**
* Provides access to the flickr.photos.notes API methods.
*
* @author Jeremy Brooks
* @see <a href="https://www.flickr.com/services/api/">Flickr API documentation</a> for more details.
*/
public class PhotosNotesApi {
private Jinx jinx;
public PhotosNotesApi(Jinx jinx) {
this.jinx = jinx;
}
/**
* Add a note to a photo. Coordinates and sizes are in pixels, based on the 500px image size shown on individual photo pages.
* <br>
* This method requires authentication with 'write' permission.
*
* @param photoId (Required) The id of the photo to add a note to.
* @param noteX (Required) The left coordinate of the note.
* @param noteY (Required) The top coordinate of the note.
* @param noteWidth (Required) The width of the note.
* @param noteHeight (Required) The height of the note.
* @param noteText (Required) The text of the note.
* @return object with the ID for the newly created note.
* @throws JinxException if required parameters are missing, or if there are any errors.
* @see <a href="https://www.flickr.com/services/api/flickr.photos.notes.add.html">flickr.photos.notes.add</a>
*/
public Note add(String photoId, int noteX, int noteY, int noteWidth, int noteHeight, String noteText) throws JinxException {
JinxUtils.validateParams(photoId, noteText);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.notes.add");
params.put("photo_id", photoId);
params.put("note_x", Integer.toString(noteX));
params.put("note_y", Integer.toString(noteY));
params.put("note_w", Integer.toString(noteWidth));
params.put("note_h", Integer.toString(noteHeight));
params.put("note_text", noteText);
return jinx.flickrPost(params, Note.class);
}
/**
* Edit a note on a photo. Coordinates and sizes are in pixels, based on the 500px image size shown on individual photo pages.
* <br>
* This method requires authentication with 'write' permission.
*
* @param noteId (Required) The id of the note to edit.
* @param noteX (Required) The left coordinate of the note.
* @param noteY (Required) The top coordinate of the note.
* @param noteWidth (Required) The width of the note.
* @param noteHeight (Required) The height of the note.
* @param noteText (Required) The text of the note.
* @return object with the status of the requested operation.
* @throws JinxException if required parameters are missing, or if there are any errors.
* @see <a href="https://www.flickr.com/services/api/flickr.photos.notes.edit.html">flickr.photos.notes.edit</a>
*/
public Response edit(String noteId, int noteX, int noteY, int noteWidth, int noteHeight, String noteText) throws JinxException {
JinxUtils.validateParams(noteId, noteText);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.notes.edit");
params.put("note_id", noteId);
params.put("note_x", Integer.toString(noteX));
params.put("note_y", Integer.toString(noteY));
params.put("note_w", Integer.toString(noteWidth));
params.put("note_h", Integer.toString(noteHeight));
params.put("note_text", noteText);
return jinx.flickrPost(params, Response.class);
}
/**
* Delete a note from a photo.
* <br>
* This method requires authentication with 'write' permission.
*
* @param noteId (Required) The id of the note to delete.
* @return object with the status of the requested operation.
* @throws JinxException if required parameters are missing, or if there are any errors.
* @see <a href="https://www.flickr.com/services/api/flickr.photos.notes.delete.html">flickr.photos.notes.delete</a>
*/
public Response delete(String noteId) throws JinxException {
JinxUtils.validateParams(noteId);
Map<String, String> params = new TreeMap<>();
params.put("method", "flickr.photos.notes.delete");
params.put("note_id", noteId);
return jinx.flickrPost(params, Response.class);
}
}
| jeremybrooks/jinx | src/main/java/net/jeremybrooks/jinx/api/PhotosNotesApi.java | Java | gpl-3.0 | 5,049 | [
30522,
1013,
1008,
1008,
9743,
2595,
2003,
9385,
2230,
1011,
12609,
2011,
7441,
8379,
1998,
16884,
1008,
1008,
9743,
2595,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
1008,
2009,
2104,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
/**
* HiPay Fullservice SDK Magento 1
*
* 2018 HiPay
*
* NOTICE OF LICENSE
*
* @author HiPay <support.tpp@hipay.com>
* @copyright 2018 HiPay
* @license https://github.com/hipay/hipay-fullservice-sdk-magento1/blob/master/LICENSE.md
*/
$installer = $this;
$installer->startSetup();
$installer->run(
"
ALTER TABLE {$this->getTable('hipay_split_payment')} ADD COLUMN `split_number` varchar(150)
"
);
$installer->run(
"
ALTER TABLE {$this->getTable('hipay_split_payment')} ADD COLUMN `tax_amount_to_pay` decimal(12,4) NOT NULL,
ADD COLUMN `total_tax_amount` decimal(12,4) NOT NULL
"
);
$installer->endSetup();
| hipay/hipay-fullservice-sdk-magento1 | src/app/code/community/Allopass/Hipay/sql/allopass_hipay_setup/mysql4-upgrade-1.1.0-1.6.0.php | PHP | apache-2.0 | 649 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
5099,
4710,
2440,
8043,
7903,
2063,
17371,
2243,
17454,
13663,
1015,
1008,
1008,
2760,
5099,
4710,
1008,
1008,
5060,
1997,
6105,
1008,
1008,
1030,
3166,
5099,
4710,
1026,
2490,
1012,
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... |
/*
* 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.spark.sql.catalyst.expressions
import java.util.UUID
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.codegen._
import org.apache.spark.sql.types._
import org.apache.spark.unsafe.types.UTF8String
/**
* Print the result of an expression to stderr (used for debugging codegen).
*/
case class PrintToStderr(child: Expression) extends UnaryExpression {
override def dataType: DataType = child.dataType
protected override def nullSafeEval(input: Any): Any = input
private val outputPrefix = s"Result of ${child.simpleString} is "
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
val outputPrefixField = ctx.addReferenceObj("outputPrefix", outputPrefix)
nullSafeCodeGen(ctx, ev, c =>
s"""
| System.err.println($outputPrefixField + $c);
| ${ev.value} = $c;
""".stripMargin)
}
}
/**
* A function throws an exception if 'condition' is not true.
*/
@ExpressionDescription(
usage = "_FUNC_(expr) - Throws an exception if `expr` is not true.",
examples = """
Examples:
> SELECT _FUNC_(0 < 1);
NULL
""")
case class AssertTrue(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
override def nullable: Boolean = true
override def inputTypes: Seq[DataType] = Seq(BooleanType)
override def dataType: DataType = NullType
override def prettyName: String = "assert_true"
private val errMsg = s"'${child.simpleString}' is not true!"
override def eval(input: InternalRow) : Any = {
val v = child.eval(input)
if (v == null || java.lang.Boolean.FALSE.equals(v)) {
throw new RuntimeException(errMsg)
} else {
null
}
}
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
val eval = child.genCode(ctx)
// Use unnamed reference that doesn't create a local field here to reduce the number of fields
// because errMsgField is used only when the value is null or false.
val errMsgField = ctx.addReferenceMinorObj(errMsg)
ExprCode(code = s"""${eval.code}
|if (${eval.isNull} || !${eval.value}) {
| throw new RuntimeException($errMsgField);
|}""".stripMargin, isNull = "true", value = "null")
}
override def sql: String = s"assert_true(${child.sql})"
}
/**
* Returns the current database of the SessionCatalog.
*/
@ExpressionDescription(
usage = "_FUNC_() - Returns the current database.",
examples = """
Examples:
> SELECT _FUNC_();
default
""")
case class CurrentDatabase() extends LeafExpression with Unevaluable {
override def dataType: DataType = StringType
override def foldable: Boolean = true
override def nullable: Boolean = false
override def prettyName: String = "current_database"
}
// scalastyle:off line.size.limit
@ExpressionDescription(
usage = "_FUNC_() - Returns an universally unique identifier (UUID) string. The value is returned as a canonical UUID 36-character string.",
examples = """
Examples:
> SELECT _FUNC_();
46707d92-02f4-4817-8116-a4c3b23e6266
""")
// scalastyle:on line.size.limit
case class Uuid() extends LeafExpression {
override lazy val deterministic: Boolean = false
override def nullable: Boolean = false
override def dataType: DataType = StringType
override def eval(input: InternalRow): Any = UTF8String.fromString(UUID.randomUUID().toString)
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
ev.copy(code = s"final UTF8String ${ev.value} = " +
s"UTF8String.fromString(java.util.UUID.randomUUID().toString());", isNull = "false")
}
}
| akopich/spark | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/misc.scala | Scala | apache-2.0 | 4,467 | [
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... |
//
// FLGridlines.h
// Fliegen
//
// Created by Abhishek Moothedath on 10/7/14.
// Copyright (c) 2014 Abhishek Moothedath. All rights reserved.
//
#import <SceneKit/SceneKit.h>
@interface FLGridlines : SCNNode
@end
| lordvisionz/Fliegen | Fliegen/FLGridlines.h | C | mit | 222 | [
30522,
1013,
1013,
1013,
1013,
13109,
16523,
3593,
12735,
1012,
1044,
1013,
1013,
13109,
28872,
2368,
1013,
1013,
1013,
1013,
2580,
2011,
11113,
24158,
5369,
2243,
9587,
14573,
11960,
2705,
2006,
2184,
1013,
1021,
1013,
2403,
1012,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.