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 |
|---|---|---|---|---|---|---|---|---|---|
/*
* 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.harmony.lang.management.tests.java.lang.management;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;
import junit.framework.TestCase;
public class MemoryMXBeanTest extends TestCase {
private MemoryMXBean mb;
protected void setUp() throws Exception {
super.setUp();
mb = ManagementFactory.getMemoryMXBean();
assertNotNull(mb);
}
protected void tearDown() throws Exception {
super.tearDown();
}
/*
* Test method for 'java.lang.management.MemoryMXBean.getHeapMemoryUsage()'
*/
public void testGetHeapMemoryUsage() {
MemoryUsage mu = mb.getHeapMemoryUsage();
assertNotNull(mu);
assertTrue(mu.getCommitted() >= mu.getUsed());
assertTrue(mu.getCommitted() <= mu.getMax());
assertTrue(mu.getUsed() <= mu.getMax());
}
/*
* Test method for 'java.lang.management.MemoryMXBean.getNonHeapMemoryUsage()'
*/
public void testGetNonHeapMemoryUsage() {
MemoryUsage mu = mb.getNonHeapMemoryUsage();
assertNotNull(mu);
assertTrue(mu.getCommitted() >= mu.getUsed());
if (mu.getMax() != -1) {
// If max is defined then used and committed will always
// be less than or equal to it
assertTrue(mu.getCommitted() <= mu.getMax());
assertTrue(mu.getUsed() <= mu.getMax());
}
}
/*
* Test method for 'java.lang.management.MemoryMXBean.getObjectPendingFinalizationCount()'
*/
public void testGetObjectPendingFinalizationCount() {
assertTrue(mb.getObjectPendingFinalizationCount() > -1);
}
/*
* Test method for 'java.lang.management.MemoryMXBean.setVerbose(boolean)'
*/
public void testSetVerbose() {
boolean initialVal = mb.isVerbose();
mb.setVerbose(!initialVal);
assertTrue(mb.isVerbose() != initialVal);
mb.setVerbose(initialVal);
assertTrue(mb.isVerbose() == initialVal);
}
}
| freeVM/freeVM | enhanced/java/classlib/modules/lang-management/src/test/api/java/org/apache/harmony/lang/management/tests/java/lang/management/MemoryMXBeanTest.java | Java | apache-2.0 | 2,895 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
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... |
<?php
namespace FSM\Exception;
/**
* Exception while configuring State, Transition or Context
*
* @author Ivan Zinovyev <vanyazin@gmail.com>
*/
class ComponentConfigurationException extends Exception
{
} | zinovyev/php-fsm | src/FSM/Exception/ComponentConfigurationException.php | PHP | gpl-2.0 | 209 | [
30522,
1026,
1029,
25718,
3415,
15327,
1042,
6491,
1032,
6453,
1025,
1013,
1008,
1008,
1008,
6453,
2096,
9530,
8873,
27390,
2075,
2110,
1010,
6653,
2030,
6123,
1008,
1008,
1030,
3166,
7332,
1062,
5740,
10736,
6777,
1026,
3158,
3148,
17168,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<ul class="menu-item">
<li class="home"><a href="/">{{ site.title }}</a></li>
{% for link in site.data.navigation %}
{% if link.url_en contains 'http' %}
{% assign domain = '' %}
{% else %}
{% assign domain = site.url_en %}
{% endif %}
<li><a href="{{ domain }}{{ link.url_en }}" {% if link.url contains 'http' %}target="_blank"{% endif %}>{{ link.title_en }}</a></li>
{% endfor %}
</ul> | TsinStudio/tsinstudio.github.com | _includes/navigation_en.html | HTML | mit | 427 | [
30522,
1026,
17359,
2465,
1027,
1000,
12183,
1011,
8875,
1000,
1028,
1026,
5622,
2465,
1027,
1000,
2188,
1000,
1028,
1026,
1037,
17850,
12879,
1027,
1000,
1013,
1000,
1028,
1063,
1063,
2609,
1012,
2516,
1065,
1065,
1026,
1013,
1037,
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... |
/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
.model-track {
-webkit-box-flex: 1;
}
| bpsinc-native/src_third_party_trace-viewer | trace_viewer/tracing/tracks/trace_model_track.css | CSS | bsd-3-clause | 213 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2262,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
1008,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 code has been automatically generated !!! Wed Jul 22 2015 13:15:44 GMT+0000 (UTC)
/**
* @module opcua.address_space.types
*/
var doDebug = false;
var assert = require("better-assert");
var util = require("util");
var _ = require("underscore");
var makeNodeId = require("../lib/datamodel/nodeid").makeNodeId;
var schema_helpers = require("../lib/misc/factories_schema_helpers");
var extract_all_fields = schema_helpers.extract_all_fields;
var resolve_schema_field_types = schema_helpers.resolve_schema_field_types;
var initialize_field = schema_helpers.initialize_field;
var initialize_field_array = schema_helpers.initialize_field_array;
var check_options_correctness_against_schema = schema_helpers.check_options_correctness_against_schema;
var _defaultTypeMap = require("../lib/misc/factories_builtin_types")._defaultTypeMap;
var ec= require("../lib/misc/encode_decode");
var encodeArray= ec.encodeArray;
var decodeArray= ec.decodeArray;
var makeExpandedNodeId= ec.makeExpandedNodeId;
var generate_new_id = require("../lib/misc/factories").generate_new_id;
var _enumerations = require("../lib/misc/factories_enumerations")._private._enumerations;
var schema = require("../schemas/ChannelSecurityToken_schema").ChannelSecurityToken_Schema;
var BaseUAObject = require("../lib/misc/factories_baseobject").BaseUAObject;
/**
*
* @class ChannelSecurityToken
* @constructor
* @extends BaseUAObject
* @param options {Object}
* @param [options.secureChannelId] {UInt32}
* @param [options.tokenId] {UInt32}
* @param [options.createdAt = Wed Jul 22 2015 13:15:44 GMT+0000 (UTC)] {UtcTime}
* @param [options.revisedLifeTime = 30000] {UInt32}
*/
function ChannelSecurityToken(options)
{
options = options || {};
/* istanbul ignore next */
if (doDebug) { check_options_correctness_against_schema(this,schema,options); }
var self = this;
assert(this instanceof BaseUAObject); // ' keyword "new" is required for constructor call')
resolve_schema_field_types(schema);
BaseUAObject.call(this,options);
/**
*
* @property secureChannelId
* @type {UInt32}
*/
self.secureChannelId = initialize_field(schema.fields[0], options.secureChannelId);
/**
*
* @property tokenId
* @type {UInt32}
*/
self.tokenId = initialize_field(schema.fields[1], options.tokenId);
/**
*
* @property createdAt
* @type {UtcTime}
* @default function () {
return new Date();
}
*/
self.createdAt = initialize_field(schema.fields[2], options.createdAt);
/**
*
* @property revisedLifeTime
* @type {UInt32}
* @default 30000
*/
self.revisedLifeTime = initialize_field(schema.fields[3], options.revisedLifeTime);
// Object.preventExtensions(self);
}
util.inherits(ChannelSecurityToken,BaseUAObject);
ChannelSecurityToken.prototype.encodingDefaultBinary =makeExpandedNodeId(443,0);
ChannelSecurityToken.prototype._schema = schema;
var encode_UInt32 = _defaultTypeMap.UInt32.encode;
var decode_UInt32 = _defaultTypeMap.UInt32.decode;
var encode_UtcTime = _defaultTypeMap.UtcTime.encode;
var decode_UtcTime = _defaultTypeMap.UtcTime.decode;
/**
* encode the object into a binary stream
* @method encode
*
* @param stream {BinaryStream}
*/
ChannelSecurityToken.prototype.encode = function(stream,options) {
// call base class implementation first
BaseUAObject.prototype.encode.call(this,stream,options);
encode_UInt32(this.secureChannelId,stream);
encode_UInt32(this.tokenId,stream);
encode_UtcTime(this.createdAt,stream);
encode_UInt32(this.revisedLifeTime,stream);
};
ChannelSecurityToken.prototype.decode = function(stream,options) {
// call base class implementation first
BaseUAObject.prototype.decode.call(this,stream,options);
this.secureChannelId = decode_UInt32(stream,options);
this.tokenId = decode_UInt32(stream,options);
this.createdAt = decode_UtcTime(stream,options);
this.revisedLifeTime = decode_UInt32(stream,options);
};
ChannelSecurityToken.possibleFields = function() {
return [
"secureChannelId",
"tokenId",
"createdAt",
"revisedLifeTime"
];
}();
exports.ChannelSecurityToken = ChannelSecurityToken;
var register_class_definition = require("../lib/misc/factories_factories").register_class_definition;
register_class_definition("ChannelSecurityToken",ChannelSecurityToken); | jcodling/node-OPC-UA-server | node_modules/node-opcua/_generated_/_auto_generated_ChannelSecurityToken.js | JavaScript | mit | 4,563 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
2023,
3642,
2038,
2042,
8073,
7013,
999,
999,
999,
21981,
21650,
2570,
2325,
2410,
1024,
2321,
1024,
4008,
13938,
2102,
1009,
2199,
2692,
1006,
11396,
1007,
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... |
jsonp({"cep":"71620235","logradouro":"Quadra SHIS QL 8 Conjunto 3","bairro":"Setor de Habita\u00e7\u00f5es Individuais Sul","cidade":"Bras\u00edlia","uf":"DF","estado":"Distrito Federal"});
| lfreneda/cepdb | api/v1/71620235.jsonp.js | JavaScript | cc0-1.0 | 190 | [
30522,
1046,
3385,
2361,
1006,
1063,
1000,
8292,
2361,
1000,
1024,
1000,
6390,
2575,
11387,
21926,
2629,
1000,
1010,
1000,
8833,
12173,
8162,
2080,
1000,
1024,
1000,
17718,
2527,
11895,
2015,
1053,
2140,
1022,
9530,
19792,
3406,
1017,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE401_Memory_Leak__new_twoIntsStruct_52b.cpp
Label Definition File: CWE401_Memory_Leak__new.label.xml
Template File: sources-sinks-52b.tmpl.cpp
*/
/*
* @description
* CWE: 401 Memory Leak
* BadSource: Allocate data using new
* GoodSource: Allocate data on the stack
* Sinks:
* GoodSink: call delete on data
* BadSink : no deallocation of data
* Flow Variant: 52 Data flow: data passed as an argument from one function to another to another in three different source files
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
namespace CWE401_Memory_Leak__new_twoIntsStruct_52
{
#ifndef OMITBAD
/* bad function declaration */
void badSink_c(twoIntsStruct * data);
void badSink_b(twoIntsStruct * data)
{
badSink_c(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink_c(twoIntsStruct * data);
void goodG2BSink_b(twoIntsStruct * data)
{
goodG2BSink_c(data);
}
/* goodB2G uses the BadSource with the GoodSink */
void goodB2GSink_c(twoIntsStruct * data);
void goodB2GSink_b(twoIntsStruct * data)
{
goodB2GSink_c(data);
}
#endif /* OMITGOOD */
} /* close namespace */
| JianpingZeng/xcc | xcc/test/juliet/testcases/CWE401_Memory_Leak/s02/CWE401_Memory_Leak__new_twoIntsStruct_52b.cpp | C++ | bsd-3-clause | 1,293 | [
30522,
1013,
1008,
23561,
7013,
3231,
18382,
5371,
5371,
18442,
1024,
19296,
2063,
12740,
2487,
1035,
3638,
1035,
17271,
1035,
1035,
2047,
1035,
2048,
18447,
4757,
18300,
1035,
4720,
2497,
1012,
18133,
2361,
3830,
6210,
5371,
1024,
19296,
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... |
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.solaredge.internal.handler;
import java.util.Map;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.solaredge.internal.AtomicReferenceTrait;
import org.openhab.binding.solaredge.internal.config.SolarEdgeConfiguration;
import org.openhab.binding.solaredge.internal.connector.WebInterface;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.binding.BaseThingHandler;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The {@link SolarEdgeBaseHandler} is responsible for handling commands, which are
* sent to one of the channels.
*
* @author Alexander Friese - initial contribution
*/
@NonNullByDefault
public abstract class SolarEdgeBaseHandler extends BaseThingHandler implements SolarEdgeHandler, AtomicReferenceTrait {
private final Logger logger = LoggerFactory.getLogger(SolarEdgeBaseHandler.class);
private final long LIVE_POLLING_INITIAL_DELAY = 1;
private final long AGGREGATE_POLLING_INITIAL_DELAY = 2;
/**
* Interface object for querying the Solaredge web interface
*/
private WebInterface webInterface;
/**
* Schedule for polling live data
*/
private final AtomicReference<@Nullable Future<?>> liveDataPollingJobReference;
/**
* Schedule for polling aggregate data
*/
private final AtomicReference<@Nullable Future<?>> aggregateDataPollingJobReference;
public SolarEdgeBaseHandler(Thing thing, HttpClient httpClient) {
super(thing);
this.webInterface = new WebInterface(scheduler, this, httpClient);
this.liveDataPollingJobReference = new AtomicReference<>(null);
this.aggregateDataPollingJobReference = new AtomicReference<>(null);
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
logger.debug("command for {}: {}", channelUID, command);
// write access is not supported.
}
@Override
public void initialize() {
logger.debug("About to initialize SolarEdge");
SolarEdgeConfiguration config = getConfiguration();
logger.debug("Solaredge initialized with configuration: {}", config);
startPolling();
webInterface.start();
updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "waiting for web api login");
}
/**
* Start the polling.
*/
private void startPolling() {
updateJobReference(liveDataPollingJobReference,
scheduler.scheduleWithFixedDelay(new SolarEdgeLiveDataPolling(this), LIVE_POLLING_INITIAL_DELAY,
getConfiguration().getLiveDataPollingInterval(), TimeUnit.MINUTES));
updateJobReference(aggregateDataPollingJobReference,
scheduler.scheduleWithFixedDelay(new SolarEdgeAggregateDataPolling(this),
AGGREGATE_POLLING_INITIAL_DELAY, getConfiguration().getAggregateDataPollingInterval(),
TimeUnit.MINUTES));
}
/**
* Disposes the bridge.
*/
@Override
public void dispose() {
logger.debug("Handler disposed.");
cancelJobReference(liveDataPollingJobReference);
cancelJobReference(aggregateDataPollingJobReference);
webInterface.dispose();
}
@Override
public WebInterface getWebInterface() {
return webInterface;
}
/**
* will update all channels provided in the map
*/
@Override
public void updateChannelStatus(Map<Channel, State> values) {
logger.debug("Handling channel update.");
for (Channel channel : values.keySet()) {
if (getChannels().contains(channel)) {
State value = values.get(channel);
if (value != null) {
logger.debug("Channel is to be updated: {}: {}", channel.getUID().getAsString(), value);
updateState(channel.getUID(), value);
} else {
logger.debug("Value is null or not provided by solaredge (channel: {})",
channel.getUID().getAsString());
updateState(channel.getUID(), UnDefType.UNDEF);
}
} else {
logger.debug("Could not identify channel: {} for model {}", channel.getUID().getAsString(),
getThing().getThingTypeUID().getAsString());
}
}
}
@Override
public void setStatusInfo(ThingStatus status, ThingStatusDetail statusDetail, String description) {
super.updateStatus(status, statusDetail, description);
}
@Override
public SolarEdgeConfiguration getConfiguration() {
return this.getConfigAs(SolarEdgeConfiguration.class);
}
}
| paulianttila/openhab2 | bundles/org.openhab.binding.solaredge/src/main/java/org/openhab/binding/solaredge/internal/handler/SolarEdgeBaseHandler.java | Java | epl-1.0 | 5,643 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2230,
1011,
25682,
16884,
2000,
1996,
2330,
25459,
2622,
1008,
1008,
2156,
1996,
5060,
5371,
1006,
1055,
1007,
5500,
2007,
2023,
2147,
2005,
3176,
1008,
2592,
1012,
1008,
1008,
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... |
/*
* Copyright (C) 2015 Nick van IJzendoorn <nijzendoorn@engineering-spirit.nl>
* 2017 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Thread test application
*
* @author Nick van IJzendoorn <nijzendoorn@engineering-spirit.nl>
* @author Sebastian Meiling <s@mlng.net>
*
* @}
*/
#include <stdio.h>
#include <inttypes.h>
#include "log.h"
#include "msg.h"
#define MSG_QUEUE_LENGTH (8)
msg_t msg_queue[MSG_QUEUE_LENGTH];
int main(void)
{
msg_t msges[MSG_QUEUE_LENGTH];
msg_init_queue(msg_queue, MSG_QUEUE_LENGTH);
puts("[START]");
/* add message to own queue */
for (unsigned idx = 0; idx < MSG_QUEUE_LENGTH; ++idx) {
msges[idx].type = idx;
msg_send_to_self(msges + idx);
LOG_INFO("+ add msg: %d\n", idx);
if (msg_avail() != (idx) + 1) {
puts("[FAILED]");
return 1;
}
}
/* receive available messages in queue */
for (unsigned idx = msg_avail(); idx > 0; --idx) {
msg_t msg;
msg_receive(&msg);
LOG_INFO("- got msg: %d\n", (MSG_QUEUE_LENGTH - idx));
if (msg.type != (MSG_QUEUE_LENGTH - idx)
|| msg_avail() != idx - 1) {
puts("[FAILED]");
return 1;
}
}
puts("[SUCCESS]");
return 0;
}
| aabadie/RIOT | tests/msg_avail/main.c | C | lgpl-2.1 | 1,499 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2325,
4172,
3158,
1045,
3501,
10431,
23835,
2078,
1026,
9152,
3501,
10431,
23835,
2078,
1030,
3330,
1011,
4382,
1012,
17953,
1028,
1008,
2418,
5292,
2860,
8719,
1008,
1008,
2023,
5371,
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... |
<?php
if ($dex_conf->get('ssl') && $_SERVER['HTTPS'] != 'on')
{
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
$form = new Form('login');
$form->addSection(__('Log in'), __('You must log in before you can continue to the admin panel.'));
$form->addText('username', __('Username'), '', '', array('[a-zA-Z0-9-_]*', 3, 16, __('Must be a valid username')));
$form->addPassword('password', __('Password'), '');
$form->addSeparator();
$form->setSubmit('<i class="fa fa-sign-in"></i> ' . __('Log in'));
$form->setResponse('', __('Not logged in'));
if ($form->submitted())
{
if ($form->validate())
{
if (User::isBlocked($form->get('username')))
$form->appendError(__('Too many login attempts within short time, please wait 15 minutes'));
else
{
$user = Db::singleQuery("SELECT user_id, password FROM user WHERE username = '" . Db::escape($form->get('username')) . "' LIMIT 1;");
if ($user && Bcrypt::verify($form->get('password'), $user['password']))
{
User::logIn($user['user_id']);
if (isset($url[1]) && strpos($url[1], 'r=') === 0)
$form->setRedirect('/' . Common::$base_url . rawurldecode(substr($url[1], 2)));
else if (Common::$request_url == 'admin/logout/')
$form->setRedirect('/' . Common::$base_url . 'admin/');
else
$form->setRedirect('/' . Common::$base_url . Common::$request_url);
}
else
{
User::addAttempt($form->get('username'));
$form->appendError(__('Username and password combination is incorrect'));
}
}
}
$form->finish();
}
Core::addTitle('Admin panel');
Hooks::emit('admin-header');
Core::set('login', $form);
Core::render('admin/login.tpl');
Hooks::emit('admin-footer');
exit;
| tdewolff/Dex | core/admin/login.php | PHP | mit | 1,728 | [
30522,
1026,
1029,
25718,
2065,
1006,
1002,
20647,
1035,
9530,
2546,
1011,
1028,
2131,
1006,
1005,
7020,
2140,
1005,
1007,
1004,
1004,
1002,
1035,
8241,
1031,
1005,
16770,
1005,
1033,
999,
1027,
1005,
2006,
1005,
1007,
1063,
20346,
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... |
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
#ifndef _BOARDS_VGABOARD_H
#define _BOARDS_VGABOARD_H
#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 1
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 20
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 21
#endif
#ifndef PICO_DEFAULT_LED_PIN
#define PICO_DEFAULT_LED_PIN 25 // same as Pico
#endif
// Audio pins. I2S BCK, LRCK are on the same pins as PWM L/R.
// - When outputting I2S, PWM sees BCK and LRCK, which should sound silent as
// they are constant duty cycle, and above the filter cutoff
// - When outputting PWM, I2S DIN should be low, so I2S should remain silent.
#define VGABOARD_I2S_DIN_PIN 26
#define VGABOARD_I2S_BCK_PIN 27
#define VGABOARD_I2S_LRCK_PIN 28
#define VGABOARD_PWM_L_PIN 28
#define VGABOARD_PWM_R_PIN 27
#define VGABOARD_VGA_COLOR_PIN_BASE 0
#define VGABOARD_VGA_SYNC_PIN_BASE 16
// Note DAT2/3 are shared with UART TX/RX (pull jumpers off header to access
// UART pins and disconnect SD DAT2/3)
#define VGABOARD_SD_CLK_PIN 5
#define VGABOARD_SD_CMD_PIN 18
#define VGABOARD_SD_DAT0_PIN 19
// Note buttons are shared with VGA colour LSBs -- if using VGA, you can float
// the pin on VSYNC assertion and sample on VSYNC deassertion
#define VGABOARD_BUTTON_A_PIN 0
#define VGABOARD_BUTTON_B_PIN 6
#define VGABOARD_BUTTON_C_PIN 11
#ifndef PICO_SCANVIDEO_COLOR_PIN_BASE
#define PICO_SCANVIDEO_COLOR_PIN_BASE VGABOARD_VGA_COLOR_PIN_BASE
#endif
#ifndef PICO_SCANVIDEO_SYMC_PIN_BASE
#define PICO_SCANVIDEO_SYNC_PIN_BASE VGABOARD_VGA_SYNC_PIN_BASE
#endif
#ifndef PICO_SD_CLK_PIN
#define PICO_SD_CLK_PIN VGABOARD_SD_CLK_PIN
#endif
#ifndef PICO_SD_CMD_PIN
#define PICO_SD_CMD_PIN VGABOARD_SD_CMD_PIN
#endif
#ifndef PICO_SD_DAT0_PIN
#define PICO_SD_DAT0_PIN VGABOARD_SD_DAT0_PIN
#endif
#define PICO_AUDIO_I2S_DATA_PIN VGABOARD_I2S_DIN_PIN
#define PICO_AUDIO_I2S_CLOCK_PIN_BASE VGABOARD_I2S_BCK_PIN
#define PICO_AUDIO_PWM_L_PIN VGABOARD_PWM_L_PIN
#define PICO_AUDIO_PWM_R_PIN VGABOARD_PWM_R_PIN
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
#define PICO_SMPS_MODE_PIN 23
#ifndef PICO_FLOAT_SUPPORT_ROM_V1
#define PICO_FLOAT_SUPPORT_ROM_V1 1
#endif
#ifndef PICO_DOUBLE_SUPPORT_ROM_V1
#define PICO_DOUBLE_SUPPORT_ROM_V1 1
#endif
#define PICO_VGA_BOARD
#endif
| nongxiaoming/rt-thread | bsp/raspberry-pico/libraries/pico-sdk/src/boards/include/boards/vgaboard.h | C | apache-2.0 | 2,774 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
12609,
20710,
2361,
9766,
14255,
1006,
6202,
1007,
5183,
1012,
1008,
1008,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
18667,
2094,
1011,
1017,
1011,
11075,
1008,
1013,
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... |
/*
* Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "config.h"
#include "StyleRareInheritedData.h"
#include "RenderStyle.h"
#include "StyleImage.h"
namespace WebCore {
StyleInheritedData::StyleInheritedData()
: indent(RenderStyle::initialTextIndent())
, line_height(RenderStyle::initialLineHeight())
, list_style_image(RenderStyle::initialListStyleImage())
, color(RenderStyle::initialColor())
, m_effectiveZoom(RenderStyle::initialZoom())
, horizontal_border_spacing(RenderStyle::initialHorizontalBorderSpacing())
, vertical_border_spacing(RenderStyle::initialVerticalBorderSpacing())
, widows(RenderStyle::initialWidows())
, orphans(RenderStyle::initialOrphans())
{
}
StyleInheritedData::~StyleInheritedData()
{
}
StyleInheritedData::StyleInheritedData(const StyleInheritedData& o)
: RefCounted<StyleInheritedData>()
, indent(o.indent)
, line_height(o.line_height)
, list_style_image(o.list_style_image)
, cursorData(o.cursorData)
, font(o.font)
, color(o.color)
, m_effectiveZoom(o.m_effectiveZoom)
, horizontal_border_spacing(o.horizontal_border_spacing)
, vertical_border_spacing(o.vertical_border_spacing)
, widows(o.widows)
, orphans(o.orphans)
{
}
static bool cursorDataEquivalent(const CursorList* c1, const CursorList* c2)
{
if (c1 == c2)
return true;
if ((!c1 && c2) || (c1 && !c2))
return false;
return (*c1 == *c2);
}
bool StyleInheritedData::operator==(const StyleInheritedData& o) const
{
return
indent == o.indent &&
line_height == o.line_height &&
StyleImage::imagesEquivalent(list_style_image.get(), o.list_style_image.get()) &&
cursorDataEquivalent(cursorData.get(), o.cursorData.get()) &&
font == o.font &&
color == o.color &&
m_effectiveZoom == o.m_effectiveZoom &&
horizontal_border_spacing == o.horizontal_border_spacing &&
vertical_border_spacing == o.vertical_border_spacing &&
widows == o.widows &&
orphans == o.orphans;
}
} // namespace WebCore
| pocketbook-free/browser | webkit-1.2.5/WebCore/rendering/style/StyleInheritedData.cpp | C++ | lgpl-2.1 | 2,961 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2639,
14405,
3775,
12849,
21997,
2080,
1006,
12849,
21997,
2080,
1030,
1047,
3207,
1012,
8917,
1007,
1008,
9385,
1006,
1039,
1007,
2432,
1010,
2384,
1010,
2294,
1010,
2289,
1010,
2263,
6207,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Guettarda sericea Müll.Arg. SPECIES
#### Status
ACCEPTED
#### According to
The Catalogue of Life, 3rd January 2011
#### Published in
null
#### Original name
null
### Remarks
null | mdoering/backbone | life/Plantae/Magnoliophyta/Magnoliopsida/Gentianales/Rubiaceae/Guettarda/Guettarda sericea/README.md | Markdown | apache-2.0 | 186 | [
30522,
1001,
19739,
16549,
13639,
14262,
6610,
2050,
14163,
3363,
1012,
12098,
2290,
1012,
2427,
1001,
1001,
1001,
1001,
3570,
3970,
1001,
1001,
1001,
1001,
2429,
2000,
1996,
10161,
1997,
2166,
1010,
3822,
2254,
2249,
1001,
1001,
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... |
<?php
/*
* 欢迎来到代码世界,如果你想修改多梦主题的代码,那我猜你是有更好的主意了~
* 那么请到多梦网络( http://www.dmeng.net/ )说说你的想法,数以万计的童鞋们会因此受益哦~
* 同时,你的名字将出现在多梦主题贡献者名单中,并有一定的积分奖励~
* 注释和代码同样重要~
* @author 多梦 @email chihyu@aliyun.com
*/
/*
* 投票 @author 多梦 at 2014.07.04
*
*/
/*
*
* 获取投票数
*
*/
function get_dmeng_user_vote( $uid, $count=true, $type='', $vote='', $limit=0, $offset=0 ){
$uid = intval($uid);
if( !$uid ) return;
$type = in_array($type, array('post', 'comment')) ? $type : '';
$vote = in_array($vote, array('up', 'down')) ? $vote : '';
global $wpdb;
$table_name = $wpdb->prefix . 'dmeng_meta';
$where = "WHERE user_id='$uid' ";
if($type) {
$vote_type = 'vote_'.$type.'_%';
$where .= "AND meta_key LIKE '$vote_type' ";
}
if($vote) $where .= "AND meta_value LIKE '$vote' ";
if($count){
$check = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name $where" );
}else{
$field = $vote ? 'meta_key' : 'meta_key,meta_value';
$check = $wpdb->get_results( "SELECT $field FROM $table_name $where ORDER BY meta_id DESC LIMIT $offset,$limit" );
}
if($check) return $check;
return 0;
}
/*
*
* huoxing投票HTML 传递文章id
*
*/
function huoxing_post_vote_html($type,$id){
$type = $type=='post' ? 'post' : 'comment';
$vote_class = 'vote-group';
$up_class = 'up';
$type_html = 'data-vote-type="post" itemscope itemtype="http://data-vocabulary.org/Review-aggregate"';
$key = 'vote_'.$type.'_'.$id;
$uid = get_current_user_id();
if($uid>0){
$vote = get_dmeng_meta($key,$uid);
if($vote){
$vote_class .= ' disabled';
$up_class .= ' highlight';
}
}
?>
<div class="btn <?php echo $vote_class;?>" data-vote-id="<?php echo $id; ?>" <?php echo $type_html; ?> role="button">
<a href="javascript:;" title="点赞" class="favorite <?php echo $up_class;?>" <?php echo $type_html; ?>><i class="glyphicon glyphicon-heart"></i></a>
</div>
<?php
}
/*
*
* 投票HTML
*
*/
function dmeng_vote_html($type,$id){
$type = $type=='post' ? 'post' : 'comment';
$vote_class = 'btn-group vote-group';
$up_class = 'btn btn-default up';
$down_class = 'btn btn-default down';
$up_html = '<span class="glyphicon glyphicon-thumbs-up"></span>';
$down_html = '<span class="glyphicon glyphicon-thumbs-down"></span>';
$type_html = 'data-vote-type="post" itemscope itemtype="http://data-vocabulary.org/Review-aggregate"';
if($type=='comment'){
$vote_class = 'comment-votes vote-group';
$up_class = 'up';
$down_class = 'down';
$up_html = '<span class="fa fa-thumbs-o-up"></span>';
$down_html = '<span class="fa fa-thumbs-o-down"></span>';
$type_html = '';
}
$key = 'vote_'.$type.'_'.$id;
$uid = get_current_user_id();
if($uid>0){
$vote = get_dmeng_meta($key,$uid);
if($vote){
$vote_class .= ' disabled';
if($vote=='up') $up_class .= ' highlight';
elseif($vote=='down') $down_class .= ' highlight';
}
}
if($type==='post'||$type==='comment'){
$votes_up = (int)get_metadata($type, $id, 'dmeng_votes_up', true);
$votes_down = (int)get_metadata($type, $id, 'dmeng_votes_down', true);
}
//$votes = $votes_up-$votes_down;
?><div class="<?php echo $vote_class;?>" data-votes-up="<?php echo $votes_up;?>" data-votes-down="<?php echo $votes_down;?>" data-vote-id="<?php echo $id; ?>" <?php echo $type_html; ?>>
<a href="javascript:;" class="<?php echo $up_class;?>"><?php echo $up_html;?> <span class="votes"><?php echo $votes_up;?></span><?php
if($type=='post'){
$count = $votes_up+$votes_down;
//~ 投票计算得分,最低1分,最高10分,四舍五入留一个小数点(用于微数据 for microdata)
$rating = ($votes_up+$votes_down)>0 ? round($votes_up/($votes_up+$votes_down)*5, 1) : 0;
if($rating<1) $rating = 1;
echo '<div class="hide" itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span itemprop="average">'.$rating.'</span><span itemprop="votes">'.$count.'</span><span itemprop="count">'.get_comments_number().'</span></div>';
}
?></a>
<a href="javascript:;" class="<?php echo $down_class;?>"><?php echo $down_html;?> <span class="votes"><?php echo $votes_down;?></span></a>
</div><?php
}
/*
*
* 投票AJAX
*
*/
function dmeng_vote_ajax_callback(){
do_action( 'dmeng_before_ajax', false, false );
if ( !isset($_POST['type']) || !isset($_POST['id']) || !isset($_POST['vote']) ) return;
$type = sanitize_text_field($_POST['type']);
$id = intval($_POST['id']);
$vote = sanitize_text_field($_POST['vote']);
$key = 'vote_'.$type.'_'.$id;
$uid = get_current_user_id();
if($uid===0){
add_dmeng_meta($key,$vote,$uid);
}else{
update_dmeng_meta($key,$vote,$uid);
}
//~ 为了便于列表应用和排序,up和down各保存一个总数到wordpress的原有meta表(postmeta/commentmeta)
if($type==='post'||$type==='comment'){
if($vote=='up') update_metadata($type, $id, 'dmeng_votes_up', (int)get_dmeng_meta_count($key,'up'));
if($vote=='down') update_metadata($type, $id, 'dmeng_votes_down', (int)get_dmeng_meta_count($key,'down'));
}
echo 'ok';
die();
}
add_action( 'wp_ajax_dmeng_vote_ajax', 'dmeng_vote_ajax_callback' );
add_action( 'wp_ajax_nopriv_dmeng_vote_ajax', 'dmeng_vote_ajax_callback' );
| zhulukun/bocool | inc/vote.php | PHP | mit | 5,386 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
100,
100,
100,
100,
1760,
100,
1745,
100,
1989,
100,
100,
100,
100,
100,
100,
100,
100,
1747,
100,
1916,
1760,
100,
1989,
100,
1855,
100,
100,
100,
1873,
100,
100,
1916,
1747,
100,
100,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
;Imports of r_xsurface_load_obj:
extern Hunk_AllocateTempMemory
extern memcpy
extern XSurfaceTransfer
extern Hunk_FreeTempMemory
extern r_modelVertColor
extern malloc
extern ClearBounds
extern AddPointToBounds
extern ExpandBounds
extern BuildAabbTree
extern free
;Exports of r_xsurface_load_obj:
global XModelReadSurface
global XModelReadSurface_BuildCollisionTree
SECTION .text
;XModelReadSurface(XModel*, unsigned char const**, void* (*)(int), XSurface*)
XModelReadSurface:
push ebp
mov ebp, esp
push edi
push esi
push ebx
sub esp, 0x69c
mov esi, [ebp+0xc]
mov dword [ebp-0x2c], 0x0
mov dword [ebp-0x28], 0x0
mov dword [ebp-0x24], 0x0
mov dword [ebp-0x20], 0x0
mov eax, [esi]
movzx eax, byte [eax]
mov edx, [ebp+0x14]
mov [edx], al
mov eax, [esi]
lea edx, [eax+0x1]
mov [esi], edx
movzx edx, word [eax+0x1]
mov [ebp-0x1c], dx
lea edx, [eax+0x3]
mov [esi], edx
movzx edx, word [eax+0x3]
mov [ebp-0x1c], dx
add eax, 0x5
mov [esi], eax
mov ecx, [ebp+0x14]
mov [ecx+0x2], dx
mov eax, [esi]
movzx edx, word [eax]
mov [ebp-0x1c], dx
add eax, 0x2
mov [esi], eax
mov [ecx+0x4], dx
mov dword [ebp-0x674], 0x0
xor edi, edi
lea ebx, [ebp-0x638]
jmp XModelReadSurface_10
XModelReadSurface_20:
movsx eax, word [ecx+0x2]
mov [ebp-0x1c], ax
lea edx, [ecx+0x4]
mov [esi], edx
shl eax, 0x6
mov [ebx], ax
movzx eax, word [ebx+0x2]
add edi, eax
add dword [ebp-0x674], 0x1
add ebx, 0xc
XModelReadSurface_10:
mov ecx, [esi]
movzx edx, word [ecx]
mov [ebp-0x1c], dx
lea eax, [ecx+0x2]
mov [esi], eax
mov [ebx+0x2], dx
test dx, dx
jnz XModelReadSurface_20
mov eax, [ebp+0x14]
movzx ebx, word [eax+0x2]
cmp ebx, edi
setnz byte [ebp-0x675]
cmp byte [ebp-0x675], 0x0
mov eax, 0x0
cmovz eax, [ebp-0x674]
mov [ebp-0x674], eax
movzx edx, byte [ebp-0x675]
mov ecx, [ebp+0x14]
mov [ecx+0x1], dl
sub eax, 0x1
jz XModelReadSurface_30
mov eax, [esi]
movsx edx, word [eax]
mov [ebp-0x1c], dx
add eax, 0x2
mov [esi], eax
mov eax, edx
movzx ebx, word [ecx+0x2]
shl ebx, 0x4
lea eax, [ebx+eax]
shl eax, 0x2
mov [esp], eax
call Hunk_AllocateTempMemory
mov [ebp-0x67c], eax
mov edi, eax
mov ebx, [ebp+0x14]
cmp word [ebx+0x2], 0x0
jnz XModelReadSurface_40
XModelReadSurface_390:
mov ecx, ebx
XModelReadSurface_470:
movzx eax, word [ecx+0x4]
lea ebx, [eax+0x1]
and ebx, 0xfffffffe
mov [ebp-0x680], ebx
lea eax, [eax+eax*2]
lea eax, [eax+eax+0x6]
mov [esp], eax
call dword [ebp+0x10]
mov edx, [ebp+0x14]
mov [edx+0xc], eax
movzx ebx, word [edx+0x4]
lea eax, [ebx+ebx*2]
test eax, eax
jg XModelReadSurface_50
mov dword [ebp-0x684], 0x0
XModelReadSurface_500:
mov esi, [ebp-0x674]
test esi, esi
jle XModelReadSurface_60
mov dword [ebp-0x640], 0x0
xor edi, edi
mov dword [ebp-0x650], 0x0
lea ecx, [ebp-0x638]
mov [ebp-0x64c], ecx
mov esi, ecx
mov [esi+0x4], di
movzx eax, word [esi+0x2]
add [ebp-0x650], eax
cmp edi, ebx
jge XModelReadSurface_70
XModelReadSurface_100:
mov eax, [ebp+0x14]
mov ecx, [eax+0xc]
lea eax, [edi+edi*2]
lea edx, [eax+eax]
movzx eax, word [edx+ecx]
cmp [ebp-0x650], eax
jle XModelReadSurface_70
lea ecx, [edx+ecx]
mov edx, edi
mov esi, ebx
XModelReadSurface_90:
add edx, 0x1
cmp esi, edx
jz XModelReadSurface_80
movzx eax, word [ecx+0x6]
add ecx, 0x6
cmp [ebp-0x650], eax
jg XModelReadSurface_90
XModelReadSurface_80:
mov eax, edx
sub ax, di
mov edi, edx
XModelReadSurface_110:
mov edx, [ebp-0x64c]
mov [edx+0x6], ax
add dword [ebp-0x640], 0x1
add edx, 0xc
mov [ebp-0x64c], edx
mov ecx, [ebp-0x640]
cmp [ebp-0x674], ecx
jz XModelReadSurface_60
mov esi, edx
mov [esi+0x4], di
movzx eax, word [esi+0x2]
add [ebp-0x650], eax
cmp edi, ebx
jl XModelReadSurface_100
XModelReadSurface_70:
xor eax, eax
jmp XModelReadSurface_110
XModelReadSurface_60:
cmp [ebp-0x680], ebx
jz XModelReadSurface_120
mov ebx, [ebp+0x14]
mov ecx, [ebx+0xc]
mov eax, [ebp-0x684]
add eax, eax
movzx edx, word [ecx+eax-0x2]
mov [ecx+eax], dx
mov ecx, eax
add ecx, [ebx+0xc]
movzx edx, word [ecx-0x2]
mov [ecx+0x2], dx
add eax, [ebx+0xc]
movzx edx, word [eax-0x2]
mov [eax+0x4], dx
add word [ebx+0x4], 0x1
XModelReadSurface_120:
mov ebx, [ebp-0x674]
test ebx, ebx
jnz XModelReadSurface_130
xor eax, eax
xor ebx, ebx
XModelReadSurface_480:
mov edx, [ebp+0x14]
mov [edx+0x24], eax
mov ecx, [ebp-0x674]
mov [edx+0x20], ecx
mov [esp+0x8], ebx
lea ebx, [ebp-0x638]
mov [esp+0x4], ebx
mov [esp], eax
call memcpy
mov esi, [ebp+0x14]
movzx ebx, word [esi+0x2]
shl ebx, 0x5
mov [esp], ebx
call dword [ebp+0x10]
mov [esi+0x1c], eax
mov eax, [ebp+0x8]
add [eax+0xcc], ebx
mov edx, [esi+0x1c]
movzx eax, word [esi+0x2]
mov [esp+0xc], eax
mov [esp+0x8], edx
mov [esp+0x4], edx
mov edx, [ebp-0x67c]
mov [esp], edx
call XSurfaceTransfer
cmp byte [ebp-0x675], 0x0
jz XModelReadSurface_140
mov eax, [ebp-0x2c]
test eax, eax
jnz XModelReadSurface_150
mov dword [ebp-0x660], 0x0
mov eax, [ebp-0x28]
test eax, eax
jnz XModelReadSurface_160
XModelReadSurface_530:
mov dword [ebp-0x65c], 0x0
mov eax, [ebp-0x24]
test eax, eax
jnz XModelReadSurface_170
XModelReadSurface_540:
mov dword [ebp-0x658], 0x0
mov edx, [ebp-0x20]
test edx, edx
jnz XModelReadSurface_180
XModelReadSurface_550:
mov dword [ebp-0x654], 0x0
XModelReadSurface_560:
mov edx, [ebp+0x14]
mov ecx, 0x1
lea ebx, [ebp-0x2c]
XModelReadSurface_190:
mov eax, [ebx+ecx*4-0x4]
mov [edx+0x10], ax
add ecx, 0x1
add edx, 0x2
cmp ecx, 0x5
jnz XModelReadSurface_190
mov edi, [ebp-0x67c]
mov ecx, [ebp+0x14]
cmp word [ecx+0x2], 0x0
jz XModelReadSurface_200
mov ebx, [ebp-0x660]
mov [ebp-0x670], ebx
mov esi, [ebp-0x65c]
mov [ebp-0x66c], esi
mov eax, [ebp-0x658]
mov [ebp-0x668], eax
mov edx, [ebp-0x654]
mov [ebp-0x664], edx
mov dword [ebp-0x63c], 0x0
XModelReadSurface_260:
movzx eax, byte [edi+0x3c]
cmp al, 0x1
jz XModelReadSurface_210
jb XModelReadSurface_220
cmp al, 0x2
jz XModelReadSurface_230
mov edx, [ebp-0x664]
lea ecx, [edx+0x2]
lea ebx, [edx+0xe]
mov [ebp-0x664], ebx
XModelReadSurface_380:
movzx eax, word [edi+0x3e]
mov [edx], ax
movzx eax, byte [edi+0x3c]
add edi, 0x40
test al, al
jz XModelReadSurface_240
movzx esi, al
test esi, esi
jle XModelReadSurface_240
mov edx, edi
xor ebx, ebx
XModelReadSurface_250:
movzx eax, word [edx]
mov [ecx], ax
movzx eax, word [edx+0x2]
mov [ecx+0x2], ax
add ecx, 0x4
add edx, 0x4
add ebx, 0x1
cmp ebx, esi
jnz XModelReadSurface_250
mov edi, edx
XModelReadSurface_240:
add dword [ebp-0x63c], 0x1
mov edx, [ebp+0x14]
movzx eax, word [edx+0x2]
cmp [ebp-0x63c], eax
jl XModelReadSurface_260
mov ebx, edx
XModelReadSurface_520:
movsx ecx, word [ebx+0x10]
movsx edx, word [ebx+0x14]
lea edx, [edx+edx*4]
movsx eax, word [ebx+0x12]
lea eax, [eax+eax*2]
add edx, eax
add ecx, edx
movsx edx, word [ebx+0x16]
lea eax, [edx*8]
sub eax, edx
add ecx, eax
mov ebx, ecx
add ebx, ebx
jnz XModelReadSurface_270
xor ecx, ecx
XModelReadSurface_650:
mov esi, [ebp+0x8]
add [esi+0xcc], ebx
mov eax, [ebp+0x14]
mov [eax+0x18], ecx
cmp word [eax+0x10], 0x0
jz XModelReadSurface_280
jg XModelReadSurface_290
XModelReadSurface_280:
mov eax, [ebp+0x14]
XModelReadSurface_580:
cmp word [eax+0x12], 0x0
jz XModelReadSurface_300
jg XModelReadSurface_310
XModelReadSurface_300:
mov eax, [ebp+0x14]
XModelReadSurface_640:
cmp word [eax+0x14], 0x0
jz XModelReadSurface_320
jg XModelReadSurface_330
XModelReadSurface_320:
mov eax, [ebp+0x14]
XModelReadSurface_620:
cmp word [eax+0x16], 0x0
jz XModelReadSurface_140
jg XModelReadSurface_340
XModelReadSurface_140:
mov eax, [ebp+0x14]
XModelReadSurface_600:
mov ecx, [eax+0x20]
test ecx, ecx
jz XModelReadSurface_350
xor ebx, ebx
mov ecx, [ebp+0x14]
jmp XModelReadSurface_360
XModelReadSurface_370:
mov ecx, esi
XModelReadSurface_360:
mov edx, [ebp+0x10]
mov [esp+0x8], edx
mov [esp+0x4], ebx
mov [esp], ecx
call XModelReadSurface_BuildCollisionTree
add ebx, 0x1
mov esi, [ebp+0x14]
cmp ebx, [esi+0x20]
jnz XModelReadSurface_370
XModelReadSurface_350:
mov eax, [ebp-0x67c]
mov [esp], eax
call Hunk_FreeTempMemory
add esp, 0x69c
pop ebx
pop esi
pop edi
pop ebp
ret
XModelReadSurface_220:
mov edx, [ebp-0x670]
mov esi, edx
add esi, 0x2
mov [ebp-0x670], esi
xor ecx, ecx
jmp XModelReadSurface_380
XModelReadSurface_210:
mov edx, [ebp-0x66c]
lea ecx, [edx+0x2]
lea eax, [edx+0x6]
mov [ebp-0x66c], eax
jmp XModelReadSurface_380
XModelReadSurface_30:
movzx ecx, word [ebp-0x638]
shr cx, 0x6
movzx ecx, cx
mov edx, ecx
sar edx, 0x5
and ecx, 0x1f
mov eax, 0x80000000
shr eax, cl
mov ecx, [ebp+0x14]
or [ecx+edx*4+0x28], eax
xor eax, eax
shl ebx, 0x4
lea eax, [ebx+eax]
shl eax, 0x2
mov [esp], eax
call Hunk_AllocateTempMemory
mov [ebp-0x67c], eax
mov edi, eax
mov ebx, [ebp+0x14]
cmp word [ebx+0x2], 0x0
jz XModelReadSurface_390
XModelReadSurface_40:
mov dword [ebp-0x688], 0x0
lea eax, [ebx+0x28]
mov [ebp-0x690], eax
jmp XModelReadSurface_400
XModelReadSurface_450:
mov dword [edi+0xc], 0xffffffff
XModelReadSurface_460:
mov eax, [esi]
lea edx, [eax+0x4]
mov [esi], edx
mov edx, [eax+0x4]
mov [ebp-0x1c], edx
add eax, 0x8
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x1c], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x2c], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x10], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x14], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x18], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x20], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x24], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x28], eax
cmp dword [ebp-0x674], 0x1
jz XModelReadSurface_410
mov eax, [esi]
movzx ecx, byte [eax]
mov [ebp-0x641], cl
add eax, 0x1
mov [esi], eax
mov [edi+0x3c], cl
movzx ebx, cl
mov [ebp-0x648], ebx
add dword [ebp+ebx*4-0x2c], 0x1
mov edx, [esi]
movsx eax, word [edx]
mov [ebp-0x1c], ax
add edx, 0x2
mov [esi], edx
mov ebx, eax
sar ebx, 0x5
mov ecx, eax
and ecx, 0x1f
mov edx, 0x80000000
shr edx, cl
mov ecx, [ebp+0x14]
or [ecx+ebx*4+0x28], edx
shl eax, 0x6
mov [edi+0x3e], ax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x30], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x34], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x38], eax
add edi, 0x40
cmp byte [ebp-0x641], 0x0
jz XModelReadSurface_420
mov eax, [ebp-0x648]
test eax, eax
jg XModelReadSurface_430
XModelReadSurface_420:
add dword [ebp-0x688], 0x1
mov edx, [ebp+0x14]
movzx eax, word [edx+0x2]
cmp [ebp-0x688], eax
jge XModelReadSurface_440
XModelReadSurface_400:
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x4], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x8], eax
mov edx, r_modelVertColor
mov eax, [edx]
cmp byte [eax+0xc], 0x0
jz XModelReadSurface_450
mov ecx, [esi]
movzx edx, byte [ecx+0x2]
shl edx, 0x10
movzx eax, byte [ecx+0x1]
shl eax, 0x8
or edx, eax
movzx eax, byte [ecx]
or edx, eax
movzx eax, byte [ecx+0x3]
shl eax, 0x18
or edx, eax
mov [edi+0xc], edx
jmp XModelReadSurface_460
XModelReadSurface_410:
mov byte [edi+0x3c], 0x0
movzx eax, word [ebp-0x638]
mov [edi+0x3e], ax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x30], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x34], eax
mov eax, [esi]
mov edx, [eax]
mov [ebp-0x1c], edx
add eax, 0x4
mov [esi], eax
mov eax, [ebp-0x1c]
mov [edi+0x38], eax
add edi, 0x40
add dword [ebp-0x688], 0x1
mov edx, [ebp+0x14]
movzx eax, word [edx+0x2]
cmp [ebp-0x688], eax
jl XModelReadSurface_400
XModelReadSurface_440:
mov ecx, edx
jmp XModelReadSurface_470
XModelReadSurface_130:
mov esi, [ebp-0x674]
lea eax, [esi+esi*2]
lea ebx, [eax*4]
mov [esp], ebx
call dword [ebp+0x10]
jmp XModelReadSurface_480
XModelReadSurface_50:
mov dword [ebp-0x684], 0x0
XModelReadSurface_490:
mov ebx, [ebp+0x14]
mov ecx, [ebx+0xc]
mov eax, [esi]
movzx edx, word [eax]
mov [ebp-0x1c], dx
add eax, 0x2
mov [esi], eax
mov eax, [ebp-0x684]
mov [ecx+eax*2], dx
add eax, 0x1
mov [ebp-0x684], eax
mov edx, [ebp+0x14]
movzx ebx, word [edx+0x4]
lea eax, [ebx+ebx*2]
cmp eax, [ebp-0x684]
jg XModelReadSurface_490
jmp XModelReadSurface_500
XModelReadSurface_430:
mov dword [ebp-0x68c], 0x0
XModelReadSurface_510:
mov edx, [esi]
movsx eax, word [edx]
mov [ebp-0x1c], ax
add edx, 0x2
mov [esi], edx
mov ebx, eax
sar ebx, 0x5
mov ecx, eax
and ecx, 0x1f
mov edx, 0x80000000
shr edx, cl
mov ecx, [ebp-0x690]
or [ecx+ebx*4], edx
shl eax, 0x6
mov [edi], ax
mov eax, [esi]
movzx edx, word [eax]
mov [ebp-0x1c], dx
add eax, 0x2
mov [esi], eax
mov [edi+0x2], dx
add edi, 0x4
add dword [ebp-0x68c], 0x1
mov ebx, [ebp-0x68c]
cmp [ebp-0x648], ebx
jnz XModelReadSurface_510
jmp XModelReadSurface_420
XModelReadSurface_200:
mov ebx, ecx
jmp XModelReadSurface_520
XModelReadSurface_230:
mov edx, [ebp-0x668]
mov ecx, edx
add ecx, 0x2
add dword [ebp-0x668], 0xa
jmp XModelReadSurface_380
XModelReadSurface_150:
add eax, eax
mov [esp], eax
call dword [ebp+0x10]
mov [ebp-0x660], eax
mov eax, [ebp-0x28]
test eax, eax
jz XModelReadSurface_530
XModelReadSurface_160:
lea eax, [eax+eax*2]
add eax, eax
mov [esp], eax
call dword [ebp+0x10]
mov [ebp-0x65c], eax
mov eax, [ebp-0x24]
test eax, eax
jz XModelReadSurface_540
XModelReadSurface_170:
lea eax, [eax+eax*4]
add eax, eax
mov [esp], eax
call dword [ebp+0x10]
mov [ebp-0x658], eax
mov edx, [ebp-0x20]
test edx, edx
jz XModelReadSurface_550
XModelReadSurface_180:
lea eax, [edx+edx]
shl edx, 0x4
sub edx, eax
mov [esp], edx
call dword [ebp+0x10]
mov [ebp-0x654], eax
jmp XModelReadSurface_560
XModelReadSurface_290:
mov ebx, [ebp-0x660]
xor edx, edx
XModelReadSurface_570:
movzx eax, word [ebx]
mov [ecx], ax
add ecx, 0x2
add edx, 0x1
add ebx, 0x2
mov esi, [ebp+0x14]
movsx eax, word [esi+0x10]
cmp eax, edx
jg XModelReadSurface_570
mov eax, esi
jmp XModelReadSurface_580
XModelReadSurface_340:
mov edx, [ebp-0x654]
xor ebx, ebx
XModelReadSurface_590:
movzx eax, word [edx]
mov [ecx], ax
movzx eax, word [edx+0x2]
mov [ecx+0x2], ax
movzx eax, word [edx+0x4]
mov [ecx+0x4], ax
movzx eax, word [edx+0x6]
mov [ecx+0x6], ax
movzx eax, word [edx+0x8]
mov [ecx+0x8], ax
movzx eax, word [edx+0xa]
mov [ecx+0xa], ax
movzx eax, word [edx+0xc]
mov [ecx+0xc], ax
add ecx, 0xe
add ebx, 0x1
add edx, 0xe
mov esi, [ebp+0x14]
movsx eax, word [esi+0x16]
cmp ebx, eax
jl XModelReadSurface_590
mov eax, esi
jmp XModelReadSurface_600
XModelReadSurface_330:
mov edx, [ebp-0x658]
xor ebx, ebx
XModelReadSurface_610:
movzx eax, word [edx]
mov [ecx], ax
movzx eax, word [edx+0x2]
mov [ecx+0x2], ax
movzx eax, word [edx+0x4]
mov [ecx+0x4], ax
movzx eax, word [edx+0x6]
mov [ecx+0x6], ax
movzx eax, word [edx+0x8]
mov [ecx+0x8], ax
add ecx, 0xa
add ebx, 0x1
add edx, 0xa
mov esi, [ebp+0x14]
movsx eax, word [esi+0x14]
cmp ebx, eax
jl XModelReadSurface_610
mov eax, esi
jmp XModelReadSurface_620
XModelReadSurface_310:
mov edx, [ebp-0x65c]
xor ebx, ebx
XModelReadSurface_630:
movzx eax, word [edx]
mov [ecx], ax
movzx eax, word [edx+0x2]
mov [ecx+0x2], ax
movzx eax, word [edx+0x4]
mov [ecx+0x4], ax
add ecx, 0x6
add ebx, 0x1
add edx, 0x6
mov esi, [ebp+0x14]
movsx eax, word [esi+0x12]
cmp ebx, eax
jl XModelReadSurface_630
mov eax, esi
jmp XModelReadSurface_640
XModelReadSurface_270:
mov [esp], ebx
call dword [ebp+0x10]
mov ecx, eax
jmp XModelReadSurface_650
add [eax], al
;XModelReadSurface_BuildCollisionTree(XSurface*, unsigned int, void* (*)(int))
XModelReadSurface_BuildCollisionTree:
push ebp
mov ebp, esp
push edi
push esi
push ebx
sub esp, 0x1ac
mov ebx, [ebp+0xc]
lea ebx, [ebx+ebx*2]
mov edx, [ebp+0x8]
mov eax, [edx+0x24]
lea ebx, [eax+ebx*4]
mov dword [esp], 0x28
call dword [ebp+0x10]
mov [ebp-0xb0], eax
mov [ebx+0x8], eax
cld
mov ecx, 0xa
xor eax, eax
lea edi, [ebp-0x88]
rep stosd
mov dword [ebp-0x7c], 0x1
mov dword [esp], 0x20000
call malloc
mov [ebp-0x70], eax
mov dword [ebp-0x6c], 0x2000
mov dword [ebp-0x68], 0x1
mov dword [ebp-0x64], 0x10
lea eax, [ebp-0x30]
mov [esp+0x4], eax
lea edx, [ebp-0x24]
mov [esp], edx
call ClearBounds
mov eax, [ebp-0xb0]
mov dword [eax+0x24], 0x0
movzx edx, word [ebx+0x4]
mov [ebp-0xa4], edx
movzx eax, word [ebx+0x6]
add eax, edx
mov [ebp-0xa0], eax
mov byte [ebp-0x99], 0x0
lea eax, [edx+edx*2]
add eax, eax
mov [ebp-0xb4], eax
lea edi, [ebp-0x54]
jmp XModelReadSurface_BuildCollisionTree_10
XModelReadSurface_BuildCollisionTree_30:
mov dword [ebp-0xa8], 0x0
XModelReadSurface_BuildCollisionTree_60:
cmp byte [ebp-0x99], 0x0
jnz XModelReadSurface_BuildCollisionTree_20
mov ebx, [ebp-0xa8]
add ebx, ebx
mov [esp], ebx
call dword [ebp+0x10]
mov edx, [ebp-0xb0]
mov [edx+0x24], eax
mov eax, [ebp-0xa8]
mov [edx+0x20], eax
add ebx, eax
shl ebx, 0x2
mov [esp], ebx
call malloc
mov [ebp-0x78], eax
mov [esp], ebx
call malloc
mov [ebp-0x74], eax
mov edx, [ebp-0xb0]
mov eax, [edx+0x24]
mov [ebp-0x88], eax
mov eax, [ebp-0xa8]
mov [ebp-0x84], eax
mov dword [ebp-0x80], 0x2
mov byte [ebp-0x99], 0x1
XModelReadSurface_BuildCollisionTree_10:
lea eax, [ebp-0x48]
mov [esp+0x4], eax
lea edx, [ebp-0x3c]
mov [esp], edx
call ClearBounds
mov eax, [ebp-0xa0]
cmp [ebp-0xa4], eax
jz XModelReadSurface_BuildCollisionTree_30
mov ebx, [ebp-0xb4]
mov esi, [ebp-0xa4]
mov byte [ebp-0x9a], 0x0
mov dword [ebp-0xa8], 0x0
mov dword [ebp-0x17c], 0x0
mov dword [ebp-0x180], 0x0
jmp XModelReadSurface_BuildCollisionTree_40
XModelReadSurface_BuildCollisionTree_70:
cmp byte [ebp-0x99], 0x0
jz XModelReadSurface_BuildCollisionTree_50
mov edx, [ebp-0xb0]
mov eax, [edx+0x24]
mov edx, [ebp-0xa8]
mov [eax+edx*2], si
mov edx, [ebp-0x17c]
add edx, [ebp-0x78]
mov eax, [ebp-0x54]
mov [edx], eax
mov eax, [ebp-0x50]
mov [edx+0x4], eax
mov eax, [ebp-0x4c]
mov [edx+0x8], eax
mov edx, [ebp-0x17c]
add edx, [ebp-0x74]
mov eax, [ebp-0x60]
mov [edx], eax
mov eax, [ebp-0x5c]
mov [edx+0x4], eax
mov eax, [ebp-0x58]
mov [edx+0x8], eax
XModelReadSurface_BuildCollisionTree_50:
add dword [ebp-0xa8], 0x1
add dword [ebp-0x180], 0x2
add dword [ebp-0x17c], 0xc
mov eax, [ebp-0x54]
mov [ebp-0x3c], eax
mov eax, [ebp-0x50]
mov [ebp-0x38], eax
mov eax, [ebp-0x4c]
mov [ebp-0x34], eax
mov eax, [ebp-0x60]
mov [ebp-0x48], eax
mov eax, [ebp-0x5c]
mov [ebp-0x44], eax
mov eax, [ebp-0x58]
mov [ebp-0x40], eax
mov byte [ebp-0x9a], 0x1
XModelReadSurface_BuildCollisionTree_90:
add esi, 0x1
add ebx, 0x6
cmp [ebp-0xa0], esi
jz XModelReadSurface_BuildCollisionTree_60
XModelReadSurface_BuildCollisionTree_40:
lea edx, [ebp-0x60]
mov [esp+0x4], edx
mov [esp], edi
call ClearBounds
lea eax, [ebp-0x60]
mov [esp+0x8], eax
mov [esp+0x4], edi
mov edx, [ebp+0x8]
mov eax, [edx+0xc]
movzx eax, word [ebx+eax]
shl eax, 0x5
add eax, [edx+0x1c]
mov [esp], eax
call AddPointToBounds
lea eax, [ebp-0x60]
mov [esp+0x8], eax
mov [esp+0x4], edi
mov edx, [ebp+0x8]
mov eax, [edx+0xc]
movzx eax, word [ebx+eax+0x2]
shl eax, 0x5
add eax, [edx+0x1c]
mov [esp], eax
call AddPointToBounds
lea eax, [ebp-0x60]
mov [esp+0x8], eax
mov [esp+0x4], edi
mov edx, [ebp+0x8]
mov eax, [edx+0xc]
movzx eax, word [ebx+eax+0x4]
shl eax, 0x5
add eax, [edx+0x1c]
mov [esp], eax
call AddPointToBounds
lea eax, [ebp-0x30]
mov [esp+0xc], eax
lea edx, [ebp-0x24]
mov [esp+0x8], edx
lea eax, [ebp-0x60]
mov [esp+0x4], eax
mov [esp], edi
call ExpandBounds
cmp byte [ebp-0x9a], 0x0
jz XModelReadSurface_BuildCollisionTree_70
movss xmm3, dword [ebp-0x40]
subss xmm3, [ebp-0x34]
movss xmm1, dword [ebp-0x48]
subss xmm1, [ebp-0x3c]
movss xmm0, dword [ebp-0x44]
subss xmm0, [ebp-0x38]
mulss xmm1, xmm0
mulss xmm3, xmm1
movss xmm4, dword [ebp-0x58]
subss xmm4, [ebp-0x4c]
movss xmm1, dword [ebp-0x60]
subss xmm1, [ebp-0x54]
movss xmm0, dword [ebp-0x5c]
subss xmm0, [ebp-0x50]
mulss xmm1, xmm0
mulss xmm4, xmm1
lea edx, [ebp-0x48]
mov [esp+0xc], edx
lea eax, [ebp-0x3c]
mov [esp+0x8], eax
lea edx, [ebp-0x60]
mov [esp+0x4], edx
mov [esp], edi
movss [ebp-0x198], xmm3
movss [ebp-0x1a8], xmm4
call ExpandBounds
movss xmm5, dword [ebp-0x3c]
movss xmm2, dword [ebp-0x40]
subss xmm2, [ebp-0x34]
movss xmm1, dword [ebp-0x48]
subss xmm1, xmm5
movss xmm0, dword [ebp-0x44]
subss xmm0, [ebp-0x38]
mulss xmm1, xmm0
mulss xmm2, xmm1
movss xmm3, dword [ebp-0x198]
movss xmm4, dword [ebp-0x1a8]
addss xmm3, xmm4
ucomiss xmm3, xmm2
jb XModelReadSurface_BuildCollisionTree_70
cmp byte [ebp-0x99], 0x0
jz XModelReadSurface_BuildCollisionTree_80
mov eax, [ebp-0x17c]
add eax, [ebp-0x78]
lea edx, [eax-0xc]
movss [eax-0xc], xmm5
mov eax, [ebp-0x38]
mov [edx+0x4], eax
mov eax, [ebp-0x34]
mov [edx+0x8], eax
mov edx, [ebp-0x17c]
add edx, [ebp-0x74]
lea ecx, [edx-0xc]
mov eax, [ebp-0x48]
mov [edx-0xc], eax
mov eax, [ebp-0x44]
mov [ecx+0x4], eax
mov eax, [ebp-0x40]
mov [ecx+0x8], eax
mov eax, [ebp-0x180]
mov edx, [ebp-0xb0]
add eax, [edx+0x24]
sub word [eax-0x2], 0x8000
XModelReadSurface_BuildCollisionTree_80:
mov byte [ebp-0x9a], 0x0
jmp XModelReadSurface_BuildCollisionTree_90
XModelReadSurface_BuildCollisionTree_20:
movss xmm1, dword [_data16_80000000]
movss xmm0, dword [ebp-0x24]
xorps xmm0, xmm1
mov edx, [ebp-0xb0]
movss [edx], xmm0
movss xmm0, dword [ebp-0x20]
xorps xmm0, xmm1
movss [edx+0x4], xmm0
movss xmm0, dword [ebp-0x1c]
xorps xmm0, xmm1
movss [edx+0x8], xmm0
movss xmm2, dword [ebp-0x2c]
subss xmm2, [ebp-0x20]
movss xmm3, dword [ebp-0x28]
subss xmm3, [ebp-0x1c]
movss xmm1, dword [ebp-0x30]
subss xmm1, [ebp-0x24]
movss xmm0, dword [_float_65535_00000000]
movaps xmm4, xmm0
divss xmm4, xmm1
movss [edx+0xc], xmm4
movaps xmm1, xmm0
divss xmm1, xmm2
movss [edx+0x10], xmm1
divss xmm0, xmm3
movss [edx+0x14], xmm0
lea eax, [ebp-0x88]
mov [esp], eax
call BuildAabbTree
mov [ebp-0xac], eax
mov edx, [ebp-0xb0]
mov [edx+0x18], eax
mov eax, [ebp-0xac]
shl eax, 0x4
add eax, 0xf
mov [esp], eax
call dword [ebp+0x10]
add eax, 0xf
and eax, 0xfffffff0
mov edx, [ebp-0xb0]
mov [edx+0x1c], eax
mov edx, [ebp-0xac]
test edx, edx
jz XModelReadSurface_BuildCollisionTree_100
mov dword [ebp-0x98], 0x0
mov dword [ebp-0x8c], 0x0
XModelReadSurface_BuildCollisionTree_200:
mov edx, [ebp-0x8c]
mov eax, [ebp-0xb0]
add edx, [eax+0x1c]
mov [ebp-0x94], edx
mov eax, [ebp-0x8c]
add eax, [ebp-0x70]
mov [ebp-0x90], eax
mov esi, [eax]
add esi, [eax+0x4]
lea edx, [ebp-0x54]
mov [esp+0x4], edx
lea eax, [ebp-0x60]
mov [esp], eax
call ClearBounds
mov eax, [ebp-0x90]
mov edx, [eax]
cmp esi, edx
jz XModelReadSurface_BuildCollisionTree_110
lea eax, [edx+edx*2]
lea ebx, [eax*4]
xor edi, edi
sub esi, edx
XModelReadSurface_BuildCollisionTree_120:
lea edx, [ebp-0x54]
mov [esp+0xc], edx
lea eax, [ebp-0x60]
mov [esp+0x8], eax
mov eax, ebx
add eax, [ebp-0x74]
mov [esp+0x4], eax
mov eax, ebx
add eax, [ebp-0x78]
mov [esp], eax
call ExpandBounds
add edi, 0x1
add ebx, 0xc
cmp edi, esi
jnz XModelReadSurface_BuildCollisionTree_120
XModelReadSurface_BuildCollisionTree_110:
movss xmm0, dword [ebp-0x60]
mov edx, [ebp-0xb0]
addss xmm0, [edx]
mulss xmm0, [edx+0xc]
movss xmm6, dword [_float_0_50000000]
subss xmm0, xmm6
xorps xmm1, xmm1
maxss xmm0, xmm1
movss xmm4, dword [_data16_4f000000]
movaps xmm3, xmm4
cmpss xmm3, xmm0, 0x2
movss xmm5, dword [_data16_4f800000]
movaps xmm1, xmm5
cmpss xmm1, xmm0, 0x2
movaps xmm2, xmm3
andps xmm2, xmm4
pslld xmm3, 0x1f
subps xmm0, xmm2
cvttps2dq xmm0, xmm0
paddd xmm0, xmm3
por xmm0, xmm1
movdqa [ebp-0xd8], xmm0
mov eax, [ebp-0xd8]
test eax, eax
js XModelReadSurface_BuildCollisionTree_130
mov edx, 0xffffffff
cmp eax, 0x10000
cmovl edx, eax
XModelReadSurface_BuildCollisionTree_270:
mov eax, [ebp-0x94]
mov [eax], dx
movss xmm0, dword [ebp-0x5c]
mov edx, [ebp-0xb0]
addss xmm0, [edx+0x4]
mulss xmm0, [edx+0x10]
subss xmm0, xmm6
xorps xmm1, xmm1
maxss xmm0, xmm1
movaps xmm2, xmm4
cmpss xmm2, xmm0, 0x2
movaps xmm1, xmm5
cmpss xmm1, xmm0, 0x2
movaps xmm3, xmm2
andps xmm3, xmm4
pslld xmm2, 0x1f
subps xmm0, xmm3
cvttps2dq xmm0, xmm0
paddd xmm0, xmm2
por xmm0, xmm1
movdqa [ebp-0xf8], xmm0
mov eax, [ebp-0xf8]
test eax, eax
js XModelReadSurface_BuildCollisionTree_140
mov edx, 0xffffffff
cmp eax, 0x10000
cmovl edx, eax
XModelReadSurface_BuildCollisionTree_260:
mov eax, [ebp-0x94]
mov [eax+0x2], dx
movss xmm0, dword [ebp-0x58]
mov edx, [ebp-0xb0]
addss xmm0, [edx+0x8]
mulss xmm0, [edx+0x14]
subss xmm0, xmm6
xorps xmm1, xmm1
maxss xmm0, xmm1
movaps xmm2, xmm4
cmpss xmm2, xmm0, 0x2
movaps xmm1, xmm5
cmpss xmm1, xmm0, 0x2
movaps xmm3, xmm2
andps xmm3, xmm4
pslld xmm2, 0x1f
subps xmm0, xmm3
cvttps2dq xmm0, xmm0
paddd xmm0, xmm2
por xmm0, xmm1
movdqa [ebp-0x118], xmm0
mov eax, [ebp-0x118]
test eax, eax
js XModelReadSurface_BuildCollisionTree_150
mov edx, 0xffffffff
cmp eax, 0x10000
cmovl edx, eax
XModelReadSurface_BuildCollisionTree_250:
mov eax, [ebp-0x94]
mov [eax+0x4], dx
movss xmm0, dword [ebp-0x54]
mov edx, [ebp-0xb0]
addss xmm0, [edx]
mulss xmm0, [edx+0xc]
addss xmm0, xmm6
xorps xmm1, xmm1
maxss xmm0, xmm1
movaps xmm2, xmm4
cmpss xmm2, xmm0, 0x2
movaps xmm1, xmm5
cmpss xmm1, xmm0, 0x2
movaps xmm3, xmm2
andps xmm3, xmm4
pslld xmm2, 0x1f
subps xmm0, xmm3
cvttps2dq xmm0, xmm0
paddd xmm0, xmm2
por xmm0, xmm1
movdqa [ebp-0x138], xmm0
mov eax, [ebp-0x138]
test eax, eax
js XModelReadSurface_BuildCollisionTree_160
mov edx, 0xffffffff
cmp eax, 0x10000
cmovl edx, eax
XModelReadSurface_BuildCollisionTree_240:
mov eax, [ebp-0x94]
mov [eax+0x6], dx
movss xmm0, dword [ebp-0x50]
mov edx, [ebp-0xb0]
addss xmm0, [edx+0x4]
mulss xmm0, [edx+0x10]
addss xmm0, xmm6
xorps xmm1, xmm1
maxss xmm0, xmm1
movaps xmm2, xmm4
cmpss xmm2, xmm0, 0x2
movaps xmm1, xmm5
cmpss xmm1, xmm0, 0x2
movaps xmm3, xmm2
andps xmm3, xmm4
pslld xmm2, 0x1f
subps xmm0, xmm3
cvttps2dq xmm0, xmm0
paddd xmm0, xmm2
por xmm0, xmm1
movdqa [ebp-0x158], xmm0
mov eax, [ebp-0x158]
test eax, eax
js XModelReadSurface_BuildCollisionTree_170
mov edx, 0xffffffff
cmp eax, 0x10000
cmovl edx, eax
XModelReadSurface_BuildCollisionTree_230:
mov eax, [ebp-0x94]
mov [eax+0x8], dx
movss xmm0, dword [ebp-0x4c]
mov edx, [ebp-0xb0]
addss xmm0, [edx+0x8]
mulss xmm0, [edx+0x14]
addss xmm0, xmm6
xorps xmm1, xmm1
maxss xmm0, xmm1
movaps xmm2, xmm4
cmpss xmm2, xmm0, 0x2
movaps xmm1, xmm5
cmpss xmm1, xmm0, 0x2
movaps [ebp-0x168], xmm1
movaps xmm1, xmm4
andps xmm1, xmm2
pslld xmm2, 0x1f
subps xmm0, xmm1
cvttps2dq xmm0, xmm0
paddd xmm0, xmm2
por xmm0, [ebp-0x168]
movdqa [ebp-0x178], xmm0
mov eax, [ebp-0x178]
test eax, eax
js XModelReadSurface_BuildCollisionTree_180
mov edx, 0xffffffff
cmp eax, 0x10000
cmovl edx, eax
XModelReadSurface_BuildCollisionTree_220:
mov eax, [ebp-0x94]
mov [eax+0xa], dx
mov edx, [ebp-0x90]
mov eax, [edx+0xc]
test eax, eax
jz XModelReadSurface_BuildCollisionTree_190
mov eax, [edx+0x8]
mov edx, [ebp-0x94]
mov [edx+0xc], ax
mov edx, [ebp-0x90]
mov eax, [edx+0xc]
mov edx, [ebp-0x94]
mov [edx+0xe], ax
XModelReadSurface_BuildCollisionTree_210:
add dword [ebp-0x98], 0x1
add dword [ebp-0x8c], 0x10
mov eax, [ebp-0x98]
cmp [ebp-0xac], eax
jnz XModelReadSurface_BuildCollisionTree_200
XModelReadSurface_BuildCollisionTree_100:
mov eax, [ebp-0x78]
mov [esp], eax
call free
mov eax, [ebp-0x74]
mov [esp], eax
call free
mov eax, [ebp-0x70]
mov [esp], eax
call free
add esp, 0x1ac
pop ebx
pop esi
pop edi
pop ebp
ret
XModelReadSurface_BuildCollisionTree_190:
mov eax, [edx]
mov edx, [ebp-0x94]
mov [edx+0xc], ax
mov edx, [ebp-0x90]
movzx eax, word [edx+0x4]
sub ax, 0x8000
mov edx, [ebp-0x94]
mov [edx+0xe], ax
jmp XModelReadSurface_BuildCollisionTree_210
XModelReadSurface_BuildCollisionTree_180:
xor edx, edx
jmp XModelReadSurface_BuildCollisionTree_220
XModelReadSurface_BuildCollisionTree_170:
xor edx, edx
jmp XModelReadSurface_BuildCollisionTree_230
XModelReadSurface_BuildCollisionTree_160:
xor edx, edx
jmp XModelReadSurface_BuildCollisionTree_240
XModelReadSurface_BuildCollisionTree_150:
xor edx, edx
jmp XModelReadSurface_BuildCollisionTree_250
XModelReadSurface_BuildCollisionTree_140:
xor edx, edx
jmp XModelReadSurface_BuildCollisionTree_260
XModelReadSurface_BuildCollisionTree_130:
xor edx, edx
jmp XModelReadSurface_BuildCollisionTree_270
;Initialized global or static variables of r_xsurface_load_obj:
SECTION .data
;Initialized constant data of r_xsurface_load_obj:
SECTION .rdata
;Zero initialized global or static variables of r_xsurface_load_obj:
SECTION .bss
;All cstrings:
SECTION .rdata
;All constant floats and doubles:
SECTION .rdata
_float_65535_00000000: dd 0x477fff00 ; 65535
_float_0_50000000: dd 0x3f000000 ; 0.5
align 16,db 0
_data16_80000000: dd 0x80000000, 0x0, 0x0, 0x0 ; DQWORD
_data16_4f000000: dd 0x4f000000, 0x0, 0x0, 0x0 ; DQWORD
_data16_4f800000: dd 0x4f800000, 0x0, 0x0, 0x0 ; DQWORD | D4edalus/CoD4x1.8_Server_Pub | src/asmsource/_r_xsurface_load_obj.asm | Assembly | agpl-3.0 | 30,063 | [
30522,
1025,
17589,
1997,
1054,
1035,
1060,
26210,
12172,
1035,
7170,
1035,
27885,
3501,
1024,
4654,
16451,
15876,
8950,
1035,
2035,
24755,
22513,
6633,
9737,
6633,
10253,
4654,
16451,
2033,
12458,
7685,
4654,
16451,
1060,
26210,
12172,
6494,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.exports = {
"extends": "airbnb",
"parser": "babel-eslint",
"plugins": [
"react"
],
"rules": {
"react/prop-types": 0,
"react/jsx-boolean-value": 0,
"consistent-return": 0,
"guard-for-in": 0,
"no-use-before-define": 0,
"space-before-function-paren": [2, { "anonymous": "never", "named": "always" }]
}
};
| danieloliveira079/healthy-life-app-v1 | .eslintrc.js | JavaScript | mit | 351 | [
30522,
11336,
1012,
14338,
1027,
1063,
1000,
8908,
1000,
1024,
1000,
2250,
24700,
2497,
1000,
1010,
1000,
11968,
8043,
1000,
1024,
1000,
11561,
2140,
1011,
9686,
4115,
2102,
1000,
1010,
1000,
13354,
7076,
1000,
1024,
1031,
1000,
10509,
1000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package seedu.address.logic.commands;
import seedu.address.commons.core.IndexPrefix;
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.Model;
import seedu.address.model.task.DeadlineTask;
import seedu.address.model.task.DeadlineTaskBuilder;
public class MarkDeadlineUnfinishedCommand implements Command {
private static final String MSG_SUCCESS = "Deadline task " + IndexPrefix.DEADLINE.getPrefixString()
+ "%s unfinished.";
private final int targetIndex;
public MarkDeadlineUnfinishedCommand(int targetIndex) {
this.targetIndex = targetIndex;
}
public int getTargetIndex() {
return targetIndex;
}
@Override
public CommandResult execute(Model model) throws CommandException {
assert model != null;
final DeadlineTask oldDeadlineTask;
try {
oldDeadlineTask = model.getDeadlineTask(targetIndex);
} catch (IllegalValueException e) {
throw new CommandException(e);
}
final DeadlineTask finishedDeadlineTask = new DeadlineTaskBuilder(oldDeadlineTask)
.setFinished(false)
.build();
try {
model.setDeadlineTask(targetIndex, finishedDeadlineTask);
} catch (IllegalValueException e) {
throw new AssertionError("The target deadline cannot be missing", e);
}
return new CommandResult(String.format(MSG_SUCCESS, targetIndex));
}
}
| snehasp13/main | src/main/java/seedu/address/logic/commands/MarkDeadlineUnfinishedCommand.java | Java | mit | 1,602 | [
30522,
7427,
6534,
2226,
1012,
4769,
1012,
7961,
1012,
10954,
1025,
12324,
6534,
2226,
1012,
4769,
1012,
7674,
1012,
4563,
1012,
5950,
28139,
8873,
2595,
1025,
12324,
6534,
2226,
1012,
4769,
1012,
7674,
1012,
11790,
1012,
6206,
10175,
5657,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tensor utility functions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import variables
__all__ = [
'assert_same_float_dtype',
'assert_scalar_int',
'convert_to_tensor_or_sparse_tensor',
'is_tensor',
'reduce_sum_n',
'with_shape',
'with_same_shape']
def _assert_same_base_type(items, expected_type=None):
r"""Asserts all items are of the same base type.
Args:
items: List of graph items (e.g., `Variable`, `Tensor`, `SparseTensor`,
`Operation`, or `IndexedSlices`). Can include `None` elements, which
will be ignored.
expected_type: Expected type. If not specified, assert all items are
of the same base type.
Returns:
Validated type, or none if neither expected_type nor items provided.
Raises:
ValueError: If any types do not match.
"""
original_item_str = None
for item in items:
if item is not None:
item_type = item.dtype.base_dtype
if not expected_type:
expected_type = item_type
original_item_str = item.name if hasattr(item, 'name') else str(item)
elif expected_type != item_type:
raise ValueError('%s, type=%s, must be of the same type (%s)%s.' % (
item.name if hasattr(item, 'name') else str(item),
item_type, expected_type,
(' as %s' % original_item_str) if original_item_str else ''))
return expected_type
def assert_same_float_dtype(tensors=None, dtype=None):
"""Validate and return float type based on `tensors` and `dtype`.
For ops such as matrix multiplication, inputs and weights must be of the
same float type. This function validates that all `tensors` are the same type,
validates that type is `dtype` (if supplied), and returns the type. Type must
be `dtypes.float32` or `dtypes.float64`. If neither `tensors` nor
`dtype` is supplied, default to `dtypes.float32`.
Args:
tensors: Tensors of input values. Can include `None` elements, which will be
ignored.
dtype: Expected type.
Returns:
Validated type.
Raises:
ValueError: if neither `tensors` nor `dtype` is supplied, or result is not
float.
"""
if tensors:
dtype = _assert_same_base_type(tensors, dtype)
if not dtype:
dtype = dtypes.float32
elif not dtype.is_floating:
raise ValueError('Expected float, got %s.' % dtype)
return dtype
def assert_scalar_int(tensor):
"""Assert `tensor` is 0-D, of type `tf.int32` or `tf.int64`.
Args:
tensor: Tensor to test.
Returns:
`tensor`, for chaining.
Raises:
ValueError: if `tensor` is not 0-D, of type `tf.int32` or `tf.int64`.
"""
data_type = tensor.dtype
if data_type.base_dtype not in [dtypes.int32, dtypes.int64]:
raise ValueError('Unexpected type %s for %s.' % (data_type, tensor.name))
shape = tensor.get_shape()
if shape.ndims != 0:
raise ValueError('Unexpected shape %s for %s.' % (shape, tensor.name))
return tensor
def reduce_sum_n(tensors, name=None):
"""Reduce tensors to a scalar sum.
This reduces each tensor in `tensors` to a scalar via `tf.reduce_sum`, then
adds them via `tf.add_n`.
Args:
tensors: List of tensors, all of the same numeric type.
name: Tensor name, and scope for all other ops.
Returns:
Total loss tensor, or None if no losses have been configured.
Raises:
ValueError: if `losses` is missing or empty.
"""
if not tensors:
raise ValueError('No tensors provided.')
tensors = [math_ops.reduce_sum(t, name='%s/sum' % t.op.name) for t in tensors]
if len(tensors) == 1:
return tensors[0]
with ops.name_scope(name, 'reduce_sum_n', tensors) as scope:
return math_ops.add_n(tensors, name=scope)
def _all_equal(tensor0, tensor1):
with ops.name_scope('all_equal', values=[tensor0, tensor1]) as scope:
return math_ops.reduce_all(
math_ops.equal(tensor0, tensor1, name='equal'), name=scope)
def _is_rank(expected_rank, actual_tensor):
"""Returns whether actual_tensor's rank is expected_rank.
Args:
expected_rank: Integer defining the expected rank, or tensor of same.
actual_tensor: Tensor to test.
Returns:
New tensor.
"""
with ops.name_scope('is_rank', values=[actual_tensor]) as scope:
expected = ops.convert_to_tensor(expected_rank, name='expected')
actual = array_ops.rank(actual_tensor, name='actual')
return math_ops.equal(expected, actual, name=scope)
def _is_shape(expected_shape, actual_tensor, actual_shape=None):
"""Returns whether actual_tensor's shape is expected_shape.
Args:
expected_shape: Integer list defining the expected shape, or tensor of same.
actual_tensor: Tensor to test.
actual_shape: Shape of actual_tensor, if we already have it.
Returns:
New tensor.
"""
with ops.name_scope('is_shape', values=[actual_tensor]) as scope:
is_rank = _is_rank(array_ops.size(expected_shape), actual_tensor)
if actual_shape is None:
actual_shape = array_ops.shape(actual_tensor, name='actual')
shape_equal = _all_equal(
ops.convert_to_tensor(expected_shape, name='expected'),
actual_shape)
return math_ops.logical_and(is_rank, shape_equal, name=scope)
def _assert_shape_op(expected_shape, actual_tensor):
"""Asserts actual_tensor's shape is expected_shape.
Args:
expected_shape: List of integers defining the expected shape, or tensor of
same.
actual_tensor: Tensor to test.
Returns:
New assert tensor.
"""
with ops.name_scope('assert_shape', values=[actual_tensor]) as scope:
actual_shape = array_ops.shape(actual_tensor, name='actual')
is_shape = _is_shape(expected_shape, actual_tensor, actual_shape)
return control_flow_ops.Assert(
is_shape, [
'Wrong shape for %s [expected] [actual].' % actual_tensor.name,
expected_shape,
actual_shape
], name=scope)
def with_same_shape(expected_tensor, tensor):
"""Assert tensors are the same shape, from the same graph.
Args:
expected_tensor: Tensor with expected shape.
tensor: Tensor of actual values.
Returns:
Tuple of (actual_tensor, label_tensor), possibly with assert ops added.
"""
with ops.name_scope('%s/' % tensor.op.name, values=[expected_tensor, tensor]):
tensor_shape = expected_tensor.get_shape()
expected_shape = (
tensor_shape.as_list() if tensor_shape.is_fully_defined()
else array_ops.shape(expected_tensor, name='expected_shape'))
return with_shape(expected_shape, tensor)
def is_tensor(x):
"""Check for tensor types.
Check whether an object is a tensor. Equivalent to
`isinstance(x, [tf.Tensor, tf.SparseTensor, tf.Variable])`.
Args:
x: An python object to check.
Returns:
`True` if `x` is a tensor, `False` if not.
"""
tensor_types = (ops.Tensor, ops.SparseTensor, variables.Variable)
return isinstance(x, tensor_types)
def with_shape(expected_shape, tensor):
"""Asserts tensor has expected shape.
If tensor shape and expected_shape, are fully defined, assert they match.
Otherwise, add assert op that will validate the shape when tensor is
evaluated, and set shape on tensor.
Args:
expected_shape: Expected shape to assert, as a 1D array of ints, or tensor
of same.
tensor: Tensor whose shape we're validating.
Returns:
tensor, perhaps with a dependent assert operation.
Raises:
ValueError: if tensor has an invalid shape.
"""
if isinstance(tensor, ops.SparseTensor):
raise ValueError('SparseTensor not supported.')
# Shape type must be 1D int32.
if is_tensor(expected_shape):
if expected_shape.dtype.base_dtype != dtypes.int32:
raise ValueError(
'Invalid dtype %s for shape %s expected of tensor %s.' % (
expected_shape.dtype, expected_shape, tensor.name))
if isinstance(expected_shape, (list, tuple)):
if not expected_shape:
expected_shape = np.asarray([], dtype=np.int32)
else:
np_expected_shape = np.asarray(expected_shape)
expected_shape = (
np.asarray(expected_shape, dtype=np.int32)
if np_expected_shape.dtype == np.int64 else np_expected_shape)
if isinstance(expected_shape, np.ndarray):
if expected_shape.ndim > 1:
raise ValueError(
'Invalid rank %s for shape %s expected of tensor %s.' % (
expected_shape.ndim, expected_shape, tensor.name))
if expected_shape.dtype != np.int32:
raise ValueError(
'Invalid dtype %s for shape %s expected of tensor %s.' % (
expected_shape.dtype, expected_shape, tensor.name))
actual_shape = tensor.get_shape()
if not actual_shape.is_fully_defined() or is_tensor(expected_shape):
with ops.name_scope('%s/' % tensor.op.name, values=[tensor]):
if not is_tensor(expected_shape) and (len(expected_shape) < 1):
# TODO(irving): Remove scalar special case
return array_ops.reshape(tensor, [])
with ops.control_dependencies([_assert_shape_op(expected_shape, tensor)]):
result = array_ops.identity(tensor)
if not is_tensor(expected_shape):
result.set_shape(expected_shape)
return result
if (not is_tensor(expected_shape) and
not actual_shape.is_compatible_with(expected_shape)):
if (len(expected_shape) < 1) and actual_shape.is_compatible_with([1]):
# TODO(irving): Remove scalar special case.
with ops.name_scope('%s/' % tensor.op.name, values=[tensor]):
return array_ops.reshape(tensor, [])
raise ValueError('Invalid shape for tensor %s, expected %s, got %s.' % (
tensor.name, expected_shape, actual_shape))
return tensor
def convert_to_tensor_or_sparse_tensor(
value, dtype=None, name=None, as_ref=False):
"""Converts value to a `SparseTensor` or `Tensor`.
Args:
value: A `SparseTensor`, `SparseTensorValue`, or an object whose type has a
registered `Tensor` conversion function.
dtype: Optional element type for the returned tensor. If missing, the
type is inferred from the type of `value`.
name: Optional name to use if a new `Tensor` is created.
as_ref: True if we want the result as a ref tensor. Only used if a new
`Tensor` is created.
Returns:
A `SparseTensor` or `Tensor` based on `value`.
Raises:
RuntimeError: If result type is incompatible with `dtype`.
"""
if dtype is not None:
dtype = dtypes.as_dtype(dtype)
if isinstance(value, ops.SparseTensorValue):
value = ops.SparseTensor.from_value(value)
if isinstance(value, ops.SparseTensor):
if dtype and not dtype.is_compatible_with(value.dtype):
raise RuntimeError(
'Sparse dtype: requested = %s, actual = %s' % (
dtype.name, value.dtype.name))
return value
return ops.convert_to_tensor(value, dtype=dtype, name=name, as_ref=as_ref)
| naturali/tensorflow | tensorflow/contrib/framework/python/framework/tensor_util.py | Python | apache-2.0 | 11,844 | [
30522,
1001,
9385,
2325,
1996,
23435,
12314,
6048,
1012,
2035,
2916,
9235,
1012,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
30524,
1000,
6105,
1000,
1007,
1025,
1001,
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... |
package test.java.PageObject;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class WindowsManage {
private WebDriver driver;
public WebDriver getAndOpenWindows(String URL){
driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(URL);
driver.manage().window().maximize();
return driver;
}
public void Close(){
driver.close();
}
}
| lvivasa/MuleSoft | src/test/java/PageObject/WindowsManage.java | Java | mit | 492 | [
30522,
7427,
3231,
1012,
9262,
1012,
3931,
16429,
20614,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
16483,
1012,
2051,
19496,
2102,
1025,
12324,
8917,
1012,
2330,
19062,
1012,
7367,
7770,
5007,
1012,
4773,
23663,
2099,
1025,
12324,
8917,
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... |
version https://git-lfs.github.com/spec/v1
oid sha256:670e72438b7fae41b3aad10e06380be23714f5a49304d0188fd58d4d8f7461af
size 2119
| yogeshsaroya/new-cdnjs | ajax/libs/sanitize.css/2.0.0/sanitize.min.css | CSS | mit | 129 | [
30522,
2544,
16770,
1024,
1013,
1013,
21025,
2102,
1011,
1048,
10343,
1012,
21025,
2705,
12083,
1012,
4012,
1013,
28699,
1013,
1058,
2487,
1051,
3593,
21146,
17788,
2575,
1024,
25535,
2063,
2581,
18827,
22025,
2497,
2581,
7011,
2063,
23632,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 BlackBerry Limited. All rights reserved.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://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 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSPDYPROTOCOLHANDLER_H
#define QSPDYPROTOCOLHANDLER_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of the Network Access API. This header file may change from
// version to version without notice, or even be removed.
//
// We mean it.
//
#include <private/qabstractprotocolhandler_p.h>
#include <QtNetwork/qnetworkreply.h>
#include <private/qbytedata_p.h>
#include <zlib.h>
#if !defined(QT_NO_HTTP) && !defined(QT_NO_SSL)
QT_BEGIN_NAMESPACE
class QHttpNetworkRequest;
#ifndef HttpMessagePair
typedef QPair<QHttpNetworkRequest, QHttpNetworkReply*> HttpMessagePair;
#endif
class QSpdyProtocolHandler : public QObject, public QAbstractProtocolHandler {
Q_OBJECT
public:
QSpdyProtocolHandler(QHttpNetworkConnectionChannel *channel);
~QSpdyProtocolHandler();
enum DataFrameFlag {
DataFrame_FLAG_FIN = 0x01,
DataFrame_FLAG_COMPRESS = 0x02
};
Q_DECLARE_FLAGS(DataFrameFlags, DataFrameFlag)
enum ControlFrameFlag {
ControlFrame_FLAG_FIN = 0x01,
ControlFrame_FLAG_UNIDIRECTIONAL = 0x02
};
Q_DECLARE_FLAGS(ControlFrameFlags, ControlFrameFlag)
enum SETTINGS_Flag {
FLAG_SETTINGS_CLEAR_SETTINGS = 0x01
};
Q_DECLARE_FLAGS(SETTINGS_Flags, SETTINGS_Flag)
enum SETTINGS_ID_Flag {
FLAG_SETTINGS_PERSIST_VALUE = 0x01,
FLAG_SETTINGS_PERSISTED = 0x02
};
Q_DECLARE_FLAGS(SETTINGS_ID_Flags, SETTINGS_ID_Flag)
virtual void _q_receiveReply() Q_DECL_OVERRIDE;
virtual void _q_readyRead() Q_DECL_OVERRIDE;
virtual bool sendRequest() Q_DECL_OVERRIDE;
private slots:
void _q_uploadDataReadyRead();
void _q_replyDestroyed(QObject*);
private:
enum FrameType {
FrameType_SYN_STREAM = 1,
FrameType_SYN_REPLY = 2,
FrameType_RST_STREAM = 3,
FrameType_SETTINGS = 4,
FrameType_PING = 6,
FrameType_GOAWAY = 7,
FrameType_HEADERS = 8,
FrameType_WINDOW_UPDATE = 9,
FrameType_CREDENTIAL // has a special type
};
enum StatusCode {
StatusCode_PROTOCOL_ERROR = 1,
StatusCode_INVALID_STREAM = 2,
StatusCode_REFUSED_STREAM = 3,
StatusCode_UNSUPPORTED_VERSION = 4,
StatusCode_CANCEL = 5,
StatusCode_INTERNAL_ERROR = 6,
StatusCode_FLOW_CONTROL_ERROR = 7,
StatusCode_STREAM_IN_USE = 8,
StatusCode_STREAM_ALREADY_CLOSED = 9,
StatusCode_INVALID_CREDENTIALS = 10,
StatusCode_FRAME_TOO_LARGE = 11
};
enum SETTINGS_ID {
SETTINGS_UPLOAD_BANDWIDTH = 1,
SETTINGS_DOWNLOAD_BANDWIDTH = 2,
SETTINGS_ROUND_TRIP_TIME = 3,
SETTINGS_MAX_CONCURRENT_STREAMS = 4,
SETTINGS_CURRENT_CWND = 5,
SETTINGS_DOWNLOAD_RETRANS_RATE = 6,
SETTINGS_INITIAL_WINDOW_SIZE = 7,
SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE = 8
};
enum GOAWAY_STATUS {
GOAWAY_OK = 0,
GOAWAY_PROTOCOL_ERROR = 1,
GOAWAY_INTERNAL_ERROR = 11
};
enum RST_STREAM_STATUS_CODE {
RST_STREAM_PROTOCOL_ERROR = 1,
RST_STREAM_INVALID_STREAM = 2,
RST_STREAM_REFUSED_STREAM = 3,
RST_STREAM_UNSUPPORTED_VERSION = 4,
RST_STREAM_CANCEL = 5,
RST_STREAM_INTERNAL_ERROR = 6,
RST_STREAM_FLOW_CONTROL_ERROR = 7,
RST_STREAM_STREAM_IN_USE = 8,
RST_STREAM_STREAM_ALREADY_CLOSED = 9,
RST_STREAM_INVALID_CREDENTIALS = 10,
RST_STREAM_FRAME_TOO_LARGE = 11
};
quint64 bytesAvailable() const;
bool readNextChunk(qint64 length, char *sink);
void sendControlFrame(FrameType type, ControlFrameFlags flags, const char *data, quint32 length);
void sendSYN_STREAM(HttpMessagePair pair, qint32 streamID,
qint32 associatedToStreamID);
void sendRST_STREAM(qint32 streamID, RST_STREAM_STATUS_CODE statusCode);
void sendPING(quint32 pingID);
bool uploadData(qint32 streamID);
Q_INVOKABLE void sendWINDOW_UPDATE(qint32 streamID, quint32 deltaWindowSize);
qint64 sendDataFrame(qint32 streamID, DataFrameFlags flags, quint32 length,
const char *data);
QByteArray composeHeader(const QHttpNetworkRequest &request);
bool uncompressHeader(const QByteArray &input, QByteArray *output);
void handleControlFrame(const QByteArray &frameHeaders);
void handleDataFrame(const QByteArray &frameHeaders);
void handleSYN_STREAM(char, quint32, const QByteArray &frameData);
void handleSYN_REPLY(char flags, quint32, const QByteArray &frameData);
void handleRST_STREAM(char flags, quint32 length, const QByteArray &frameData);
void handleSETTINGS(char flags, quint32 length, const QByteArray &frameData);
void handlePING(char, quint32 length, const QByteArray &frameData);
void handleGOAWAY(char flags, quint32, const QByteArray &frameData);
void handleHEADERS(char flags, quint32, const QByteArray &frameData);
void handleWINDOW_UPDATE(char, quint32, const QByteArray &frameData);
qint32 generateNextStreamID();
void parseHttpHeaders(char flags, const QByteArray &frameData);
void replyFinished(QHttpNetworkReply *httpReply, qint32 streamID);
void replyFinishedWithError(QHttpNetworkReply *httpReply, qint32 streamID,
QNetworkReply::NetworkError errorCode, const char *errorMessage);
qint32 m_nextStreamID;
QHash<quint32, HttpMessagePair> m_inFlightStreams;
qint32 m_maxConcurrentStreams;
quint32 m_initialWindowSize;
QByteDataBuffer m_spdyBuffer;
bool m_waitingForCompleteStream;
z_stream m_deflateStream;
z_stream m_inflateStream;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QSpdyProtocolHandler::DataFrameFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(QSpdyProtocolHandler::ControlFrameFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(QSpdyProtocolHandler::SETTINGS_Flags)
Q_DECLARE_OPERATORS_FOR_FLAGS(QSpdyProtocolHandler::SETTINGS_ID_Flags)
QT_END_NAMESPACE
#endif // !defined(QT_NO_HTTP) && !defined(QT_NO_SSL)
#endif // QSPDYPROTOCOLHANDLER_H
| jlspyaozhongkai/Uter | third_party_build/Qt5.5.0/include/QtNetwork/5.5.0/QtNetwork/private/qspdyprotocolhandler_p.h | C | gpl-3.0 | 7,698 | [
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... |
@font-face {
font-family: 'Sue Ellen Francisco';
font-style: normal;
font-weight: 400;
src: url(ellen.woff);format("woff");} | nurulimamnotes/banten-it-solutions | css/ellen.css | CSS | gpl-2.0 | 132 | [
30522,
1030,
15489,
1011,
2227,
1063,
15489,
1011,
2155,
1024,
1005,
9790,
9155,
3799,
1005,
1025,
15489,
1011,
2806,
1024,
3671,
1025,
15489,
1011,
3635,
1024,
4278,
1025,
5034,
2278,
1024,
24471,
2140,
1006,
9155,
1012,
24185,
4246,
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... |
---
layout: docs
title: GitHub Pages
prev_section: extras
next_section: deployment-methods
permalink: /docs/github-pages/
---
[GitHub Pages](http://pages.github.com) are public web pages for users,
organizations, and repositories, that are freely hosted on GitHub's
`github.io` domain or on a custom domain name of your choice. GitHub Pages are
powered by Jekyll behind the scenes, so in addition to supporting regular HTML
content, they’re also a great way to host your Jekyll-powered website for free.
## Deploying Jekyll to GitHub Pages
GitHub Pages work by looking at certain branches of repositories on GitHub.
There are two basic types available: user/organization pages and project pages.
The way to deploy these two types of sites are nearly identical, except for a
few minor details.
<div class="note protip">
<h5>Use the <code>github-pages</code> gem</h5>
<p>
Our friends at GitHub have provided the
<a href="https://github.com/github/pages-gem">github-pages</a>
gem which is used to manage Jekyll and its dependencies on
GitHub Pages. Using it in your projects means that when you deploy
your site to GitHub Pages, you will not be caught by unexpected
differences between various versions of the gems. To use the
currently-deployed version of the gem in your project, add the
following to your <code>Gemfile</code>:
{% highlight ruby %}
source 'https://rubygems.org'
require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', versions['github-pages']
{% endhighlight %}
This will ensure that when you run <code>bundle install</code>, you
have the correct version of the <code>github-pages</code> gem.
</p>
</div>
### User and Organization Pages
User and organization pages live in a special GitHub repository dedicated to
only the GitHub Pages files. This repository must be named after the account
name. For example, [@mojombo’s user page
repository](https://github.com/mojombo/mojombo.github.io) has the name
`mojombo.github.io`.
Content from the `master` branch of your repository will be used to build and
publish the GitHub Pages site, so make sure your Jekyll site is stored there.
<div class="note info">
<h5>Custom domains do not affect repository names</h5>
<p>
GitHub Pages are initially configured to live under the
<code>username.github.io</code> subdomain, which is why repositories must
be named this way <strong>even if a custom domain is being used</strong>.
</p>
</div>
### Project Pages
Unlike user and organization Pages, Project Pages are kept in the same
repository as the project they are for, except that the website content is
stored in a specially named `gh-pages` branch. The content of this branch will
be rendered using Jekyll, and the output will become available under a subpath
of your user pages subdomain, such as `username.github.io/project` (unless a
custom domain is specified—see below).
The Jekyll project repository itself is a perfect example of this branch
structure—the [master branch]({{ site.repository }}) contains the
actual software project for Jekyll, however the Jekyll website (that you’re
looking at right now) is contained in the [gh-pages
branch]({{ site.repository }}/tree/gh-pages) of the same repository.
<div class="note warning">
<h5>Source Files Must be in the Root Directory</h5>
<p>
Github Pages <a href="https://help.github.com/articles/troubleshooting-github-pages-build-failures#source-setting">overrides</a> the <a href="http://jekyllrb.com/docs/configuration/#global-configuration">“Site Source”</a> configuration value, so if you locate your files anywhere other than the root directory, your site may not build correctly.
</p>
</div>
### Project Page URL Structure
Sometimes it's nice to preview your Jekyll site before you push your `gh-pages`
branch to GitHub. However, the subdirectory-like URL structure GitHub uses for
Project Pages complicates the proper resolution of URLs. Here is an approach to
utilizing the GitHub Project Page URL structure (`username.github.io/project-name/`)
whilst maintaining the ability to preview your Jekyll site locally.
1. In `_config.yml`, set the `baseurl` option to `/project-name` -- note the
leading slash and the **absence** of a trailing slash.
2. When referencing JS or CSS files, do it like this:
`{% raw %}{{ site.baseurl }}/path/to/css.css{% endraw %}` -- note the slash
immediately following the variable (just before "path").
3. When doing permalinks or internal links, do it like this:
`{% raw %}{{ site.baseurl }}{{ post.url }}{% endraw %}` -- note that there
is **no** slash between the two variables.
4. Finally, if you'd like to preview your site before committing/deploying using
`jekyll serve`, be sure to pass an **empty string** to the `--baseurl` option,
so that you can view everything at `localhost:4000` normally (without
`/project-name` at the beginning): `jekyll serve --baseurl ''`
This way you can preview your site locally from the site root on localhost,
but when GitHub generates your pages from the gh-pages branch all the URLs
will start with `/project-name` and resolve properly.
<div class="note">
<h5>GitHub Pages Documentation, Help, and Support</h5>
<p>
For more information about what you can do with GitHub Pages, as well as for
troubleshooting guides, you should check out <a
href="https://help.github.com/categories/20/articles">GitHub’s Pages Help
section</a>. If all else fails, you should contact <a
href="https://github.com/contact">GitHub Support</a>.
</p>
</div>
| kinlane/jekyll | site/_docs/github-pages.md | Markdown | mit | 5,657 | [
30522,
1011,
1011,
1011,
9621,
1024,
9986,
2015,
2516,
1024,
21025,
2705,
12083,
5530,
3653,
2615,
1035,
2930,
1024,
26279,
2279,
1035,
2930,
1024,
10813,
1011,
4725,
2566,
9067,
19839,
1024,
1013,
9986,
2015,
1013,
21025,
2705,
12083,
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... |
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
*
* 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.kie.workbench.common.screens.datasource.management.client.dbexplorer.schemas;
import com.google.gwt.view.client.AsyncDataProvider;
import org.uberfire.client.mvp.UberElement;
import org.uberfire.ext.widgets.common.client.common.HasBusyIndicator;
public interface DatabaseSchemaExplorerView
extends UberElement< DatabaseSchemaExplorerView.Presenter >, HasBusyIndicator {
interface Presenter {
void onOpen( DatabaseSchemaRow row );
}
interface Handler {
void onOpen( String schemaName );
}
void setDataProvider( AsyncDataProvider< DatabaseSchemaRow > dataProvider );
void redraw( );
} | romartin/kie-wb-common | kie-wb-common-screens/kie-wb-common-datasource-mgmt/kie-wb-common-datasource-mgmt-client/src/main/java/org/kie/workbench/common/screens/datasource/management/client/dbexplorer/schemas/DatabaseSchemaExplorerView.java | Java | apache-2.0 | 1,272 | [
30522,
1013,
1008,
1008,
9385,
2355,
2417,
6045,
1010,
4297,
1012,
1998,
1013,
2030,
2049,
18460,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# -*- coding: utf-8 -*-
# ProjectEuler/src/python/problem404.py
#
# Crisscross Ellipses
# ===================
# Published on Sunday, 2nd December 2012, 01:00 am
#
# Ea is an ellipse with an equation of the form x2 + 4y2 = 4a2. Ea' is the
# rotated image of Ea by θ degrees counterclockwise around the origin O(0, 0)
# for 0° θ 90°. b is the distance to the origin of the two intersection
# points closest to the origin and c is the distance of the two other
# intersection points. We call an ordered triplet (a, b, c) a canonical
# ellipsoidal triplet if a, b and c are positive integers. For example, (209,
# 247, 286) is a canonical ellipsoidal triplet. Let C(N) be the number of
# distinct canonical ellipsoidal triplets (a, b, c) for a N. It can be
# verified that C(103) = 7, C(104) = 106 and C(106) = 11845. Find C(1017).
import projecteuler as pe
def main():
pass
if __name__ == "__main__":
main()
| olduvaihand/ProjectEuler | src/python/problem404.py | Python | mit | 944 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
1001,
2622,
13765,
3917,
1013,
5034,
2278,
1013,
18750,
1013,
3291,
12740,
2549,
1012,
1052,
2100,
1001,
1001,
13675,
14643,
16458,
3449,
15000,
8583,
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
if (!is_null($this->session->userdata('quiz_bg_img'))) { ?>
<style type="text/css">
body {
background-image: url("<?php echo base_url()."/public/img/".$this->session->userdata('quiz_bg_img'); ?>");
background-size: cover;
}
</style>
<img src="<?php echo base_url()."/public/img/logo.png"; ?>" class="img-responsive" id="logo">
<?php } ?>
<div class="container">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h4 class="starter-template">
Ciena Presents
</h4>
<p class="text-center h1">
<?php echo urldecode($this->session->userdata('quiz_name')); ?>
</p>
</div>
</div>
<div class="row" style="padding-top: 5%">
<div class="col-md-12 text-center">
<?php echo anchor('/Quiz/take_quiz/'.$this->session->userdata('quiz_id'), 'Begin Quiz', array('title' => $this->session->userdata('quiz_name'), 'class' => 'btn btn-ciena-yes btn-lg ')); ?>
<h4>Do not use the back arrow button during the quiz</h4>
</div>
</div>
</div>
</div> | Jonyorker/ciena-quiz | application/views/quiz_splash_view.php | PHP | mit | 1,078 | [
30522,
1026,
1029,
25718,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
5219,
1011,
1028,
5310,
2850,
2696,
1006,
1005,
19461,
1035,
1038,
2290,
1035,
10047,
2290,
1005,
1007,
1007,
1007,
1063,
1029,
1028,
1026,
2806,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package io.izenecloud.larser.framework;
import io.izenecloud.conf.Configuration;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.kohsuke.args4j.spi.StringOptionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LaserArgument {
private static final Logger LOG = LoggerFactory
.getLogger(LaserArgument.class);
public static final Set<String> VALID_ARGUMENTS = new HashSet<String>(
Arrays.asList("-configure"));
@Option(name = "-configure", required = true, handler = StringOptionHandler.class)
private String configure;
public String getConfigure() {
return configure;
}
public static void parseArgs(String[] args) throws CmdLineException,
IOException {
ArrayList<String> argsList = new ArrayList<String>(Arrays.asList(args));
for (int i = 0; i < args.length; i++) {
if (i % 2 == 0 && !LaserArgument.VALID_ARGUMENTS.contains(args[i])) {
argsList.remove(args[i]);
argsList.remove(args[i + 1]);
}
}
final LaserArgument laserArgument = new LaserArgument();
new CmdLineParser(laserArgument).parseArgument(argsList
.toArray(new String[argsList.size()]));
Configuration conf = Configuration.getInstance();
LOG.info("Load configure, {}", laserArgument.getConfigure());
Path path = new Path(laserArgument.getConfigure());
FileSystem fs = FileSystem
.get(new org.apache.hadoop.conf.Configuration());
conf.load(path, fs);
}
}
| izenecloud/laser | src/main/java/io/izenecloud/larser/framework/LaserArgument.java | Java | apache-2.0 | 1,698 | [
30522,
7427,
22834,
1012,
1045,
10431,
8586,
23743,
2094,
1012,
16357,
2121,
1012,
7705,
1025,
12324,
22834,
1012,
1045,
10431,
8586,
23743,
2094,
1012,
9530,
2546,
1012,
9563,
1025,
12324,
9262,
1012,
22834,
1012,
22834,
10288,
24422,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
序 壬申秋余權什邑事樂其
訟少俗淳較他邑易治以
為此必有得於山川風氣
者X吏人以邑志至則邑
令紀君手成書也當是時
大吏增修蜀志檄下諸郡
===
紛紛四方延師儒及鄉先
生之能文者多無成X上
之或往反駁詰勸經歲月
而是書不四月既畢無議
之者蓋紀君豫章名士博
洽多聞邑人士又喜以載
筆光其里採訪勤考據確
===
宜乎成之者速且善如此什
邑在郡北百里外地接荒
徼高山大壑綿亘數千里
長莽叢薄怪禽駭獸自古
不通人跡邑士之考輿圖
者裹糧以往越險垂危露
宿閱月凡山川支幹源
===
流莫不得實以歸又舊志
修自前邑令史君距今數
十年期間嘉言懿行X以
維持風教而湮沒於窮鄉
委巷寂?寞無傳者至是而
X微闡幽無遺憾焉夫前
事之不忘後事之師也讀
===
斯志者按其山川觀其風
氣知民生之所以遂與民
俗之所由淳治譜X是乎
在余任事僅七月舊章具
備不勞而理後之君子X
心民X將斯志是賴是則
紀君之用心及邑人士之
===
相與有成者不可不傳也
乃固晉?紳u之請而為之序
嘉慶十八年三月權邑令
雲南石屏州朱XX撰
===
序
什邡之有志始於康熙二十
二年前胡令之鴻草創僅二
十餘頁五十九年丁令士一
得漢州一州三縣古X志鈔
本採集增修梗概略具乾隆
六年劉令紹X復加修補均
未及刊刻十二年史令進爵
===
紛紛四方延師儒及鄉先
生之能文者多無成X上
之或往反駁詰勸經歲月
而是書不四月既畢無議
之者蓋紀君豫章名士博
洽多聞邑人士又喜以載
筆光其里採訪勤考據確
===
宜乎成之者速且善如此什
邑在郡北百里外地接荒
徼高山大壑綿亘數千里
長莽叢薄怪禽駭獸自古
不通人跡邑士之考輿圖
者裹糧以往越險垂危露
宿閱月凡山川支幹源
===
流莫不得實以歸又舊志
修自前邑令史君距今數
十年期間嘉言懿行X以
維持風教而湮沒於窮鄉
委巷寂?寞無傳者至是而
X微闡幽無遺憾焉夫前
事之不忘後事之師也讀
===
斯志者按其山川觀其風
氣知民生之所以遂與民
俗之所由淳治譜X是乎
在余任事僅七月舊章具
備不勞而理後之君子X
心民X將斯志是賴是則
紀君之用心及邑人士之
===
流莫不得實以歸又舊志
修自前邑令史君距今數
十年期間嘉言懿行X以
維持風教而湮沒於窮鄉
委巷寂?寞無傳者至是而
X微闡幽無遺憾焉夫前
事之不忘後事之師也讀
===
斯志者按其山川觀其風
氣知民生之所以遂與民
俗之所由淳治譜X是乎
在余任事僅七月舊章具
備不勞而理後之君子X
心民X將斯志是賴是則
紀君之用心及邑人士之
===
相與有成者不可不傳也
乃固晉?紳u之請而為之序
嘉慶十八年三月權邑令
雲南石屏州朱XX撰
===
序
什邡之有志始於康熙二十
二年前胡令之鴻草創僅二
十餘頁五十九年丁令士一
得漢州一州三縣古X志鈔
本採集增修梗概略具乾隆
六年劉令紹X復加修補均
未及刊刻十二年史令進爵
===
始X輯成書凡十八卷今又
六十餘年嘉慶辛未
制府奏修四川通志定為條
目格式飭下諸郡邑一體編
撰大奎承乏方亭因集邑人
士之通曉故事者將舊志復
加稽核仿照格式分類編次
並採訪六十餘年事迹及前
===
此山川古迹之未詳者增
錄之大奎公餘之暇為之一
一考訂期於完備四月閱而
畢繕錄成X上之
制府X以備通志採擇爾
嘉慶十七年壬申夏五月什
邡縣紀大奎謹識
===
===
原序
漢南三坡史君以名孝廉蒞什邡政通人和境內
寧謐公暇則修舉廢墜治律梁塞城闕創義學社
學及尊經閣魁星閣凡昔所未備者次第設施什
故望邑江山形勝甲於西川來則景物日益清
和桑麻被XX誦之聲相聞入境者未嘗不流連
太息知邑之有賢候也X余令繁江壤地相錯思
一往游X治蹟君亦數以書招為職守所羈不能
越境心悵悵之會余去官居成都君入省必來視
===
坐定不復作寒暄輒問君近舉何事治何先君枚
數以復津津有味余戲曰方亭百里君田舍在茲
耶相與大小而罷傾復郵示所輯縣志初邑令山
陰胡君日照丁君三原劉君先後䉵修君蒞什六
載極意搜羅復增益若干卷至是將付梓以余昔
修繁志嘗耗心力大於斯也命一言為序值余抱痾
?不能竟讀間撮大X觀之見其義例謹嚴序次詳
盡所須條教皆誠意藹然如入窮薝?而治其家事
乃益X君之心存濟物為什父老慶得賢侯而又
===
自愧往者治繁之不如遠甚也今夫溺於富貴利
達者以官為家矯之者曰仕宦如傳舍由前之
說人皆知其陋由後之說則賢達所尚然土X
人民贅疣職事其害也至於上下解體而不可為
故吾謂士患不以官為家以官為家而心有不盡
焉者寡矣今
聖天子子惠元元勤求至理教養之
訓屢飭有司令長秩雖卑固儼然稱民父母也為一家
之父母而漠視其家者人不以為狂易必以為不
===
祥則為民父母而漠視其民者尚克膺司牧之任
哉讀君是志以考所行則知余疇昔往複之詞雖
戲言亦足以當治譜矣若余遲暮一官頹唐特甚
迴憶歸民蒞政鹿鹿無足稱然遇力所可辨分所
得為者不敢不X勉從事而自下車之始謀修邑
乘歷五六載然後克成其勤苦X與君同雖謹嚴
詳盡較之什志遠謝不如要特才分使然其區區
自盡之苦心未嘗不與君相視而莫逆也然則君
之命以序言與余之承命而弗辭者毋亦有在於
===
是歟獨念余尚平夙願至老弗衰徒以仕宦匆匆
什邡咫尺之地竟不能命駕一往今既辭簪組號散
人矣期以餘年躡屐涉章雒X鎣華望雍侯之故
墟仿二程往來讀書之地退而與父老子弟謳吟
下上以傳送賢侯之所設施凡今日之見於圖經
者庶幾一一驗之君行報最旦夕待遷其尚為余
少X作東道主也乾隆十二年季春朔日石幢弟
鄭方城拜題於錦江書院
===
祥則為民父母而漠視其民者尚克膺司牧之任
哉讀君是志以考所行則知余疇昔往複之詞雖
戲言亦足以當治譜矣若余遲暮一官頹唐特甚
迴憶歸民蒞政鹿鹿無足稱然遇力所可辨分所
得為者不敢不X勉從事而自下車之始謀修邑
乘歷五六載然後克成其勤苦X與君同雖謹嚴
詳盡較之什志遠謝不如要特才分使然其區區
自盡之苦心未嘗不與君相視而莫逆也然則君
之命以序言與余之承命而弗辭者毋亦有在於
===
是歟獨念余尚平夙願至老弗衰徒以仕宦匆匆
什邡咫尺之地竟不能命駕一往今既辭簪組號散
人矣期以餘年躡屐涉章雒X鎣華望雍侯之故
墟仿二程往來讀書之地退而與父老子弟謳吟
下上以傳送賢侯之所設施凡今日之見於圖經
者庶幾一一驗之君行報最旦夕待遷其尚為余
少X作東道主也乾隆十二年季春朔日石幢弟
鄭方城拜題於錦江書院
===
===
原序
竊念令之為職祿秩雖卑然為守土之官親民之
牧也有守土之責則凡所以敬典維禮興利除害
夙寤夜興土為
朝廷裕養而敷教者當無弗至也居親民之任則凡
所以X奸剔弊慎刑法明罰矢慎公下為斯民養
欲而給求者慮無弗周也然而措施之方無他奇
能惟在因民情宜土俗而已若然則邑志之修所
關不X重哉 爵 自辛酉之冬恭膺
===
簡命來令方亭政事之暇訪求遺志得一草冊閱之寥
寥簡陋未未成佚?因思一邑雖微同沐
皇仁之浩蕩均在光天化日之中其間山川土田何以
昭帶礪之盟泉流堰道何以厚耕鋤之溉城郭人
民未可以缺X者貽譏也錢糧學校不可以舛廢
者滋咎也若夫忠孝節義之傳風俗人文之備尤
足以深入人心挽回氣習不可以缺焉而弗備者
也不禁慨然嘆息謂此書之缺懼不足以昭往而
勸來信今而垂後也因X然者久之及丁卯之春
===
謀諸學校紳者詳加採訪X集成X非謂因民情
宜土俗是書果足以為將來之資助亦謂今日之
見聞若斯姑以等諸梨棗不敢遺失異日倘有博
古通今椽管花毫之遇則覽斯稿也當諒 爵 雖不
敏猶不敢忘守土親民之至意庶幾XX之功 爵
亦與有榮施矣是為序
時
乾隆十有三年戊辰仲春月上浣文林郎知成都府
什邡縣事關南史進爵謹撰?
===
===
什邡縣誌目錄
卷一
星野
卷二
圖考
卷三
建置沿革
卷四
疆域
===
卷五 形勢 卷六 山川 卷七 戶口 卷八 田賦 卷九
===
水利 卷十 城池 卷十一 關隘 卷十二 津梁 卷十三 古蹟
===
卷十四 公署 卷十五 學校 卷十六 祀典 卷十七 祠廟 卷十八
===
風俗 卷十九 兵制 卷二十 屯田 卷二十一 邊防 卷二十二 驛傳
===
卷二十三 鋪遷 卷二十四 土司 卷二十五 武功 卷二十六 屯練 卷二十七
===
寺觀 卷二十八 鹽法 卷二十九 茶法 卷三十 錢法 卷三十一 木政
===
卷三十二 榷政 卷三十三 X政 卷三十四 職官 卷三十五 選舉 卷三十六
===
封蔭 卷三十七 政績 卷三十八 人物 卷三十九 烈女 卷四十 隱逸
===
卷三十二 榷政 卷三十三 X政 卷三十四 職官 卷三十五 選舉 卷三十六
===
封蔭 卷三十七 政績 卷三十八 人物 卷三十九 烈女 卷四十 隱逸
===
卷四十一 流寓 卷四十二 仙釋 卷四十三 方技 卷四十四 古帝王 卷四十五
===
故宮 卷四十六 陵墓 卷四十七 X竊 卷四十八之一 藝文 卷四十八之二 藝文
===
卷四十八之三 藝文 卷四十八之四 藝文 卷四十九 典籍 卷五十 金石 卷五十一
===
物產 卷五十二 祥異 卷五十三 X識 卷五十四 外紀
===
===
續補提綱 嘉慶甲戌總局札取須知冊併作此附呈間 有訂正原本處因補刻於目錄之後
卷一星野志 查乾隆十二年知縣史進爵舊縣誌
所載星野雖誤然實本舊通志沿襲史記天官書
漢書天文志XX參益州之說故仍存舊志原文
而別附考訂一篇於後以備採擇
卷二圖考志 首分野次疆域水利河泉各堰等圖
一一確核形勢其九聯坪禹母所居棲鳳山夫子
院二程夫子讀書處為邑中最勝末附洛書八方
合十一圖因前時未有此說特附什邡考及九聯
===
坪圖記於後以備參考其說X件第六卷山川志之內洛水附識第十三卷古蹟志內之禹王廟附識
卷三建置沿革 史令舊志頗詳今悉原本而添入文武各官增減於後
卷四疆域志 仍舊縣誌
卷五形勢志 累?增舊縣誌
卷六山川志 於縣誌舊本外增入金厳八卦頂二山其舊志記載未詳者特於章雒二山及雒水諸
===
流後各附識一跋X及洛書之說以備參考又盤江河舊通志縣誌俱誤標新婦水非河本名今改正新婦水別入古蹟
卷七戶口志 據賦役全書增輯並?附各鄉保甲於後
卷八田賦志 據賦役全書增輯又歲支縣養廉銀陸百兩典史養廉銀八十兩賢西由司庫動支給領前志稿內遺漏未載今附識於此
卷九水利志 按縣境雖都江堰所不及而境內河
===
堰泉堰分派溝渠最多每歲民間爭訟不息並時有鄰封漢綿二處截挖之患今逐一確勘分析源流比舊縣誌特詳而史令原本修渠灌溉諸法仍備錄於後
卷十城池志 仍舊志本有?附修補歲月於後
卷十一關隘志 邑地非孔道故舊志無關隘間於別卷中分見數條今遵照格式X為一卷並將各市路通鄰境及交界處所一一增入
卷十二津梁志 因舊志復加增輯共七十餘處以
===
金帶玉馬迴瀾鄧通大石連雲六橋為勝
卷十三古蹟志 以禹廟遺址雒縣廢址馬腳井社臨觀遺址zuo纓泉夫子院慧劍井新婦水等處為最舊志禹王廟一段附載禹母祠事蹟因通志載禹生石紐村在石泉縣故約X其辭以為未敢質議今特取石泉縣舊志所載考其大有?可疑者附識於後以備恭考其說並見第二卷圖考志內之什邡考九聯坪圖記第六卷山川志之雒水附識又隋文帝子蜀王廟遺址舊志失載今據南
===
陽寺宋任願碑記補入有盤江河內之新婦水舊通志縣誌俱誤入山川志內失河本名今考正以新婦水歸古蹟以盤江河補入山川
卷十四公署志 舊志附建置門今遵格式查明修建個年歲輯為一卷附常社個倉及營房軍器局養濟院等於後
卷十五學校志 X因舊志重加增輯附書院及社學於後
卷十六祀典志 X因舊志復加增輯
===
卷十七祠廟志 舊志附祀典內今遵格式訂正原本淆誤缺X之處另輯一卷
卷十八風格志 大X與君屬同故悉仍舊志附以詳飲酒禮並錄邪教天主教誘民個術於後
卷十九兵制志 X因舊志修輯
卷二十屯田志 卷二十一邊防志 卷二十二驛傳志 以上三門縣歷無其制今依格式編次仍存此三卷門類而於卷內聲敘什邑歷無此制以備
===
總局編次門類易於查考
卷二十三鋪遷志 X因舊志並考賦役全書增輯
卷二十四土司志 卷二十五武功志 卷二十六屯練志 邑無土司亦無武功可紀及屯練之制今於三卷內X為聲敘以備
卷二十七寺觀志 共八十九處最著者六一羅漢寺唐馬祖道場一慧劍寺唐波崙禪師建一南陽寺湧泉成河灌什漢田無數一三泉寺元大定
===
間建一龍居寺唐李真人建一雪門寺即夫子院一箭古蹟
卷二十八鹽法志 卷二十九茶法志 以上二法舊志並附賦稅門今遵照格式重加增輯個另為一卷
卷三十錢法志 卷三十一木政志 卷三十二榷政志 以上三門歷無設有廠局今於三卷內分析聲敘以備
總局查考
===
總局編次門類易於查考
卷二十三鋪遷志 X因舊志並考賦役全書增輯
卷二十四土司志 卷二十五武功志 卷二十六屯練志 邑無土司亦無武功可紀及屯練之制今於三卷內X為聲敘以備
卷二十七寺觀志 共八十九處最著者六一羅漢寺唐馬祖道場一慧劍寺唐波崙禪師建一南陽寺湧泉成河灌什漢田無數一三泉寺元大定
===
間建一龍居寺唐李真人建一雪門寺即夫子院一箭古蹟
卷二十八鹽法志 卷二十九茶法志 以上二法舊志並附賦稅門今遵照格式重加增輯個另為一卷
卷三十錢法志 卷三十一木政志 卷三十二榷政志 以上三門歷無設有廠局今於三卷內分析聲敘以備
總局查考
===
卷三十三X政志 舊志未載今自康熙二十五年起至嘉慶七年歷次欽奉 恩旨X免酌免錢糧及因辦運夫米捐津貼銀兩欠奉 恩旨X免錢糧分數一一恭錄於卷其當日有無士民志 切公捐具呈不願邀免者今無案可考
卷三十四職官志 舊志知縣自明以前惟漢宋二代X存數人餘俱無考教諭以下自明以前俱不可考今因舊志所載增入乾隆十二年以後正署各官於卷
===
卷三十五選舉志 舊志無薦辟其進士自宋以前無考舉人以下自明以前無考今增錄乾隆十二年以後各姓名於卷
卷三十六封蔭志 X因舊志復加增輯
卷三十七政績志 自漢依賴舊志名宦所載悉存之增入乾隆六年以後輿論X協彰彰著聞者史進爵以下五人又康熙九年什邡尹李若璋志載入墳墓今移於此凡前後共二十三人以備採擇
===
卷三十八人物誌 合舊志所載並續入唐綏以下共四十三人以備採擇因沿舊志時代次序編錄品目未分極為X忽今各依品目分列於左便於查考又舊志附鄉官四十五人今仍存之
一宦業
漢楊宣 入鄉賢 郭賀
唐雍無逸
明曹山 入鄉賢 劉克學 入鄉賢
本朝唐綏
===
一儒林
漢XX 入鄉賢 段恭
一文苑
漢李尤 入鄉賢
本朝李霖 李泰秀 黃世仰
一處士
漢折象 入鄉賢 賈詡
宋李發
本朝趙居仁 入鄉賢 李樞 劉迪旭
===
吳相富 陳功朝 寗祝先
張宗法 李淑東 張有道
黃世祿 張振鵬 陳文武
一忠義
元馮文舉 入忠義祠
明雷應奇 入忠義祠
本朝李國祥 入忠義祠 楊兆熊 入忠義祠 余文泰 入忠義祠
張超 入忠義祠
一孝友
===
宋王禹城 入孝義祠 陳如松 入孝義祠
明胡定 入孝義祠
本朝吳得明 黃子尚 劉亨運
黃宗X 冷中榮 劉宗泗
羅登誥
以上漢郭賀段恭賈詡三人舊志無據華陽國志補入XX李尤二人據後漢書本傳皆雲廣漢雒縣人而舊通志改為新都人殊誤志內未及辨訂因附識於此
===
卷三十九列女志 有節烈節孝節婦孝婦貞女合舊志所載及新採訪共九十人以備採擇
卷四十隱逸志 舊志附人物僅二人今補入華陽國志一人又新增一人以備採擇
卷四十一流寓志 舊志四人二程夫子最著新增無
卷四十二仙釋志 存舊志九人以備採擇其馬大師即馬祖也又補入馬祖錄中了恩一人
卷四十三方技志 存舊志藝術三人以備採擇郭
===
玉入鄉賢祠舊志傳文多X誤今據後漢書方術本傳訂正
卷四十四古帝王志 卷四十五故宮志 邑無古帝王都會及宮殿等事以漢封什邡侯雍齒傳國四世附識卷內又隋帝子蜀王曾因獵至什不知封地是否在此舊通志縣誌俱未載僅南陽寺宋任願重修蜀王廟碑記尚存文多缺X未便增入今補入藝文志內備考
卷四十六陵墓志 因舊志墳墓邑冢X加增輯
===
卷四十七X竊志 邑古無竊據事惟晉時李雄據成都相距不遠附識卷內
卷四十八藝文志 藝文比他卷較多分為卷四十八之一之二之三之四前卷恭錄
宸翰後三卷錄歷代詩文以備採擇
卷四十九典籍志 縣著述可X者惟後周蜀郡公衛元嵩易元包經與揚雄太元經並宸舊通志縣志皆失載今特為標出並撮敘大旨以表之傳敘三篇並跋錄藝文志此外附錄二十餘種以備採
===
擇
卷五十金石志 舊縣誌所載古淳千古編鐘及熙寧淳熙二碑皆無存宋紹興中任願修蜀王廟碑舊志失載自多殘缺此外 至聖銅鐵像四尊及古佛神像各尊並列於卷
卷五十一物產志 大約與郡屬州縣同今備錄於卷
卷五十二祥異志 X採舊志數事並補華陽國志一事及五世同堂者一人錄於卷又譚興湖夫婦
===
九十五世一堂誤寫於外紀之末應移入此卷並附識之
卷五十三雜識志 錄唐王象之蜀水考見眾水源流並採舊志土著姓氏及耕作種植牧養諸法附以八景四景等著於卷
卷五十四外紀志 錄李雨村蜀碑記補一事並採舊志紀異數事又續採二事附於卷卷末誤入譚興湖五世同堂一事應移祥異志
===
什邡縣誌䉵修姓氏
總修
成都府什邡縣知縣紀大奎 慎齋臨川人
協修
什邡縣儒學教諭雷思恪 X洲渠縣人
署什邡縣儒學訓導陳鴻X 逵亭蓬溪人
分修
舉人王道和 斯美
舉人羅瑩璋 金函
===
舉人寥全誥 文山
X生戴瑤 汝玉
貢生劉X同 菊田
庠生高炳南 近光
X生楊炳川 繼修
採訪
庠生孫元樞
庠生譚靜
庠生漆維棟
===
庠生劉百川
庠生徐紹玉
吏員王廷賢
庠生鍾靈
編次
貢生林時春
X生袁信春
監生李大鵬
校對
X生陳X章
X生余祚新
繕寫
X生戴心正
增生寥禮璠
增生孫道淵
庠生周聯吉
庠生劉紹南
庠生甘懷泗
===
庠生陳德音
庠生戴心濤
童生曹政修
童生趙應開
庠生徐步青
童生余敬思
布衣劉位賢 華陽人
協理
千總權文璣
===
監生樊護
職員榮茂葵
監生鄧廷禮
職員戴青雲
繪圖
邑人羅登誥
梓人
邑人宋盛選 男朝貴
===
什邡縣誌卷一
星野志
史記秦地於天官東井與鬼之分野也南至巴蜀廣漢晉書天文志自畢十二度至東井十五度為實沈於辰在申魏分屬益州通志成都屬井鬼之分入參一度今什邡西北距成都 西北准天度言 一百二十里當觜參之次於辰在申 以中州論 廣漢土地譜雲高帝置廣漢郡 今成都 領十縣上應十支通夷在戌陽泉在亥南安在子涪流在丑梓潼在寅五城在卯新都在辰資中
===
在巳犍為在午什邡在酉考天文度數觜五分參十一度什邡在酉 以廣漢論 分野當在觜參一度初一分之第一X強 舊志 謹按什邡X成都接壤漢彭天文井宿分野縣舊志以什邡距成都一百二十里分野觜第五分之末參一度之初蓋沿四川通志誤引史記漢書觜X參益州之文以為成都府屬井鬼之分入參一度不知成都地在坤維約值參井之間而天文
===
東井與鬼雍州柳七星張三河翼軫荊州數語於前後日月五星文義敘次既相隔絕又與總論內分野之占不盡合其為後人竄入顯然無疑漢書十二州並以日月甲乙諸期與總論分野之說雜為一段足見其X至其地理志輯論所著謂秦地於天官東井與鬼之分野其界自宏農故關以西京兆扶風馮翊北地上郡西河安定天水隴西南有巴蜀廣漢犍為武都西有金城武威張掖酒泉
===
敦煌又西南有X柯越X益州皆宜屬焉自井十度至柳三度謂之X首之次秦之分也魏地觜X參之分野其界自高陵以東河內南有陳留?及汝南之召陵X疆新汲西華長平潁川之舞陽X許鄢?陵河南之開封中牟陽武酸棗卷皆魏分之徙都大梁故魏一號為梁然則觜X參晉魏分非益州明矣蓋班固於地理志特為精詳而X於天文僅割裂史記參錯成篇故不免沿其竄入之文彼此抵捂而後世分野之說亦往往因之又
===
或漢改梁州為益州而魏晉亦虢?為梁注史記者因遂以魏晉之梁屬益州繫以分星竄入天官此所以由誤與今考明史天文志畢七度至井八度實沈之次屬山西井九度至柳三度鶉首之次屬陝西四川雲南此足以訂史漢及舊通志之誤矣 嘉慶壬申春二月知縣紀大奎謹識
===
|||什邡縣誌卷二 圖考志 星野地與譜圖
===
|||井宿分野圖
===
星經步天歌 井?八星橫列河中靜一星名鉞井邊安兩河個三南 北正天罇三星井上頭罇上橫列五諸侯上北河西積水欲覓積薪東畔是鉞下四星名水府水位東邊四星序四瀆橫列南河里南河下頭是軍市軍市團圓十三星 今六星 中心一X野雞精孫子丈人市下列各立兩星從東說闕邱二X南河東邱下一狼光蓬茸左畔九X彎弧弓一矢擬射頑狼胸有X老人南極中春秋出入壽無窮
===
|||疆域地與圖
===
|||
===
|||河道水利圖
===
|||
===
|||
===
|||城池圖
===
|||九聯坪禹母祠遺址圖
===
|||
===
|||鎣華山圖
===
|||
===
|||鎣華山圖
===
|||
===
|||鎣華山圖
===
|||
===
|||棲鳳山夫子院圖
===
|||
===
|||
===
|||南陽寺圖
===
|||洛水分派堰道圖
===
|||
===
|||南陽泉堰道圖
===
|||
===
|||
===
|||羅漢寺圖
===
|||
===
|||雍侯墓圖
===
|||洛書八方合十圖
===
附 什邡考 自秦漢已有什邡之名四川通志不詳其義邑乘謂因洛水所瀉之形號汁方語涉牽強按山海經岷山之首曰女幾之山洛水出焉水經注洛水出廣漢郡洛縣章山漢書地理志雒縣注章山雒水所出華陽國志導洛通山洛水經什邡洛雒通用今縣北有雒縣舊址以雒水得名水源在萬山中眾流交絡邑乘三江口山內有九聯坪雒流屈曲環繞禹王廟禹母祠基在焉基址鴻闊年代無稽
===
古碑屹立字跡不可辨疑秦漢間物相傳禹母居此帝王世紀禹生廣柔縣石紐鄉X兒坪今其地無可考通志雲在石泉又雲在汶川距章洛皆不遠未知孰是余惟神禹降生天比錫之苞符洛書之出或當在此河圖圓象天洛書方象地易曰著之德圓而神卦之德方以知著以圓衍卦從書列蓋洛書八方方皆合十一與九合十六與四合十七與三合十二與八合十初出之時疑即名之曰十方猶河圖之言五位也此地既有洛書之祥意
===
十方之名必藉藉久著秦郡縣天下取以名地加偏旁為什邡什亦作XX汁並音十邡亦作防並音方世遠遐X紀載無存後世遂失其自必以洛出書為河南之洛不復詳考矣余甫蒞斯邑未暇即至其地因覽志乘撫卷流連X然太息思大聖人鍾毓之祥有汨沒如斯者誰其信之誰其信之顧事雖無徵義實可據X書之以備考古者訂焉嘉慶丙寅秋七月知縣紀大奎謹識 附 九聯坪圖記
===
古郡邑所由名或以山或以水或以實蹟自漢以來什邡地甚著求其所由名不可得余嘉慶丙寅來蒞斯土覽邑乘三江口內九聯坪有禹廟及禹母祠遺址洛水環繞古碑屹立傳為禹母所居因念天生神禹靈龜出洛洛書八方合十祥瑞之符殆當在是作什邡考以詢之邑人士並求所謂九聯坪者坪在萬山嵯峨中今人跡所罕至而余吏事冗繁又足蹣跚不任屐齒撫卷流連蓋六載於茲今
===
制府奏修四川通志飭下諸郡邑採輯古今來事即紀載之所未備者乃令邑諸生劉子百川譚子靜漆子維棟孫子元樞等入山訪求越十餘日至其處繪圖以歸按圖自雒口高景關X流而上百數十里洛水發源之處奇峰重疊土人名之為九嶺山第一嶺高入雲漢其背為茂州地八嶺絡繹奔峙於前洛水出其旁其右章水出焉俗謂二道金河以兩水昔嘗出金故也自九嶺山以下逶迤數十里高峰特起山面壁立如削壁上近頂一巖名金
===
巖窩山前開大坪蟬聯左右次第凡幾九各寬十餘畝此所謂九聯坪是也一二三坪自右而左以次微低又下為第四坪又斜右出而中為第五坪又斜左第六坪坪左巨石高五尺餘圍二丈五尺中劃斷如鋸解寬一寸土人名鋸解石又斜右當五坪之下為第七坪八坪八坪斜右而上為第九坪與第六坪左右相對上三坪橫列山面高丈餘下六坪僅以次微低其第五坪當上下左右八坪之中人言古禹廟在此今土中尚有古磚瓦又
===
言舊X石皆鑿為磨古碑今無存洛水屈曲左繞會同貫溝之水橫逕坪前章水X山右合洛水為三江口又南行會乾河又十里許會通溪河皆自西注於洛通溪岸北高山雄踞周圍八脈小峰環擁山頂名八卦頂為九聯坪之下障頂右三泉各距五尺許深二尺寬丈餘清冽可飲洛水又南行會中河小河各澗水數十里出雒口高景關下關山險峻怪石磊磊蹲踞如虎豹與雲蓋山兩岸對峙儼若門戶蓋九嶺以下諸山之總鑰也余惟
===
九聯坪絡天開異境而九嶺八卦與洛書數位相似山水之靈相為孕育則余向疑洛書之出於此為什邡所由名者或不盡誣與通志引帝王世紀禹生廣柔縣石紐鄉X而坪以其地無可考或雲在石泉又雲在汶川此坪距縣百數十里華陽國志李冰導洛通山洛水出瀑口經什邡即本非古什邡境或前此為石泉軍所屬汶山郡所屬蓋未可知也邑乘舊無九嶺八卦諸名當時或失之漢書水經注皆言洛水出章山通志章山一名
===
章洛自明以來但知有鎣華不能確指章山之名或即以鎣華為章山又言即洛通山邑乘以鎣華北諸山之峻者圖之為章洛為洛通殆亦擬議之雲今章洛二水皆出九嶺而自一嶺以下諸嶺多上平爾雅釋山曰上正章疏雲山形上平者名章然則章山即九嶺之本名而九坪右章左洛環合交通殆即通志之章洛與華陽國志之洛通又或八卦頂洛水與通溪合流謂之洛通均未可知也余既未能親歷其地姑就今圖記之如此時嘉慶
===
壬申仲春月之廿有四日也知縣紀大奎謹識
===
什邡縣誌卷三 建置沿革志 什邡古蜀X近冉X地史記自邛X以東北君長以什數冉X為大 冉X地漢武X汶山郡 漢書高帝六年分置廣漢郡統縣十二有廣漢 莽曰廣信 什邡 莽曰美信 雒 有章山洛水 蜀漢章武二年分廣漢置梓潼郡什邡隸梓潼廣漢郡統廣漢德陽五城三縣晉書泰始二年置新都郡領四縣雒什邡隸焉元康六年九月罷新都郡改縣為南陽郡尋廢永嘉以後沿革不一有
===
南北陰平金山白水等郡名北周孝閔帝改縣曰方亭武帝天和間併入雒縣隋書開皇三年廢廣漢改屬蜀郡十八年改曰綿竹大業三年仍復名雒唐書武德二年析雒復置什邡縣武德三年又析雒復置德陽縣均屬益州垂拱三年析益州置縣五雒什綿德金堂隸漢州德陽郡宋書漢州德陽郡領四雒什綿德元史中統元年廢雒縣置漢州領三縣什綿德明史明玉珍據蜀復以州治立雒縣明制隸成都府仍統什綿德三縣洪
===
武十年省什邡入綿竹十三年仍置什邡縣國朝因之康熙二十六年省屬漢州直隸成都府 舊志 附考 依史志原本 什邡古蜀地蜀之為國肇自人皇史記索隱曰蜀西南夷舊有君長謂黃帝子昌意娶蜀山氏女也夏商因之武王牧野之會蜀與焉號蠶叢氏周襄王元年蠶叢氏稱王治瞿上 今雙流縣瞿上鄉 次柏灌次魚鳧 治導江 杜宇氏繼之七國稱王宇遂稱帝 治郫 號曰望帝會
===
水災蜀其臣鱉靈 楚人 治之宇遂讓位靈號叢帝 揚雄蜀本紀雲治廣都樊鄉 開明氏鱉靈九世孫開明尚立驅冉X服邛X徙治成都去帝號稱王周顯王時遂盡有X漢之地慎靚王五年巴蜀相攻 華陽國志蜀王封其弟於漢中號曰X侯侯與巴為好後與蜀為讐王怒伐X侯侯奔巴於是相攻 告急於秦秦遣張儀司馬錯伐蜀滅之開明氏遂亡 見外紀 秦得蜀封子通為蜀侯始皇二十六年罷侯置守列為蜀郡置雒縣因有汁邡之名
===
西漢高祖置廣漢郡六年庚子封雍齒為汁方侯謹按史記留後世家封雍齒為什方侯作什方高祖功臣年表作汁邡如淳曰汁音十邡音方漢書張良傳作什邡功臣表作汁防師古曰汁音十防音方武帝元朔二年甲寅春正月詔諸侯王得分國邑封子弟於是封雍侯庶子於王子城 寰宇記城在九隴縣 元鼎五年秋九月侯桓以X金故免宣帝元康四年巳未求高祖功臣子孫失侯者賜雍
===
侯元孫長安金復其家淮陽王更始元年癸未秋七月公孫述 扶風人 守臨邛時赤眉賊亂述假稱漢將軍明年自立為蜀王國號成改元龍興東漢光武建武十二年丙申春正月帝遣吳漢由魚涪津進拔廣都 今雙流縣 臧宮拔綿竹述敗死叛據十四年縣悉仍舊靈帝中平五年戊辰三月以劉焉為益州牧六月州從事賈龍迎焉徙治綿竹遂徙雒縣於什德之間
===
獻帝興平元年甲戌十二月綿竹城災焉徙治成都卒子璋襲稱益州牧建安十八年癸巳先主破涪圍雒十九年甲午雒縣潰先主進圍成都五月璋降二傳共二十四年縣仍舊制後漢昭烈入成都領益州牧建安二十五年庚子冬十月獻帝禪位於魏王曹丕改元黃初明年辛丑四月漢中王即帝位於武擔之南改元章武三年癸卯夏四月先帝崩於永安宮 今夔州府學 五月太子
===
禪即位後主景耀六年癸未改元炎興冬十月鄧艾入蜀破諸葛瞻於綿竹帝出降明年甲申魏改元咸熙十二月元帝禪位於晉王司馬炎晉武帝泰始元年乙酉春正月受魏禪元康六年改縣為南陽郡尋廢惠帝永寧元年辛酉春正月刺史趙X 巴西人 斬牙將李庠庠弟特流等叛屯綿竹X遣長史費遠屯兵於石亭以距之 今有石亭鋪 二月李特攻破石亭軍X走死明年二月益州刺史羅尚擊特斬之眾推特之子雄為牧光興元年丙寅六月雄據成都稱帝改元晏平國號成五傳而李勢立東晉穆帝永和三年丁未桓溫伐蜀三月李勢降共竊據四十六年縣仍晉制泰定帝元熙二年庚申禪位於劉裕國號宋為南北朝歷齊至梁縣併仍晉制梁簡文帝大寶二年辛未八月侯景廢帝立豫章王棟明年壬申十一月梁湘東王即位於江陵改元
===
承聖癸酉二月西魏宇文泰尉遲䢛?伐蜀八月取之蜀入於西魏縣併仍舊魏恭帝三年丙子十二月禪位於宇文覺 泰之子 國號周蜀隸於北周孝閔帝改縣為方亭武帝天和間併入雒縣移治廣漢隋文帝開皇三年癸卯廢廣漢郡單治雒縣隸於蜀郡唐高祖武德二年巳卯析雒復置什邡縣 一作X邡 屬益州武后垂拱二年改屬廣漢隸成都路
===
昭宗大順二年辛亥十月以王建為西川節度使建遂建立行台承制拜封 後梁太祖開平元年丁卯九月王建稱帝國號大蜀辛未改元永平二年壬申什邡獲銅碑建更子名元膺改縣曰通計戊寅改元光天六月建X子衍襲巳卯改元乾德縣仍復舊 後唐莊宗同光三年乙酉冬十月帝遣郭崇韜副魏王繼岌伐蜀十月衍出降凡二傳叛據三十五年十二月以董璋鎮東川孟知祥 形州龍崗人 鎮西川
===
明宗長興三年壬辰三月董璋襲西川克漢州知祥將兵趨救敗之西川兵入漢州是夕知祥宿雒縣 注雲州宅剽掠故宿雒 五月璋死祥幷東川明年封蜀王潞王清泰元年甲午正月知祥稱帝改元明德十一月X太子襲位更名昶戊戌改元廣政縣仍舊制宋太祖乾德二年甲子十一月遣王全斌伐蜀三年乙丑正月昶降凡二傳叛據共四十一年分成都為劍南路列什雒屬漢州 南宋理宗寶佑六年戊午 元憲宗八年 二月四川制置使
===
蒲擇之與元將鈕璘戰敗成都入於元遂廢雒縣置什邡屬州隸府 元順帝至正二十二年壬寅賊將明玉珍 隨州人 據重慶稱隴蜀王二十三年癸卯正月稱帝國號夏改元天統丙午三月玉珍卒子昇襲始十歲改元開熙 以上詳諸史 明太祖洪武三年庚戌十二月遣湯和等伐蜀四年辛亥五月明昇降凡二傳竊據共九年洪武九年丙辰分成都為川西道縣仍元制
===
崇禎八年乙亥流氛四熾正月諸賊大會於滎陽共十三家七十二營時賊寇李自成 米脂人 猶屬偏裨十年丁丑冬十月李自成犯蜀自梓潼分三路一走潼川一趨綿州一入江油分陷兩川諸州縣 明紀編年 崇禎十三年庚辰六月流寇張獻忠 膚施人明史延安柳樹澗人 自楚入蜀九月攻陷達州川西州縣多被劫掠後與川將張令方國安戰敗走匿白羊山中巳而復出屯開縣張令戰死施主女土司秦良玉亦敗遂
===
蹂躪東北西三川之地後復歸於襄陽 崇禎十七年甲申正月獻忠棄長沙領步騎數十萬陷夔州遂入蜀是年三月闖賊李自成自山西攻陷京師X廟徇國明亡 見紀事本末 國朝順治元年甲申五月故明南京諸臣尊立福王改元宏光命故大學士王應熊督川湖軍事兵力弱不果行獻忠在蜀陷涪州屠重慶三月十五日攻克成都蜀王闔宮被難忠遂X號大西改元大順冬十一月庚寅即偽位詭開科取士至集青羊宮
===
盡殺之筆墨成邱塚又殺各衛籍軍九十八萬人 見明史 遣將分屠州縣明年乙酉七月十五日屠漢州八月十五日屠什邡 耆舊夙傳 將卒以殺人多少論功 以右手為驗 故常百方刁誘設計屠戮遂致士民殆盡野無煙火先是獻忠殺戮川民川南豪士會英李占春千大海王祥陽展李勲等團結義兵互起殺賊故忠謀殺益毒 見明史 順治喪水分丁亥春正月嘉州楊展見賊屠川西悿毒統義師X江而上時賊以船載蜀金浮江而下遇
===
展江口因傾以赴X展連戰皆克與賊相持 見費氏X書 值王師伐蜀展密遣人迎附 肅王表展掛平西將軍印圖賊 見漢州萬人塚碑 比賊見川民盡謀窺西安遂焚夷成都率兵出川北又欲盡殺川兵偽將劉進忠故統川兵聞之潛逃遂來奔乞為鄉導 肅王命裨將雅布蘭與俱至鹽亭界大霧獻忠曉行猝遇我兵於鳳凰坡中矢墜馬蒲伏積薪下我兵曳出斬之川中自遭獻忠難列城內雜樹成拱狗食人肉
===
若虎豹X人死輒棄去不盡食也民逃深山中草衣木食久徧體生毛獻忠既誅餘賊尚據川西後賊屢敗賊黨孫可望等潰入川南殺會英李乾德後降於永明王 見明史 順治五年戊子李公國英來任巡撫討賊六年巳丑秋七月楊展為降將武大定袁韜等所害 順治七年庚寅展子璟新奉 命於川南轉運穀X分給牛種四面捕賊餘黨八年辛卯王師掃清餘氛奠安蜀土明年壬辰開科取士 補行辛卯科 縣仍明制 耆舊夙傳 康熙十三年癸丑冬逆藩吳三桂叛據雲南明年全蜀俱陷十九年庚申勇略將軍趙良棟統兵征討於正月二十四日入成都克復全川 通志 二十六年丁卯什邡省屬漢州直隸成都府 查二十六年邑民王相儒等赴憲屢訴屬州之累邑令胡之鴻詳X乃直隸府雍正四年請設直隸州 上憲議以什邡隸綿州邑貢生周進爵楊允實等赴訴各憲邑令管X傳通行詳X
===
什邡縣誌卷四 疆域志 什邡在府北一百四十里東西距四十五里南北距六十里東二十里抵直隸綿州德陽縣界西二十五里抵彭縣羅家場界南至迴龍橋十里下抵漢州界北五十里抵綿竹縣火燒堰界東南十五里抵漢州馬師院界東北二十三里抵新市鎮中分交綿竹縣界西南二十五里至三界橋交彭縣漢州界西北四十五里抵彭縣西北橋界
===
西北章山一帶東抵綿竹南抵彭縣西抵石泉縣雪山地界攀巖附險直約六十里橫約七十里編戶入朱李二村 方亭鄉分圖方一圖方二圖方三圖縣城在此鄉之中俗名縣村 南陽鄉在縣西北及高景關內外俗名朱村 永安鄉在縣西及寶山龍居二口內外俗名李村 新安鄉在縣西北中衝俗名甘村 康熙三十二年於方亭鄉內另分新甲一鄉
===
什邡縣誌卷五 形勢志 蓬山高矗剛水清環 通志 雄峙高景關保障西偏半壁分流古雒水潤霑南畝千渠 蜀沃野千里什僻壤一隅西北山高東南地衍上與彭綿共咽喉下為德漢所憑藉山中羊腸鳥道八步坎遙通陰平 即鄧艾入蜀處 分水嶺遠達尤溪 即灌縣路口 三江堡攀援可及威茂 三江堡係安綿彭什三十二堡之一馬尾白水龍
===
蟒等堡同為西山防汛明時曾置戍守 大山外左右咸列羌氐 左羌龍州 以外之夷右氐汶川以內之夷 籌邊守護殆未可忽幸無瑕 山名 高頂銀屏鎣峰環峙鐵壁天生保障從古恃之自山頂綿亘而下石亭江繞其東巢鳳山環其西其中平衍繍錯遙望章山藏風雲雷火之奇 山中有風巖火洞雲壑雷坪等異蹟 溯源洛水匯鶴雁魚龍之勝 有白鶴潭龍潭等名白魚河金雁江皆洛水所流派也 至若訪雪門寺之遺址 二程夫子讀書處在棲鳳山 想禹王之故蹟 山中有禹母祠遺址在九聯坪 尤令人景仰不置雲
===
什邡縣誌卷六 山川志 章山一名章洛山明一統志在縣西北六十里上有風洞即氣涼火洞即之氣熱肘名高境關山麗?名楊村壩漢書地理志章山雒水所出南至新都谷入湔有工官莽曰吾雒 舊制 雒通山縣西北一百五十里洛水發源此華陽國志苻堅有子避難於雒通山即此 舊志 按舊通志章山一名雒通山有名章洛山是一
===
山也邑舊志首章山縣西北六十里次雒通山西北一百五十里詢之山中人皆不能知山高路峻里數多少未可援以為定今X洛水發源之處奇峰磊磊土人名九嶺山山後為茂州地雲有黑龍泉自山穴中潛行出九嶺山谷流為金河二道按舊圖考之即洛水章水二源疑九嶺即洛通以泉自山後潛通也爾雅疏山形上平者名章九嶺危峻人跡罕到土人雲山嶺多上平疑亦即章山也然自高景關以內諸山上
===
平者多其大者如金巖窩八卦頂木瓜坪之類皆章洛水所經按其形勢即得以章洛洛通之名名之又舊志章山上有風洞火洞二洞在高景關外關山雄峙洛水由此而出謂之雒口則以高景關山為章為洛通亦無不類今既無從確指其實姑仍舊志分類二山以存其名俟博古者考焉知縣紀大奎識 金巖縣北一百四十里不知古何名即九聯坪之頂自九嶺山左分一支綿亘數十里高山壁立山頂
===
上平中起一小巖土人名金巖窩山前開九坪蟬聯各十餘畝禹母祠遺蹟在第五坪章水洛水左右環抱水曰金河山曰金巖疑此即古章洛山也 新增 八卦頂在九聯坪西南十里許山垂八脈各擁小峰巒山頂高聳上平濛濛煙霧中不知古何山名土人皆相傳為八卦頂按通溪河自山右入洛或此是洛通山也以上二山舊志無今增入 新增 無瑕山係章洛山之頂鎣華後山高峰壁立峭拔插
===
天兩肩如旗距俗呼火焰嶺人跡罕到其後為汶山為玉壘此山即玉壘諸山之東一峰 史志 鎣華山縣西北一百二十里山巔積雪四時不消 胡志 今為明本福地 史志 按九嶺山左分一支為九聯坪右分一支出鎣華山為縣脈起祖山最靈異古山名無考或謂即章山相傳高僧明本明天順間建寺於此改今名後遂以明本為鎣華祖師俗訛紛藉不知其所自始每歲自三月至六月朝山男婦X集
===
遠方之人雖嚴示不能禁民不務實行而X神求福每念及此為之愧X雖然佛氏以清凈為本僧如有靈非第X神不福必更有蹙然不自安者寧獨有司之愧也與哉紀大奎識 分水嶺治北一百一十里什彭分界右為小河之源 史志 鳳棲山一名棲賢山漢州古志在縣西六十二里其下為二程夫子講學處相傳東漢時有鳳棲於此 史志 今山下有夫子院舊名雪門寺詳見古蹟
===
高景關山治西北五十里山形峭拔與綿竹雲蓋山對峙水流潭底人過虛空曲路倒轉儼如門戶 史志 按高景一作高境洛水出口處 太蓬山治西北五十三里明以統志雲據一邑之勝高崖矗天瀑布飛瀉最為奇觀 史志 山在高景關側舊通志作大蓬 楊村山即楊村壩後山今俗名青嘴山 史志 小九峰山治西北六十五里峰下有寺名凈土山口外有寺名下院凈土寺僧田在焉 丁志
===
龍居山縣西五十二里方與勝覽雲有等慈院飛瀑千尺虛亭屹然橋橫路轉高柏雍翠上有龍居寺 史志 明成化時所建古殿猶存 寶蓮山在龍居山之左正峰如寶蓋傍岡如蓮瓣扶繞望之爽心豁目 史志 以上山內有木瓜坪九聯坪三江口麻柳坪板坪鹽井灘X窩坪欲湔壩皂莢坪黃鹿坪雷洞坪X光台唐家坪老道坪獅子坪白雲山古尤坪石門洞白鹿坪龍神巖黃楊坪老鷹巖天生
===
坪蜂岩烏木莊八步坎天車坡碗子嶺溜沙坡截刀嶺兩河口回光山酥骨嶺石馬峰高樓峰頂心坡三X坪三刀截等地名 史志 湧泉山縣西五十里山形高聳峰嶺XX撲向田疇山麗之下死亡平田離山腳三里許突發一泉四季流水不竭曰湧泉 史志 九嶺岡縣西三十里湧泉之下平岡突起俗名白虎頭逶迤里許山腹漸大九脈起伏岡勢蜿蜒 胡志 巢鳳山治西三十五里自九嶺岡至此山勢斜插左
===
舒右斂凸起高峰形如巢鳳舊名慈母山託為目連事蹟怪誕不經殊失山靈鍾奇毓秀之意故易以今名 知縣史進爵 吉陽山巢鳳山對岸鴨子河經其下左白塔右龍潭襟帶小邱此巒秀出其間獨大上接彭縣分界處山後有白塔係宋天聖年建塔上層層石刻皆什邡縣字樣其募化錢財皆什邡村鎮地名查彭縣丹景山有古碑名此為什邡塔知縣李允符在任時互爭失之今為彭州所屬 史志
===
隱峰山 見仙女洞碑 治西南二十五里自吉陽山右臂豐隆而下遍列田疇下抵高家山形如弓眠內抱直至漢州故名今遊覽者覆漢州火盆山登高回望儼然一峰自天彭葛X中抽下壩綿亘西陸直抵東山會合北來諸嶺恍若此中有山嶺盤旋及驗漢彭壩中處處只見田塍高低一片平鋪之形並未見山則此山殆漢什之內障也考縣西山脈自彭邑紅岩子過水穿田湔水繞乎左廉江行乎右交會於馬腳鎮之西北隅循之逆上累累小山X
===
羅列鎮塞於期間其中田土廣大寬綽殊為美境 史志 按仙女洞側有前明成化九年隱峰山壽尊寺祖庭如禪師道行碑一通故史志據碑增入隱峰山名壽尊寺在仙女洞前以形勢考之即仙女洞山名也碑文多殘缺今不載 雍齒山通志雲在縣城南四百步 史志 大墓山有二皆在治西二十五里彼此相去約五里 史志
===
黃帽山治南十里連漢州界細考山形未係生成恐係王墓之訛明時王墓有曾經崩潰者內皆火磚修砌外方壅土如小山形大墓山類此各處皆有而華陽東山累累更多 志史 雒水今名石亭江在縣北東流入漢州界劉焉治綿竹時鑿石壘亭以鎮雒水故以名江晉書蜀郡太守李苾遣督護常俊長史費遠督萬餘人斷北道屯於石亭以據李特即此華陽國志李冰導雒水於雒通山水經注雒水出雒縣章山蜀水考雒水
===
出什邡章雒山按雒水淬刀快利故又名剛雒 胡志 考洛水有三書言伊洛在河南禮雍州其川洛X在陝西水經注洛水出章山此指什邡之洛湘中記雲湘水置清雖深五六尺見底了了然石子如X蒲白沙如霜雪赤岸如朝霞今雒水清甘澄澈雖深一二丈畢見纖塵關潭產魚色青碧鱗細如清水波紋但少且不易得陳明卿曰蜀江之水非一而以岷瀘洛巴為大 按九域志什邡縣有X江寰宇託X江在縣東北八十里源出雒通山
===
今考西山諸水X江並無實蹟他書亦不載是九域寰宇誤以洛為X也又按通志載石亭江經縣城東北十里流入漢州界X江在縣東北十八里是有因九域寰宇字樣以白魚河誤以為石亭江石亭江誤以為X江也今並詳考如左 史志 石亭江即雒水源發雒通山左出三江口俗名大河環流一百六十里抵高景關關外白鶴潭右分上堰口又二里右分下堰口左分火燒堰入綿竹界又一里為下堰之總堰口正派流下經縣東二
===
十里入漢州 史志 竹溪河源發章山之西至高橋鋪入大河俗名中河 史志 湔氐河在縣西九十里土人呼塹底河又名櫸溪河源出土地嶺 什彭分界處 自南逆北經龍居九峰山之後抵八角廟左有小河自分水嶺來會繞鳳棲山下入雒俗名小河俞安期山水紀蜀水以江為宗自江以北諸山皆曰岷諸水皆曰湔漢志雲玉壘山湔水所出邑之無瑕山玉壘之一也因山舊
===
隸湔氐道故名考川西之水岷江為瀆自江所出者皆為沱自江以北彭門左右別出之水為湔什邡之水為洛綿竹之水為綿自綿而北有涪水潼水皆入西漢水嘉陵江會岷江於渝城若沱若湔若綿又皆以洛為宗洛水自什綿而德漢由金堂出懷簡歷資中內江達富順過南溪會岷江於瀘城之東號為內水故瀘州北塔頂上前賢曾題有洛水朝宗之詩 史志 官渠河係堰右分之河 倒流河係上堰左分
===
之河康熙六十一年二河紛爭水分奉 撫憲蔡委官驗立制口平流詳文載河岸碑 史志 小石河下堰右分之河 馬沿河下堰正支之河流五十里入漢州界為沈犀江褚亮詩列宿光輿井分芒跨梁岷沈犀對江浦駟馬入城闕?白魚河下堰左分之河流四十里經禾豐場下入漢州界因白魚為水患得名 史志 義橋河縣東北五里 史志 馬沿河分派一支之下流入漢州
===
三岔河縣西三十里官渠河之下流也 史志 黃土河縣西十八里倒流河之下流也南陽寺東西泉水入焉 史志 金帶河縣西六里相傳昭烈帝遺帶於此化龍而去 胡志 或曰其水曲折環抱邑西故名襟帶 史志 此小石河倒流河之尾水與南陽泉一支合流入鴨子河歸漢州 按山海經岷山之首曰女幾之山洛水出焉東注於江女幾古山名今不可考要其為漢志水
===
之河康熙。。。流入漢州
===
三岔河縣。。。為漢志水
===
經注雒縣章山之雒水固可無疑今考洛水發源九嶺山環遶東北七八十里逕九聯坪東南會章水及乾河通溪河諸水皆自西注於洛土人名曰大河又南至高橋場會中河諸澗之水又至棲鳳山會小河諸澗之水至高景關出口名曰雒口河流遂大華陽國志蜀王杜宇稱帝以褒斜為前門熊耳為後戶玉壘峩眉為城郭江潛綿洛為池澤此當日洛水為鉅觀也後世引水灌田自關口以外分而為官渠諸
===
河又分而為白魚諸河又分而為綿竹之火燒堰於是正河淺涸幾不復知有山海水經之舊矣余惟河圖洛書伏羲大禹之瑞而岷山女幾之洛與河南X舉之洛並著山海經九嶺八卦諸山眾流交絡曲折盤旋最為靈異禹固汶山郡人史記岷山作汶山然則洛出書之為岷山以南之洛而非必其為河南X舉之洛固事與理之可信者余故不憚再三考之如此並詳圖考志紀大奎識
===
南陽泉河縣西二十里兩歧泉流共匯為河凡受灌居民每春設牲醴祭禱邑中諸泉惟此為最 史志 雙溪河縣西十二里源出南陽泉橋下歧分左右沛澤河右名磚橋河 史志 玉馬河縣西南十二里自南陽泉石滾河流至自黃土以下三河陸續會合流入漢州名雁?水 史志 按南陽泉自天生橋下右分一支合倒流河尾水入黃土河其左一支正河流至玉馬橋下左右又分出二支中一支柏林堰水短左右二支
===
各別為河俱下入鴨子河會右一支黃土河同歸漢州舊志雙溪河及左沛澤右磚橋等名今土人皆不能知疑即玉馬橋下之柏林堰左右二支也 馬腳河縣西南二十里源發彭縣三郎鎮本縣三岔河之下流合焉相傳昭烈?帝過此馬跌岸石上有故蹟後人因建漢帝宮以紀其事 丁志 即漢州金雁?河之上流今人呼為野鴨河恐乃雁之訛又呼鴨子河河之高岸冬多藏燕頷赤如金又恐鴨為
===
燕之訛也此即湔水之一 史志 洛江水縣西二十七里寰宇記源出九隴縣兩歧山 即彭門 經縣界亦名廉江水今羅家場小石河是下流至馬腳鎮合鴨子河入漢州界為金雁?江 史志 盤江河縣西二十五里水自彭縣關口小石河下分為三右一支入縣境泉水溝中為羅江水左為盤江河與鴨子河同源至縣西南復合流入鴨子河歸漢州舊志通志標名新婦水非河本名新婦水另入古蹟
===
什邡縣誌卷七 戶口志 明洪武間戶肆百四拾口叁千壹百柒拾伍嘉靖二十五年增戶捌拾口肆百貳拾肆隆慶萬曆間同 漢州古志 國朝自康熙六年奉文清查起至五十九年戶共貳仟陸百貳拾貳丁共玖佰柒拾叁每丁徵銀捌分貳釐毫伍絲捌忽 丁志 雍正七年清查起至十年編審主戶伍仟伍佰陸拾
===
捌戶主戶丁口伍仟伍佰陸拾捌丁佃戶壹百肆拾叁戶佃戶丁口壹百肆拾叁丁共計戶伍仟柒百壹拾壹丁口 史志 乾隆十一年編審戶伍仟玖佰捌戶主戶釘扣伍仟玖佰捌丁佃戶壹百柒拾捌戶佃戶丁口壹百柒拾捌丁口共計陸千捌拾陸戶共計釘扣陸千捌拾陸丁口 史志 乾隆十年起至十九年止現編人丁陸千貳百九十肆丁 二十年起至二十九年止現編人丁柒千
===
貳百壹拾玖丁 三十年起至三十九年止現編人丁一萬壹仟貳百陸拾捌丁 四十年起至四十九年止現編人丁一萬捌仟肆佰貳拾玖丁 五十年起至五十九年止現編人丁貳萬貳仟叁佰肆拾肆丁 賦役全書 乾隆六十年起至嘉慶九年止現編人丁肆萬捌仟捌佰玖拾丁 賦役全書 嘉慶十七年報部承糧花戶肆萬玖千貳百伍拾玖戶男捌萬伍仟肆佰肆拾貳丁婦陸萬貳仟玖佰
===
貳拾口共壹拾肆萬捌仟叁佰陸拾貳丁口 附 保甲 縣城內外里甲五名 保正五名 方一圖里甲四名 保正八名 方二圖里甲七名 保正十二名 方三上圖里甲七名 保正十二名 方三下圖里甲五名 保正九名 南陽鄉里甲四名 保正十四名 新安鄉里甲五名 保正九名
===
永安鄉里甲六名 保正十四名 新甲里甲十二名 保正十二名 場鎮約保 永興場街約五名 保正五名 徐家場街約五名 保正五名 馬腳鎮街約五名 保正五名 街子場街約三名 保正三名 興隆場街約一名 保正二名 靈傑場街約一名 保正二名
===
紅廟場街約一名 保正一名 白廟場街約一名 保正一名 朱家橋街約一名 保正一名 禾豐場街約一名 保正二名 新市鎮街約一名 保正二名 高橋場街約二名 保正二名 隆興場街約一名 保正一名 趙家場街保一名 復興場街保一名
===
雙土地街保一名 鹽井灘街保一名 八角廟街保一名 每歲各鄉查造煙戶編連保甲以十戶為一牌立一牌頭五牌為一里甲里甲管理戶口條糧催收等事保正管理稽查地方稟報事故等事至本城內外及各場市鎮設立街保視場之大小以定其數管理各處公務巡查匪類稟
===
報事故等事以上皆輪年報替
===
什邡縣誌卷五十 金石志 邑舊多三教堂鑄儒釋道三像乾隆九年奉部議改革邑令史進爵建方亭書院適成迎 至聖像安於中堂後邑令石欽承奉於奎閣繼又奉於文昌祠後殿乾隆四十一年邑令任思正建樓於書院之後迎聖像安奉於其上像有三銅二鐵一鐵像高五尺銅像四尺有餘又
===
至聖鐵像一尊在治北六十里夫子院明萬曆七年張超張成張崇鑄像高四尺 古佛鐵像四尊在治西十里大觀音寺明成化十一年鑄 真武祖師鐵像一尊在署北街真武 宮明宏治年間鑄 馬祖銅像一尊在治北里許羅漢寺明萬曆間邑人徐應聘鑄 觀音鐵像一尊彌陀銅像一尊在治北五十XXX相寺明成化間鐵XXXXXXXXXX老君鐵像一尊文昌鐵像一尊在治西五里三教堂 明嘉靖二十五年鑄 古佛鐵像一尊在治北三十里黃泥庵明萬曆九年鑄 五顯鐵像一尊在治東一里土主廟明天啟年間鑄燃燈古佛鐵像一尊在治南六里為妥庵頹垣中掘出年代無考 鐵大釜二鐵罐一在治北六十里凈土寺明成化年
===
間僧慧祥鑄 銅鏡厚二寸五分圍七尺五存徑二尺二寸五分在治北 194
| shifangzhi/ShifangXianZhi | ShifangZhi.md | Markdown | mit | 52,914 | [
30522,
100,
100,
100,
1929,
100,
100,
100,
100,
1751,
100,
100,
100,
100,
100,
100,
100,
100,
100,
100,
1900,
100,
100,
100,
100,
1873,
100,
100,
1831,
1835,
1977,
100,
100,
1060,
100,
1756,
100,
100,
1851,
100,
100,
100,
100,
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... |
/**
* #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
* This file is part of the Smart Developer Hub Project:
* http://www.smartdeveloperhub.org/
*
* Center for Open Middleware
* http://www.centeropenmiddleware.com/
* #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
* Copyright (C) 2015-2016 Center for Open Middleware.
* #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
* 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.
* #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
* Artifact : org.smartdeveloperhub.harvesters.scm:scm-harvester-frontend:0.3.0
* Bundle : scm-harvester.war
* #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
*/
package org.smartdeveloperhub.harvesters.scm.frontend.core.util;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.fail;
import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import mockit.Expectations;
import mockit.Mocked;
import org.ldp4j.application.data.DataSet;
import org.ldp4j.application.data.Individual;
import org.ldp4j.application.data.Name;
import org.ldp4j.application.data.NamingScheme;
import org.ldp4j.application.ext.ApplicationRuntimeException;
import org.ldp4j.application.session.ContainerSnapshot;
import org.ldp4j.application.session.ResourceSnapshot;
import org.ldp4j.application.session.WriteSession;
public abstract class AbstractCappedContainerHandlerTestHelper {
private final class CustomDataSet implements DataSet {
@Override
public Iterator<Individual<?, ?>> iterator() {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public Name<?> name() {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public int numberOfIndividuals() {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public boolean hasIndividuals() {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public Collection<? extends Individual<?, ?>> individuals() {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public Set<Serializable> individualIds() {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public boolean hasIndividual(final Object id) {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public <T extends Serializable, S extends Individual<T, S>> S individualOfId(final T id) {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public <T extends Serializable, S extends Individual<T, S>> S individual(final T id, final Class<? extends S> clazz) {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public boolean isEmpty() {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public void remove(final Individual<?, ?> src) {
throw new UnsupportedOperationException("Method should not be invoked");
}
@Override
public String toString() {
return "DATASET";
}
}
@Mocked private ContainerSnapshot container;
@Mocked private WriteSession session;
@Mocked private ResourceSnapshot snapshot;
protected final void verifyGetReturnsEmptyDataset(final AbstractCappedContainerHandler sut) throws Exception {
final Name<String> name=NamingScheme.getDefault().name("id");
new Expectations() {{
AbstractCappedContainerHandlerTestHelper.this.snapshot.name();this.result=name;
}};
final DataSet result = sut.get(this.snapshot);
assertThat((Object)result.name(),sameInstance((Object)name));
assertThat(result.hasIndividuals(),equalTo(false));
}
protected final void verifyFactoryMethodIsDisabled(final String name, final AbstractCappedContainerHandler sut) {
try {
sut.create(this.container, new CustomDataSet(), this.session);
fail("Factory method should be disabled");
} catch (final ApplicationRuntimeException e) {
assertThat(e.getMessage().toLowerCase(),equalTo(name+" creation is not supported"));
}
}
}
| SmartDeveloperHub/sdh-scm-harvester | frontend/src/test/java/org/smartdeveloperhub/harvesters/scm/frontend/core/util/AbstractCappedContainerHandlerTestHelper.java | Java | apache-2.0 | 4,942 | [
30522,
1013,
1008,
1008,
1008,
1001,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
1027,
1011,
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... |
# Using OSX FileMerge as diff tool
You can with success specify the *FileMerge* application bundled with *Xcode* as diff tool on the command line, this does require that you use the command line wrapper tools specified on the FileMerge page.
```bash
% svn diff --diff-cmd fmdiff <some file>
```
| jonasbn/til | subversion/use_filemerge_for_diff.md | Markdown | mit | 297 | [
30522,
1001,
2478,
9808,
2595,
5371,
5017,
3351,
2004,
4487,
4246,
6994,
2017,
2064,
2007,
3112,
20648,
1996,
1008,
5371,
5017,
3351,
1008,
4646,
24378,
2007,
1008,
1060,
16044,
1008,
2004,
4487,
4246,
6994,
2006,
1996,
3094,
2240,
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... |
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct point { x: int, y: int }
trait methods {
fn impurem(&self);
fn blockm(&self, f: ||);
}
impl methods for point {
fn impurem(&self) {
}
fn blockm(&self, f: ||) { f() }
}
fn a() {
let mut p = point {x: 3, y: 4};
// Here: it's ok to call even though receiver is mutable, because we
// can loan it out.
p.impurem();
// But in this case we do not honor the loan:
p.blockm(|| {
p.x = 10; //~ ERROR cannot assign
})
}
fn b() {
let mut p = point {x: 3, y: 4};
// Here I create an outstanding loan and check that we get conflicts:
let l = &mut p;
p.impurem(); //~ ERROR cannot borrow
l.x += 1;
}
fn c() {
// Loaning @mut as & is considered legal due to dynamic checks...
let q = @mut point {x: 3, y: 4};
q.impurem();
// ...but we still detect errors statically when we can.
q.blockm(|| {
q.x = 10; //~ ERROR cannot assign
})
}
fn main() {
}
| fabricedesre/rust | src/test/compile-fail/borrowck-loan-rcvr.rs | Rust | apache-2.0 | 1,426 | [
30522,
1013,
1013,
9385,
2262,
1996,
18399,
2622,
9797,
1012,
2156,
1996,
9385,
1013,
1013,
5371,
2012,
1996,
2327,
1011,
2504,
14176,
1997,
2023,
4353,
1998,
2012,
1013,
1013,
8299,
1024,
1013,
1013,
18399,
1011,
11374,
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... |
# frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is
# 3000.
#
port ENV.fetch('PORT') { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
# option you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
| wanganyv/cii-best-practices-badge | config/puma.rb | Ruby | mit | 2,038 | [
30522,
1001,
7708,
1035,
5164,
1035,
18204,
1024,
2995,
1001,
16405,
2863,
2064,
3710,
2169,
5227,
1999,
1037,
11689,
2013,
2019,
4722,
11689,
4770,
1012,
1001,
1996,
1036,
16457,
1036,
4118,
4292,
3138,
2048,
3616,
1037,
6263,
1998,
4555,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2014-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.amazonaws.services.mediaconvert.model;
import javax.annotation.Generated;
/**
* Use Deinterlacer (DeinterlaceMode) to choose how the service will do deinterlacing. Default is Deinterlace. -
* Deinterlace converts interlaced to progressive. - Inverse telecine converts Hard Telecine 29.97i to progressive
* 23.976p. - Adaptive auto-detects and converts to progressive.
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public enum DeinterlacerMode {
DEINTERLACE("DEINTERLACE"),
INVERSE_TELECINE("INVERSE_TELECINE"),
ADAPTIVE("ADAPTIVE");
private String value;
private DeinterlacerMode(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
/**
* Use this in place of valueOf.
*
* @param value
* real value
* @return DeinterlacerMode corresponding to the value
*
* @throws IllegalArgumentException
* If the specified value does not map to one of the known values in this enum.
*/
public static DeinterlacerMode fromValue(String value) {
if (value == null || "".equals(value)) {
throw new IllegalArgumentException("Value cannot be null or empty!");
}
for (DeinterlacerMode enumEntry : DeinterlacerMode.values()) {
if (enumEntry.toString().equals(value)) {
return enumEntry;
}
}
throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
}
}
| jentfoo/aws-sdk-java | aws-java-sdk-mediaconvert/src/main/java/com/amazonaws/services/mediaconvert/model/DeinterlacerMode.java | Java | apache-2.0 | 2,135 | [
30522,
1013,
1008,
1008,
9385,
2297,
1011,
10476,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "ros1initializer.h"
#include <ros/ros.h>
#include <common/logging.h>
using namespace roscommunication;
Ros1Initializer::Ros1Initializer(QString name)
: mInitialized(false)
{
ros::VP_string initString;
QString nodeName = name;
ros::init(initString, nodeName.toStdString());
if(!ros::isInitialized())
{
debug(LOG_ERROR, "RosInitializer", "Could not initialize ROS");
return;
}
mInitialized = true;
debug(LOG_WARNING, "RosInitializer", "Initialized");
ROS_INFO("ROS initialized");
}
bool Ros1Initializer::initialized() const
{
return mInitialized;
}
| piappl/ros2_benchmarking | comm/ros1node/ros1initializer.cpp | C++ | lgpl-3.0 | 620 | [
30522,
1001,
2421,
1000,
20996,
2015,
2487,
5498,
20925,
17629,
1012,
1044,
1000,
1001,
2421,
1026,
20996,
2015,
1013,
20996,
2015,
1012,
1044,
1028,
1001,
2421,
1026,
2691,
1013,
15899,
1012,
1044,
1028,
2478,
3415,
15327,
30524,
4892,
217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#region Copyright 2010 by Roger Knapp, Licensed under the Apache License, Version 2.0
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Security.Cryptography;
using Interop.BugTraqProvider;
using CSharpTest.Net.WinForms;
using CSharpTest.Net.Crypto;
using CSharpTest.Net.SvnPlugin.Interfaces;
using CSharpTest.Net.SvnPlugin.UI;
using System.Runtime.CompilerServices;
using System.Configuration;
using CSharpTest.Net.Serialization;
namespace CSharpTest.Net.SvnPlugin
{
/// <summary>
/// COM Registered InterOp for TortoiseSVN integration
/// </summary>
[ComVisible(true), ProgId("SvnPlugin.MyPlugin"), Guid(MyPlugin.GUID), ClassInterface(ClassInterfaceType.AutoDual)]
public class MyPlugin : IDisposable, IBugTraqProvider, IBugTraqProvider2
{
const string GUID = "CF732FD7-AA8A-4E9D-9E15-025E4D1A7E9D";
const string CLSID = "{" + GUID + "}";
const string BUTTON_TEXT = "{0} Issues";
private IIssuesService _connector = null;
private IIssuesServiceConnection _service = null;
private IssuesListView _issues = null;
private Configuration _config = null;
private bool _cancelled = true;
/// <summary> Constructs a MyPlugin </summary>
public MyPlugin()
{
//System.Diagnostics.Debugger.Break();
Log.Write("Started, logging to {0}", Log.Config.LogFile);
Resolver.Hook();
CertificateHandler.Hook();
}
#region Public Interfaces:
/// <summary> Returns true if the operation was cancelled </summary>
public bool Canceled { get { return _cancelled; } }
private string GetAppSetting(string name)
{
if (_config == null)
{
Log.Verbose("Settings = {0}", this.GetType().Assembly.Location);
_config = ConfigurationManager.OpenExeConfiguration(this.GetType().Assembly.Location);
}
KeyValueConfigurationElement setting = _config.AppSettings.Settings[name];
return setting == null ? null : setting.Value;
}
/// <summary> Returns the Issue tracking connector </summary>
public IIssuesService Connector
{
get
{
if (_connector == null)
{
string fullClass = GetAppSetting(typeof(IIssuesService).FullName);
Log.Verbose("IIssuesService = '{0}'", fullClass);
if (string.IsNullOrEmpty(fullClass))
throw new ApplicationException("Unable to locate CSharpTest.Net.SvnPlugin.Interfaces.IIssuesService entry in app.config");
_connector = (IIssuesService)Type.GetType(fullClass, true).InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, null, null);
}
return _connector;
}
}
/// <summary>
/// Returns true if the configuration is present (not nessessarily valid)
/// </summary>
public bool IsConfigured(IntPtr hParentWnd, string rootUrl, string commonRoot)
{
string service, user, password;
return TryParseParameters(hParentWnd, rootUrl, commonRoot, out service, out user, out password);
}
/// <summary>
/// Attepts to log on to the specified instance. The instance url must contain a user
/// name in the format of "http://user@server:port/".
/// </summary>
public bool Logon(IntPtr hParentWnd, string rootUrl, string commonRoot)
{
string message;
if (_service != null)
return true;
if (!TryLogon(hParentWnd, rootUrl, commonRoot, out message, out _service))
{
ShowError(hParentWnd, String.Format("Unable to connect to {1}, check your configuration.\r\nReason: {0}", message, Connector.ServiceName), "Login Error");
return false;
}
return _service != null;
}
/// <summary>
/// Prompt the user for the comments and related issues
/// </summary>
public string GetCommitMsg(IntPtr hParentWnd, string rootUrl, string originalMessage, string commonRoot, string[] files)
{
string message = originalMessage;
try
{
if (!Logon(hParentWnd, rootUrl, commonRoot))
return originalMessage;
if (_issues == null)
_issues = new IssuesListView(_service, originalMessage, files);
else
_issues.SyncComments(originalMessage);
IssuesList form = new IssuesList(_issues);
if (hParentWnd == IntPtr.Zero)
form.ShowInTaskbar = true;
if (form.ShowDialog(Win32Window.FromHandle(hParentWnd)) != DialogResult.OK)
{ _cancelled = true; return originalMessage; }
_cancelled = false;
return _issues.GetFullComments();
}
catch (OperationCanceledException) { _cancelled = true; return originalMessage; }
catch (Exception ex)
{
ShowError(hParentWnd, ex.Message, ex.GetType().FullName);
throw;
}
}
/// <summary>
/// Commit the requested changes for any related issues
/// </summary>
public string CommitChanges(IntPtr hParentWnd, string originalMessage, int revision, string[] files)
{
if (Canceled) return originalMessage;
if (_service == null || _issues == null)
throw new UnauthorizedAccessException();
_issues.SyncComments(originalMessage);
StringBuilder sbResponse = new StringBuilder();
sbResponse.AppendFormat("{0}", originalMessage);
if (GetAppSetting("addRevisionComment") == "false")
revision = -1;
if (GetAppSetting("addFilesComment") == "false")
files = new string[0];
foreach (Exception e in _issues.CommitChanges(revision, files))
{
sbResponse.AppendLine();
sbResponse.AppendFormat("ERROR: {0}", e.Message);
}
return sbResponse.ToString();
}
#endregion
#region Private Helpers
void ShowError(IntPtr hParentWnd, string text, string caption)
{
_cancelled = true;
MessageBox.Show(Win32Window.FromHandle(hParentWnd), text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
void SaveSettings(string userId, string uri, string password)
{
INameValueStore storage = new CSharpTest.Net.Serialization.StorageClasses.RegistryStorage();
try
{
if (String.IsNullOrEmpty(password))
{
storage.Delete(uri, "UserName");
storage.Delete(uri, "Password");
}
else
{
storage.Write(uri, "UserName", userId);
storage.Write(uri, "Password", Encryption.CurrentUser.Encrypt(password));
}
}
catch { }
}
string ReadSettings(IntPtr hParentWnd, string serviceUri, ref string userId)
{
INameValueStore storage = new CSharpTest.Net.Serialization.StorageClasses.RegistryStorage();
try
{
string password;
storage.Read(serviceUri, "UserName", out userId);
if (storage.Read(serviceUri, "Password", out password))
return Encryption.CurrentUser.Decrypt(password);
}
catch { }
PasswordEntry pwdDlg = new PasswordEntry(userId, serviceUri);
if (pwdDlg.ShowDialog(Win32Window.FromHandle(hParentWnd)) == DialogResult.OK)
{
userId = pwdDlg.UserName.Text;
SaveSettings(userId, serviceUri, pwdDlg.Password.Text);
return pwdDlg.Password.Text;
}
return null;
}
bool TryParseParameters(IntPtr hParentWnd, string parameters, string commonRoot, out string serviceUri, out string user, out string password)
{
serviceUri = user = password = null;
if (String.IsNullOrEmpty(parameters) && !String.IsNullOrEmpty(commonRoot))
{ //Read from svn...
SvnProperties props = new SvnProperties(commonRoot);
string testUri = props.Search(".", true, Connector.UriPropertyName);
if (!String.IsNullOrEmpty(testUri))
parameters = testUri;
}
if (String.IsNullOrEmpty(parameters))
{
string test = System.Configuration.ConfigurationManager.AppSettings[Connector.UriPropertyName];
if (!String.IsNullOrEmpty(test))
parameters = test;
}
Uri uri;
if (Uri.TryCreate(parameters, UriKind.Absolute, out uri))
{
serviceUri = String.Format("{0}://{1}:{2}{3}", uri.Scheme, uri.Host, uri.Port, uri.PathAndQuery);
if (!String.IsNullOrEmpty(uri.UserInfo))
{
string[] parts = uri.UserInfo.Split(':');
if (parts.Length == 2 && !String.IsNullOrEmpty(parts[0]) && !String.IsNullOrEmpty(parts[1]))
{
user = parts[0];
password = parts[1];
}
else
{
user = uri.UserInfo;
password = ReadSettings(hParentWnd, serviceUri, ref user);
}
}
else
password = ReadSettings(hParentWnd, serviceUri, ref user);
if (!String.IsNullOrEmpty(user) && !String.IsNullOrEmpty(password))
return true;
}
return false;
}
string GetParamDesc()
{
string message = "Parameter must be a valid absolute uri optionally with \r\n" +
"a user name and password. Leave blank to read value from svn \r\n" +
"property named: '{0}'\r\n" +
"\tExample 1: http://{2}.com:8080\r\n" +
"\tExample 2: http://username@{2}.com:8080\r\n" +
"\tExample 3: http://username:password@{2}.com:8080";
return String.Format(message, Connector.UriPropertyName, Connector.ServiceName, Connector.ServiceName.ToLower());
}
bool TryLogon(IntPtr hParentWnd, string parameters, string commonRoot, out string message, out IIssuesServiceConnection service)
{
IIssuesService connector = this.Connector;
string serviceUri, user, password;
message = null;
service = null;
if (!TryParseParameters(hParentWnd, parameters, commonRoot, out serviceUri, out user, out password))
{
message = GetParamDesc();
return false;
}
try
{
if (!connector.Connect(serviceUri, user, password, GetAppSetting, out service))
{
SaveSettings(user, serviceUri, null);
return false;
}
return true;
}
catch (Exception e)
{
Log.Error(e);
message = e.Message;
return false;
}
}
#endregion
/// <summary> Releases any locked resources </summary>
public void Dispose()
{
if (_issues != null)
_issues.Dispose();
_issues = null;
if (_service != null)
_service.Dispose();
_service = null;
}
#region IBugTraqProvider2 Members
bool IBugTraqProvider2.ValidateParameters(IntPtr hParentWnd, string parameters)
{
try
{
return String.IsNullOrEmpty(parameters) || Logon(hParentWnd, parameters, null);
}
catch (Exception e) { Log.Error(e); throw; }
}
string IBugTraqProvider2.GetLinkText(IntPtr hParentWnd, string parameters)
{
try
{
return String.Format(BUTTON_TEXT, Connector.ServiceName);
}
catch (Exception e) { Log.Error(e); throw; }
}
string IBugTraqProvider2.GetCommitMessage(IntPtr hParentWnd, string parameters, string commonRoot, string[] pathList, string originalMessage)
{
try
{
return GetCommitMsg(hParentWnd, parameters, originalMessage, commonRoot, pathList);
}
catch (Exception e) { Log.Error(e); throw; }
}
string IBugTraqProvider2.GetCommitMessage2(IntPtr hParentWnd, string parameters, string commonURL, string commonRoot, string[] pathList, string originalMessage, string bugID, out string bugIDOut, out string[] revPropNames, out string[] revPropValues)
{
try
{
bugIDOut = bugID;
revPropNames = new string[0];
revPropValues = new string[0];
string message = GetCommitMsg(hParentWnd, parameters, originalMessage, commonRoot, pathList);
if (_issues != null)
{
foreach (IIssue issue in _issues.SelectedIssues)
{ bugIDOut = issue.DisplayId; break; }
}
return message;
}
catch (Exception e) { Log.Error(e); throw; }
}
string IBugTraqProvider2.CheckCommit(IntPtr hParentWnd, string parameters, string commonURL, string commonRoot, string[] pathList, string commitMessage)
{
try
{
return String.Empty;
}
catch (Exception e) { Log.Error(e); throw; }
}
string IBugTraqProvider2.OnCommitFinished(IntPtr hParentWnd, string commonRoot, string[] pathList, string originalMessage, int revision)
{
try
{
return CommitChanges(hParentWnd, originalMessage, revision, pathList);
}
catch (Exception e) { Log.Error(e); throw; }
}
bool IBugTraqProvider2.HasOptions() { return true; }
///TODO: - need to complete implementation for options dialog
string IBugTraqProvider2.ShowOptionsDialog(IntPtr hParentWnd, string parameters)
{
try
{
OptionUrlEntry dlg = new OptionUrlEntry(parameters, GetParamDesc());
if (dlg.ShowDialog(Win32Window.FromHandle(hParentWnd)) == DialogResult.OK)
return dlg.ServiceUri.Text;
return parameters;
}
catch (Exception e) { Log.Error(e); throw; }
}
#endregion
#region IBugTraqProvider Members
bool IBugTraqProvider.ValidateParameters(IntPtr hParentWnd, string parameters)
{
try
{
return String.IsNullOrEmpty(parameters) || Logon(hParentWnd, parameters, null);
}
catch (Exception e) { Log.Error(e); throw; }
}
string IBugTraqProvider.GetLinkText(IntPtr hParentWnd, string parameters)
{
try
{
return String.Format(BUTTON_TEXT, Connector.ServiceName);
}
catch (Exception e) { Log.Error(e); throw; }
}
string IBugTraqProvider.GetCommitMessage(IntPtr hParentWnd, string parameters, string commonRoot, string[] pathList, string originalMessage)
{
try
{
string message = GetCommitMsg(hParentWnd, parameters, originalMessage, commonRoot, pathList);
message = CommitChanges(hParentWnd, message, -1, new string[0]);
return message;
}
catch (Exception e) { Log.Error(e); throw; }
}
#endregion
#region COM Interop/Registration
static IEnumerable<string> GetRegistryKeysToAdd()
{
yield return String.Format(@"CLSID\{0}\Implemented Categories\{{3494FA92-B139-4730-9591-01135D5E7831}}", CLSID);
yield return String.Format(@"CLSID\{0}\Implemented Categories\{{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}}", CLSID);
}
/// <summary>
/// Registeres this assembly with COM using the custom keys required for TortoiseSVN interop
/// </summary>
[ComRegisterFunction]
public static void RegisterFunction(Type t)
{
try
{
if (typeof(MyPlugin) == t)
{
foreach (string keypath in GetRegistryKeysToAdd())
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(keypath))
{ key.Close(); }//{ Console.WriteLine(key.ToString()); }
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(String.Format(@"CLSID\{0}\InprocServer32", CLSID)))
if (key != null) key.SetValue("Assembly", t.Assembly.FullName);
if (t.Assembly.Location != null && System.IO.File.Exists(t.Assembly.Location))
{
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(String.Format(@"CLSID\{0}\InprocServer32", CLSID)))
if (key != null) key.SetValue("CodeBase", t.Assembly.Location);
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(String.Format(@"CLSID\{0}\InprocServer32\{1}", CLSID, t.Assembly.GetName().Version)))
{
if (key != null)
{
key.SetValue(null, "mscoree.dll");
key.SetValue("ThreadingModel", "Both");
key.SetValue("CodeBase", t.Assembly.Location);
}
}
}
}
}
catch (Exception e)
{
Console.Error.WriteLine(e.ToString());
}
}
/// <summary>
/// Unregisteres this assembly removing the custom keys required for TortoiseSVN interop
/// </summary>
[ComUnregisterFunction]
public static void UnregisterFunction(Type t)
{
try
{
foreach (string key in GetRegistryKeysToAdd())
Registry.ClassesRoot.DeleteSubKey(key, false);
}
catch (Exception e)
{
Console.Error.WriteLine(e.ToString());
}
}
#endregion
}
} | csharptest/JiraSVN | src/SvnPlugin/MyPlugin.cs | C# | apache-2.0 | 16,267 | [
30522,
1001,
2555,
9385,
2230,
2011,
5074,
14161,
29098,
1010,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1013,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# Copyright 2021 Google LLC
#
# 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
#
# https://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.
def strip_region_tags(sample_text):
"""Remove blank lines and region tags from sample text"""
magic_lines = [
line for line in sample_text.split("\n") if len(line) > 0 and "# [" not in line
]
return "\n".join(magic_lines)
| googleapis/python-bigquery | samples/magics/_helpers.py | Python | apache-2.0 | 823 | [
30522,
1001,
9385,
25682,
8224,
11775,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1001,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6105,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
\hypertarget{dir_e1120d38b56829564970ce9576dddbdf}{\section{jamms Directory Reference}
\label{dir_e1120d38b56829564970ce9576dddbdf}\index{jamms Directory Reference@{jamms Directory Reference}}
}
Directory dependency graph for jamms\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=262pt]{dir_e1120d38b56829564970ce9576dddbdf_dep}
\end{center}
\end{figure}
\subsection*{Directories}
\begin{DoxyCompactItemize}
\item
directory \hyperlink{dir_77b208f94221f94139bdd2444dc4f570}{Tower\+Defense}
\end{DoxyCompactItemize}
| sli-fox/jamms | TowerDefense/Documentation/latex/dir_e1120d38b56829564970ce9576dddbdf.tex | TeX | apache-2.0 | 550 | [
30522,
1032,
23760,
7559,
18150,
1063,
16101,
1035,
1041,
14526,
11387,
2094,
22025,
2497,
26976,
2620,
24594,
26976,
26224,
19841,
3401,
2683,
28311,
30524,
3830,
1063,
16101,
1035,
1041,
14526,
11387,
2094,
22025,
2497,
26976,
2620,
24594,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 (
"flag"
"fmt"
"net/http"
. "gopkg.in/go-on/lib.v2/types"
. "gopkg.in/go-on/lib.v2/html"
"gopkg.in/go-on/lib.v2/internal/bootstrap/bs3"
"gopkg.in/go-on/cdncache.v1"
)
var (
port = flag.Int("port", 8083, "port of the http server")
mountPoint = flag.String("mountpoint", "", "mount point for the cached files (leave empty to prevent caching)")
)
func main() {
flag.Parse()
cdn := cdncache.CDN(*mountPoint)
http.Handle("/",
HTML5(
Lang_("en"),
HEAD(
CharsetUtf8(),
HttpEquiv("X-UA-Compatible", "IE=edge"),
Viewport("width=device-width, initial-scale=1"),
TITLE("Starter Template for Bootstrap"),
CssHref(cdn(bs3.CDN_3_1_1_min)),
CssHref(cdn(bs3.CDN_3_1_1_theme_min)),
CssHref(cdn("http://getbootstrap.com/examples/starter-template/starter-template.css")),
HTMLString(fmt.Sprintf(`
<!--[if lt IE 9]>
<script src="%s"></script>
<script src="%s"></script>
<![endif]-->
`,
cdn("https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"),
cdn("https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"),
),
),
),
BODY(
DIV(bs3.Navbar, bs3.Navbar_inverse, bs3.Navbar_fixed_top,
Attrs_("role", "navigation"),
DIV(bs3.Container,
DIV(bs3.Navbar_header,
BUTTON(bs3.Navbar_toggle,
Type_("button"),
Attrs_("data-toggle", "collapse", "data-target", ".navbar-collapse"),
SPAN(bs3.Sr_only, "Toogle navigation"),
SPAN(bs3.Icon_bar),
SPAN(bs3.Icon_bar),
SPAN(bs3.Icon_bar),
),
AHref("#", bs3.Navbar_brand, "Project name"),
),
DIV(bs3.Collapse, bs3.Navbar_collapse,
UL(bs3.Nav, bs3.Navbar_nav,
LI(bs3.Active, AHref("#", "Home")),
LI(AHref("#about", "About")),
LI(AHref("#contact", "Contact")),
),
),
),
),
DIV(bs3.Container,
DIV(Class("starter-template"),
H1("Bootstrap starter template"),
P(bs3.Lead,
"Use this document as a way to quickly start any new project.",
BR(),
"All you get is this text and a mostly barebones HTML document.",
),
),
),
JsSrc(cdn("//code.jquery.com/jquery-1.11.0.min.js")),
JsSrc(cdn(bs3.CDN_3_1_1_js_min)),
),
),
)
fmt.Printf("listening on localhost: %d\n", *port)
http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
}
| go-on/cdncache | example/main.go | GO | mit | 2,369 | [
30522,
7427,
2364,
12324,
1006,
1000,
5210,
1000,
1000,
4718,
2102,
1000,
1000,
5658,
1013,
8299,
1000,
1012,
1000,
2175,
2361,
2243,
2290,
1012,
1999,
1013,
2175,
1011,
2006,
1013,
5622,
2497,
1012,
1058,
2475,
1013,
4127,
1000,
1012,
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>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/core/analysis/analysis_sub_view.html">
<link rel="import" href="/core/analysis/util.html">
<link rel="import" href="/core/analysis/analysis_link.html">
<link rel="import" href="/base/utils.html">
<polymer-element name="tv-c-single-cpu-slice-sub-view"
extends="tracing-analysis-sub-view">
<template>
<style>
table {
border-collapse: collapse;
border-width: 0;
margin-bottom: 25px;
width: 100%;
}
table tr > td:first-child {
padding-left: 2px;
}
table tr > td {
padding: 2px 4px 2px 4px;
vertical-align: text-top;
width: 150px;
}
table td td {
padding: 0 0 0 0;
width: auto;
}
tr {
vertical-align: top;
}
tr:nth-child(2n+0) {
background-color: #e2e2e2;
}
</style>
<table>
<tr>
<td>Running process:</td><td id="process-name"></td>
</tr>
<tr>
<td>Running thread:</td><td id="thread-name"></td>
</tr>
<tr>
<td>Start:</td><td id="start"></td>
</tr>
<tr>
<td>Duration:</td><td id="duration"></td>
</tr>
<tr>
<td>Active slices:</td><td id="running-thread"></td>
</tr>
<tr>
<td>Args:</td>
<td>
<tv-c-analysis-generic-object-view id="args">
</tv-c-analysis-generic-object-view>
</td>
</tr>
</table>
</template>
<script>
'use strict';
Polymer({
created: function() {
this.currentSelection_ = undefined;
},
get selection() {
return this.currentSelection_;
},
set selection(selection) {
if (selection.length !== 1)
throw new Error('Only supports single slices');
if (!(selection[0] instanceof tv.c.trace_model.CpuSlice))
throw new Error('Only supports thread time slices');
this.currentSelection_ = selection;
var cpuSlice = selection[0];
var thread = cpuSlice.threadThatWasRunning;
var shadowRoot = this.shadowRoot;
if (thread) {
shadowRoot.querySelector('#process-name').textContent =
thread.parent.userFriendlyName;
shadowRoot.querySelector('#thread-name').textContent =
thread.userFriendlyName;
} else {
shadowRoot.querySelector('#process-name').parentElement.style.display =
'none';
shadowRoot.querySelector('#thread-name').textContent = cpuSlice.title;
}
shadowRoot.querySelector('#start').textContent =
tv.c.analysis.tsString(cpuSlice.start);
shadowRoot.querySelector('#duration').textContent =
tv.c.analysis.tsString(cpuSlice.duration);
var runningThreadEl = shadowRoot.querySelector('#running-thread');
var timeSlice = cpuSlice.getAssociatedTimeslice();
if (!timeSlice) {
runningThreadEl.parentElement.style.display = 'none';
} else {
var threadLink = document.createElement('tv-c-analysis-link');
threadLink.selection = new tv.c.Selection(timeSlice);
threadLink.textContent = 'Click to select';
runningThreadEl.parentElement.style.display = '';
runningThreadEl.textContent = '';
runningThreadEl.appendChild(threadLink);
}
shadowRoot.querySelector('#args').object = cpuSlice.args;
}
});
</script>
</polymer-element>
| vmpstr/trace-viewer | trace_viewer/core/analysis/single_cpu_slice_sub_view.html | HTML | bsd-3-clause | 3,547 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
999,
1011,
1011,
9385,
1006,
1039,
1007,
2286,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
18667,
2094,
1011,
2806,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
gnbbBoilerplate
===============
A Backbone, Coffeescript, SASS, Gulp boilerplate
** created for personal use, will be improved as I go along
** roughly designed based on: https://github.com/jh3y/gulp-boilerplate-v2
| gnesher/gnbbBoilerplate | README.md | Markdown | mit | 216 | [
30522,
1043,
27698,
10322,
10448,
3917,
15725,
1027,
1027,
30524,
1027,
1027,
1027,
1037,
21505,
1010,
4157,
22483,
1010,
21871,
2015,
1010,
26546,
15635,
15725,
1008,
1008,
2580,
2005,
3167,
2224,
1010,
2097,
2022,
5301,
2004,
1045,
2175,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.components;
import com.intellij.util.xmlb.annotations.Attribute;
public class ServiceDescriptor {
@Attribute("serviceInterface")
public String serviceInterface;
@Attribute("serviceImplementation")
public String serviceImplementation;
@Attribute("overrides")
public boolean overrides;
public String getInterface() {
return serviceInterface != null ? serviceInterface : getImplementation();
}
public String getImplementation() {
return serviceImplementation;
}
}
| akosyakov/intellij-community | platform/platform-impl/src/com/intellij/openapi/components/ServiceDescriptor.java | Java | apache-2.0 | 1,126 | [
30522,
1013,
1008,
1008,
9385,
2456,
1011,
2325,
6892,
10024,
7076,
1055,
1012,
1054,
1012,
1051,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Common.h"
#include "QuestDef.h"
#include "GameObject.h"
#include "ObjectMgr.h"
#include "PoolMgr.h"
#include "SpellMgr.h"
#include "Spell.h"
#include "UpdateMask.h"
#include "Opcodes.h"
#include "WorldPacket.h"
#include "World.h"
#include "DatabaseEnv.h"
#include "LootMgr.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "InstanceScript.h"
#include "Battleground.h"
#include "Util.h"
#include "OutdoorPvPMgr.h"
#include "BattlegroundAV.h"
#include "ScriptMgr.h"
GameObject::GameObject() : WorldObject(), m_goValue(new GameObjectValue)
{
m_objectType |= TYPEMASK_GAMEOBJECT;
m_objectTypeId = TYPEID_GAMEOBJECT;
m_updateFlag = (UPDATEFLAG_HAS_POSITION | UPDATEFLAG_POSITION | UPDATEFLAG_ROTATION);
m_valuesCount = GAMEOBJECT_END;
m_respawnTime = 0;
m_respawnDelayTime = 300;
m_lootState = GO_NOT_READY;
m_spawnedByDefault = true;
m_usetimes = 0;
m_spellId = 0;
m_cooldownTime = 0;
m_goInfo = NULL;
m_ritualOwner = NULL;
m_goData = NULL;
m_DBTableGuid = 0;
m_rotation = 0;
m_groupLootTimer = 0;
lootingGroupLowGUID = 0;
ResetLootMode(); // restore default loot mode
}
GameObject::~GameObject()
{
delete m_goValue;
//if (m_uint32Values) // field array can be not exist if GameOBject not loaded
// CleanupsBeforeDelete();
}
void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
{
if (IsInWorld())
RemoveFromWorld();
if (m_uint32Values) // field array can be not exist if GameOBject not loaded
{
// Possible crash at access to deleted GO in Unit::m_gameobj
if (uint64 owner_guid = GetOwnerGUID())
{
Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
if (owner)
owner->RemoveGameObject(this,false);
else
{
const char * ownerType = "creature";
if (IS_PLAYER_GUID(owner_guid))
ownerType = "player";
else if (IS_PET_GUID(owner_guid))
ownerType = "pet";
sLog.outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
GetGUIDLow(), GetGOInfo()->id, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType);
}
}
}
}
void GameObject::AddToWorld()
{
///- Register the gameobject for guid lookup
if (!IsInWorld())
{
if (m_zoneScript)
m_zoneScript->OnGameObjectCreate(this, true);
sObjectAccessor.AddObject(this);
WorldObject::AddToWorld();
}
}
void GameObject::RemoveFromWorld()
{
///- Remove the gameobject from the accessor
if (IsInWorld())
{
if (m_zoneScript)
m_zoneScript->OnGameObjectCreate(this, false);
// Possible crash at access to deleted GO in Unit::m_gameobj
if (uint64 owner_guid = GetOwnerGUID())
{
if (Unit * owner = GetOwner())
owner->RemoveGameObject(this,false);
else
sLog.outError("Delete GameObject (GUID: %u Entry: %u) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid));
}
WorldObject::RemoveFromWorld();
sObjectAccessor.RemoveObject(this);
}
}
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit)
{
ASSERT(map);
SetMap(map);
Relocate(x,y,z,ang);
if (!IsPositionValid())
{
sLog.outError("Gameobject (GUID: %u Entry: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",guidlow,name_id,x,y);
return false;
}
SetPhaseMask(phaseMask,false);
SetZoneScript();
if (m_zoneScript)
{
name_id = m_zoneScript->GetGameObjectEntry(guidlow, name_id);
if (!name_id)
return false;
}
GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(name_id);
if (!goinfo)
{
sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f) ang: %f rotation0: %f rotation1: %f rotation2: %f rotation3: %f",guidlow, name_id, map->GetId(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3);
return false;
}
Object::_Create(guidlow, goinfo->id, HIGHGUID_GAMEOBJECT);
m_goInfo = goinfo;
if (goinfo->type >= MAX_GAMEOBJECT_TYPE)
{
sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: it have not exist GO type '%u' in `gameobject_template`. It's will crash client if created.",guidlow,name_id,goinfo->type);
return false;
}
SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation0);
SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation1);
UpdateRotationFields(rotation2,rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3
SetFloatValue(OBJECT_FIELD_SCALE_X, goinfo->size);
SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction);
SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags);
SetEntry(goinfo->id);
SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId);
// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
SetGoState(go_state);
SetGoType(GameobjectTypes(goinfo->type));
SetGoArtKit(0); // unknown what this is
SetByteValue(GAMEOBJECT_BYTES_1, 2, artKit);
switch(goinfo->type)
{
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
m_goValue->building.health = goinfo->building.intactNumHits + goinfo->building.damagedNumHits;
SetGoAnimProgress(255);
break;
case GAMEOBJECT_TYPE_TRANSPORT:
SetUInt32Value(GAMEOBJECT_LEVEL, goinfo->transport.pause);
if (goinfo->transport.startOpen)
SetGoState(GO_STATE_ACTIVE);
SetGoAnimProgress(animprogress);
break;
case GAMEOBJECT_TYPE_FISHINGNODE:
SetGoAnimProgress(0);
break;
default:
SetGoAnimProgress(animprogress);
break;
}
LastUsedScriptID = GetGOInfo()->ScriptId;
return true;
}
void GameObject::Update(uint32 diff)
{
if (IS_MO_TRANSPORT(GetGUID()))
{
//((Transport*)this)->Update(p_time);
return;
}
switch (m_lootState)
{
case GO_NOT_READY:
{
switch(GetGoType())
{
case GAMEOBJECT_TYPE_TRAP:
{
// Arming Time for GAMEOBJECT_TYPE_TRAP (6)
GameObjectInfo const* goInfo = GetGOInfo();
// Bombs
if (goInfo->trap.charges == 2)
m_cooldownTime = time(NULL) + 10; // Hardcoded tooltip value
else if (Unit* owner = GetOwner())
{
if (owner->isInCombat())
m_cooldownTime = time(NULL) + goInfo->trap.startDelay;
}
m_lootState = GO_READY;
break;
}
case GAMEOBJECT_TYPE_FISHINGNODE:
{
// fishing code (bobber ready)
if (time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME)
{
// splash bobber (bobber ready now)
Unit* caster = GetOwner();
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
{
SetGoState(GO_STATE_ACTIVE);
SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN);
UpdateData udata;
udata.m_map = uint16(GetMapId());
WorldPacket packet;
BuildValuesUpdateBlockForPlayer(&udata,caster->ToPlayer());
udata.BuildPacket(&packet);
caster->ToPlayer()->GetSession()->SendPacket(&packet);
SendCustomAnim();
}
m_lootState = GO_READY; // can be successfully open with some chance
}
return;
}
default:
m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
break;
}
// NO BREAK for switch (m_lootState)
}
case GO_READY:
{
if (m_respawnTime > 0) // timer on
{
if (m_respawnTime <= time(NULL)) // timer expired
{
m_respawnTime = 0;
m_SkillupList.clear();
m_usetimes = 0;
switch (GetGoType())
{
case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
{
Unit* caster = GetOwner();
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
{
caster->FinishSpell(CURRENT_CHANNELED_SPELL);
WorldPacket data(SMSG_FISH_ESCAPED,0);
caster->ToPlayer()->GetSession()->SendPacket(&data);
}
// can be delete
m_lootState = GO_JUST_DEACTIVATED;
return;
}
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
//we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)
if (GetGoState() != GO_STATE_READY)
ResetDoorOrButton();
//flags in AB are type_button and we need to add them here so no break!
default:
if (!m_spawnedByDefault) // despawn timer
{
// can be despawned or destroyed
SetLootState(GO_JUST_DEACTIVATED);
return;
}
// respawn timer
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
if (poolid)
sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
else
GetMap()->Add(this);
break;
}
}
}
if (isSpawned())
{
// traps can have time and can not have
GameObjectInfo const* goInfo = GetGOInfo();
if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
{
if (m_cooldownTime >= time(NULL))
return;
// Type 2 - Bomb (will go away after casting it's spell)
if (goInfo->trap.charges == 2)
{
if (goInfo->trap.spellId)
CastSpell(NULL, goInfo->trap.spellId); // FIXME: null target won't work for target type 1
SetLootState(GO_JUST_DEACTIVATED);
break;
}
// Type 0 and 1 - trap (type 0 will not get removed after casting a spell)
Unit* owner = GetOwner();
Unit* ok = NULL; // pointer to appropriate target if found any
bool IsBattlegroundTrap = false;
//FIXME: this is activation radius (in different casting radius that must be selected from spell data)
//TODO: move activated state code (cast itself) to GO_ACTIVATED, in this place only check activating and set state
float radius = (float)(goInfo->trap.radius)/2; // TODO rename radius to diameter (goInfo->trap.radius) should be (goInfo->trap.diameter)
if (!radius)
{
if (goInfo->trap.cooldown != 3) // cast in other case (at some triggering/linked go/etc explicit call)
return;
else
{
if (m_respawnTime > 0)
break;
radius = (float)goInfo->trap.cooldown; // battlegrounds gameobjects has data2 == 0 && data5 == 3
IsBattlegroundTrap = true;
if (!radius)
return;
}
}
// Note: this hack with search required until GO casting not implemented
// search unfriendly creature
if (owner) // hunter trap
{
Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, ok, checker);
VisitNearbyGridObject(radius, searcher);
if (!ok) VisitNearbyWorldObject(radius, searcher);
}
else // environmental trap
{
// environmental damage spells already have around enemies targeting but this not help in case not existed GO casting support
// affect only players
Player* player = NULL;
Trinity::AnyPlayerInObjectRangeCheck checker(this, radius);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
VisitNearbyWorldObject(radius, searcher);
ok = player;
}
if (ok)
{
// some traps do not have spell but should be triggered
if (goInfo->trap.spellId)
CastSpell(ok, goInfo->trap.spellId);
m_cooldownTime = time(NULL) + 4; // 4 seconds
if (owner) // || goInfo->trap.charges == 1)
SetLootState(GO_JUST_DEACTIVATED);
if (IsBattlegroundTrap && ok->GetTypeId() == TYPEID_PLAYER)
{
//Battleground gameobjects case
if (ok->ToPlayer()->InBattleground())
if (Battleground *bg = ok->ToPlayer()->GetBattleground())
bg->HandleTriggerBuff(GetGUID());
}
}
}
else if (uint32 max_charges = goInfo->GetCharges())
{
if (m_usetimes >= max_charges)
{
m_usetimes = 0;
SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
}
}
}
break;
}
case GO_ACTIVATED:
{
switch(GetGoType())
{
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
if (GetGOInfo()->GetAutoCloseTime() && (m_cooldownTime < time(NULL)))
ResetDoorOrButton();
break;
case GAMEOBJECT_TYPE_GOOBER:
if (m_cooldownTime < time(NULL))
{
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
SetLootState(GO_JUST_DEACTIVATED);
m_cooldownTime = 0;
}
break;
case GAMEOBJECT_TYPE_CHEST:
if (m_groupLootTimer)
{
if (m_groupLootTimer <= diff)
{
Group* group = sObjectMgr.GetGroupByGUID(lootingGroupLowGUID);
if (group)
group->EndRoll(&loot);
m_groupLootTimer = 0;
lootingGroupLowGUID = 0;
}
else m_groupLootTimer -= diff;
}
default:
break;
}
break;
}
case GO_JUST_DEACTIVATED:
{
//if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
if (GetGoType() == GAMEOBJECT_TYPE_GOOBER)
{
uint32 spellId = GetGOInfo()->goober.spellId;
if (spellId)
{
std::set<uint32>::const_iterator it = m_unique_users.begin();
std::set<uint32>::const_iterator end = m_unique_users.end();
for (; it != end; ++it)
{
if (Unit* owner = Unit::GetUnit(*this, uint64(*it)))
owner->CastSpell(owner, spellId, false);
}
m_unique_users.clear();
m_usetimes = 0;
}
SetGoState(GO_STATE_READY);
//any return here in case battleground traps
}
if (GetOwnerGUID())
{
if (Unit* owner = GetOwner())
{
owner->RemoveGameObject(this, false);
SetRespawnTime(0);
Delete();
}
return;
}
//burning flags in some battlegrounds, if you find better condition, just add it
if (GetGOInfo()->IsDespawnAtAction() || GetGoAnimProgress() > 0)
{
SendObjectDeSpawnAnim(GetGUID());
//reset flags
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
}
loot.clear();
SetLootState(GO_READY);
if (!m_respawnDelayTime)
return;
if (!m_spawnedByDefault)
{
m_respawnTime = 0;
UpdateObjectVisibility();
return;
}
m_respawnTime = time(NULL) + m_respawnDelayTime;
// if option not set then object will be saved at grid unload
if (sWorld.getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
SaveRespawnTime();
UpdateObjectVisibility();
break;
}
}
sScriptMgr.OnGameObjectUpdate(this, diff);
}
void GameObject::Refresh()
{
// not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
if (m_respawnTime > 0 && m_spawnedByDefault)
return;
if (isSpawned())
GetMap()->Add(this);
}
void GameObject::AddUniqueUse(Player* player)
{
AddUse();
m_unique_users.insert(player->GetGUIDLow());
}
void GameObject::Delete()
{
SetLootState(GO_NOT_READY);
if (GetOwnerGUID())
if (Unit * owner = GetOwner())
owner->RemoveGameObject(this, false);
ASSERT (!GetOwnerGUID());
SendObjectDeSpawnAnim(GetGUID());
SetGoState(GO_STATE_READY);
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
if (poolid)
sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
else
AddObjectToRemoveList();
}
void GameObject::getFishLoot(Loot *fishloot, Player* loot_owner)
{
fishloot->clear();
uint32 zone, subzone;
GetZoneAndAreaId(zone,subzone);
// if subzone loot exist use it
if (!fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, true))
// else use zone loot (must exist in like case)
fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner,true);
}
void GameObject::SaveToDB()
{
// this should only be used when the gameobject has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise
GameObjectData const *data = sObjectMgr.GetGOData(m_DBTableGuid);
if (!data)
{
sLog.outError("GameObject::SaveToDB failed, cannot get gameobject data!");
return;
}
SaveToDB(GetMapId(), data->spawnMask, data->phaseMask);
}
void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
{
const GameObjectInfo *goI = GetGOInfo();
if (!goI)
return;
if (!m_DBTableGuid)
m_DBTableGuid = GetGUIDLow();
// update in loaded data (changing data only in this place)
GameObjectData& data = sObjectMgr.NewGOData(m_DBTableGuid);
// data->guid = guid don't must be update at save
data.id = GetEntry();
data.mapid = mapid;
data.phaseMask = phaseMask;
data.posX = GetPositionX();
data.posY = GetPositionY();
data.posZ = GetPositionZ();
data.orientation = GetOrientation();
data.rotation0 = GetFloatValue(GAMEOBJECT_PARENTROTATION+0);
data.rotation1 = GetFloatValue(GAMEOBJECT_PARENTROTATION+1);
data.rotation2 = GetFloatValue(GAMEOBJECT_PARENTROTATION+2);
data.rotation3 = GetFloatValue(GAMEOBJECT_PARENTROTATION+3);
data.spawntimesecs = m_spawnedByDefault ? m_respawnDelayTime : -(int32)m_respawnDelayTime;
data.animprogress = GetGoAnimProgress();
data.go_state = GetGoState();
data.spawnMask = spawnMask;
data.artKit = GetGoArtKit();
// updated in DB
std::ostringstream ss;
ss << "INSERT INTO gameobject VALUES ("
<< m_DBTableGuid << ", "
<< GetEntry() << ", "
<< mapid << ", "
<< uint32(spawnMask) << "," // cast to prevent save as symbol
<< uint16(GetPhaseMask()) << "," // prevent out of range error
<< GetPositionX() << ", "
<< GetPositionY() << ", "
<< GetPositionZ() << ", "
<< GetOrientation() << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION) << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+1) << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ", "
<< m_respawnDelayTime << ", "
<< uint32(GetGoAnimProgress()) << ", "
<< uint32(GetGoState()) << ")";
SQLTransaction trans = WorldDatabase.BeginTransaction();
trans->PAppend("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
trans->Append(ss.str().c_str());
WorldDatabase.CommitTransaction(trans);
}
bool GameObject::LoadFromDB(uint32 guid, Map *map)
{
GameObjectData const* data = sObjectMgr.GetGOData(guid);
if (!data)
{
sLog.outErrorDb("Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid);
return false;
}
uint32 entry = data->id;
//uint32 map_id = data->mapid; // already used before call
uint32 phaseMask = data->phaseMask;
float x = data->posX;
float y = data->posY;
float z = data->posZ;
float ang = data->orientation;
float rotation0 = data->rotation0;
float rotation1 = data->rotation1;
float rotation2 = data->rotation2;
float rotation3 = data->rotation3;
uint32 animprogress = data->animprogress;
GOState go_state = data->go_state;
uint32 artKit = data->artKit;
m_DBTableGuid = guid;
if (map->GetInstanceId() != 0) guid = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if (!Create(guid,entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
return false;
if (data->spawntimesecs >= 0)
{
m_spawnedByDefault = true;
if (!GetGOInfo()->GetDespawnPossibility() && !GetGOInfo()->IsDespawnAtAction())
{
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN);
m_respawnDelayTime = 0;
m_respawnTime = 0;
}
else
{
m_respawnDelayTime = data->spawntimesecs;
m_respawnTime = sObjectMgr.GetGORespawnTime(m_DBTableGuid, map->GetInstanceId());
// ready to respawn
if (m_respawnTime && m_respawnTime <= time(NULL))
{
m_respawnTime = 0;
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
}
}
}
else
{
m_spawnedByDefault = false;
m_respawnDelayTime = -data->spawntimesecs;
m_respawnTime = 0;
}
m_goData = data;
return true;
}
void GameObject::DeleteFromDB()
{
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
sObjectMgr.DeleteGOData(m_DBTableGuid);
WorldDatabase.PExecute("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
WorldDatabase.PExecute("DELETE FROM game_event_gameobject WHERE guid = '%u'", m_DBTableGuid);
}
GameObject* GameObject::GetGameObject(WorldObject& object, uint64 guid)
{
return object.GetMap()->GetGameObject(guid);
}
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
bool GameObject::hasQuest(uint32 quest_id) const
{
QuestRelationBounds qr = sObjectMgr.GetGOQuestRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr)
{
if (itr->second == quest_id)
return true;
}
return false;
}
bool GameObject::hasInvolvedQuest(uint32 quest_id) const
{
QuestRelationBounds qir = sObjectMgr.GetGOQuestInvolvedRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr)
{
if (itr->second == quest_id)
return true;
}
return false;
}
bool GameObject::IsTransport() const
{
// If something is marked as a transport, don't transmit an out of range packet for it.
GameObjectInfo const * gInfo = GetGOInfo();
if (!gInfo) return false;
return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT;
}
// is Dynamic transport = non-stop Transport
bool GameObject::IsDynTransport() const
{
// If something is marked as a transport, don't transmit an out of range packet for it.
GameObjectInfo const * gInfo = GetGOInfo();
if (!gInfo) return false;
return gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT || (gInfo->type == GAMEOBJECT_TYPE_TRANSPORT && !gInfo->transport.pause);
}
Unit* GameObject::GetOwner() const
{
return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
}
void GameObject::SaveRespawnTime()
{
if (m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault)
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),m_respawnTime);
}
bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
{
// Not in world
if (!IsInWorld() || !u->IsInWorld())
return false;
// Transport always visible at this step implementation
if (IsTransport() && IsInMap(u))
return true;
// quick check visibility false cases for non-GM-mode
if (!u->isGameMaster())
{
// despawned and then not visible for non-GM in GM-mode
if (!isSpawned())
return false;
// special invisibility cases
if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed)
{
Unit *owner = GetOwner();
if (owner && u->IsHostileTo(owner) && !canDetectTrap(u, GetDistance(u)))
return false;
}
}
// check distance
return IsWithinDistInMap(u->m_seer,World::GetMaxVisibleDistanceForObject() +
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
bool GameObject::canDetectTrap(Player const* u, float distance) const
{
if (u->hasUnitState(UNIT_STAT_STUNNED))
return false;
if (distance < GetGOInfo()->size) //collision
return true;
if (!u->HasInArc(M_PI, this)) //behind
return false;
if (u->HasAuraType(SPELL_AURA_DETECT_STEALTH))
return true;
//Visible distance is modified by -Level Diff (every level diff = 0.25f in visible distance)
float visibleDistance = (int32(u->getLevel()) - int32(GetOwner()->getLevel()))* 0.25f;
//GetModifier for trap (miscvalue 1)
//35y for aura 2836
//WARNING: these values are guessed, may be not blizzlike
visibleDistance += u->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DETECT, 1)* 0.5f;
return distance < visibleDistance;
}
void GameObject::Respawn()
{
if (m_spawnedByDefault && m_respawnTime > 0)
{
m_respawnTime = time(NULL);
sObjectMgr.SaveGORespawnTime(m_DBTableGuid,GetInstanceId(),0);
}
}
bool GameObject::ActivateToQuest(Player *pTarget) const
{
if (!sObjectMgr.IsGameObjectForQuests(GetEntry()))
return false;
switch (GetGoType())
{
// scan GO chest with loot including quest items
case GAMEOBJECT_TYPE_CHEST:
{
if (LootTemplates_Gameobject.HaveQuestLootForPlayer(GetGOInfo()->GetLootId(), pTarget))
{
//TODO: fix this hack
//look for battlegroundAV for some objects which are only activated after mine gots captured by own team
if (GetEntry() == BG_AV_OBJECTID_MINE_N || GetEntry() == BG_AV_OBJECTID_MINE_S)
if (Battleground *bg = pTarget->GetBattleground())
if (bg->GetTypeID(true) == BATTLEGROUND_AV && !(((BattlegroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(),pTarget->GetTeam())))
return false;
return true;
}
break;
}
case GAMEOBJECT_TYPE_GOOBER:
{
if (pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE || GetGOInfo()->goober.questId == -1)
return true;
break;
}
default:
break;
}
return false;
}
void GameObject::TriggeringLinkedGameObject(uint32 trapEntry, Unit* target)
{
GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(trapEntry);
if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP)
return;
SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
if (!trapSpell) // checked at load already
return;
float range;
SpellRangeEntry const * srentry = sSpellRangeStore.LookupEntry(trapSpell->rangeIndex);
//get owner to check hostility of GameObject
if (GetSpellMaxRangeForHostile(srentry) == GetSpellMaxRangeForHostile(srentry))
range = GetSpellMaxRangeForHostile(srentry);
else
{
if (Unit *owner = GetOwner())
range = (float)owner->GetSpellMaxRangeForTarget(target, srentry);
else
//if no owner assume that object is hostile to target
range = GetSpellMaxRangeForHostile(srentry);
}
// search nearest linked GO
GameObject* trapGO = NULL;
{
// using original GO distance
CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target,trapEntry,range);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO,go_check);
TypeContainerVisitor<Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker);
cell.Visit(p, object_checker, *GetMap(), *target, range);
}
// found correct GO
if (trapGO)
trapGO->CastSpell(target, trapInfo->trap.spellId);
}
GameObject* GameObject::LookupFishingHoleAround(float range)
{
GameObject* ok = NULL;
CellPair p(Trinity::ComputeCellPair(GetPositionX(),GetPositionY()));
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
Trinity::NearestGameObjectFishingHole u_check(*this, range);
Trinity::GameObjectSearcher<Trinity::NearestGameObjectFishingHole> checker(this, ok, u_check);
TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::NearestGameObjectFishingHole>, GridTypeMapContainer > grid_object_checker(checker);
cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
return ok;
}
void GameObject::ResetDoorOrButton()
{
if (m_lootState == GO_READY || m_lootState == GO_JUST_DEACTIVATED)
return;
SwitchDoorOrButton(false);
SetLootState(GO_JUST_DEACTIVATED);
m_cooldownTime = 0;
}
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */)
{
if (m_lootState != GO_READY)
return;
if (!time_to_restore)
time_to_restore = GetGOInfo()->GetAutoCloseTime();
SwitchDoorOrButton(true,alternative);
SetLootState(GO_ACTIVATED);
m_cooldownTime = time(NULL) + time_to_restore;
}
void GameObject::SetGoArtKit(uint8 kit)
{
SetByteValue(GAMEOBJECT_BYTES_1, 2, kit);
GameObjectData *data = const_cast<GameObjectData*>(sObjectMgr.GetGOData(m_DBTableGuid));
if (data)
data->artKit = kit;
}
void GameObject::SetGoArtKit(uint8 artkit, GameObject *go, uint32 lowguid)
{
const GameObjectData *data = NULL;
if (go)
{
go->SetGoArtKit(artkit);
data = go->GetGOData();
}
else if (lowguid)
data = sObjectMgr.GetGOData(lowguid);
if (data)
const_cast<GameObjectData*>(data)->artKit = artkit;
}
void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */)
{
if (activate)
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
else
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
if (GetGoState() == GO_STATE_READY) //if closed -> open
SetGoState(alternative ? GO_STATE_ACTIVE_ALTERNATIVE : GO_STATE_ACTIVE);
else //if open -> close
SetGoState(GO_STATE_READY);
}
void GameObject::Use(Unit* user)
{
// by default spell caster is user
Unit* spellCaster = user;
uint32 spellId = 0;
bool triggered = false;
switch(GetGoType())
{
case GAMEOBJECT_TYPE_DOOR: //0
case GAMEOBJECT_TYPE_BUTTON: //1
//doors/buttons never really despawn, only reset to default state/flags
UseDoorOrButton();
// activate script
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
return;
case GAMEOBJECT_TYPE_QUESTGIVER: //2
{
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
player->PrepareGossipMenu(this, GetGOInfo()->questgiver.gossipID);
player->SendPreparedGossip(this);
return;
}
//Sitting: Wooden bench, chairs enzz
case GAMEOBJECT_TYPE_CHAIR: //7
{
GameObjectInfo const* info = GetGOInfo();
if (!info)
return;
if (user->GetTypeId() != TYPEID_PLAYER)
return;
if (!ChairListSlots.size()) // this is called once at first chair use to make list of available slots
{
if (info->chair.slots > 0) // sometimes chairs in DB have error in fields and we dont know number of slots
for (uint32 i = 0; i < info->chair.slots; ++i)
ChairListSlots[i] = 0; // Last user of current slot set to 0 (none sit here yet)
else
ChairListSlots[0] = 0; // error in DB, make one default slot
}
Player* player = (Player*)user;
// a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one
float lowestDist = DEFAULT_VISIBILITY_DISTANCE;
uint32 nearest_slot = 0;
float x_lowest = GetPositionX();
float y_lowest = GetPositionY();
// the object orientation + 1/2 pi
// every slot will be on that straight line
float orthogonalOrientation = GetOrientation()+M_PI*0.5f;
// find nearest slot
bool found_free_slot = false;
for (ChairSlotAndUser::iterator itr = ChairListSlots.begin(); itr != ChairListSlots.end(); ++itr)
{
// the distance between this slot and the center of the go - imagine a 1D space
float relativeDistance = (info->size*itr->first)-(info->size*(info->chair.slots-1)/2.0f);
float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation);
float y_i = GetPositionY() + relativeDistance * sin(orthogonalOrientation);
if (itr->second)
{
if (Player* ChairUser = sObjectMgr.GetPlayer(itr->second))
if (ChairUser->IsSitState() && ChairUser->getStandState() != UNIT_STAND_STATE_SIT && ChairUser->GetExactDist2d(x_i, y_i) < 0.1f)
continue; // This seat is already occupied by ChairUser. NOTE: Not sure if the ChairUser->getStandState() != UNIT_STAND_STATE_SIT check is required.
else
itr->second = 0; // This seat is unoccupied.
else
itr->second = 0; // The seat may of had an occupant, but they're offline.
}
found_free_slot = true;
// calculate the distance between the player and this slot
float thisDistance = player->GetDistance2d(x_i, y_i);
/* debug code. It will spawn a npc on each slot to visualize them.
Creature* helper = player->SummonCreature(14496, x_i, y_i, GetPositionZ(), GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10000);
std::ostringstream output;
output << i << ": thisDist: " << thisDistance;
helper->MonsterSay(output.str().c_str(), LANG_UNIVERSAL, 0);
*/
if (thisDistance <= lowestDist)
{
nearest_slot = itr->first;
lowestDist = thisDistance;
x_lowest = x_i;
y_lowest = y_i;
}
}
if (found_free_slot)
{
ChairSlotAndUser::iterator itr = ChairListSlots.find(nearest_slot);
if (itr != ChairListSlots.end())
{
itr->second = player->GetGUID(); //this slot in now used by player
player->TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->chair.height);
return;
}
}
//else
//player->GetSession()->SendNotification("There's nowhere left for you to sit.");
return;
}
//big gun, its a spell/aura
case GAMEOBJECT_TYPE_GOOBER: //10
{
GameObjectInfo const* info = GetGOInfo();
if (user->GetTypeId() == TYPEID_PLAYER)
{
Player* player = (Player*)user;
if (info->goober.pageId) // show page...
{
WorldPacket data(SMSG_GAMEOBJECT_PAGETEXT, 8);
data << GetGUID();
player->GetSession()->SendPacket(&data);
}
else if (info->goober.gossipID)
{
player->PrepareGossipMenu(this, info->goober.gossipID);
player->SendPreparedGossip(this);
}
if (info->goober.eventId)
{
sLog.outDebug("Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetDBTableGUIDLow());
GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
EventInform(info->goober.eventId);
}
// possible quest objective for active quests
if (info->goober.questId && sObjectMgr.GetQuestTemplate(info->goober.questId))
{
//Quest require to be active for GO using
if (player->GetQuestStatus(info->goober.questId) != QUEST_STATUS_INCOMPLETE)
break;
}
if (Battleground* bg = player->GetBattleground())
bg->EventPlayerUsedGO(player, this);
player->CastedCreatureOrGO(info->id, GetGUID(), 0);
}
if (uint32 trapEntry = info->goober.linkedTrapId)
TriggeringLinkedGameObject(trapEntry, user);
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
SetLootState(GO_ACTIVATED);
uint32 time_to_restore = info->GetAutoCloseTime();
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
if (time_to_restore && info->goober.customAnim)
SendCustomAnim();
else
SetGoState(GO_STATE_ACTIVE);
m_cooldownTime = time(NULL) + time_to_restore;
// cast this spell later if provided
spellId = info->goober.spellId;
spellCaster = NULL;
break;
}
case GAMEOBJECT_TYPE_CAMERA: //13
{
GameObjectInfo const* info = GetGOInfo();
if (!info)
return;
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if (info->camera.cinematicId)
player->SendCinematicStart(info->camera.cinematicId);
if (info->camera.eventID)
GetMap()->ScriptsStart(sEventScripts, info->camera.eventID, player, this);
return;
}
//fishing bobber
case GAMEOBJECT_TYPE_FISHINGNODE: //17
{
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if (player->GetGUID() != GetOwnerGUID())
return;
switch(getLootState())
{
case GO_READY: // ready for loot
{
uint32 zone, subzone;
GetZoneAndAreaId(zone,subzone);
int32 zone_skill = sObjectMgr.GetFishingBaseSkillLevel(subzone);
if (!zone_skill)
zone_skill = sObjectMgr.GetFishingBaseSkillLevel(zone);
//provide error, no fishable zone or area should be 0
if (!zone_skill)
sLog.outErrorDb("Fishable areaId %u are not properly defined in `skill_fishing_base_level`.",subzone);
int32 skill = player->GetSkillValue(SKILL_FISHING);
int32 chance;
if (skill < zone_skill)
{
chance = int32(pow((double)skill/zone_skill,2) * 100);
if (chance < 1)
chance = 1;
}
else
chance = 100;
int32 roll = irand(1,100);
sLog.outStaticDebug("Fishing check (skill: %i zone min skill: %i chance %i roll: %i",skill,zone_skill,chance,roll);
// but you will likely cause junk in areas that require a high fishing skill (not yet implemented)
if (chance >= roll)
{
player->UpdateFishingSkill();
// prevent removing GO at spell cancel
player->RemoveGameObject(this,false);
SetOwnerGUID(player->GetGUID());
//TODO: find reasonable value for fishing hole search
GameObject* ok = LookupFishingHoleAround(20.0f + CONTACT_DISTANCE);
if (ok)
{
ok->Use(player);
SetLootState(GO_JUST_DEACTIVATED);
}
else
player->SendLoot(GetGUID(),LOOT_FISHING);
}
// TODO: else: junk
break;
}
case GO_JUST_DEACTIVATED: // nothing to do, will be deleted at next update
break;
default:
{
SetLootState(GO_JUST_DEACTIVATED);
WorldPacket data(SMSG_FISH_NOT_HOOKED, 0);
player->GetSession()->SendPacket(&data);
break;
}
}
player->FinishSpell(CURRENT_CHANNELED_SPELL);
return;
}
case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18
{
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
Unit* owner = GetOwner();
GameObjectInfo const* info = GetGOInfo();
// ritual owner is set for GO's without owner (not summoned)
if (!m_ritualOwner && !owner)
m_ritualOwner = player;
if (owner)
{
if (owner->GetTypeId() != TYPEID_PLAYER)
return;
// accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect)
if (player == owner->ToPlayer() || (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(owner->ToPlayer())))
return;
// expect owner to already be channeling, so if not...
if (!owner->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
return;
// in case summoning ritual caster is GO creator
spellCaster = owner;
}
else
{
if (player != m_ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(m_ritualOwner)))
return;
spellCaster = player;
}
AddUniqueUse(player);
if (info->summoningRitual.animSpell)
{
player->CastSpell(player, info->summoningRitual.animSpell, true);
// for this case, summoningRitual.spellId is always triggered
triggered = true;
}
// full amount unique participants including original summoner
if (GetUniqueUseCount() == info->summoningRitual.reqParticipants)
{
spellCaster = m_ritualOwner ? m_ritualOwner : spellCaster;
spellId = info->summoningRitual.spellId;
if (spellId == 62330) // GO store nonexistent spell, replace by expected
{
// spell have reagent and mana cost but it not expected use its
// it triggered spell in fact casted at currently channeled GO
spellId = 61993;
triggered = true;
}
// finish owners spell
if (owner)
owner->FinishSpell(CURRENT_CHANNELED_SPELL);
// can be deleted now, if
if (!info->summoningRitual.ritualPersistent)
SetLootState(GO_JUST_DEACTIVATED);
else
{
// reset ritual for this GO
m_ritualOwner = NULL;
m_unique_users.clear();
m_usetimes = 0;
}
}
else
return;
// go to end function to spell casting
break;
}
case GAMEOBJECT_TYPE_SPELLCASTER: //22
{
GameObjectInfo const* info = GetGOInfo();
if (!info)
return;
if (info->spellcaster.partyOnly)
{
Unit* caster = GetOwner();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
return;
if (user->GetTypeId() != TYPEID_PLAYER || !user->ToPlayer()->IsInSameRaidWith(caster->ToPlayer()))
return;
}
spellId = info->spellcaster.spellId;
AddUse();
break;
}
case GAMEOBJECT_TYPE_MEETINGSTONE: //23
{
GameObjectInfo const* info = GetGOInfo();
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
Player* targetPlayer = ObjectAccessor::FindPlayer(player->GetSelection());
// accept only use by player from same raid as caster, except caster itself
if (!targetPlayer || targetPlayer == player || !targetPlayer->IsInSameRaidWith(player))
return;
//required lvl checks!
uint8 level = player->getLevel();
if (level < info->meetingstone.minLevel)
return;
level = targetPlayer->getLevel();
if (level < info->meetingstone.minLevel)
return;
if (info->id == 194097)
spellId = 61994; // Ritual of Summoning
else
spellId = 59782; // Summoning Stone Effect
break;
}
case GAMEOBJECT_TYPE_FLAGSTAND: // 24
{
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if (player->CanUseBattlegroundObject())
{
// in battleground check
Battleground *bg = player->GetBattleground();
if (!bg)
return;
if (player->GetVehicle())
return;
// BG flag click
// AB:
// 15001
// 15002
// 15003
// 15004
// 15005
bg->EventPlayerClickedOnFlag(player, this);
return; //we don;t need to delete flag ... it is despawned!
}
break;
}
case GAMEOBJECT_TYPE_FISHINGHOLE: // 25
{
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
player->SendLoot(GetGUID(), LOOT_FISHINGHOLE);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, GetGOInfo()->id);
return;
}
case GAMEOBJECT_TYPE_FLAGDROP: // 26
{
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if (player->CanUseBattlegroundObject())
{
// in battleground check
Battleground *bg = player->GetBattleground();
if (!bg)
return;
if( player->GetVehicle())
return;
// BG flag dropped
// WS:
// 179785 - Silverwing Flag
// 179786 - Warsong Flag
// EotS:
// 184142 - Netherstorm Flag
GameObjectInfo const* info = GetGOInfo();
if (info)
{
switch(info->id)
{
case 179785: // Silverwing Flag
// check if it's correct bg
if (bg->GetTypeID(true) == BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag(player, this);
break;
case 179786: // Warsong Flag
if (bg->GetTypeID(true) == BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag(player, this);
break;
case 184142: // Netherstorm Flag
if (bg->GetTypeID(true) == BATTLEGROUND_EY)
bg->EventPlayerClickedOnFlag(player, this);
break;
}
}
//this cause to call return, all flags must be deleted here!!
spellId = 0;
Delete();
}
break;
}
case GAMEOBJECT_TYPE_BARBER_CHAIR: //32
{
GameObjectInfo const* info = GetGOInfo();
if (!info)
return;
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
// fallback, will always work
player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
WorldPacket data(SMSG_ENABLE_BARBER_SHOP, 0);
player->GetSession()->SendPacket(&data);
player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->barberChair.chairheight);
return;
}
default:
sLog.outDebug("Unknown Object Type %u", GetGoType());
break;
}
if (!spellId)
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
if (user->GetTypeId() != TYPEID_PLAYER || !sOutdoorPvPMgr.HandleCustomSpell((Player*)user,spellId,this))
sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u)", spellId,GetEntry(),GetGoType());
else
sLog.outDebug("WORLD: %u non-dbc spell was handled by OutdoorPvP", spellId);
return;
}
if (spellCaster)
spellCaster->CastSpell(user, spellInfo, triggered);
else
CastSpell(user, spellId);
}
void GameObject::CastSpell(Unit* target, uint32 spellId)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
return;
bool self = false;
for (uint8 i = 0; i < 3; ++i)
{
if (spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
{
self = true;
break;
}
}
if (self)
{
if (target)
target->CastSpell(target, spellInfo, true);
return;
}
//summon world trigger
Creature *trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, 1);
if (!trigger) return;
trigger->SetVisibility(VISIBILITY_OFF); //should this be true?
if (Unit *owner = GetOwner())
{
trigger->setFaction(owner->getFaction());
trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, owner->GetGUID());
}
else
{
trigger->setFaction(14);
// Set owner guid for target if no owner avalible - needed by trigger auras
// - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, target ? target->GetGUID() : 0);
}
//trigger->setDeathState(JUST_DIED);
//trigger->RemoveCorpse();
}
void GameObject::SendCustomAnim()
{
WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,8+4);
data << GetGUID();
data << uint32(GetGoAnimProgress());
SendMessageToSet(&data, true);
}
bool GameObject::IsInRange(float x, float y, float z, float radius) const
{
GameObjectDisplayInfoEntry const * info = sGameObjectDisplayInfoStore.LookupEntry(GetUInt32Value(GAMEOBJECT_DISPLAYID));
if (!info)
return IsWithinDist3d(x, y, z, radius);
float sinA = sin(GetOrientation());
float cosA = cos(GetOrientation());
float dx = x - GetPositionX();
float dy = y - GetPositionY();
float dz = z - GetPositionZ();
float dist = sqrt(dx*dx + dy*dy);
float sinB = dx / dist;
float cosB = dy / dist;
dx = dist * (cosA * cosB + sinA * sinB);
dy = dist * (cosA * sinB - sinA * cosB);
return dx < info->maxX + radius && dx > info->minX - radius
&& dy < info->maxY + radius && dy > info->minY - radius
&& dz < info->maxZ + radius && dz > info->minZ - radius;
}
void GameObject::TakenDamage(uint32 damage, Unit *who)
{
if (!m_goValue->building.health)
return;
Player* pwho = NULL;
if (who)
{
if (who->GetTypeId() == TYPEID_PLAYER)
pwho = who->ToPlayer();
else if (who->IsVehicle() && who->GetCharmerOrOwner())
pwho = who->GetCharmerOrOwner()->ToPlayer();
}
if (m_goValue->building.health > damage)
m_goValue->building.health -= damage;
else
m_goValue->building.health = 0;
if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed
{
uint8 hitType = BG_OBJECT_DMG_HIT_TYPE_HIGH_DAMAGED;
if (!m_goValue->building.health)
{
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DESTROYED);
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->building.destroyedDisplayId);
EventInform(m_goInfo->building.destroyedEvent);
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
bg->DestroyGate(pwho, this, m_goInfo->building.destroyedEvent);
hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_DESTROYED;
sScriptMgr.OnGameObjectDestroyed(pwho, this, m_goInfo->building.destroyedEvent);
}
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
bg->EventPlayerDamagedGO(pwho, this, hitType, m_goInfo->building.destroyedEvent);
}
else // from intact to damaged
{
uint8 hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_DAMAGED;
if (m_goValue->building.health + damage < m_goInfo->building.intactNumHits + m_goInfo->building.damagedNumHits)
hitType = BG_OBJECT_DMG_HIT_TYPE_DAMAGED;
if (m_goValue->building.health <= m_goInfo->building.damagedNumHits)
{
if (!m_goInfo->building.destroyedDisplayId)
m_goValue->building.health = m_goInfo->building.damagedNumHits;
else if (!m_goValue->building.health)
m_goValue->building.health = 1;
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->building.damagedDisplayId);
EventInform(m_goInfo->building.damagedEvent);
hitType = BG_OBJECT_DMG_HIT_TYPE_JUST_HIGH_DAMAGED;
}
if (pwho)
if (Battleground* bg = pwho->GetBattleground())
bg->EventPlayerDamagedGO(pwho, this, hitType, m_goInfo->building.destroyedEvent);
}
SetGoAnimProgress(m_goValue->building.health*255/(m_goInfo->building.intactNumHits + m_goInfo->building.damagedNumHits));
}
void GameObject::Rebuild()
{
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED + GO_FLAG_DESTROYED);
SetUInt32Value(GAMEOBJECT_DISPLAYID, m_goInfo->displayId);
m_goValue->building.health = m_goInfo->building.intactNumHits + m_goInfo->building.damagedNumHits;
EventInform(m_goInfo->building.rebuildingEvent);
}
void GameObject::EventInform(uint32 eventId)
{
if (eventId && m_zoneScript)
m_zoneScript->ProcessEvent(this, eventId);
}
// overwrite WorldObject function for proper name localization
const char* GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const
{
if (loc_idx != DEFAULT_LOCALE)
{
uint8 uloc_idx = uint8(loc_idx);
if (GameObjectLocale const *cl = sObjectMgr.GetGameObjectLocale(GetEntry()))
if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty())
return cl->Name[uloc_idx].c_str();
}
return GetName();
}
void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 /*=0.0f*/)
{
static double const atan_pow = atan(pow(2.0f, -20.0f));
double f_rot1 = sin(GetOrientation() / 2.0f);
double f_rot2 = cos(GetOrientation() / 2.0f);
int64 i_rot1 = int64(f_rot1 / atan_pow *(f_rot2 >= 0 ? 1.0f : -1.0f));
int64 rotation = (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
//float f_rot2 = sin(0.0f / 2.0f);
//int64 i_rot2 = f_rot2 / atan(pow(2.0f, -20.0f));
//rotation |= (((i_rot2 << 22) >> 32) >> 11) & 0x000003FFFFE00000;
//float f_rot3 = sin(0.0f / 2.0f);
//int64 i_rot3 = f_rot3 / atan(pow(2.0f, -21.0f));
//rotation |= (i_rot3 >> 42) & 0x7FFFFC0000000000;
m_rotation = rotation;
if (rotation2 == 0.0f && rotation3 == 0.0f)
{
rotation2 = (float)f_rot1;
rotation3 = (float)f_rot2;
}
SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2);
SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
}
| milleniumcore/CactusEMU | src/server/game/Entities/GameObject/GameObject.cpp | C++ | gpl-2.0 | 64,195 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2384,
1011,
2268,
24792,
2015,
1026,
8299,
1024,
1013,
1013,
2131,
2386,
12333,
1012,
4012,
1013,
1028,
1008,
1008,
9385,
1006,
1039,
1007,
2263,
1011,
2230,
7124,
1026,
8299,
1024,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
const mongoose = require('mongoose')
const Schema = mongoose.Schema
let AgencySchema = new Schema({
})
module.exports = mongoose.model('Agency', AgencySchema)
| ValentinAlexandrovGeorgiev/deal | server/models/agency.js | JavaScript | mit | 162 | [
30522,
9530,
3367,
12256,
3995,
9232,
1027,
5478,
1006,
1005,
12256,
3995,
9232,
1005,
1007,
9530,
3367,
8040,
28433,
1027,
12256,
3995,
9232,
1012,
8040,
28433,
2292,
4034,
22842,
2863,
1027,
2047,
8040,
28433,
1006,
1063,
1065,
1007,
1133... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
-webkit-transition: -webkit-transform 0.2s ease-out, opacity 0.2s ease-in;
-moz-transition: -moz-transform 0.2s ease-out, opacity 0.2s ease-in;
-o-transition: -o-transform 0.2s ease-out, opacity 0.2s ease-in;
transition: transform 0.2s ease-out, opacity 0.2s ease-in;
}
| aksswami/aks-bitmap | www/css/MarkerCluster.css | CSS | apache-2.0 | 366 | [
30522,
1012,
7053,
7485,
1011,
9324,
1011,
2019,
5714,
1012,
7053,
7485,
1011,
12115,
1011,
12696,
1010,
1012,
7053,
7485,
1011,
9324,
1011,
2019,
5714,
1012,
7053,
7485,
1011,
12115,
1011,
5192,
1063,
1011,
4773,
23615,
1011,
6653,
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... |
---
name: cljs.core/quote
see also:
---
## Summary
## Details
## Examples
| cljs/api | docfiles/cljs.core/quote.md | Markdown | mit | 77 | [
30522,
1011,
1011,
1011,
2171,
1024,
18856,
22578,
1012,
4563,
1013,
14686,
2156,
2036,
1024,
1011,
1011,
1011,
1001,
1001,
12654,
1001,
1001,
4751,
1001,
1001,
4973,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/******************************************************************************
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* 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,
* USA
*
* The full GNU General Public License is included in this distribution
* in the file called COPYING.
*
* Contact Information:
* Intel Linux Wireless <ilw@linux.intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*
* BSD LICENSE
*
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#include <linux/etherdevice.h>
#include <linux/ip.h>
#include <linux/fs.h>
#include <net/cfg80211.h>
#include <net/ipv6.h>
#include <net/tcp.h>
#include <net/addrconf.h>
#include "iwl-modparams.h"
#include "fw-api.h"
#include "mvm.h"
void iwl_mvm_set_rekey_data(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct cfg80211_gtk_rekey_data *data)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
if (iwlwifi_mod_params.sw_crypto)
return;
mutex_lock(&mvm->mutex);
memcpy(mvmvif->rekey_data.kek, data->kek, NL80211_KEK_LEN);
memcpy(mvmvif->rekey_data.kck, data->kck, NL80211_KCK_LEN);
mvmvif->rekey_data.replay_ctr =
cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr));
mvmvif->rekey_data.valid = true;
mutex_unlock(&mvm->mutex);
}
#if IS_ENABLED(CONFIG_IPV6)
void iwl_mvm_ipv6_addr_change(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct inet6_dev *idev)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct inet6_ifaddr *ifa;
int idx = 0;
read_lock_bh(&idev->lock);
list_for_each_entry(ifa, &idev->addr_list, if_list) {
mvmvif->target_ipv6_addrs[idx] = ifa->addr;
idx++;
if (idx >= IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_MAX)
break;
}
read_unlock_bh(&idev->lock);
mvmvif->num_target_ipv6_addrs = idx;
}
#endif
void iwl_mvm_set_default_unicast_key(struct ieee80211_hw *hw,
struct ieee80211_vif *vif, int idx)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
mvmvif->tx_key_idx = idx;
}
static void iwl_mvm_convert_p1k(u16 *p1k, __le16 *out)
{
int i;
for (i = 0; i < IWL_P1K_SIZE; i++)
out[i] = cpu_to_le16(p1k[i]);
}
struct wowlan_key_data {
struct iwl_wowlan_rsc_tsc_params_cmd *rsc_tsc;
struct iwl_wowlan_tkip_params_cmd *tkip;
bool error, use_rsc_tsc, use_tkip;
int wep_key_idx;
};
static void iwl_mvm_wowlan_program_keys(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
struct ieee80211_key_conf *key,
void *_data)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct wowlan_key_data *data = _data;
struct aes_sc *aes_sc, *aes_tx_sc = NULL;
struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL;
struct iwl_p1k_cache *rx_p1ks;
u8 *rx_mic_key;
struct ieee80211_key_seq seq;
u32 cur_rx_iv32 = 0;
u16 p1k[IWL_P1K_SIZE];
int ret, i;
mutex_lock(&mvm->mutex);
switch (key->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104: { /* hack it for now */
struct {
struct iwl_mvm_wep_key_cmd wep_key_cmd;
struct iwl_mvm_wep_key wep_key;
} __packed wkc = {
.wep_key_cmd.mac_id_n_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color)),
.wep_key_cmd.num_keys = 1,
/* firmware sets STA_KEY_FLG_WEP_13BYTES */
.wep_key_cmd.decryption_type = STA_KEY_FLG_WEP,
.wep_key.key_index = key->keyidx,
.wep_key.key_size = key->keylen,
};
/*
* This will fail -- the key functions don't set support
* pairwise WEP keys. However, that's better than silently
* failing WoWLAN. Or maybe not?
*/
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
break;
memcpy(&wkc.wep_key.key[3], key->key, key->keylen);
if (key->keyidx == mvmvif->tx_key_idx) {
/* TX key must be at offset 0 */
wkc.wep_key.key_offset = 0;
} else {
/* others start at 1 */
data->wep_key_idx++;
wkc.wep_key.key_offset = data->wep_key_idx;
}
ret = iwl_mvm_send_cmd_pdu(mvm, WEP_KEY, CMD_SYNC,
sizeof(wkc), &wkc);
data->error = ret != 0;
mvm->ptk_ivlen = key->iv_len;
mvm->ptk_icvlen = key->icv_len;
mvm->gtk_ivlen = key->iv_len;
mvm->gtk_icvlen = key->icv_len;
/* don't upload key again */
goto out_unlock;
}
default:
data->error = true;
goto out_unlock;
case WLAN_CIPHER_SUITE_AES_CMAC:
/*
* Ignore CMAC keys -- the WoWLAN firmware doesn't support them
* but we also shouldn't abort suspend due to that. It does have
* support for the IGTK key renewal, but doesn't really use the
* IGTK for anything. This means we could spuriously wake up or
* be deauthenticated, but that was considered acceptable.
*/
goto out_unlock;
case WLAN_CIPHER_SUITE_TKIP:
if (sta) {
tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc;
tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc;
rx_p1ks = data->tkip->rx_uni;
ieee80211_get_key_tx_seq(key, &seq);
tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16);
tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32);
ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k);
iwl_mvm_convert_p1k(p1k, data->tkip->tx.p1k);
memcpy(data->tkip->mic_keys.tx,
&key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY],
IWL_MIC_KEY_SIZE);
rx_mic_key = data->tkip->mic_keys.rx_unicast;
} else {
tkip_sc =
data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc;
rx_p1ks = data->tkip->rx_multi;
rx_mic_key = data->tkip->mic_keys.rx_mcast;
}
/*
* For non-QoS this relies on the fact that both the uCode and
* mac80211 use TID 0 (as they need to to avoid replay attacks)
* for checking the IV in the frames.
*/
for (i = 0; i < IWL_NUM_RSC; i++) {
ieee80211_get_key_rx_seq(key, i, &seq);
tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16);
tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32);
/* wrapping isn't allowed, AP must rekey */
if (seq.tkip.iv32 > cur_rx_iv32)
cur_rx_iv32 = seq.tkip.iv32;
}
ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
cur_rx_iv32, p1k);
iwl_mvm_convert_p1k(p1k, rx_p1ks[0].p1k);
ieee80211_get_tkip_rx_p1k(key, vif->bss_conf.bssid,
cur_rx_iv32 + 1, p1k);
iwl_mvm_convert_p1k(p1k, rx_p1ks[1].p1k);
memcpy(rx_mic_key,
&key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY],
IWL_MIC_KEY_SIZE);
data->use_tkip = true;
data->use_rsc_tsc = true;
break;
case WLAN_CIPHER_SUITE_CCMP:
if (sta) {
u8 *pn = seq.ccmp.pn;
aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc;
aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc;
ieee80211_get_key_tx_seq(key, &seq);
aes_tx_sc->pn = cpu_to_le64((u64)pn[5] |
((u64)pn[4] << 8) |
((u64)pn[3] << 16) |
((u64)pn[2] << 24) |
((u64)pn[1] << 32) |
((u64)pn[0] << 40));
} else {
aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc;
}
/*
* For non-QoS this relies on the fact that both the uCode and
* mac80211 use TID 0 for checking the IV in the frames.
*/
for (i = 0; i < IWL_NUM_RSC; i++) {
u8 *pn = seq.ccmp.pn;
ieee80211_get_key_rx_seq(key, i, &seq);
aes_sc->pn = cpu_to_le64((u64)pn[5] |
((u64)pn[4] << 8) |
((u64)pn[3] << 16) |
((u64)pn[2] << 24) |
((u64)pn[1] << 32) |
((u64)pn[0] << 40));
}
data->use_rsc_tsc = true;
break;
}
/*
* The D3 firmware hardcodes the key offset 0 as the key it uses
* to transmit packets to the AP, i.e. the PTK.
*/
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
key->hw_key_idx = 0;
mvm->ptk_ivlen = key->iv_len;
mvm->ptk_icvlen = key->icv_len;
} else {
/*
* firmware only supports TSC/RSC for a single key,
* so if there are multiple keep overwriting them
* with new ones -- this relies on mac80211 doing
* list_add_tail().
*/
key->hw_key_idx = 1;
mvm->gtk_ivlen = key->iv_len;
mvm->gtk_icvlen = key->icv_len;
}
ret = iwl_mvm_set_sta_key(mvm, vif, sta, key, true);
data->error = ret != 0;
out_unlock:
mutex_unlock(&mvm->mutex);
}
static int iwl_mvm_send_patterns(struct iwl_mvm *mvm,
struct cfg80211_wowlan *wowlan)
{
struct iwl_wowlan_patterns_cmd *pattern_cmd;
struct iwl_host_cmd cmd = {
.id = WOWLAN_PATTERNS,
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
.flags = CMD_SYNC,
};
int i, err;
if (!wowlan->n_patterns)
return 0;
cmd.len[0] = sizeof(*pattern_cmd) +
wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern);
pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
if (!pattern_cmd)
return -ENOMEM;
pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns);
for (i = 0; i < wowlan->n_patterns; i++) {
int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
memcpy(&pattern_cmd->patterns[i].mask,
wowlan->patterns[i].mask, mask_len);
memcpy(&pattern_cmd->patterns[i].pattern,
wowlan->patterns[i].pattern,
wowlan->patterns[i].pattern_len);
pattern_cmd->patterns[i].mask_size = mask_len;
pattern_cmd->patterns[i].pattern_size =
wowlan->patterns[i].pattern_len;
}
cmd.data[0] = pattern_cmd;
err = iwl_mvm_send_cmd(mvm, &cmd);
kfree(pattern_cmd);
return err;
}
static int iwl_mvm_send_proto_offload(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
union {
struct iwl_proto_offload_cmd_v1 v1;
struct iwl_proto_offload_cmd_v2 v2;
struct iwl_proto_offload_cmd_v3_small v3s;
struct iwl_proto_offload_cmd_v3_large v3l;
} cmd = {};
struct iwl_host_cmd hcmd = {
.id = PROT_OFFLOAD_CONFIG_CMD,
.flags = CMD_SYNC,
.data[0] = &cmd,
.dataflags[0] = IWL_HCMD_DFL_DUP,
};
struct iwl_proto_offload_cmd_common *common;
u32 enabled = 0, size;
u32 capa_flags = mvm->fw->ucode_capa.flags;
#if IS_ENABLED(CONFIG_IPV6)
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
int i;
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL ||
capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
struct iwl_ns_config *nsc;
struct iwl_targ_addr *addrs;
int n_nsc, n_addrs;
int c;
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
nsc = cmd.v3s.ns_config;
n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3S;
addrs = cmd.v3s.targ_addrs;
n_addrs = IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3S;
} else {
nsc = cmd.v3l.ns_config;
n_nsc = IWL_PROTO_OFFLOAD_NUM_NS_CONFIG_V3L;
addrs = cmd.v3l.targ_addrs;
n_addrs = IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V3L;
}
if (mvmvif->num_target_ipv6_addrs)
enabled |= IWL_D3_PROTO_OFFLOAD_NS;
/*
* For each address we have (and that will fit) fill a target
* address struct and combine for NS offload structs with the
* solicited node addresses.
*/
for (i = 0, c = 0;
i < mvmvif->num_target_ipv6_addrs &&
i < n_addrs && c < n_nsc; i++) {
struct in6_addr solicited_addr;
int j;
addrconf_addr_solict_mult(&mvmvif->target_ipv6_addrs[i],
&solicited_addr);
for (j = 0; j < c; j++)
if (ipv6_addr_cmp(&nsc[j].dest_ipv6_addr,
&solicited_addr) == 0)
break;
if (j == c)
c++;
addrs[i].addr = mvmvif->target_ipv6_addrs[i];
addrs[i].config_num = cpu_to_le32(j);
nsc[j].dest_ipv6_addr = solicited_addr;
memcpy(nsc[j].target_mac_addr, vif->addr, ETH_ALEN);
}
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL)
cmd.v3s.num_valid_ipv6_addrs = cpu_to_le32(i);
else
cmd.v3l.num_valid_ipv6_addrs = cpu_to_le32(i);
} else if (capa_flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
if (mvmvif->num_target_ipv6_addrs) {
enabled |= IWL_D3_PROTO_OFFLOAD_NS;
memcpy(cmd.v2.ndp_mac_addr, vif->addr, ETH_ALEN);
}
BUILD_BUG_ON(sizeof(cmd.v2.target_ipv6_addr[0]) !=
sizeof(mvmvif->target_ipv6_addrs[0]));
for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V2); i++)
memcpy(cmd.v2.target_ipv6_addr[i],
&mvmvif->target_ipv6_addrs[i],
sizeof(cmd.v2.target_ipv6_addr[i]));
} else {
if (mvmvif->num_target_ipv6_addrs) {
enabled |= IWL_D3_PROTO_OFFLOAD_NS;
memcpy(cmd.v1.ndp_mac_addr, vif->addr, ETH_ALEN);
}
BUILD_BUG_ON(sizeof(cmd.v1.target_ipv6_addr[0]) !=
sizeof(mvmvif->target_ipv6_addrs[0]));
for (i = 0; i < min(mvmvif->num_target_ipv6_addrs,
IWL_PROTO_OFFLOAD_NUM_IPV6_ADDRS_V1); i++)
memcpy(cmd.v1.target_ipv6_addr[i],
&mvmvif->target_ipv6_addrs[i],
sizeof(cmd.v1.target_ipv6_addr[i]));
}
#endif
if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_SMALL) {
common = &cmd.v3s.common;
size = sizeof(cmd.v3s);
} else if (capa_flags & IWL_UCODE_TLV_FLAGS_NEW_NSOFFL_LARGE) {
common = &cmd.v3l.common;
size = sizeof(cmd.v3l);
} else if (capa_flags & IWL_UCODE_TLV_FLAGS_D3_6_IPV6_ADDRS) {
common = &cmd.v2.common;
size = sizeof(cmd.v2);
} else {
common = &cmd.v1.common;
size = sizeof(cmd.v1);
}
if (vif->bss_conf.arp_addr_cnt) {
enabled |= IWL_D3_PROTO_OFFLOAD_ARP;
common->host_ipv4_addr = vif->bss_conf.arp_addr_list[0];
memcpy(common->arp_mac_addr, vif->addr, ETH_ALEN);
}
if (!enabled)
return 0;
common->enabled = cpu_to_le32(enabled);
hcmd.len[0] = size;
return iwl_mvm_send_cmd(mvm, &hcmd);
}
enum iwl_mvm_tcp_packet_type {
MVM_TCP_TX_SYN,
MVM_TCP_RX_SYNACK,
MVM_TCP_TX_DATA,
MVM_TCP_RX_ACK,
MVM_TCP_RX_WAKE,
MVM_TCP_TX_FIN,
};
static __le16 pseudo_hdr_check(int len, __be32 saddr, __be32 daddr)
{
__sum16 check = tcp_v4_check(len, saddr, daddr, 0);
return cpu_to_le16(be16_to_cpu((__force __be16)check));
}
static void iwl_mvm_build_tcp_packet(struct ieee80211_vif *vif,
struct cfg80211_wowlan_tcp *tcp,
void *_pkt, u8 *mask,
__le16 *pseudo_hdr_csum,
enum iwl_mvm_tcp_packet_type ptype)
{
struct {
struct ethhdr eth;
struct iphdr ip;
struct tcphdr tcp;
u8 data[];
} __packed *pkt = _pkt;
u16 ip_tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
int i;
pkt->eth.h_proto = cpu_to_be16(ETH_P_IP),
pkt->ip.version = 4;
pkt->ip.ihl = 5;
pkt->ip.protocol = IPPROTO_TCP;
switch (ptype) {
case MVM_TCP_TX_SYN:
case MVM_TCP_TX_DATA:
case MVM_TCP_TX_FIN:
memcpy(pkt->eth.h_dest, tcp->dst_mac, ETH_ALEN);
memcpy(pkt->eth.h_source, vif->addr, ETH_ALEN);
pkt->ip.ttl = 128;
pkt->ip.saddr = tcp->src;
pkt->ip.daddr = tcp->dst;
pkt->tcp.source = cpu_to_be16(tcp->src_port);
pkt->tcp.dest = cpu_to_be16(tcp->dst_port);
/* overwritten for TX SYN later */
pkt->tcp.doff = sizeof(struct tcphdr) / 4;
pkt->tcp.window = cpu_to_be16(65000);
break;
case MVM_TCP_RX_SYNACK:
case MVM_TCP_RX_ACK:
case MVM_TCP_RX_WAKE:
memcpy(pkt->eth.h_dest, vif->addr, ETH_ALEN);
memcpy(pkt->eth.h_source, tcp->dst_mac, ETH_ALEN);
pkt->ip.saddr = tcp->dst;
pkt->ip.daddr = tcp->src;
pkt->tcp.source = cpu_to_be16(tcp->dst_port);
pkt->tcp.dest = cpu_to_be16(tcp->src_port);
break;
default:
WARN_ON(1);
return;
}
switch (ptype) {
case MVM_TCP_TX_SYN:
/* firmware assumes 8 option bytes - 8 NOPs for now */
memset(pkt->data, 0x01, 8);
ip_tot_len += 8;
pkt->tcp.doff = (sizeof(struct tcphdr) + 8) / 4;
pkt->tcp.syn = 1;
break;
case MVM_TCP_TX_DATA:
ip_tot_len += tcp->payload_len;
memcpy(pkt->data, tcp->payload, tcp->payload_len);
pkt->tcp.psh = 1;
pkt->tcp.ack = 1;
break;
case MVM_TCP_TX_FIN:
pkt->tcp.fin = 1;
pkt->tcp.ack = 1;
break;
case MVM_TCP_RX_SYNACK:
pkt->tcp.syn = 1;
pkt->tcp.ack = 1;
break;
case MVM_TCP_RX_ACK:
pkt->tcp.ack = 1;
break;
case MVM_TCP_RX_WAKE:
ip_tot_len += tcp->wake_len;
pkt->tcp.psh = 1;
pkt->tcp.ack = 1;
memcpy(pkt->data, tcp->wake_data, tcp->wake_len);
break;
}
switch (ptype) {
case MVM_TCP_TX_SYN:
case MVM_TCP_TX_DATA:
case MVM_TCP_TX_FIN:
pkt->ip.tot_len = cpu_to_be16(ip_tot_len);
pkt->ip.check = ip_fast_csum(&pkt->ip, pkt->ip.ihl);
break;
case MVM_TCP_RX_WAKE:
for (i = 0; i < DIV_ROUND_UP(tcp->wake_len, 8); i++) {
u8 tmp = tcp->wake_mask[i];
mask[i + 6] |= tmp << 6;
if (i + 1 < DIV_ROUND_UP(tcp->wake_len, 8))
mask[i + 7] = tmp >> 2;
}
/* fall through for ethernet/IP/TCP headers mask */
case MVM_TCP_RX_SYNACK:
case MVM_TCP_RX_ACK:
mask[0] = 0xff; /* match ethernet */
/*
* match ethernet, ip.version, ip.ihl
* the ip.ihl half byte is really masked out by firmware
*/
mask[1] = 0x7f;
mask[2] = 0x80; /* match ip.protocol */
mask[3] = 0xfc; /* match ip.saddr, ip.daddr */
mask[4] = 0x3f; /* match ip.daddr, tcp.source, tcp.dest */
mask[5] = 0x80; /* match tcp flags */
/* leave rest (0 or set for MVM_TCP_RX_WAKE) */
break;
};
*pseudo_hdr_csum = pseudo_hdr_check(ip_tot_len - sizeof(struct iphdr),
pkt->ip.saddr, pkt->ip.daddr);
}
static int iwl_mvm_send_remote_wake_cfg(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct cfg80211_wowlan_tcp *tcp)
{
struct iwl_wowlan_remote_wake_config *cfg;
struct iwl_host_cmd cmd = {
.id = REMOTE_WAKE_CONFIG_CMD,
.len = { sizeof(*cfg), },
.dataflags = { IWL_HCMD_DFL_NOCOPY, },
.flags = CMD_SYNC,
};
int ret;
if (!tcp)
return 0;
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
if (!cfg)
return -ENOMEM;
cmd.data[0] = cfg;
cfg->max_syn_retries = 10;
cfg->max_data_retries = 10;
cfg->tcp_syn_ack_timeout = 1; /* seconds */
cfg->tcp_ack_timeout = 1; /* seconds */
/* SYN (TX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->syn_tx.data, NULL,
&cfg->syn_tx.info.tcp_pseudo_header_checksum,
MVM_TCP_TX_SYN);
cfg->syn_tx.info.tcp_payload_length = 0;
/* SYN/ACK (RX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->synack_rx.data, cfg->synack_rx.rx_mask,
&cfg->synack_rx.info.tcp_pseudo_header_checksum,
MVM_TCP_RX_SYNACK);
cfg->synack_rx.info.tcp_payload_length = 0;
/* KEEPALIVE/ACK (TX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->keepalive_tx.data, NULL,
&cfg->keepalive_tx.info.tcp_pseudo_header_checksum,
MVM_TCP_TX_DATA);
cfg->keepalive_tx.info.tcp_payload_length =
cpu_to_le16(tcp->payload_len);
cfg->sequence_number_offset = tcp->payload_seq.offset;
/* length must be 0..4, the field is little endian */
cfg->sequence_number_length = tcp->payload_seq.len;
cfg->initial_sequence_number = cpu_to_le32(tcp->payload_seq.start);
cfg->keepalive_interval = cpu_to_le16(tcp->data_interval);
if (tcp->payload_tok.len) {
cfg->token_offset = tcp->payload_tok.offset;
cfg->token_length = tcp->payload_tok.len;
cfg->num_tokens =
cpu_to_le16(tcp->tokens_size % tcp->payload_tok.len);
memcpy(cfg->tokens, tcp->payload_tok.token_stream,
tcp->tokens_size);
} else {
/* set tokens to max value to almost never run out */
cfg->num_tokens = cpu_to_le16(65535);
}
/* ACK (RX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->keepalive_ack_rx.data,
cfg->keepalive_ack_rx.rx_mask,
&cfg->keepalive_ack_rx.info.tcp_pseudo_header_checksum,
MVM_TCP_RX_ACK);
cfg->keepalive_ack_rx.info.tcp_payload_length = 0;
/* WAKEUP (RX) */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->wake_rx.data, cfg->wake_rx.rx_mask,
&cfg->wake_rx.info.tcp_pseudo_header_checksum,
MVM_TCP_RX_WAKE);
cfg->wake_rx.info.tcp_payload_length =
cpu_to_le16(tcp->wake_len);
/* FIN */
iwl_mvm_build_tcp_packet(
vif, tcp, cfg->fin_tx.data, NULL,
&cfg->fin_tx.info.tcp_pseudo_header_checksum,
MVM_TCP_TX_FIN);
cfg->fin_tx.info.tcp_payload_length = 0;
ret = iwl_mvm_send_cmd(mvm, &cmd);
kfree(cfg);
return ret;
}
struct iwl_d3_iter_data {
struct iwl_mvm *mvm;
struct ieee80211_vif *vif;
bool error;
};
static void iwl_mvm_d3_iface_iterator(void *_data, u8 *mac,
struct ieee80211_vif *vif)
{
struct iwl_d3_iter_data *data = _data;
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
return;
if (mvmvif->ap_sta_id == IWL_MVM_STATION_COUNT)
return;
if (data->vif) {
IWL_ERR(data->mvm, "More than one managed interface active!\n");
data->error = true;
return;
}
data->vif = vif;
}
static int iwl_mvm_d3_reprogram(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_sta *ap_sta)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct ieee80211_chanctx_conf *ctx;
u8 chains_static, chains_dynamic;
struct cfg80211_chan_def chandef;
int ret, i;
struct iwl_binding_cmd binding_cmd = {};
struct iwl_time_quota_cmd quota_cmd = {};
u32 status;
/* add back the PHY */
if (WARN_ON(!mvmvif->phy_ctxt))
return -EINVAL;
rcu_read_lock();
ctx = rcu_dereference(vif->chanctx_conf);
if (WARN_ON(!ctx)) {
rcu_read_unlock();
return -EINVAL;
}
chandef = ctx->def;
chains_static = ctx->rx_chains_static;
chains_dynamic = ctx->rx_chains_dynamic;
rcu_read_unlock();
ret = iwl_mvm_phy_ctxt_add(mvm, mvmvif->phy_ctxt, &chandef,
chains_static, chains_dynamic);
if (ret)
return ret;
/* add back the MAC */
mvmvif->uploaded = false;
if (WARN_ON(!vif->bss_conf.assoc))
return -EINVAL;
/* hack */
vif->bss_conf.assoc = false;
ret = iwl_mvm_mac_ctxt_add(mvm, vif);
vif->bss_conf.assoc = true;
if (ret)
return ret;
/* add back binding - XXX refactor? */
binding_cmd.id_and_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
mvmvif->phy_ctxt->color));
binding_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
binding_cmd.phy =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
mvmvif->phy_ctxt->color));
binding_cmd.macs[0] = cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color));
for (i = 1; i < MAX_MACS_IN_BINDING; i++)
binding_cmd.macs[i] = cpu_to_le32(FW_CTXT_INVALID);
status = 0;
ret = iwl_mvm_send_cmd_pdu_status(mvm, BINDING_CONTEXT_CMD,
sizeof(binding_cmd), &binding_cmd,
&status);
if (ret) {
IWL_ERR(mvm, "Failed to add binding: %d\n", ret);
return ret;
}
if (status) {
IWL_ERR(mvm, "Binding command failed: %u\n", status);
return -EIO;
}
ret = iwl_mvm_sta_send_to_fw(mvm, ap_sta, false);
if (ret)
return ret;
rcu_assign_pointer(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id], ap_sta);
ret = iwl_mvm_mac_ctxt_changed(mvm, vif);
if (ret)
return ret;
/* and some quota */
quota_cmd.quotas[0].id_and_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->phy_ctxt->id,
mvmvif->phy_ctxt->color));
quota_cmd.quotas[0].quota = cpu_to_le32(100);
quota_cmd.quotas[0].max_duration = cpu_to_le32(1000);
for (i = 1; i < MAX_BINDINGS; i++)
quota_cmd.quotas[i].id_and_color = cpu_to_le32(FW_CTXT_INVALID);
ret = iwl_mvm_send_cmd_pdu(mvm, TIME_QUOTA_CMD, CMD_SYNC,
sizeof(quota_cmd), "a_cmd);
if (ret)
IWL_ERR(mvm, "Failed to send quota: %d\n", ret);
return 0;
}
static int iwl_mvm_get_last_nonqos_seq(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_nonqos_seq_query_cmd query_cmd = {
.get_set_flag = cpu_to_le32(IWL_NONQOS_SEQ_GET),
.mac_id_n_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color)),
};
struct iwl_host_cmd cmd = {
.id = NON_QOS_TX_COUNTER_CMD,
.flags = CMD_SYNC | CMD_WANT_SKB,
};
int err;
u32 size;
if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API) {
cmd.data[0] = &query_cmd;
cmd.len[0] = sizeof(query_cmd);
}
err = iwl_mvm_send_cmd(mvm, &cmd);
if (err)
return err;
size = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
size -= sizeof(cmd.resp_pkt->hdr);
if (size < sizeof(__le16)) {
err = -EINVAL;
} else {
err = le16_to_cpup((__le16 *)cmd.resp_pkt->data);
/* new API returns next, not last-used seqno */
if (mvm->fw->ucode_capa.flags &
IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API)
err = (u16) (err - 0x10);
}
iwl_free_resp(&cmd);
return err;
}
void iwl_mvm_set_last_nonqos_seq(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_nonqos_seq_query_cmd query_cmd = {
.get_set_flag = cpu_to_le32(IWL_NONQOS_SEQ_SET),
.mac_id_n_color =
cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id,
mvmvif->color)),
.value = cpu_to_le16(mvmvif->seqno),
};
/* return if called during restart, not resume from D3 */
if (!mvmvif->seqno_valid)
return;
mvmvif->seqno_valid = false;
if (!(mvm->fw->ucode_capa.flags &
IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API))
return;
if (iwl_mvm_send_cmd_pdu(mvm, NON_QOS_TX_COUNTER_CMD, CMD_SYNC,
sizeof(query_cmd), &query_cmd))
IWL_ERR(mvm, "failed to set non-QoS seqno\n");
}
static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
struct cfg80211_wowlan *wowlan,
bool test)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_d3_iter_data suspend_iter_data = {
.mvm = mvm,
};
struct ieee80211_vif *vif;
struct iwl_mvm_vif *mvmvif;
struct ieee80211_sta *ap_sta;
struct iwl_mvm_sta *mvm_ap_sta;
struct iwl_wowlan_config_cmd wowlan_config_cmd = {};
struct iwl_wowlan_kek_kck_material_cmd kek_kck_cmd = {};
struct iwl_wowlan_tkip_params_cmd tkip_cmd = {};
struct iwl_d3_manager_config d3_cfg_cmd_data = {
/*
* Program the minimum sleep time to 10 seconds, as many
* platforms have issues processing a wakeup signal while
* still being in the process of suspending.
*/
.min_sleep_time = cpu_to_le32(10 * 1000 * 1000),
};
struct iwl_host_cmd d3_cfg_cmd = {
.id = D3_CONFIG_CMD,
.flags = CMD_SYNC | CMD_WANT_SKB,
.data[0] = &d3_cfg_cmd_data,
.len[0] = sizeof(d3_cfg_cmd_data),
};
struct wowlan_key_data key_data = {
.use_rsc_tsc = false,
.tkip = &tkip_cmd,
.use_tkip = false,
};
int ret, i;
int len __maybe_unused;
u8 old_aux_sta_id, old_ap_sta_id = IWL_MVM_STATION_COUNT;
if (!wowlan) {
/*
* mac80211 shouldn't get here, but for D3 test
* it doesn't warrant a warning
*/
WARN_ON(!test);
return -EINVAL;
}
key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL);
if (!key_data.rsc_tsc)
return -ENOMEM;
mutex_lock(&mvm->mutex);
old_aux_sta_id = mvm->aux_sta.sta_id;
/* see if there's only a single BSS vif and it's associated */
ieee80211_iterate_active_interfaces_atomic(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_iface_iterator, &suspend_iter_data);
if (suspend_iter_data.error || !suspend_iter_data.vif) {
ret = 1;
goto out_noreset;
}
vif = suspend_iter_data.vif;
mvmvif = iwl_mvm_vif_from_mac80211(vif);
ap_sta = rcu_dereference_protected(
mvm->fw_id_to_mac_id[mvmvif->ap_sta_id],
lockdep_is_held(&mvm->mutex));
if (IS_ERR_OR_NULL(ap_sta)) {
ret = -EINVAL;
goto out_noreset;
}
mvm_ap_sta = (struct iwl_mvm_sta *)ap_sta->drv_priv;
/* TODO: wowlan_config_cmd.wowlan_ba_teardown_tids */
wowlan_config_cmd.is_11n_connection = ap_sta->ht_cap.ht_supported;
/* Query the last used seqno and set it */
ret = iwl_mvm_get_last_nonqos_seq(mvm, vif);
if (ret < 0)
goto out_noreset;
wowlan_config_cmd.non_qos_seq = cpu_to_le16(ret);
/*
* For QoS counters, we store the one to use next, so subtract 0x10
* since the uCode will add 0x10 *before* using the value while we
* increment after using the value (i.e. store the next value to use).
*/
for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
u16 seq = mvm_ap_sta->tid_data[i].seq_number;
seq -= 0x10;
wowlan_config_cmd.qos_seq[i] = cpu_to_le16(seq);
}
if (wowlan->disconnect)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_BEACON_MISS |
IWL_WOWLAN_WAKEUP_LINK_CHANGE);
if (wowlan->magic_pkt)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_MAGIC_PACKET);
if (wowlan->gtk_rekey_failure)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_GTK_REKEY_FAIL);
if (wowlan->eap_identity_req)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_EAP_IDENT_REQ);
if (wowlan->four_way_handshake)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_4WAY_HANDSHAKE);
if (wowlan->n_patterns)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_PATTERN_MATCH);
if (wowlan->rfkill_release)
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_RF_KILL_DEASSERT);
if (wowlan->tcp) {
/*
* Set the "link change" (really "link lost") flag as well
* since that implies losing the TCP connection.
*/
wowlan_config_cmd.wakeup_filter |=
cpu_to_le32(IWL_WOWLAN_WAKEUP_REMOTE_LINK_LOSS |
IWL_WOWLAN_WAKEUP_REMOTE_SIGNATURE_TABLE |
IWL_WOWLAN_WAKEUP_REMOTE_WAKEUP_PACKET |
IWL_WOWLAN_WAKEUP_LINK_CHANGE);
}
iwl_mvm_cancel_scan(mvm);
iwl_trans_stop_device(mvm->trans);
/*
* The D3 firmware still hardcodes the AP station ID for the
* BSS we're associated with as 0. Store the real STA ID here
* and assign 0. When we leave this function, we'll restore
* the original value for the resume code.
*/
old_ap_sta_id = mvm_ap_sta->sta_id;
mvm_ap_sta->sta_id = 0;
mvmvif->ap_sta_id = 0;
/*
* Set the HW restart bit -- this is mostly true as we're
* going to load new firmware and reprogram that, though
* the reprogramming is going to be manual to avoid adding
* all the MACs that aren't support.
* We don't have to clear up everything though because the
* reprogramming is manual. When we resume, we'll actually
* go through a proper restart sequence again to switch
* back to the runtime firmware image.
*/
set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
/* We reprogram keys and shouldn't allocate new key indices */
memset(mvm->fw_key_table, 0, sizeof(mvm->fw_key_table));
mvm->ptk_ivlen = 0;
mvm->ptk_icvlen = 0;
mvm->ptk_ivlen = 0;
mvm->ptk_icvlen = 0;
/*
* The D3 firmware still hardcodes the AP station ID for the
* BSS we're associated with as 0. As a result, we have to move
* the auxiliary station to ID 1 so the ID 0 remains free for
* the AP station for later.
* We set the sta_id to 1 here, and reset it to its previous
* value (that we stored above) later.
*/
mvm->aux_sta.sta_id = 1;
ret = iwl_mvm_load_d3_fw(mvm);
if (ret)
goto out;
ret = iwl_mvm_d3_reprogram(mvm, vif, ap_sta);
if (ret)
goto out;
if (!iwlwifi_mod_params.sw_crypto) {
/*
* This needs to be unlocked due to lock ordering
* constraints. Since we're in the suspend path
* that isn't really a problem though.
*/
mutex_unlock(&mvm->mutex);
ieee80211_iter_keys(mvm->hw, vif,
iwl_mvm_wowlan_program_keys,
&key_data);
mutex_lock(&mvm->mutex);
if (key_data.error) {
ret = -EIO;
goto out;
}
if (key_data.use_rsc_tsc) {
struct iwl_host_cmd rsc_tsc_cmd = {
.id = WOWLAN_TSC_RSC_PARAM,
.flags = CMD_SYNC,
.data[0] = key_data.rsc_tsc,
.dataflags[0] = IWL_HCMD_DFL_NOCOPY,
.len[0] = sizeof(*key_data.rsc_tsc),
};
ret = iwl_mvm_send_cmd(mvm, &rsc_tsc_cmd);
if (ret)
goto out;
}
if (key_data.use_tkip) {
ret = iwl_mvm_send_cmd_pdu(mvm,
WOWLAN_TKIP_PARAM,
CMD_SYNC, sizeof(tkip_cmd),
&tkip_cmd);
if (ret)
goto out;
}
if (mvmvif->rekey_data.valid) {
memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd));
memcpy(kek_kck_cmd.kck, mvmvif->rekey_data.kck,
NL80211_KCK_LEN);
kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN);
memcpy(kek_kck_cmd.kek, mvmvif->rekey_data.kek,
NL80211_KEK_LEN);
kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN);
kek_kck_cmd.replay_ctr = mvmvif->rekey_data.replay_ctr;
ret = iwl_mvm_send_cmd_pdu(mvm,
WOWLAN_KEK_KCK_MATERIAL,
CMD_SYNC,
sizeof(kek_kck_cmd),
&kek_kck_cmd);
if (ret)
goto out;
}
}
ret = iwl_mvm_send_cmd_pdu(mvm, WOWLAN_CONFIGURATION,
CMD_SYNC, sizeof(wowlan_config_cmd),
&wowlan_config_cmd);
if (ret)
goto out;
ret = iwl_mvm_send_patterns(mvm, wowlan);
if (ret)
goto out;
ret = iwl_mvm_send_proto_offload(mvm, vif);
if (ret)
goto out;
ret = iwl_mvm_send_remote_wake_cfg(mvm, vif, wowlan->tcp);
if (ret)
goto out;
ret = iwl_mvm_power_update_device_mode(mvm);
if (ret)
goto out;
ret = iwl_mvm_power_update_mode(mvm, vif);
if (ret)
goto out;
#ifdef CONFIG_IWLWIFI_DEBUGFS
if (mvm->d3_wake_sysassert)
d3_cfg_cmd_data.wakeup_flags |=
cpu_to_le32(IWL_WAKEUP_D3_CONFIG_FW_ERROR);
#endif
/* must be last -- this switches firmware state */
ret = iwl_mvm_send_cmd(mvm, &d3_cfg_cmd);
if (ret)
goto out;
#ifdef CONFIG_IWLWIFI_DEBUGFS
len = le32_to_cpu(d3_cfg_cmd.resp_pkt->len_n_flags) &
FH_RSCSR_FRAME_SIZE_MSK;
if (len >= sizeof(u32) * 2) {
mvm->d3_test_pme_ptr =
le32_to_cpup((__le32 *)d3_cfg_cmd.resp_pkt->data);
}
#endif
iwl_free_resp(&d3_cfg_cmd);
clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
iwl_trans_d3_suspend(mvm->trans, test);
out:
mvm->aux_sta.sta_id = old_aux_sta_id;
mvm_ap_sta->sta_id = old_ap_sta_id;
mvmvif->ap_sta_id = old_ap_sta_id;
if (ret < 0)
ieee80211_restart_hw(mvm->hw);
out_noreset:
kfree(key_data.rsc_tsc);
mutex_unlock(&mvm->mutex);
return ret;
}
int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
{
return __iwl_mvm_suspend(hw, wowlan, false);
}
/* converted data from the different status responses */
struct iwl_wowlan_status_data {
u16 pattern_number;
u16 qos_seq_ctr[8];
u32 wakeup_reasons;
u32 wake_packet_length;
u32 wake_packet_bufsize;
const u8 *wake_packet;
};
static void iwl_mvm_report_wakeup_reasons(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct iwl_wowlan_status_data *status)
{
struct sk_buff *pkt = NULL;
struct cfg80211_wowlan_wakeup wakeup = {
.pattern_idx = -1,
};
struct cfg80211_wowlan_wakeup *wakeup_report = &wakeup;
u32 reasons = status->wakeup_reasons;
if (reasons == IWL_WOWLAN_WAKEUP_BY_NON_WIRELESS) {
wakeup_report = NULL;
goto report;
}
if (reasons & IWL_WOWLAN_WAKEUP_BY_MAGIC_PACKET)
wakeup.magic_pkt = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_PATTERN)
wakeup.pattern_idx =
status->pattern_number;
if (reasons & (IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON |
IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH))
wakeup.disconnect = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_GTK_REKEY_FAILURE)
wakeup.gtk_rekey_failure = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED)
wakeup.rfkill_release = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_EAPOL_REQUEST)
wakeup.eap_identity_req = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_FOUR_WAY_HANDSHAKE)
wakeup.four_way_handshake = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_LINK_LOSS)
wakeup.tcp_connlost = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_SIGNATURE_TABLE)
wakeup.tcp_nomoretokens = true;
if (reasons & IWL_WOWLAN_WAKEUP_BY_REM_WAKE_WAKEUP_PACKET)
wakeup.tcp_match = true;
if (status->wake_packet_bufsize) {
int pktsize = status->wake_packet_bufsize;
int pktlen = status->wake_packet_length;
const u8 *pktdata = status->wake_packet;
struct ieee80211_hdr *hdr = (void *)pktdata;
int truncated = pktlen - pktsize;
/* this would be a firmware bug */
if (WARN_ON_ONCE(truncated < 0))
truncated = 0;
if (ieee80211_is_data(hdr->frame_control)) {
int hdrlen = ieee80211_hdrlen(hdr->frame_control);
int ivlen = 0, icvlen = 4; /* also FCS */
pkt = alloc_skb(pktsize, GFP_KERNEL);
if (!pkt)
goto report;
memcpy(skb_put(pkt, hdrlen), pktdata, hdrlen);
pktdata += hdrlen;
pktsize -= hdrlen;
if (ieee80211_has_protected(hdr->frame_control)) {
/*
* This is unlocked and using gtk_i(c)vlen,
* but since everything is under RTNL still
* that's not really a problem - changing
* it would be difficult.
*/
if (is_multicast_ether_addr(hdr->addr1)) {
ivlen = mvm->gtk_ivlen;
icvlen += mvm->gtk_icvlen;
} else {
ivlen = mvm->ptk_ivlen;
icvlen += mvm->ptk_icvlen;
}
}
/* if truncated, FCS/ICV is (partially) gone */
if (truncated >= icvlen) {
icvlen = 0;
truncated -= icvlen;
} else {
icvlen -= truncated;
truncated = 0;
}
pktsize -= ivlen + icvlen;
pktdata += ivlen;
memcpy(skb_put(pkt, pktsize), pktdata, pktsize);
if (ieee80211_data_to_8023(pkt, vif->addr, vif->type))
goto report;
wakeup.packet = pkt->data;
wakeup.packet_present_len = pkt->len;
wakeup.packet_len = pkt->len - truncated;
wakeup.packet_80211 = false;
} else {
int fcslen = 4;
if (truncated >= 4) {
truncated -= 4;
fcslen = 0;
} else {
fcslen -= truncated;
truncated = 0;
}
pktsize -= fcslen;
wakeup.packet = status->wake_packet;
wakeup.packet_present_len = pktsize;
wakeup.packet_len = pktlen - truncated;
wakeup.packet_80211 = true;
}
}
report:
ieee80211_report_wowlan_wakeup(vif, wakeup_report, GFP_KERNEL);
kfree_skb(pkt);
}
static void iwl_mvm_aes_sc_to_seq(struct aes_sc *sc,
struct ieee80211_key_seq *seq)
{
u64 pn;
pn = le64_to_cpu(sc->pn);
seq->ccmp.pn[0] = pn >> 40;
seq->ccmp.pn[1] = pn >> 32;
seq->ccmp.pn[2] = pn >> 24;
seq->ccmp.pn[3] = pn >> 16;
seq->ccmp.pn[4] = pn >> 8;
seq->ccmp.pn[5] = pn;
}
static void iwl_mvm_tkip_sc_to_seq(struct tkip_sc *sc,
struct ieee80211_key_seq *seq)
{
seq->tkip.iv32 = le32_to_cpu(sc->iv32);
seq->tkip.iv16 = le16_to_cpu(sc->iv16);
}
static void iwl_mvm_set_aes_rx_seq(struct aes_sc *scs,
struct ieee80211_key_conf *key)
{
int tid;
BUILD_BUG_ON(IWL_NUM_RSC != IEEE80211_NUM_TIDS);
for (tid = 0; tid < IWL_NUM_RSC; tid++) {
struct ieee80211_key_seq seq = {};
iwl_mvm_aes_sc_to_seq(&scs[tid], &seq);
ieee80211_set_key_rx_seq(key, tid, &seq);
}
}
static void iwl_mvm_set_tkip_rx_seq(struct tkip_sc *scs,
struct ieee80211_key_conf *key)
{
int tid;
BUILD_BUG_ON(IWL_NUM_RSC != IEEE80211_NUM_TIDS);
for (tid = 0; tid < IWL_NUM_RSC; tid++) {
struct ieee80211_key_seq seq = {};
iwl_mvm_tkip_sc_to_seq(&scs[tid], &seq);
ieee80211_set_key_rx_seq(key, tid, &seq);
}
}
static void iwl_mvm_set_key_rx_seq(struct ieee80211_key_conf *key,
struct iwl_wowlan_status_v6 *status)
{
union iwl_all_tsc_rsc *rsc = &status->gtk.rsc.all_tsc_rsc;
switch (key->cipher) {
case WLAN_CIPHER_SUITE_CCMP:
iwl_mvm_set_aes_rx_seq(rsc->aes.multicast_rsc, key);
break;
case WLAN_CIPHER_SUITE_TKIP:
iwl_mvm_set_tkip_rx_seq(rsc->tkip.multicast_rsc, key);
break;
default:
WARN_ON(1);
}
}
struct iwl_mvm_d3_gtk_iter_data {
struct iwl_wowlan_status_v6 *status;
void *last_gtk;
u32 cipher;
bool find_phase, unhandled_cipher;
int num_keys;
};
static void iwl_mvm_d3_update_gtks(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
struct ieee80211_key_conf *key,
void *_data)
{
struct iwl_mvm_d3_gtk_iter_data *data = _data;
if (data->unhandled_cipher)
return;
switch (key->cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
/* ignore WEP completely, nothing to do */
return;
case WLAN_CIPHER_SUITE_CCMP:
case WLAN_CIPHER_SUITE_TKIP:
/* we support these */
break;
default:
/* everything else (even CMAC for MFP) - disconnect from AP */
data->unhandled_cipher = true;
return;
}
data->num_keys++;
/*
* pairwise key - update sequence counters only;
* note that this assumes no TDLS sessions are active
*/
if (sta) {
struct ieee80211_key_seq seq = {};
union iwl_all_tsc_rsc *sc = &data->status->gtk.rsc.all_tsc_rsc;
if (data->find_phase)
return;
switch (key->cipher) {
case WLAN_CIPHER_SUITE_CCMP:
iwl_mvm_aes_sc_to_seq(&sc->aes.tsc, &seq);
iwl_mvm_set_aes_rx_seq(sc->aes.unicast_rsc, key);
break;
case WLAN_CIPHER_SUITE_TKIP:
iwl_mvm_tkip_sc_to_seq(&sc->tkip.tsc, &seq);
iwl_mvm_set_tkip_rx_seq(sc->tkip.unicast_rsc, key);
break;
}
ieee80211_set_key_tx_seq(key, &seq);
/* that's it for this key */
return;
}
if (data->find_phase) {
data->last_gtk = key;
data->cipher = key->cipher;
return;
}
if (data->status->num_of_gtk_rekeys)
ieee80211_remove_key(key);
else if (data->last_gtk == key)
iwl_mvm_set_key_rx_seq(key, data->status);
}
static bool iwl_mvm_setup_connection_keep(struct iwl_mvm *mvm,
struct ieee80211_vif *vif,
struct iwl_wowlan_status_v6 *status)
{
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
struct iwl_mvm_d3_gtk_iter_data gtkdata = {
.status = status,
};
u32 disconnection_reasons =
IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_MISSED_BEACON |
IWL_WOWLAN_WAKEUP_BY_DISCONNECTION_ON_DEAUTH;
if (!status || !vif->bss_conf.bssid)
return false;
if (le32_to_cpu(status->wakeup_reasons) & disconnection_reasons)
return false;
/* find last GTK that we used initially, if any */
gtkdata.find_phase = true;
ieee80211_iter_keys(mvm->hw, vif,
iwl_mvm_d3_update_gtks, >kdata);
/* not trying to keep connections with MFP/unhandled ciphers */
if (gtkdata.unhandled_cipher)
return false;
if (!gtkdata.num_keys)
goto out;
if (!gtkdata.last_gtk)
return false;
/*
* invalidate all other GTKs that might still exist and update
* the one that we used
*/
gtkdata.find_phase = false;
ieee80211_iter_keys(mvm->hw, vif,
iwl_mvm_d3_update_gtks, >kdata);
if (status->num_of_gtk_rekeys) {
struct ieee80211_key_conf *key;
struct {
struct ieee80211_key_conf conf;
u8 key[32];
} conf = {
.conf.cipher = gtkdata.cipher,
.conf.keyidx = status->gtk.key_index,
};
switch (gtkdata.cipher) {
case WLAN_CIPHER_SUITE_CCMP:
conf.conf.keylen = WLAN_KEY_LEN_CCMP;
memcpy(conf.conf.key, status->gtk.decrypt_key,
WLAN_KEY_LEN_CCMP);
break;
case WLAN_CIPHER_SUITE_TKIP:
conf.conf.keylen = WLAN_KEY_LEN_TKIP;
memcpy(conf.conf.key, status->gtk.decrypt_key, 16);
/* leave TX MIC key zeroed, we don't use it anyway */
memcpy(conf.conf.key +
NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY,
status->gtk.tkip_mic_key, 8);
break;
}
key = ieee80211_gtk_rekey_add(vif, &conf.conf);
if (IS_ERR(key))
return false;
iwl_mvm_set_key_rx_seq(key, status);
}
if (status->num_of_gtk_rekeys) {
__be64 replay_ctr =
cpu_to_be64(le64_to_cpu(status->replay_ctr));
ieee80211_gtk_rekey_notify(vif, vif->bss_conf.bssid,
(void *)&replay_ctr, GFP_KERNEL);
}
out:
mvmvif->seqno_valid = true;
/* +0x10 because the set API expects next-to-use, not last-used */
mvmvif->seqno = le16_to_cpu(status->non_qos_seq_ctr) + 0x10;
return true;
}
/* releases the MVM mutex */
static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
struct ieee80211_vif *vif)
{
u32 base = mvm->error_event_table;
struct error_table_start {
/* cf. struct iwl_error_event_table */
u32 valid;
u32 error_id;
} err_info;
struct iwl_host_cmd cmd = {
.id = WOWLAN_GET_STATUSES,
.flags = CMD_SYNC | CMD_WANT_SKB,
};
struct iwl_wowlan_status_data status;
struct iwl_wowlan_status_v6 *status_v6;
int ret, len, status_size, i;
bool keep;
struct ieee80211_sta *ap_sta;
struct iwl_mvm_sta *mvm_ap_sta;
iwl_trans_read_mem_bytes(mvm->trans, base,
&err_info, sizeof(err_info));
if (err_info.valid) {
IWL_INFO(mvm, "error table is valid (%d)\n",
err_info.valid);
if (err_info.error_id == RF_KILL_INDICATOR_FOR_WOWLAN) {
struct cfg80211_wowlan_wakeup wakeup = {
.rfkill_release = true,
};
ieee80211_report_wowlan_wakeup(vif, &wakeup,
GFP_KERNEL);
}
goto out_unlock;
}
/* only for tracing for now */
ret = iwl_mvm_send_cmd_pdu(mvm, OFFLOADS_QUERY_CMD, CMD_SYNC, 0, NULL);
if (ret)
IWL_ERR(mvm, "failed to query offload statistics (%d)\n", ret);
ret = iwl_mvm_send_cmd(mvm, &cmd);
if (ret) {
IWL_ERR(mvm, "failed to query status (%d)\n", ret);
goto out_unlock;
}
/* RF-kill already asserted again... */
if (!cmd.resp_pkt)
goto out_unlock;
if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API)
status_size = sizeof(struct iwl_wowlan_status_v6);
else
status_size = sizeof(struct iwl_wowlan_status_v4);
len = le32_to_cpu(cmd.resp_pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
if (len - sizeof(struct iwl_cmd_header) < status_size) {
IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
goto out_free_resp;
}
if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API) {
status_v6 = (void *)cmd.resp_pkt->data;
status.pattern_number = le16_to_cpu(status_v6->pattern_number);
for (i = 0; i < 8; i++)
status.qos_seq_ctr[i] =
le16_to_cpu(status_v6->qos_seq_ctr[i]);
status.wakeup_reasons = le32_to_cpu(status_v6->wakeup_reasons);
status.wake_packet_length =
le32_to_cpu(status_v6->wake_packet_length);
status.wake_packet_bufsize =
le32_to_cpu(status_v6->wake_packet_bufsize);
status.wake_packet = status_v6->wake_packet;
} else {
struct iwl_wowlan_status_v4 *status_v4;
status_v6 = NULL;
status_v4 = (void *)cmd.resp_pkt->data;
status.pattern_number = le16_to_cpu(status_v4->pattern_number);
for (i = 0; i < 8; i++)
status.qos_seq_ctr[i] =
le16_to_cpu(status_v4->qos_seq_ctr[i]);
status.wakeup_reasons = le32_to_cpu(status_v4->wakeup_reasons);
status.wake_packet_length =
le32_to_cpu(status_v4->wake_packet_length);
status.wake_packet_bufsize =
le32_to_cpu(status_v4->wake_packet_bufsize);
status.wake_packet = status_v4->wake_packet;
}
if (len - sizeof(struct iwl_cmd_header) !=
status_size + ALIGN(status.wake_packet_bufsize, 4)) {
IWL_ERR(mvm, "Invalid WoWLAN status response!\n");
goto out_free_resp;
}
/* still at hard-coded place 0 for D3 image */
ap_sta = rcu_dereference_protected(
mvm->fw_id_to_mac_id[0],
lockdep_is_held(&mvm->mutex));
if (IS_ERR_OR_NULL(ap_sta))
goto out_free_resp;
mvm_ap_sta = (struct iwl_mvm_sta *)ap_sta->drv_priv;
for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
u16 seq = status.qos_seq_ctr[i];
/* firmware stores last-used value, we store next value */
seq += 0x10;
mvm_ap_sta->tid_data[i].seq_number = seq;
}
/* now we have all the data we need, unlock to avoid mac80211 issues */
mutex_unlock(&mvm->mutex);
iwl_mvm_report_wakeup_reasons(mvm, vif, &status);
keep = iwl_mvm_setup_connection_keep(mvm, vif, status_v6);
iwl_free_resp(&cmd);
return keep;
out_free_resp:
iwl_free_resp(&cmd);
out_unlock:
mutex_unlock(&mvm->mutex);
return false;
}
static void iwl_mvm_read_d3_sram(struct iwl_mvm *mvm)
{
#ifdef CONFIG_IWLWIFI_DEBUGFS
const struct fw_img *img = &mvm->fw->img[IWL_UCODE_WOWLAN];
u32 len = img->sec[IWL_UCODE_SECTION_DATA].len;
u32 offs = img->sec[IWL_UCODE_SECTION_DATA].offset;
if (!mvm->store_d3_resume_sram)
return;
if (!mvm->d3_resume_sram) {
mvm->d3_resume_sram = kzalloc(len, GFP_KERNEL);
if (!mvm->d3_resume_sram)
return;
}
iwl_trans_read_mem_bytes(mvm->trans, offs, mvm->d3_resume_sram, len);
#endif
}
static void iwl_mvm_d3_disconnect_iter(void *data, u8 *mac,
struct ieee80211_vif *vif)
{
/* skip the one we keep connection on */
if (data == vif)
return;
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_resume_disconnect(vif);
}
static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
{
struct iwl_d3_iter_data resume_iter_data = {
.mvm = mvm,
};
struct ieee80211_vif *vif = NULL;
int ret;
enum iwl_d3_status d3_status;
bool keep = false;
mutex_lock(&mvm->mutex);
/* get the BSS vif pointer again */
ieee80211_iterate_active_interfaces_atomic(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_iface_iterator, &resume_iter_data);
if (WARN_ON(resume_iter_data.error || !resume_iter_data.vif))
goto out_unlock;
vif = resume_iter_data.vif;
ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test);
if (ret)
goto out_unlock;
if (d3_status != IWL_D3_STATUS_ALIVE) {
IWL_INFO(mvm, "Device was reset during suspend\n");
goto out_unlock;
}
/* query SRAM first in case we want event logging */
iwl_mvm_read_d3_sram(mvm);
keep = iwl_mvm_query_wakeup_reasons(mvm, vif);
#ifdef CONFIG_IWLWIFI_DEBUGFS
if (keep)
mvm->keep_vif = vif;
#endif
/* has unlocked the mutex, so skip that */
goto out;
out_unlock:
mutex_unlock(&mvm->mutex);
out:
if (!test)
ieee80211_iterate_active_interfaces_rtnl(mvm->hw,
IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_disconnect_iter, keep ? vif : NULL);
/* return 1 to reconfigure the device */
set_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
return 1;
}
int iwl_mvm_resume(struct ieee80211_hw *hw)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
return __iwl_mvm_resume(mvm, false);
}
void iwl_mvm_set_wakeup(struct ieee80211_hw *hw, bool enabled)
{
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
device_set_wakeup_enable(mvm->trans->dev, enabled);
}
#ifdef CONFIG_IWLWIFI_DEBUGFS
static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
{
struct iwl_mvm *mvm = inode->i_private;
int err;
if (mvm->d3_test_active)
return -EBUSY;
file->private_data = inode->i_private;
ieee80211_stop_queues(mvm->hw);
synchronize_net();
/* start pseudo D3 */
rtnl_lock();
err = __iwl_mvm_suspend(mvm->hw, mvm->hw->wiphy->wowlan_config, true);
rtnl_unlock();
if (err > 0)
err = -EINVAL;
if (err) {
ieee80211_wake_queues(mvm->hw);
return err;
}
mvm->d3_test_active = true;
mvm->keep_vif = NULL;
return 0;
}
static ssize_t iwl_mvm_d3_test_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct iwl_mvm *mvm = file->private_data;
u32 pme_asserted;
while (true) {
/* read pme_ptr if available */
if (mvm->d3_test_pme_ptr) {
pme_asserted = iwl_trans_read_mem32(mvm->trans,
mvm->d3_test_pme_ptr);
if (pme_asserted)
break;
}
if (msleep_interruptible(100))
break;
}
return 0;
}
static void iwl_mvm_d3_test_disconn_work_iter(void *_data, u8 *mac,
struct ieee80211_vif *vif)
{
/* skip the one we keep connection on */
if (_data == vif)
return;
if (vif->type == NL80211_IFTYPE_STATION)
ieee80211_connection_loss(vif);
}
static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
{
struct iwl_mvm *mvm = inode->i_private;
int remaining_time = 10;
mvm->d3_test_active = false;
__iwl_mvm_resume(mvm, true);
iwl_abort_notification_waits(&mvm->notif_wait);
ieee80211_restart_hw(mvm->hw);
/* wait for restart and disconnect all interfaces */
while (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
remaining_time > 0) {
remaining_time--;
msleep(1000);
}
if (remaining_time == 0)
IWL_ERR(mvm, "Timed out waiting for HW restart to finish!\n");
ieee80211_iterate_active_interfaces_atomic(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_test_disconn_work_iter, mvm->keep_vif);
ieee80211_wake_queues(mvm->hw);
return 0;
}
const struct file_operations iwl_dbgfs_d3_test_ops = {
.llseek = no_llseek,
.open = iwl_mvm_d3_test_open,
.read = iwl_mvm_d3_test_read,
.release = iwl_mvm_d3_test_release,
};
#endif
| freedesktop-unofficial-mirror/tegra__linux | drivers/net/wireless/iwlwifi/mvm/d3.c | C | gpl-2.0 | 53,080 | [
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... |
<?php
/**
* Core Zone Cities (core-zone-city)
* @var $this app\components\View
* @var $this ommu\core\controllers\zone\CityController
* @var $model ommu\core\models\CoreZoneCity
* @var $form app\components\widgets\ActiveForm
*
* @author Putra Sudaryanto <putra@ommu.id>
* @contact (+62)856-299-4114
* @copyright Copyright (c) 2017 OMMU (www.ommu.id)
* @created date 14 September 2017, 22:22 WIB
* @modified date 30 January 2019, 17:13 WIB
* @link https://github.com/ommu/mod-core
*
*/
use yii\helpers\Html;
use app\components\widgets\ActiveForm;
use ommu\core\models\CoreZoneProvince;
?>
<div class="core-zone-city-form">
<?php $form = ActiveForm::begin([
'options' => ['class' => 'form-horizontal form-label-left'],
'enableClientValidation' => true,
'enableAjaxValidation' => false,
//'enableClientScript' => true,
'fieldConfig' => [
'errorOptions' => [
'encode' => false,
],
],
]); ?>
<?php //echo $form->errorSummary($model);?>
<?php $province = CoreZoneProvince::getProvince();
echo $form->field($model, 'province_id')
->dropDownList($province, ['prompt' => ''])
->label($model->getAttributeLabel('province_id')); ?>
<?php echo $form->field($model, 'city_name')
->textInput(['maxlength' => true])
->label($model->getAttributeLabel('city_name')); ?>
<?php echo $form->field($model, 'mfdonline')
->textInput(['maxlength' => true])
->label($model->getAttributeLabel('mfdonline')); ?>
<?php echo $form->field($model, 'checked')
->checkbox()
->label($model->getAttributeLabel('checked')); ?>
<?php
if ($model->isNewRecord && !$model->getErrors()) {
$model->publish = 1;
}
echo $form->field($model, 'publish')
->checkbox()
->label($model->getAttributeLabel('publish')); ?>
<hr/>
<?php echo $form->field($model, 'submitButton')
->submitButton(); ?>
<?php ActiveForm::end(); ?>
</div> | ommu/Core | views/zone/city/_form.php | PHP | apache-2.0 | 1,836 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
4563,
4224,
3655,
1006,
4563,
1011,
4224,
1011,
2103,
1007,
1008,
1030,
13075,
1002,
2023,
10439,
1032,
6177,
1032,
3193,
1008,
1030,
13075,
1002,
2023,
18168,
12274,
1032,
4563,
1032,
21257... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GFX_MOJOM_RRECT_F_MOJOM_TRAITS_H_
#define UI_GFX_MOJOM_RRECT_F_MOJOM_TRAITS_H_
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
#include "ui/gfx/mojom/rrect_f.mojom-shared.h"
#include "ui/gfx/rrect_f.h"
#include "ui/gfx/rrect_f_builder.h"
namespace mojo {
namespace {
gfx::mojom::RRectFType GfxRRectFTypeToMojo(gfx::RRectF::Type type) {
switch (type) {
case gfx::RRectF::Type::kEmpty:
return gfx::mojom::RRectFType::kEmpty;
case gfx::RRectF::Type::kRect:
return gfx::mojom::RRectFType::kRect;
case gfx::RRectF::Type::kSingle:
return gfx::mojom::RRectFType::kSingle;
case gfx::RRectF::Type::kSimple:
return gfx::mojom::RRectFType::kSimple;
case gfx::RRectF::Type::kOval:
return gfx::mojom::RRectFType::kOval;
case gfx::RRectF::Type::kComplex:
return gfx::mojom::RRectFType::kComplex;
}
NOTREACHED();
return gfx::mojom::RRectFType::kEmpty;
}
gfx::RRectF::Type MojoRRectFTypeToGfx(gfx::mojom::RRectFType type) {
switch (type) {
case gfx::mojom::RRectFType::kEmpty:
return gfx::RRectF::Type::kEmpty;
case gfx::mojom::RRectFType::kRect:
return gfx::RRectF::Type::kRect;
case gfx::mojom::RRectFType::kSingle:
return gfx::RRectF::Type::kSingle;
case gfx::mojom::RRectFType::kSimple:
return gfx::RRectF::Type::kSimple;
case gfx::mojom::RRectFType::kOval:
return gfx::RRectF::Type::kOval;
case gfx::mojom::RRectFType::kComplex:
return gfx::RRectF::Type::kComplex;
}
NOTREACHED();
return gfx::RRectF::Type::kEmpty;
}
} // namespace
template <>
struct StructTraits<gfx::mojom::RRectFDataView, gfx::RRectF> {
static gfx::mojom::RRectFType type(const gfx::RRectF& input) {
return GfxRRectFTypeToMojo(input.GetType());
}
static gfx::RectF rect(const gfx::RRectF& input) { return input.rect(); }
static gfx::Vector2dF upper_left(const gfx::RRectF& input) {
return input.GetCornerRadii(gfx::RRectF::Corner::kUpperLeft);
}
static gfx::Vector2dF upper_right(const gfx::RRectF& input) {
return input.GetCornerRadii(gfx::RRectF::Corner::kUpperRight);
}
static gfx::Vector2dF lower_right(const gfx::RRectF& input) {
return input.GetCornerRadii(gfx::RRectF::Corner::kLowerRight);
}
static gfx::Vector2dF lower_left(const gfx::RRectF& input) {
return input.GetCornerRadii(gfx::RRectF::Corner::kLowerLeft);
}
static bool Read(gfx::mojom::RRectFDataView data, gfx::RRectF* out) {
gfx::RRectF::Type type(MojoRRectFTypeToGfx(data.type()));
gfx::RectF rect;
if (!data.ReadRect(&rect))
return false;
if (type <= gfx::RRectF::Type::kRect) {
*out = gfx::RRectFBuilder().set_rect(rect).Build();
return true;
}
gfx::Vector2dF upper_left;
if (!data.ReadUpperLeft(&upper_left))
return false;
if (type <= gfx::RRectF::Type::kSimple) {
*out = gfx::RRectFBuilder()
.set_rect(rect)
.set_radius(upper_left.x(), upper_left.y())
.Build();
return true;
}
gfx::Vector2dF upper_right;
gfx::Vector2dF lower_right;
gfx::Vector2dF lower_left;
if (!data.ReadUpperRight(&upper_right) ||
!data.ReadLowerRight(&lower_right) ||
!data.ReadLowerLeft(&lower_left)) {
return false;
}
*out = gfx::RRectFBuilder()
.set_rect(rect)
.set_upper_left(upper_left.x(), upper_left.y())
.set_upper_right(upper_right.x(), upper_right.y())
.set_lower_right(lower_right.x(), lower_right.y())
.set_lower_left(lower_left.x(), lower_left.y())
.Build();
return true;
}
};
} // namespace mojo
#endif // UI_GFX_MOJOM_RRECT_F_MOJOM_TRAITS_H_
| endlessm/chromium-browser | ui/gfx/mojom/rrect_f_mojom_traits.h | C | bsd-3-clause | 3,912 | [
30522,
1013,
1013,
9385,
2760,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
18667,
2094,
1011,
2806,
6105,
2008,
2064,
2022,
1013,
1013,
2179,
1999,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#Region "Microsoft.VisualBasic::3e29c929dbfbd2169572b406b503398f, Microsoft.VisualBasic.Core\src\Extensions\Math\NumberGroups.vb"
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' 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/>.
' /********************************************************************************/
' Summaries:
' Module NumberGroups
'
' Function: BinarySearch, (+3 Overloads) GroupBy, GroupByImpl, GroupByParallel, Groups
' Match, Min
'
' Interface IVector
'
' Properties: Data
'
' Interface INumberTag
'
' Properties: Tag
'
'
' /********************************************************************************/
#End Region
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
Imports Microsoft.VisualBasic.ComponentModel.TagData
Imports Microsoft.VisualBasic.Language
Imports Microsoft.VisualBasic.Linq
Imports Microsoft.VisualBasic.Math.Statistics
Imports Microsoft.VisualBasic.Parallel
Imports stdNum = System.Math
Namespace Math
''' <summary>
''' Simple number vector grouping
''' </summary>
Public Module NumberGroups
<Extension>
Public Function Match(Of T As IVector)(a As IEnumerable(Of T), b As IEnumerable(Of T)) As Double
Dim target As New List(Of T)(a)
Dim mins = b.Select(Function(x) target.Min(x))
Dim result As Double = mins.Sum(Function(tt) tt.Tag)
With target
For Each x In mins.Select(Function(o) o.Value)
Call .Remove(item:=x)
If .Count = 0 Then
Exit For
End If
Next
End With
Return result * (target.Count + 1)
End Function
''' <summary>
''' 计算出<paramref name="target"/>集合之众的与<paramref name="v"/>距离最小的元素
''' (或者说是匹配度最高的元素)
''' </summary>
''' <typeparam name="T"></typeparam>
''' <param name="target"></param>
''' <param name="v"></param>
''' <returns></returns>
<Extension>
Public Function Min(Of T As IVector)(target As IEnumerable(Of T), v As T) As DoubleTagged(Of T)
Dim minV# = Double.MaxValue
Dim minX As T
Dim vector#() = v.Data
For Each x As T In target
Dim d# = x.Data.EuclideanDistance(vector)
If d < minV Then
minV = d
minX = x
End If
Next
Return New DoubleTagged(Of T) With {
.Tag = minV,
.Value = minX
}
End Function
''' <summary>
''' Returns ``-1`` means no search result
''' </summary>
''' <param name="seq"></param>
''' <param name="target#"></param>
''' <param name="equals"></param>
''' <returns></returns>
<Extension>
Public Function BinarySearch(seq As IEnumerable(Of Double), target#, equals As GenericLambda(Of Double).IEquals) As Integer
With seq _
.SeqIterator _
.OrderBy(Function(x) x.value) _
.ToArray
Dim x As SeqValue(Of Double)
Dim min% = 0
Dim max% = .Length - 1
Dim index%
Dim value#
If max = -1 Then
' no elements
Return -1
ElseIf max = 0 Then
' one element
If equals(.ByRef(0).value, target) Then
Return 0
Else
' 序列只有一个元素,但是不相等,则返回-1,否则后面的while会无限死循环
Return -1
End If
End If
Do While max <> (min + 1)
index = (max - min) / 2 + min
x = .ByRef(index)
value = x.value
If equals(target, value) Then
Return x.i
ElseIf target > value Then
min = index
Else
max = index
End If
Loop
If equals(.ByRef(min).value, target) Then
Return .ByRef(min).i
ElseIf equals(.ByRef(max).value, target) Then
Return .ByRef(max).i
Else
Return -1
End If
End With
End Function
''' <summary>
''' 将一维的数据按照一定的偏移量分组输出
''' </summary>
''' <param name="source"></param>
''' <returns></returns>
<Extension> Public Iterator Function GroupBy(Of T)(source As IEnumerable(Of T),
evaluate As Func(Of T, Double),
equals As GenericLambda(Of Double).IEquals) As IEnumerable(Of NamedCollection(Of T))
#If NET_48 = 1 Or netcore5 = 1 Then
' 先进行预处理:求值然后进行排序
Dim tagValues = source _
.Select(Function(o) (evaluate(o), o)) _
.OrderBy(Function(o) o.Item1) _
.ToArray
Dim means As New Average
Dim members As New List(Of T)
' 根据分组的平均值来进行分组操作
For Each x As (val#, o As T) In tagValues
If means.N = 0 Then
means += x.Item1
members += x.Item2
Else
If equals(means.Average, x.Item1) Then
means += x.Item1
members += x.Item2
Else
Yield New NamedCollection(Of T)(CStr(means.Average), members)
means = New Average({x.Item1})
members = New List(Of T) From {x.Item2}
End If
End If
Next
If members > 0 Then
Yield New NamedCollection(Of T)(CStr(means.Average), members)
End If
#Else
Throw New NotImplementedException
#End If
End Function
''' <summary>
''' 将一维的数据按照一定的偏移量分组输出
''' </summary>
''' <param name="source"></param>
''' <returns></returns>
<Extension> Public Iterator Function GroupByParallel(Of T)(source As IEnumerable(Of T),
evaluate As Func(Of T, Double),
equals As GenericLambda(Of Double).IEquals,
Optional chunkSize% = 20000) As IEnumerable(Of NamedCollection(Of T))
Dim partitions = source _
.SplitIterator(partitionSize:=chunkSize) _
.AsParallel _
.Select(Function(part)
Return part.AsList.GroupByImpl(evaluate, equals)
End Function) _
.IteratesALL _
.AsList
' 先分割,再对name做分组
Dim union = partitions.GroupByImpl(Function(part) Val(part.Name), equals)
For Each unionGroup In union
Dim name$ = unionGroup.Name
Dim data = unionGroup _
.Value _
.Select(Function(member) member.Value) _
.IteratesALL _
.ToArray
Yield New NamedCollection(Of T) With {
.Name = name,
.Value = data
}
Next
End Function
<Extension>
Private Function GroupByImpl(Of T)(source As List(Of T), evaluate As Func(Of T, Double), equals As GenericLambda(Of Double).IEquals) As NamedCollection(Of T)()
Dim tmp As New With {
.avg = New Average({}),
.list = New List(Of T)
}
Dim groups = {
tmp
}.AsList * 0
Do While source.Count > 0
Dim x As T = source.Pop
Dim value# = evaluate(x)
Dim hit% = groups _
.Select(Function(g)
Return g.avg.Average
End Function) _
.BinarySearch(value, equals)
' 在这里应该使用二分法查找来加快计算速度的
If hit > -1 Then
With groups(hit)
.avg += value
.list.Add(x)
End With
Else
groups += New With {
.avg = New Average({value}),
.list = New List(Of T) From {x}
}
End If
Loop
Return groups _
.Select(Function(tuple)
Return New NamedCollection(Of T) With {
.Name = tuple.avg.Average,
.Value = tuple.list
}
End Function) _
.OrderBy(Function(tuple) Val(tuple.Name)) _
.ToArray
End Function
''' <summary>
''' 将一维的数据按照一定的偏移量分组输出
''' </summary>
''' <param name="source"></param>
''' <param name="offsets"></param>
''' <returns></returns>
'''
<MethodImpl(MethodImplOptions.AggressiveInlining)>
<Extension>
Public Function GroupBy(Of T)(source As IEnumerable(Of T), evaluate As Func(Of T, Double), offsets#) As IEnumerable(Of NamedCollection(Of T))
Return source.GroupBy(evaluate, equals:=Function(a, b) stdNum.Abs(a - b) <= offsets)
End Function
''' <summary>
''' 将一维的数据按照一定的偏移量分组输出
''' </summary>
''' <param name="numbers"></param>
''' <param name="offsets#"></param>
''' <returns></returns>
<MethodImpl(MethodImplOptions.AggressiveInlining)>
<Extension>
Public Function GroupBy(numbers As IEnumerable(Of Double), offsets#) As IEnumerable(Of NamedCollection(Of Double))
Return numbers.GroupBy(Self(Of Double), Function(a, b) stdNum.Abs(a - b) <= offsets)
End Function
''' <summary>
''' 按照相邻的两个数值是否在offset区间内来进行简单的分组操作
''' </summary>
''' <typeparam name="TagObject"></typeparam>
''' <param name="source"></param>
''' <param name="offset"></param>
''' <returns></returns>
<Extension>
Public Function Groups(Of TagObject As INumberTag)(source As IEnumerable(Of TagObject), offset As Integer) As GroupResult(Of TagObject, Integer)()
Dim list As New List(Of GroupResult(Of TagObject, Integer))
Dim orders As TagObject() = (From x As TagObject
In source
Select x
Order By x.Tag Ascending).ToArray
Dim tag As TagObject = orders(Scan0)
Dim tmp As New List(Of TagObject) From {tag}
For Each x As TagObject In orders.Skip(1)
If x.Tag - tag.Tag <= offset Then ' 因为已经是经过排序了的,所以后面总是大于前面的
tmp += x
Else
tag = x
list += New GroupResult(Of TagObject, Integer)(tag.Tag, tmp)
tmp = New List(Of TagObject) From {x}
End If
Next
If tmp.Count > 0 Then
list += New GroupResult(Of TagObject, Integer)(tag.Tag, tmp)
End If
Return list
End Function
End Module
''' <summary>
''' The numeric vector model
''' </summary>
Public Interface IVector
ReadOnly Property Data As Double()
End Interface
Public Interface INumberTag
ReadOnly Property Tag As Integer
End Interface
End Namespace
| amethyst-asuka/VisualBasic_AppFramework | Microsoft.VisualBasic.Core/src/Extensions/Math/NumberGroups.vb | Visual Basic | gpl-3.0 | 13,540 | [
30522,
1001,
2555,
1000,
7513,
1012,
5107,
22083,
2594,
1024,
1024,
1017,
2063,
24594,
2278,
2683,
24594,
18939,
26337,
2094,
17465,
2575,
2683,
28311,
2475,
2497,
12740,
2575,
2497,
12376,
22394,
2683,
2620,
2546,
1010,
7513,
1012,
5107,
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... |
#require File.dirname(__FILE__) + '/formats/email'
module DataMapper
module Validate
##
#
# @author Guy van den Berg
# @since 0.9
class CustomValidator < GenericValidator
def initialize(field_name, options = {}, &b)
#super(field_name, options)
#@field_name, @options = field_name, options
#@options[:allow_nil] = false unless @options.has_key?(:allow_nil)
end
def call(target)
#field_value = target.instance_variable_get("@#{@field_name}")
#return true if @options[:allow_nil] && field_value.nil?
#validation = (@options[:as] || @options[:with])
#error_message = nil
# Figure out what to use as the actual validator.
# If a symbol is passed to :as, look up
# the canned validation in FORMATS.
#
#validator = if validation.is_a? Symbol
# if FORMATS[validation].is_a? Array
# error_message = FORMATS[validation][1]
# FORMATS[validation][0]
# else
# FORMATS[validation] || validation
# end
#else
# validation
#end
#valid = case validator
#when Proc then validator.call(field_value)
#when Regexp then validator =~ field_value
#else raise UnknownValidationFormat, "Can't determine how to validate #{target.class}##{@field_name} with #{validator.inspect}"
#end
#unless valid
# field = Inflector.humanize(@field_name)
# value = field_value
#
# error_message = @options[:message] || error_message || '%s is invalid'.t(field)
# error_message = error_message.call(field, value) if Proc === error_message
#
# add_error(target, error_message , @field_name)
#end
#return valid
end
#class UnknownValidationFormat < StandardError; end
end # class CustomValidator
module ValidatesFormatOf
#def validates_format_of(*fields)
#opts = opts_from_validator_args(fields)
#add_validator_to_context(opts, fields, DataMapper::Validate::FormatValidator)
#end
end # module ValidatesFormatOf
end # module Validate
end # module DataMapper
| kad3nce/collective | gems/gems/dm-validations-0.9.5/lib/dm-validations/custom_validator.rb | Ruby | mit | 2,225 | [
30522,
1001,
5478,
5371,
1012,
16101,
18442,
1006,
1035,
1035,
5371,
1035,
1035,
1007,
1009,
1005,
1013,
11630,
1013,
10373,
1005,
11336,
2951,
2863,
30524,
1004,
1038,
1007,
1001,
3565,
1006,
2492,
1035,
2171,
1010,
7047,
1007,
1001,
1030,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
namespace TietoCRM.Models
{
/// <summary>
/// Denna klass används inte längre!
/// </summary>
public class MainContractText
{
public enum MainContractType
{
MainHead,
Subheading,
Text
};
private MainContractType type;
public MainContractType Type
{
get { return type; }
set { type = value; }
}
private String name;
public String Name
{
get { return name; }
set { name = value; }
}
private String value;
public String Value
{
get { return this.value; }
set { this.value = value; }
}
private List<MainContractText> children;
public List<MainContractText> Children
{
get { return children; }
set { children = value; }
}
/// <summary>
/// init the object with certain values.
/// </summary>
/// <param name="name">The column name in the database</param>
/// <param name="type">The heading type of the object, MainHead, Subheading, Text</param>
/// <param name="value">The value the database holds</param>
public MainContractText(String name, MainContractType type, String value)
{
this.Name = name;
this.Type = type;
this.Value = value;
this.Children = new List<MainContractText>();
}
}
} | erlingsjostrom/TSS | TESS/Models/MainContractText.cs | C# | mit | 1,630 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
3415,
15327,
5495,
3406,
26775,
2213,
1012,
4275,
1063,
1013,
1013,
1013,
1026,
12654,
1028,
1013,
1013,
1013,
7939,
2532,
1047,
27102,
2019,
6212,
5104,
20014,
2063,
11374... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
"""A way to read and write structs to a binary file, with fast access
Licensed under the 3-clause BSD License:
Copyright (c) 2011-2014, Neeraj Kumar (neerajkumar.org)
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 author 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 NEERAJ KUMAR 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.
"""
import os, sys, time
import struct
class StructFile(object):
"""A file which contains structs"""
def __init__(self, structfmt, fname):
"""Initializes a structfile using the given structfmt and fname.
The file is opened in the given mode ('rb' as default)."""
self.struct = struct.Struct(structfmt)
self.size = self.struct.size
self.fname = fname
if not os.path.exists(fname):
open(fname, 'wb').close()
self.readptr = open(fname, 'rb')
try:
self.writeptr = open(fname, 'r+b')
except IOError:
self.writeptr = None
def __len__(self):
"""Returns the number of structs in this file"""
f = self.readptr
f.seek(0, os.SEEK_END)
n = f.tell()
return n/self.size
def __iter__(self):
"""Iterates over structs in this file, from the beginning"""
f = open(self.fname, 'rb')
while 1:
try:
yield self.struct.unpack(f.read(self.size))
except EOFError:
break
def __getitem__(self, i):
"""Returns the i'th struct.
Negative indices work as well.
Raised IndexError on invalid index.
"""
l = len(self)
if i < 0:
i += l
if i >= l: raise IndexError
f = self.readptr
f.seek(self.size*i)
return self.struct.unpack(f.read(self.size))
def __setitem__(self, i, val):
"""Sets the i'th struct. The file must already have this many structs.
Negative indices work as well.
Raised IndexError on invalid index.
Raises IOError if the file doesn't have write permissions.
"""
l = len(self)
if i < 0:
i += l
if i >= l: raise IndexError
f = self.writeptr
if not f: raise IOError
f.seek(self.size*i)
f.write(self.struct.pack(*val))
def flush(self):
"""Flushes the file if any changes have been made.
Raises IOError if the file doesn't have write permissions.
"""
if not self.writeptr: raise IOError
self.writeptr.flush()
def append(self, val):
"""Adds the given value to the end of the file.
Raises IOError if the file doesn't have write permissions.
"""
f = self.writeptr
if not f: raise IOError
f.seek(0, os.SEEK_END)
f.write(self.struct.pack(*val))
| neeraj-kumar/nkpylib | structfile.py | Python | bsd-3-clause | 4,103 | [
30522,
1000,
1000,
1000,
1037,
2126,
2000,
3191,
1998,
4339,
2358,
6820,
16649,
2000,
1037,
12441,
5371,
1010,
2007,
3435,
3229,
7000,
2104,
1996,
1017,
1011,
11075,
18667,
2094,
6105,
1024,
9385,
1006,
1039,
1007,
2249,
1011,
2297,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package addonloader.util;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
/**
* Simple wrapper around {@link Properites},
* allowing to easily access objects.
* @author Enginecrafter77
*/
public class ObjectSettings extends Properties{
private static final long serialVersionUID = -8939834947658913650L;
private final File path;
public ObjectSettings(File path) throws FileNotFoundException, IOException
{
this.path = path;
this.load(new FileReader(path));
}
public ObjectSettings(String path) throws FileNotFoundException, IOException
{
this(new File(path));
}
public boolean getBoolean(String key, boolean def)
{
return Boolean.parseBoolean(this.getProperty(key, String.valueOf(def)));
}
public int getInteger(String key, int def)
{
return Integer.parseInt(this.getProperty(key, String.valueOf(def)));
}
public float getFloat(String key, float def)
{
return Float.parseFloat(this.getProperty(key, String.valueOf(def)));
}
public void set(String key, Object val)
{
this.setProperty(key, val.toString());
}
public void store(String comment)
{
try
{
this.store(new FileOutputStream(path), comment);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
| Enginecrafter77/LMPluger | src/addonloader/util/ObjectSettings.java | Java | mit | 1,423 | [
30522,
7427,
5587,
2239,
11066,
2121,
1012,
21183,
4014,
1025,
12324,
9262,
1012,
22834,
1012,
5371,
1025,
12324,
9262,
1012,
22834,
1012,
5371,
17048,
14876,
8630,
10288,
24422,
1025,
12324,
9262,
1012,
22834,
1012,
5371,
5833,
18780,
21422,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 Ember from 'ember';
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize: function(serialized) {
return (Ember.typeOf(serialized) == "array") ? serialized : [];
},
serialize: function(deserialized) {
var type = Ember.typeOf(deserialized);
if (type == 'array') {
return deserialized
} else if (type == 'string') {
return deserialized.split(',').map(function(item) {
return Ember.$.trim(item);
});
} else {
return [];
}
}
});
| johan--/rose | rui/app/transforms/array.js | JavaScript | gpl-3.0 | 522 | [
30522,
12324,
7861,
5677,
2013,
1005,
7861,
5677,
1005,
1025,
12324,
16233,
2013,
1005,
7861,
5677,
1011,
2951,
1005,
1025,
9167,
12398,
16233,
1012,
10938,
1012,
7949,
1006,
1063,
4078,
11610,
3669,
4371,
1024,
3853,
1006,
27289,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
from . import models
from . import lroe
| factorlibre/l10n-spain | l10n_es_ticketbai_api_batuz/__init__.py | Python | agpl-3.0 | 40 | [
30522,
2013,
1012,
12324,
4275,
2013,
1012,
12324,
1048,
3217,
2063,
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... |
<?php
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Professional Subscription
* Agreement ("License") which can be viewed at
* http://www.sugarcrm.com/crm/products/sugar-professional-eula.html
* By installing or using this file, You have unconditionally agreed to the
* terms and conditions of the License, and You may not use this file except in
* compliance with the License. Under the terms of the license, You shall not,
* among other things: 1) sublicense, resell, rent, lease, redistribute, assign
* or otherwise transfer Your rights to the Software, and 2) use the Software
* for timesharing or service bureau purposes such as hosting the Software for
* commercial gain and/or for the benefit of a third party. Use of the Software
* may be subject to applicable fees and any use of the Software without first
* paying applicable fees is strictly prohibited. You do not have the right to
* remove SugarCRM copyrights from the source code or user interface.
*
* All copies of the Covered Code must include on each user interface screen:
* (i) the "Powered by SugarCRM" logo and
* (ii) the SugarCRM copyright notice
* in the same form as they appear in the distribution. See full license for
* requirements.
*
* Your Warranty, Limitations of liability and Indemnity are expressly stated
* in the License. Please refer to the License for the specific language
* governing these rights and limitations under the License. Portions created
* by SugarCRM are Copyright (C) 2004-2010 SugarCRM, Inc.; All Rights Reserved.
********************************************************************************/
$module_name = 'sugartalk_SMS';
$viewdefs[$module_name]['DetailView'] = array(
'templateMeta' => array('form' => array('buttons'=>array('EDIT', 'DUPLICATE', 'DELETE',)),
'maxColumns' => '1',
'widths' => array(
array('label' => '10', 'field' => '30'),
array('label' => '10', 'field' => '30')
),
),
'panels' => array (
array (
'name',
),
array (
'assigned_user_name',
),
)
);
?> | MarStan/sugar_work | modules/sugartalk_SMS/metadata/wireless.detailviewdefs.php | PHP | agpl-3.0 | 2,329 | [
30522,
1026,
1029,
25718,
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,
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... |
/// \file
// Range v3 library
//
// Copyright Eric Niebler 2013-present
// Copyright Tomislav Ivek 2015-2016
//
// Use, modification and distribution is subject to the
// Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//
#ifndef RANGES_V3_VIEW_SET_ALGORITHM_HPP
#define RANGES_V3_VIEW_SET_ALGORITHM_HPP
#include <algorithm>
#include <iterator>
#include <type_traits>
#include <utility>
#include <meta/meta.hpp>
#include <range/v3/range_fwd.hpp>
#include <range/v3/functional/comparisons.hpp>
#include <range/v3/functional/identity.hpp>
#include <range/v3/functional/invoke.hpp>
#include <range/v3/iterator/default_sentinel.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/primitives.hpp>
#include <range/v3/range/traits.hpp>
#include <range/v3/utility/move.hpp>
#include <range/v3/utility/semiregular_box.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/view/all.hpp>
#include <range/v3/view/facade.hpp>
#include <range/v3/view/view.hpp>
#include <range/v3/detail/disable_warnings.hpp>
namespace ranges
{
/// \cond
namespace detail
{
template<typename Rng1, typename Rng2, typename C, typename P1, typename P2,
template<bool, typename...> class Cursor, cardinality Cardinality>
struct set_algorithm_view
: view_facade<set_algorithm_view<Rng1, Rng2, C, P1, P2, Cursor, Cardinality>,
Cardinality>
{
private:
friend range_access;
semiregular_box_t<C> pred_;
semiregular_box_t<P1> proj1_;
semiregular_box_t<P2> proj2_;
Rng1 rng1_;
Rng2 rng2_;
template<bool IsConst>
using cursor = Cursor<IsConst, Rng1, Rng2, C, P1, P2>;
cursor<simple_view<Rng1>() && simple_view<Rng2>()> begin_cursor()
{
return {pred_,
proj1_,
proj2_,
ranges::begin(rng1_),
ranges::end(rng1_),
ranges::begin(rng2_),
ranges::end(rng2_)};
}
CPP_member
auto begin_cursor() const -> CPP_ret(cursor<true>)( //
requires range<Rng1 const> && range<Rng2 const>)
{
return {pred_,
proj1_,
proj2_,
ranges::begin(rng1_),
ranges::end(rng1_),
ranges::begin(rng2_),
ranges::end(rng2_)};
}
public:
set_algorithm_view() = default;
set_algorithm_view(Rng1 rng1, Rng2 rng2, C pred, P1 proj1, P2 proj2)
: pred_(std::move(pred))
, proj1_(std::move(proj1))
, proj2_(std::move(proj2))
, rng1_(std::move(rng1))
, rng2_(std::move(rng2))
{}
};
template<bool IsConst, typename Rng1, typename Rng2, typename C, typename P1,
typename P2>
struct set_difference_cursor
{
private:
friend struct set_difference_cursor<!IsConst, Rng1, Rng2, C, P1, P2>;
using pred_ref_ = semiregular_box_ref_or_val_t<C, IsConst>;
using proj1_ref_ = semiregular_box_ref_or_val_t<P1, IsConst>;
using proj2_ref_ = semiregular_box_ref_or_val_t<P2, IsConst>;
pred_ref_ pred_;
proj1_ref_ proj1_;
proj2_ref_ proj2_;
template<typename T>
using constify_if = meta::const_if_c<IsConst, T>;
using R1 = constify_if<Rng1>;
using R2 = constify_if<Rng2>;
iterator_t<R1> it1_;
sentinel_t<R1> end1_;
iterator_t<R2> it2_;
sentinel_t<R2> end2_;
void satisfy()
{
while(it1_ != end1_)
{
if(it2_ == end2_)
return;
if(invoke(pred_, invoke(proj1_, *it1_), invoke(proj2_, *it2_)))
return;
if(!invoke(pred_, invoke(proj2_, *it2_), invoke(proj1_, *it1_)))
++it1_;
++it2_;
}
}
public:
using value_type = range_value_t<constify_if<Rng1>>;
using single_pass = meta::or_c<single_pass_iterator_<iterator_t<R1>>,
single_pass_iterator_<iterator_t<R2>>>;
set_difference_cursor() = default;
set_difference_cursor(pred_ref_ pred, proj1_ref_ proj1, proj2_ref_ proj2,
iterator_t<R1> it1, sentinel_t<R1> end1,
iterator_t<R2> it2, sentinel_t<R2> end2)
: pred_(std::move(pred))
, proj1_(std::move(proj1))
, proj2_(std::move(proj2))
, it1_(std::move(it1))
, end1_(std::move(end1))
, it2_(std::move(it2))
, end2_(std::move(end2))
{
satisfy();
}
CPP_template(bool Other)( //
requires IsConst && (!Other)) //
set_difference_cursor(
set_difference_cursor<Other, Rng1, Rng2, C, P1, P2> that)
: pred_(std::move(that.pred_))
, proj1_(std::move(that.proj1_))
, proj2_(std::move(that.proj2_))
, it1_(std::move(that.it1_))
, end1_(std::move(that.end1_))
, it2_(std::move(that.it2_))
, end2_(std::move(that.end2_))
{}
// clang-format off
auto CPP_auto_fun(read)()(const)
(
return *it1_
)
// clang-format on
void next()
{
++it1_;
satisfy();
}
CPP_member
auto equal(set_difference_cursor const & that) const -> CPP_ret(bool)( //
requires forward_range<Rng1>)
{
// does not support comparing iterators from different ranges
return it1_ == that.it1_;
}
bool equal(default_sentinel_t) const
{
return it1_ == end1_;
}
// clang-format off
auto CPP_auto_fun(move)()(const)
(
return iter_move(it1_)
)
// clang-format on
};
constexpr cardinality set_difference_cardinality(cardinality c1, cardinality c2)
{
return (c1 == unknown)
? unknown
: (c1 >= 0) || (c1 == finite) ? finite : // else, c1 == infinite
(c2 >= 0) || (c2 == finite) ? infinite : unknown;
}
} // namespace detail
/// \endcond
template<typename Rng1, typename Rng2, typename C, typename P1, typename P2>
using set_difference_view =
detail::set_algorithm_view<Rng1, Rng2, C, P1, P2, detail::set_difference_cursor,
detail::set_difference_cardinality(
range_cardinality<Rng1>::value,
range_cardinality<Rng2>::value)>;
namespace views
{
struct set_difference_base_fn
{
template<typename Rng1, typename Rng2, typename C = less,
typename P1 = identity, typename P2 = identity>
auto operator()(Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{},
P2 proj2 = P2{}) const
-> CPP_ret(set_difference_view<all_t<Rng1>, all_t<Rng2>, C, P1, P2>)( //
requires viewable_range<Rng1> && input_range<Rng1> &&
viewable_range<Rng2> && input_range<Rng2> &&
indirect_relation<C, projected<iterator_t<Rng1>, P1>,
projected<iterator_t<Rng2>, P2>>)
{
return {all(static_cast<Rng1 &&>(rng1)),
all(static_cast<Rng2 &&>(rng2)),
std::move(pred),
std::move(proj1),
std::move(proj2)};
}
};
struct set_difference_fn : set_difference_base_fn
{
using set_difference_base_fn::operator();
template<typename Rng2, typename C = less, typename P1 = identity,
typename P2 = identity>
constexpr auto CPP_fun(operator())(Rng2 && rng2, C && pred = C{},
P1 proj1 = P1{}, P2 proj2 = P2{})(
const //
requires viewable_range<Rng2> && input_range<Rng2> &&
(!range<C>))
{
return make_view_closure(bind_back(set_difference_base_fn{},
all(rng2),
static_cast<C &&>(pred),
std::move(proj1),
std::move(proj2)));
}
};
/// \relates set_difference_fn
/// \ingroup group-views
RANGES_INLINE_VARIABLE(set_difference_fn, set_difference)
} // namespace views
/// @}
/// \cond
namespace detail
{
template<bool IsConst, typename Rng1, typename Rng2, typename C, typename P1,
typename P2>
struct set_intersection_cursor
{
private:
friend struct set_intersection_cursor<!IsConst, Rng1, Rng2, C, P1, P2>;
using pred_ref_ = semiregular_box_ref_or_val_t<C, IsConst>;
using proj1_ref_ = semiregular_box_ref_or_val_t<P1, IsConst>;
using proj2_ref_ = semiregular_box_ref_or_val_t<P2, IsConst>;
pred_ref_ pred_;
proj1_ref_ proj1_;
proj2_ref_ proj2_;
template<typename T>
using constify_if = meta::const_if_c<IsConst, T>;
using R1 = constify_if<Rng1>;
using R2 = constify_if<Rng2>;
iterator_t<R1> it1_;
sentinel_t<R1> end1_;
iterator_t<R2> it2_;
sentinel_t<R2> end2_;
void satisfy()
{
while(it1_ != end1_ && it2_ != end2_)
{
if(invoke(pred_, invoke(proj1_, *it1_), invoke(proj2_, *it2_)))
++it1_;
else
{
if(!invoke(pred_, invoke(proj2_, *it2_), invoke(proj1_, *it1_)))
return;
++it2_;
}
}
}
public:
using value_type = range_value_t<R1>;
using single_pass = meta::or_c<single_pass_iterator_<iterator_t<R1>>,
single_pass_iterator_<iterator_t<R2>>>;
set_intersection_cursor() = default;
set_intersection_cursor(pred_ref_ pred, proj1_ref_ proj1, proj2_ref_ proj2,
iterator_t<R1> it1, sentinel_t<R1> end1,
iterator_t<R2> it2, sentinel_t<R2> end2)
: pred_(std::move(pred))
, proj1_(std::move(proj1))
, proj2_(std::move(proj2))
, it1_(std::move(it1))
, end1_(std::move(end1))
, it2_(std::move(it2))
, end2_(std::move(end2))
{
satisfy();
}
CPP_template(bool Other)( //
requires IsConst && (!Other)) //
set_intersection_cursor(
set_intersection_cursor<Other, Rng1, Rng2, C, P1, P2> that)
: pred_(std::move(that.pred_))
, proj1_(std::move(that.proj1_))
, proj2_(std::move(that.proj2_))
, it1_(std::move(that.it1_))
, end1_(std::move(that.end1_))
, it2_(std::move(that.it2_))
, end2_(std::move(that.end2_))
{}
// clang-format off
auto CPP_auto_fun(read)()(const)
(
return *it1_
)
// clang-format on
void next()
{
++it1_;
++it2_;
satisfy();
}
CPP_member
auto equal(set_intersection_cursor const & that) const -> CPP_ret(bool)( //
requires forward_range<Rng1>)
{
// does not support comparing iterators from different ranges
return it1_ == that.it1_;
}
bool equal(default_sentinel_t) const
{
return (it1_ == end1_) || (it2_ == end2_);
}
// clang-format off
auto CPP_auto_fun(move)()(const)
(
return iter_move(it1_)
)
// clang-format on
};
constexpr cardinality set_intersection_cardinality(cardinality c1, cardinality c2)
{
return (c1 == unknown) || (c2 == unknown)
? unknown
: (c1 >= 0 || c1 == finite) || (c2 >= 0 || c2 == finite) ? finite
: unknown;
}
} // namespace detail
/// \endcond
template<typename Rng1, typename Rng2, typename C, typename P1, typename P2>
using set_intersection_view =
detail::set_algorithm_view<Rng1, Rng2, C, P1, P2, detail::set_intersection_cursor,
detail::set_intersection_cardinality(
range_cardinality<Rng1>::value,
range_cardinality<Rng2>::value)>;
namespace views
{
struct set_intersection_base_fn
{
template<typename Rng1, typename Rng2, typename C = less,
typename P1 = identity, typename P2 = identity>
auto operator()(Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{},
P2 proj2 = P2{}) const
-> CPP_ret(set_intersection_view<all_t<Rng1>, all_t<Rng2>, C, P1, P2>)( //
requires viewable_range<Rng1> && input_range<Rng1> &&
viewable_range<Rng2> && input_range<Rng2> &&
indirect_relation<C, projected<iterator_t<Rng1>, P1>,
projected<iterator_t<Rng2>, P2>>)
{
return {all(static_cast<Rng1 &&>(rng1)),
all(static_cast<Rng2 &&>(rng2)),
std::move(pred),
std::move(proj1),
std::move(proj2)};
}
};
struct set_intersection_fn : set_intersection_base_fn
{
using set_intersection_base_fn::operator();
template<typename Rng2, typename C = less, typename P1 = identity,
typename P2 = identity>
constexpr auto CPP_fun(operator())(Rng2 && rng2, C && pred = C{},
P1 proj1 = P1{}, P2 proj2 = P2{})(
const //
requires viewable_range<Rng2> && input_range<Rng2> &&
(!range<C>))
{
return make_view_closure(bind_back(set_intersection_base_fn{},
all(rng2),
static_cast<C &&>(pred),
std::move(proj1),
std::move(proj2)));
}
};
/// \relates set_intersection_fn
/// \ingroup group-views
RANGES_INLINE_VARIABLE(set_intersection_fn, set_intersection)
} // namespace views
/// @}
/// \cond
namespace detail
{
template<bool IsConst, typename Rng1, typename Rng2, typename C, typename P1,
typename P2>
struct set_union_cursor
{
private:
friend struct set_union_cursor<!IsConst, Rng1, Rng2, C, P1, P2>;
using pred_ref_ = semiregular_box_ref_or_val_t<C, IsConst>;
using proj1_ref_ = semiregular_box_ref_or_val_t<P1, IsConst>;
using proj2_ref_ = semiregular_box_ref_or_val_t<P2, IsConst>;
pred_ref_ pred_;
proj1_ref_ proj1_;
proj2_ref_ proj2_;
template<typename T>
using constify_if = meta::const_if_c<IsConst, T>;
using R1 = constify_if<Rng1>;
using R2 = constify_if<Rng2>;
iterator_t<R1> it1_;
sentinel_t<R1> end1_;
iterator_t<R2> it2_;
sentinel_t<R2> end2_;
enum class state_t
{
FIRST,
SECOND
} state;
void satisfy()
{
if(it1_ == end1_)
{
state = state_t::SECOND;
return;
}
if(it2_ == end2_)
{
state = state_t::FIRST;
return;
}
if(invoke(pred_, invoke(proj2_, *it2_), invoke(proj1_, *it1_)))
{
state = state_t::SECOND;
return;
}
if(!invoke(pred_, invoke(proj1_, *it1_), invoke(proj2_, *it2_)))
++it2_;
state = state_t::FIRST;
}
public:
using value_type = common_type_t<range_value_t<R1>, range_value_t<R2>>;
using reference_type =
common_reference_t<range_reference_t<R1>, range_reference_t<R2>>;
using rvalue_reference_type =
common_reference_t<range_rvalue_reference_t<R1>,
range_rvalue_reference_t<R2>>;
using single_pass = meta::or_c<single_pass_iterator_<iterator_t<R1>>,
single_pass_iterator_<iterator_t<R2>>>;
set_union_cursor() = default;
set_union_cursor(pred_ref_ pred, proj1_ref_ proj1, proj2_ref_ proj2,
iterator_t<R1> it1, sentinel_t<R1> end1, iterator_t<R2> it2,
sentinel_t<R2> end2)
: pred_(std::move(pred))
, proj1_(std::move(proj1))
, proj2_(std::move(proj2))
, it1_(std::move(it1))
, end1_(std::move(end1))
, it2_(std::move(it2))
, end2_(std::move(end2))
{
satisfy();
}
CPP_template(bool Other)( //
requires IsConst && (!Other))
set_union_cursor(set_union_cursor<Other, Rng1, Rng2, C, P1, P2> that)
: pred_(std::move(that.pred_))
, proj1_(std::move(that.proj1_))
, proj2_(std::move(that.proj2_))
, it1_(std::move(that.it1_))
, end1_(std::move(that.end1_))
, it2_(std::move(that.it2_))
, end2_(std::move(that.end2_))
{}
reference_type read() const noexcept(noexcept(*it1_) && noexcept(*it2_))
{
if(state == state_t::SECOND)
return *it2_;
else
return *it1_;
}
void next()
{
if(state == state_t::FIRST)
++it1_;
else
++it2_;
satisfy();
}
CPP_member
auto equal(set_union_cursor const & that) const -> CPP_ret(bool)( //
requires forward_range<Rng1> && forward_range<Rng2>)
{
// does not support comparing iterators from different ranges
return (it1_ == that.it1_) && (it2_ == that.it2_);
}
bool equal(default_sentinel_t) const
{
return (it1_ == end1_) && (it2_ == end2_);
}
rvalue_reference_type move() const
noexcept(noexcept(iter_move(it1_)) && noexcept(iter_move(it2_)))
{
if(state == state_t::SECOND)
return iter_move(it2_);
else
return iter_move(it1_);
}
};
constexpr cardinality set_union_cardinality(cardinality c1, cardinality c2)
{
return (c1 == infinite) || (c2 == infinite)
? infinite
: (c1 == unknown) || (c2 == unknown) ? unknown : finite;
}
} // namespace detail
/// \endcond
template<typename Rng1, typename Rng2, typename C, typename P1, typename P2>
using set_union_view =
detail::set_algorithm_view<Rng1, Rng2, C, P1, P2, detail::set_union_cursor,
detail::set_union_cardinality(
range_cardinality<Rng1>::value,
range_cardinality<Rng2>::value)>;
namespace views
{
struct set_union_base_fn
{
public:
template<typename Rng1, typename Rng2, typename C = less,
typename P1 = identity, typename P2 = identity>
auto operator()(Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{},
P2 proj2 = P2{}) const
-> CPP_ret(set_union_view<all_t<Rng1>, all_t<Rng2>, C, P1, P2>)( //
requires viewable_range<Rng1> && input_range<Rng1> &&
viewable_range<Rng2> && input_range<Rng2> && common_with<
range_value_t<Rng1>, range_value_t<Rng2>> &&
common_reference_with<range_reference_t<Rng1>,
range_reference_t<Rng2>> &&
common_reference_with<range_rvalue_reference_t<Rng1>,
range_rvalue_reference_t<Rng2>> &&
indirect_relation<C, projected<iterator_t<Rng1>, P1>,
projected<iterator_t<Rng2>, P2>>)
{
return {all(static_cast<Rng1 &&>(rng1)),
all(static_cast<Rng2 &&>(rng2)),
std::move(pred),
std::move(proj1),
std::move(proj2)};
}
};
struct set_union_fn : set_union_base_fn
{
using set_union_base_fn::operator();
template<typename Rng2, typename C = less, typename P1 = identity,
typename P2 = identity>
constexpr auto CPP_fun(operator())(Rng2 && rng2, C && pred = C{},
P1 proj1 = P1{}, P2 proj2 = P2{})(
const //
requires viewable_range<Rng2> && input_range<Rng2> &&
(!range<C>))
{
return make_view_closure(bind_back(set_union_base_fn{},
all(rng2),
static_cast<C &&>(pred),
std::move(proj1),
std::move(proj2)));
}
};
/// \relates set_union_fn
/// \ingroup group-views
RANGES_INLINE_VARIABLE(set_union_fn, set_union)
} // namespace views
/// @}
/// \cond
namespace detail
{
template<bool IsConst, typename Rng1, typename Rng2, typename C, typename P1,
typename P2>
struct set_symmetric_difference_cursor
{
private:
friend struct set_symmetric_difference_cursor<!IsConst, Rng1, Rng2, C, P1,
P2>;
using pred_ref_ = semiregular_box_ref_or_val_t<C, IsConst>;
using proj1_ref_ = semiregular_box_ref_or_val_t<P1, IsConst>;
using proj2_ref_ = semiregular_box_ref_or_val_t<P2, IsConst>;
pred_ref_ pred_;
proj1_ref_ proj1_;
proj2_ref_ proj2_;
template<typename T>
using constify_if = meta::const_if_c<IsConst, T>;
using R1 = constify_if<Rng1>;
using R2 = constify_if<Rng2>;
iterator_t<R1> it1_;
sentinel_t<R1> end1_;
iterator_t<R2> it2_;
sentinel_t<R2> end2_;
enum class state_t
{
FIRST,
SECOND,
ONLY_FIRST,
ONLY_SECOND
} state;
void satisfy()
{
while(it1_ != end1_)
{
if(it2_ == end2_)
{
state = state_t::ONLY_FIRST;
return;
}
if(invoke(pred_, invoke(proj1_, *it1_), invoke(proj2_, *it2_)))
{
state = state_t::FIRST;
return;
}
else
{
if(invoke(pred_, invoke(proj2_, *it2_), invoke(proj1_, *it1_)))
{
state = state_t::SECOND;
return;
}
else
{
++it1_;
++it2_;
}
}
}
state = state_t::ONLY_SECOND;
}
public:
using value_type = common_type_t<range_value_t<R1>, range_value_t<R2>>;
using reference_type =
common_reference_t<range_reference_t<R1>, range_reference_t<R2>>;
using rvalue_reference_type =
common_reference_t<range_rvalue_reference_t<R1>,
range_rvalue_reference_t<R2>>;
using single_pass = meta::or_c<single_pass_iterator_<iterator_t<R1>>,
single_pass_iterator_<iterator_t<R2>>>;
set_symmetric_difference_cursor() = default;
set_symmetric_difference_cursor(pred_ref_ pred, proj1_ref_ proj1,
proj2_ref_ proj2, iterator_t<R1> it1,
sentinel_t<R1> end1, iterator_t<R2> it2,
sentinel_t<R2> end2)
: pred_(std::move(pred))
, proj1_(std::move(proj1))
, proj2_(std::move(proj2))
, it1_(std::move(it1))
, end1_(std::move(end1))
, it2_(std::move(it2))
, end2_(std::move(end2))
, state()
{
satisfy();
}
CPP_template(bool Other)( //
requires IsConst && (!Other)) //
set_symmetric_difference_cursor(
set_symmetric_difference_cursor<Other, Rng1, Rng2, C, P1, P2> that)
: pred_(std::move(that.pred_))
, proj1_(std::move(that.proj1_))
, proj2_(std::move(that.proj2_))
, it1_(std::move(that.it1_))
, end1_(std::move(that.end1_))
, it2_(std::move(that.it2_))
, end2_(std::move(that.end2_))
, state(that.state)
{}
reference_type read() const noexcept(noexcept(*it1_) && noexcept(*it2_))
{
if(state == state_t::SECOND || state == state_t::ONLY_SECOND)
return *it2_;
else
return *it1_;
}
void next()
{
switch(state)
{
case state_t::FIRST:
++it1_;
satisfy();
break;
case state_t::ONLY_FIRST:
++it1_;
break;
case state_t::SECOND:
++it2_;
satisfy();
break;
case state_t::ONLY_SECOND:
++it2_;
break;
}
}
CPP_member
auto equal(set_symmetric_difference_cursor const & that) const
-> CPP_ret(bool)( //
requires forward_range<R1> && forward_range<R2>)
{
// does not support comparing iterators from different ranges:
return (it1_ == that.it1_) && (it2_ == that.it2_);
}
bool equal(default_sentinel_t) const
{
return (it1_ == end1_) && (it2_ == end2_);
}
rvalue_reference_type move() const
noexcept(noexcept(iter_move(it1_)) && noexcept(iter_move(it2_)))
{
if(state == state_t::SECOND || state == state_t::ONLY_SECOND)
return iter_move(it2_);
else
return iter_move(it1_);
}
};
constexpr cardinality set_symmetric_difference_cardinality(cardinality c1,
cardinality c2)
{
return (c1 == unknown) || (c2 == unknown)
? unknown
: (c1 == infinite) != (c2 == infinite)
? infinite
: (c1 == infinite) && (c2 == infinite) ? unknown : finite;
}
} // namespace detail
/// \endcond
template<typename Rng1, typename Rng2, typename C, typename P1, typename P2>
using set_symmetric_difference_view = detail::set_algorithm_view<
Rng1, Rng2, C, P1, P2, detail::set_symmetric_difference_cursor,
detail::set_symmetric_difference_cardinality(range_cardinality<Rng1>::value,
range_cardinality<Rng2>::value)>;
namespace views
{
struct set_symmetric_difference_base_fn
{
template<typename Rng1, typename Rng2, typename C = less,
typename P1 = identity, typename P2 = identity>
auto operator()(Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{},
P2 proj2 = P2{}) const
-> CPP_ret(set_symmetric_difference_view<all_t<Rng1>, all_t<Rng2>, C, P1,
P2>)( //
requires viewable_range<Rng1> && input_range<Rng1> &&
viewable_range<Rng2> && input_range<Rng2> && common_with<
range_value_t<Rng1>, range_value_t<Rng2>> &&
common_reference_with<range_reference_t<Rng1>,
range_reference_t<Rng2>> &&
common_reference_with<range_rvalue_reference_t<Rng1>,
range_rvalue_reference_t<Rng2>> &&
indirect_relation<C, projected<iterator_t<Rng1>, P1>,
projected<iterator_t<Rng2>, P2>>)
{
return {all(static_cast<Rng1 &&>(rng1)),
all(static_cast<Rng2 &&>(rng2)),
std::move(pred),
std::move(proj1),
std::move(proj2)};
}
};
struct set_symmetric_difference_fn : set_symmetric_difference_base_fn
{
using set_symmetric_difference_base_fn::operator();
template<typename Rng2, typename C = less, typename P1 = identity,
typename P2 = identity>
constexpr auto CPP_fun(operator())(Rng2 && rng2, C && pred = C{},
P1 proj1 = P1{}, P2 proj2 = P2{})(
const //
requires viewable_range<Rng2> && input_range<Rng2> &&
(!range<C>))
{
return make_view_closure(bind_back(set_symmetric_difference_base_fn{},
all(rng2),
static_cast<C &&>(pred),
std::move(proj1),
std::move(proj2)));
}
};
/// \relates set_symmetric_difference_fn
/// \ingroup group-views
RANGES_INLINE_VARIABLE(set_symmetric_difference_fn, set_symmetric_difference)
} // namespace views
/// @}
} // namespace ranges
#include <range/v3/detail/reenable_warnings.hpp>
#endif
| bredelings/BAli-Phy | external/range-v3/0.10.0/include/range/v3/view/set_algorithm.hpp | C++ | gpl-2.0 | 33,745 | [
30522,
1013,
1013,
1013,
1032,
5371,
1013,
1013,
2846,
1058,
30524,
1015,
1012,
1014,
1012,
1006,
2156,
10860,
1013,
1013,
5371,
6105,
1035,
1015,
1035,
1014,
1012,
19067,
2102,
2030,
6100,
2012,
1013,
1013,
8299,
1024,
1013,
1013,
7479,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Asqatasun - Automated webpage assessment
* Copyright (C) 2008-2020 Asqatasun.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Contact us by mail: asqatasun AT asqatasun DOT org
*/
package org.asqatasun.rules.rgaa30;
import org.asqatasun.entity.audit.TestSolution;
import org.asqatasun.ruleimplementation.link.AbstractLinkRuleImplementation;
import org.asqatasun.rules.elementchecker.link.LinkPertinenceChecker;
import org.asqatasun.rules.elementselector.SvgLinkElementSelector;
import static org.asqatasun.rules.keystore.AttributeStore.TITLE_ATTR;
import static org.asqatasun.rules.keystore.HtmlElementStore.TEXT_ELEMENT2;
import static org.asqatasun.rules.keystore.RemarkMessageStore.CHECK_LINK_PERTINENCE_MSG;
import static org.asqatasun.rules.keystore.RemarkMessageStore.UNEXPLICIT_LINK_MSG;
/**
* Implementation of the rule 6.3.5 of the referential Rgaa 3.0.
*
* For more details about the implementation, refer to <a href="http://doc.asqatasun.org/en/90_Rules/rgaa3.0/06.Links/Rule-6-3-5.html">the rule 6.3.5 design page.</a>
* @see <a href="http://references.modernisation.gouv.fr/referentiel-technique-0#test-6-3-5"> 6.3.5 rule specification</a>
*/
public class Rgaa30Rule060305 extends AbstractLinkRuleImplementation {
/**
* Default constructor
*/
public Rgaa30Rule060305 () {
// context is not taken into consideration
super(new SvgLinkElementSelector(false),
new LinkPertinenceChecker(
// not pertinent solution
TestSolution.FAILED,
// not pertinent message
UNEXPLICIT_LINK_MSG,
// manual check message
CHECK_LINK_PERTINENCE_MSG,
// evidence elements
TEXT_ELEMENT2,
TITLE_ATTR
),
null);
}
}
| Asqatasun/Asqatasun | rules/rules-rgaa3.0/src/main/java/org/asqatasun/rules/rgaa30/Rgaa30Rule060305.java | Java | agpl-3.0 | 2,514 | [
30522,
1013,
1008,
1008,
2004,
19062,
10230,
4609,
1011,
12978,
4773,
13704,
7667,
1008,
9385,
1006,
1039,
1007,
2263,
1011,
12609,
2004,
19062,
10230,
4609,
1012,
8917,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
Copyright (C) 2006, 2008, 2009 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Simple program to show using libiso9660 to extract a file from a
CUE/BIN CD image.
If a single argument is given, it is used as the CUE file of a CD image
to use. Otherwise a compiled-in default image name (that
comes with the libcdio distribution) will be used.
This program can be compiled with either a C or C++ compiler. In
the distribution we prefer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* This is the CD-image with an ISO-9660 filesystem */
#define ISO9660_IMAGE_PATH "../../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/isofs-m1.cue"
#define ISO9660_PATH "/"
#define ISO9660_FILENAME "COPYING"
#define LOCAL_FILENAME "copying"
#include "portable.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio++/cdio.hpp>
#include <cdio++/iso9660.hpp>
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
delete (p_stat); \
delete (p_iso); \
return rc; \
int
main(int argc, const char *argv[])
{
ISO9660::Stat *p_stat;
FILE *p_outfd;
unsigned int i;
char const *psz_image;
char const *psz_fname;
char translated_name[256];
char untranslated_name[256] = ISO9660_PATH;
ISO9660::FS *p_iso = new ISO9660::FS;
if (argc > 3) {
printf("usage %s [CD-ROM-or-image [filename]]\n", argv[0]);
printf("Extracts filename from CD-ROM-or-image.\n");
return 1;
}
if (argc > 1)
psz_image = argv[1];
else
psz_image = ISO9660_IMAGE;
if (argc > 2)
psz_fname = argv[2];
else
psz_fname = ISO9660_FILENAME;
strcat(untranslated_name, psz_fname);
if (!p_iso->open(psz_image, DRIVER_UNKNOWN)) {
fprintf(stderr, "Sorry, couldn't open %s\n", psz_image);
return 1;
}
p_stat = p_iso->stat(psz_fname);
if (!p_stat)
{
fprintf(stderr,
"Could not get ISO-9660 file information for file %s\n",
untranslated_name);
delete(p_iso);
return 2;
}
iso9660_name_translate(psz_fname, translated_name);
if (!(p_outfd = fopen (translated_name, "wb")))
{
perror ("fopen()");
delete (p_stat);
delete (p_iso);
return 3;
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
{
const unsigned int i_blocks = CEILING(p_stat->p_stat->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks; i ++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_stat->p_stat->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
try {
p_iso->readDataBlocks(buf, lsn, ISO_BLOCKSIZE);
}
catch ( DriverOpException e ) {
fprintf(stderr, "Error reading ISO 9660 file at lsn %lu:\n\t%s.\n",
(long unsigned int) lsn, e.get_msg());
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
{
perror ("fwrite()");
my_exit(5);
}
}
}
fflush (p_outfd);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of ISO_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), p_stat->p_stat->size))
perror ("ftruncate()");
printf("Extraction of file '%s' from '%s' successful.\n",
translated_name, untranslated_name);
my_exit(0);
}
| Distrotech/libcdio | example/C++/OO/isofile2.cpp | C++ | gpl-3.0 | 4,170 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2294,
1010,
2263,
1010,
2268,
6857,
18862,
1026,
6857,
1030,
27004,
1012,
8917,
1028,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* author: the5fire
* blog: the5fire.com
* date: 2014-03-16
* */
$(function(){
WEB_SOCKET_SWF_LOCATION = "/static/WebSocketMain.swf";
WEB_SOCKET_DEBUG = true;
var socket = io.connect();
socket.on('connect', function(){
console.log('connected');
});
$(window).bind("beforeunload", function() {
socket.disconnect();
});
var User = Backbone.Model.extend({
urlRoot: '/user',
});
var Topic = Backbone.Model.extend({
urlRoot: '/topic',
});
var Message = Backbone.Model.extend({
urlRoot: '/message',
sync: function(method, model, options) {
if (method === 'create') {
socket.emit('message', model.attributes);
// 错误处理没做
$('#comment').val('');
} else {
return Backbone.sync(method, model, options);
};
},
});
var Topics = Backbone.Collection.extend({
url: '/topic',
model: Topic,
});
var Messages = Backbone.Collection.extend({
url: '/message',
model: Message,
});
var topics = new Topics;
var TopicView = Backbone.View.extend({
tagName: "div class='column'",
templ: _.template($('#topic-template').html()),
// 渲染列表页模板
render: function() {
$(this.el).html(this.templ(this.model.toJSON()));
return this;
},
});
var messages = new Messages;
var MessageView = Backbone.View.extend({
tagName: "div class='comment'",
templ: _.template($('#message-template').html()),
// 渲染列表页模板
render: function() {
$(this.el).html(this.templ(this.model.toJSON()));
return this;
},
});
var AppView = Backbone.View.extend({
el: "#main",
topic_list: $("#topic_list"),
topic_section: $("#topic_section"),
message_section: $("#message_section"),
message_list: $("#message_list"),
message_head: $("#message_head"),
events: {
'click .submit': 'saveMessage',
'click .submit_topic': 'saveTopic',
'keypress #comment': 'saveMessageEvent',
},
initialize: function() {
_.bindAll(this, 'addTopic', 'addMessage');
topics.bind('add', this.addTopic);
// 定义消息列表池,每个topic有自己的message collection
// 这样保证每个主题下得消息不冲突
this.message_pool = {};
this.socket = null;
this.message_list_div = document.getElementById('message_list');
},
addTopic: function(topic) {
var view = new TopicView({model: topic});
this.topic_list.append(view.render().el);
},
addMessage: function(message) {
var view = new MessageView({model: message});
this.message_list.append(view.render().el);
self.message_list.scrollTop(self.message_list_div.scrollHeight);
},
saveMessageEvent: function(evt) {
if (evt.keyCode == 13) {
this.saveMessage(evt);
}
},
saveMessage: function(evt) {
var comment_box = $('#comment')
var content = comment_box.val();
if (content == '') {
alert('内容不能为空');
return false;
}
var topic_id = comment_box.attr('topic_id');
var message = new Message({
content: content,
topic_id: topic_id,
});
var messages = this.message_pool[topic_id];
message.save(); // 依赖上面对sync的重载
},
saveTopic: function(evt) {
var topic_title = $('#topic_title');
if (topic_title.val() == '') {
alert('主题不能为空!');
return false
}
var topic = new Topic({
title: topic_title.val(),
});
self = this;
topic.save(null, {
success: function(model, response, options){
topics.add(response);
topic_title.val('');
},
error: function(model, resp, options) {
alert(resp.responseText);
}
});
},
showTopic: function(){
topics.fetch();
this.topic_section.show();
this.message_section.hide();
this.message_list.html('');
this.goOut()
},
goOut: function(){
// 退出房间
socket.emit('go_out');
socket.removeAllListeners('message');
},
initMessage: function(topic_id) {
var messages = new Messages;
messages.bind('add', this.addMessage);
this.message_pool[topic_id] = messages;
},
showMessage: function(topic_id) {
this.initMessage(topic_id);
this.message_section.show();
this.topic_section.hide();
this.showMessageHead(topic_id);
$('#comment').attr('topic_id', topic_id);
var messages = this.message_pool[topic_id];
// 进入房间
socket.emit('topic', topic_id);
// 监听message事件,添加对话到messages中
socket.on('message', function(response) {
messages.add(response);
});
messages.fetch({
data: {topic_id: topic_id},
success: function(resp) {
self.message_list.scrollTop(self.message_list_div.scrollHeight)
},
error: function(model, resp, options) {
alert(resp.responseText);
}
});
},
showMessageHead: function(topic_id) {
var topic = new Topic({id: topic_id});
self = this;
topic.fetch({
success: function(resp, model, options){
self.message_head.html(model.title);
},
error: function(model, resp, options) {
alert(resp.responseText);
}
});
},
});
var LoginView = Backbone.View.extend({
el: "#login",
wrapper: $('#wrapper'),
events: {
'keypress #login_pwd': 'loginEvent',
'click .login_submit': 'login',
'keypress #reg_pwd_repeat': 'registeEvent',
'click .registe_submit': 'registe',
},
hide: function() {
this.wrapper.hide();
},
show: function() {
this.wrapper.show();
},
loginEvent: function(evt) {
if (evt.keyCode == 13) {
this.login(evt);
}
},
login: function(evt){
var username_input = $('#login_username');
var pwd_input = $('#login_pwd');
var u = new User({
username: username_input.val(),
password: pwd_input.val(),
});
u.save(null, {
url: '/login',
success: function(model, resp, options){
g_user = resp;
// 跳转到index
appRouter.navigate('index', {trigger: true});
},
error: function(model, resp, options) {
alert(resp.responseText);
}
});
},
registeEvent: function(evt) {
if (evt.keyCode == 13) {
this.registe(evt);
}
},
registe: function(evt){
var reg_username_input = $('#reg_username');
var reg_pwd_input = $('#reg_pwd');
var reg_pwd_repeat_input = $('#reg_pwd_repeat');
var u = new User({
username: reg_username_input.val(),
password: reg_pwd_input.val(),
password_repeat: reg_pwd_repeat_input.val(),
});
u.save(null, {
success: function(model, resp, options){
g_user = resp;
// 跳转到index
appRouter.navigate('index', {trigger: true});
},
error: function(model, resp, options) {
alert(resp.responseText);
}
});
},
});
var UserView = Backbone.View.extend({
el: "#user_info",
username: $('#username'),
show: function(username) {
this.username.html(username);
this.$el.show();
},
});
var AppRouter = Backbone.Router.extend({
routes: {
"login": "login",
"index": "index",
"topic/:id" : "topic",
},
initialize: function(){
// 初始化项目, 显示首页
this.appView = new AppView();
this.loginView = new LoginView();
this.userView = new UserView();
this.indexFlag = false;
},
login: function(){
this.loginView.show();
},
index: function(){
if (g_user && g_user.id != undefined) {
this.appView.showTopic();
this.userView.show(g_user.username);
this.loginView.hide();
this.indexFlag = true; // 标志已经到达主页了
}
},
topic: function(topic_id) {
if (g_user && g_user.id != undefined) {
this.appView.showMessage(topic_id);
this.userView.show(g_user.username);
this.loginView.hide();
this.indexFlag = true; // 标志已经到达主页了
}
},
});
var appRouter = new AppRouter();
var g_user = new User;
g_user.fetch({
success: function(model, resp, options){
g_user = resp;
Backbone.history.start({pustState: true});
if(g_user === null || g_user.id === undefined) {
// 跳转到登录页面
appRouter.navigate('login', {trigger: true});
} else if (appRouter.indexFlag == false){
// 跳转到首页
appRouter.navigate('index', {trigger: true});
}
},
error: function(model, resp, options) {
alert(resp.responseText);
}
}); // 获取当前用户
});
| yhbyun/wechat-1 | src/static/js/chat.js | JavaScript | apache-2.0 | 10,736 | [
30522,
1013,
1008,
1008,
3166,
1024,
1996,
2629,
10273,
1008,
9927,
1024,
1996,
2629,
10273,
1012,
4012,
1008,
3058,
1024,
2297,
1011,
6021,
1011,
2385,
1008,
1008,
1013,
1002,
1006,
3853,
1006,
1007,
1063,
4773,
1035,
22278,
1035,
25430,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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>Snoopify</title>
<link rel="stylesheet" type="text/css" href="settings.css">
</head>
<body>
<h1>'Sup neff?</h1>
<button id="snoop_on" type="button">Snoop on</button>
<button id="snoop_off" type="button">Snoop off</button>
<br/><br/>
<text>Oh foshizzle</text>
<img src="http://i.imgur.com/jcIK7fy.gif" id="snoop"/>
</body>
<script language="javascript" type="text/javascript" src="settings.js"></script>
</html>
| omkarmoghe/snoopify | settings.html | HTML | mit | 491 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
2516,
1028,
29044,
8757,
1026,
1013,
2516,
1028,
1026,
4957,
2128,
2140,
1027,
1000,
6782,
21030,
2102,
1000,
2828,
1027,
1000,
3793,
1013,
20116,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 "PlayerAnimation.h"
PlayerAnimation::PlayerAnimation(Vector2D pos,SpriteAnimation *sptAnm,iComponentMediator *mediator)
: _animation(sptAnm),cGraphic(mediator),_pos(pos)
{
timeCounter = 0;
}
PlayerAnimation::~PlayerAnimation()
{
delete _animation;
}
int PlayerAnimation::DirectionFrame(iGameObject *obj)
{
int result;
if(obj->acc.y <= -1)
result = _animation->amtOfFrames()*3;
else if(obj->acc.y >= 1)
result = 0;
else if(obj->acc.x >= 1)
result = _animation->amtOfFrames();
else if( obj->acc.x <= -1)
result = _animation->amtOfFrames()*2;
return result;
}
void PlayerAnimation::receiveMessage(int msg)
{
}
void PlayerAnimation::Update(iGameObject *obj, float dt)
{
timeCounter += dt;
if(timeCounter >= 0.25f)
{
_animation->UpdateAnimation();
timeCounter = 0;
}
if(obj->acc.x == 0 && obj->acc.y == 0)
{
_animation->setKeyFrame(_animation->getKeyFrame());
}
else
if(_oldAcc != obj->acc)
_animation->setKeyFrame(DirectionFrame(obj));
_oldAcc = obj->acc;
}
void PlayerAnimation::Render(iGameObject *obj)
{
_animation->Render(_pos.x,_pos.y);
}
| fenexomega/PokeClone2 | src/game/main/components/PlayerAnimation.cpp | C++ | bsd-2-clause | 1,212 | [
30522,
1001,
2421,
1000,
2447,
7088,
28649,
1012,
1044,
1000,
2447,
7088,
28649,
1024,
1024,
2447,
7088,
28649,
1006,
9207,
2475,
2094,
13433,
2015,
1010,
11867,
17625,
7088,
28649,
1008,
11867,
5794,
2213,
1010,
24582,
25377,
5643,
3372,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.tachys.moneyshare.dataaccess.db.contracts;
import android.provider.BaseColumns;
public class SettlementContract {
public SettlementContract() {
}
public static class SettlementEntry implements BaseColumns {
public static final String TABLE_NAME = "settlement";
public static final String COLUMN_NAME_PAYERID = "payer";
public static final String COLUMN_NAME_PAYEEID = "payee";
public static final String COLUMN_NAME_AMOUNT = "amount";
}
}
| StrawHatPirates/MoneyShare | src/app/src/main/java/com/tachys/moneyshare/dataaccess/db/contracts/SettlementContract.java | Java | gpl-2.0 | 502 | [
30522,
7427,
4012,
1012,
11937,
11714,
2015,
1012,
2769,
7377,
2890,
1012,
2951,
6305,
9623,
2015,
1012,
16962,
1012,
8311,
1025,
12324,
11924,
1012,
10802,
1012,
2918,
25778,
2819,
3619,
1025,
2270,
2465,
4093,
8663,
6494,
6593,
1063,
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... |
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _libs = require('../../libs');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Radio = function (_Component) {
_inherits(Radio, _Component);
function Radio(props) {
_classCallCheck(this, Radio);
var _this = _possibleConstructorReturn(this, (Radio.__proto__ || Object.getPrototypeOf(Radio)).call(this, props));
_this.state = {
checked: _this.getChecked(props)
};
return _this;
}
_createClass(Radio, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(props) {
var checked = this.getChecked(props);
if (this.state.checked != checked) {
this.setState({ checked: checked });
}
}
}, {
key: 'onChange',
value: function onChange(e) {
var checked = e.target.checked;
if (checked) {
if (this.props.onChange) {
if (this.props.hasOwnProperty('model')) {
this.props.onChange(this.props.value);
} else {
this.props.onChange(e);
}
}
}
this.setState({ checked: checked });
}
}, {
key: 'onFocus',
value: function onFocus() {
this.setState({
focus: true
});
}
}, {
key: 'onBlur',
value: function onBlur() {
this.setState({
focus: false
});
}
}, {
key: 'getChecked',
value: function getChecked(props) {
return props.model == props.value || Boolean(props.checked);
}
}, {
key: 'render',
value: function render() {
var checked = this.state.checked;
var _props = this.props,
disabled = _props.disabled,
focus = _props.focus,
value = _props.value,
children = _props.children;
return _react2.default.createElement(
'label',
{ style: this.style(), className: this.className('el-radio') },
_react2.default.createElement(
'span',
{ className: this.classNames({
'el-radio__input': true,
'is-checked': checked,
'is-disabled': disabled,
'is-focus': focus
}) },
_react2.default.createElement('span', { className: 'el-radio__inner' }),
_react2.default.createElement('input', {
type: 'radio',
className: 'el-radio__original',
checked: checked,
disabled: disabled,
onChange: this.onChange.bind(this),
onFocus: this.onFocus.bind(this),
onBlur: this.onBlur.bind(this)
})
),
_react2.default.createElement(
'span',
{ className: 'el-radio__label' },
children || value
)
);
}
}]);
return Radio;
}(_libs.Component);
var _default = Radio;
exports.default = _default;
Radio.propTypes = {
value: _libs.PropTypes.oneOfType([_libs.PropTypes.string, _libs.PropTypes.number]).isRequired,
onChange: _libs.PropTypes.func,
disabled: _libs.PropTypes.bool,
focus: _libs.PropTypes.bool,
/* eslint-disable */
checked: _libs.PropTypes.bool
/* eslint-enable */
};
;
var _temp = function () {
if (typeof __REACT_HOT_LOADER__ === 'undefined') {
return;
}
__REACT_HOT_LOADER__.register(Radio, 'Radio', 'src/radio/Radio.jsx');
__REACT_HOT_LOADER__.register(_default, 'default', 'src/radio/Radio.jsx');
}();
; | allanfish/elementui | dist/npm/src/radio/Radio.js | JavaScript | mit | 5,024 | [
30522,
1005,
2224,
9384,
1005,
1025,
4874,
1012,
9375,
21572,
4842,
3723,
1006,
14338,
1010,
1000,
1035,
1035,
9686,
5302,
8566,
2571,
1000,
1010,
1063,
30524,
1007,
1063,
3853,
9375,
21572,
4842,
7368,
1006,
4539,
1010,
24387,
1007,
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... |
<div id="print_area" style="width:200px; font-size:12px;">
<?php
include('dbcon_s.php');
$date=date('Y-m-d', $time_now);
if($_POST['h_status']=='off')
{
$query=mysql_query("select count(*) as num_order, sum(person) as total_person, sum(order_total) as total_order, sum(discount) as total_discount, sum(ser_charge) as total_s_charge, sum(vat_total) as total_vat, sum(cash) as total_cash, date from order_list where status='false' AND date='$date' AND terminal='".$_POST['terminal']."'");
}
else
{
$query=mysql_query("select count(*) as num_order, sum(person) as total_person, sum(order_total) as total_order, sum(discount) as total_discount, sum(ser_charge) as total_s_charge, sum(vat_total) as total_vat, sum(cash) as total_cash, date from order_list where status='false' AND date='$date' AND terminal='".$_POST['terminal']."'");
}
$row=mysql_fetch_array($query);
?>
<h2 style="text-align:center; font-family:Forte; margin:0px; padding:0px;">La Bamba</h2>
<p style="text-align:center; margin:0px; font-size:12px;">
House # 54, Road # 20,<br />
Sector # 03, Rabindra Sarani<br />
Uttara, Dhaka-1230<br />
Phone : 01759783896-7<br />
Vat Reg No: 5111110711
</p>
<p style="text-align:center; margin:0px; font-size:12px;">
Day Report (<?php echo $_POST['terminal']; ?>)
</p>
Report Date : <?php echo $row['date']; ?><br />
Print Date : <?php echo $date; ?><br />
<table cellspacing="0" style="width:100%; font-size:12px;">
<tr>
<th style="text-align:left">Number of order:</th>
<th style="text-align:left;"><?php echo $row['num_order']; ?></th>
</tr>
<tr>
<th style="text-align:left">Total Person:</th>
<th style="text-align:left;"><?php echo $row['total_person']; ?></th>
</tr>
<tr>
<th style="text-align:left">Total Order:</th>
<th style="text-align:left;"><?php echo $row['total_order']; ?></th>
</tr>
<tr>
<th style="text-align:left">Total Discount:</th>
<th style="text-align:left;"><?php echo $row['total_discount']; ?></th>
</tr>
<tr>
<th style="text-align:left">Total Service Charge:</th>
<th style="text-align:left;"><?php echo $row['total_s_charge']; ?></th>
</tr>
<tr>
<th style="text-align:left">Total Vat:</th>
<th style="text-align:left;"><?php echo $row['total_vat']; ?></th>
</tr>
<tr>
<th style="text-align:left">Total Cash:</th>
<th style="text-align:left;"><?php echo $row['total_cash']; ?></th>
</tr>
</table>
<br />
<div style="border-bottom:1px dotted #000;"></div>
<br />
Day report (<?php echo $_POST['terminal']; ?>) printed by : <?php echo $_POST['user']; ?>
</div>
| DR-PHP666/RMS | print_day_report.php | PHP | apache-2.0 | 3,222 | [
30522,
1026,
4487,
2615,
8909,
1027,
1000,
6140,
1035,
2181,
1000,
2806,
1027,
1000,
9381,
1024,
3263,
2361,
2595,
1025,
15489,
1011,
2946,
1024,
2260,
2361,
2595,
1025,
1000,
1028,
1026,
1029,
25718,
2421,
1006,
1005,
16962,
8663,
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... |
/*!
* jQuery UI Effects Fold 1.11.2
* http://jqueryui.com
*
* Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/fold-effect/
*/(function(e){typeof define=="function"&&define.amd?define(["jquery","./effect"],e):e(jQuery)})(function(e){return e.effects.effect.fold=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=s==="hide",a=t.size||15,f=/([0-9]+)%/.exec(a),l=!!t.horizFirst,c=o!==l,h=c?["width","height"]:["height","width"],p=t.duration/2,d,v,m={},g={};e.effects.save(r,i),r.show(),d=e.effects.createWrapper(r).css({overflow:"hidden"}),v=c?[d.width(),d.height()]:[d.height(),d.width()],f&&(a=parseInt(f[1],10)/100*v[u?0:1]),o&&d.css(l?{height:0,width:a}:{height:a,width:0}),m[h[0]]=o?v[0]:a,g[h[1]]=o?v[1]:0,d.animate(m,p,t.easing).animate(g,p,t.easing,function(){u&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()})}}); | Nikola-xiii/d8intranet | drupal/core/assets/vendor/jquery.ui/ui/effect-fold-min.js | JavaScript | gpl-2.0 | 1,035 | [
30522,
1013,
1008,
999,
1008,
1046,
4226,
2854,
21318,
3896,
10671,
1015,
1012,
2340,
1012,
1016,
1008,
8299,
1024,
1013,
1013,
1046,
4226,
2854,
10179,
1012,
4012,
1008,
1008,
9385,
2297,
1046,
4226,
2854,
3192,
1998,
2060,
16884,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
elgg_load_js('fullcalendar');
elgg_load_css("fullcalendar_css");
elgg_load_js("reveal2");
elgg_load_css('reveal');
$entity = $vars['entity'];
$json_data = elgg_get_json_eventos_entity($entity);
?>
<script>
$(document).ready(function() {
$('#info-evento').hide(), $('#calendar').fullCalendar({
height: 450,
width: 500,
events:
<?php echo $json_data ?>,
eventClick: function(calEvent, jsEvent, view) {
pintarEvento(calEvent.id, jsEvent);
}
});
});
function pintarEvento(id, jsEvent) {
var modalLocation = "myModalEv";
$('#' + modalLocation).reveal($(this).data());
elgg.get('ajax/view/eventos/calendario/ver_evento', {
timeout: 30000,
data: {
guid_evento: id,
},
success: function(result, success, xhr) {
$('#ver-info-evento').html(result);
},
});
}
</script>
<div id="myModalEv" class="reveal-modal">
<div class="close-reveal-modal"></div>
<div class="pop-up-calendar pop-up">
<div id='ver-info-evento'></div>
</div>
</div>
<div class='box contet-grupo-investigacion'><div class='padding20'>
<?php echo $breadcrumbs . $header ?>
<div id='calendar'>
</div>
<div id='info-evento'>
</div>
</div></div>
| jonreycas/enjambre | mod/eventos/views/default/eventos/calendario/ver_calendario.php | PHP | gpl-2.0 | 1,499 | [
30522,
1026,
1029,
25718,
3449,
13871,
1035,
7170,
1035,
1046,
2015,
1006,
1005,
2440,
9289,
10497,
2906,
1005,
1007,
1025,
3449,
13871,
1035,
7170,
1035,
20116,
2015,
1006,
1000,
2440,
9289,
10497,
2906,
1035,
20116,
2015,
1000,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
---
layout: post
title: 随手记
subtitle: Project 729
header-img: ""
categories: [blog ]
tags: [project,learn ]
---
## 转换时间字符串为数字时间戳
import datetime,time
dt = datetime.datetime.strptime('2010-01-01 18','%Y-%m-%d %H')
输出:datetime.datetime(2010, 1, 1, 18, 0)
time_tuple = dt.timetuple()
ts = time.mktime(time_tuple)
ts
输出:1262340000.0
## 这条排序没看懂
sims=sorted(enumerate(sims),key=lambda item: item[1],reverse=True)
D3.js
## pandoc
pandoc可以很方便的转换文档格式,但是不知为何,“doc/SL331C-A-01.docx”文件转换时会丢失数字和字母数据。
## pickle
使用pickle永久保存变量内容。
## flask-wtf
Filefield的使用没搞懂,只能读取一个上传文件名,而且没有方法获取绝对/相对文件路径,或者存储数据。。。这要怎么处理??????!!!!!
## markdown
markdown可以兼容html | KevinBean/KevinBean.github.io | _posts/2016-07-29-Project729-notebook.md | Markdown | apache-2.0 | 951 | [
30522,
1011,
1011,
1011,
9621,
1024,
2695,
2516,
1024,
100,
1858,
100,
4942,
3775,
9286,
1024,
2622,
5824,
2683,
20346,
1011,
10047,
2290,
1024,
1000,
1000,
7236,
1024,
1031,
9927,
1033,
22073,
1024,
1031,
2622,
1010,
4553,
1033,
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... |
StockPredict
============
Predict stock market prices based on discovered patterns
| ozzioma/StockPredict | README.md | Markdown | mit | 84 | [
30522,
4518,
28139,
29201,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
16014,
4518,
3006,
7597,
2241,
2006,
3603,
7060,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* bzflag
* Copyright (c) 1993-2012 Tim Riker
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* BillboardSceneNode:
* Encapsulates information for rendering a textured billboard.
*/
#ifndef BZF_BILLBOARD_SCENE_NODE_H
#define BZF_BILLBOARD_SCENE_NODE_H
#include "common.h"
#include "SceneNode.h"
#include "OpenGLLight.h"
class BillboardSceneNode : public SceneNode {
public:
BillboardSceneNode(const GLfloat pos[3]);
~BillboardSceneNode();
virtual BillboardSceneNode* copy() const;
void setLoop(bool = true);
void setDuration(float);
void resetTime();
void updateTime(float dt);
bool isAtEnd() const;
bool isLight() const;
void setLight(bool = true);
void setLightColor(GLfloat r, GLfloat g, GLfloat b);
void setLightAttenuation(GLfloat c, GLfloat l, GLfloat q);
void setLightScaling(GLfloat intensityScaleFactor);
void setLightFadeStartTime(float t);
void setGroundLight(bool value);
void setSize(float side);
void setSize(float width, float height);
void setColor(GLfloat r, GLfloat g,
GLfloat b, GLfloat a = 1.0f);
void setColor(const GLfloat* rgba);
void setTexture(const int);
void setTextureAnimation(int cu, int cv);
void move(const GLfloat pos[3]);
void setAngle(GLfloat);
void addLight(SceneRenderer&);
void notifyStyleChange();
void addRenderNodes(SceneRenderer&);
protected:
class BillboardRenderNode : public RenderNode {
public:
BillboardRenderNode(const BillboardSceneNode*);
~BillboardRenderNode();
void setColor(const GLfloat* rgba);
void render();
const GLfloat* getPosition() const { return sceneNode->getSphere(); }
void setFrame(float u, float v);
void setFrameSize(float du, float dv);
private:
const BillboardSceneNode* sceneNode;
float u, v;
GLfloat du, dv;
};
friend class BillboardRenderNode;
void setFrame();
void prepLight();
private:
bool show;
bool hasAlpha;
bool hasTexture;
bool hasTextureAlpha;
bool looping;
bool lightSource;
bool groundLight;
float width, height;
GLfloat color[4];
GLfloat angle;
GLfloat lightColor[3];
GLfloat lightScale;
float lightCutoffTime;
int cu, cv;
float t, duration;
OpenGLLight light;
OpenGLGState gstate;
BillboardRenderNode renderNode;
};
#endif // BZF_BILLBOARD_SCENE_NODE_H
// Local Variables: ***
// mode:C++ ***
// tab-width: 8 ***
// c-basic-offset: 2 ***
// indent-tabs-mode: t ***
// End: ***
// ex: shiftwidth=2 tabstop=8
| SlyMongoose/462Shootout | bzflag-2.4.2/include/BillboardSceneNode.h | C | mit | 2,940 | [
30522,
1013,
1008,
1038,
2480,
10258,
8490,
1008,
9385,
1006,
1039,
1007,
2857,
1011,
2262,
5199,
15544,
5484,
1008,
1008,
2023,
7427,
2003,
2489,
4007,
1025,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
1008,
19933,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
make gio_rev03_defconfig
make
| psyke83/kernel_samsung_gio2europa | make_kernel_GT-S5660.sh | Shell | gpl-2.0 | 30 | [
30522,
2191,
21025,
2080,
1035,
7065,
2692,
2509,
1035,
13366,
8663,
8873,
2290,
2191,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/bash
# Script to query the wiki pages name for Helm completion source
# swivt:wikiPageModificationDate swivt:wikiPageSortKey
# TODO: error handling is bad
#set -x
QUERY=$(cat<<EOF
select *
from <virtual://mediawiki> {
?page a mw:Page ;
mw:pageNamespaceId ?nsid ;
mw:pageTitle ?title ;
mw:pageUrl ?url ;
mw:pageLatestRev ?latestRev ;
# TODO : improve this, remove magic constants
# skip 6 (file pages) and 102 (something from SemanticMediaWiki)
# c.f. namespaces in LocalSettings.php
FILTER(?nsid IN (0, 2, 14, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107))
} order by desc(?latestRev) limit 9999
EOF
)
#echo "$QUERY"
echo '`(' ; \
curl -u admin:admin -H "Accept: application/sparql-results+json" -G https://localhost/stardog/bs/query \
--data-urlencode query="$QUERY" 2> /dev/null \
| jq -r '.results.bindings[] | @text "((title . \"\(.title.value)\") (url . \"\(.url.value)\"))"' \
; echo ")"
# Output is something like
# {
# "head" : {
# "vars" : [
# "page",
# "title",
# "url",
# "f"
# ]
# },
# "results" : {
# "bindings" : [
# {
# "page" : {
# "type" : "uri",
# "value" : "http://localhost/mediawiki/index.php/Special:URIResolver/TestSMW"
# },
# "title" : {
# "type" : "literal",
# "value" : "TestSMW"
# },
# "url" : {
# "type" : "uri",
# "value" : "https://localhost/mediawiki/index.php/TestSMW"
# }
# },
# {
# "page" : {
# "type" : "uri",
# "value" : "http://localhost/mediawiki/index.php/Special:URIResolver/XXX"
# },
# "title" : {
# "type" : "literal",
# "value" : "XXX"
# },
# "url" : {
# "type" : "uri",
# "value" : "https://localhost/mediawiki/index.php/XXX"
# }
# }
# ]
# }
# }
| jbalint/banshee-sympatico | percy/percy-wiki-pages.sh | Shell | mit | 1,958 | [
30522,
1001,
999,
1013,
8026,
1013,
24234,
1001,
5896,
2000,
23032,
1996,
15536,
3211,
5530,
2171,
2005,
16254,
6503,
3120,
1001,
25430,
12848,
2102,
1024,
15536,
3211,
13704,
5302,
4305,
10803,
13701,
25430,
12848,
2102,
1024,
15536,
3211,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.ode.bpel.engine;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.wsdl.OperationType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.ode.bpel.common.CorrelationKeySet;
import org.apache.ode.bpel.runtime.PartnerLinkInstance;
import org.apache.ode.bpel.runtime.Selector;
import org.apache.ode.utils.ObjectPrinter;
/**
* <p>
* This class handles behaviour of IMAs (Inbound Message Activities) as specified in WS BPEL.
* This includes detecting conflictingReceive and conflictingRequest faults.
* </p>
*/
public class IMAManager2 implements Serializable {
private static final long serialVersionUID = -5556374398943757951L;
private static final Logger __log = LoggerFactory.getLogger(IMAManager2.class);
// holds rid for registered IMAs
public final Map<RequestIdTuple, Entry> _byRid = new HashMap<RequestIdTuple, Entry>();
// holds outstanding rid that are now waiting to reply (Open IMAs)
public final Map<OutstandingRequestIdTuple, String> _byOrid = new HashMap<OutstandingRequestIdTuple, String>();
public final Map<String, Entry> _byChannel = new HashMap<String, Entry>();
/**
* finds conflictingReceive
*
* @param selectors
* @return
*/
int findConflict(Selector selectors[]) {
if (__log.isTraceEnabled()) {
__log.trace(ObjectPrinter.stringifyMethodEnter("findConflict", new Object[] { "selectors", selectors }));
}
Set<RequestIdTuple> workingSet = new HashSet<RequestIdTuple>(_byRid.keySet());
for (int i = 0; i < selectors.length; ++i) {
final RequestIdTuple rid = new RequestIdTuple(selectors[i].plinkInstance, selectors[i].opName, selectors[i].correlationKeySet);
if (workingSet.contains(rid)) {
return i;
}
workingSet.add(rid);
}
return -1;
}
/**
* Register IMA
*
* @param pickResponseChannel
* response channel associated with this receive/pick
* @param selectors
* selectors for this receive/pick
*/
void register(String pickResponseChannel, Selector selectors[]) {
if (__log.isTraceEnabled()) {
__log.trace(ObjectPrinter.stringifyMethodEnter("register", new Object[] { "pickResponseChannel", pickResponseChannel, "selectors", selectors }));
}
if (_byChannel.containsKey(pickResponseChannel)) {
String errmsg = "INTERNAL ERROR: Duplicate ENTRY for RESPONSE CHANNEL " + pickResponseChannel;
__log.error(errmsg);
throw new IllegalArgumentException(errmsg);
}
Entry entry = new Entry(pickResponseChannel, selectors);
for (int i = 0; i < selectors.length; ++i) {
final RequestIdTuple rid = new RequestIdTuple(selectors[i].plinkInstance, selectors[i].opName, selectors[i].correlationKeySet);
if (_byRid.containsKey(rid)) {
String errmsg = "INTERNAL ERROR: Duplicate ENTRY for RID " + rid;
__log.error(errmsg);
throw new IllegalStateException(errmsg);
}
_byRid.put(rid, entry);
}
_byChannel.put(pickResponseChannel, entry);
}
/**
* Registers Open IMA.
* It doesn't open IMA for non two way operations.
*
* @param partnerLink
* @param opName
* @param mexId
* @param mexRef
* @return
*/
String processOutstandingRequest(PartnerLinkInstance partnerLink, String opName, String mexId, String mexRef) {
if (__log.isTraceEnabled()) {
__log.trace(ObjectPrinter.stringifyMethodEnter("process", new Object[] { "partnerLinkInstance", partnerLink, "operationName", opName, "messageExchangeId", mexId, "mexRef", mexRef }));
}
final OutstandingRequestIdTuple orid = new OutstandingRequestIdTuple(partnerLink, opName, mexId);
if (_byOrid.containsKey(orid)) {
//conflictingRequest found
return mexRef;
}
// We convert into outstanding request only for in-out operations (pending release operation)
if (partnerLink.partnerLink.getMyRoleOperation(opName).getStyle().equals(OperationType.REQUEST_RESPONSE)) {
_byOrid.put(orid, mexRef);
}
return null;
}
/**
* This is used to remove IMA from registered state.
*
* @see #register(String, Selector[])
* @param pickResponseChannel
*/
void cancel(String pickResponseChannel, boolean isTimer) {
if (__log.isTraceEnabled())
__log.trace(ObjectPrinter.stringifyMethodEnter("cancel", new Object[] { "pickResponseChannel", pickResponseChannel }));
Entry entry = _byChannel.remove(pickResponseChannel);
if (entry != null) {
while (_byRid.values().remove(entry));
} else if (!isTimer){
String errmsg = "INTERNAL ERROR: No ENTRY for RESPONSE CHANNEL " + pickResponseChannel;
__log.error(errmsg);
throw new IllegalArgumentException(errmsg);
}
}
/**
* Release Open IMA.
*
* @param plinkInstnace
* partner link
* @param opName
* operation
* @param mexId
* message exchange identifier IN THE BPEL SENSE OF THE TERM (i.e. a receive/reply disambiguator).
* @return message exchange identifier associated with the registration that matches the parameters
*/
public String release(PartnerLinkInstance plinkInstnace, String opName, String mexId) {
if (__log.isTraceEnabled())
__log.trace(ObjectPrinter.stringifyMethodEnter("release", new Object[] { "plinkInstance", plinkInstnace, "opName", opName, "mexId", mexId }));
final OutstandingRequestIdTuple orid = new OutstandingRequestIdTuple(plinkInstnace, opName, mexId);
String mexRef = _byOrid.remove(orid);
if (mexRef == null) {
if (__log.isDebugEnabled()) {
__log.debug("==release: ORID " + orid + " not found in " + _byOrid);
}
return null;
}
return mexRef;
}
/**
* "Release" all Open IMAs
*
* @return a list of message exchange identifiers for message exchanges that were begun (receive/pick got a message) but not yet completed (reply not yet sent)
*/
public String[] releaseAll() {
if (__log.isTraceEnabled())
__log.trace(ObjectPrinter.stringifyMethodEnter("releaseAll", null));
ArrayList<String> mexRefs = new ArrayList<String>();
while (!_byOrid.isEmpty()) {
String mexRef = _byOrid.entrySet().iterator().next().getValue();
mexRefs.add(mexRef);
_byOrid.values().remove(mexRef);
}
return mexRefs.toArray(new String[mexRefs.size()]);
}
public String toString() {
return ObjectPrinter.toString(this, new Object[] { "byRid", _byRid, "byOrid", _byOrid, "byChannel", _byChannel });
}
public static class RequestIdTuple implements Serializable {
private static final long serialVersionUID = -1059389611839777482L;
/** On which partner link it was received. */
PartnerLinkInstance partnerLink;
/** Name of the operation. */
String opName;
/** cset */
CorrelationKeySet ckeySet;
/** Constructor. */
RequestIdTuple(PartnerLinkInstance partnerLink, String opName, CorrelationKeySet ckeySet) {
this.partnerLink = partnerLink;
this.opName = opName;
this.ckeySet = ckeySet;
}
public String toString() {
return ObjectPrinter.toString(this, new Object[] { "partnerLink", partnerLink, "opName", opName, "cSet", ckeySet});
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((ckeySet == null) ? 0 : ckeySet.hashCode());
result = prime * result
+ ((opName == null) ? 0 : opName.hashCode());
result = prime * result
+ ((partnerLink == null) ? 0 : partnerLink.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof RequestIdTuple)) {
return false;
}
RequestIdTuple other = (RequestIdTuple) obj;
if (ckeySet == null) {
if (other.ckeySet != null) {
return false;
}
} else if (!ckeySet.equals(other.ckeySet)) {
return false;
}
if (opName == null) {
if (other.opName != null) {
return false;
}
} else if (!opName.equals(other.opName)) {
return false;
}
if (partnerLink == null) {
if (other.partnerLink != null) {
return false;
}
} else if (!partnerLink.equals(other.partnerLink)) {
return false;
}
return true;
}
}
public static class OutstandingRequestIdTuple implements Serializable {
private static final long serialVersionUID = -1059389611839777482L;
/** On which partner link it was received. */
PartnerLinkInstance partnerLink;
/** Name of the operation. */
String opName;
/** Message exchange identifier. */
String mexId;
/** Constructor. */
OutstandingRequestIdTuple(PartnerLinkInstance partnerLink, String opName, String mexId) {
this.partnerLink = partnerLink;
this.opName = opName;
this.mexId = mexId == null ? "" : mexId;
}
public int hashCode() {
return this.partnerLink.hashCode() ^ this.opName.hashCode() ^ this.mexId.hashCode();
}
public boolean equals(Object obj) {
OutstandingRequestIdTuple other = (OutstandingRequestIdTuple) obj;
return other.partnerLink.equals(partnerLink) && other.opName.equals(opName) && other.mexId.equals(mexId);
}
public String toString() {
return ObjectPrinter.toString(this, new Object[] { "partnerLink", partnerLink, "opName", opName, "mexId", mexId });
}
}
public static class Entry implements Serializable {
private static final long serialVersionUID = -583743124656582887L;
final String pickResponseChannel;
public Selector[] selectors;
Entry(String pickResponseChannel, Selector[] selectors) {
this.pickResponseChannel = pickResponseChannel;
this.selectors = selectors;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime
* result
+ ((pickResponseChannel == null) ? 0 : pickResponseChannel
.hashCode());
result = prime * result + Arrays.hashCode(selectors);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Entry other = (Entry) obj;
if (pickResponseChannel == null) {
if (other.pickResponseChannel != null)
return false;
} else if (!pickResponseChannel.equals(other.pickResponseChannel))
return false;
if (!Arrays.equals(selectors, other.selectors))
return false;
return true;
}
public String toString() {
return ObjectPrinter.toString(this, new Object[] { "pickResponseChannel", pickResponseChannel, "selectors", selectors });
}
}
}
| Subasinghe/ode | bpel-runtime/src/main/java/org/apache/ode/bpel/engine/IMAManager2.java | Java | apache-2.0 | 13,206 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
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... |
using Chloe.DbExpressions;
using Chloe.RDBMS;
namespace Chloe.PostgreSQL.MethodHandlers
{
class Trim_Handler : IMethodHandler
{
public bool CanProcess(DbMethodCallExpression exp)
{
if (exp.Method != PublicConstants.MethodInfo_String_Trim)
return false;
return true;
}
public void Process(DbMethodCallExpression exp, SqlGeneratorBase generator)
{
generator.SqlBuilder.Append("RTRIM(LTRIM(");
exp.Object.Accept(generator);
generator.SqlBuilder.Append("))");
}
}
}
| shuxinqin/Chloe | src/Chloe.PostgreSQL/MethodHandlers/Trim_Handler.cs | C# | mit | 603 | [
30522,
2478,
9318,
1012,
16962,
10288,
20110,
8496,
1025,
2478,
9318,
1012,
16428,
25526,
2015,
1025,
3415,
15327,
9318,
1012,
2695,
17603,
2015,
4160,
2140,
1012,
4118,
11774,
12910,
1063,
2465,
12241,
1035,
28213,
1024,
10047,
11031,
7716,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 br.nom.strey.maicon.loterias.quina;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.Toast;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
import br.nom.strey.maicon.loterias.R;
import br.nom.strey.maicon.loterias.main.Categories;
import br.nom.strey.maicon.loterias.main.LoteriaDetailActivity;
import br.nom.strey.maicon.loterias.utils.DBHelper;
import br.nom.strey.maicon.loterias.utils.WebService;
public class QuinaListFragment extends Fragment {
private static final String LOGTAG = "MegaListFragment";
private View rootView = null;
private ListView listView_volantes = null;
private Context ctx;
private List<QuinaVolantesVO> listQuinaVolantes;
private QuinaVolantesDAO dao_volantes;
private QuinaVolantesAdapter adapter_volantes;
private MenuItem refresh;
private Menu menu;
private static Integer concurso_max_remote_resultados;
private static final String MAX_CONCURSO = "max_conc";
public QuinaListFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(LOGTAG, "onCreate");
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
new CheckVolantesResultado().execute();
getActivity().getActionBar().setTitle(getString(R.string.action_megasena_header_list));
ctx = getActivity().getBaseContext();
rootView = inflater.inflate(R.layout.fragment_quina_list, container, false);
refresh = menu.findItem(R.id.action_update);
listView_volantes = (ListView) rootView.findViewById(R.id.lv_volantes);
dao_volantes = new QuinaVolantesDAO(ctx);
listQuinaVolantes = dao_volantes.getAll();
adapter_volantes = new QuinaVolantesAdapter(getActivity(), listQuinaVolantes, false);
listView_volantes.setAdapter(adapter_volantes);
listView_volantes.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
return rootView;
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
ctx = getActivity().getBaseContext();
refresh = menu.findItem(R.id.action_update);
QuinaVolantesDAO dao_volantes = new QuinaVolantesDAO(ctx);
if (dao_volantes.getAll().isEmpty()) {
refresh.setVisible(false);
}
// backUpDB();
super.onPrepareOptionsMenu(menu);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
this.menu = menu;
menu.clear();
menuInflater = getActivity().getMenuInflater();
menuInflater.inflate(R.menu.action_lista, menu);
super.onCreateOptionsMenu(menu, menuInflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_incluir:
((LoteriaDetailActivity) getActivity()).editQuinaFragment();
return true;
case R.id.action_update:
new CheckVolantesResultado().execute();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void refreshVolantesList(Boolean exibe_acertos) {
listQuinaVolantes = dao_volantes.getAll();
adapter_volantes = new QuinaVolantesAdapter(getActivity(), listQuinaVolantes, exibe_acertos);
listView_volantes.setAdapter(adapter_volantes);
adapter_volantes.notifyDataSetChanged();
if (listQuinaVolantes.size() > 0) {
refresh.setVisible(true);
} else {
refresh.setVisible(false);
}
}
private void backUpDB() {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//br.nom.strey.maicon.loterias//databases//" + DBHelper.DBNAME;
String backupDBPath = "//data//" + DBHelper.DBNAME;
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
if (currentDB.exists()) {
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
Toast.makeText(ctx, "Backup Efetuado", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(ctx, "Base de origem não localizada: " + currentDBPath, Toast.LENGTH_LONG).show();
}
} else {
Toast.makeText(ctx, "Sem permissão de escrita no SDCARD", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
}
}
private class CheckVolantesResultado extends AsyncTask<Void, Void, Void> {
public CheckVolantesResultado() {
}
@Override
protected void onPreExecute() {
if (refresh != null) {
refresh.setActionView(R.layout.actionbar_indeterminate_progress);
}
super.onPreExecute();
}
@Override
protected void onPostExecute(Void aVoid) {
if (refresh != null) {
refresh.setActionView(null);
}
refreshVolantesList(true);
super.onPostExecute(aVoid);
}
@Override
protected Void doInBackground(Void... voids) {
QuinaVolantesDAO dao_volantes = new QuinaVolantesDAO(ctx);
List<QuinaVolantesVO> volantes_para_conferir = dao_volantes.getAll();
ArrayList<Integer> concursos_para_conferir = dao_volantes.getConcursosParaConferir();
QuinaResultadosDAO dao_resultado = new QuinaResultadosDAO(ctx);
if (!concursos_para_conferir.isEmpty()) {
for (Integer concurso : concursos_para_conferir) {
if (!dao_resultado.existeResultado(concurso)) {
if (WebService.isConnected(ctx) != WebService.DISCONNECTED) {
StringBuffer strUrl = new StringBuffer("http://maicon.strey.nom.br/");
strUrl.append("loto/");
strUrl.append("getResults.php");
strUrl.append("?loto=");
strUrl.append(URLEncoder.encode(Categories.QUINA));
strUrl.append("&concurso=");
strUrl.append(concurso);
try {
URL url = new URL(strUrl.toString());
URLConnection con = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String str_json = in.readLine();
Log.d(LOGTAG, "str_json: " + str_json);
JSONObject obj_json = new JSONObject(str_json);
if (concurso > 0) {
QuinaResultadosVO vo_resultado = new QuinaResultadosVO();
vo_resultado.setJson(obj_json);
if (dao_resultado.existe(vo_resultado.getConcurso())) {
dao_resultado.update(vo_resultado);
} else {
dao_resultado.insert(vo_resultado);
}
} else {
concurso_max_remote_resultados = obj_json.getInt(MAX_CONCURSO);
Log.d(LOGTAG, MAX_CONCURSO + "_remote: " + concurso_max_remote_resultados);
}
} catch (Exception e) {
concurso_max_remote_resultados = 1;
e.printStackTrace();
}
} else {
Toast.makeText(ctx, getString(R.string.conexao_nao_identificada), Toast.LENGTH_LONG).show();
}
}
}
for (QuinaVolantesVO vo_volante : volantes_para_conferir) {
vo_volante.confereResultado(ctx);
dao_volantes = new QuinaVolantesDAO(ctx);
dao_volantes.update(vo_volante);
}
}
// backUpDB();
return null;
}
}
}
| mstrey/lotoNaMao | mobile/Loterias/src/main/java/br/nom/strey/maicon/loterias/quina/QuinaListFragment.java | Java | gpl-3.0 | 9,626 | [
30522,
7427,
7987,
1012,
2053,
2213,
1012,
2358,
15202,
1012,
14736,
8663,
1012,
2843,
11610,
2015,
1012,
21864,
2532,
1025,
12324,
11924,
1012,
4180,
1012,
6123,
1025,
12324,
11924,
1012,
9808,
1012,
2004,
6038,
25572,
6711,
1025,
12324,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="ApiGen 2.8.0" />
<title>Overview</title>
<script type="text/javascript" src="resources/combined.js"></script>
<script type="text/javascript" src="elementlist.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="resources/style.css?3505392360" />
</head>
<body>
<h3><a href="../../../../public">Retournez au site</a></h3>
<div id="left">
<div id="menu">
<span>Overview</span>
<div id="groups">
</div>
<div id="elements">
<h3>Functions</h3>
<ul>
<li><a href="function-afficher_resto.html">afficher_resto</a></li>
<li><a href="function-afficher_users.html" class="invalid">afficher_users</a></li>
<li><a href="function-insert_horraire_resto.html">insert_horraire_resto</a></li>
<li><a href="function-insert_notif.html">insert_notif</a></li>
<li><a href="function-insert_resto.html">insert_resto</a></li>
<li><a href="function-insert_users.html">insert_users</a></li>
<li><a href="function-insert_users_pro.html">insert_users_pro</a></li>
<li><a href="function-new_restaurant.html">new_restaurant</a></li>
<li><a href="function-supp_horraire_resto.html">supp_horraire_resto</a></li>
<li><a href="function-supp_notif_resto.html">supp_notif_resto</a></li>
<li><a href="function-supp_resto.html">supp_resto</a></li>
<li><a href="function-supp_users.html">supp_users</a></li>
<li><a href="function-supp_users_pro.html">supp_users_pro</a></li>
<li><a href="function-update_notifications.html">update_notifications</a></li>
<li><a href="function-update_resto.html">update_resto</a></li>
<li><a href="function-verif_count_notif.html">verif_count_notif</a></li>
<li><a href="function-verif_details.html" class="invalid">verif_details</a></li>
<li><a href="function-verif_user.html" class="invalid">verif_user</a></li>
</ul>
</div>
</div>
</div>
<div id="splitter"></div>
<div id="right">
<div id="rightInner">
<form id="search">
<input type="hidden" name="cx" value="" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" class="text" autofocus />
<input type="submit" value="Search" />
</form>
<div id="navigation">
<ul>
<li class="active">
<span>Overview</span> </li>
<li>
<span>Class</span> </li>
</ul>
<ul>
<li>
<a href="tree.html" title="Tree view of classes, interfaces, traits and exceptions"><span>Tree</span></a>
</li>
</ul>
<ul>
</ul>
</div>
<div id="content">
<h1>Overview</h1>
<table class="summary" id="functions">
<caption>Functions summary</caption>
<tr>
<td class="name"><a href="function-afficher_resto.html">afficher_resto</a></td>
<td>
<!-- by Texy2! --></td>
</tr>
<tr>
<td class="name"><a href="function-afficher_users.html" class="invalid">afficher_users</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-insert_horraire_resto.html">insert_horraire_resto</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-insert_notif.html">insert_notif</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-insert_resto.html">insert_resto</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-insert_users.html">insert_users</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-insert_users_pro.html">insert_users_pro</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-new_restaurant.html">new_restaurant</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-supp_horraire_resto.html">supp_horraire_resto</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-supp_notif_resto.html">supp_notif_resto</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-supp_resto.html">supp_resto</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-supp_users.html">supp_users</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-supp_users_pro.html">supp_users_pro</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-update_notifications.html">update_notifications</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-update_resto.html">update_resto</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-verif_count_notif.html">verif_count_notif</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-verif_details.html" class="invalid">verif_details</a></td>
<td></td>
</tr>
<tr>
<td class="name"><a href="function-verif_user.html" class="invalid">verif_user</a></td>
<td></td>
</tr>
</table>
</div>
<div id="footer">
API documentation generated by <a href="http://apigen.org">ApiGen 2.8.0</a>
</div>
</div>
</div>
</body>
</html>
| jordanams/lunchr | lunchr_back-office/app/view/tools/APIGEN_RESULTAT/index.html | HTML | mit | 4,780 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
4180,
1011,
2828,
1000,
4180,
1027,
1000,
3793,
1013,
16129,
1025,
25869,
13462,
1027,
21183,
2546,
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... |
// PART OF THE MACHINE SIMULATION. DO NOT CHANGE.
package nachos.machine;
import nachos.security.*;
import java.io.EOFException;
import java.util.Arrays;
/**
* A <tt>CoffSection</tt> manages a single section within a COFF executable.
*/
public class CoffSection {
/**
* Allocate a new COFF section with the specified parameters.
*
* @param coff the COFF object to which this section belongs.
* @param name the COFF name of this section.
* @param executable <tt>true</tt> if this section contains code.
* @param readOnly <tt>true</tt> if this section is read-only.
* @param numPages the number of virtual pages in this section.
* @param firstVPN the first virtual page number used by this.
*/
protected CoffSection(Coff coff, String name, boolean executable,
boolean readOnly, int numPages, int firstVPN) {
this.coff = coff;
this.name = name;
this.executable = executable;
this.readOnly = readOnly;
this.numPages = numPages;
this.firstVPN = firstVPN;
file = null;
size = 0;
contentOffset = 0;
initialized = true;
}
/**
* Load a COFF section from an executable.
*
* @param file the file containing the executable.
* @param headerOffset the offset of the section header in the
* executable.
*
* @exception EOFException if an error occurs.
*/
public CoffSection(OpenFile file, Coff coff,
int headerOffset) throws EOFException {
this.file = file;
this.coff = coff;
Lib.assertTrue(headerOffset >= 0);
if (headerOffset+headerLength > file.length()) {
Lib.debug(dbgCoffSection, "\tsection header truncated");
throw new EOFException();
}
byte[] buf = new byte[headerLength];
Lib.strictReadFile(file, headerOffset, buf, 0, headerLength);
name = Lib.bytesToString(buf, 0, 8);
int vaddr = Lib.bytesToInt(buf, 12);
size = Lib.bytesToInt(buf, 16);
contentOffset = Lib.bytesToInt(buf, 20);
int numRelocations = Lib.bytesToUnsignedShort(buf, 32);
int flags = Lib.bytesToInt(buf, 36);
if (numRelocations != 0) {
Lib.debug(dbgCoffSection, "\tsection needs relocation");
throw new EOFException();
}
switch (flags & 0x0FFF) {
case 0x0020:
executable = true;
readOnly = true;
initialized = true;
break;
case 0x0040:
executable = false;
readOnly = false;
initialized = true;
break;
case 0x0080:
executable = false;
readOnly = false;
initialized = false;
break;
case 0x0100:
executable = false;
readOnly = true;
initialized = true;
break;
default:
Lib.debug(dbgCoffSection, "\tinvalid section flags: " + flags);
throw new EOFException();
}
if (vaddr%Processor.pageSize != 0 || size < 0 ||
initialized && (contentOffset < 0 ||
contentOffset+size > file.length())) {
Lib.debug(dbgCoffSection, "\tinvalid section addresses: " +
"vaddr=" + vaddr + " size=" + size +
" contentOffset=" + contentOffset);
throw new EOFException();
}
numPages = Lib.divRoundUp(size, Processor.pageSize);
firstVPN = vaddr / Processor.pageSize;
}
/**
* Return the COFF object used to load this executable instance.
*
* @return the COFF object corresponding to this section.
*/
public Coff getCoff() {
return coff;
}
/**
* Return the name of this section.
*
* @return the name of this section.
*/
public String getName() {
return name;
}
/**
* Test whether this section is read-only.
*
* @return <tt>true</tt> if this section should never be written.
*/
public boolean isReadOnly() {
return readOnly;
}
/**
* Test whether this section is initialized. Loading a page from an
* initialized section requires a disk access, while loading a page from an
* uninitialized section requires only zero-filling the page.
*
* @return <tt>true</tt> if this section contains initialized data in the
* executable.
*/
public boolean isInitialzed() {
return initialized;
}
/**
* Return the length of this section in pages.
*
* @return the number of pages in this section.
*/
public int getLength() {
return numPages;
}
/**
* Return the first virtual page number used by this section.
*
* @return the first virtual page number used by this section.
*/
public int getFirstVPN() {
return firstVPN;
}
/**
* Load a page from this segment into physical memory.
*
* @param spn the page number within this segment.
* @param ppn the physical page to load into.
*/
public void loadPage(int spn, int ppn) {
Lib.assertTrue(file != null);
Lib.assertTrue(spn>=0 && spn<numPages);
Lib.assertTrue(ppn>=0 && ppn<Machine.processor().getNumPhysPages());
int pageSize = Processor.pageSize;
byte[] memory = Machine.processor().getMemory();
int paddr = ppn*pageSize;
int faddr = contentOffset + spn*pageSize;
int initlen;
if (!initialized)
initlen = 0;
else if (spn == numPages-1)
initlen = size % pageSize;
else
initlen = pageSize;
if (initlen > 0)
Lib.strictReadFile(file, faddr, memory, paddr, initlen);
Arrays.fill(memory, paddr+initlen, paddr+pageSize, (byte) 0);
}
/** The COFF object to which this section belongs. */
protected Coff coff;
/** The COFF name of this section. */
protected String name;
/** True if this section contains code. */
protected boolean executable;
/** True if this section is read-only. */
protected boolean readOnly;
/** True if this section contains initialized data. */
protected boolean initialized;
/** The number of virtual pages in this section. */
protected int numPages;
/** The first virtual page number used by this section. */
protected int firstVPN;
private OpenFile file;
private int contentOffset, size;
/** The length of a COFF section header. */
public static final int headerLength = 40;
private static final char dbgCoffSection = 'c';
}
| VictoriaLacroix/operating-system | nachos/machine/CoffSection.java | Java | gpl-2.0 | 6,104 | [
30522,
1013,
1013,
2112,
1997,
1996,
3698,
12504,
1012,
2079,
2025,
2689,
1012,
7427,
6583,
9905,
2015,
1012,
3698,
1025,
12324,
6583,
9905,
2015,
1012,
3036,
1012,
1008,
1025,
12324,
9262,
1012,
22834,
1012,
1041,
11253,
10288,
24422,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
namespace DD.Cloud.WebApi.TemplateToolkit
{
/// <summary>
/// Factory methods for creating value providers.
/// </summary>
/// <typeparam name="TContext">
/// The type used as a context for each request.
/// </typeparam>
public static class ValueProvider<TContext>
{
/// <summary>
/// Create a value provider from the specified selector function.
/// </summary>
/// <typeparam name="TValue">
/// The type of value returned by the selector.
/// </typeparam>
/// <param name="selector">
/// A selector function that, when given an instance of <typeparamref name="TContext"/>, and returns a well-known value of type <typeparamref name="TValue"/> derived from the context.
/// </param>
/// <returns>
/// The value provider.
/// </returns>
public static IValueProvider<TContext, TValue> FromSelector<TValue>(Func<TContext, TValue> selector)
{
if (selector == null)
throw new ArgumentNullException("selector");
return new SelectorValueProvider<TValue>(selector);
}
/// <summary>
/// Create a value provider from the specified function.
/// </summary>
/// <typeparam name="TValue">
/// The type of value returned by the function.
/// </typeparam>
/// <param name="getValue">
/// A function that returns a well-known value of type <typeparamref name="TValue"/>.
/// </param>
/// <returns>
/// The value provider.
/// </returns>
public static IValueProvider<TContext, TValue> FromFunction<TValue>(Func<TValue> getValue)
{
if (getValue == null)
throw new ArgumentNullException("getValue");
return new FunctionValueProvider<TValue>(getValue);
}
/// <summary>
/// Create a value provider from the specified constant value.
/// </summary>
/// <typeparam name="TValue">
/// The type of value returned by the provider.
/// </typeparam>
/// <param name="value">
/// A constant value that is returned by the provider.
/// </param>
/// <returns>
/// The value provider.
/// </returns>
public static IValueProvider<TContext, TValue> FromConstantValue<TValue>(TValue value)
{
if (value == null)
throw new ArgumentNullException("value");
return new ConstantValueProvider<TValue>(value);
}
/// <summary>
/// Value provider that invokes a selector function on the context to extract its value.
/// </summary>
/// <typeparam name="TValue">
/// The type of value returned by the provider.
/// </typeparam>
class SelectorValueProvider<TValue>
: IValueProvider<TContext, TValue>
{
/// <summary>
/// The selector function that extracts a value from the context.
/// </summary>
readonly Func<TContext, TValue> _selector;
/// <summary>
/// Create a new selector-based value provider.
/// </summary>
/// <param name="selector">
/// The selector function that extracts a value from the context.
/// </param>
public SelectorValueProvider(Func<TContext, TValue> selector)
{
_selector = selector;
}
/// <summary>
/// Extract the value from the specified context.
/// </summary>
/// <param name="source">
/// The TContext instance from which the value is to be extracted.
/// </param>
/// <returns>
/// The value.
/// </returns>
public TValue Get(TContext source)
{
if (source == null)
throw new InvalidOperationException("The current request template has one more more deferred parameters that refer to its context; the context parameter must therefore be supplied.");
return _selector(source);
}
}
/// <summary>
/// Value provider that invokes a function to extract its value.
/// </summary>
/// <typeparam name="TValue">
/// The type of value returned by the provider.
/// </typeparam>
class FunctionValueProvider<TValue>
: IValueProvider<TContext, TValue>
{
/// <summary>
/// The function that is invoked to provide a value.
/// </summary>
readonly Func<TValue> _getValue;
/// <summary>
/// Create a new function-based value provider.
/// </summary>
/// <param name="getValue">
/// The function that is invoked to provide a value.
/// </param>
public FunctionValueProvider(Func<TValue> getValue)
{
_getValue = getValue;
}
/// <summary>
/// Extract the value from the specified context.
/// </summary>
/// <param name="source">
/// The TContext instance from which the value is to be extracted.
/// </param>
/// <returns>
/// The value.
/// </returns>
public TValue Get(TContext source)
{
if (source == null)
return default(TValue); // AF: Is this correct?
return _getValue();
}
}
/// <summary>
/// Value provider that returns a constant value.
/// </summary>
/// <typeparam name="TValue">
/// The type of value returned by the provider.
/// </typeparam>
class ConstantValueProvider<TValue>
: IValueProvider<TContext, TValue>
{
/// <summary>
/// The constant value returned by the provider.
/// </summary>
readonly TValue _value;
/// <summary>
/// Create a new constant value provider.
/// </summary>
/// <param name="value">
/// The constant value returned by the provider.
/// </param>
public ConstantValueProvider(TValue value)
{
_value = value;
}
/// <summary>
/// Extract the value from the specified context.
/// </summary>
/// <param name="source">
/// The TContext instance from which the value is to be extracted.
/// </param>
/// <returns>
/// The value.
/// </returns>
public TValue Get(TContext source)
{
if (source == null)
return default(TValue); // AF: Is this correct?
return _value;
}
}
}
}
| DimensionDataCBUSydney/Watt | Watt/ValueProvider.cs | C# | mit | 5,719 | [
30522,
2478,
2291,
1025,
3415,
15327,
20315,
1012,
6112,
1012,
4773,
9331,
2072,
1012,
23561,
3406,
4747,
23615,
1063,
1013,
30524,
1013,
1013,
1026,
1013,
12654,
1028,
1013,
1013,
1013,
1026,
2828,
28689,
2213,
2171,
1027,
1000,
22975,
280... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# 2010 Half Dollar
## Kennedy
### Type 1 - Silver
| isaacdagel/numisreg-db | united-states/half-dollars/kennedy/type-1/2010.md | Markdown | cc0-1.0 | 50 | [
30522,
1001,
2230,
2431,
7922,
1001,
1001,
5817,
1001,
1001,
1001,
2828,
1015,
1011,
3165,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package main
import (
"net/http"
"github.com/gorilla/mux"
"github.com/lxc/lxd/lxd/resources"
"github.com/lxc/lxd/lxd/response"
storagePools "github.com/lxc/lxd/lxd/storage"
"github.com/lxc/lxd/shared/api"
)
var api10ResourcesCmd = APIEndpoint{
Path: "resources",
Get: APIEndpointAction{Handler: api10ResourcesGet, AccessHandler: allowAuthenticated},
}
var storagePoolResourcesCmd = APIEndpoint{
Path: "storage-pools/{name}/resources",
Get: APIEndpointAction{Handler: storagePoolResourcesGet, AccessHandler: allowAuthenticated},
}
// /1.0/resources
// Get system resources
func api10ResourcesGet(d *Daemon, r *http.Request) response.Response {
// If a target was specified, forward the request to the relevant node.
resp := forwardedResponseIfTargetIsRemote(d, r)
if resp != nil {
return resp
}
// Get the local resource usage
res, err := resources.GetResources()
if err != nil {
return response.SmartError(err)
}
return response.SyncResponse(true, res)
}
// /1.0/storage-pools/{name}/resources
// Get resources for a specific storage pool
func storagePoolResourcesGet(d *Daemon, r *http.Request) response.Response {
// If a target was specified, forward the request to the relevant node.
resp := forwardedResponseIfTargetIsRemote(d, r)
if resp != nil {
return resp
}
// Get the existing storage pool
poolName := mux.Vars(r)["name"]
var res *api.ResourcesStoragePool
pool, err := storagePools.GetPoolByName(d.State(), poolName)
if err != nil {
return response.InternalError(err)
}
res, err = pool.GetResources()
if err != nil {
return response.InternalError(err)
}
return response.SyncResponse(true, res)
}
| Skarlso/lxd | lxd/resources.go | GO | apache-2.0 | 1,664 | [
30522,
7427,
2364,
12324,
1006,
1000,
5658,
1013,
8299,
1000,
1000,
21025,
2705,
12083,
1012,
4012,
1013,
23526,
1013,
14163,
2595,
1000,
1000,
21025,
2705,
12083,
1012,
4012,
1013,
1048,
2595,
2278,
1013,
1048,
2595,
2094,
1013,
1048,
2595... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hott: Not compatible</title>
<link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" />
<link href="../../../../../bootstrap.min.css" rel="stylesheet">
<link href="../../../../../bootstrap-custom.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<script src="../../../../../moment.min.js"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="../../../../.."><i class="fa fa-lg fa-flag-checkered"></i> Coq bench</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="../..">clean / released</a></li>
<li class="active"><a href="">8.6.1 / hott - 8.11</a></li>
</ul>
</div>
</div>
</div>
<div class="article">
<div class="row">
<div class="col-md-12">
<a href="../..">« Up</a>
<h1>
hott
<small>
8.11
<span class="label label-info">Not compatible</span>
</small>
</h1>
<p><em><script>document.write(moment("2020-06-28 21:12:27 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2020-06-28 21:12:27 UTC)</em><p>
<h2>Context</h2>
<pre># Packages matching: installed
# Name # Installed # Synopsis
base-bigarray base
base-num base Num library distributed with the OCaml compiler
base-threads base
base-unix base
camlp5 7.12 Preprocessor-pretty-printer of OCaml
conf-findutils 1 Virtual package relying on findutils
conf-m4 1 Virtual package relying on m4
coq 8.6.1 Formal proof management system.
num 0 The Num library for arbitrary-precision integer and rational arithmetic
ocaml 4.05.0 The OCaml compiler (virtual package)
ocaml-base-compiler 4.05.0 Official 4.05.0 release
ocaml-config 1 OCaml Switch Configuration
ocamlfind 1.8.1 A library manager for OCaml
# opam file:
opam-version: "2.0"
maintainer: "Jason Gross <jgross@mit.edu>"
homepage: "http://homotopytypetheory.org/"
bug-reports: "https://github.com/HoTT/HoTT/issues"
license: "BSD-2-Clause"
build: [
["bash" "-c" "./autogen.sh -skip-submodules || :"]
["./configure" "COQBIN=%{bin}%" "--prefix=%{prefix}%"]
[make "-j%{jobs}%"]
]
install: [make "install"]
depends: [
"conf-autoconf" {build}
"ocaml"
"ocamlfind" {build}
"coq" {>= "8.11" & < "8.12~"}
]
authors: ["The Coq-HoTT Development Team"]
dev-repo: "git+https://github.com/HoTT/HoTT.git"
synopsis: "The Homotopy Type Theory library"
tags: [ "logpath:HoTT" ]
url {
src: "https://github.com/HoTT/HoTT/archive/V8.11.tar.gz"
checksum: "sha512=b7970162bba57bd5ba31bbe2b493fa72788c5ab9fc23dc961b10396b511fa1baa07543293cb525603add500403ed6b4b1b3807389438d697a0d377375cf3da76"
}
</pre>
<h2>Lint</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Dry install</h2>
<p>Dry install with the current Coq version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam install -y --show-action coq-hott.8.11 coq.8.6.1</code></dd>
<dt>Return code</dt>
<dd>5120</dd>
<dt>Output</dt>
<dd><pre>[NOTE] Package coq is already installed (current version is 8.6.1).
The following dependencies couldn't be met:
- coq-hott -> coq >= 8.11
Your request can't be satisfied:
- No available version of coq satisfies the constraints
No solution found, exiting
</pre></dd>
</dl>
<p>Dry install without Coq/switch base, to test if the problem was incompatibility with the current Coq/OCaml version:</p>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>opam remove -y coq; opam install -y --show-action --unlock-base coq-hott.8.11</code></dd>
<dt>Return code</dt>
<dd>0</dd>
</dl>
<h2>Install dependencies</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Install</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Duration</dt>
<dd>0 s</dd>
</dl>
<h2>Installation size</h2>
<p>No files were installed.</p>
<h2>Uninstall</h2>
<dl class="dl-horizontal">
<dt>Command</dt>
<dd><code>true</code></dd>
<dt>Return code</dt>
<dd>0</dd>
<dt>Missing removes</dt>
<dd>
none
</dd>
<dt>Wrong removes</dt>
<dd>
none
</dd>
</dl>
</div>
</div>
</div>
<hr/>
<div class="footer">
<p class="text-center">
<small>Sources are on <a href="https://github.com/coq-bench">GitHub</a>. © Guillaume Claret.</small>
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="../../../../../bootstrap.min.js"></script>
</body>
</html>
| coq-bench/coq-bench.github.io | clean/Linux-x86_64-4.05.0-2.0.6/released/8.6.1/hott/8.11.html | HTML | mit | 6,817 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
2171,
1027,
1000,
3193,
6442,
1000,
418... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* dmroom.cpp
* Staff functions related to rooms.
* ____ _
* | _ \ ___ __ _| |_ __ ___ ___
* | |_) / _ \/ _` | | '_ ` _ \/ __|
* | _ < __/ (_| | | | | | | \__ \
* |_| \_\___|\__,_|_|_| |_| |_|___/
*
* Permission to use, modify and distribute is granted via the
* GNU Affero General Public License v3 or later
*
* Copyright (C) 2007-2021 Jason Mitchell, Randi Mitchell
* Contributions by Tim Callahan, Jonathan Hseu
* Based on Mordor (C) Brooke Paul, Brett J. Vickers, John P. Freeman
*
*/
#include <dirent.h> // for opendir, readdir, dirent
#include <fmt/format.h> // for format
#include <libxml/parser.h> // for xmlDocSetRootElement
#include <unistd.h> // for unlink
#include <boost/algorithm/string/replace.hpp> // for replace_all
#include <boost/iterator/iterator_traits.hpp> // for iterator_value<>::type
#include <cstdio> // for sprintf
#include <cstdlib> // for atoi, exit
#include <cstring> // for strcmp, strlen, strcpy
#include <ctime> // for time, ctime, time_t
#include <deque> // for _Deque_iterator
#include <iomanip> // for operator<<, setw
#include <iostream> // for operator<<, char_traits
#include <list> // for operator==, list, _Lis...
#include <map> // for operator==, map, map<>...
#include <string> // for string, operator==
#include <string_view> // for operator==, string_view
#include <utility> // for pair
#include "area.hpp" // for Area, MapMarker, AreaZone
#include "async.hpp" // for Async, AsyncExternal
#include "catRef.hpp" // for CatRef
#include "catRefInfo.hpp" // for CatRefInfo
#include "cmd.hpp" // for cmd
#include "commands.hpp" // for getFullstrText, cmdNoAuth
#include "config.hpp" // for Config, gConfig, Deity...
#include "deityData.hpp" // for DeityData
#include "dice.hpp" // for Dice
#include "dm.hpp" // for dmAddMob, dmAddObj
#include "effects.hpp" // for EffectInfo, Effects
#include "factions.hpp" // for Faction
#include "flags.hpp" // for R_TRAINING_ROOM, R_SHO...
#include "free_crt.hpp" // for free_crt
#include "global.hpp" // for CreatureClass, Creatur...
#include "hooks.hpp" // for Hooks
#include "lasttime.hpp" // for crlasttime
#include <libxml/xmlstring.h> // for BAD_CAST
#include "location.hpp" // for Location
#include "monType.hpp" // for getHitdice, getName
#include "money.hpp" // for Money, GOLD
#include "mudObjects/areaRooms.hpp" // for AreaRoom
#include "mudObjects/creatures.hpp" // for Creature
#include "mudObjects/exits.hpp" // for Exit, getDir, getDirName
#include "mudObjects/monsters.hpp" // for Monster
#include "mudObjects/objects.hpp" // for Object
#include "mudObjects/players.hpp" // for Player
#include "mudObjects/rooms.hpp" // for BaseRoom, ExitList
#include "mudObjects/uniqueRooms.hpp" // for UniqueRoom
#include "os.hpp" // for merror
#include "paths.hpp" // for checkDirExists, AreaRoom
#include "proc.hpp" // for ChildType, ChildType::...
#include "property.hpp" // for Property
#include "proto.hpp" // for log_immort, low, needU...
#include "raceData.hpp" // for RaceData
#include "range.hpp" // for Range
#include "server.hpp" // for Server, gServer
#include "size.hpp" // for getSizeName, getSize
#include "startlocs.hpp" // for StartLoc
#include "stats.hpp" // for Stat
#include "swap.hpp" // for SwapRoom
#include "track.hpp" // for Track
#include "traps.hpp" // for TRAP_ACID, TRAP_ALARM
#include "utils.hpp" // for MAX, MIN
#include "wanderInfo.hpp" // for WanderInfo
#include "xml.hpp" // for loadRoom, loadMonster
//*********************************************************************
// checkTeleportRange
//*********************************************************************
void checkTeleportRange(const Player* player, const CatRef& cr) {
// No warning for the test range
if(cr.isArea("test"))
return;
const CatRefInfo* cri = gConfig->getCatRefInfo(cr.area);
if(!cri) {
player->printColor("^yNo CatRefInfo zone found for this room's area. Contact a dungeonmaster to fix this.\n");
return;
}
if(cr.id > cri->getTeleportWeight()) {
player->printColor("^yThis room is outside the CatRefInfo zone's teleport range.\n");
return;
}
}
//*********************************************************************
// isCardinal
//*********************************************************************
bool isCardinal(std::string_view xname) {
return( xname == "north" ||
xname == "east" ||
xname == "south" ||
xname == "west" ||
xname == "northeast" ||
xname == "northwest" ||
xname == "southeast" ||
xname == "southwest"
);
}
//*********************************************************************
// wrapText
//*********************************************************************
std::string wrapText(std::string_view text, int wrap) {
if(text.empty())
return("");
std::string wrapped = "";
int len = text.length(), i=0, sp=0, spLast=0, spLen=0;
char ch, chLast;
// find our starting position
while(text.at(i) == ' ' || text.at(i) == '\n' || text.at(i) == '\r')
i++;
for(; i < len; i++) {
ch = text.at(i);
// convert linebreaks to spaces
if(ch == '\r')
ch = ' ';
if(ch == '\n')
ch = ' ';
// skiping 2x spacing (or greater)
if(ch == ' ' && chLast == ' ') {
do {
i++;
} while(i+1 < len && (text.at(i+1) == ' ' || text.at(i+1) == '\n' || text.at(i+1) == '\r'));
if(i < len)
ch = text.at(i);
}
// don't add trailing spaces
if(ch != ' ' || i+1 < len) {
// If there is color in the room description, the color characters
// shouldn't count toward string length.
if(ch == '^')
spLen += 2;
// wrap
if(ch == ' ') {
// We went over! spLast points to the last non-overboard space.
if(wrap <= (sp - spLen)) {
wrapped.replace(spLast, 1, "\n");
spLen = spLast;
}
spLast = sp;
}
wrapped += ch;
sp++;
chLast = ch;
}
}
return(wrapped);
}
//*********************************************************************
// expand_exit_name
//*********************************************************************
std::string expand_exit_name(const std::string &name) {
if(name == "n")
return("north");
if(name == "s")
return("south");
if(name == "e")
return("east");
if(name == "w")
return("west");
if(name == "sw")
return("southwest");
if(name == "nw")
return("northwest");
if(name == "se")
return("southeast");
if(name == "ne")
return("northeast");
if(name == "d")
return("door");
if(name == "o")
return("out");
if(name == "p")
return("passage");
if(name == "t")
return("trap door");
if(name == "a")
return("arch");
if(name == "g")
return("gate");
if(name == "st")
return("stairs");
return(name);
}
//*********************************************************************
// opposite_exit_name
//*********************************************************************
std::string opposite_exit_name(const std::string &name) {
if(name == "south")
return("north");
if(name == "north")
return("south");
if(name == "west")
return("east");
if(name == "east")
return("west");
if(name == "northeast")
return("southwest");
if(name == "southeast")
return("northwest");
if(name == "northwest")
return("southeast");
if(name == "southwest")
return("northeast");
if(name == "up")
return("down");
if(name == "down")
return("up");
return(name);
}
//*********************************************************************
// dmPurge
//*********************************************************************
// This function allows staff to purge a room of all its objects and
// monsters.
int dmPurge(Player* player, cmd* cmnd) {
BaseRoom* room = player->getRoomParent();
if(!player->canBuildMonsters() && !player->canBuildObjects())
return(cmdNoAuth(player));
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: this room is out of your range; you cannot *purge here.\n");
return(0);
}
room->purge(false);
player->print("Purged.\n");
if(!player->isDm())
log_immort(false,player, "%s purged room %s.\n", player->getCName(), player->getRoomParent()->fullName().c_str());
return(0);
}
//*********************************************************************
// dmEcho
//*********************************************************************
// This function allows a staff specified by the socket descriptor in
// the first parameter to echo the rest of their command line to all
// the other people in the room.
int dmEcho(Player* player, cmd* cmnd) {
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: room number not in any of your allotted ranges.\n");
return(0);
}
std::string text = getFullstrText(cmnd->fullstr, 1);
if(text.empty() || Pueblo::is(text)) {
player->print("Echo what?\n");
return(0);
}
if(!player->isCt())
broadcast(isStaff, "^G*** %s (%s) echoed: %s",
player->getCName(), player->getRoomParent()->fullName().c_str(), text.c_str());
broadcast(nullptr, player->getRoomParent(), "%s", text.c_str());
return(0);
}
//*********************************************************************
// dmReloadRoom
//*********************************************************************
// This function allows a staff to reload a room from disk.
int dmReloadRoom(Player* player, cmd* cmnd) {
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: this room is out of your range; you cannot reload this room.\n");
return(0);
}
if(gServer->reloadRoom(player->getRoomParent()))
player->print("Ok.\n");
else
player->print("Reload failed.\n");
return(0);
}
//*********************************************************************
// resetPerms
//*********************************************************************
// This function allows a staff to reset perm timeouts in the room
int dmResetPerms(Player* player, cmd* cmnd) {
std::map<int, crlasttime>::iterator it;
crlasttime* crtm=nullptr;
std::map<int, long> tempMonsters;
std::map<int, long> tempObjects;
UniqueRoom *room = player->getUniqueRoomParent();
//long temp_obj[10], temp_mon[10];
if(!needUniqueRoom(player))
return(0);
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: this room is out of your range; you cannot reload this room.\n");
return(0);
}
for(it = room->permMonsters.begin(); it != room->permMonsters.end() ; it++) {
crtm = &(*it).second;
tempMonsters[(*it).first] = crtm->interval;
crtm->ltime = time(nullptr);
crtm->interval = 0;
}
for(it = room->permObjects.begin(); it != room->permObjects.end() ; it++) {
crtm = &(*it).second;
tempObjects[(*it).first] = crtm->interval;
crtm->ltime = time(nullptr);
crtm->interval = 0;
}
player->print("Permanent object and creature timeouts reset.\n");
room->addPermCrt();
for(it = room->permMonsters.begin(); it != room->permMonsters.end() ; it++) {
crtm = &(*it).second;
crtm->interval = tempMonsters[(*it).first];
crtm->ltime = time(nullptr);
}
for(it = room->permObjects.begin(); it != room->permObjects.end() ; it++) {
crtm = &(*it).second;
crtm->interval = tempObjects[(*it).first];
crtm->ltime = time(nullptr);
}
log_immort(true, player, "%s reset perm timeouts in room %s\n", player->getCName(), player->getRoomParent()->fullName().c_str());
if(gServer->resaveRoom(room->info) < 0)
player->print("Room fail saved.\n");
else
player->print("Room saved.\n");
return(0);
}
//*********************************************************************
// stat_rom_exits
//*********************************************************************
// Display information on room given to staff.
void stat_rom_exits(Creature* player, BaseRoom* room) {
char str[1024], temp[25], tempstr[32];
int i=0, flagcount=0;
UniqueRoom* uRoom = room->getAsUniqueRoom();
if(room->exits.empty())
return;
player->print("Exits:\n");
for(Exit* exit : room->exits) {
if(!exit->getLevel())
player->print(" %s: ", exit->getCName());
else
player->print(" %s(L%d): ", exit->getCName(), exit->getLevel());
if(!exit->target.mapmarker.getArea())
player->printColor("%s ", exit->target.room.str(uRoom ? uRoom->info.area : "", 'y').c_str());
else
player->print(" A:%d X:%d Y:%d Z:%d ",
exit->target.mapmarker.getArea(), exit->target.mapmarker.getX(),
exit->target.mapmarker.getY(), exit->target.mapmarker.getZ());
*str = 0;
strcpy(str, "Flags: ");
for(i=0; i<MAX_EXIT_FLAGS; i++) {
if(exit->flagIsSet(i)) {
sprintf(tempstr, "%s(%d), ", gConfig->getXFlag(i).c_str(), i+1);
strcat(str, tempstr);
flagcount++;
}
}
if(flagcount) {
str[strlen(str) - 2] = '.';
str[strlen(str) - 1] = 0;
}
if(flagcount)
player->print("%s", str);
if(exit->flagIsSet(X_LOCKABLE)) {
player->print(" Key#: %d ", exit->getKey());
if(!exit->getKeyArea().empty())
player->printColor(" Area: ^y%s^x ", exit->getKeyArea().c_str());
}
if(exit->flagIsSet(X_TOLL_TO_PASS))
player->print(" Toll: %d ", exit->getToll());
player->print("\n");
if(!exit->getDescription().empty())
player->print(" Description: \"%s\"\n", exit->getDescription().c_str());
if( (exit->flagIsSet(X_CAN_LOOK) || exit->flagIsSet(X_LOOK_ONLY)) &&
exit->flagIsSet(X_NO_SCOUT)
)
player->printColor("^rExit is flagged as no-scout, but it flagged as lookable.\n");
if(exit->flagIsSet(X_PLEDGE_ONLY)) {
for(i=1; i<15; i++)
if(exit->flagIsSet(i+40)) {
sprintf(temp, "Clan: %d, ",i);
strcat(str, temp);
}
player->print(" Clan: %s\n", temp);
}
if(exit->flagIsSet(X_PORTAL)) {
player->printColor(" Owner: ^c%s^x Uses: ^c%d^x\n", exit->getPassPhrase().c_str(), exit->getKey());
} else if(!exit->getPassPhrase().empty()) {
player->print(" Passphrase: \"%s\"\n", exit->getPassPhrase().c_str());
if(exit->getPassLanguage())
player->print(" Passlang: %s\n", get_language_adj(exit->getPassLanguage()));
}
if(!exit->getEnter().empty())
player->print(" OnEnter: \"%s\"\n", exit->getEnter().c_str());
if(!exit->getOpen().empty())
player->print(" OnOpen: \"%s\"\n", exit->getOpen().c_str());
if(exit->getSize() || exit->getDirection()) {
if(exit->getSize())
player->print(" Size: %s", getSizeName(exit->getSize()).c_str());
if(exit->getDirection()) {
player->print(" Direction: %s", getDirName(exit->getDirection()).c_str());
if(getDir(exit->getName()) != NoDirection)
player->printColor("\n^rThis exit has a direction set, but the exit is a cardinal exit.");
}
player->print("\n");
}
if(!exit->effects.effectList.empty())
player->printColor(" Effects:\n%s", exit->effects.getEffectsString(player).c_str());
player->printColor("%s", exit->hooks.display().c_str());
}
}
//*********************************************************************
// trainingFlagSet
//*********************************************************************
bool trainingFlagSet(const BaseRoom* room, const TileInfo *tile, const AreaZone *zone, int flag) {
return( (room && room->flagIsSet(flag)) ||
(tile && tile->flagIsSet(flag)) ||
(zone && zone->flagIsSet(flag))
);
}
//*********************************************************************
// whatTraining
//*********************************************************************
// determines what class can train here
int whatTraining(const BaseRoom* room, const TileInfo *tile, const AreaZone *zone, int extra) {
int i = 0;
if(R_TRAINING_ROOM - 1 == extra || trainingFlagSet(room, tile, zone, R_TRAINING_ROOM - 1))
i += 16;
if(R_TRAINING_ROOM == extra || trainingFlagSet(room, tile, zone, R_TRAINING_ROOM))
i += 8;
if(R_TRAINING_ROOM + 1 == extra || trainingFlagSet(room, tile, zone, R_TRAINING_ROOM + 1))
i += 4;
if(R_TRAINING_ROOM + 2 == extra || trainingFlagSet(room, tile, zone, R_TRAINING_ROOM + 2))
i += 2;
if(R_TRAINING_ROOM + 3 == extra || trainingFlagSet(room, tile, zone, R_TRAINING_ROOM + 3))
i += 1;
return(i > static_cast<int>(CreatureClass::CLASS_COUNT) - 1 ? 0 : i);
}
bool BaseRoom::hasTraining() const {
return(whatTraining() != CreatureClass::NONE);
}
CreatureClass BaseRoom::whatTraining(int extra) const {
return(static_cast<CreatureClass>(::whatTraining(this, (const TileInfo*)nullptr, (const AreaZone*)nullptr, extra)));
}
//*********************************************************************
// showRoomFlags
//*********************************************************************
void showRoomFlags(const Player* player, const BaseRoom* room, const TileInfo *tile, const AreaZone *zone) {
bool flags=false;
int i=0;
std::ostringstream oStr;
oStr << "^@Flags set: ";
for(; i<MAX_ROOM_FLAGS; i++) {
if(i >=2 && i <= 6) // skips training flags
continue;
if( (room && room->flagIsSet(i)) ||
(tile && tile->flagIsSet(i)) ||
(zone && zone->flagIsSet(i))
) {
if(flags)
oStr << ", ";
flags = true;
oStr << gConfig->getRFlag(i) << "(" << (int)(i+1) << ")";
}
}
if(!flags)
oStr << "None";
oStr << ".^x\n";
i = whatTraining(room, tile, zone, 0);
if(i)
oStr << "^@Training: " << get_class_string(i) << "^x\n";
player->printColor("%s", oStr.str().c_str());
// inform user of redundant flags
if(room && room->getAsConstUniqueRoom()) {
bool hasTraining = room->hasTraining();
bool limboOrCoven = room->flagIsSet(R_LIMBO) || room->flagIsSet(R_VAMPIRE_COVEN);
if(room->flagIsSet(R_NO_TELEPORT)) {
if( limboOrCoven ||
room->flagIsSet(R_JAIL) ||
room->flagIsSet(R_ETHEREAL_PLANE) ||
hasTraining
)
player->printColor("^rThis room does not need flag 13-No Teleport set.\n");
}
if(room->flagIsSet(R_NO_SUMMON_OUT)) {
if( room->flagIsSet(R_IS_STORAGE_ROOM) ||
room->flagIsSet(R_LIMBO)
)
player->printColor("^rThis room does not need flag 29-No Summon Out set.\n");
}
if(room->flagIsSet(R_NO_LOGIN)) {
if( room->flagIsSet(R_LOG_INTO_TRAP_ROOM) ||
hasTraining
)
player->printColor("^rThis room does not need flag 34-No Log set.\n");
}
if(room->flagIsSet(R_NO_CLAIR_ROOM)) {
if(limboOrCoven)
player->printColor("^rThis room does not need flag 43-No Clair set.\n");
}
if(room->flagIsSet(R_NO_TRACK_TO)) {
if( limboOrCoven ||
room->flagIsSet(R_IS_STORAGE_ROOM) ||
room->flagIsSet(R_NO_TELEPORT) ||
hasTraining
)
player->printColor("^rThis room does not need flag 52-No Track To set.\n");
}
if(room->flagIsSet(R_NO_SUMMON_TO)) {
if( limboOrCoven ||
room->flagIsSet(R_NO_TELEPORT) ||
room->flagIsSet(R_ONE_PERSON_ONLY) ||
hasTraining
)
player->printColor("^rThis room does not need flag 54-No Summon To set.\n");
}
if(room->flagIsSet(R_NO_TRACK_OUT)) {
if( room->flagIsSet(R_LIMBO) ||
room->flagIsSet(R_ETHEREAL_PLANE)
)
player->printColor("^rThis room does not need flag 54-No Summon To set.\n");
}
if(room->flagIsSet(R_OUTLAW_SAFE)) {
if( limboOrCoven ||
hasTraining
)
player->printColor("^rThis room does not need flag 57-Outlaw Safe set.\n");
}
if(room->flagIsSet(R_LOG_INTO_TRAP_ROOM)) {
if(hasTraining)
player->printColor("^rThis room does not need flag 63-Log To Trap Exit set.\n");
}
if(room->flagIsSet(R_LIMBO)) {
if(room->flagIsSet(R_POST_OFFICE))
player->printColor("^rThis room does not need flag 11-Post Office set.\n");
if(room->flagIsSet(R_FAST_HEAL))
player->printColor("^rThis room does not need flag 14-Fast Heal set.\n");
if(room->flagIsSet(R_NO_POTION))
player->printColor("^rThis room does not need flag 32-No Potion set.\n");
if(room->flagIsSet(R_NO_CAST_TELEPORT))
player->printColor("^rThis room does not need flag 38-No Cast Teleport set.\n");
if(room->flagIsSet(R_NO_FLEE))
player->printColor("^rThis room does not need flag 44-No Flee set.\n");
if(room->flagIsSet(R_BANK))
player->printColor("^rThis room does not need flag 58-Bank set.\n");
if(room->flagIsSet(R_MAGIC_MONEY_MACHINE))
player->printColor("^rThis room does not need flag 59-Magic Money Machine set.\n");
}
}
}
//*********************************************************************
// stat_rom
//*********************************************************************
int stat_rom(Player* player, AreaRoom* room) {
std::list<AreaZone*>::iterator it;
AreaZone* zone=nullptr;
TileInfo* tile=nullptr;
if(!player->checkBuilder(nullptr))
return(0);
if(player->getClass() == CreatureClass::CARETAKER)
log_immort(false,player, "%s statted room %s.\n", player->getCName(), player->getRoomParent()->fullName().c_str());
player->print("Room: %s %s\n\n",
room->area->name.c_str(), room->fullName().c_str());
tile = room->area->getTile(room->area->getTerrain(nullptr, &room->mapmarker, 0, 0, 0, true), false);
for(it = room->area->zones.begin() ; it != room->area->zones.end() ; it++) {
zone = (*it);
if(zone->inside(room->area, &room->mapmarker)) {
player->printColor("^yZone:^x %s\n", zone->name.c_str());
if(zone->wander.getTraffic()) {
zone->wander.show(player);
} else {
player->print(" No monsters come in this zone.\n");
}
player->print("\n");
}
}
if(room->getSize())
player->printColor("Size: ^y%s\n", getSizeName(room->getSize()).c_str());
if(tile->wander.getTraffic())
tile->wander.show(player);
player->print("Terrain: %c\n", tile->getDisplay());
if(room->isWater())
player->printColor("Water: ^gyes\n");
if(room->isRoad())
player->printColor("Road: ^gyes\n");
player->printColor("Generic Room: %s\n", room->canSave() ? "^rNo" : "^gYes");
if(room->unique.id) {
player->printColor("Links to unique room ^y%s^x.\n", room->unique.str().c_str());
player->printColor("needsCompass: %s^x decCompass: %s",
room->getNeedsCompass() ? "^gYes" : "^rNo", room->getDecCompass() ? "^gYes" : "^rNo");
}
player->print("\n");
showRoomFlags(player, room, nullptr, nullptr);
if(!room->effects.effectList.empty())
player->printColor("Effects:\n%s", room->effects.getEffectsString(player).c_str());
player->printColor("%s", room->hooks.display().c_str());
stat_rom_exits(player, room);
return(0);
}
//*********************************************************************
// validateShop
//*********************************************************************
void validateShop(const Player* player, const UniqueRoom* shop, const UniqueRoom* storage) {
// basic checks
if(!shop) {
player->printColor("^rThe shop associated with this storage room does not exist.\n");
return;
}
if(!storage) {
player->printColor("^rThe storage room associated with this shop does not exist.\n");
return;
}
if(shop->info == storage->info) {
player->printColor("^rThe shop and the storage room cannot be the same room. Set the shop's trap exit appropriately.\n");
return;
}
CatRef cr = shopStorageRoom(shop);
if(shop->info == cr) {
player->printColor("^rThe shop and the storage room cannot be the same room. Set the shop's trap exit appropriately.\n");
return;
}
std::string name = "Storage: ";
name += shop->getName();
if(cr != storage->info)
player->printColor("^rThe shop's storage room of %s does not match the storage room %s.\n", cr.str().c_str(), storage->info.str().c_str());
if(storage->getTrapExit() != shop->info)
player->printColor("^yThe storage room's trap exit of %s does not match the shop room %s.\n", storage->info.str().c_str(), shop->info.str().c_str());
if(!shop->flagIsSet(R_SHOP))
player->printColor("^rThe shop's flag 1-Shoppe is not set.\n");
if(!storage->flagIsSet(R_SHOP_STORAGE))
player->printColor("^rThe storage room's flag 97-Shop Storage is not set.\n");
// what DOESN'T the storage room need?
if(storage->flagIsSet(R_NO_LOGIN))
player->printColor("^rThe storage room does not need flag 34-No Log set.\n");
if(storage->flagIsSet(R_LOG_INTO_TRAP_ROOM))
player->printColor("^rThe storage room does not need flag 63-Log To Trap Exit set.\n");
if(storage->flagIsSet(R_NO_TELEPORT))
player->printColor("^rThe storage room does not need flag 13-No Teleport set.\n");
if(storage->flagIsSet(R_NO_SUMMON_TO))
player->printColor("^rThe storage room does not need flag 54-No Summon To set.\n");
if(storage->flagIsSet(R_NO_TRACK_TO))
player->printColor("^rThe storage room does not need flag 52-No Track To set.\n");
if(storage->flagIsSet(R_NO_CLAIR_ROOM))
player->printColor("^rThe storage room does not need flag 43-No Clair set.\n");
if(storage->exits.empty()) {
player->printColor("^yThe storage room does not have an out exit pointing to the shop.\n");
} else {
const Exit* exit = storage->exits.front();
if( exit->target.room != shop->info || exit->getName() != "out")
player->printColor("^yThe storage room does not have an out exit pointing to the shop.\n");
else if(storage->exits.size() > 1)
player->printColor("^yThe storage room has more than one exit - it only needs one out exit pointing to the shop.\n");
}
}
//*********************************************************************
// stat_rom
//*********************************************************************
int stat_rom(Player* player, UniqueRoom* room) {
std::map<int, crlasttime>::iterator it;
crlasttime* crtm=nullptr;
CatRef cr;
Monster* monster=nullptr;
Object* object=nullptr;
UniqueRoom* shop=nullptr;
time_t t = time(nullptr);
if(!player->checkBuilder(room))
return(0);
if(player->getClass() == CreatureClass::CARETAKER)
log_immort(false,player, "%s statted room %s.\n", player->getCName(), player->getRoomParent()->fullName().c_str());
player->printColor("Room: %s", room->info.str("", 'y').c_str());
if(gConfig->inSwapQueue(room->info, SwapRoom, true))
player->printColor(" ^eThis room is being swapped.");
player->print("\nTimes People have entered this room: %d\n", room->getBeenHere());
player->print("Name: %s\n", room->getCName());
Property *p = gConfig->getProperty(room->info);
if(p) {
player->printColor("Property Belongs To: ^y%s^x\nProperty Type: ^y%s\n",
p->getOwner().c_str(), p->getTypeStr().c_str());
}
if(player->isCt()) {
if(room->last_mod[0])
player->printColor("^cLast modified by: %s on %s\n", room->last_mod, stripLineFeeds(room->lastModTime));
if(room->lastPly[0])
player->printColor("^cLast player here: %s on %s\n", room->lastPly, stripLineFeeds(room->lastPlyTime));
} else
player->print("\n");
if(room->getSize())
player->printColor("Size: ^y%s\n", getSizeName(room->getSize()).c_str());
if(room->getRoomExperience())
player->print("Experience for entering this room: %d\n", room->getRoomExperience());
if(!room->getFaction().empty())
player->printColor("Faction: ^g%s^x\n", room->getFaction().c_str());
if(!room->getFishingStr().empty())
player->printColor("Fishing: ^g%s^x\n", room->getFishingStr().c_str());
if(room->getMaxMobs() > 0)
player->print("Max mob allowance: %d\n", room->getMaxMobs());
room->wander.show(player, room->info.area);
player->print("\n");
player->print("Perm Objects:\n");
for(it = room->permObjects.begin(); it != room->permObjects.end() ; it++) {
crtm = &(*it).second;
loadObject((*it).second.cr, &object);
player->printColor("^y%2d) ^x%14s ^y::^x %-30s ^yInterval:^x %-5d ^yTime Until Spawn:^x %-5d", (*it).first+1,
crtm->cr.str("", 'y').c_str(), object ? object->getCName() : "", crtm->interval, MAX<long>(0, crtm->ltime + crtm->interval-t));
if(room->flagIsSet(R_SHOP_STORAGE) && object)
player->printColor(" ^yCost:^x %s", object->value.str().c_str());
player->print("\n");
// warning about deeds in improper areas
if(object && object->deed.low.id && !object->deed.isArea(room->info.area))
player->printColor(" ^YCaution:^x this object's deed area does not match the room's area.\n");
if(object) {
delete object;
object = nullptr;
}
}
player->print("\n");
player->print("Perm Monsters:\n");
for(it = room->permMonsters.begin(); it != room->permMonsters.end() ; it++) {
crtm = &(*it).second;
loadMonster((*it).second.cr, &monster);
player->printColor("^m%2d) ^x%14s ^m::^x %-30s ^mInterval:^x %d ^yTime until Spawn:^x %-5d\n", (*it).first+1,
crtm->cr.str("", 'm').c_str(), monster ? monster->getCName() : "", crtm->interval, MAX<long>(0, crtm->ltime + crtm->interval-t));
if(monster) {
free_crt(monster);
monster = nullptr;
}
}
player->print("\n");
if(!room->track.getDirection().empty() && room->flagIsSet(R_PERMENANT_TRACKS))
player->print("Perm Tracks: %s.\n", room->track.getDirection().c_str());
if(room->getLowLevel() || room->getHighLevel()) {
player->print("Level Boundary: ");
if(room->getLowLevel())
player->print("%d+ level ", room->getLowLevel());
if(room->getHighLevel())
player->print("%d- level ", room->getHighLevel());
player->print("\n");
}
if( room->flagIsSet(R_LOG_INTO_TRAP_ROOM) ||
room->flagIsSet(R_SHOP_STORAGE) ||
room->hasTraining()
) {
if(room->getTrapExit().id)
player->print("Players will relog into room %s from here.\n", room->getTrapExit().str(room->info.area).c_str());
else
player->printColor("^rTrap exit needs to be set to %s room number.\n", room->flagIsSet(R_SHOP_STORAGE) ? "shop" : "relog");
}
if( room->getSize() == NO_SIZE && (
room->flagIsSet(R_INDOORS) ||
room->flagIsSet(R_UNDERGROUND)
)
)
player->printColor("^yThis room does not have a size set.\n");
checkTeleportRange(player, room->info);
// isShopValid
if(room->flagIsSet(R_SHOP)) {
cr = shopStorageRoom(room);
player->print("Shop storage room: %s (%s)\n", cr.str().c_str(),
cr.id == room->info.id+1 && cr.isArea(room->info.area) ? "default" : "trapexit");
if(room->getFaction().empty() && room->info.area != "shop")
player->printColor("^yThis shop does not have a faction set.\n");
loadRoom(cr, &shop);
validateShop(player, room, shop);
} else if(room->flagIsSet(R_PAWN_SHOP)) {
if(room->getFaction().empty())
player->printColor("^yThis pawn shop does not have a faction set.\n");
}
if(room->flagIsSet(R_SHOP_STORAGE)) {
loadRoom(room->getTrapExit(), &shop);
validateShop(player, shop, room);
}
if(room->getTrap()) {
if(room->getTrapWeight())
player->print("Trap weight: %d/%d lbs\n", room->getWeight(), room->getTrapWeight());
player->print("Trap type: ");
switch(room->getTrap()) {
case TRAP_PIT:
player->print("Pit Trap (exit rm %s)\n", room->getTrapExit().str(room->info.area).c_str());
break;
case TRAP_DART:
player->print("Poison Dart Trap\n");
break;
case TRAP_BLOCK:
player->print("Falling Block Trap\n");
break;
case TRAP_MPDAM:
player->print("MP Damage Trap\n");
break;
case TRAP_RMSPL:
player->print("Negate Spell Trap\n");
break;
case TRAP_NAKED:
player->print("Naked Trap\n");
break;
case TRAP_TPORT:
player->print("Teleport Trap\n");
break;
case TRAP_ARROW:
player->print("Arrow Trap\n");
break;
case TRAP_SPIKED_PIT:
player->print("Spiked Pit Trap (exit rm %s)\n", room->getTrapExit().str(room->info.area).c_str());
break;
case TRAP_WORD:
player->print("Word of Recall Trap\n");
break;
case TRAP_FIRE:
player->print("Fire Trap\n");
break;
case TRAP_FROST:
player->print("Frost Trap\n");
break;
case TRAP_ELEC:
player->print("Electricity Trap\n");
break;
case TRAP_ACID:
player->print("Acid Trap\n");
break;
case TRAP_ROCKS:
player->print("Rockslide Trap\n");
break;
case TRAP_ICE:
player->print("Icicle Trap\n");
break;
case TRAP_SPEAR:
player->print("Spear Trap\n");
break;
case TRAP_CROSSBOW:
player->print("Crossbow Trap\n");
break;
case TRAP_GASP:
player->print("Poison Gas Trap\n");
break;
case TRAP_GASB:
player->print("Blinding Gas Trap\n");
break;
case TRAP_GASS:
player->print("Stun Gas Trap\n");
break;
case TRAP_MUD:
player->print("Mud Trap\n");
break;
case TRAP_DISP:
player->print("Room Displacement Trap (exit rm %s)\n", room->getTrapExit().str(room->info.area).c_str());
break;
case TRAP_FALL:
player->print("Deadly Fall Trap (exit rm %s)\n", room->getTrapExit().str(room->info.area).c_str());
break;
case TRAP_CHUTE:
player->print("Chute Trap (exit rm %s)\n", room->getTrapExit().str(room->info.area).c_str());
break;
case TRAP_ALARM:
player->print("Alarm Trap (guard rm %s)\n", room->getTrapExit().str(room->info.area).c_str());
break;
case TRAP_BONEAV:
player->print("Bone Avalanche Trap (exit rm %s)\n", room->getTrapExit().str(room->info.area).c_str());
break;
case TRAP_PIERCER:
player->print("Piercer trap (%d piercers)\n", room->getTrapStrength());
break;
case TRAP_ETHEREAL_TRAVEL:
player->print("Ethereal travel trap.\n");
break;
case TRAP_WEB:
player->print("Sticky spider web trap.\n");
break;
default:
player->print("Invalid trap #\n");
break;
}
}
if(room->flagIsSet(R_CAN_SHOPLIFT))
player->print("Store guardroom: rm %s\n", cr.str(room->info.area).c_str());
showRoomFlags(player, room, nullptr, nullptr);
if(!room->effects.effectList.empty())
player->printColor("Effects:\n%s", room->effects.getEffectsString(player).c_str());
player->printColor("%s", room->hooks.display().c_str());
stat_rom_exits(player, room);
return(0);
}
//*********************************************************************
// dmAddRoom
//*********************************************************************
// This function allows staff to add a new, empty room to the current
// database of rooms.
int dmAddRoom(Player* player, cmd* cmnd) {
UniqueRoom *newRoom=nullptr;
char file[80];
int i=1;
if(!strcmp(cmnd->str[1], "c") && (cmnd->num > 1)) {
dmAddMob(player, cmnd);
return(0);
}
if(!strcmp(cmnd->str[1], "o") && (cmnd->num > 1)) {
dmAddObj(player, cmnd);
return(0);
}
CatRef cr;
bool extra = !strcmp(cmnd->str[1], "r");
getCatRef(getFullstrText(cmnd->fullstr, extra ? 2 : 1), &cr, player);
if(cr.id < 1) {
player->print("Index error: please specify room number.\n");
return(0);
}
if(!player->checkBuilder(cr, false)) {
player->print("Error: Room number not inside any of your alotted ranges.\n");
return(0);
}
if(gConfig->moveRoomRestrictedArea(cr.area)) {
player->print("Error: ""%s"" is a restricted range. You cannot create unique rooms in that area.\n");
return(0);
}
Path::checkDirExists(cr.area, roomPath);
if(!strcmp(cmnd->str[extra ? 3 : 2], "loop"))
i = MAX(1, MIN(100, (int)cmnd->val[extra ? 3 : 2]));
for(; i; i--) {
if(!player->checkBuilder(cr, false)) {
player->print("Error: Room number not inside any of your alotted ranges.\n");
return(0);
}
sprintf(file, "%s", roomPath(cr));
if(file_exists(file)) {
player->print("Room already exists.\n");
return(0);
}
newRoom = new UniqueRoom;
if(!newRoom)
merror("dmAddRoom", FATAL);
newRoom->info = cr;
newRoom->setFlag(R_CONSTRUCTION);
newRoom->setName("New Room");
if(newRoom->saveToFile(0) < 0) {
player->print("Write failed.\n");
return(0);
}
delete newRoom;
log_immort(true, player, "%s created room %s.\n", player->getCName(), cr.str().c_str());
player->print("Room %s created.\n", cr.str().c_str());
checkTeleportRange(player, cr);
cr.id++;
}
return(0);
}
//*********************************************************************
// dmSetRoom
//*********************************************************************
// This function allows staff to set a characteristic of a room.
int dmSetRoom(Player* player, cmd* cmnd) {
BaseRoom *room = player->getRoomParent();
int a=0, num=0;
CatRef cr;
if(cmnd->num < 3) {
player->print("Syntax: *set r [option] [<value>]\n");
return(0);
}
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: Room number not inside any of your alotted ranges.\n");
return(0);
}
switch(low(cmnd->str[2][0])) {
case 'b':
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
if(low(cmnd->str[2][1]) == 'l') {
player->getUniqueRoomParent()->setLowLevel(cmnd->val[2]);
player->print("Low level boundary %d\n", player->getUniqueRoomParent()->getLowLevel());
} else if(low(cmnd->str[2][1]) == 'h') {
player->getUniqueRoomParent()->setHighLevel(cmnd->val[2]);
player->print("Upper level boundary %d\n", player->getUniqueRoomParent()->getHighLevel());
}
break;
case 'd':
if(!player->inAreaRoom()) {
player->print("Error: You need to be in an area room to do that.\n");
return(0);
}
if(!player->getAreaRoomParent()->unique.id) {
player->print("Error: The area room must have the unique field set [*set r unique #].\n");
return(0);
}
player->getAreaRoomParent()->setDecCompass(!player->getAreaRoomParent()->getDecCompass());
player->printColor("DecCompass toggled, set to %s^x.\n",
player->getAreaRoomParent()->getDecCompass() ? "^gYes" : "^rNo");
log_immort(true, player, "%s set decCompass to %s in room %s.\n", player->getCName(),
player->getAreaRoomParent()->getDecCompass() ? "true" : "false", room->fullName().c_str());
break;
case 'e':
if(cmnd->str[2][1] == 'f') {
if(cmnd->num < 4) {
player->print("Set what effect to what?\n");
return(0);
}
long duration = -1;
int strength = 1;
std::string txt = getFullstrText(cmnd->fullstr, 4);
if(!txt.empty())
duration = atoi(txt.c_str());
txt = getFullstrText(cmnd->fullstr, 5);
if(!txt.empty())
strength = atoi(txt.c_str());
if(duration > EFFECT_MAX_DURATION || duration < -1) {
player->print("Duration must be between -1 and %d.\n", EFFECT_MAX_DURATION);
return(0);
}
if(strength < 0 || strength > EFFECT_MAX_STRENGTH) {
player->print("Strength must be between 0 and %d.\n", EFFECT_MAX_STRENGTH);
return(0);
}
std::string effectStr = cmnd->str[3];
EffectInfo* toSet = nullptr;
if((toSet = room->getExactEffect(effectStr))) {
// We have an existing effect we're modifying
if(duration == 0) {
// Duration is 0, so remove it
room->removeEffect(toSet, true);
player->print("Effect '%s' (room) removed.\n", effectStr.c_str());
} else {
// Otherwise modify as appropriate
toSet->setDuration(duration);
if(strength != -1)
toSet->setStrength(strength);
player->print("Effect '%s' (room) set to duration %d and strength %d.\n", effectStr.c_str(), toSet->getDuration(), toSet->getStrength());
}
break;
} else {
// No existing effect, add a new one
if(strength == -1)
strength = 1;
if(room->addEffect(effectStr, duration, strength, nullptr, true) != nullptr){
player->print("Effect '%s' (room) added with duration %d and strength %d.\n", effectStr.c_str(), duration, strength);
} else {
player->print("Unable to add effect '%s' (room)\n", effectStr.c_str());
}
break;
}
} else if(cmnd->str[2][1] == 'x') {
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
player->getUniqueRoomParent()->setRoomExperience(cmnd->val[2]);
player->print("Room experience set to %d.\n", player->getUniqueRoomParent()->getRoomExperience());
log_immort(true, player, "%s set roomExp to %d in room %s.\n", player->getCName(),
player->getUniqueRoomParent()->getRoomExperience(), room->fullName().c_str());
} else {
player->print("Invalid option.\n");
return(0);
}
break;
case 'f':
if(low(cmnd->str[2][1]) == 'i') {
if(!strcmp(cmnd->str[3], "")) {
player->getUniqueRoomParent()->setFishing("");
player->print("Fishing list cleared.\n");
log_immort(true, player, "%s cleared fishing list in room %s.\n", player->getCName(),
room->fullName().c_str());
} else {
const Fishing* list = gConfig->getFishing(cmnd->str[3]);
if(!list) {
player->print("Fishing list \"%s\" does not exist!\n", cmnd->str[3]);
return(0);
}
player->getUniqueRoomParent()->setFishing(cmnd->str[3]);
player->print("Fishing list set to %s.\n", player->getUniqueRoomParent()->getFishingStr().c_str());
log_immort(true, player, "%s set fishing list to %s in room %s.\n", player->getCName(),
player->getUniqueRoomParent()->getFishingStr().c_str(), room->fullName().c_str());
}
} else if(low(cmnd->str[2][1]) == 'a') {
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
if(cmnd->num < 3) {
player->print("Set faction to what?\n");
return(0);
} else if(cmnd->num == 3) {
player->getUniqueRoomParent()->setFaction("");
player->print("Faction cleared.\n");
log_immort(true, player, "%s cleared faction in room %s.\n", player->getCName(),
room->fullName().c_str());
return(0);
}
Property* p = gConfig->getProperty(player->getUniqueRoomParent()->info);
if(p && p->getType() == PROP_SHOP) {
player->print("You can't set room faction on player shops!\n");
return(0);
}
const Faction* faction = gConfig->getFaction(cmnd->str[3]);
if(!faction) {
player->print("'%s' is an invalid faction.\n", cmnd->str[3]);
return(0);
}
player->getUniqueRoomParent()->setFaction(faction->getName());
player->print("Faction set to %s.\n", player->getUniqueRoomParent()->getFaction().c_str());
log_immort(true, player, "%s set faction to %s in room %s.\n", player->getCName(),
player->getUniqueRoomParent()->getFaction().c_str(), room->fullName().c_str());
break;
} else {
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
num = cmnd->val[2];
if(num < 1 || num > MAX_ROOM_FLAGS) {
player->print("Error: outside of range.\n");
return(0);
}
if(!player->isCt() && num == R_CONSTRUCTION+1) {
player->print("Error: you cannot set/clear that flag.\n");
return(0);
}
if(!strcmp(cmnd->str[3], "del")) {
for(a=0;a<MAX_ROOM_FLAGS;a++)
player->getUniqueRoomParent()->clearFlag(a);
player->print("All room flags cleared.\n");
log_immort(true, player, "%s cleared all flags in room %s.\n",
player->getCName(), room->fullName().c_str());
break;
}
if(player->getUniqueRoomParent()->flagIsSet(num - 1)) {
player->getUniqueRoomParent()->clearFlag(num - 1);
player->print("Room flag #%d(%s) off.\n", num, gConfig->getRFlag(num-1).c_str());
log_immort(true, player, "%s cleared flag #%d(%s) in room %s.\n", player->getCName(), num, gConfig->getRFlag(num-1).c_str(),
room->fullName().c_str());
} else {
if(num >= R_TRAINING_ROOM && num - 4 <= R_TRAINING_ROOM) {
// setting a training flag - do we let them?
if(player->getUniqueRoomParent()->whatTraining(num-1) == CreatureClass::NONE) {
player->print("You are setting training for a class that does not exist.\n");
return(0);
}
}
player->getUniqueRoomParent()->setFlag(num - 1);
player->print("Room flag #%d(%s) on.\n", num, gConfig->getRFlag(num-1).c_str());
log_immort(true, player, "%s set flag #%d(%s) in room %s.\n", player->getCName(), num, gConfig->getRFlag(num-1).c_str(),
room->fullName().c_str());
if(num-1 == R_SHOP)
player->printColor("^YNote:^x you must set the Shop Storage (97) to use this room as a shop.\n");
if((num-1 == R_INDOORS || num-1 == R_VAMPIRE_COVEN || num-1 == R_UNDERGROUND) && player->getUniqueRoomParent()->getSize() == NO_SIZE)
player->printColor("^YNote:^x don't forget to set the size for this room.\n");
}
// try and be smart
if( num-1 == R_SHOP_STORAGE &&
player->getUniqueRoomParent()->getName() == "New Room" &&
player->getUniqueRoomParent()->exits.empty())
{
cr = player->getUniqueRoomParent()->info;
UniqueRoom* shop=nullptr;
std::string storageName = "Storage: ";
cr.id--;
if(loadRoom(cr, &shop)) {
if( shop->flagIsSet(R_SHOP) &&
(!shop->getTrapExit().id || shop->getTrapExit() == cr)
) {
player->printColor("^ySetting up this storage room for you...\n");
player->printColor("^y * ^xSetting the trap exit to %s...\n", cr.str().c_str());
player->getUniqueRoomParent()->setTrapExit(cr);
player->printColor("^y * ^xCreating exit ""out"" to %s...\n", cr.str().c_str());
link_rom(player->getUniqueRoomParent(), cr, "out");
player->getUniqueRoomParent()->setTrapExit(cr);
player->printColor("^y * ^xNaming this room...\n");
storageName += shop->getName();
player->getUniqueRoomParent()->setName(storageName);
player->print("Done!\n");
}
}
}
}
break;
case 'l':
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
if(strcmp(cmnd->str[3], "clear") != 0) {
player->print("Are you sure?\nType \"*set r last clear\" to clear last-arrived info.\n");
return(0);
}
strcpy(player->getUniqueRoomParent()->lastPly, "");
strcpy(player->getUniqueRoomParent()->lastPlyTime, "");
player->print("Last-arrived info cleared.\n");
break;
case 'm':
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
player->getUniqueRoomParent()->setMaxMobs(cmnd->val[2]);
if(!player->getUniqueRoomParent()->getMaxMobs())
player->print("The limit on the number of creatures that can be here has been removed.\n");
else
player->print("Only %d creature%s can now be in here at a time.\n", player->getUniqueRoomParent()->getMaxMobs(), player->getUniqueRoomParent()->getMaxMobs() != 1 ? "s" : "");
log_immort(true, player, "%s set max %d mobs in room %s.\n", player->getCName(), player->getUniqueRoomParent()->getMaxMobs(),
room->fullName().c_str());
break;
case 'n':
if(!player->inAreaRoom()) {
player->print("Error: You need to be in an area room to do that.\n");
return(0);
}
if(!player->getAreaRoomParent()->unique.id) {
player->print("Error: The area room must have the unique field set [*set r unique #].\n");
return(0);
}
player->getAreaRoomParent()->setNeedsCompass(!player->getAreaRoomParent()->getNeedsCompass());
player->printColor("NeedsCompass toggled, set to %s^x.\n",
player->getAreaRoomParent()->getNeedsCompass() ? "^gYes" : "^rNo");
log_immort(true, player, "%s set needsCompass to %s in room %s.\n", player->getCName(),
player->getAreaRoomParent()->getNeedsCompass() ? "true" : "false", room->fullName().c_str());
break;
case 'r':
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
num = atoi(&cmnd->str[2][1]);
if(num < 1 || num > NUM_RANDOM_SLOTS) {
player->print("Error: outside of range.\n");
return(PROMPT);
}
getCatRef(getFullstrText(cmnd->fullstr, 3), &cr, player);
if(!cr.id) {
player->getUniqueRoomParent()->wander.random.erase(num-1);
player->print("Random #%d has been cleared.\n", num);
} else {
player->getUniqueRoomParent()->wander.random[num-1] = cr;
player->print("Random #%d is now %s.\n", num, cr.str().c_str());
}
log_immort(false,player, "%s set mob slot %d to mob %s in room %s.\n",
player->getCName(), num, cr.str().c_str(),
room->fullName().c_str());
break;
case 's':
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
player->getUniqueRoomParent()->setSize(getSize(cmnd->str[3]));
player->print("Size set to %s.\n", getSizeName(player->getUniqueRoomParent()->getSize()).c_str());
log_immort(true, player, "%s set room %s's %s to %s.\n",
player->getCName(), room->fullName().c_str(), "Size", getSizeName(player->getUniqueRoomParent()->getSize()).c_str());
break;
case 't':
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
player->getUniqueRoomParent()->wander.setTraffic(cmnd->val[2]);
log_immort(true, player, "%s set room %s's traffic to %ld.\n", player->getCName(),
player->getUniqueRoomParent()->info.str().c_str(), player->getUniqueRoomParent()->wander.getTraffic());
player->print("Traffic is now %d%%.\n", player->getUniqueRoomParent()->wander.getTraffic());
break;
case 'x':
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
if(low(cmnd->str[2][1]) == 'x') {
getCatRef(getFullstrText(cmnd->fullstr, 3), &cr, player);
if(!player->checkBuilder(cr)) {
player->print("Trap's exit must be within an assigned range.\n");
return(0);
}
player->getUniqueRoomParent()->setTrapExit(cr);
player->print("Room's trap exit is now %s.\n", player->getUniqueRoomParent()->getTrapExit().str().c_str());
log_immort(true, player, "%s set trapexit to %s in room %s.\n", player->getCName(),
player->getUniqueRoomParent()->getTrapExit().str().c_str(), room->fullName().c_str());
} else if(low(cmnd->str[2][1]) == 'w') {
num = (int)cmnd->val[2];
if(num < 0 || num > 5000) {
player->print("Trap weight cannot be less than 0 or greater than 5000.\n");
return(0);
}
player->getUniqueRoomParent()->setTrapWeight(num);
player->print("Room's trap weight is now %d.\n", player->getUniqueRoomParent()->getTrapWeight());
log_immort(true, player, "%s set trapweight to %d in room %s.\n", player->getCName(), player->getUniqueRoomParent()->getTrapWeight(),
room->fullName().c_str());
} else if(low(cmnd->str[2][1]) == 's') {
num = (int)cmnd->val[2];
if(num < 0 || num > 5000) {
player->print("Trap strength cannot be less than 0 or greater than 5000.\n");
return(0);
}
player->getUniqueRoomParent()->setTrapStrength(num);
player->print("Room's trap strength is now %d.\n", player->getUniqueRoomParent()->getTrapStrength());
log_immort(true, player, "%s set trapstrength to %d in room %s.\n", player->getCName(), player->getUniqueRoomParent()->getTrapStrength(),
room->fullName().c_str());
} else {
player->getUniqueRoomParent()->setTrap(cmnd->val[2]);
player->print("Room has trap #%d set.\n", player->getUniqueRoomParent()->getTrap());
log_immort(true, player, "%s set trap #%d in room %s.\n", player->getCName(), player->getUniqueRoomParent()->getTrap(),
room->fullName().c_str());
}
break;
case 'u':
if(!player->inAreaRoom()) {
player->print("Error: You need to be in an area room to do that.\n");
return(0);
}
getCatRef(getFullstrText(cmnd->fullstr, 3), &cr, player);
player->getAreaRoomParent()->unique = cr;
player->print("Unique room set to %s.\n", player->getAreaRoomParent()->unique.str().c_str());
if(player->getAreaRoomParent()->unique.id)
player->print("You'll need to use *teleport to get to this room in the future.\n");
log_immort(true, player, "%s set unique room to %s in room %s.\n",
player->getCName(), player->getAreaRoomParent()->unique.str().c_str(),
room->fullName().c_str());
break;
default:
player->print("Invalid option.\n");
return(0);
}
if(player->inUniqueRoom())
player->getUniqueRoomParent()->escapeText();
room_track(player);
return(0);
}
//*********************************************************************
// dmSetExit
//*********************************************************************
// This function allows staff to set a characteristic of an exit.
int dmSetExit(Player* player, cmd* cmnd) {
BaseRoom* room = player->getRoomParent();
int num=0;
//char orig_exit[30];
short n=0;
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: Room number not inside any of your alotted ranges.\n");
return(0);
}
// setting something on the exit
if(cmnd->str[1][1]) {
if(cmnd->num < 3) {
player->print("Invalid syntax.\n");
return(0);
}
Exit* exit = findExit(player, cmnd->str[2], 1);
if(!exit) {
player->print("Exit not found.\n");
return(0);
}
switch(cmnd->str[1][1]) {
case 'd':
{
if(cmnd->str[1][2] == 'i') {
Direction dir = getDir(cmnd->str[3]);
if(getDir(exit->getName()) != NoDirection && dir != NoDirection) {
player->print("This exit does not need a direction set on it.\n");
return(0);
}
exit->setDirection(dir);
player->printColor("%s^x's %s set to %s.\n", exit->getCName(), "Direction", getDirName(exit->getDirection()).c_str());
log_immort(true, player, "%s set %s %s^g's %s to %s.\n",
player->getCName(), "exit", exit->getCName(), "Direction", getDirName(exit->getDirection()).c_str());
} else if(cmnd->str[1][2] == 'e') {
std::string desc = getFullstrText(cmnd->fullstr, 3);
boost::replace_all(desc, "*CR*", "\n");
exit->setDescription(desc);
if(exit->getDescription().empty()) {
player->print("Description cleared.\n");
log_immort(true, player, "%s cleared %s^g's %s.\n", player->getCName(), exit->getCName(), "Description");
} else {
player->print("Description set to \"%s\".\n", exit->getDescription().c_str());
log_immort(true, player, "%s set %s^g's %s to \"%s\".\n", player->getCName(), exit->getCName(), "Description", exit->getDescription().c_str());
}
} else {
player->print("Description or direction?\n");
return(0);
}
break;
}
case 'e':
if(cmnd->str[1][2] == 'f') {
if(cmnd->num < 4) {
player->print("Set what effect to what?\n");
return(0);
}
long duration = -1;
int strength = 1;
std::string txt = getFullstrText(cmnd->fullstr, 4);
if(!txt.empty())
duration = atoi(txt.c_str());
txt = getFullstrText(cmnd->fullstr, 5);
if(!txt.empty())
strength = atoi(txt.c_str());
if(duration > EFFECT_MAX_DURATION || duration < -1) {
player->print("Duration must be between -1 and %d.\n", EFFECT_MAX_DURATION);
return(0);
}
if(strength < 0 || strength > EFFECT_MAX_STRENGTH) {
player->print("Strength must be between 0 and %d.\n", EFFECT_MAX_STRENGTH);
return(0);
}
std::string effectStr = cmnd->str[3];
EffectInfo* toSet = nullptr;
if((toSet = exit->getExactEffect(effectStr))) {
// We have an existing effect we're modifying
if(duration == 0) {
// Duration is 0, so remove it
exit->removeEffect(toSet, true);
player->print("Effect '%s' (exit) removed.\n", effectStr.c_str());
} else {
// Otherwise modify as appropriate
toSet->setDuration(duration);
if(strength != -1)
toSet->setStrength(strength);
player->print("Effect '%s' (exit) set to duration %d and strength %d.\n", effectStr.c_str(), toSet->getDuration(), toSet->getStrength());
}
} else {
// No existing effect, add a new one
if(strength == -1)
strength = 1;
if(exit->addEffect(effectStr, duration, strength, nullptr, true) != nullptr) {
player->print("Effect '%s' (exit) added with duration %d and strength %d.\n", effectStr.c_str(), duration, strength);
} else {
player->print("Unable to add effect '%s' (exit)\n", effectStr.c_str());
}
}
break;
} else {
exit->setEnter(getFullstrText(cmnd->fullstr, 3));
if(exit->getEnter().empty() || Pueblo::is(exit->getEnter())) {
exit->setEnter("");
player->print("OnEnter cleared.\n");
log_immort(true, player, "%s cleared %s^g's %s.\n", player->getCName(), exit->getCName(), "OnEnter");
} else {
player->print("OnEnter set to \"%s\".\n", exit->getEnter().c_str());
log_immort(true, player, "%s set %s^g's %s to \"%s\".\n", player->getCName(), exit->getCName(), "OnEnter", exit->getEnter().c_str());
}
}
break;
case 'f':
num = cmnd->val[2];
if(num < 1 || num > MAX_EXIT_FLAGS) {
player->print("Error: flag out of range.\n");
return(PROMPT);
}
if(exit->flagIsSet(num - 1)) {
exit->clearFlag(num - 1);
player->printColor("%s^x exit flag #%d off.\n", exit->getCName(), num);
log_immort(true, player, "%s cleared %s^g exit flag #%d(%s) in room %s.\n", player->getCName(), exit->getCName(), num, gConfig->getXFlag(num-1).c_str(),
room->fullName().c_str());
} else {
exit->setFlag(num - 1);
player->printColor("%s^x exit flag #%d on.\n", exit->getCName(), num);
log_immort(true, player, "%s turned on %s^g exit flag #%d(%s) in room %s.\n", player->getCName(), exit->getCName(), num, gConfig->getXFlag(num-1).c_str(),
room->fullName().c_str());
}
break;
case 'k':
if(cmnd->str[1][2] == 'a') {
exit->setKeyArea(cmnd->str[3]);
if(exit->getKeyArea().empty()) {
player->print("Key Area cleared.\n");
log_immort(true, player, "%s cleared %s^g's %s.\n", player->getCName(), exit->getCName(), "Key Area");
} else {
player->print("Key Area set to \"%s\".\n", exit->getKeyArea().c_str());
log_immort(true, player, "%s set %s^g's %s to \"%s\".\n", player->getCName(), exit->getCName(), "Key Area", exit->getKeyArea().c_str());
}
} else {
if(cmnd->val[2] > 255 || cmnd->val[2] < 0) {
player->print("Error: key out of range.\n");
return(0);
}
exit->setKey(cmnd->val[2]);
player->printColor("Exit %s^x key set to %d.\n", exit->getCName(), exit->getKey());
log_immort(true, player, "%s set %s^g's %s to %ld.\n", player->getCName(), exit->getCName(), "Key", exit->getKey());
}
break;
case 'l':
if(cmnd->val[2] > MAXALVL || cmnd->val[2] < 0) {
player->print("Level must be from 0 to %d.\n", MAXALVL);
return(0);
}
exit->setLevel(cmnd->val[2]);
player->printColor("Exit %s^x's level is now set to %d.\n", exit->getCName(), exit->getLevel());
log_immort(true, player, "%s set %s^g's %s to %ld.\n", player->getCName(), exit->getCName(), "Pick Level", exit->getLevel());
break;
case 'o':
exit->setOpen(getFullstrText(cmnd->fullstr, 3));
if(exit->getOpen().empty() || Pueblo::is(exit->getOpen())) {
exit->setOpen("");
player->print("OnOpen cleared.\n");
log_immort(true, player, "%s cleared %s^g's %s.\n", player->getCName(), exit->getCName(), "OnOpen");
} else {
player->print("OnOpen set to \"%s\".\n", exit->getOpen().c_str());
log_immort(true, player, "%s set %s^g's %s to \"%s\".\n", player->getCName(), exit->getCName(), "OnOpen", exit->getOpen().c_str());
}
break;
case 'p':
if(low(cmnd->str[1][2]) == 'p') {
exit->setPassPhrase(getFullstrText(cmnd->fullstr, 3));
if(exit->getPassPhrase().empty()) {
player->print("Passphrase cleared.\n");
log_immort(true, player, "%s cleared %s^g's %s.\n", player->getCName(), exit->getCName(), "Passphrase");
} else {
player->print("Passphrase set to \"%s\".\n", exit->getPassPhrase().c_str());
log_immort(true, player, "%s set %s^g's %s to \"%s\".\n", player->getCName(), exit->getCName(), "Passphrase", exit->getPassPhrase().c_str());
}
} else if(low(cmnd->str[1][2]) == 'l') {
n = cmnd->val[2];
if(n < 0 || n > LANGUAGE_COUNT) {
player->print("Error: pass language out of range.\n");
return(0);
}
n--;
if(n < 0)
n = 0;
exit->setPassLanguage(n);
player->print("Pass language %s.\n", n ? "set" : "cleared");
log_immort(true, player, "%s set %s^g's %s to %s(%ld).\n", player->getCName(), exit->getCName(), "Passlang", n ? get_language_adj(n) : "Nothing", n+1);
} else {
player->print("Passphrase (xpp) or passlang (xpl)?\n");
return(0);
}
break;
case 's':
exit->setSize(getSize(cmnd->str[3]));
player->printColor("%s^x's %s set to %s.\n", exit->getCName(), "Size", getSizeName(exit->getSize()).c_str());
log_immort(true, player, "%s set %s %s^g's %s to %s.\n",
player->getCName(), "exit", exit->getCName(), "Size", getSizeName(exit->getSize()).c_str());
break;
case 't':
n = (short)cmnd->val[2];
if(n > 30000 || n < 0) {
player->print("Must be between 0-30000.\n");
return(0);
}
exit->setToll(n);
player->printColor("Exit %s^x's toll is now set to %d.\n", exit->getCName(), exit->getToll());
log_immort(true, player, "%s set %s^g's %s to %ld.\n", player->getCName(), exit->getCName(), "Toll", exit->getToll());
break;
default:
player->print("Invalid syntax.\n");
return(0);
}
if(player->inUniqueRoom())
player->getUniqueRoomParent()->escapeText();
room_track(player);
return(0);
}
// otherwise, we have other plans for this function
if(cmnd->num < 3) {
player->print("Syntax: *set x <name> <#> [. or name]\n");
return(0);
}
// we need more variables to continue our work
MapMarker mapmarker;
BaseRoom* room2=nullptr;
AreaRoom* aRoom=nullptr;
UniqueRoom *uRoom=nullptr;
Area *area=nullptr;
CatRef cr;
std::string returnExit = getFullstrText(cmnd->fullstr, 4);
getDestination(getFullstrText(cmnd->fullstr, 3).c_str(), &mapmarker, &cr, player);
if(!mapmarker.getArea() && !cr.id) {
// if the expanded exit wasnt found
// and the exit was expanded, check to delete the original
if(room->delExit(cmnd->str[2]))
player->print("Exit %s deleted.\n", cmnd->str[2]);
else
player->print("Exit %s not found.\n", cmnd->str[2]);
return(0);
}
if(cr.id) {
if(!player->checkBuilder(cr))
return(0);
if(!loadRoom(cr, &uRoom)) {
player->print("Room %s does not exist.\n", cr.str().c_str());
return(0);
}
room2 = uRoom;
} else {
if(player->getClass() == CreatureClass::BUILDER) {
player->print("Sorry, builders cannot link exits to the overland.\n");
return(0);
}
area = gServer->getArea(mapmarker.getArea());
if(!area) {
player->print("Area does not exist.\n");
return(0);
}
aRoom = area->loadRoom(nullptr, &mapmarker, false);
room2 = aRoom;
}
std::string newName = getFullstrText(cmnd->fullstr, 2, ' ', false, true);
if(newName.length() > 20) {
player->print("Exit names must be 20 characters or less in length.\n");
return(0);
}
newName = expand_exit_name(newName);
if(!returnExit.empty()) {
if(returnExit == ".")
returnExit = opposite_exit_name(newName);
if(cr.id) {
link_rom(room, cr, newName);
if(player->inUniqueRoom())
link_rom(uRoom, player->getUniqueRoomParent()->info, returnExit);
else
link_rom(uRoom, &player->getAreaRoomParent()->mapmarker, returnExit);
gServer->resaveRoom(cr);
} else {
link_rom(room, &mapmarker, newName);
if(player->inUniqueRoom())
link_rom(aRoom, player->getUniqueRoomParent()->info, returnExit);
else
link_rom(aRoom, &player->getAreaRoomParent()->mapmarker, returnExit);
aRoom->save();
}
log_immort(true, player, "%s linked room %s to room %s in %s^g direction, both ways.\n",
player->getCName(), room->fullName().c_str(), room2->fullName().c_str(), newName.c_str());
player->printColor("Room %s linked to room %s in %s^x direction, both ways.\n",
room->fullName().c_str(), room2->fullName().c_str(), newName.c_str());
} else {
if(cr.id)
link_rom(room, cr, newName);
else
link_rom(room, &mapmarker, newName);
player->printColor("Room %s linked to room %s in %s^x direction.\n",
room->fullName().c_str(), room2->fullName().c_str(), newName.c_str());
log_immort(true, player, "%s linked room %s to room %s in %s^g direction.\n",
player->getCName(), room->fullName().c_str(), room2->fullName().c_str(), newName.c_str());
}
if(player->inUniqueRoom())
gServer->resaveRoom(player->getUniqueRoomParent()->info);
if(aRoom && aRoom->canDelete())
area->remove(aRoom);
room_track(player);
return(0);
}
//*********************************************************************
// room_track
//*********************************************************************
int room_track(Creature* player) {
long t = time(nullptr);
if(player->isMonster() || !player->inUniqueRoom())
return(0);
strcpy(player->getUniqueRoomParent()->last_mod, player->getCName());
strcpy(player->getUniqueRoomParent()->lastModTime, ctime(&t));
return(0);
}
//*********************************************************************
// dmReplace
//*********************************************************************
// this command lets staff replace words or phrases in a room description
int dmReplace(Player* player, cmd* cmnd) {
UniqueRoom *room = player->getUniqueRoomParent();
int n=0, skip=0, skPos=0;
std::string::size_type i=0, pos=0;
char delim = ' ';
bool sdesc=false, ldesc=false;
std::string search = "", temp = "";
if(!needUniqueRoom(player))
return(0);
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Room is not in any of your alotted room ranges.\n");
return(0);
}
if(cmnd->num < 3) {
player->print("syntax: *replace [-SL#<num>] <search> <replace>\n");
return(0);
}
// we have flags!
// let's find out what they are
if(cmnd->str[1][0] == '-') {
i=1;
while(i < strlen(cmnd->str[1])) {
switch(cmnd->str[1][i]) {
case 'l':
ldesc = true;
break;
case 's':
sdesc = true;
break;
case '#':
skip = atoi(&cmnd->str[1][++i]);
break;
default:
break;
}
i++;
}
}
// we need to get fullstr into a nicer format
i = strlen(cmnd->str[0]);
if(ldesc || sdesc || skip)
i += strlen(cmnd->str[1]) + 1;
// which deliminator should we use?
if(cmnd->fullstr[i+1] == '\'' || cmnd->fullstr[i+1] == '"' || cmnd->fullstr[i+1] == '*') {
delim = cmnd->fullstr[i+1];
i++;
}
// fullstr is now our search text and replace text seperated by a space
cmnd->fullstr = cmnd->fullstr.substr(i+1);
//strcpy(cmnd->fullstr, &cmnd->fullstr[i+1]);
// we search until we find the deliminator we're looking for
pos=0;
i = cmnd->fullstr.length();
while(pos < i) {
if(cmnd->fullstr[pos] == delim)
break;
pos++;
}
if(pos == i) {
if(delim != ' ')
player->print("Deliminator not found.\n");
else
player->print("No replace text found.\n");
return(0);
}
// cut the string apart
cmnd->fullstr[pos] = 0;
search = cmnd->fullstr;
// if it's not a space, we need to add 2 to get rid of the space and
// next deliminator
if(delim != ' ') {
pos += 2;
// although we don't have to, we're enforcing that the deliminators
// equal each other so people are consistent with the usage of this function
if(cmnd->fullstr[pos] != delim) {
player->print("Deliminators do not match up.\n");
return(0);
}
}
// fullstr now has our replace text
//strcpy(cmnd->fullstr, &cmnd->fullstr[pos+1]);
cmnd->fullstr = cmnd->fullstr.substr(pos+1);
if(delim != ' ') {
if(cmnd->fullstr[cmnd->fullstr.length()-1] != delim) {
player->print("Deliminators do not match up.\n");
return(0);
}
cmnd->fullstr[cmnd->fullstr.length()-1] = 0;
}
// the text we are searching for is in "search"
// the text we are replacing it with is in "fullstr"
// we will use i to help us reuse code
// 0 = sdesc, 1 = ldesc
i = 0;
// if only long desc, skip short desc
if(ldesc && !sdesc)
i++;
// loop for the short and long desc
do {
// loop for skip
do {
if(!i)
n = room->getShortDescription().find(search.c_str(), skPos);
else
n = room->getLongDescription().find(search.c_str(), skPos);
if(n >= 0) {
if(--skip > 0)
skPos = n + 1;
else {
if(!i) {
temp = room->getShortDescription().substr(0, n);
temp += cmnd->fullstr;
temp += room->getShortDescription().substr(n + search.length(), room->getShortDescription().length());
room->setShortDescription(temp);
} else {
temp = room->getLongDescription().substr(0, n);
temp += cmnd->fullstr;
temp += room->getLongDescription().substr(n + search.length(), room->getLongDescription().length());
room->setLongDescription(temp);
}
player->print("Replaced.\n");
room->escapeText();
return(0);
}
}
} while(n >= 0 && skip);
// if we're on long desc (i=1), we'll stop after this, so no worries
// if we're on short desc and not doing long desc, we need to stop
if(sdesc && !ldesc)
i++;
i++;
} while(i<2);
player->print("Pattern not found.\n");
return(0);
}
//*********************************************************************
// dmDelete
//*********************************************************************
// Allows staff to delete some/all of the room description
int dmDelete(Player* player, cmd* cmnd) {
UniqueRoom *room = player->getUniqueRoomParent();
int pos=0;
int unsigned i=0;
bool sdesc=false, ldesc=false, phrase=false, after=false;
if(!needUniqueRoom(player))
return(0);
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Room is not in any of your alotted room ranges.\n");
return(0);
}
if(cmnd->num < 2) {
player->print("syntax: *delete [-ASLPE] <delete_word>\n");
return(0);
}
// take care of the easy one
if(!strcmp(cmnd->str[1], "-a")) {
room->setShortDescription("");
room->setLongDescription("");
} else {
// determine our flags
i=1;
while(i < strlen(cmnd->str[1])) {
switch(cmnd->str[1][i]) {
case 'l':
ldesc = true;
break;
case 's':
sdesc = true;
break;
case 'p':
phrase = true;
break;
case 'e':
after = true;
break;
default:
break;
}
i++;
}
// a simple delete operation
if(!phrase && !after) {
if(sdesc)
room->setShortDescription("");
if(ldesc)
room->setLongDescription("");
if(!sdesc && !ldesc) {
player->print("Invalid syntax.\n");
return(0);
}
} else {
// we need to figure out what our phrase is
// turn fullstr into what we want to delete
i = strlen(cmnd->str[0]) + strlen(cmnd->str[1]) + 1;
if( i >= cmnd->fullstr.length() ) {
player->print("Pattern not found.\n");
return(0);
}
// fullstr is now our phrase
cmnd->fullstr = cmnd->fullstr.substr(i+1);
// we will use i to help us reuse code
// 0 = sdesc, 1 = ldesc
i = 0;
// if only long desc, skip short desc
if(ldesc && !sdesc)
i++;
// loop!
do {
if(!i)
pos = room->getShortDescription().find(cmnd->fullstr);
else
pos = room->getLongDescription().find(cmnd->fullstr);
if(pos >= 0)
break;
// if we're on long desc (i=1), we'll stop after this, so no worries
// if we're on short desc and not doing long desc, we need to stop
if(sdesc && !ldesc)
i++;
i++;
} while(i<2);
// did we find it?
if(pos < 0) {
player->print("Pattern not found.\n");
return(0);
}
// we delete everything after the phrase
if(after) {
if(!phrase)
pos += cmnd->fullstr.length();
// if it's in the short desc, and they wanted to delete
// from both short and long, then delete all of long
if(!i && !(sdesc ^ ldesc))
room->setLongDescription("");
if(!i)
room->setShortDescription(room->getShortDescription().substr(0, pos));
else
room->setLongDescription(room->getLongDescription().substr(0, pos));
// only delete the phrase
} else {
if(!i)
room->setShortDescription(room->getShortDescription().substr(0, pos) + room->getShortDescription().substr(pos + cmnd->fullstr.length(), room->getShortDescription().length()));
else
room->setLongDescription(room->getLongDescription().substr(0, pos) + room->getLongDescription().substr(pos + cmnd->fullstr.length(), room->getLongDescription().length()));
}
} // phrase && after
} // *del -A
log_immort(true, player, "%s deleted description in room %s.\n", player->getCName(),
player->getUniqueRoomParent()->info.str().c_str());
player->print("Deleted.\n");
return(0);
}
//*********************************************************************
// dmNameRoom
//*********************************************************************
int dmNameRoom(Player* player, cmd* cmnd) {
if(!needUniqueRoom(player))
return(0);
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Room is not in any of your alotted room ranges.\n");
return(0);
}
std::string name = getFullstrText(cmnd->fullstr, 1);
if(name.empty() || Pueblo::is(name)) {
player->print("Rename room to what?\n");
return(0);
}
if(name.length() > 79)
name = name.substr(0, 79);
player->getUniqueRoomParent()->setName(name);
log_immort(true, player, "%s renamed room %s.\n", player->getCName(), player->getRoomParent()->fullName().c_str());
player->print("Done.\n");
return(0);
}
//*********************************************************************
// dmDescription
//*********************************************************************
// Allows a staff to add the given text to the room description.
int dmDescription(Player* player, cmd* cmnd, bool append) {
UniqueRoom *room = player->getUniqueRoomParent();
int unsigned i=0;
bool sdesc=false, newline=false;
if(!needUniqueRoom(player))
return(0);
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Room is not in any of your alotted room ranges.\n");
return(0);
}
if(cmnd->num < 2) {
player->print("syntax: *%s [-sn] <text>\n", append ? "append" : "prepend");
return(0);
}
// turn fullstr into what we want to append
i = strlen(cmnd->str[0]);
sdesc = cmnd->str[1][0] == '-' && (cmnd->str[1][1] == 's' || cmnd->str[1][2] == 's');
newline = !(cmnd->str[1][0] == '-' && (cmnd->str[1][1] == 'n' || cmnd->str[1][2] == 'n'));
// keep chopping
if(sdesc || !newline)
i += strlen(cmnd->str[1]) + 1;
cmnd->fullstr = cmnd->fullstr.substr(i+1);
// strcpy(cmnd->fullstr, &cmnd->fullstr[i+1]);
if(cmnd->fullstr.find(" ") != std::string::npos)
player->printColor("Do not use double spaces in room descriptions! Use ^W*wrap^x to fix this.\n");
if(sdesc) {
// short descriptions
newline = newline && !room->getShortDescription().empty();
if(append) {
room->appendShortDescription(newline ? "\n" : "");
room->appendShortDescription(cmnd->fullstr);
} else {
if(newline)
cmnd->fullstr += "\n";
room->setShortDescription(cmnd->fullstr + room->getShortDescription());
}
player->print("Short description %s.\n", append ? "appended" : "prepended");
} else {
// long descriptions
newline = newline && !room->getLongDescription().empty();
if(append) {
room->appendLongDescription(newline ? "\n" : "");
room->appendLongDescription(cmnd->fullstr);
} else {
if(newline)
cmnd->fullstr += "\n";
room->setLongDescription(cmnd->fullstr + room->getLongDescription());
}
player->print("Long description %s.\n", append ? "appended" : "prepended");
}
player->getUniqueRoomParent()->escapeText();
log_immort(true, player, "%s descripted in room %s.\n", player->getCName(),
player->getUniqueRoomParent()->info.str().c_str());
return(0);
}
//*********************************************************************
// dmAppend
//*********************************************************************
int dmAppend(Player* player, cmd* cmnd) {
return(dmDescription(player, cmnd, true));
}
//*********************************************************************
// dmPrepend
//*********************************************************************
int dmPrepend(Player* player, cmd* cmnd) {
return(dmDescription(player, cmnd, false));
}
//*********************************************************************
// dmMobList
//*********************************************************************
// Display information about what mobs will randomly spawn.
void showMobList(Player* player, WanderInfo *wander, std::string_view type) {
std::map<int, CatRef>::iterator it;
Monster *monster=nullptr;
bool found=false, maybeAggro=false;
std::ostringstream oStr;
for(it = wander->random.begin(); it != wander->random.end() ; it++) {
if(!found)
oStr << "^cTraffic = " << wander->getTraffic() << "\n";
found=true;
if(!(*it).second.id)
continue;
if(!loadMonster((*it).second, &monster))
continue;
if(monster->flagIsSet(M_AGGRESSIVE))
oStr << "^r";
else {
maybeAggro = monster->flagIsSet(M_AGGRESSIVE_EVIL) ||
monster->flagIsSet(M_AGGRESSIVE_GOOD) ||
monster->flagIsSet(M_AGGRESSIVE_AFTER_TALK) ||
monster->flagIsSet(M_CLASS_AGGRO_INVERT) ||
monster->flagIsSet(M_RACE_AGGRO_INVERT) ||
monster->flagIsSet(M_DEITY_AGGRO_INVERT);
if(!maybeAggro) {
RaceDataMap::iterator rIt;
for(rIt = gConfig->races.begin() ; rIt != gConfig->races.end() ; rIt++) {
if(monster->isRaceAggro((*rIt).second->getId(), false)) {
maybeAggro = true;
break;
}
}
}
if(!maybeAggro) {
for(int n=1; n<static_cast<int>(STAFF); n++) {
if(monster->isClassAggro(n, false)) {
maybeAggro = true;
break;
}
}
}
if(!maybeAggro) {
DeityDataMap::iterator dIt;
for(dIt = gConfig->deities.begin() ; dIt != gConfig->deities.end() ; dIt++) {
if(monster->isDeityAggro((*dIt).second->getId(), false)) {
maybeAggro = true;
break;
}
}
}
if(maybeAggro)
oStr << "^y";
else
oStr << "^g";
}
oStr << "Slot " << std::setw(2) << (*it).first+1 << ": " << monster->getName() << " "
<< "[" << monType::getName(monster->getType()) << ":" << monType::getHitdice(monster->getType()) << "HD]\n"
<< " ^x[I:" << monster->info.str() << " L:" << monster->getLevel()
<< " X:" << monster->getExperience() << " G:" << monster->coins[GOLD]
<< " H:" << monster->hp.getMax() << " M:" << monster->mp.getMax()
<< " N:" << (monster->getNumWander() ? monster->getNumWander() : 1)
<< (monster->getAlignment() > 0 ? "^g" : "") << (monster->getAlignment() < 0 ? "^r" : "")
<< " A:" << monster->getAlignment()
<< "^x D:" << monster->damage.average() << "]\n";
free_crt(monster);
}
if(!found)
oStr << " No random monsters currently come in this " << type << ".";
player->printColor("%s\n", oStr.str().c_str());
}
int dmMobList(Player* player, cmd* cmnd) {
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: Room number not inside any of your alotted ranges.\n");
return(0);
}
player->print("Random monsters which come in this room:\n");
if(player->inUniqueRoom())
showMobList(player, &player->getUniqueRoomParent()->wander, "room");
else if(player->inAreaRoom()) {
Area* area = player->getAreaRoomParent()->area;
std::list<AreaZone*>::iterator it;
AreaZone *zone=nullptr;
for(it = area->zones.begin() ; it != area->zones.end() ; it++) {
zone = (*it);
if(zone->inside(area, &player->getAreaRoomParent()->mapmarker)) {
player->print("Zone: %s\n", zone->name.c_str());
showMobList(player, &zone->wander, "zone");
}
}
TileInfo* tile = area->getTile(area->getTerrain(nullptr, &player->getAreaRoomParent()->mapmarker, 0, 0, 0, true),
area->getSeasonFlags(&player->getAreaRoomParent()->mapmarker));
if(tile && tile->wander.getTraffic()) {
player->print("Tile: %s\n", tile->getName().c_str());
showMobList(player, &tile->wander, "tile");
}
}
return(0);
}
//*********************************************************************
// dmWrap
//*********************************************************************
// dmWrap will either wrap the short or long desc of a room to the
// specified length, for sanity, a range of 60 - 78 chars is the limit.
int dmWrap(Player* player, cmd* cmnd) {
UniqueRoom *room = player->getUniqueRoomParent();
int wrap=0;
bool err=false, which=false;
std::string text = "";
if(!needUniqueRoom(player))
return(0);
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Room is not in any of your alotted room ranges.\n");
return(0);
}
// parse the input command for syntax/range problems
if(cmnd->num < 2)
err = true;
else {
switch(cmnd->str[1][0]) {
case 'l':
which = true;
text = room->getLongDescription();
break;
case 's':
which = false;
text = room->getShortDescription();
break;
default:
err = true;
break;
}
if(!err) {
wrap = cmnd->val[1];
if(wrap < 60 || wrap > 78)
err = true;
}
}
if(err) {
player->print("*wrap <s | l> <len> where len is between 60 and 78 >\n");
return(0);
}
if((!which && room->getShortDescription().empty()) || (which && room->getLongDescription().empty())) {
player->print("No text to wrap!\n");
return(0);
}
// adjust!
wrap++;
// replace!
if(!which)
room->setShortDescription(wrapText(room->getShortDescription(), wrap));
else
room->setLongDescription(wrapText(room->getLongDescription(), wrap));
player->print("Text wrapped.\n");
player->getUniqueRoomParent()->escapeText();
log_immort(false, player, "%s wrapped the description in room %s.\n", player->getCName(), player->getRoomParent()->fullName().c_str());
return(0);
}
//*********************************************************************
// dmDeleteAllExits
//*********************************************************************
int dmDeleteAllExits(Player* player, cmd* cmnd) {
if(player->getRoomParent()->exits.empty()) {
player->print("No exits to delete.\n");
return(0);
}
player->getRoomParent()->clearExits();
// sorry, can't delete exits in overland
if(player->inAreaRoom())
player->getAreaRoomParent()->updateExits();
player->print("All exits deleted.\n");
log_immort(true, player, "%s deleted all exits in room %s.\n", player->getCName(), player->getRoomParent()->fullName().c_str());
room_track(player);
return(0);
}
//*********************************************************************
// exit_ordering
//*********************************************************************
// 1 mean exit2 goes in front of exit1
// 0 means keep looking
int exit_ordering(const char *exit1, const char *exit2) {
// always skip if they're the same name
if(!strcmp(exit1, exit2)) return(0);
// north east south west
if(!strcmp(exit1, "north")) return(0);
if(!strcmp(exit2, "north")) return(1);
if(!strcmp(exit1, "east")) return(0);
if(!strcmp(exit2, "east")) return(1);
if(!strcmp(exit1, "south")) return(0);
if(!strcmp(exit2, "south")) return(1);
if(!strcmp(exit1, "west")) return(0);
if(!strcmp(exit2, "west")) return(1);
// northeast northwest southeast southwest
if(!strcmp(exit1, "northeast")) return(0);
if(!strcmp(exit2, "northeast")) return(1);
if(!strcmp(exit1, "northwest")) return(0);
if(!strcmp(exit2, "northwest")) return(1);
if(!strcmp(exit1, "southeast")) return(0);
if(!strcmp(exit2, "southeast")) return(1);
if(!strcmp(exit1, "southwest")) return(0);
if(!strcmp(exit2, "southwest")) return(1);
if(!strcmp(exit1, "up")) return(0);
if(!strcmp(exit2, "up")) return(1);
if(!strcmp(exit1, "down")) return(0);
if(!strcmp(exit2, "down")) return(1);
// alphabetic
return strcmp(exit1, exit2) > 0 ? 1 : 0;
}
//*********************************************************************
// dmArrangeExits
//*********************************************************************
bool exitCompare( const Exit* left, const Exit* right ){
return(!exit_ordering(left->getCName(), right->getCName()));
}
void BaseRoom::arrangeExits(Player* player) {
if(exits.size() <= 1) {
if(player)
player->print("No exits to rearrange!\n");
return;
}
exits.sort(exitCompare);
if(player)
player->print("Exits rearranged!\n");
}
int dmArrangeExits(Player* player, cmd* cmnd) {
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Error: Room number not inside any of your alotted ranges.\n");
return(0);
}
player->getRoomParent()->arrangeExits(player);
return(0);
}
//*********************************************************************
// link_rom
//*********************************************************************
// from this room to unique room
void link_rom(BaseRoom* room, const Location& l, std::string_view str) {
for(Exit* ext : room->exits) {
if(ext->getName() == str) {
ext->target = l;
return;
}
}
Exit* exit = new Exit;
exit->setRoom(room);
exit->setName(str);
exit->target = l;
room->exits.push_back(exit);
}
void link_rom(BaseRoom* room, short tonum, std::string_view str) {
Location l;
l.room.id = tonum;
link_rom(room, l, str);
}
void link_rom(BaseRoom* room, const CatRef& cr, std::string_view str) {
Location l;
l.room = cr;
link_rom(room, l, str);
}
void link_rom(BaseRoom* room, MapMarker *mapmarker, std::string_view str) {
Location l;
l.mapmarker = *mapmarker;
link_rom(room, l, str);
}
//*********************************************************************
// dmFix
//*********************************************************************
int dmFix(Player* player, cmd* cmnd, std::string_view name, char find, char replace) {
Exit *exit=nullptr;
int i=0;
bool fixed=false;
if(cmnd->num < 2) {
player->bPrint(fmt::format("Syntax: *{}up <exit>\n", name));
return(0);
}
exit = findExit(player, cmnd);
if(!exit) {
player->print("You don't see that exit.\n");
return(0);
}
std::string newName = exit->getName();
for(i=newName.length(); i>0; i--) {
if(newName[i] == find) {
newName[i] = replace;
fixed = true;
}
}
if(fixed) {
exit->setName(newName);
log_immort(true, player, fmt::format("{} {}ed the exit '{}' in room {}.\n",
player->getName(), name, exit->getName(), player->getRoomParent()->fullName()).c_str());
player->print("Done.\n");
} else
player->print("Couldn't find any underscores.\n");
return(0);
}
//*********************************************************************
// dmUnfixExit
//*********************************************************************
int dmUnfixExit(Player* player, cmd* cmnd) {
return(dmFix(player, cmnd, "unfix", ' ', '_'));
}
//*********************************************************************
// dmFixExit
//*********************************************************************
int dmFixExit(Player* player, cmd* cmnd) {
return(dmFix(player, cmnd, "fix", '_', ' '));
}
//*********************************************************************
// dmRenameExit
//*********************************************************************
int dmRenameExit(Player* player, cmd* cmnd) {
Exit *exit=nullptr;
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Room is not in any of your alotted room ranges.\n");
return(0);
}
if(cmnd->num < 3) {
player->print("Syntax: *xrename <old exit>[#] <new exit>\n");
return(0);
}
exit = findExit(player, cmnd);
if(!exit) {
player->print("There is no exit here by that name.\n");
return(0);
}
std::string newName = getFullstrText(cmnd->fullstr, 2);
if(newName.length() > 20) {
player->print("New exit name must be 20 characters or less in length.\n");
return(0);
}
player->printColor("Exit \"%s^x\" renamed to \"%s^x\".\n", exit->getCName(), newName.c_str());
log_immort(false, player, "%s renamed exit %s^g to %s^g in room %s.\n",
player->getCName(), exit->getCName(), newName.c_str(), player->getRoomParent()->fullName().c_str());
room_track(player);
if(getDir(newName) != NoDirection)
exit->setDirection(NoDirection);
exit->setName( newName.c_str());
return(0);
}
//*********************************************************************
// dmDestroyRoom
//*********************************************************************
int dmDestroyRoom(Player* player, cmd* cmnd) {
if(!player->inUniqueRoom()) {
player->print("Error: You need to be in a unique room to do that.\n");
return(0);
}
if(!player->checkBuilder(player->getUniqueRoomParent())) {
player->print("Room is not in any of your alotted room ranges.\n");
return(0);
}
if( player->getUniqueRoomParent()->info.isArea("test") &&
player->getUniqueRoomParent()->info.id == 1
) {
player->print("Sorry, you cannot destroy this room.\n");
player->print("It is the Builder Waiting Room.\n");
return(0);
}
if(player->bound.room == player->currentLocation.room) {
player->print("Sorry, you cannot destroy this room.\n");
player->print("It is your bound room.\n");
return(0);
}
std::map<std::string, StartLoc*>::iterator sIt;
for(sIt = gConfig->start.begin() ; sIt != gConfig->start.end() ; sIt++) {
if( player->getUniqueRoomParent()->info == (*sIt).second->getBind().room ||
player->getUniqueRoomParent()->info == (*sIt).second->getRequired().room
) {
player->print("Sorry, you cannot destroy this room.\n");
player->print("It is important to starting locations.\n");
return(0);
}
}
std::list<CatRefInfo*>::const_iterator crIt;
for(crIt = gConfig->catRefInfo.begin() ; crIt != gConfig->catRefInfo.end() ; crIt++) {
if(player->getUniqueRoomParent()->info.isArea((*crIt)->getArea())) {
if((*crIt)->getLimbo() == player->getUniqueRoomParent()->info.id) {
player->print("Sorry, you cannot destroy this room.\n");
player->print("It is a Limbo room.\n");
return(0);
}
if((*crIt)->getRecall() == player->getUniqueRoomParent()->info.id) {
player->print("Sorry, you cannot destroy this room.\n");
player->print("It is a recall room.\n");
return(0);
}
}
}
log_immort(true, player, "%s destroyed room %s.\n",
player->getCName(), player->getRoomParent()->fullName().c_str());
player->getUniqueRoomParent()->destroy();
return(0);
}
//*********************************************************************
// findRoomsWithFlag
//*********************************************************************
void findRoomsWithFlag(const Player* player, const Range& range, int flag) {
Async async;
if(async.branch(player, ChildType::PRINT) == AsyncExternal) {
std::ostringstream oStr;
bool found = false;
if(range.low.id <= range.high) {
UniqueRoom* room=nullptr;
CatRef cr;
int high = range.high;
cr.setArea(range.low.area);
cr.id = range.low.id;
if(range.low.id == -1 && range.high == -1) {
cr.id = 1;
high = RMAX;
}
for(; cr.id < high; cr.id++) {
if(!loadRoom(cr, &room))
continue;
if(room->flagIsSet(flag)) {
if(player->isStaff())
oStr << room->info.rstr() << " - ";
oStr << room->getName() << "^x\n";
found = true;
}
}
}
std::cout << "^YLocations found:^x\n";
if(!found) {
std::cout << "No available locations were found.";
} else {
std::cout << oStr.str();
}
exit(0);
}
}
void findRoomsWithFlag(const Player* player, CatRef area, int flag) {
Async async;
if(async.branch(player, ChildType::PRINT) == AsyncExternal) {
struct dirent *dirp=nullptr;
DIR *dir=nullptr;
std::ostringstream oStr;
bool found = false;
char filename[250];
UniqueRoom *room=nullptr;
// This tells us just to get the path, not the file,
// and tells loadRoomFromFile to ignore the CatRef
area.id = -1;
std::string path = roomPath(area);
if((dir = opendir(path.c_str())) != nullptr) {
while((dirp = readdir(dir)) != nullptr) {
// is this a room file?
if(dirp->d_name[0] == '.')
continue;
sprintf(filename, "%s/%s", path.c_str(), dirp->d_name);
if(!loadRoomFromFile(area, &room, filename))
continue;
if(room->flagIsSet(flag)) {
if(player->isStaff())
oStr << room->info.rstr() << " - ";
oStr << room->getName() << "^x\n";
found = true;
}
// TODO: Memleak (even though it is forked), room is not deleted
}
}
std::cout << "^YLocations found:^x\n";
if(!found) {
std::cout << "No available locations were found.";
} else {
std::cout << oStr.str();
}
exit(0);
}
}
//*********************************************************************
// dmFind
//*********************************************************************
int dmFind(Player* player, cmd* cmnd) {
std::string type = getFullstrText(cmnd->fullstr, 1);
CatRef cr;
if(player->inUniqueRoom())
cr = player->getUniqueRoomParent()->info;
else
cr.setArea("area");
if(type == "r")
type = "room";
else if(type == "o")
type = "object";
else if(type == "m")
type = "monster";
if(type.empty() || (type != "room" && type != "object" && type != "monster")) {
if(!type.empty())
player->print("\"%s\" is not a valid type.\n", type.c_str());
player->print("Search for next available of the following: room, object, monster.\n");
return(0);
}
if(!player->checkBuilder(cr)) {
player->print("Error: this area is out of your range; you cannot *find here.\n");
return(0);
}
if(type == "monster" && !player->canBuildMonsters()) {
player->print("Error: you cannot work with monsters.\n");
return(0);
}
if(type == "object" && !player->canBuildObjects()) {
player->print("Error: you cannot work with objects.\n");
return(0);
}
Async async;
if(async.branch(player, ChildType::PRINT) == AsyncExternal) {
cr = findNextEmpty(type, cr.area);
std::cout << "^YNext available " << type << " in area " << cr.area << "^x\n";
if(cr.id == -1)
std::cout << "No empty %ss found.", type.c_str();
else {
std::cout << cr.rstr();
}
exit(0);
} else {
player->printColor("Searching for next available %s in ^W%s^x.\n", type.c_str(), cr.area.c_str());
}
return(0);
}
//*********************************************************************
// findNextEmpty
//*********************************************************************
// searches for the next empty room/object/monster in the area
CatRef findNextEmpty(const std::string &type, const std::string &area) {
CatRef cr;
cr.setArea(area);
if(type == "room") {
UniqueRoom* room=nullptr;
for(cr.id = 1; cr.id < RMAX; cr.id++)
if(!loadRoom(cr, &room))
return(cr);
} else if(type == "object") {
Object *object=nullptr;
for(cr.id = 1; cr.id < OMAX; cr.id++) {
if(!loadObject(cr, &object))
return(cr);
else
delete object;
}
} else if(type == "monster") {
Monster *monster=nullptr;
for(cr.id = 1; cr.id < MMAX; cr.id++) {
if(!loadMonster(cr, &monster))
return(cr);
else
free_crt(monster);
}
}
// -1 indicates failure
cr.id = -1;
return(cr);
}
//*********************************************************************
// save
//*********************************************************************
void AreaRoom::save(Player* player) const {
char filename[256];
sprintf(filename, "%s/%d/", Path::AreaRoom, area->id);
Path::checkDirExists(filename);
strcat(filename, mapmarker.filename().c_str());
if(!canSave()) {
if(file_exists(filename)) {
if(player)
player->print("Restoring this room to generic status.\n");
unlink(filename);
} else {
if(player)
player->print("There is no reason to save this room!\n\n");
}
return;
}
// record rooms saved during swap
if(gConfig->swapIsInteresting(this))
gConfig->swapLog((std::string)"a" + mapmarker.str(), false);
xmlDocPtr xmlDoc;
xmlNodePtr rootNode, curNode;
xmlDoc = xmlNewDoc(BAD_CAST "1.0");
rootNode = xmlNewDocNode(xmlDoc, nullptr, BAD_CAST "AreaRoom", nullptr);
xmlDocSetRootElement(xmlDoc, rootNode);
unique.save(rootNode, "Unique", false);
xml::saveNonZeroNum(rootNode, "NeedsCompass", needsCompass);
xml::saveNonZeroNum(rootNode, "DecCompass", decCompass);
effects.save(rootNode, "Effects");
hooks.save(rootNode, "Hooks");
curNode = xml::newStringChild(rootNode, "MapMarker");
mapmarker.save(curNode);
curNode = xml::newStringChild(rootNode, "Exits");
saveExitsXml(curNode);
xml::saveFile(filename, xmlDoc);
xmlFreeDoc(xmlDoc);
if(player)
player->print("Room saved.\n");
}
| RealmsMud/RealmsCode | staff/dmroom.cpp | C++ | agpl-3.0 | 114,289 | [
30522,
1013,
1008,
1008,
1040,
2213,
9954,
1012,
18133,
2361,
1008,
3095,
4972,
3141,
2000,
4734,
1012,
1008,
1035,
1035,
1035,
1035,
1035,
1008,
1064,
1035,
1032,
1035,
1035,
1035,
1035,
1035,
1035,
1064,
1064,
1035,
1035,
1035,
1035,
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... |
/* Generated by camel build tools - do NOT edit this file! */
package org.apache.camel.component.nats;
import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.util.CaseInsensitiveMap;
import org.apache.camel.support.component.PropertyConfigurerSupport;
/**
* Generated by camel build tools - do NOT edit this file!
*/
@SuppressWarnings("unchecked")
public class NatsComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
private static final Map<String, Object> ALL_OPTIONS;
static {
Map<String, Object> map = new CaseInsensitiveMap();
map.put("servers", java.lang.String.class);
map.put("verbose", boolean.class);
map.put("bridgeErrorHandler", boolean.class);
map.put("lazyStartProducer", boolean.class);
map.put("basicPropertyBinding", boolean.class);
map.put("useGlobalSslContextParameters", boolean.class);
ALL_OPTIONS = map;
}
@Override
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
NatsComponent target = (NatsComponent) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "basicpropertybinding":
case "basicPropertyBinding": target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); return true;
case "bridgeerrorhandler":
case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
case "servers": target.setServers(property(camelContext, java.lang.String.class, value)); return true;
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": target.setUseGlobalSslContextParameters(property(camelContext, boolean.class, value)); return true;
case "verbose": target.setVerbose(property(camelContext, boolean.class, value)); return true;
default: return false;
}
}
@Override
public Map<String, Object> getAllOptions(Object target) {
return ALL_OPTIONS;
}
@Override
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
NatsComponent target = (NatsComponent) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "basicpropertybinding":
case "basicPropertyBinding": return target.isBasicPropertyBinding();
case "bridgeerrorhandler":
case "bridgeErrorHandler": return target.isBridgeErrorHandler();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
case "servers": return target.getServers();
case "useglobalsslcontextparameters":
case "useGlobalSslContextParameters": return target.isUseGlobalSslContextParameters();
case "verbose": return target.isVerbose();
default: return null;
}
}
}
| alvinkwekel/camel | components/camel-nats/src/generated/java/org/apache/camel/component/nats/NatsComponentConfigurer.java | Java | apache-2.0 | 3,229 | [
30522,
1013,
1008,
7013,
2011,
19130,
3857,
5906,
1011,
2079,
2025,
10086,
2023,
5371,
999,
1008,
1013,
7427,
8917,
1012,
15895,
1012,
19130,
1012,
6922,
1012,
14085,
2015,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
4949,
1025,
12324,
8917... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# escape=`
FROM mcr.microsoft.com/windows/servercore as msi
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV MONGO_VERSION 3.4.5
ENV MONGO_DOWNLOAD_URL https://downloads.mongodb.com/win32/mongodb-win32-x86_64-enterprise-windows-64-${MONGO_VERSION}-signed.msi
ENV MONGO_DOWNLOAD_SHA256 cda1c8d547fc6051d7bbe2953f9a75bced846ac64a733726f8443835db5b2901
RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL)
RUN Invoke-WebRequest -Uri $env:MONGO_DOWNLOAD_URL -OutFile 'mongodb.msi'
RUN Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256)
RUN if ((Get-FileHash mongodb.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { `
Write-Host 'FAILED!'; `
exit 1; `
}
RUN Start-Process msiexec.exe -ArgumentList '/i', 'mongodb.msi', '/quiet', '/norestart', 'INSTALLLOCATION=C:\mongodb', 'ADDLOCAL=Server,Client,MonitoringTools,ImportExportTools,MiscellaneousTools' -NoNewWindow -Wait
RUN Remove-Item C:\mongodb\bin\*.pdb
FROM mcr.microsoft.com/windows/nanoserver:sac2016
COPY --from=msi C:\mongodb\ C:\mongodb\
COPY --from=msi C:\windows\system32\msvcp140.dll C:\windows\system32
COPY --from=msi C:\windows\system32\vcruntime140.dll C:\windows\system32
COPY --from=msi C:\windows\system32\wininet.dll C:\windows\system32
RUN mkdir C:\data\db & setx /m PATH %PATH%;C:\mongodb\bin
VOLUME C:\data\db
EXPOSE 27017
CMD ["mongod.exe"]
| StefanScherer/dockerfiles-windows | mongo/3.4/enterprise/Dockerfile | Dockerfile | mit | 1,448 | [
30522,
1001,
4019,
1027,
1036,
2013,
11338,
2099,
1012,
7513,
1012,
4012,
1013,
3645,
1013,
8241,
17345,
2004,
5796,
2072,
5806,
1031,
1000,
4204,
18223,
1000,
1010,
1000,
1011,
3094,
1000,
1010,
1000,
1002,
7561,
18908,
3258,
28139,
25523,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_72) on Mon Jul 13 21:12:18 UTC 2015 -->
<title>SOFTDeferredUpdates (LWJGL 3.0.0a)</title>
<meta name="date" content="2015-07-13">
<link rel="stylesheet" type="text/css" href="../../../javadoc.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="SOFTDeferredUpdates (LWJGL 3.0.0a)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../org/lwjgl/openal/SOFTBufferSubData.html" title="class in org.lwjgl.openal"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../org/lwjgl/openal/SOFTDirectChannels.html" title="class in org.lwjgl.openal"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/lwjgl/openal/SOFTDeferredUpdates.html" target="_top">Frames</a></li>
<li><a href="SOFTDeferredUpdates.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>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li><a href="#field_summary">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li><a href="#field_detail">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.lwjgl.openal</div>
<h2 title="Class SOFTDeferredUpdates" class="title">Class SOFTDeferredUpdates</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.lwjgl.openal.SOFTDeferredUpdates</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="strong">SOFTDeferredUpdates</span>
extends java.lang.Object</pre>
<div class="block">Native bindings to the <a href="http://kcat.strangesoft.net/openal-extensions/SOFT_deferred_updates.txt">SOFT_deferred_updates</a> extension.
<p>This extension allows applications to defer playback state updates. With unextended OpenAL, the playback state would respond to changes as soon as it
could handle them, which makes it effectively impossible to ensure multiple changes occur at the same time without the potential of a "partial" update
(where one change is heard without the other). This extension provides a way to prevent state updates from occuring until they've all been done, where
they will all apply at once.</p></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html#AL_DEFERRED_UPDATES_SOFT">AL_DEFERRED_UPDATES_SOFT</a></strong></code>
<div class="block">Accepted by the <code>paramName</code> parameter of alGetBoolean, alGetBooleanv (as well as the Integer, Float, and Double variants).</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html#alDeferUpdatesSOFT()">alDeferUpdatesSOFT</a></strong>()</code>
<div class="block">Sometimes it is desirable to ensure multiple state changes take effect at the same time.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html#alProcessUpdatesSOFT()">alProcessUpdatesSOFT</a></strong>()</code>
<div class="block">Resumes updates.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html" title="class in org.lwjgl.openal">SOFTDeferredUpdates</a></code></td>
<td class="colLast"><code><strong><a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html#getInstance()">getInstance</a></strong>()</code>
<div class="block">Returns the <a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html" title="class in org.lwjgl.openal"><code>SOFTDeferredUpdates</code></a> instance for the current context.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="AL_DEFERRED_UPDATES_SOFT">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>AL_DEFERRED_UPDATES_SOFT</h4>
<pre>public static final int AL_DEFERRED_UPDATES_SOFT</pre>
<div class="block">Accepted by the <code>paramName</code> parameter of alGetBoolean, alGetBooleanv (as well as the Integer, Float, and Double variants).</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../constant-values.html#org.lwjgl.openal.SOFTDeferredUpdates.AL_DEFERRED_UPDATES_SOFT">Constant Field Values</a></dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getInstance()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInstance</h4>
<pre>public static <a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html" title="class in org.lwjgl.openal">SOFTDeferredUpdates</a> getInstance()</pre>
<div class="block">Returns the <a href="../../../org/lwjgl/openal/SOFTDeferredUpdates.html" title="class in org.lwjgl.openal"><code>SOFTDeferredUpdates</code></a> instance for the current context.</div>
</li>
</ul>
<a name="alDeferUpdatesSOFT()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>alDeferUpdatesSOFT</h4>
<pre>public static void alDeferUpdatesSOFT()</pre>
<div class="block">Sometimes it is desirable to ensure multiple state changes take effect at the same time. Normally this isn't possible due to the AL processing updates
asychronously, so the playback state can be updated with only part of the changes having been specified. An application can prevent these updates by
calling this function.
<p>When called, samples will continue to render and be sent to the output device, but the effects of changing playback properties, such as the source or
listener gain, or auxiliary slot gain or effect if EFX is supported, among others, will be deferred. Multiple changes can be batched so that they all
apply at once at a later time.</p></div>
</li>
</ul>
<a name="alProcessUpdatesSOFT()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>alProcessUpdatesSOFT</h4>
<pre>public static void alProcessUpdatesSOFT()</pre>
<div class="block">Resumes updates.
<p>Once called, all pending deferred updates will be processed. Any following state changes will also apply as normal.</p></div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../index-all.html">Index</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../org/lwjgl/openal/SOFTBufferSubData.html" title="class in org.lwjgl.openal"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../org/lwjgl/openal/SOFTDirectChannels.html" title="class in org.lwjgl.openal"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/lwjgl/openal/SOFTDeferredUpdates.html" target="_top">Frames</a></li>
<li><a href="SOFTDeferredUpdates.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>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li><a href="#field_summary">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li><a href="#field_detail">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small><i>Copyright LWJGL. All Rights Reserved. <a href="http://lwjgl.org/license.php">License terms</a>.</i></small></p>
</body>
</html>
| TheOfficialSkara/Game-Engine | lib/LWJGL/doc/org/lwjgl/openal/SOFTDeferredUpdates.html | HTML | gpl-2.0 | 11,839 | [
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... |
from distutils.core import setup
setup(
# Application name:
name="streaker",
# Version number (initial):
version="0.0.1",
# Application author details:
author="Aldi Alimucaj",
author_email="aldi.alimucaj@gmail.com",
# Packages
packages=["streaker"],
scripts=['bin/streaker'],
# Include additional files into the package
include_package_data=True,
# Details
url="http://pypi.python.org/pypi/Streaker_v001/",
#
license="MIT",
description="GitHub streak manipulator",
# long_description=open("README.txt").read(),
# Dependent packages (distributions)
install_requires=[
# "",
],
)
| aldialimucaj/Streaker | setup.py | Python | mit | 680 | [
30522,
2013,
4487,
3367,
21823,
4877,
1012,
4563,
12324,
16437,
16437,
1006,
1001,
4646,
2171,
1024,
2171,
1027,
1000,
9039,
2121,
1000,
1010,
1001,
2544,
2193,
1006,
3988,
1007,
1024,
2544,
1027,
1000,
1014,
1012,
1014,
1012,
1015,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
module.exports = MnInputCustomElement()
function MnInputCustomElement() {
const supportsCustomElements = 'customElements' in window
if (!supportsCustomElements) {
require('@webcomponents/custom-elements')
}
if (!window.customElements.get('mn-input')) {
window.customElements.define('mn-input', require('./input.class.js'))
}
return window.customElements.get('mn-input')
}
| reserva-facil/minimalist | webcomponents/input/input.webcomponent.js | JavaScript | mit | 396 | [
30522,
11336,
1012,
14338,
1027,
24098,
2378,
18780,
7874,
20389,
12260,
3672,
1006,
1007,
3853,
24098,
2378,
18780,
7874,
20389,
12260,
3672,
1006,
1007,
1063,
9530,
3367,
6753,
7874,
20389,
12260,
8163,
1027,
1005,
7661,
12260,
8163,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FoodInventory.Data.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class FoodInventoryEntities : DbContext
{
public FoodInventoryEntities()
: base("name=FoodInventoryEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Product> Products { get; set; }
}
}
| ckoeber/foodinventory | FoodInventory.Data/Models/FoodInventory.Context.cs | C# | gpl-3.0 | 969 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>groupby - org.saddle.groupby</title>
<meta name="description" content="groupby - org.saddle.groupby" />
<meta name="keywords" content="groupby org.saddle.groupby" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="../../../lib/template.css" media="screen" type="text/css" rel="stylesheet" />
<link href="../../../lib/diagrams.css" media="screen" type="text/css" rel="stylesheet" id="diagrams-css" />
<script type="text/javascript">
if(top === self) {
var url = '../../../index.html';
var hash = 'org.saddle.groupby.package';
var anchor = window.location.hash;
var anchor_opt = '';
if (anchor.length >= 1)
anchor_opt = '@' + anchor.substring(1);
window.location.href = url + '#' + hash + anchor_opt;
}
</script>
</head>
<body class="value">
<div id="definition">
<img src="../../../lib/package_big.png" />
<p id="owner"><a href="../../package.html" class="extype" name="org">org</a>.<a href="../package.html" class="extype" name="org.saddle">saddle</a></p>
<h1>groupby</h1>
</div>
<h4 id="signature" class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">package</span>
</span>
<span class="symbol">
<span class="name">groupby</span>
</span>
</h4>
<div id="comment" class="fullcommenttop"></div>
<div id="mbrsel">
<div id="textfilter"><span class="pre"></span><span class="input"><input id="mbrsel-input" type="text" accesskey="/" /></span><span class="post"></span></div>
<div id="visbl">
<span class="filtertype">Visibility</span>
<ol><li class="public in"><span>Public</span></li><li class="all out"><span>All</span></li></ol>
</div>
</div>
<div id="template">
<div id="allMembers">
<div id="types" class="types members">
<h3>Type Members</h3>
<ol><li name="org.saddle.groupby.FrameGrouper" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="FrameGrouper[Z,X,Y,T]extendsAnyRef"></a>
<a id="FrameGrouper[Z,X,Y,T]:FrameGrouper[Z,X,Y,T]"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="FrameGrouper.html"><span class="name">FrameGrouper</span></a><span class="tparams">[<span name="Z">Z</span>, <span name="X">X</span>, <span name="Y">Y</span>, <span name="T">T</span>]</span><span class="result"> extends <span class="extype" name="scala.AnyRef">AnyRef</span></span>
</span>
</h4>
<p class="comment cmt">Helper class to do combine or transform after a groupBy
</p>
</li><li name="org.saddle.groupby.IndexGrouper" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="IndexGrouper[Y]extendsAnyRef"></a>
<a id="IndexGrouper[Y]:IndexGrouper[Y]"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="IndexGrouper.html"><span class="name">IndexGrouper</span></a><span class="tparams">[<span name="Y">Y</span>]</span><span class="result"> extends <span class="extype" name="scala.AnyRef">AnyRef</span></span>
</span>
</h4>
<p class="comment cmt">Creates groups for each unique key in an index
</p>
</li><li name="org.saddle.groupby.SeriesGrouper" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="SeriesGrouper[Y,X,T]extendsIndexGrouper[Y]"></a>
<a id="SeriesGrouper[Y,X,T]:SeriesGrouper[Y,X,T]"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="SeriesGrouper.html"><span class="name">SeriesGrouper</span></a><span class="tparams">[<span name="Y">Y</span>, <span name="X">X</span>, <span name="T">T</span>]</span><span class="result"> extends <a href="IndexGrouper.html" class="extype" name="org.saddle.groupby.IndexGrouper">IndexGrouper</a>[<span class="extype" name="org.saddle.groupby.SeriesGrouper.Y">Y</span>]</span>
</span>
</h4>
<p class="comment cmt">Helper class to do combine or transform after a groupBy
</p>
</li></ol>
</div>
<div id="values" class="values members">
<h3>Value Members</h3>
<ol><li name="org.saddle.groupby.FrameGrouper" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="FrameGrouper"></a>
<a id="FrameGrouper:FrameGrouper"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="FrameGrouper$.html"><span class="name">FrameGrouper</span></a>
</span>
</h4>
</li><li name="org.saddle.groupby.IndexGrouper" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="IndexGrouper"></a>
<a id="IndexGrouper:IndexGrouper"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="IndexGrouper$.html"><span class="name">IndexGrouper</span></a>
</span>
</h4>
</li><li name="org.saddle.groupby.SeriesGrouper" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="SeriesGrouper"></a>
<a id="SeriesGrouper:SeriesGrouper"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="SeriesGrouper$.html"><span class="name">SeriesGrouper</span></a>
</span>
</h4>
</li></ol>
</div>
</div>
<div id="inheritedMembers">
</div>
<div id="groupedMembers">
<div class="group" name="Ungrouped">
<h3>Ungrouped</h3>
</div>
</div>
</div>
<div id="tooltip"></div>
<div id="footer"> </div>
<script defer="defer" type="text/javascript" id="jquery-js" src="../../../lib/jquery.js"></script><script defer="defer" type="text/javascript" id="jquery-ui-js" src="../../../lib/jquery-ui.js"></script><script defer="defer" type="text/javascript" id="tools-tooltip-js" src="../../../lib/tools.tooltip.js"></script><script defer="defer" type="text/javascript" id="template-js" src="../../../lib/template.js"></script>
</body>
</html> | saddle/saddle | saddle-core/target/scala-2.10/api/org/saddle/groupby/package.html | HTML | apache-2.0 | 7,315 | [
30522,
1026,
1029,
20950,
2544,
1027,
1005,
1015,
1012,
1014,
1005,
17181,
1027,
1005,
21183,
2546,
1011,
1022,
1005,
1029,
1028,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* This file is part of the OpenPNE package.
* (c) OpenPNE Project (http://www.openpne.jp/)
*
* For the full copyright and license information, please view the LICENSE
* file and the NOTICE file that were distributed with this source code.
*/
/**
* csrfError action.
*
* @package OpenPNE
* @subpackage default
* @author Kousuke Ebihara <ebihara@tejimaya.com>
*/
class csrfErrorAction extends sfAction
{
public function execute($request)
{
}
}
| smart-e/lifemap | apps/pc_backend/modules/default/actions/csrfErrorAction.class.php | PHP | apache-2.0 | 507 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
1996,
2330,
2361,
2638,
7427,
1012,
1008,
1006,
1039,
1007,
2330,
2361,
2638,
2622,
1006,
8299,
1024,
1013,
1013,
7479,
1012,
2330,
2361,
2638,
1012,
16545,
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... |
# qingmq-broker
QingMQ Broker
| qingmq/qingmq-broker | README.md | Markdown | mit | 30 | [
30522,
1001,
13282,
2213,
4160,
1011,
20138,
13282,
2213,
4160,
20138,
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,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 statalign.base.hmm;
/**
* The abstract class of Hidden Markov Models.
*
* @author novak
*
*/
public abstract class Hmm {
/**
* HMM model parameters. Implementing classes can use their own assignment and
* any number of parameters.
* In the case of the TKF92 model (HmmTkf92), values are: r, lambda and mu.
*/
public double[] params;
/**
* Abstract function that specifies the emission of each state in the HMM in the form
* of an array A: A[s][i]=1 iff state i emits into sequence s (s=0 is the parent sequence;
* for pair-HMMs s=1 is the child sequence, for 3-seq HMMs s=1 is left and s=2 is right
* child).
* HMM implementations must override this and return their own emission patterns.
* @return array specifying emission patterns as described above
*/
public abstract int[][] getStateEmit();
/**
* Abstract function returning an array A that helps identify the state with some
* emission pattern. The emission pattern is coded as a single integer: e.g. for a 3-seq
* HMM, emission into the parent sequence and right child only is coded as 101 binary,
* i.e. 4+1=5. Then, A[5] gives the index of the state with the above emission pattern.
* HMM implementations must override this and return an array corresponding to their own
* state - emission pattern assignment.
* @return array describing the emission pattern to state conversion
*/
public abstract int[] getEmitPatt2State();
/**
* Returns the index of the start state.
*
* @return The index of the start state;
*/
public abstract int getStart();
/**
* Returns the index of the end state.
*
* @return The index of the end state;
*/
public abstract int getEnd();
/**
* Returns the logarithm of the stationary probability of generating
* a sequence of <code>length</code> characters under the HMM.
* @param length The length of the sequence whose stationary
* probability is to be computed.
* @return The logarithm of the stationary probability under the HMM.
*/
public double getLogStationaryProb(int length) { return 0.0; }
}
| statalign/statalign | src/statalign/base/hmm/Hmm.java | Java | gpl-3.0 | 2,170 | [
30522,
7427,
28093,
11475,
16206,
1012,
2918,
1012,
17012,
1025,
1013,
1008,
1008,
1008,
1996,
10061,
2465,
1997,
5023,
28003,
2615,
4275,
1012,
1008,
1008,
1030,
3166,
19580,
1008,
1008,
1013,
2270,
10061,
2465,
17012,
1063,
1013,
1008,
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... |
<div>
<nav>
<ul id="menu">
{% for m in menu %}
<li>
{% if m.subsistemas %}
{{ m.nombreDireccion }}
<ul>
{% for submenu in m.subsistemas %}
<li>
<a href="{{submenu.target}}">{{ submenu.nombreSistema }}</a>
</li>
{% endfor %}
</ul>
{% else %}
<a href="{{m.target}}"> {{ m.nombreDireccion }}</a>
{% endif%}
</li>
{% endfor %}
<li>
{% firstof user.get_short_name user.get_username %}
<a href="{% url 'logout_view' %}" id="logout">Cerrar sesion</a>
</li>
</ul>
</nav>
</br> </br> </br>
</div>
| mmanto/sstuv | secur/templates/menu.html | HTML | gpl-3.0 | 669 | [
30522,
1026,
4487,
2615,
1028,
1026,
6583,
2615,
1028,
1026,
17359,
8909,
1027,
1000,
12183,
1000,
1028,
1063,
1003,
2005,
1049,
1999,
12183,
1003,
1065,
1026,
5622,
1028,
1063,
1003,
2065,
1049,
1012,
4942,
6190,
18532,
3022,
1003,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.authority.indexer;
import org.apache.log4j.Logger;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.core.Context;
import org.dspace.event.Consumer;
import org.dspace.event.Event;
import java.util.HashSet;
import java.util.Set;
/**
* Consumer that takes care of the indexing of authority controlled metadata fields for installed/updated items
*
* @author Antoine Snyers (antoine at atmire.com)
* @author Kevin Van de Velde (kevin at atmire dot com)
* @author Ben Bosman (ben at atmire dot com)
* @author Mark Diggory (markd at atmire dot com)
*/
public class AuthorityConsumer implements Consumer {
private static final Logger log = Logger.getLogger(AuthorityConsumer.class);
/** A set of all item IDs installed which need their authority updated **/
private Set<Integer> itemsToUpdateAuthority = null;
/** A set of item IDs who's metadata needs to be reindexed **/
private Set<Integer> itemsToReindex = null;
public void initialize() throws Exception {
}
public void consume(Context ctx, Event event) throws Exception {
if(itemsToUpdateAuthority == null){
itemsToUpdateAuthority = new HashSet<Integer>();
itemsToReindex = new HashSet<Integer>();
}
DSpaceObject dso = event.getSubject(ctx);
if(dso instanceof Item){
Item item = (Item) dso;
if(item.isArchived()){
if(!itemsToReindex.contains(item.getID()))
itemsToReindex.add(item.getID());
}
if(("ARCHIVED: " + true).equals(event.getDetail())){
itemsToUpdateAuthority.add(item.getID());
}
}
}
public void end(Context ctx) throws Exception {
if(itemsToUpdateAuthority == null)
return;
try{
ctx.turnOffAuthorisationSystem();
for (Integer id : itemsToUpdateAuthority) {
Item item = Item.find(ctx, id);
AuthorityIndexClient.indexItem(ctx, item);
}
//Loop over our items which need to be re indexed
for (Integer id : itemsToReindex) {
Item item = Item.find(ctx, id);
AuthorityIndexClient.indexItem(ctx, item);
}
} catch (Exception e){
log.error("Error while consuming the authority consumer", e);
} finally {
itemsToUpdateAuthority = null;
itemsToReindex = null;
ctx.restoreAuthSystemState();
}
}
public void finish(Context ctx) throws Exception {
}
}
| rnathanday/dryad-repo | dspace-api/src/main/java/org/dspace/authority/indexer/AuthorityConsumer.java | Java | bsd-3-clause | 2,863 | [
30522,
1013,
1008,
1008,
1008,
1996,
8417,
1997,
2023,
5371,
2024,
3395,
2000,
1996,
6105,
1998,
9385,
1008,
6851,
1999,
1996,
6105,
1998,
5060,
6764,
2012,
1996,
7117,
1997,
1996,
3120,
1008,
3392,
1998,
2800,
3784,
2012,
1008,
1008,
829... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import uuid
from django.db import models
from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.models import BaseUserManager
from django.utils import timezone
from accelerator_abstract.models import BaseUserRole
from accelerator_abstract.models.base_base_profile import EXPERT_USER_TYPE
MAX_USERNAME_LENGTH = 30
class UserManager(BaseUserManager):
use_in_migrations = True
def _create_user(self, email, password,
is_staff, is_superuser, **extra_fields):
"""
Creates and saves an User with the given email and password.
"""
now = timezone.now()
if not email:
raise ValueError('An email address must be provided.')
email = self.normalize_email(email)
if "is_active" not in extra_fields:
extra_fields["is_active"] = True
if "username" not in extra_fields:
# For now we need to have a unique id that is at
# most 30 characters long. Using uuid and truncating.
# Ideally username goes away entirely at some point
# since we're really using email. If we have to keep
# username for some reason then we could switch over
# to a string version of the pk which is guaranteed
# be unique.
extra_fields["username"] = str(uuid.uuid4())[:MAX_USERNAME_LENGTH]
user = self.model(email=email,
is_staff=is_staff,
is_superuser=is_superuser,
last_login=None,
date_joined=now,
**extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
def create_user(self, email=None, password=None, **extra_fields):
return self._create_user(email, password, False, False,
**extra_fields)
def create_superuser(self, email, password, **extra_fields):
return self._create_user(email, password, True, True,
**extra_fields)
class User(AbstractUser):
# Override the parent email field to add uniqueness constraint
email = models.EmailField(blank=True, unique=True)
objects = UserManager()
class Meta:
db_table = 'auth_user'
managed = settings.ACCELERATOR_MODELS_ARE_MANAGED
def __init__(self, *args, **kwargs):
super(User, self).__init__(*args, **kwargs)
self.startup = None
self.team_member = None
self.profile = None
self.user_finalist_roles = None
class AuthenticationException(Exception):
pass
def __str__(self):
return self.email
def full_name(self):
fn = self.first_name
ln = self.last_name
if fn and ln:
name = u"%s %s" % (fn, ln)
else:
name = str(self.email)
return name
def user_phone(self):
return self._get_profile().phone
def image_url(self):
return self._get_profile().image_url()
def team_member_id(self):
return self.team_member.id if self._get_member() else ''
def user_title(self):
return self._get_title_and_company()['title']
def user_twitter_handle(self):
return self._get_profile().twitter_handle
def user_linked_in_url(self):
return self._get_profile().linked_in_url
def user_facebook_url(self):
return self._get_profile().facebook_url
def user_personal_website_url(self):
return self._get_profile().personal_website_url
def type(self):
return self._get_profile().user_type
def startup_name(self):
return self._get_title_and_company()['company']
def _get_title_and_company(self):
if self._is_expert() and self._has_expert_details():
profile = self._get_profile()
title = profile.title
company = profile.company
return {
"title": title,
"company": company
}
self._get_member()
title = self.team_member.title if self.team_member else ""
company = self.startup.name if self._get_startup() else None
return {
"title": title,
"company": company
}
def _has_expert_details(self):
if self._is_expert():
profile = self._get_profile()
return True if profile.title or profile.company else False
def startup_industry(self):
return self.startup.primary_industry if self._get_startup() else None
def top_level_startup_industry(self):
industry = (
self.startup.primary_industry if self._get_startup() else None)
return industry.parent if industry and industry.parent else industry
def startup_status_names(self):
if self._get_startup():
return [startup_status.program_startup_status.startup_status
for startup_status in self.startup.startupstatus_set.all()]
def finalist_user_roles(self):
if not self.user_finalist_roles:
finalist_roles = BaseUserRole.FINALIST_USER_ROLES
self.user_finalist_roles = self.programrolegrant_set.filter(
program_role__user_role__name__in=finalist_roles
).values_list('program_role__name', flat=True).distinct()
return list(self.user_finalist_roles)
def program(self):
return self.startup.current_program() if self._get_startup() else None
def location(self):
program = self.program()
return program.program_family.name if program else None
def year(self):
program = self.program()
return program.start_date.year if program else None
def is_team_member(self):
return True if self._get_member() else False
def _get_startup(self):
if not self.startup:
self._get_member()
if self.team_member:
self.startup = self.team_member.startup
return self.startup
def _get_member(self):
if not self.team_member:
self.team_member = self.startupteammember_set.last()
return self.team_member
def _get_profile(self):
if self.profile:
return self.profile
self.profile = self.get_profile()
return self.profile
def has_a_finalist_role(self):
return len(self.finalist_user_roles()) > 0
def _is_expert(self):
profile = self._get_profile()
return profile.user_type == EXPERT_USER_TYPE.lower()
| masschallenge/django-accelerator | simpleuser/models.py | Python | mit | 6,632 | [
30522,
12324,
1057,
21272,
2013,
6520,
23422,
1012,
16962,
12324,
4275,
2013,
6520,
23422,
1012,
9530,
2546,
12324,
10906,
2013,
6520,
23422,
1012,
9530,
18886,
2497,
1012,
8740,
2705,
1012,
4275,
12324,
10061,
20330,
2013,
6520,
23422,
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... |
/*
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
* From ASN.1 module "EUTRA-RRC-Definitions"
* found in "36331-ac0.asn"
* `asn1c -S /home/nyee/srsLTE/srslte/examples/src/asn1c/skeletons -fcompound-names -fskeletons-copy -gen-PER -pdu=auto`
*/
#ifndef _SPS_ConfigDL_H_
#define _SPS_ConfigDL_H_
#include <asn_application.h>
/* Including external dependencies */
#include <NULL.h>
#include <NativeEnumerated.h>
#include <NativeInteger.h>
#include "N1PUCCH-AN-PersistentList.h"
#include <constr_SEQUENCE.h>
#include <constr_CHOICE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum SPS_ConfigDL_PR {
SPS_ConfigDL_PR_NOTHING, /* No components present */
SPS_ConfigDL_PR_release,
SPS_ConfigDL_PR_setup
} SPS_ConfigDL_PR;
typedef enum SPS_ConfigDL__setup__semiPersistSchedIntervalDL {
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf10 = 0,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf20 = 1,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf32 = 2,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf40 = 3,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf64 = 4,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf80 = 5,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf128 = 6,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf160 = 7,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf320 = 8,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_sf640 = 9,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_spare6 = 10,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_spare5 = 11,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_spare4 = 12,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_spare3 = 13,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_spare2 = 14,
SPS_ConfigDL__setup__semiPersistSchedIntervalDL_spare1 = 15
} e_SPS_ConfigDL__setup__semiPersistSchedIntervalDL;
typedef enum SPS_ConfigDL__setup__twoAntennaPortActivated_r10_PR {
SPS_ConfigDL__setup__twoAntennaPortActivated_r10_PR_NOTHING, /* No components present */
SPS_ConfigDL__setup__twoAntennaPortActivated_r10_PR_release,
SPS_ConfigDL__setup__twoAntennaPortActivated_r10_PR_setup
} SPS_ConfigDL__setup__twoAntennaPortActivated_r10_PR;
/* SPS-ConfigDL */
typedef struct SPS_ConfigDL {
SPS_ConfigDL_PR present;
union SPS_ConfigDL_u {
NULL_t release;
struct SPS_ConfigDL__setup {
long semiPersistSchedIntervalDL;
long numberOfConfSPS_Processes;
N1PUCCH_AN_PersistentList_t n1PUCCH_AN_PersistentList;
/*
* This type is extensible,
* possible extensions are below.
*/
struct SPS_ConfigDL__setup__twoAntennaPortActivated_r10 {
SPS_ConfigDL__setup__twoAntennaPortActivated_r10_PR present;
union SPS_ConfigDL__setup__twoAntennaPortActivated_r10_u {
NULL_t release;
struct SPS_ConfigDL__setup__twoAntennaPortActivated_r10__setup {
N1PUCCH_AN_PersistentList_t n1PUCCH_AN_PersistentListP1_r10;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} setup;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} *twoAntennaPortActivated_r10;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} setup;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} SPS_ConfigDL_t;
/* Implementation */
/* extern asn_TYPE_descriptor_t asn_DEF_semiPersistSchedIntervalDL_4; // (Use -fall-defs-global to expose) */
extern asn_TYPE_descriptor_t asn_DEF_SPS_ConfigDL;
#ifdef __cplusplus
}
#endif
#endif /* _SPS_ConfigDL_H_ */
#include <asn_internal.h>
| nyee32/Senior_Project | lte/SPS-ConfigDL.h | C | agpl-3.0 | 3,619 | [
30522,
1013,
1008,
1008,
7013,
2011,
2004,
2078,
2487,
2278,
1011,
1014,
1012,
1023,
1012,
2654,
1006,
8299,
1024,
1013,
1013,
7006,
3388,
1012,
18558,
1013,
2004,
2078,
2487,
2278,
1007,
1008,
2013,
2004,
2078,
1012,
1015,
11336,
1000,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2006-2011 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2011 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
* OpenNMS(R) 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.
*
* OpenNMS(R) 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 OpenNMS(R). If not, see:
* http://www.gnu.org/licenses/
*
* For more information contact:
* OpenNMS(R) Licensing <license@opennms.org>
* http://www.opennms.org/
* http://www.opennms.com/
*******************************************************************************/
package org.opennms.protocols.jmx.connectors;
import javax.management.MBeanServerConnection;
/*
* This interface defines the ability to handle a live connection and the ability to
* close it.
*
* @author <A HREF="mailto:mike@opennms.org">Mike Jamison </A>
* @author <A HREF="http://www.opennms.org/">OpenNMS </A>
*/
/**
* <p>ConnectionWrapper interface.</p>
*
* @author ranger
* @version $Id: $
*/
public interface ConnectionWrapper {
/**
* <p>getMBeanServer</p>
*
* @return a {@link javax.management.MBeanServerConnection} object.
*/
public MBeanServerConnection getMBeanServer();
/**
* <p>close</p>
*/
public void close();
}
| tharindum/opennms_dashboard | opennms-services/src/main/java/org/opennms/protocols/jmx/connectors/ConnectionWrapper.java | Java | gpl-2.0 | 1,879 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (C) 2011 Whisper Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.smssecure.smssecure.recipients;
import android.content.Context;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import org.smssecure.smssecure.contacts.avatars.ContactPhotoFactory;
import org.smssecure.smssecure.database.CanonicalAddressDatabase;
import org.smssecure.smssecure.util.Util;
import org.whispersystems.libaxolotl.util.guava.Optional;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
public class RecipientFactory {
private static final RecipientProvider provider = new RecipientProvider();
public static Recipients getRecipientsForIds(Context context, String recipientIds, boolean asynchronous) {
if (TextUtils.isEmpty(recipientIds))
return new Recipients();
return getRecipientsForIds(context, Util.split(recipientIds, " "), asynchronous);
}
public static Recipients getRecipientsFor(Context context, List<Recipient> recipients, boolean asynchronous) {
long[] ids = new long[recipients.size()];
int i = 0;
for (Recipient recipient : recipients) {
ids[i++] = recipient.getRecipientId();
}
return provider.getRecipients(context, ids, asynchronous);
}
public static Recipients getRecipientsFor(Context context, Recipient recipient, boolean asynchronous) {
long[] ids = new long[1];
ids[0] = recipient.getRecipientId();
return provider.getRecipients(context, ids, asynchronous);
}
public static Recipient getRecipientForId(Context context, long recipientId, boolean asynchronous) {
return provider.getRecipient(context, recipientId, asynchronous);
}
public static Recipients getRecipientsForIds(Context context, long[] recipientIds, boolean asynchronous) {
return provider.getRecipients(context, recipientIds, asynchronous);
}
public static Recipients getRecipientsFromString(Context context, @NonNull String rawText, boolean asynchronous) {
StringTokenizer tokenizer = new StringTokenizer(rawText, ",");
List<String> ids = new LinkedList<>();
while (tokenizer.hasMoreTokens()) {
Optional<Long> id = getRecipientIdFromNumber(context, tokenizer.nextToken());
if (id.isPresent()) {
ids.add(String.valueOf(id.get()));
}
}
return getRecipientsForIds(context, ids, asynchronous);
}
private static Recipients getRecipientsForIds(Context context, List<String> idStrings, boolean asynchronous) {
long[] ids = new long[idStrings.size()];
int i = 0;
for (String id : idStrings) {
ids[i++] = Long.parseLong(id);
}
return provider.getRecipients(context, ids, asynchronous);
}
private static Optional<Long> getRecipientIdFromNumber(Context context, String number) {
number = number.trim();
if (number.isEmpty()) return Optional.absent();
if (hasBracketedNumber(number)) {
number = parseBracketedNumber(number);
}
return Optional.of(CanonicalAddressDatabase.getInstance(context).getCanonicalAddressId(number));
}
private static boolean hasBracketedNumber(String recipient) {
int openBracketIndex = recipient.indexOf('<');
return (openBracketIndex != -1) &&
(recipient.indexOf('>', openBracketIndex) != -1);
}
private static String parseBracketedNumber(String recipient) {
int begin = recipient.indexOf('<');
int end = recipient.indexOf('>', begin);
String value = recipient.substring(begin + 1, end);
return value;
}
public static void clearCache() {
provider.clearCache();
}
}
| matlink/SMSSecure | src/org/smssecure/smssecure/recipients/RecipientFactory.java | Java | gpl-3.0 | 4,267 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2249,
7204,
3001,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
30524,
2030,
1008,
1006,
2012,
2115,
5724,
1007,
2151,
2101,
2544,
1012,
1008,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 1999-2017 YaoTrue.
*
* 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.yaotrue.web.command;
import java.io.Serializable;
/**
* @author <a href="mailto:yaotrue@163.com">yaotrue</a>
* 2017年8月16日 下午9:15:05
*/
public class BaseCommand implements Serializable {
/**
* <code>{@value}</code>
*/
private static final long serialVersionUID = 6878114738264710696L;
}
| yaotrue/learn-parent | learn-lang/src/main/java/com/yaotrue/web/command/BaseCommand.java | Java | apache-2.0 | 950 | [
30522,
1013,
1008,
1008,
9385,
2639,
1011,
2418,
23711,
16344,
5657,
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,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>
table.head, table.foot { width: 100%; }
td.head-rtitle, td.foot-os { text-align: right; }
td.head-vol { text-align: center; }
table.foot td { width: 50%; }
table.head td { width: 33%; }
div.spacer { margin: 1em 0; }
</style>
<title>
Mono(MakeCert)</title>
</head>
<body>
<div class="mandoc">
<table class="head">
<tbody>
<tr>
<td class="head-ltitle">
Mono(MakeCert)</td>
<td class="head-vol">
</td>
<td class="head-rtitle">
Mono(MakeCert)</td>
</tr>
</tbody>
</table>
<div class="section">
<h1>NAME</h1> MakeCert - Create X.509 certificates for test purposes</div>
<div class="section">
<h1>SYNOPSIS</h1> <b>makecert [options] certificate</b></div>
<div class="section">
<h1>DESCRIPTION</h1> Create an X.509 certificate using the provided informations. This is useful for testing Authenticode signatures, SSL and S/MIME technologies.</div>
<div class="section">
<h1>PARAMETERS</h1><dl>
<dt>
<i>-# num</i></dt>
<dd>
Specify the certificate serial number.</dd>
</dl>
<dl>
<dt>
<i>-n dn</i></dt>
<dd>
Specify the subject Distinguished Name (DN).</dd>
</dl>
<dl>
<dt>
<i>-in dn</i></dt>
<dd>
Specify the issuer Distinguished Name (DN).</dd>
</dl>
<dl>
<dt>
<i>-r</i></dt>
<dd>
Create a self-signed, also called root, certificate.</dd>
</dl>
<dl>
<dt>
<i>-iv pvkfile</i></dt>
<dd>
Specify the private key file (.PVK) for the issuer. The private key in the specified file will be used to sign the new certificate.</dd>
</dl>
<dl>
<dt>
<i>-ic certfile</i></dt>
<dd>
Extract the issuer's name from the specified certificate file - i.e. the subject name of the specified certificate becomes the issuer name of the new certificate.</dd>
</dl>
<dl>
<dt>
<i>-in name</i></dt>
<dd>
Use the issuer's name from the specified parameter.</dd>
</dl>
<dl>
<dt>
<i>-ik container</i></dt>
<dd>
Specify the key container name to be used for the issuer.</dd>
</dl>
<dl>
<dt>
<i>-iky [signature | exchange | #]</i></dt>
<dd>
Specify the key number to be used in the provider (when used with -ik).</dd>
</dl>
<dl>
<dt>
<i>-ip provider</i></dt>
<dd>
Specify the cryptographic provider to be used for the issuer.</dd>
</dl>
<dl>
<dt>
<i>-ir [localmachine | currentuser]</i></dt>
<dd>
Specify the provider will search the user or the machine keys containers for the issuer.</dd>
</dl>
<dl>
<dt>
<i>-iy number</i></dt>
<dd>
Specify the provider type to be used for the issuer.</dd>
</dl>
<dl>
<dt>
<i>-sv pkvfile</i></dt>
<dd>
Specify the private key file (.PVK) for the subject. The public part of the key will be inserted into the created certificate. If non-existant the specified file will be created with a new key pair (default to 1024 bits RSA key pair).</dd>
</dl>
<dl>
<dt>
<i>-sk container</i></dt>
<dd>
Specify the key container name to be used for the subject.</dd>
</dl>
<dl>
<dt>
<i>-sky [signature | exchange | #]</i></dt>
<dd>
Specify the key number to be used in the provider (when used with -sk).</dd>
</dl>
<dl>
<dt>
<i>-sp provider</i></dt>
<dd>
Specify the cryptographic provider to be used for the subject.</dd>
</dl>
<dl>
<dt>
<i>-sr [localmachine | currentuser]</i></dt>
<dd>
Specify the provider will search the user or the machine keys containers for the subject.</dd>
</dl>
<dl>
<dt>
<i>-sy number</i></dt>
<dd>
Specify the provider type to be used for the issuer.</dd>
</dl>
<dl>
<dt>
<i>-a hash</i></dt>
<dd>
Select hash algorithm. Only MD5 and SHA1 algorithms are supported.</dd>
</dl>
<dl>
<dt>
<i>-b date</i></dt>
<dd>
The date since when the certificate is valid (notBefore).</dd>
</dl>
<dl>
<dt>
<i>-e date</i></dt>
<dd>
The date until when the certificate is valid (notAfter).</dd>
</dl>
<dl>
<dt>
<i>-m number</i></dt>
<dd>
Specify the certificate validity period in months. This is added to the notBefore validity date which can be set with -b or will default to the current date/time.</dd>
</dl>
<dl>
<dt>
<i>-cy [authority|end]</i></dt>
<dd>
Basic constraints. Select Authority or End-Entity certificate. Only Authority certificates can be used to sign other certificates (-ic). End-Entity can be used by clients (e.g. Authenticode, S/MIME) or servers (e.g. SSL).</dd>
</dl>
<dl>
<dt>
<i>-h number</i></dt>
<dd>
Add a path length restriction to the certificate chain. This is only applicable for certificates that have BasicConstraint set to Authority (-cy authority). This is used to limit the chain of certificates than can be issued under this authority.</dd>
</dl>
<dl>
<dt>
<i>-alt filename</i></dt>
<dd>
Add a subjectAltName extension to the certificate. Each line from 'filename' will be added as a DNS entry of the extension. This option is useful if you want to create a single SSL certificate to work on several hosts that do not share a common domain name (i.e. CN=*.domain.com would not work).</dd>
</dl>
<dl>
<dt>
<i>-eku oid[,oid]</i></dt>
<dd>
Add some extended key usage OID to the certificate.</dd>
</dl>
<dl>
<dt>
<i>-p12 pkcs12file password</i></dt>
<dd>
Create a new PKCS#12 file containing both the certificates (the subject and possibly the issuer's) and the private key. The PKCS#12 file is protected with the specified password. This option is <b>mono exclusive.</b></dd>
</dl>
<dl>
<dt>
<i>-?</i></dt>
<dd>
Help (display this help message)</dd>
</dl>
<dl>
<dt>
<i>-!</i></dt>
<dd>
Extended help (for advanced options)</dd>
</dl>
</div>
<div class="section">
<h1>EXAMPLES</h1> To create a SSL test (i.e. non trusted) certificate is easy once your know your host's name. The following command will create a test certificate for an SSL server:<br/>
$ hostname <br/>
pollux<div class="spacer">
</div>
<br/>
$ makecert -r -eku 1.3.6.1.5.5.7.3.1 -n "CN=pollux" -sv pollux.pvk pollux.cer<br/>
Success<br/>
<div class="spacer">
</div>
In particular in the above example, the parameters used to build this test certificate were:<dl>
<dt>
<i>-r</i></dt>
<dd>
Create a self-signed certificate (i.e. without an hierarchy).</dd>
</dl>
<dl>
<dt>
<i>-eku 1.3.6.1.5.5.7.3.1</i></dt>
<dd>
Optional (as sadly most client don't require it). This indicates that your certificate is intended for server-side authentication.</dd>
</dl>
<dl>
<dt>
<i>-n</i></dt>
<dd>
Common Name (CN) = Host name. This is verified the SSL client and must match the connected host (or else you'll get a warning or error or *gasp* nothing).</dd>
</dl>
<dl>
<dt>
<i>-sv private.key</i></dt>
<dd>
The private key file. The key (1024 bits RSA key pair) will be automatically generated if the specified file isn't present.</dd>
</dl>
<dl>
<dt>
<i>pollux.cer</i></dt>
<dd>
The SSL certificate to be created for your host.</dd>
</dl>
</div>
<div class="section">
<h1>KNOWN RESTRICTIONS</h1> Compared to the Windows version some options aren't supported (-$, -d, -l, -nscp, -is, -sc, -ss). Also PVK files with passwords aren't supported.</div>
<div class="section">
<h1>AUTHOR</h1> Written by Sebastien Pouliot</div>
<div class="section">
<h1>COPYRIGHT</h1> Copyright (C) 2003 Motus Technologies. Copyright (C) 2004-2005 Novell. Released under BSD license.</div>
<div class="section">
<h1>MAILING LISTS</h1> Visit http://lists.ximian.com/mailman/listinfo/mono-devel-list for details.</div>
<div class="section">
<h1>WEB SITE</h1> Visit http://www.mono-project.com for details</div>
<div class="section">
<h1>SEE ALSO</h1> <b>signcode(1)</b></div>
<table class="foot">
<tr>
<td class="foot-date">
</td>
<td class="foot-os">
</td>
</tr>
</table>
</div>
</body>
</html>
| fusion809/fusion809.github.io-old | man/makecert.1.html | HTML | gpl-3.0 | 7,430 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1013,
1028,
1026,
2806,
1028,
2795,
1012,
2132,
1010,
2795,
1012,
3329,
1063,
9381,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.